当前位置: 首页>>代码示例>>PHP>>正文


PHP Note::wp_version_compare方法代码示例

本文整理汇总了PHP中Note::wp_version_compare方法的典型用法代码示例。如果您正苦于以下问题:PHP Note::wp_version_compare方法的具体用法?PHP Note::wp_version_compare怎么用?PHP Note::wp_version_compare使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Note的用法示例。


在下文中一共展示了Note::wp_version_compare方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: get_customizer_sidebar_args

 public static function get_customizer_sidebar_args($previewer = false)
 {
     // Bail if lower than WordPress 4.1
     if (Note::wp_version_compare('4.1', '<')) {
         return array();
     }
     global $post, $wp_customize;
     // Grab the Note Sidebars instance
     $note_sidebars = Note_Sidebars();
     // Grab the sidebars widget option
     $sidebars_widgets = get_option('sidebars_widgets');
     // Bail if in the Customizer isn't ready
     if (!is_a($wp_customize, 'WP_Customize_Manager')) {
         return $note_sidebars->sidebar_args;
     }
     // Setup post ID, section prefix, and widgets panel flag
     $post_id = !empty($post) && is_a($post, 'WP_Post') ? $post->ID : false;
     $post_id = apply_filters('note_customizer_sidebar_args_post_id', $post_id, $previewer, $note_sidebars);
     $section_prefix = 'sidebar-widgets-';
     $remove_widgets_panel = false;
     // If the widgets panel doesn't exist yet, create a mock one now with a title for the json() methods used below
     if (!$wp_customize->get_panel('widgets')) {
         // Widgets Panel
         $wp_customize->add_panel('widgets', array('type' => 'widgets', 'title' => __('Widgets', 'note')));
         // Set the flag
         $remove_widgets_panel = true;
     }
     // Format sidebar locations for localizations
     foreach ($note_sidebars->sidebar_locations as $sidebar_location) {
         // Loop through each sidebar within this location
         foreach ($sidebar_location as $sidebar_id) {
             // Note Sidebar arguments for this sidebar
             $sidebar_args = self::note_sidebar_args($sidebar_id, $post_id);
             // Get the sidebar ID
             $customizer_sidebar_id = self::get_sidebar_arg('id', $sidebar_args);
             // Generate a setting ID
             $setting_id = 'sidebars_widgets[' . $customizer_sidebar_id . ']';
             // Create a mock Customizer Setting
             $wp_customize->add_setting($setting_id, $wp_customize->widgets->get_setting_args($setting_id));
             // Generate a section ID
             $section_id = $section_prefix . $customizer_sidebar_id;
             // Create a mock Customizer Section
             $customizer_section = new Note_Customizer_Sidebar_Section($wp_customize, $section_id, array('id' => $section_id, 'title' => self::get_sidebar_arg('name', $sidebar_args), 'description' => self::get_sidebar_arg('description', $sidebar_args), 'sidebar_id' => $customizer_sidebar_id, 'panel' => 'widgets'));
             $wp_customize->add_section($customizer_section);
             // Create a mock Customizer Control
             $customizer_control = new Note_Customizer_Sidebar_Control($wp_customize, $setting_id, array('description' => self::get_sidebar_arg('description', $sidebar_args), 'section' => $section_id, 'sidebar_id' => $customizer_sidebar_id, 'priority' => 0));
             $wp_customize->add_control($customizer_control);
             // Customizer data
             $sidebar_args['customizer'] = array('setting' => array('id' => $setting_id, 'transport' => 'refresh', 'value' => isset($sidebars_widgets[$customizer_sidebar_id]) ? $sidebars_widgets[$customizer_sidebar_id] : array()), 'section' => $customizer_section && method_exists($customizer_section, 'json') ? $customizer_section->json() : array(), 'control' => $customizer_control && method_exists($customizer_control, 'json') ? $customizer_control->json() : array());
             /*
              * Adjust section data
              */
             $sidebar_args['customizer']['section']['active'] = true;
             // Activate this section within the Customizer when it is created
             unset($sidebar_args['customizer']['section']['instanceNumber']);
             // Remove instance number
             /*
              * Adjust control data
              */
             $sidebar_args['customizer']['control']['id'] = $setting_id;
             // ID
             $sidebar_args['customizer']['control']['active'] = true;
             // Activate this control within the Customizer when it is created
             $sidebar_args['customizer']['control']['priority'] = 0;
             // No active widgets
             unset($sidebar_args['customizer']['control']['instanceNumber']);
             // Remove instance number
             // If we're not in the Previewer, remove the mock Settings, Sections, and Controls active
             if (!$previewer) {
                 // Remove Customizer mock setting, section, and control
                 $wp_customize->remove_setting($setting_id);
                 $wp_customize->remove_section($section_id);
                 $wp_customize->remove_control($setting_id);
             }
             // Store a reference to the sidebar arguments
             $note_sidebars->sidebar_args[$sidebar_id] = $sidebar_args;
         }
     }
     // Remove the "mock" Widgets panel (it will be added by WordPress core on the "wp" action)
     if ($remove_widgets_panel) {
         $wp_customize->remove_panel('widgets');
     }
     return $note_sidebars->sidebar_args;
 }
开发者ID:ITJ-RSA,项目名称:note,代码行数:84,代码来源:class-note-sidebars.php

示例2: wp

 /**
  * This function runs after the WP and WP_Query objects are set up.
  */
 function wp()
 {
     // Bail if lower than WordPress 4.1
     if (Note::wp_version_compare('4.1', '<')) {
         return;
     }
     // Note Sidebars (single content types only or if filter returns true)
     if (is_singular() || apply_filters('note_customizer_localize_sidebar_args', false, $this)) {
         // Grab Note Sidebar Customizer arguments (keep Customizer Sections/Controls active for Previewer)
         $this->note_sidebar_args = Note_Sidebars::get_customizer_sidebar_args(true);
         // Note Sidebar args
         if (!isset($this->note_localize['sidebars'])) {
             $this->note_localize['sidebars'] = array();
         }
         $this->note_localize['sidebars']['args'] = apply_filters('note_localize_sidebar_args', $this->note_sidebar_args, $this);
         /*
          * Inactive Widgets
          *
          * WordPress does not create controls for inactive widgets, but we need those controls
          * because sidebars can be removed and added/re-added dynamically. Only do this in the
          * Customizer and only do this for Note Sidebars.
          */
         $this->register_inactive_note_widgets(true);
     }
 }
开发者ID:ITJ-RSA,项目名称:note,代码行数:28,代码来源:class-note-customizer.php

示例3: is_customize_preview

 /**
  * This function determines we're currently being previewed in the Customizer.
  */
 public function is_customize_preview()
 {
     $is_gte_wp_4 = Note::wp_version_compare('4.0');
     // Less than 4.0
     if (!$is_gte_wp_4) {
         global $wp_customize;
         return is_a($wp_customize, 'WP_Customize_Manager') && $wp_customize->is_preview();
     } else {
         return is_customize_preview();
     }
 }
开发者ID:ITJ-RSA,项目名称:note,代码行数:14,代码来源:class-note-widget.php


注:本文中的Note::wp_version_compare方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。