445
458
* Render the control's content.
447
* Allows the content to be overriden without having to rewrite the wrapper in `$this::render()`.
460
* Allows the content to be overridden without having to rewrite the wrapper in `$this::render()`.
449
462
* Supports basic input types `text`, `checkbox`, `textarea`, `radio`, `select` and `dropdown-pages`.
450
463
* Additional input types such as `email`, `url`, `number`, `hidden` and `date` are supported implicitly.
533
546
<span class="description customize-control-description"><?php echo $this->description; ?></span>
536
<?php $dropdown = wp_dropdown_pages(
550
$dropdown_name = '_customize-dropdown-pages-' . $this->id;
551
$show_option_none = __( '— Select —' );
552
$option_none_value = '0';
553
$dropdown = wp_dropdown_pages(
538
'name' => '_customize-dropdown-pages-' . $this->id,
555
'name' => $dropdown_name,
540
'show_option_none' => __( '— Select —' ),
541
'option_none_value' => '0',
557
'show_option_none' => $show_option_none,
558
'option_none_value' => $option_none_value,
542
559
'selected' => $this->value(),
562
if ( empty( $dropdown ) ) {
563
$dropdown = sprintf( '<select id="%1$s" name="%1$s">', esc_attr( $dropdown_name ) );
564
$dropdown .= sprintf( '<option value="%1$s">%2$s</option>', esc_attr( $option_none_value ), esc_html( $show_option_none ) );
565
$dropdown .= '</select>';
546
568
// Hackily add in the data link parameter.
547
569
$dropdown = str_replace( '<select', '<select ' . $this->get_link(), $dropdown );
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 ) );
582
if ( $auto_draft_page_options ) {
583
$dropdown = str_replace( '</select>', $auto_draft_page_options . '</select>', $dropdown );
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-link add-new-toggle"><?php
592
/* translators: %s: add new page label */
593
printf( __( '+ %s' ), get_post_type_object( 'page' )->labels->add_new_item );
595
<div class="new-content-item">
596
<label for="create-input-<?php echo $this->id; ?>"><span class="screen-reader-text"><?php _e( 'New page title' ); ?></span></label>
597
<input type="text" id="create-input-<?php echo $this->id; ?>" class="create-item-input" placeholder="<?php esc_attr_e( 'New page title…' ); ?>">
598
<button type="button" class="button add-content"><?php _e( 'Add' ); ?></button>
614
663
/** WP_Customize_Background_Image_Control class */
615
664
require_once( ABSPATH . WPINC . '/customize/class-wp-customize-background-image-control.php' );
666
/** WP_Customize_Background_Position_Control class */
667
require_once( ABSPATH . WPINC . '/customize/class-wp-customize-background-position-control.php' );
617
669
/** WP_Customize_Cropped_Image_Control class */
618
670
require_once( ABSPATH . WPINC . '/customize/class-wp-customize-cropped-image-control.php' );