/** * Save the meta when the post is saved. * * @param int $post_id The ID of the post being saved. */ public function save($post_id) { /* * We need to verify this came from the our screen and with proper authorization, * because save_post can be triggered at other times. */ // Check if our nonce is set. if (!isset($_POST['a3_pvc_activation_custom_box_nonce'])) { return $post_id; } $nonce = $_POST['a3_pvc_activation_custom_box_nonce']; // Verify that the nonce is valid. if (!wp_verify_nonce($nonce, 'a3_pvc_activation_custom_box')) { return $post_id; } // If this is an autosave, our form has not been submitted, // so we don't want to do anything. if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) { 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; } } /* OK, its safe for us to save the data now. */ if (isset($_POST['a3_pvc_activated'])) { $a3_pvc_activated = 'true'; } else { $a3_pvc_activated = 'false'; } // Update the meta field. update_post_meta($post_id, '_a3_pvc_activated', $a3_pvc_activated); // Manual change Total Views and Today Views if (isset($_POST['a3_pvc_total_views']) && isset($_POST['a3_pvc_today_views'])) { $total_views = trim($_POST['a3_pvc_total_views']); $today_views = trim($_POST['a3_pvc_today_views']); A3_PVC::pvc_stats_manual_update($post_id, $total_views, $today_views); } }