Make WordPress Core


Ignore:
Timestamp:
02/24/2016 06:27:45 PM (10 years ago)
Author:
westonruter
Message:

Customize: Allow controls to be registered without any associated settings.

  • Improves parity between partials and controls. A partial or control can be settingless if instantiated with settings param as empty array (otherwise, if null, then the partial/control ID is used).
  • Eliminate need to create dummy settings that serve no purpose except to place a control in the UI.
  • Removes dummy settings for create_new_menu and new_menu_name.
  • Introduces WP_Customize_Control::$capability and WP_Customize_Partial::$capability, and if set checks them in the respective check_capabilities() methods.
  • Prevents PHP fatal error from happening when non-existing settings are provided to control: "Call to a member function check_capabilities() on a non-object".
  • Fixes issue where nav menu items and widgets were no longer working with selective refresh because cap check was failing.

See #27355.
Fixes #35926.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-customize-nav-menus.php

    r36676 r36689  
    607607        ) ) );
    608608
    609         $this->manager->add_setting( 'new_menu_name', array(
    610             'type'      => 'new_menu',
    611             'default'   => '',
    612             'transport' => isset( $this->manager->selective_refresh ) ? 'postMessage' : 'refresh',
    613         ) );
    614 
    615609        $this->manager->add_control( 'new_menu_name', array(
    616610            'label'       => '',
    617611            'section'     => 'add_menu',
    618612            'type'        => 'text',
     613            'settings'    => array(),
    619614            'input_attrs' => array(
    620615                'class'       => 'menu-name-field',
     
    623618        ) );
    624619
    625         $this->manager->add_setting( 'create_new_menu', array(
    626             'type' => 'new_menu',
    627         ) );
    628 
    629620        $this->manager->add_control( new WP_Customize_New_Menu_Control( $this->manager, 'create_new_menu', array(
    630             'section' => 'add_menu',
     621            'section'  => 'add_menu',
     622            'settings' => array(),
    631623        ) ) );
    632624    }
     
    852844                    'render_callback'     => array( $this, 'render_nav_menu_partial' ),
    853845                    'container_inclusive' => true,
     846                    'settings'            => array(), // Empty because the nav menu instance may relate to a menu or a location.
     847                    'capability'          => 'edit_theme_options',
    854848                )
    855849            );
Note: See TracChangeset for help on using the changeset viewer.