Display widgets and Samsarin PHP Widget.|灵动边栏插件,使用它将使你更容易的控制你的边栏显示,安装激活以后会在小工具页面显示控制各个小工具在博客中任何页面是否显示,以实现不同页面不同侧边栏的效果;同时在小工具页面产生一个支持php语言的文本小工具,让你更容易的添加属于自己的边栏小工具.此插件在Display widgets和Samsarin PHP Widget基础上修改,在此感谢原作者. Author: 阿邙 Author URI: http://amangs.com/ Version: 1.02 */ function d_p_d_widget($instance){ if (is_home()) $show = isset($instance['page-home']) ? ($instance['page-home']) : false; else if (is_front_page()) $show = isset($instance['page-front']) ? ($instance['page-front']) : false; else if (is_category()) $show = $instance['cat-'.get_query_var('cat')]; else if (is_archive()) $show = $instance['page-archive']; else if (is_single()){ $show = $instance['page-single']; if (!$show){ foreach(get_the_category() as $cat){ if ($show) continue; if (isset($instance['cat-'.$cat->cat_ID])) $show = $instance['cat-'.$cat->cat_ID]; } } }else if (is_404()) $show = $instance['page-404']; else if (is_search()) $show = $instance['page-search']; else{ global $wp_query; $post_id = $wp_query->get_queried_object_id(); $show = $instance['page-'.$post_id]; } if (isset($instance['include']) && (($instance['include'] and $show == false) or ($instance['include'] == 0 and $show))) return false; else return $instance; } function dw_show_hide_widget_options($widget, $return, $instance){ $last_saved = get_option('dw_check_new_pages'); //Check to see when pages and categories were last saved //if more than 1 minute ago, we can check again if(!$last_saved or ((time() - $last_saved) >= 60)){ $pages = get_posts( array('post_type' => 'page', 'post_status' => 'published', 'numberposts' => 99, 'order_by' => 'post_title', 'order' => 'ASC')); $cats = get_categories(); update_option('dw_saved_page_list', serialize($pages)); update_option('dw_saved_cat_list', serialize($cats)); update_option('dw_check_new_pages', time()); }else{ $pages = unserialize(get_option('dw_saved_page_list')); $cats = unserialize(get_option('dw_saved_cat_list')); } $wp_page_types = array('front' => 'Front', 'home' => 'Blog','archive' => 'Archives','single' => 'Single Post','404' => '404', 'search' => 'Search'); $instance['include'] = isset($instance['include']) ? $instance['include'] : 0; ?>
Pages
ID] = isset($instance['page-'.$page->ID]) ? $instance['page-'.$page->ID] : false; ?>ID], true) ?> id="get_field_id('page-'.$page->ID); ?>" name="get_field_name('page-'.$page->ID); ?>" />
Categories
cat_ID] = isset($instance['cat-'.$cat->cat_ID]) ? $instance['cat-'.$cat->cat_ID] : false; ?>cat_ID], true) ?> id="get_field_id('cat-'.$cat->cat_ID); ?>" name="get_field_name('cat-'.$cat->cat_ID); ?>" />
Miscellaneous
$label){ $instance['page-'. $key] = isset($instance['page-'. $key]) ? $instance['page-'. $key] : false; ?>id="get_field_id('page-'. $key); ?>" name="get_field_name('page-'. $key); ?>" />