430 $this->render_content(); |
435 $this->render_content(); |
431 echo '</li>'; |
436 echo '</li>'; |
432 } |
437 } |
433 |
438 |
434 /** |
439 /** |
435 * Get the data link attribute for a setting. |
440 * Gets the data link attribute for a setting. |
436 * |
441 * |
437 * @since 3.4.0 |
442 * @since 3.4.0 |
438 * @since 4.9.0 Return a `data-customize-setting-key-link` attribute if a setting is not registered for the supplied setting key. |
443 * @since 4.9.0 Return a `data-customize-setting-key-link` attribute if a setting is not registered for the supplied setting key. |
439 * |
444 * |
440 * @param string $setting_key |
445 * @param string $setting_key |
441 * @return string Data link parameter, a `data-customize-setting-link` attribute if the `$setting_key` refers to a pre-registered setting, |
446 * @return string Data link parameter, a `data-customize-setting-link` attribute if the `$setting_key` refers |
442 * and a `data-customize-setting-key-link` attribute if the setting is not yet registered. |
447 * to a pre-registered setting, and a `data-customize-setting-key-link` attribute if the setting |
|
448 * is not yet registered. |
443 */ |
449 */ |
444 public function get_link( $setting_key = 'default' ) { |
450 public function get_link( $setting_key = 'default' ) { |
445 if ( isset( $this->settings[ $setting_key ] ) && $this->settings[ $setting_key ] instanceof WP_Customize_Setting ) { |
451 if ( isset( $this->settings[ $setting_key ] ) && $this->settings[ $setting_key ] instanceof WP_Customize_Setting ) { |
446 return 'data-customize-setting-link="' . esc_attr( $this->settings[ $setting_key ]->id ) . '"'; |
452 return 'data-customize-setting-link="' . esc_attr( $this->settings[ $setting_key ]->id ) . '"'; |
447 } else { |
453 } else { |
448 return 'data-customize-setting-key-link="' . esc_attr( $setting_key ) . '"'; |
454 return 'data-customize-setting-key-link="' . esc_attr( $setting_key ) . '"'; |
449 } |
455 } |
450 } |
456 } |
451 |
457 |
452 /** |
458 /** |
453 * Render the data link attribute for the control's input element. |
459 * Renders the data link attribute for the control's input element. |
454 * |
460 * |
455 * @since 3.4.0 |
461 * @since 3.4.0 |
456 * @uses WP_Customize_Control::get_link() |
462 * @uses WP_Customize_Control::get_link() |
457 * |
463 * |
458 * @param string $setting_key |
464 * @param string $setting_key Default 'default'. |
459 */ |
465 */ |
460 public function link( $setting_key = 'default' ) { |
466 public function link( $setting_key = 'default' ) { |
461 echo $this->get_link( $setting_key ); |
467 echo $this->get_link( $setting_key ); |
462 } |
468 } |
463 |
469 |
464 /** |
470 /** |
465 * Render the custom attributes for the control's input element. |
471 * Renders the custom attributes for the control's input element. |
466 * |
472 * |
467 * @since 4.0.0 |
473 * @since 4.0.0 |
468 */ |
474 */ |
469 public function input_attrs() { |
475 public function input_attrs() { |
470 foreach ( $this->input_attrs as $attr => $value ) { |
476 foreach ( $this->input_attrs as $attr => $value ) { |
471 echo $attr . '="' . esc_attr( $value ) . '" '; |
477 echo $attr . '="' . esc_attr( $value ) . '" '; |
472 } |
478 } |
473 } |
479 } |
474 |
480 |
475 /** |
481 /** |
476 * Render the control's content. |
482 * Renders the control's content. |
477 * |
483 * |
478 * Allows the content to be overridden without having to rewrite the wrapper in `$this::render()`. |
484 * Allows the content to be overridden without having to rewrite the wrapper in `$this::render()`. |
479 * |
485 * |
480 * Supports basic input types `text`, `checkbox`, `textarea`, `radio`, `select` and `dropdown-pages`. |
486 * Supports basic input types `text`, `checkbox`, `textarea`, `radio`, `select` and `dropdown-pages`. |
481 * Additional input types such as `email`, `url`, `number`, `hidden` and `date` are supported implicitly. |
487 * Additional input types such as `email`, `url`, `number`, `hidden` and `date` are supported implicitly. |
606 |
612 |
607 // Hackily add in the data link parameter. |
613 // Hackily add in the data link parameter. |
608 $dropdown = str_replace( '<select', '<select ' . $this->get_link() . ' id="' . esc_attr( $input_id ) . '" ' . $describedby_attr, $dropdown ); |
614 $dropdown = str_replace( '<select', '<select ' . $this->get_link() . ' id="' . esc_attr( $input_id ) . '" ' . $describedby_attr, $dropdown ); |
609 |
615 |
610 /* |
616 /* |
611 * Even more hacikly add auto-draft page stubs. |
617 * Even more hackily 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. |
618 * @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>. |
619 * See <https://github.com/xwp/wp-customize-posts/pull/250>. |
614 */ |
620 */ |
615 $nav_menus_created_posts_setting = $this->manager->get_setting( 'nav_menus_created_posts' ); |
621 $nav_menus_created_posts_setting = $this->manager->get_setting( 'nav_menus_created_posts' ); |
616 if ( $nav_menus_created_posts_setting && current_user_can( 'publish_pages' ) ) { |
622 if ( $nav_menus_created_posts_setting && current_user_can( 'publish_pages' ) ) { |
629 echo $dropdown; |
635 echo $dropdown; |
630 ?> |
636 ?> |
631 <?php if ( $this->allow_addition && current_user_can( 'publish_pages' ) && current_user_can( 'edit_theme_options' ) ) : // Currently tied to menus functionality. ?> |
637 <?php if ( $this->allow_addition && current_user_can( 'publish_pages' ) && current_user_can( 'edit_theme_options' ) ) : // Currently tied to menus functionality. ?> |
632 <button type="button" class="button-link add-new-toggle"> |
638 <button type="button" class="button-link add-new-toggle"> |
633 <?php |
639 <?php |
634 /* translators: %s: Add New Page label. */ |
640 /* translators: %s: Add Page label. */ |
635 printf( __( '+ %s' ), get_post_type_object( 'page' )->labels->add_new_item ); |
641 printf( __( '+ %s' ), get_post_type_object( 'page' )->labels->add_new_item ); |
636 ?> |
642 ?> |
637 </button> |
643 </button> |
638 <div class="new-content-item-wrapper"> |
644 <div class="new-content-item-wrapper"> |
639 <label for="create-input-<?php echo esc_attr( $this->id ); ?>"><?php _e( 'New page title' ); ?></label> |
645 <label for="create-input-<?php echo esc_attr( $this->id ); ?>"><?php _e( 'New page title' ); ?></label> |