• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP wp_is_post_autosave函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中wp_is_post_autosave函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_is_post_autosave函数的具体用法?PHP wp_is_post_autosave怎么用?PHP wp_is_post_autosave使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: update_orders_value

	public static function update_orders_value( $post_id, $post ) {
		if ( is_int( wp_is_post_revision( $post_id ) ) ) return;
		if ( is_int( wp_is_post_autosave( $post_id ) ) ) return;
		if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE ) return $post_id;
		if ( ! current_user_can( 'edit_post', $post_id ) ) return $post_id;
		if ( $post->post_type != 'product' ) return $post_id;
		
		if ( version_compare( WC()->version, '2.2.0', '<' ) ) {
			$product 	= get_product( $post );
		} else {
			$product 	= wc_get_product( $post );
		}
		if ( $product ) {
			if ( $product->is_on_sale() ) {
				update_post_meta( $post_id, '_psad_onsale_order', 2 );
			} else {
				update_post_meta( $post_id, '_psad_onsale_order', 1 );
			}
			if ( $product->is_featured() ) {
				update_post_meta( $post_id, '_psad_featured_order', 2 );
			} else {
				update_post_meta( $post_id, '_psad_featured_order', 1 );	
			}
		}
	}
开发者ID:helloworld-digital,项目名称:katemorgan,代码行数:25,代码来源:class-wc-psad-functions.php


示例2: save_default_post_categories

 /**
  * This function set post in default category.
  *
  * @param $post_ID
  *
  * @return mixed
  */
 public function save_default_post_categories($post_ID)
 {
     if (wp_is_post_autosave($post_ID) || wp_is_post_revision($post_ID)) {
         return $post_ID;
     }
     $categories = wp_get_post_categories($post_ID);
     if (count($categories) === 1 && $categories[0] === (int) get_option('default_category')) {
         $cats = (array) $this->get_default_post_category_by_lang(get_post_meta($post_ID, 'translation_lang', true));
         wp_set_post_categories($post_ID, $cats);
     }
 }
开发者ID:albertso,项目名称:Unyson-Translation-Extension,代码行数:18,代码来源:class-fw-extension-translate-terms.php


示例3: wc_tab_manager_meta_boxes_save

/**
 * Runs when a post is saved and does an action which the write panel save scripts can hook into.
 *
 * @access public
 * @param int $post_id post identifier
 * @param object $post post object
 */
function wc_tab_manager_meta_boxes_save($post_id, $post)
{
    if (empty($post_id) || empty($post) || empty($_POST)) {
        return;
    }
    if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
        return;
    }
    if (is_int(wp_is_post_revision($post))) {
        return;
    }
    if (is_int(wp_is_post_autosave($post))) {
        return;
    }
    if (empty($_POST['woocommerce_meta_nonce']) || !wp_verify_nonce($_POST['woocommerce_meta_nonce'], 'woocommerce_save_data')) {
        return;
    }
    if (!current_user_can('edit_post', $post_id)) {
        return;
    }
    if ('wc_product_tab' != $post->post_type) {
        return;
    }
    do_action('woocommerce_process_wc_product_tab_meta', $post_id, $post);
    woocommerce_meta_boxes_save_errors();
}
开发者ID:shahadat014,项目名称:geleyi,代码行数:33,代码来源:writepanels-init.php


示例4: dwci_meta_save_event

 /**
  * Function responsible for saving the event post.
  */
 function dwci_meta_save_event($post_id)
 {
     $is_autosave = wp_is_post_autosave($post_id);
     $is_revision = wp_is_post_revision($post_id);
     $is_valid_nonce = isset($_POST['dwci_events_nonce']) && wp_verify_nonce($_POST['dwci_events_nonce'], 'ppl-event-nonce') ? true : false;
     if ($is_autosave || $is_revision || !$is_valid_nonce) {
         return;
     }
     if (isset($_POST['event_id'])) {
         update_post_meta($post_id, 'event_id', sanitize_text_field($_POST['event_id']));
     }
     if (!isset($_POST['event_id']) || empty($_POST['event_id'])) {
         //exit('EVPPTF01032016');
         return;
         //$error = new WP_Error( 'event_id', sprintf( __( 'You have forgotten to specify the %1$s for your function. %2$s Error triggered inside %3$s on line %4$s.', TEXTDOMAIN ), '$args[\'event_id\']', "\n", __FILE__, __LINE__ ) );
     }
     if (isset($_POST['event_date'])) {
         update_post_meta($post_id, 'event_date', sanitize_text_field($_POST['event_date']));
     }
     if (isset($_POST['event_reg_start'])) {
         update_post_meta($post_id, 'event_reg_start', sanitize_text_field($_POST['event_reg_start']));
     }
     if (isset($_POST['event_open_seats'])) {
         update_post_meta($post_id, 'event_open_seats', sanitize_text_field($_POST['event_open_seats']));
     }
 }
开发者ID:Socratemus,项目名称:ptf-wp-plugin,代码行数:29,代码来源:EventCtrl.php


示例5: save_post

 /**
  * Generate a pdf for the post when it is updated.
  * @param $post_id
  * @param $post
  */
 public static function save_post($post_id, $post)
 {
     if (wp_is_post_autosave($post_id) || wp_is_post_revision($post_id) || !post_type_supports($post->post_type, 'print_pdf') || isset($_REQUEST['bulk_edit'])) {
         return $post_id;
     }
     self::save_pdf($post);
 }
开发者ID:voceconnect,项目名称:voce-post-pdfs,代码行数:12,代码来源:voce-post-pdfs.php


示例6: save_meta_boxes

 /**
  * Check if we're saving, the trigger an action based on the post type.
  * @param int $post_id
  * @param object $post
  */
 public function save_meta_boxes($post_id, $post)
 {
     // $post_id and $post are required
     if (empty($post_id) || empty($post) || self::$saved_meta_boxes) {
         return;
     }
     // Don't save meta boxes for revisions or autosaves
     if (defined('DOING_AUTOSAVE') || is_int(wp_is_post_revision($post)) || is_int(wp_is_post_autosave($post))) {
         return;
     }
     // Check the nonce
     if (empty($_POST['restaurantpress_meta_nonce']) || !wp_verify_nonce($_POST['restaurantpress_meta_nonce'], 'restaurantpress_save_data')) {
         return;
     }
     // Check the post being saved == the $post_id to prevent triggering this call for other save_post events
     if (empty($_POST['post_ID']) || $_POST['post_ID'] != $post_id) {
         return;
     }
     // Check user has permission to edit
     if (!current_user_can('edit_post', $post_id)) {
         return;
     }
     // We need this save event to run once to avoid potential endless loops. This would have been perfect:
     self::$saved_meta_boxes = true;
     // Check the post type
     if (in_array($post->post_type, array('food_menu', 'food_group'))) {
         do_action('restaurantpress_process_' . $post->post_type . '_meta', $post_id, $post);
     }
 }
开发者ID:themegrill,项目名称:restaurantpress,代码行数:34,代码来源:class-rp-admin-meta-boxes.php


示例7: save_meta_box

 public function save_meta_box($post_id)
 {
     // Checks save status
     $is_autosave = wp_is_post_autosave($post_id);
     $is_revision = wp_is_post_revision($post_id);
     $is_valid_nonce = isset($_POST['heimdall_meta_box_nonce']) && wp_verify_nonce($_POST['heimdall_meta_box_nonce'], 'heimdall_meta_box') ? 'true' : 'false';
     // Exits script depending on save status
     if ($is_autosave || $is_revision || !$is_valid_nonce) {
         return $post_id;
     }
     // Check the user's permissions.
     if ('page' == $_POST['post_type']) {
         if (!current_user_can('edit_page', $post_id)) {
             return $post_id;
         }
     } else {
         if (!current_user_can('edit_post', $post_id)) {
             return $post_id;
         }
     }
     // Update the post meta
     if (isset($_POST['heimdall_secured_page'])) {
         update_post_meta($post_id, '_heimdall_secured_page', 1);
     } else {
         delete_post_meta($post_id, '_heimdall_secured_page');
     }
     if (isset($_POST['heimdall_whitelist']) && is_array($_POST['heimdall_whitelist'])) {
         update_post_meta($post_id, '_heimdall_whitelist', $_POST['heimdall_whitelist']);
     } else {
         delete_post_meta($post_id, '_heimdall_whitelist');
     }
 }
开发者ID:danillotuhumury,项目名称:heimdall,代码行数:32,代码来源:class.heimdall-admin.php


示例8: save_meta_boxes

 /**
  * Save meta boxes.
  *
  * @param int    $post_id
  * @param object $post
  */
 public function save_meta_boxes($post_id, $post)
 {
     // Can't proceed without a post id or post.
     if (empty($post_id) || empty($post)) {
         return;
     }
     // Don't save meta boxes for revisions or autosaves
     if (defined('DOING_AUTOSAVE') || is_int(wp_is_post_revision($post)) || is_int(wp_is_post_autosave($post))) {
         return;
     }
     // Check the post being saved has the same id as the post id.
     // This will prevent other save post events.
     if ($this->valid_post_id($post_id)) {
         return;
     }
     // Check if our nonce is vailed.
     if (!wp_verify_nonce(papi_get_sanitized_post('papi_meta_nonce'), 'papi_save_data')) {
         return;
     }
     // Check for any of the capabilities before we save the code.
     if (!current_user_can('edit_posts') || !current_user_can('edit_pages')) {
         return;
     }
     $this->save_properties($post_id);
 }
开发者ID:ekandreas,项目名称:papi,代码行数:31,代码来源:class-papi-admin-post-handler.php


示例9: save

 function save($post_id)
 {
     /**
      * Perform checks
      */
     if (wp_is_post_revision($post_id) || wp_is_post_autosave($post_id)) {
         return;
     }
     if (isset($_REQUEST['doing_wp_cron'])) {
         return;
     }
     if (isset($_REQUEST['post_view'])) {
         return;
     }
     if (!isset($_POST['post_type']) || 'gc' != $_POST['post_type']) {
         return;
     }
     /**
      * Save data
      */
     $post = get_post($post_id);
     if (!get_post_meta($post_id, '_gc_id', true) && 'publish' == $post->post_status) {
         update_post_meta($post_id, '_gc_id', self::get_id($post->post_title));
     }
 }
开发者ID:trendwerk,项目名称:global-content-blocks,代码行数:25,代码来源:class-tp-global-content-blocks.php


示例10: __action_save_post

 public function __action_save_post($post_id)
 {
     if (wp_is_post_autosave($post_id) || wp_is_post_revision($post_id)) {
         return $post_id;
     }
     $post_type = get_post_type($post_id);
     foreach ($this->connection_factory->get_connections() as $connection) {
         $connection_args = $connection->get_args();
         if (isset($_POST[$connection->get_name() . '_' . 'to']) && isset($_POST[$connection->get_name() . '_to_nonce']) && wp_verify_nonce($_POST[$connection->get_name() . '_to_nonce'], 'set_' . $connection->get_name() . '_to_' . $post_id)) {
             if (in_array($post_type, $connection->from())) {
                 $to_ids = empty($_POST[$connection->get_name() . '_to']) ? array() : array_map('intval', explode(',', $_POST[$connection->get_name() . '_to']));
                 $connection->set_connected_to($post_id, $to_ids);
             }
         }
         if ($connection_args['reciprocal'] && isset($_POST[$connection->get_name() . '_' . 'from']) && isset($_POST[$connection->get_name() . '_from_nonce']) && wp_verify_nonce($_POST[$connection->get_name() . '_from_nonce'], 'set_' . $connection->get_name() . '_from_' . $post_id)) {
             if (in_array($post_type, $connection->to())) {
                 $from_ids = empty($_POST[$connection->get_name() . '_from']) ? array() : array_map('intval', explode(',', $_POST[$connection->get_name() . '_from']));
                 $current_from_ids = $connection->get_connected_from_objects($post_id);
                 //remove this post from all the posts this item was removed from
                 foreach (array_diff($current_from_ids, $from_ids) as $from_id_to_remove) {
                     $current_to_ids = $connection->get_connected_to_objects($from_id_to_remove);
                     if (false !== ($offset = array_search($post_id, $current_to_ids))) {
                         array_splice($current_to_ids, $offset, 1);
                     }
                     $connection->set_connected_to($from_id_to_remove, $current_to_ids);
                 }
                 //add this post to all of the currently selected items
                 foreach (array_diff($from_ids, $current_from_ids) as $from_id_to_add) {
                     $connection->set_connected_to($from_id_to_add, array($post_id), true);
                 }
             }
         }
     }
 }
开发者ID:humanmade,项目名称:vip-mu-plugins-public,代码行数:34,代码来源:admin.php


示例11: can_save_post_meta

 /**
  * Determines whether or not post meta can be saved.
  *
  * @param int $post_id The id of the post being saved.
  * @param string $action The feature's action.
  * @param string $nonce The feature's nonce.
  * @return boolean Whether the post meta can saved or not.
  */
 public function can_save_post_meta($post_id, $action, $nonce)
 {
     $is_autosave = wp_is_post_autosave($post_id);
     $is_revision = wp_is_post_revision($post_id);
     $is_valid_nonce = isset($_POST[$nonce]) && wp_verify_nonce($_POST[$nonce], $action);
     return !($is_autosave || $is_revision) && $is_valid_nonce;
 }
开发者ID:manovotny,项目名称:wp-post-type-util,代码行数:15,代码来源:class-wp-post-type-util.php


示例12: possiblyAddPostThumbnail

 public function possiblyAddPostThumbnail($postId, $post = false)
 {
     if (!$post) {
         $post = get_post($postId);
     }
     if (false === (wp_is_post_autosave($postId) || wp_is_post_revision($postId)) && post_type_supports($post->post_type, 'thumbnail')) {
         $thumb = get_post_thumbnail_id($postId);
         if (empty($thumb)) {
             // get images as attachements
             $images = get_posts(array('post_type' => 'attachment', 'post_mime_type' => 'image', 'post_parent' => $postId, 'order' => 'ASC', 'orderby' => 'post_date', 'numberposts' => 1));
             if (!is_array($images) || count($images) == 0) {
                 // if there are no attachments, search post content
                 preg_match_all('|<img.*?src=[\'"](.*?)[\'"].*?>|i', $post->post_content, $matches);
                 // search for uploaded images in the post
                 if (isset($matches) && isset($matches[1][0]) && strlen(trim($matches[1][0])) > 0) {
                     $image = $matches[1][0];
                     $this->uploadThumb($post, $image);
                 }
             } else {
                 $image = array_shift($images);
                 update_post_meta($postId, '_thumbnail_id', $image->ID);
                 return true;
             }
         }
     }
 }
开发者ID:jorgeasaldivar,项目名称:auto-thumbnailer,代码行数:26,代码来源:auto-thumbnailer.php


示例13: save

 /**
  * Save meta data
  *
  * @param int $post_id
  * @param \WP_Post $post
  */
 public function save($post_id, $post)
 {
     if (empty($post_id) || empty($post) || empty($_POST)) {
         return;
     }
     if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
         return;
     }
     if (is_int(wp_is_post_revision($post))) {
         return;
     }
     if (is_int(wp_is_post_autosave($post))) {
         return;
     }
     if (empty($_POST['license_wp_nonce']) || !wp_verify_nonce($_POST['license_wp_nonce'], 'save_meta_data')) {
         return;
     }
     if (!current_user_can('edit_post', $post_id)) {
         return;
     }
     if ($post->post_type != 'api_product') {
         return;
     }
     do_action('license_wp_save_api_product', $post_id, $post);
 }
开发者ID:ChromeOrange,项目名称:license-wp,代码行数:31,代码来源:ApiProductData.php


示例14: site_subheader_metabox_save

function site_subheader_metabox_save($post_id)
{
    // Checks save status
    $is_autosave = wp_is_post_autosave($post_id);
    $is_revision = wp_is_post_revision($post_id);
    $is_valid_nonce = isset($_POST['sc_nonce']) && wp_verify_nonce($_POST['sc_nonce'], basename(__FILE__)) ? 'true' : 'false';
    // Exits script depending on save status
    if ($is_autosave || $is_revision || !$is_valid_nonce) {
        return;
    }
    // Checks for input and sanitizes/saves if needed
    if (isset($_POST['site-subheader-title'])) {
        update_post_meta($post_id, 'site-subheader-title', sanitize_text_field($_POST['site-subheader-title']));
    }
    if (isset($_POST['site-subheader-text'])) {
        update_post_meta($post_id, 'site-subheader-text', sanitize_text_field($_POST['site-subheader-text']));
    }
    if (isset($_POST['button-title'])) {
        update_post_meta($post_id, 'button-title', sanitize_text_field($_POST['button-title']));
    }
    if (isset($_POST['button-url'])) {
        update_post_meta($post_id, 'button-url', sanitize_text_field($_POST['button-url']));
    }
    if (isset($_POST['button-alt'])) {
        update_post_meta($post_id, 'button-alt', sanitize_text_field($_POST['button-alt']));
    }
}
开发者ID:steticode,项目名称:steticode-site,代码行数:27,代码来源:site-subheader-metabox.php


示例15: save_data

 /**
  * Saves Metabox data to a database.
  *
  * @param int    $post_id ID of the post we are working with.
  * @param object $post    Post object.
  * @since 0.1.0
  */
 public function save_data($post_id, $post)
 {
     // Check if nonce is set.
     if (!isset($_POST['_portfolio_toolkit_nonce'])) {
         return;
     }
     // In case it is, verify it.
     $nonce = sanitize_key($_POST['_portfolio_toolkit_nonce']);
     if (!wp_verify_nonce($nonce, plugin_basename(__FILE__))) {
         return;
     }
     // Return if it is a revision or autosave.
     if (wp_is_post_autosave($post->ID) || wp_is_post_revision($post->ID)) {
         return;
     }
     // Is the user allowed to edit the post or page?
     if (!current_user_can('edit_post', $post->ID)) {
         return;
     }
     // Loop through meta array, saving or deleting data.
     foreach ($this->get_fields() as $field) {
         if (isset($_POST[$field['name']])) {
             // Sanitize and save data.
             if ('url' == $field['sntz']) {
                 $value = esc_url_raw(wp_unslash($_POST[$field['name']]));
             } else {
                 $value = sanitize_text_field(wp_unslash($_POST[$field['name']]));
             }
             update_post_meta($post->ID, $field['name'], $value);
         } else {
             delete_post_meta($post->ID, $field['name']);
         }
     }
 }
开发者ID:andreitache,项目名称:portfolio-toolkit,代码行数:41,代码来源:class-portfolio-toolkit-admin-meta.php


示例16: user_can_save

 public function user_can_save($post_id)
 {
     $is_valid_nonce = isset($_POST['tmj-post-notice-nonce']) && wp_verify_nonce($_POST['tmj-post-notice-nonce'], 'tmj-post-notice-save');
     $is_autosave = wp_is_post_autosave($post_id);
     $is_revision = wp_is_post_revision($post_id);
     return !($is_autosave || $is_revision) && $is_valid_nonce;
 }
开发者ID:Theminijohn,项目名称:wp-post-notice,代码行数:7,代码来源:class-tmj-post-editor.php


示例17: woocommerce_meta_boxes_save

function woocommerce_meta_boxes_save($post_id, $post)
{
    global $wpdb;
    if (!$_POST) {
        return $post_id;
    }
    if (is_int(wp_is_post_revision($post_id))) {
        return;
    }
    if (is_int(wp_is_post_autosave($post_id))) {
        return;
    }
    if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
        return $post_id;
    }
    if (!isset($_POST['woocommerce_meta_nonce']) || isset($_POST['woocommerce_meta_nonce']) && !wp_verify_nonce($_POST['woocommerce_meta_nonce'], 'woocommerce_save_data')) {
        return $post_id;
    }
    if (!current_user_can('edit_post', $post_id)) {
        return $post_id;
    }
    if ($post->post_type != 'product' && $post->post_type != 'shop_order' && $post->post_type != 'shop_coupon') {
        return $post_id;
    }
    do_action('woocommerce_process_' . $post->post_type . '_meta', $post_id, $post);
}
开发者ID:bidhanbaral,项目名称:fotodep_store,代码行数:26,代码来源:writepanels-init.php


示例18: royal_user_can_save

function royal_user_can_save($post_id, $nonce)
{
    $is_autosave = wp_is_post_autosave($post_id);
    $is_revision = wp_is_post_revision($post_id);
    $is_valid_nonce = isset($_POST[$nonce]) && wp_verify_nonce($_POST[$nonce], 'royal_nonce');
    // Return true if the user is able to save - otherwise, false.
    return !($is_autosave || $is_revision) && $is_valid_nonce;
}
开发者ID:timb1981,项目名称:ChamferZone,代码行数:8,代码来源:metaboxes.php


示例19: save_post_meta

 public static function save_post_meta($post_id, $post)
 {
     $data = stripslashes_deep($_POST);
     if (wp_is_post_autosave($post_id) || wp_is_post_revision($post_id) || !isset($data['wp-convertkit-save-meta-nonce']) || !wp_verify_nonce($data['wp-convertkit-save-meta-nonce'], 'wp-convertkit-save-meta')) {
         return;
     }
     self::_set_meta($post_id, $data['wp-convertkit']);
 }
开发者ID:justinputney,项目名称:ConvertKit-WordPress,代码行数:8,代码来源:wp-convertkit.php


示例20: save_post

 public static function save_post($post_id, $post)
 {
     if ($parent_id = wp_is_post_revision($post_id) && !wp_is_post_autosave($post_id)) {
         $meta = piklist('post_custom', $parent_id);
         foreach ($meta as $key => $value) {
             add_metadata('post', $post_id, $key, maybe_serialize($value));
         }
     }
 }
开发者ID:Themes-Protoarte,项目名称:piklist,代码行数:9,代码来源:class-piklist-revision.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP wp_is_post_revision函数代码示例发布时间:2022-05-23
下一篇:
PHP wp_is_mobile函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap