equal
deleted
inserted
replaced
10 /** |
10 /** |
11 * Customize Control class. |
11 * Customize Control class. |
12 * |
12 * |
13 * @since 3.4.0 |
13 * @since 3.4.0 |
14 */ |
14 */ |
|
15 #[AllowDynamicProperties] |
15 class WP_Customize_Control { |
16 class WP_Customize_Control { |
16 |
17 |
17 /** |
18 /** |
18 * Incremented with each new class instantiation, then stored in $instance_number. |
19 * Incremented with each new class instantiation, then stored in $instance_number. |
19 * |
20 * |
165 /** |
166 /** |
166 * Constructor. |
167 * Constructor. |
167 * |
168 * |
168 * Supplied `$args` override class property defaults. |
169 * Supplied `$args` override class property defaults. |
169 * |
170 * |
170 * If `$args['settings']` is not defined, use the $id as the setting ID. |
171 * If `$args['settings']` is not defined, use the `$id` as the setting ID. |
171 * |
172 * |
172 * @since 3.4.0 |
173 * @since 3.4.0 |
173 * |
174 * |
174 * @param WP_Customize_Manager $manager Customizer bootstrap instance. |
175 * @param WP_Customize_Manager $manager Customizer bootstrap instance. |
175 * @param string $id Control ID. |
176 * @param string $id Control ID. |
550 <?php endif; ?> |
551 <?php endif; ?> |
551 |
552 |
552 <select id="<?php echo esc_attr( $input_id ); ?>" <?php echo $describedby_attr; ?> <?php $this->link(); ?>> |
553 <select id="<?php echo esc_attr( $input_id ); ?>" <?php echo $describedby_attr; ?> <?php $this->link(); ?>> |
553 <?php |
554 <?php |
554 foreach ( $this->choices as $value => $label ) { |
555 foreach ( $this->choices as $value => $label ) { |
555 echo '<option value="' . esc_attr( $value ) . '"' . selected( $this->value(), $value, false ) . '>' . $label . '</option>'; |
556 echo '<option value="' . esc_attr( $value ) . '"' . selected( $this->value(), $value, false ) . '>' . esc_html( $label ) . '</option>'; |
556 } |
557 } |
557 ?> |
558 ?> |
558 </select> |
559 </select> |
559 <?php |
560 <?php |
560 break; |
561 break; |
604 } |
605 } |
605 |
606 |
606 // Hackily add in the data link parameter. |
607 // Hackily add in the data link parameter. |
607 $dropdown = str_replace( '<select', '<select ' . $this->get_link() . ' id="' . esc_attr( $input_id ) . '" ' . $describedby_attr, $dropdown ); |
608 $dropdown = str_replace( '<select', '<select ' . $this->get_link() . ' id="' . esc_attr( $input_id ) . '" ' . $describedby_attr, $dropdown ); |
608 |
609 |
609 // Even more hacikly add auto-draft page stubs. |
610 /* |
610 // @todo Eventually this should be removed in favor of the pages being injected into the underlying get_pages() call. See <https://github.com/xwp/wp-customize-posts/pull/250>. |
611 * Even more hacikly add auto-draft page stubs. |
|
612 * @todo Eventually this should be removed in favor of the pages being injected into the underlying get_pages() call. |
|
613 * See <https://github.com/xwp/wp-customize-posts/pull/250>. |
|
614 */ |
611 $nav_menus_created_posts_setting = $this->manager->get_setting( 'nav_menus_created_posts' ); |
615 $nav_menus_created_posts_setting = $this->manager->get_setting( 'nav_menus_created_posts' ); |
612 if ( $nav_menus_created_posts_setting && current_user_can( 'publish_pages' ) ) { |
616 if ( $nav_menus_created_posts_setting && current_user_can( 'publish_pages' ) ) { |
613 $auto_draft_page_options = ''; |
617 $auto_draft_page_options = ''; |
614 foreach ( $nav_menus_created_posts_setting->value() as $auto_draft_page_id ) { |
618 foreach ( $nav_menus_created_posts_setting->value() as $auto_draft_page_id ) { |
615 $post = get_post( $auto_draft_page_id ); |
619 $post = get_post( $auto_draft_page_id ); |
629 <?php |
633 <?php |
630 /* translators: %s: Add New Page label. */ |
634 /* translators: %s: Add New Page label. */ |
631 printf( __( '+ %s' ), get_post_type_object( 'page' )->labels->add_new_item ); |
635 printf( __( '+ %s' ), get_post_type_object( 'page' )->labels->add_new_item ); |
632 ?> |
636 ?> |
633 </button> |
637 </button> |
634 <div class="new-content-item"> |
638 <div class="new-content-item-wrapper"> |
635 <label for="create-input-<?php echo esc_attr( $this->id ); ?>"><span class="screen-reader-text"><?php _e( 'New page title' ); ?></span></label> |
639 <label for="create-input-<?php echo esc_attr( $this->id ); ?>"><?php _e( 'New page title' ); ?></label> |
636 <input type="text" id="create-input-<?php echo esc_attr( $this->id ); ?>" class="create-item-input" placeholder="<?php esc_attr_e( 'New page title…' ); ?>"> |
640 <div class="new-content-item"> |
637 <button type="button" class="button add-content"><?php _e( 'Add' ); ?></button> |
641 <input type="text" id="create-input-<?php echo esc_attr( $this->id ); ?>" class="create-item-input" > |
|
642 <button type="button" class="button add-content"><?php _e( 'Add' ); ?></button> |
|
643 </div> |
638 </div> |
644 </div> |
639 <?php endif; ?> |
645 <?php endif; ?> |
640 <?php |
646 <?php |
641 break; |
647 break; |
642 default: |
648 default: |
690 * @see WP_Customize_Control::print_template() |
696 * @see WP_Customize_Control::print_template() |
691 * |
697 * |
692 * @since 4.1.0 |
698 * @since 4.1.0 |
693 */ |
699 */ |
694 protected function content_template() {} |
700 protected function content_template() {} |
695 |
|
696 } |
701 } |
697 |
702 |
698 /** |
703 /** |
699 * WP_Customize_Color_Control class. |
704 * WP_Customize_Color_Control class. |
700 */ |
705 */ |