Exemplo n.º 1
0
    /**
     * @desc Output of plugin?s editform in te adminarea
     * @author Georg Leciejewski
     */
    function widget_king_rss_control($number)
    {
        # Get our options and see if we're handling a form submission.
        $options = $newoptions = get_option('widget_king_rss');
        if ($_POST["king_rss_submit_{$number}"]) {
            if (isset($_POST["king_rss_defaults_{$number}"])) {
                #if defaults are choosen
                if (!empty($_POST["king_rss_url_{$number}"])) {
                    $newoptions[$number]['rss_url'] = strip_tags(stripslashes($_POST["king_rss_url_{$number}"]));
                } else {
                    $newoptions[$number]['rss_url'] = "http://www.blog.mediaprojekte.de/feed/";
                }
                $newoptions[$number]['max_items'] = "10";
                $newoptions[$number]['shortdesc'] = "50";
                $newoptions[$number]['showdate'] = "j F Y";
                #php time format
                $newoptions[$number]['error'] = "Sorry can not grab the Feed!";
                $newoptions[$number]['titlehtml'] = '<h2><a class="rsswidget" href="%rssurl%" title="Syndicate this content"><img src="%rssicon%" alt="RSS" height="14" width="14"/></a>
<a class="rsswidget" href="%link%" title="%descr%">%title%</a></h2><ul>';
                $newoptions[$number]['rsshtml'] = '<li><strong>%date%</strong><br /><a class="rsswidget" href="%link%" title="%text%">%title%</a></li>';
                $newoptions[$number]['before_widget'] = '<li class="widget">';
                $newoptions[$number]['after_widget'] = "</ul></li>";
            } elseif ($_POST["king_rss_copy_{$number}"] !== 'No' && $_POST["king_rss_copy_{$number}"] != $number) {
                # do the copying
                $copy = $_POST["king_rss_copy_{$number}"];
                #$copyoption
                $newoptions[$number]['title'] = $options[$copy]['title'];
                $newoptions[$number]['rss_url'] = $options[$copy]['rss_url'];
                $newoptions[$number]['max_items'] = $options[$copy]['max_items'];
                $newoptions[$number]['cache_time'] = $options[$copy]['cache_time'];
                $newoptions[$number]['nosort'] = $options[$copy]['nosort'];
                $newoptions[$number]['shortdesc'] = $options[$copy]['shortdesc'];
                $newoptions[$number]['showdate'] = $options[$copy]['showdate'];
                $newoptions[$number]['error'] = $options[$copy]['error'];
                $newoptions[$number]['rsshtml'] = $options[$copy]['rsshtml'];
                $newoptions[$number]['titlehtml'] = $options[$copy]['titlehtml'];
                $newoptions[$number]['stripads'] = $options[$copy]['stripads'];
                $newoptions[$number]['show_category'] = $options[$copy]['show_category'];
                $newoptions[$number]['category_id'] = $options[$copy]['category_id'];
                $newoptions[$number]['show_on_site_area'] = $options[$copy]['show_on_site_area'];
                $newoptions[$number]['show_not_on_site_area'] = $options[$copy]['show_not_on_site_area'];
                $newoptions[$number]['site_area'] = $options[$copy]['site_area'];
                $newoptions[$number]['site_area_id'] = $options[$copy]['site_area_id'];
                $newoptions[$number]['before_widget'] = $options[$copy]['before_widget'];
                $newoptions[$number]['after_widget'] = $options[$copy]['after_widget'];
            } else {
                # insert new form values
                $newoptions[$number]['title'] = strip_tags(stripslashes($_POST["king_rss_title_{$number}"]));
                $newoptions[$number]['rss_url'] = strip_tags(stripslashes($_POST["king_rss_url_{$number}"]));
                $newoptions[$number]['max_items'] = strip_tags(stripslashes($_POST["king_rss_max_items_{$number}"]));
                $newoptions[$number]['cache_time'] = strip_tags(stripslashes($_POST["king_rss_cache_time_{$number}"]));
                $newoptions[$number]['nosort'] = isset($_POST["king_rss_nosort_{$number}"]);
                $newoptions[$number]['shortdesc'] = $_POST["king_rss_shortdesc_{$number}"];
                $newoptions[$number]['showdate'] = $_POST["king_rss_showdate_{$number}"];
                #php time format
                $newoptions[$number]['error'] = strip_tags(stripslashes($_POST["king_rss_error_{$number}"]));
                $newoptions[$number]['rsshtml'] = stripslashes($_POST["king_rss_rsshtml_{$number}"]);
                $newoptions[$number]['titlehtml'] = stripslashes($_POST["king_rss_titlehtml_{$number}"]);
                $newoptions[$number]['stripads'] = isset($_POST["king_rss_stripads_{$number}"]);
                $newoptions[$number]['show_category'] = isset($_POST["king_rss_showcategory_{$number}"]);
                $newoptions[$number]['category_id'] = $_POST["king_rss_category_id_{$number}"];
                $newoptions[$number]['show_on_site_area'] = isset($_POST["king_rss_show_on_site_area_{$number}"]);
                $newoptions[$number]['show_not_on_site_area'] = isset($_POST["king_rss_show_not_on_site_area_{$number}"]);
                $newoptions[$number]['site_area'] = $_POST["king_rss_site_area_{$number}"];
                $newoptions[$number]['site_area_id'] = $_POST["king_rss_site_area_id_{$number}"];
                $newoptions[$number]['before_widget'] = html_entity_decode($_POST["king_before_rss_widget_{$number}"]);
                $newoptions[$number]['after_widget'] = html_entity_decode($_POST["king_after_rss_widget_{$number}"]);
            }
        }
        if ($options != $newoptions) {
            $options = $newoptions;
            update_option('widget_king_rss', $options);
        }
        $title = htmlspecialchars($options[$number]['title'], ENT_QUOTES);
        $rss_url = htmlspecialchars($options[$number]['rss_url'], ENT_QUOTES);
        $max_items = $options[$number]['max_items'];
        $cache_time = $options[$number]['cache_time'];
        $nosort = $options[$number]['nosort'] ? 'checked' : '';
        $shortdesc = $options[$number]['shortdesc'];
        $showdate = $options[$number]['showdate'];
        $error = htmlspecialchars($options[$number]['error'], ENT_QUOTES);
        $titlehtml = htmlspecialchars($options[$number]['titlehtml'], ENT_QUOTES);
        $rsshtml = htmlspecialchars($options[$number]['rsshtml'], ENT_QUOTES);
        $stripads = $options[$number]['stripads'] ? 'checked' : '';
        $show_category = $options[$number]['show_category'] ? 'checked' : '';
        $category_id = $options[$number]['category_id'];
        $show_on_site_area = $options[$number]['show_on_site_area'] ? 'checked' : '';
        $show_not_on_site_area = $options[$number]['show_not_on_site_area'] ? 'checked' : '';
        $site_area = $options[$number]['site_area'];
        $site_area_id = $options[$number]['site_area_id'];
        $before_widget = stripslashes(htmlentities($options[$number]['before_widget']));
        $after_widget = stripslashes(htmlentities($options[$number]['after_widget']));
        # Here is the form segment. Notice that I have outsourced the form elements to be a little cleaner
        echo king_get_tab_start('rss' . $number, array(__('Basic', 'widgetKing'), __('Advanced', 'widgetKing'), __('Show', 'widgetKing'), __('Export', 'widgetKing')));
        # show rss URL
        echo king_get_textbox_p(array('Label_Id_Name' => "king_rss_url_{$number}", 'Description' => __('The Feed URL', 'widgetKing'), 'Label_Title' => __('Insert your rss Feed URL.', 'widgetKing'), 'Value' => $rss_url, 'Class' => 'big'));
        # show child rss
        echo king_get_textbox_p(array('Label_Id_Name' => "king_rss_max_items_{$number}", 'Description' => __('Feed Items to show', 'widgetKing'), 'Label_Title' => __('How many Articles or Items do you want to show from the Feed. Of course this is a numeric Value!', 'widgetKing'), 'Value' => $max_items, 'Max' => '3', 'Class' => 'small'));
        # show only short description
        echo king_get_textbox_p(array('Label_Id_Name' => "king_rss_shortdesc_{$number}", 'Description' => __('Show only the first No. Letters ', 'widgetKing'), 'Label_Title' => __('How much of the Feed Article Text should be shown? Of course this is a numeric Value! f.ex. Set to 100 to show the first 100 letters.', 'widgetKing'), 'Value' => $shortdesc, 'Max' => '3', 'Class' => 'small'));
        # show Date
        echo king_get_textbox_p(array('Label_Id_Name' => "king_rss_showdate_{$number}", 'Description' => __('Dateformat (php time)', 'widgetKing'), 'Label_Title' => __('Enter the date  in php time() format. If left empty none is shown. You can check this f.ex. in your blog settings. or juggle with j F Y, g:i a', 'widgetKing'), 'Value' => $showdate, 'Max' => '20'));
        # show Error Message
        echo king_get_textbox_p(array('Label_Id_Name' => "king_rss_error_{$number}", 'Description' => __('Error Message', 'widgetKing'), 'Label_Title' => __('The error Message shown if the feed cant be fetched', 'widgetKing'), 'Value' => $error, 'Max' => '60'));
        # sort order
        echo king_get_checkbox_p(array('Label_Id_Name' => "king_rss_nosort_{$number}", 'Description' => __('Do not sort Feed', 'widgetKing'), 'Label_Title' => __('Prevent sorting the feed by the time of its items. f.ex. used when grabbing a google calendar feed', 'widgetKing'), 'Value' => $nosort));
        # strip Ads
        echo king_get_checkbox_p(array('Label_Id_Name' => "king_rss_stripads_{$number}", 'Description' => __('Strip Ads', 'widgetKing'), 'Label_Title' => __('Strip out Feed-Ads from Google/Pheedo/Doubleclicks.', 'widgetKing'), 'Value' => $stripads));
        #cache time
        echo king_get_textbox_p(array('Label_Id_Name' => "king_rss_cache_time_{$number}", 'Description' => __('Refresh the feed every Minutes', 'widgetKing'), 'Label_Title' => __('The Feed will be refreshed every given Minutes. If the feed does not update frequently set a high value, else make it grab the feed more often. Default is 60 minutes, if left empty', 'widgetKing'), 'Class' => 'small', 'Value' => $cache_time));
        # set to defaults
        echo king_get_checkbox_p(array('Label_Id_Name' => "king_rss_defaults_{$number}", 'Description' => __('Insert default Options', 'widgetKing'), 'Label_Title' => __('Set all Widget Options to (hopefully failsave) Defaults. You should definitly try out some more of the HTML Placeholders for the RSS', 'widgetKing')));
        # copy
        echo king_get_select_p(array('Label_Id_Name' => "king_rss_copy_{$number}", 'Description' => __('Copy Settings from Widget No.', 'widgetKing'), 'Label_Title' => __('Choose a Widget Number from which you want to copy the settings into this one. Make sure to choose the right widget, with some Options in it!', 'widgetKing'), 'select_options' => array('No', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20')));
        # show title
        echo king_get_textbox_p(array('Label_Id_Name' => "king_rss_title_{$number}", 'Description' => __('Internal Widget Title', 'widgetKing'), 'Label_Title' => __('The title inside this widget admin page. Is shown next to the widgets name, if you applied my Widget Title Hack -> try to google on that. Or search the MP:Blog', 'widgetKing'), 'Value' => $title, 'Max' => '50'));
        # devider
        echo king_get_tab_section('rss' . $number . '-1');
        #before widget
        echo king_get_textbox_p(array('Label_Id_Name' => "king_before_rss_widget_{$number}", 'Description' => __('HTML before widget', 'widgetKing'), 'Label_Title' => __('HTML which opens this widget. Can be something linke ul with a class, depending on your css and Theme', 'widgetKing'), 'Value' => $before_widget, 'Class' => 'big'));
        # rss template html
        echo king_get_textarea_p(array('Label_Id_Name' => "king_rss_titlehtml_{$number}", 'Description' => __('RSS Title HTML Template', 'widgetKing'), 'Label_Title' => __('The HTML that will be used to format the RSS-Title output. There are several Placeholders wich can be used. <br />%link% - Link to Website <br />%title% - RSS Title<br />%descr% - RSS Description<br />%rssurl% - Feed URL<br />%rssicon% - RSS Icon <br />%feedimg% - Feed Image if provided by Feed.', 'widgetKing'), 'Value' => $titlehtml));
        # rss template html
        echo king_get_textarea_p(array('Label_Id_Name' => "king_rss_rsshtml_{$number}", 'Description' => __('RSS Item formatting HTML Template', 'widgetKing'), 'Label_Title' => __('The HTML that will be used to format each Item of the RSS output. There are several Placeholders wich can be used: <br />%title% - Item Title<br />%date% - Item Date<br />%link% - Link to Item Title<br />%text% - Item Text<br />%category% - Item Categories if provided delimited by | <br />%author% - Item Author if provided', 'widgetKing'), 'Value' => $rsshtml));
        #after widget
        echo king_get_textbox_p(array('Label_Id_Name' => "king_after_rss_widget_{$number}", 'Description' => __('HTML after widget', 'widgetKing'), 'Label_Title' => __('HTML which closes this widget. Can be something linke /ul , depending on what you set as HTML before', 'widgetKing'), 'Value' => $after_widget, 'Class' => 'big'));
        #devider
        echo king_get_tab_section('rss' . $number . '-2');
        #Where To Show Options Panel
        widget_king_where_to_show('rss', $number, $show_category, $category_id, $show_on_site_area, $show_not_on_site_area, $site_area, $site_area_id);
        echo king_get_tab_section('rss' . $number . '-3');
        king_get_dump_options('rss', $number, 'widget_rss_categories');
        echo king_get_hidden("king_rss_submit_{$number}", '1', "king_rss_submit_{$number}");
        echo king_get_tab_end();
    }
Exemplo n.º 2
0
/**
* @desc The HTML Options fields to show the login dump
* @author Georg Leciejewski
* @param string $widgetname Short Name of the widget ie: text for king_text_widget
* @param int $number Number of the widget
* @param string $widget_longname Full widget Name ie: king_text_widget . is used for the get option call in king_dump_options
*/
function king_get_dump_options($widgetname, $number, $widget_longname)
{
    echo king_get_textarea_p(array('Label_Id_Name' => 'king_' . $widgetname . '_dump_' . $number . '', 'Description' => __('Current Configuration Code', 'widgetKing'), 'Label_Title' => __('Copy this Configuration code into another widget, send it to your friends or paste new config options here.', 'widgetKing'), 'Value' => stripslashes(king_dump_options($widget_longname, $number)), 'Class' => 'big'));
    echo king_get_checkbox_p(array('Label_Id_Name' => 'king_' . $widgetname . '_usedump_' . $number . '', 'Description' => __('Use Config Code for new settings', 'widgetKing'), 'Label_Title' => __('Your inserted config code will be taken to set the widgets options. <br />!CAREFULL only paste Config Options from SAME WIDGET TYPE! <br />If the text is in the wrong format it can f*** up your Options. In such a case you can empty the field to reset the options.', 'widgetKing')));
}
Exemplo n.º 3
0
 /**
  * @desc Output of plugin?s editform in te adminarea
  * @author Georg Leciejewski
  */
 function widget_king_text_control($number)
 {
     // Get our options and see if we're handling a form submission.
     $options = $newoptions = get_option('widget_king_text');
     if ($_POST["king_text_submit_{$number}"]) {
         //if defaults are choosen
         if (isset($_POST["king_text_defaults_{$number}"])) {
             /*  no defaults atm	*/
         } elseif ($_POST["king_text_copy_{$number}"] !== 'No' && $_POST["king_text_copy_{$number}"] != $number) {
             $copy = $_POST["king_text_copy_{$number}"];
             $newoptions[$number] = array();
             foreach ($options[$copy] as $key => $val) {
                 $newoptions[$number][$key] = $val;
             }
         } else {
             // insert new form values
             $newoptions[$number]['title'] = strip_tags(stripslashes($_POST["king_text_title_{$number}"]));
             $newoptions[$number]['text'] = stripslashes($_POST["king_text_text_{$number}"]);
             if (!current_user_can('unfiltered_html')) {
                 $newoptions[$number]['text'] = stripslashes(wp_filter_post_kses($newoptions[$number]['text']));
             }
             $newoptions[$number]['use_php'] = isset($_POST["king_text_use_php_{$number}"]);
             $newoptions[$number]['show_category'] = isset($_POST["king_text_showcategory_{$number}"]);
             $newoptions[$number]['category_id'] = $_POST["king_text_category_id_{$number}"];
             $newoptions[$number]['slide'] = isset($_POST["king_text_slide_{$number}"]);
             $newoptions[$number]['show_on_site_area'] = isset($_POST["king_text_show_on_site_area_{$number}"]);
             $newoptions[$number]['show_not_on_site_area'] = isset($_POST["king_text_show_not_on_site_area_{$number}"]);
             $newoptions[$number]['site_area'] = $_POST["king_text_site_area_{$number}"];
             $newoptions[$number]['site_area_id'] = $_POST["king_text_site_area_id_{$number}"];
             $newoptions[$number]['before_widget'] = html_entity_decode($_POST["king_before_text_widget_{$number}"]);
             $newoptions[$number]['after_widget'] = html_entity_decode($_POST["king_after_text_widget_{$number}"]);
             $newoptions[$number]['before_widget_title'] = html_entity_decode($_POST["king_before_text_widget_title_{$number}"]);
             $newoptions[$number]['after_widget_title'] = html_entity_decode($_POST["king_after_text_widget_title_{$number}"]);
         }
     }
     if ($options != $newoptions) {
         $options = $newoptions;
         update_option('widget_king_text', $options);
     }
     $title = htmlspecialchars($options[$number]['title'], ENT_QUOTES);
     $text = htmlspecialchars($options[$number]['text'], ENT_QUOTES);
     $show_category = $options[$number]['show_category'] ? 'checked' : '';
     $category_id = $options[$number]['category_id'];
     $use_php = $options[$number]['use_php'] ? 'checked' : '';
     $show_on_site_area = $options[$number]['show_on_site_area'] ? 'checked' : '';
     $show_not_on_site_area = $options[$number]['show_not_on_site_area'] ? 'checked' : '';
     $site_area = $options[$number]['site_area'];
     $site_area_id = $options[$number]['site_area_id'];
     $slide = !empty($options[$number]['slide']) ? 'checked' : '';
     $before_widget = stripslashes(htmlentities($options[$number]['before_widget']));
     $after_widget = stripslashes(htmlentities($options[$number]['after_widget']));
     $before_widget_title = stripslashes(htmlentities($options[$number]['before_widget_title']));
     $after_widget_title = stripslashes(htmlentities($options[$number]['after_widget_title']));
     echo king_get_tab_start('text' . $number, array(__('Basic Features', 'widgetKing'), __('Show', 'widgetKing'), __('HTML', 'widgetKing')));
     # show title
     echo king_get_textbox_p(array('Label_Id_Name' => "king_text_title_{$number}", 'Description' => __('Title', 'widgetKing'), 'Label_Title' => __('The title above your text menu', 'widgetKing'), 'Value' => $title));
     #use_php in textarea
     echo king_get_checkbox_p(array('Label_Id_Name' => "king_text_use_php_{$number}", 'Description' => __('Use PHP in Text', 'widgetKing'), 'Label_Title' => __('If checked the inserted code is evaluated as php.PHP Code MUST be enclosed in &lt;?php and ?&gt; tags! You can also insert Wordpress Code if you have not found a Widget for it yet.', 'widgetKing'), 'Value' => $use_php));
     # show child text
     echo king_get_textarea_p(array('Label_Id_Name' => "king_text_text_{$number}", 'Description' => __('Text or HTML', 'widgetKing'), 'Label_Title' => __('Insert your Text Freely. This can be bannercode, images or whatever you like. The HTML gets stripped if you do not have the right to insert unfiltered html.', 'widgetKing'), 'Value' => $text, 'Class' => 'big'));
     #copy
     echo king_get_select_p(array('Label_Id_Name' => "king_text_copy_{$number}", 'Description' => __('Copy Settings from Widget No.', 'widgetKing'), 'Label_Title' => __('Choose a Widget Number from which you want to copy the settings into this one. Make sure to choose the right widget, with some Options in it!', 'widgetKing'), 'select_options' => array('No', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19')));
     echo king_get_tab_section('text' . $number . '-1');
     # Where To Show Options Panel
     widget_king_where_to_show('text', $number, $show_category, $category_id, $show_on_site_area, $show_not_on_site_area, $site_area, $site_area_id);
     echo king_get_tab_section('text' . $number . '-2');
     # Widget HTML
     widget_king_htmloptions('text', $number, $before_widget, $before_widget_title, $after_widget_title, $after_widget);
     echo king_get_hidden("king_text_submit_{$number}", '1', "king_text_submit_{$number}");
     echo king_get_tab_end();
 }