Esempio n. 1
0
/**
 * 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();
}
 /**
  * Compatibility function to use the new WC_Admin_Meta_Boxes class for the save_errors() function
  *
  * @since 1.0-1
  * @return old save_errors function or new class
  */
 public static function save_errors()
 {
     if (self::is_wc_version_gte_2_1()) {
         WC_Admin_Meta_Boxes::save_errors();
     } else {
         woocommerce_meta_boxes_save_errors();
     }
 }
/**
 * Save meta boxes
 *
 * Runs when a post is saved and does an action which the write panel save scripts can hook into.
 *
 * @access public
 * @param mixed $post_id
 * @param mixed $post
 * @return void
 */
function woocommerce_meta_boxes_save($post_id, $post)
{
    if (empty($post_id) || 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 ($post->post_type != 'product' && $post->post_type != 'shop_order' && $post->post_type != 'shop_coupon') {
        return;
    }
    do_action('woocommerce_process_' . $post->post_type . '_meta', $post_id, $post);
    woocommerce_meta_boxes_save_errors();
}