Changeset 6088
- Timestamp:
- 11/08/2017 04:30:14 AM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/handbook/inc/widgets.php
r5959 r6088 22 22 } 23 23 24 function __construct() { 25 $widget_ops = array('classname' => 'widget_wporg_handbook_pages', 'description' => __( 'Your site’s Handbook Pages', 'wporg' ) ); 24 public function __construct() { 25 $widget_ops = array( 26 'classname' => 'widget_wporg_handbook_pages', 27 'description' => __( 'Your site’s Handbook Pages', 'wporg' ), 28 'customize_selective_refresh' => true, 29 ); 26 30 WP_Widget::__construct( self::get_widget_id_base(), __( 'Handbook Pages', 'wporg' ), $widget_ops ); 27 31 } 28 32 29 function widget( $args, $instance ) {33 public function widget( $args, $instance ) { 30 34 $args['after_title'] = '</h2>' . "\n" . '<div class="menu-table-of-contents-container">' . "\n"; 31 35 $args['after_widget'] = '</div>'; 32 36 33 add_filter( 'widget_pages_args', array( $this, 'handbook_post_type' ) );37 add_filter( 'widget_pages_args', array( $this, 'handbook_post_type' ), 10, 2 ); 34 38 add_filter( 'page_css_class', array( $this, 'amend_page_css_class' ) ); 35 39 parent::widget( $args, $instance ); … … 38 42 } 39 43 40 function handbook_post_type( $args ) { 44 public function form( $instance ) { 45 parent::form( $instance ); 46 47 $checked = $instance['show_home'] ? 'checked="checked"' : ''; 48 ?> 49 <p> 50 <input class="widefat" id="<?php echo esc_attr( $this->get_field_id('show_home') ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'show_home' ) ); ?>" type="checkbox" value="1" <?php echo $checked ?> /> 51 <label for="<?php echo esc_attr( $this->get_field_id( 'show_home' ) ); ?>"><?php _e( 'List the home page' ); ?></label> 52 </p> 53 <?php 54 } 55 56 public function update( $new_instance, $old_instance ) { 57 $instance = parent::update( $new_instance, $old_instance ); 58 $instance['show_home'] = (bool) $new_instance['show_home']; 59 60 return $instance; 61 } 62 63 public function handbook_post_type( $args, $instance ) { 41 64 $post = get_post(); 65 66 if ( ! isset( $instance['show_home'] ) ) { 67 $instance['show_home'] = false; 68 } 42 69 43 70 $this->post_types = (array) apply_filters( 'handbook_post_types', $this->post_types ); … … 60 87 $page = get_page_by_path( $slug, OBJECT, $post->post_type ); 61 88 } 62 if ( $page ) {89 if ( $page && ! $instance['show_home'] ) { 63 90 $args['exclude'] = $page->ID; 64 91 } … … 67 94 } 68 95 69 function append_suffix( $t ) {96 public function append_suffix( $t ) { 70 97 if ( in_array( $t, array( 'handbook', 'page' ) ) ) { 71 98 return $t; … … 83 110 * @return array 84 111 */ 85 function amend_page_css_class( $css_class ) {112 public function amend_page_css_class( $css_class ) { 86 113 $class_name_map = array( 87 114 'current_page_ancestor' => 'current-menu-ancestor',
Note: See TracChangeset
for help on using the changeset viewer.