コード例 #1
0
                if ($help_plausi_failed) {
                    echo '<div id="' . $element_widget_warning . '" class="error" ><p><b>Code did not pass the plausibility check. Please review your code!</b> <br><i>(' . $help_plausi_failed . ')</i></p></div>';
                }
                $cache_widget = array();
            }
        }
    }
}
$backup_available = MCW_get_widget_backup();
//print_r($backup_available);
$backup_available = !empty($backup_available[0]);
$javascript_is_allowed = MCW_get_option('allow_js');
if (empty($cache_widget)) {
    $cache_widget['filter'] = array('all' => 1);
    //hopefully filter "all" does exist
    $cache_widget['kind'] = MCW_get_option('std_kind');
}
?>


<!-- display existing widgets -->

<?php 
if ($javascript_is_allowed) {
    echo '<script type="text/javascript" src="' . MCW_get_url('js_1') . '"></script>';
    echo '<script type="text/javascript" src="' . MCW_get_url('js_2') . '"></script>';
    echo '<script type="text/javascript" src="' . MCW_get_url('js_tooltip') . '"></script>';
    // thanks to http://www.walterzorn.de/tooltip/tooltip.htm
    ?>

<script type="text/javascript">
コード例 #2
0
function MCW_plugin_init()
{
    if (!function_exists('register_widget')) {
        return;
    }
    /******************************/
    /*** deinstallation routine ***/
    /******************************/
    function MCW_deinstall()
    {
        global $mcw_prefix;
        global $mcw_widgetsoption;
        global $mcw_configoption;
        global $mcw_metaoption;
        global $mcw_backup_postfix;
        delete_option($mcw_prefix . $mcw_metaoption);
        //delete all productive data
        $all_widget_IDs = get_option($mcw_prefix . $mcw_widgetsoption);
        $max = count($all_widget_IDs);
        for ($i = 0; $i < $max; ++$i) {
            delete_option($mcw_prefix . 'w_' . $all_widget_IDs[$i]['name']);
        }
        delete_option($mcw_prefix . $mcw_widgetsoption);
        delete_option($mcw_prefix . $mcw_configoption);
        //delete all backup data
        $all_backup_widget_IDs = get_option($mcw_prefix . $mcw_widgetsoption . $mcw_backup_postfix);
        $max = count($all_backup_widget_IDs);
        for ($i = 0; $i < $max; ++$i) {
            delete_option($mcw_prefix . $mcw_backup_postfix . 'w_' . $all_backup_widget_IDs[$i]['name']);
        }
        delete_option($mcw_prefix . $mcw_widgetsoption . $mcw_backup_postfix);
        delete_option($mcw_prefix . $mcw_configoption . $mcw_backup_postfix);
    }
    /************************************/
    /***     initialize widgets       ***/
    /************************************/
    $myWidget_IDs_all = MCW_get_all_widget_IDs();
    $maxindex = count($myWidget_IDs_all);
    // Register widgets
    if (!empty($myWidget_IDs_all)) {
        if (MCW_generaterequired() == true) {
            echo MCW_generate_class();
        }
        //include_once( "my_custom_widget_classes.php" );
        global $mcw_path;
        include_once $mcw_path["include_class"];
        $tag = MCW_get_option('outfilter');
        add_filter($tag, MCW_make_available_outside);
    }
    /*************************************************************************/
    /***  single widget-implementation as it has to be according to WP 2.8 ***/
    /*************************************************************************/
    include_once "my_custom_widget_addon.php";
}
コード例 #3
0
function MCW_generate_class_content($mcwname)
{
    //convert widget-name into class-name
    $classname = 'MCW_' . MCW_make_name_acceptable($mcwname);
    $classname = eregi_replace('-', '_', $classname);
    MCW_logfile('widgetname "' . $mcwname . '" converted into classname "' . $classname . '"');
    $res = "<?" . "php";
    $res = $res . "\n" . "class " . $classname . " extends WP_Widget";
    $res = $res . "\n" . "{";
    $res = $res . "\n" . "\tfunction " . $classname . "(){";
    $res = $res . "\n" . "\t\t\$" . "widget_ops = array('classname' => '" . $classname . "', 'description' => 'CustomWidget generated with MCW &raquo;' );";
    $max_width = MCW_get_option('filter_width') * 4 + 30 + 15;
    //4*filters+margin+padding+"IE-bug"
    $res = $res . "\n" . "\t\t\$" . "control_ops = array('width' => " . $max_width . ");";
    $res = $res . "\n" . "\t\t\$" . "this->WP_Widget('" . $classname . "', 'MCW: " . $mcwname . "', \$" . "widget_ops, \$" . "control_ops);";
    $res = $res . "\n" . "\t}";
    $res = $res . "\n" . "\tfunction widget(\$" . "args, \$" . "instance){";
    $res = $res . "\n" . "\t\t\$" . "args['name'] = '" . $mcwname . "';";
    $res = $res . "\n" . "\t\tMCW_eval_code(\$" . "args);";
    $res = $res . "\n" . "\t}";
    $res = $res . "\n" . "\tfunction update(\$" . "new_instance, \$" . "old_instance){";
    $res = $res . "\n" . "\t  \$" . "new_instance['title'] = MCW_get_widget_info('" . $mcwname . "', 'title');";
    $res = $res . "\n" . "\t\treturn \$" . "new_instance;";
    $res = $res . "\n" . "\t}";
    $res = $res . "\n" . "\tfunction form(\$" . "instance){";
    $res = $res . "\n" . "    MCW_get_official_form('" . $mcwname . "');\t  ";
    $res = $res . "\n" . "  }";
    $res = $res . "\n" . "}";
    $res = $res . "\n" . "\tfunction " . $classname . "Init() {";
    $res = $res . "\n" . "\t  register_widget('" . $classname . "');";
    $res = $res . "\n" . "\t}";
    $res = $res . "\n" . "\tadd_action('widgets_init', '" . $classname . "Init');";
    $res = $res . "\n" . "?" . ">";
    return $res;
}
コード例 #4
0
 /**
  * Creates the edit form for the widget.
  *
  */
 function form($instance)
 {
     global $mcw_prefix;
     global $mcw_path;
     //if (!empty($instance)){
     include_once MCW_get_url('style');
     //}
     //Defaults
     $defaults = MCW_get_default_options();
     $instance = wp_parse_args((array) $instance, array('title' => '', 'kind' => $defaults['std_kind'], 'name' => $this->id, 'filter-all' => 1));
     $title = htmlspecialchars($instance['title']);
     echo '<div class="mcw-row-"><label for="' . $this->get_field_name('title') . '"><input type="text" id="' . $this->get_field_id('title') . '" name="' . $this->get_field_name('title') . '" value="' . $title . '" size="13" ></label></div>';
     echo '<div class="mcw-row-small"><nobr><label for="' . $this->get_field_name('kind') . '_php"><input type="radio" id="' . $this->get_field_id('kind') . '_php" name="' . $this->get_field_name('kind') . '" value="php" checked="checked"> PHP</label></nobr>';
     echo '<nobr><label for="' . $this->get_field_name('kind') . '_html"><input type="radio" id="' . $this->get_field_id('kind') . '_html" name="' . $this->get_field_name('kind') . '" value="html"' . MCW_check($instance['kind'], "html") . '> HTML</label></nobr></div><br>';
     //echo '<div class="mcw-row">'.MCW_get_input_code($instance, $this).'</div>';
     echo '<div class="mcw-row"><textarea cols="60" id="' . $this->get_field_id('code') . '" name="' . $this->get_field_name('code') . '" style="height:' . MCW_get_option('code_height') . 'px; font-family:Courier, Monaco, monospace;" >' . stripslashes($instance["code"]) . '</textarea><br></div>';
     //echo '<div class="mcw-row-small">'.MCW_get_input_filters($instance, $this).'</div>';
     $myfilteroptions = MCW_get_option('filters');
     // get all filters
     if (empty($myfilteroptions)) {
         $myfilteroptions = array('all' => '1');
     }
     $max = count($myfilteroptions);
     echo '<div class="mcw-row-small">';
     for ($i = 0; $i < $max; ++$i) {
         echo '<nobr><label for="' . $this->get_field_id('filter' . '-' . $myfilteroptions[$i][0]) . '">';
         echo '<input type="checkbox" id="' . $this->get_field_id('filter' . '-' . $myfilteroptions[$i][0]) . '" name="' . $this->get_field_name('filter' . '-' . $myfilteroptions[$i][0]) . '" value="1" ';
         echo MCW_check($instance['filter-' . $myfilteroptions[$i][0]], "1");
         //active or not
         echo '> ' . $myfilteroptions[$i][0] . ' </label></nobr>';
     }
     echo '</div>';
 }
コード例 #5
0
   <?php 
         }
     }
 } else {
     if ($_POST[$button_name_submit . '_add'] == $button_text_add) {
         //add filter
         $cache_filters = MCW_get_all_filters();
         if ($add_cache[0] == "" || $add_cache[1] == "") {
             echo '<div class="error"><p><b>Please enter a name and a check to create a new filter!</b></p></div>';
         } else {
             if (MCW_filter_already_exist($add_cache[0])) {
                 echo '<div class="error"><p><b>Filter "' . $add_cache[0] . '" allready exists!</b></p></div>';
             } else {
                 $cache_filters[] = $add_cache;
                 MCW_set_filters($cache_filters);
                 $cache_options = MCW_get_option();
                 ?>
   <div id="message" class="updated fade">
     <p>
       <strong>
         <?php 
                 echo 'Filter "' . $add_cache[0] . '" added';
                 ?>
       </strong>
     </p>
   </div>
   <?php 
                 $add_cache = array();
             }
         }
     }