本文整理匯總了PHP中WC_Admin_Meta_Boxes::saved_meta_boxes方法的典型用法代碼示例。如果您正苦於以下問題:PHP WC_Admin_Meta_Boxes::saved_meta_boxes方法的具體用法?PHP WC_Admin_Meta_Boxes::saved_meta_boxes怎麽用?PHP WC_Admin_Meta_Boxes::saved_meta_boxes使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類WC_Admin_Meta_Boxes
的用法示例。
在下文中一共展示了WC_Admin_Meta_Boxes::saved_meta_boxes方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: 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;
}
// Dont' 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['woocommerce_meta_nonce']) || !wp_verify_nonce($_POST['woocommerce_meta_nonce'], 'woocommerce_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:
// remove_action( current_filter(), __METHOD__ );
// But cannot be used due to https://github.com/woothemes/woocommerce/issues/6485
// When that is patched in core we cna use the above. For now:
self::$saved_meta_boxes = true;
// Check the post type
if (in_array($post->post_type, wc_get_order_types('order-meta-boxes'))) {
do_action('woocommerce_process_shop_order_meta', $post_id, $post);
} elseif (in_array($post->post_type, array('product', 'shop_coupon'))) {
do_action('woocommerce_process_' . $post->post_type . '_meta', $post_id, $post);
}
}