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


PHP WP_Customize_Setting::post_value方法代码示例

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


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

示例1: _save_post_id

 /**
  * Save data in special option for better performance in query
  *
  * @param \WP_Customize_Setting $setting
  */
 protected function _save_post_id($setting)
 {
     Posts::update($setting->id, $setting->post_value());
 }
开发者ID:Viktor777,项目名称:wp-customize-builder,代码行数:9,代码来源:Post.php

示例2: menu_customizer_preview_nav_menu

/**
 * Preview changes made to a nav menu.
 *
 * Filters nav menu display to show customized items in the customized order.
 *
 * @since Menu Customizer 0.0
 *
 * @param array                $value   Array of the menu items to preview, in order.
 * @param WP_Customize_Setting $setting WP_Customize_Setting instance.
 */
function menu_customizer_preview_nav_menu($setting)
{
    $menu_id = str_replace('nav_menu_', '', $setting->id);
    // Ensure that $menu_id is valid.
    $menu_id = (int) $menu_id;
    $menu = wp_get_nav_menu_object($menu_id);
    if (!$menu || !$menu_id) {
        return new WP_Error('invalid_menu_id', __('Invalid menu ID.'));
    }
    if (is_wp_error($menu)) {
        return $menu;
    }
    $menu_id = $menu->term_id;
    // @todo don't use a closure for PHP 5.2
    add_filter('wp_get_nav_menu_items', function ($items, $menu, $args) use($menu_id, $setting) {
        $preview_menu_id = $menu->term_id;
        if ($menu_id == $preview_menu_id) {
            $new_ids = $setting->post_value();
            $new_items = array();
            $i = 0;
            // For each item, get object and update menu order property.
            foreach ($new_ids as $item_id) {
                $item = get_post($item_id);
                $item = wp_setup_nav_menu_item($item);
                $item->menu_order = $i;
                $new_items[] = $item;
                $i++;
            }
            return $new_items;
        } else {
            return $items;
        }
    }, 10, 3);
}
开发者ID:dauidus,项目名称:woof,代码行数:44,代码来源:menu-customizer.php

示例3:

 /**
  * @param WP_Customize_Setting $setting
  */
 function custom_type_preview($setting)
 {
     $previewed_value = $setting->post_value($this->undefined);
     if ($this->undefined !== $previewed_value) {
         $this->custom_type_data_previewed[$setting->id] = $previewed_value;
     }
 }
开发者ID:atimmer,项目名称:wordpress-develop-mirror,代码行数:10,代码来源:setting.php

示例4: save_nav_menus_created_posts

 /**
  * Publish the auto-draft posts that were created for nav menu items.
  *
  * The post IDs will have been sanitized by already by
  * `WP_Customize_Nav_Menu_Items::sanitize_nav_menus_created_posts()` to
  * remove any post IDs for which the user cannot publish or for which the
  * post is not an auto-draft.
  *
  * @since 4.7.0
  * @access public
  *
  * @param WP_Customize_Setting $setting Customizer setting object.
  */
 public function save_nav_menus_created_posts($setting)
 {
     $post_ids = $setting->post_value();
     if (!empty($post_ids)) {
         foreach ($post_ids as $post_id) {
             $target_status = 'attachment' === get_post_type($post_id) ? 'inherit' : 'publish';
             $args = array('ID' => $post_id, 'post_status' => $target_status);
             $post_name = get_post_meta($post_id, '_customize_draft_post_name', true);
             if ($post_name) {
                 $args['post_name'] = $post_name;
             }
             // Note that wp_publish_post() cannot be used because unique slugs need to be assigned.
             wp_update_post(wp_slash($args));
             delete_post_meta($post_id, '_customize_draft_post_name');
         }
     }
 }
开发者ID:CompositeUK,项目名称:clone.WordPress-Core,代码行数:30,代码来源:class-wp-customize-nav-menus.php

示例5: save_nav_menus_created_posts

 /**
  * Publish the auto-draft posts that were created for nav menu items.
  *
  * The post IDs will have been sanitized by already by
  * `WP_Customize_Nav_Menu_Items::sanitize_nav_menus_created_posts()` to
  * remove any post IDs for which the user cannot publish or for which the
  * post is not an auto-draft.
  *
  * @since 4.7.0
  * @access public
  *
  * @param WP_Customize_Setting $setting Customizer setting object.
  */
 public function save_nav_menus_created_posts($setting)
 {
     $post_ids = $setting->post_value();
     if (!empty($post_ids)) {
         foreach ($post_ids as $post_id) {
             wp_publish_post($post_id);
         }
     }
 }
开发者ID:nicholasgriffintn,项目名称:WordPress,代码行数:22,代码来源:class-wp-customize-nav-menus.php

示例6: save_nav_menus_created_posts

 /**
  * Publish the auto-draft posts that were created for nav menu items.
  *
  * The post IDs will have been sanitized by already by
  * `WP_Customize_Nav_Menu_Items::sanitize_nav_menus_created_posts()` to
  * remove any post IDs for which the user cannot publish or for which the
  * post is not an auto-draft.
  *
  * @since 4.7.0
  * @access public
  *
  * @param WP_Customize_Setting $setting Customizer setting object.
  */
 public function save_nav_menus_created_posts($setting)
 {
     $post_ids = $setting->post_value();
     if (!empty($post_ids)) {
         foreach ($post_ids as $post_id) {
             // Note that wp_publish_post() cannot be used because unique slugs need to be assigned.
             wp_update_post(array('ID' => $post_id, 'post_status' => 'publish'));
         }
     }
 }
开发者ID:aaemnnosttv,项目名称:develop.git.wordpress.org,代码行数:23,代码来源:class-wp-customize-nav-menus.php

示例7: array

 function set_wp2android_theme_menu($wp_customize)
 {
     $setting = new WP_Customize_Setting($wp_customize, 'wp2android_theme_menu', array('default' => ''));
     $menu = $setting->post_value();
     $wp_customize->add_setting($setting);
     if (!empty($menu)) {
         wp2android_plugin_menus()->setMenu($menu);
     }
 }
开发者ID:apppressers,项目名称:apppressers.github.io,代码行数:9,代码来源:switcher.php

示例8: save_nav_menus_created_posts

 /**
  * Publish the auto-draft posts that were created for nav menu items.
  *
  * The post IDs will have been sanitized by already by
  * `WP_Customize_Nav_Menu_Items::sanitize_nav_menus_created_posts()` to
  * remove any post IDs for which the user cannot publish or for which the
  * post is not an auto-draft.
  *
  * @since 4.7.0
  * @access public
  *
  * @param WP_Customize_Setting $setting Customizer setting object.
  */
 public function save_nav_menus_created_posts($setting)
 {
     $post_ids = $setting->post_value();
     if (!empty($post_ids)) {
         foreach ($post_ids as $post_id) {
             $target_status = 'attachment' === get_post_type($post_id) ? 'inherit' : 'publish';
             // Note that wp_publish_post() cannot be used because unique slugs need to be assigned.
             wp_update_post(array('ID' => $post_id, 'post_status' => $target_status));
         }
     }
 }
开发者ID:johnpbloch,项目名称:wordpress,代码行数:24,代码来源:class-wp-customize-nav-menus.php


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