WordPress.org

Make WordPress Core

Ticket #35926: 35926.0.diff

File 35926.0.diff, 3.6 KB (added by westonruter, 5 years ago)

WIP

  • src/wp-includes/class-wp-customize-control.php

    diff --git src/wp-includes/class-wp-customize-control.php src/wp-includes/class-wp-customize-control.php
    index a892b10..c53422e 100644
    class WP_Customize_Control { 
    187187                $this->instance_number = self::$instance_count;
    188188
    189189                // Process settings.
    190                 if ( empty( $this->settings ) ) {
     190                if ( ! isset( $args['settings'] ) ) {
    191191                        $this->settings = $id;
    192192                }
    193193
    class WP_Customize_Control { 
    196196                        foreach ( $this->settings as $key => $setting ) {
    197197                                $settings[ $key ] = $this->manager->get_setting( $setting );
    198198                        }
    199                 } else {
     199                } else if ( is_string( $this->settings ) ) {
    200200                        $this->setting = $this->manager->get_setting( $this->settings );
    201201                        $settings['default'] = $this->setting;
    202202                }
  • src/wp-includes/class-wp-customize-nav-menus.php

    diff --git src/wp-includes/class-wp-customize-nav-menus.php src/wp-includes/class-wp-customize-nav-menus.php
    index b4bd0fd..77593d9 100644
    final class WP_Customize_Nav_Menus { 
    596596                        'priority' => 999,
    597597                ) ) );
    598598
    599                 $this->manager->add_setting( 'new_menu_name', array(
    600                         'type'      => 'new_menu',
    601                         'default'   => '',
    602                         'transport' => isset( $this->manager->selective_refresh ) ? 'postMessage' : 'refresh',
    603                 ) );
    604 
    605599                $this->manager->add_control( 'new_menu_name', array(
    606600                        'label'       => '',
    607601                        'section'     => 'add_menu',
    final class WP_Customize_Nav_Menus { 
    612606                        ),
    613607                ) );
    614608
    615                 $this->manager->add_setting( 'create_new_menu', array(
    616                         'type' => 'new_menu',
    617                 ) );
    618 
    619609                $this->manager->add_control( new WP_Customize_New_Menu_Control( $this->manager, 'create_new_menu', array(
    620610                        'section' => 'add_menu',
    621611                ) ) );
  • src/wp-includes/customize/class-wp-customize-partial.php

    diff --git src/wp-includes/customize/class-wp-customize-partial.php src/wp-includes/customize/class-wp-customize-partial.php
    index 3cb410b..680c5f0 100644
    class WP_Customize_Partial { 
    9090        public $primary_setting;
    9191
    9292        /**
     93         * Capability required to edit this partial.
     94         *
     95         * Normally this is empty and the capability is derived from the capabilities
     96         * of the associated `$settings`.
     97         *
     98         * @since 4.5.0
     99         * @access public
     100         * @var string
     101         */
     102        public $capability;
     103
     104        /**
    93105         * Render callback.
    94106         *
    95107         * @since 4.5.0
    class WP_Customize_Partial { 
    157169                }
    158170
    159171                // Process settings.
    160                 if ( empty( $this->settings ) ) {
     172                if ( ! isset( $args['settings'] ) ) {
    161173                        $this->settings = array( $id );
    162174                } else if ( is_string( $this->settings ) ) {
    163175                        $this->settings = array( $this->settings );
    class WP_Customize_Partial { 
    290302         * Checks if the user can refresh this partial.
    291303         *
    292304         * Returns false if the user cannot manipulate one of the associated settings,
    293          * or if one of the associated settings does not exist.
     305         * or if one of the associated settings does not exist, or if the partial
     306         * has an explicit `$capability` which the current user cannot do.
    294307         *
    295308         * @since 4.5.0
    296309         * @access public
    class WP_Customize_Partial { 
    299312         *                    or if one of the associated settings does not exist.
    300313         */
    301314        final public function check_capabilities() {
     315                if ( ! empty( $this->capability ) && ! current_user_can( $this->capability ) ) {
     316                        return false;
     317                }
    302318                foreach ( $this->settings as $setting_id ) {
    303319                        $setting = $this->component->manager->get_setting( $setting_id );
    304320                        if ( ! $setting || ! $setting->check_capabilities() ) {