Changeset 30329
- Timestamp:
- 11/13/2014 12:18:01 PM (10 years ago)
- Location:
- trunk/src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/js/customize-controls.js
r30309 r30329 1349 1349 } 1350 1350 1351 /* 1352 * Walk over all panels, sections, and controls and set their 1353 * respective active states to true if the preview explicitly 1354 * indicates as such. 1355 */ 1351 1356 var constructs = { 1352 1357 panel: data.activePanels, … … 1354 1359 control: data.activeControls 1355 1360 }; 1356 1357 $.each( constructs, function ( type, activeConstructs ) { 1358 if ( activeConstructs ) { 1359 $.each( activeConstructs, function ( id, active ) { 1360 var construct = api[ type ]( id ); 1361 if ( construct ) { 1362 construct.active( active ); 1363 } 1364 } ); 1365 } 1361 _( constructs ).each( function ( activeConstructs, type ) { 1362 api[ type ].each( function ( construct, id ) { 1363 var active = !! ( activeConstructs && activeConstructs[ id ] ); 1364 construct.active( active ); 1365 } ); 1366 1366 } ); 1367 1368 1367 } ); 1369 1368 -
trunk/src/wp-admin/js/customize-widgets.js
r30308 r30329 1369 1369 1370 1370 /** 1371 * wp.customize.Widgets.SidebarSection 1372 * 1373 * Customizer section representing a widget area widget 1374 * 1375 * @since 4.1.0 1376 */ 1377 api.Widgets.SidebarSection = api.Section.extend({ 1378 1379 /** 1380 * Sync the section's active state back to the Backbone model's is_rendered attribute 1381 */ 1382 ready: function () { 1383 var section = this, registeredSidebar; 1384 api.Section.prototype.ready.call( this ); 1385 registeredSidebar = api.Widgets.registeredSidebars.get( section.params.sidebarId ); 1386 section.active.bind( function ( active ) { 1387 registeredSidebar.set( 'is_rendered', active ); 1388 }); 1389 registeredSidebar.set( 'is_rendered', section.active() ); 1390 }, 1391 1392 /** 1393 * Override Section.isContextuallyActive() to skip considering 1394 * SidebarControl as opposed to a WidgetControl. 1395 * 1396 * @returns {boolean} 1397 */ 1398 isContextuallyActive: function () { 1399 var section, activeCount; 1400 section = this; 1401 activeCount = 0; 1402 _( section.controls() ).each( function ( control ) { 1403 if ( control.active() && ! control.extended( api.Widgets.SidebarControl ) ) { 1404 activeCount += 1; 1405 } 1406 }); 1407 return ( activeCount !== 0 ); 1408 } 1409 }); 1410 1411 /** 1371 1412 * wp.customize.Widgets.SidebarControl 1372 1413 * … … 1374 1415 * Note that 'sidebar_widgets' must match the WP_Widget_Area_Customize_Control::$type 1375 1416 * 1417 * @since 3.9.0 1418 * 1376 1419 * @constructor 1377 1420 * @augments wp.customize.Control … … 1396 1439 */ 1397 1440 _setupModel: function() { 1398 var self = this, 1399 registeredSidebar = api.Widgets.registeredSidebars.get( this.params.sidebar_id ); 1441 var self = this; 1400 1442 1401 1443 this.setting.bind( function( newWidgetIds, oldWidgetIds ) { … … 1500 1542 } ); 1501 1543 } ); 1502 1503 // Update the model with whether or not the sidebar is rendered1504 self.active.bind( function ( active ) {1505 registeredSidebar.set( 'is_rendered', active );1506 api.section( self.section.get() ).active( active );1507 } );1508 api.section( self.section.get() ).active( self.active() );1509 1544 }, 1510 1545 … … 1817 1852 } ); 1818 1853 1819 / **1820 * Extends wp.customizer.controlConstructor with control constructor for1821 * widget_form and sidebar_widgets.1822 */1854 // Register models for custom section and control types 1855 $.extend( api.sectionConstructor, { 1856 sidebar: api.Widgets.SidebarSection 1857 }); 1823 1858 $.extend( api.controlConstructor, { 1824 1859 widget_form: api.Widgets.WidgetControl, -
trunk/src/wp-includes/class-wp-customize-control.php
r30326 r30329 1116 1116 } 1117 1117 1118 /**1119 * Whether the current sidebar is rendered on the page.1120 *1121 * @since 4.0.01122 * @access public1123 *1124 * @return bool Whether sidebar is rendered.1125 */1126 public function active_callback() {1127 return $this->manager->widgets->is_sidebar_rendered( $this->sidebar_id );1128 }1129 1118 } 1130 1119 -
trunk/src/wp-includes/class-wp-customize-manager.php
r30309 r30329 516 516 foreach ( $this->panels as $id => $panel ) { 517 517 $settings['activePanels'][ $id ] = $panel->active(); 518 foreach ( $panel->sections as $id => $section ) { 519 $settings['activeSections'][ $id ] = $section->active(); 520 } 518 521 } 519 522 foreach ( $this->sections as $id => $section ) { -
trunk/src/wp-includes/class-wp-customize-section.php
r30214 r30329 311 311 } 312 312 } 313 314 /** 315 * Customizer section representing widget area (sidebar). 316 * 317 * @package WordPress 318 * @subpackage Customize 319 * @since 4.1.0 320 */ 321 class WP_Customize_Sidebar_Section extends WP_Customize_Section { 322 323 /** 324 * @since 4.1.0 325 * @access public 326 * @var string 327 */ 328 public $type = 'sidebar'; 329 330 /** 331 * Unique identifier. 332 * 333 * @since 4.1.0 334 * @access public 335 * @var string 336 */ 337 public $sidebar_id; 338 339 /** 340 * Gather the parameters passed to client JavaScript via JSON. 341 * 342 * @since 4.1.0 343 * 344 * @return array The array to be exported to the client as JSON 345 */ 346 public function json() { 347 $json = parent::json(); 348 $json['sidebarId'] = $this->sidebar_id; 349 return $json; 350 } 351 352 /** 353 * Whether the current sidebar is rendered on the page. 354 * 355 * @since 4.1.0 356 * @access public 357 * 358 * @return bool Whether sidebar is rendered. 359 */ 360 public function active_callback() { 361 return $this->manager->widgets->is_sidebar_rendered( $this->sidebar_id ); 362 } 363 } -
trunk/src/wp-includes/class-wp-customize-widgets.php
r30055 r30329 469 469 'priority' => array_search( $sidebar_id, array_keys( $wp_registered_sidebars ) ), 470 470 'panel' => 'widgets', 471 'sidebar_id' => $sidebar_id, 471 472 ); 472 473 … … 482 483 $section_args = apply_filters( 'customizer_widgets_section_args', $section_args, $section_id, $sidebar_id ); 483 484 484 $this->manager->add_section( $section_id, $section_args ); 485 $section = new WP_Customize_Sidebar_Section( $this->manager, $section_id, $section_args ); 486 $this->manager->add_section( $section ); 485 487 486 488 $control = new WP_Widget_Area_Customize_Control( $this->manager, $setting_id, array(
Note: See TracChangeset
for help on using the changeset viewer.