Changeset 38906 for trunk/src/wp-includes/class-wp-customize-control.php
- Timestamp:
- 10/25/2016 06:30:27 AM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-wp-customize-control.php
r38624 r38906 114 114 */ 115 115 public $input_attrs = array(); 116 117 /** 118 * Show UI for adding new content, currently only used for the dropdown-pages control. 119 * 120 * @since 4.7.0 121 * @access public 122 * @var array 123 */ 124 public $allow_addition = false; 116 125 117 126 /** … … 297 306 $this->json['description'] = $this->description; 298 307 $this->json['instanceNumber'] = $this->instance_number; 308 309 if ( 'dropdown-pages' === $this->type ) { 310 $this->json['allow_addition'] = $this->allow_addition; 311 } 299 312 } 300 313 … … 555 568 // Hackily add in the data link parameter. 556 569 $dropdown = str_replace( '<select', '<select ' . $this->get_link(), $dropdown ); 570 571 // Even more hacikly add auto-draft page stubs. 572 // @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>. 573 $nav_menus_created_posts_setting = $this->manager->get_setting( 'nav_menus_created_posts' ); 574 if ( $nav_menus_created_posts_setting && current_user_can( 'publish_pages' ) ) { 575 $auto_draft_page_options = ''; 576 foreach ( $nav_menus_created_posts_setting->value() as $auto_draft_page_id ) { 577 $post = get_post( $auto_draft_page_id ); 578 if ( $post && 'page' === $post->post_type ) { 579 $auto_draft_page_options .= sprintf( '<option value="%1$s">%2$s</option>', esc_attr( $post->ID ), esc_html( $post->post_title ) ); 580 } 581 } 582 if ( $auto_draft_page_options ) { 583 $dropdown = str_replace( '</select>', $auto_draft_page_options . '</select>', $dropdown ); 584 } 585 } 586 557 587 echo $dropdown; 558 588 ?> 559 589 </label> 560 <?php 590 <?php if ( $this->allow_addition && current_user_can( 'publish_pages' ) && current_user_can( 'edit_theme_options' ) ) : // Currently tied to menus functionality. ?> 591 <button type="button" class="button add-new-toggle"><?php echo get_post_type_object( 'page' )->labels->add_new_item; ?></button> 592 <div class="new-content-item"> 593 <label for="create-input-<?php echo $this->id; ?>"><span class="screen-reader-text"><?php _e( 'New page title' ); ?></span></label> 594 <input type="text" id="create-input-<?php echo $this->id; ?>" class="create-item-input" placeholder="<?php esc_attr_e( 'New page title…' ); ?>"> 595 <button type="button" class="button add-content"><?php _e( 'Add' ); ?></button> 596 </div> 597 <?php endif; 561 598 break; 562 599 default:
Note: See TracChangeset
for help on using the changeset viewer.