Make WordPress Core


Ignore:
Timestamp:
03/28/2012 09:45:51 AM (13 years ago)
Author:
koopersmith
Message:

Theme Customizer: Add data binding to page dropdown controls. Add WP_Customize_Control->get_link() to return the data attribute string. see #19910.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/class-wp-customize-control.php

    r20299 r20302  
    169169    }
    170170
     171    public function get_link( $setting_key = 'default' ) {
     172        if ( ! isset( $this->settings[ $setting_key ] ) )
     173            return '';
     174
     175        return 'data-customize-setting-link="' . esc_attr( $this->settings[ $setting_key ]->id ) . '"';
     176    }
     177
    171178    public function link( $setting_key = 'default' ) {
    172         if ( ! isset( $this->settings[ $setting_key ] ) )
    173             return;
    174 
    175         echo 'data-customize-setting-link="' . esc_attr( $this->settings[ $setting_key ]->id ) . '"';
     179        echo $this->get_link( $setting_key );
    176180    }
    177181
     
    310314                break;
    311315            case 'dropdown-pages':
     316                $dropdown = wp_dropdown_pages(
     317                    array(
     318                        'name'              => '_customize-dropdown-pages-' . $this->id,
     319                        'echo'              => 0,
     320                        'show_option_none'  => __( '— Select —' ),
     321                        'option_none_value' => '0',
     322                        'selected'          => $this->value(),
     323                    )
     324                );
     325
     326                // Hackily add in the data link parameter.
     327                $dropdown = str_replace( '<select', '<select ' . $this->get_link(), $dropdown );
     328
    312329                printf(
    313330                    '<label class="customize-control-select"><span class="customize-control-title">%s</span> %s</label>',
    314331                    $this->label,
    315                     wp_dropdown_pages(
    316                         array(
    317                             // @todo: this is going to need fixing.
    318                             // 'name'              => $this->get_name(),
    319                             'echo'              => 0,
    320                             'show_option_none'  => __( '&mdash; Select &mdash;' ),
    321                             'option_none_value' => '0',
    322                             'selected'          => $this->value(),
    323                         )
    324                     )
     332                    $dropdown
    325333                );
    326334                break;
Note: See TracChangeset for help on using the changeset viewer.