本文整理汇总了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());
}
示例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);
}
示例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;
}
}
示例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');
}
}
}
示例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);
}
}
}
示例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'));
}
}
}
示例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);
}
}
示例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));
}
}
}