當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。