/** * @desc Output of widget composing the list_pages function call * this function is called for every pages widget * @param array $args - aditional arguments passed to the wp_list_pages filter by some other plugins * @param int $number - the widget identifier * @author Georg Leciejewski */ function widget_king_pages($args, $number = 1) { # $args is an array of strings that help widgets to conform to # the active theme: before_widget, before_title, after_widget, # and after_title are the array keys. Default tags: li and h2. $data = array(); extract($args, EXTR_PREFIX_ALL, "default"); $options = get_option('widget_king_pages'); $data['title'] = $options[$number]['title']; $data['child_of'] = $options[$number]['child_of'] ? $options[$number]['child_of'] : 0; $data['sort_column'] = $options[$number]['sort_column']; $data['sort_order'] = $options[$number]['sort_order']; $data['exclude'] = $options[$number]['exclude']; $data['depth'] = $options[$number]['depth']; $data['show_date'] = $options[$number]['show_date']; $data['date_format'] = $options[$number]['date_format']; $data['sort_order'] = $options[$number]['sort_order']; $data['title_li'] = $options[$number]['title_li']; $data['foldlist'] = $options[$number]['foldlist']; $data['show_category'] = $options[$number]['show_category'] ? 1 : 0; $data['category_id'] = $options[$number]['category_id']; $data['show_on_site_area'] = $options[$number]['show_on_site_area'] ? 1 : 0; $data['show_not_on_site_area'] = $options[$number]['show_not_on_site_area'] ? 1 : 0; $data['site_area_id'] = $options[$number]['site_area_id']; $data['site_area'] = $options[$number]['site_area']; $data['before_widget'] = empty($options[$number]['before_widget']) ? $default_before_widget : stripslashes($options[$number]['before_widget']); $data['before_widget_title'] = empty($options[$number]['before_widget_title']) ? $default_before_title : stripslashes($options[$number]['before_widget_title']); $data['after_widget_title'] = empty($options[$number]['after_widget_title']) ? $default_after_title : stripslashes($options[$number]['after_widget_title']); $data['after_widget'] = empty($options[$number]['after_widget']) ? $default_after_widget : stripslashes($options[$number]['after_widget']); $already_out = null; if (!empty($data['show_category'])) { # if in category $post = $wp_query->post; if (king_in_category($data['category_id'])) { king_pages_output($data, $number); $already_out = 1; } } if (!empty($data['show_on_site_area'])) { # display widget on special sitearea if (king_in_site_area($data['site_area'], $data['site_area_id']) && $already_out != 1) { king_pages_output($data, $number); $already_out = 1; } } elseif (!empty($data['show_not_on_site_area'])) { # display widget everwhere but in this sitearea if (!king_in_site_area($data['site_area'], $data['site_area_id']) && $already_out != 1) { king_pages_output($data, $number); } } if (empty($data['show_not_on_site_area']) && empty($data['show_on_site_area']) && empty($data['show_category'])) { # always show king_pages_output($data, $number); } #debug output if (!empty($options[$number]['debug'])) { echo "<h2>__('Your Menu Options are:', 'widgetKing')</h2>\n\t\t\t\tchild_of={$child_of} <br>\n\t\t\t\tsort_column={$sort_column} <br>\n\t\t\t\tsort_order={$sort_order} <br>\n\t\t\t\texclude={$exclude} <br>\n\t\t\t\tdepth={$depth} <br>\n\t\t\t\tshow_date={$show_date} <br>\n\t\t\t\tdate_format={$date_format} <br>\n\t\t\t\ttitle_li=title_li <br>"; } }
/** * Output a widget and detect if it should be shown * * @param <Widget> $widget object * @param <Array> $args is an array of strings that help widgets to conform to * the active theme: before_widget, before_title, after_widget, * and after_title are the array keys. Default tags: li and h2. * @param <Array> $opts - existing options */ public static function do_show($widget, $args, $opts) { extract($args); $opts['title'] = apply_filters('widget_title', empty($opts['title']) ? '' : $opts['title'], $opts, $widget->id_base); //take care of some escaped fields $opts['before_widget'] = empty($opts['before_widget']) ? $before_widget : stripslashes($opts['before_widget']); $opts['before_widget_title'] = empty($opts['before_widget_title']) ? $before_title : stripslashes($opts['before_widget_title']); $opts['after_widget_title'] = empty($opts['after_widget_title']) ? $after_title : stripslashes($opts['after_widget_title']); $opts['after_widget'] = empty($opts['after_widget']) ? $after_widget : stripslashes($opts['after_widget']); $already_out = false; # These lines generate our output. Widgets can be very complex # but as you can see here, they can also be very, very simple. if (!empty($opts['show_category'])) { $post = $wp_query->post; if (king_in_category($opts['cat_ids'])) { $widget->output($opts); $already_out = true; } } # sitearea Outputexport if (!empty($opts['show_on_site_area'])) { if (king_in_site_area($opts['site_area'], $opts['site_area_id']) && !$already_out) { # in the site area $widget->output($opts); } } elseif (!empty($opts['show_not_on_site_area'])) { if (!king_in_site_area($opts['site_area'], $opts['site_area_id']) && !$already_out) { #not in the site area $widget->output($opts); } } # always show if (empty($opts['show_not_on_site_area']) && empty($opts['show_on_site_area']) && empty($opts['show_category'])) { $widget->output($opts); } }
/** * @desc Output of plugin composing the list_cats function call * @author Georg Leciejewski */ function widget_king_categories($args, $number = 1) { # $args is an array of strings that help widgets to conform to # the active theme: before_widget, before_title, after_widget, # and after_title are the array keys. Default tags: li and h2. $data = array(); extract($args, EXTR_PREFIX_ALL, "default"); $options = get_option('widget_king_categories'); $data['title'] = empty($options[$number]['title']) ? __('Categories') : $options[$number]['title']; $data['hierarchical'] = $options[$number]['hierarchical'] ? 1 : 0; $data['sort_column'] = $options[$number]['sort_column']; $data['sort_order'] = $options[$number]['sort_order']; $data['file'] = $options[$number]['file']; $data['list'] = $options[$number]['list'] ? 1 : 0; $data['optiondates'] = $options[$number]['optiondates'] ? 1 : 0; $data['optioncount'] = $options[$number]['count'] ? 1 : 0; $data['hide_empty'] = $options[$number]['empty'] ? 1 : 0; $data['count'] = $options[$number]['count'] ? 1 : 0; $data['use_desc_for_title'] = $options[$number]['desc_title'] ? 1 : 0; $data['children'] = $options[$number]['children'] ? 1 : 0; $data['child_of'] = empty($options[$number]['child_of']) ? 0 : $options[$number]['child_of']; $data['feed'] = $options[$number]['feed']; $data['feed_image'] = stripslashes($options[$number]['feed_image']); $data['exclude'] = $options[$number]['exclude']; $data['show_category'] = $options[$number]['show_category'] ? 1 : 0; $data['category_id'] = $options[$number]['category_id']; $data['show_on_site_area'] = $options[$number]['show_on_site_area'] ? 1 : 0; $data['show_not_on_site_area'] = $options[$number]['show_not_on_site_area'] ? 1 : 0; $data['site_area_id'] = $options[$number]['site_area_id']; $data['site_area'] = $options[$number]['site_area']; $data['before_widget'] = empty($options[$number]['before_widget']) ? $default_before_widget : stripslashes($options[$number]['before_widget']); $data['before_widget_title'] = empty($options[$number]['before_widget_title']) ? $default_before_title : stripslashes($options[$number]['before_widget_title']); $data['after_widget_title'] = empty($options[$number]['after_widget_title']) ? $default_after_title : stripslashes($options[$number]['after_widget_title']); $data['after_widget'] = empty($options[$number]['after_widget']) ? $default_after_widget : stripslashes($options[$number]['after_widget']); # These lines generate our output. Widgets can be very complex # but as you can see here, they can also be very, very simple. if (!empty($data['show_category'])) { $post = $wp_query->post; if (king_in_category($data['category_id'])) { king_cat_output($data, $number); $already_out = 1; } } # sitearea Output if (!empty($data['show_on_site_area'])) { if (king_in_site_area($data['site_area'], $data['site_area_id']) && $already_out != 1) { #if in the site area king_cat_output($data, $number); } } elseif (!empty($data['show_not_on_site_area'])) { if (!king_in_site_area($data['site_area'], $data['site_area_id']) && $already_out != 1) { #if not in the site area king_cat_output($data, $number); } #end if not sitearea } if (empty($data['show_not_on_site_area']) && empty($data['show_on_site_area']) && empty($data['show_category'])) { # always show king_cat_output($data, $number); } if (!empty($options[$number]['debug'])) { echo "<h2>__('Your Menu Options are:', 'widgetKing')</h2>\n\t\t\t\tsort_column={$sort_column} <br>\n\t\t\t\tsort_order={$sort_order} <br>\n\t\t\t\tfile={$file} <br>\n\t\t\t\tlist={$list} <br>\n\t\t\t\toptiondates={$optiondates} <br>\n\t\t\t\toptioncount={$count} <br>\n\t\t\t\thide_empty={$hide_empty} <br>\n\t\t\t\tuse_desc_for_title={$use_desc_for_title} <br>\n\t\t\t\tchildren={$children} <br>\n\t\t\t\tchild_of={$child_of} <br>\n\t\t\t\tfeed={$feed} <br>\n\t\t\t\tfeed_image={$feed_image} <br>\n\t\t\t\texclude={$exclude} <br>\n\t\t\t\thierarchical={$hierarchical}"; } }