'widget_section', 'description' => __('Display arbitrary text or HTML on certain sections of your site.')); $control_ops = array('width' => 400); $this->WP_Widget('section', __('Section'), $widget_ops, $control_ops); } function widget( $args, $instance ) { extract($args); // Most of the conditional tags will always return true when passed an empty array. So we need to pad them will some junk. $instance['special-pages'][] = -1; $instance['pages'][] = -1; $instance['categories'][] = -1; $instance['tags'][] = -1; $should_display = false; foreach($instance['special-pages'] as $key) { switch($key){ case "front": if(is_front_page()) $should_display = true; break; case "category": if(is_category($instance['categories'])) $should_display = true; break; case "tag": if(is_tag($instance['tags'])) $should_display = true; break; case "date": if(is_date()) $should_display = true; break; case "page": // Exclude the front page to avoid confusion if(!is_front_page() && is_page()) $should_display = true; break; case "post": if(is_single()) $should_display = true; break; case "comment": // Exclude the front page to avoid confusion if(!is_front_page() && is_singular() && comments_open()) $should_display = true; break; case "author": if(is_author()) $should_display = true; break; } if($should_display) break; } if(!$should_display) { if(is_page($instance['pages'])) $should_display = true; elseif(is_singular() && in_category($instance['categories'])) $should_display = true; elseif(is_singular() && has_tag($instance['tags'])) $should_display = true; } if($should_display) { echo $before_widget; ?>
'', 'display-title' => true, 'body' => '', 'special-pages' => array(), 'pages' => array(), 'categories' => array(), 'tags' => array()) ); $title = strip_tags($instance['title']); $display_title = (bool) $instance['display-title']; $special_pages = $instance['special-pages']; $pages = $instance['pages']; $categories = $instance['categories']; $tags = $instance['tags']; $body = format_to_edit($instance['body']); ?>" />
line 714 as of 2.8) and the wp_category_checklist() function (in /wp-admin/includes/template.php -> line 490 as of 2.8) to make sense of the following code. */ function my_checklist($mode = 'pages', $args = '') { switch($mode) { case 'categories': $defaults = array( 'selected' => array(), 'echo' => 1, 'id' => 'page_id', 'name' => 'page_id' ); $data = get_categories('get=all'); $walker = new MyCategoryChecklistWalker; break; case 'tags': $defaults = array( 'selected' => array(), 'echo' => 1, 'id' => 'tag_id', 'name' => 'tag_id' ); $data = get_tags('get=all'); $walker = new MyTagChecklistWalker; break; case 'pages': default: $defaults = array( 'selected' => array(), 'echo' => 1, 'id' => 'category_id', 'name' => 'category_id' ); $data = get_pages('get=all'); $walker = new MyPageChecklistWalker; break; } $r = wp_parse_args( $args, $defaults ); extract( $r, EXTR_SKIP ); if ( ! empty($data) ) { $output = "