當前位置: 首頁>>代碼示例>>PHP>>正文


PHP WP_Customize_Manager::controls方法代碼示例

本文整理匯總了PHP中WP_Customize_Manager::controls方法的典型用法代碼示例。如果您正苦於以下問題:PHP WP_Customize_Manager::controls方法的具體用法?PHP WP_Customize_Manager::controls怎麽用?PHP WP_Customize_Manager::controls使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在WP_Customize_Manager的用法示例。


在下文中一共展示了WP_Customize_Manager::controls方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: array

 /**
  * Temporarily remove widget settings and controls from the Manager so that
  * they won't be serialized at once in _wpCustomizeSettings. This greatly
  * reduces the peak memory usage.
  *
  * This is only relevant in WordPress versions older than 4.4-alpha-33636-src,
  * with the changes introduced in Trac #33898.
  *
  * @link https://core.trac.wordpress.org/ticket/33898
  */
 function defer_serializing_data_until_shutdown()
 {
     $this->customize_controls = array();
     $controls = $this->manager->controls();
     foreach ($controls as $control) {
         if ($control instanceof \WP_Widget_Form_Customize_Control || $control instanceof \WP_Widget_Area_Customize_Control) {
             $this->customize_controls[$control->id] = $control;
             $this->manager->remove_control($control->id);
         }
     }
     /*
      * Note: There is currently a Core dependency issue where the control for WP_Widget_Area_Customize_Control
      * must be processed after the control for WP_Widget_Form_Customize_Control, as otherwise the sidebar
      * does not initialize properly (specifically in regards to the reorder-toggle button. So this is why
      * we are including the WP_Widget_Area_Customize_Controls among those which are deferred.
      */
     $this->customize_settings = array();
     $settings = $this->manager->settings();
     foreach ($settings as $setting) {
         if (preg_match('/^(widget_.+?\\[\\d+\\]|sidebars_widgets\\[.+?\\])$/', $setting->id)) {
             $this->customize_settings[$setting->id] = $setting;
             $this->manager->remove_setting($setting->id);
         }
     }
     // We have to use shutdown because no action is triggered after _wpCustomizeSettings is written.
     add_action('shutdown', array($this, 'export_data_with_peak_memory_usage_minimized'), 10);
     add_action('shutdown', array($this, 'fixup_widget_control_params_for_dom_deferral'), 11);
 }
開發者ID:BE-Webdesign,項目名稱:wp-customize-widgets-plus,代碼行數:38,代碼來源:class-deferred-customize-widgets.php

示例2: array

 /**
  * @ticket 37128
  */
 function test_prepare_controls_wp_list_sort_controls()
 {
     wp_set_current_user(self::$admin_user_id);
     $controls = array('foo' => 2, 'bar' => 4, 'foobar' => 3, 'key' => 1);
     $controls_sorted = array('key', 'foo', 'foobar', 'bar');
     $this->manager->add_section('foosection', array());
     foreach ($controls as $control_id => $priority) {
         $this->manager->add_setting($control_id);
         $this->manager->add_control($control_id, array('priority' => $priority, 'section' => 'foosection'));
     }
     $this->manager->prepare_controls();
     $result = $this->manager->controls();
     $this->assertEquals($controls_sorted, array_keys($result));
 }
開發者ID:CompositeUK,項目名稱:clone.WordPress-Develop,代碼行數:17,代碼來源:manager.php


注:本文中的WP_Customize_Manager::controls方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。