/** * Save Force SSL option to post or page * * @param int $post_id * @return int $post_id */ public function post_save($post_id) { if (array_key_exists($this->getPlugin()->getSlug(), $_POST)) { if (!wp_verify_nonce($_POST[$this->getPlugin()->getSlug()], $this->getPlugin()->getSlug())) { return $post_id; } if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) { return $post_id; } if (@$_POST['post_type'] == 'page') { if (!current_user_can('edit_page', $post_id)) { return $post_id; } } else { if (!current_user_can('edit_post', $post_id)) { return $post_id; } } $force_ssl = @$_POST['force_ssl'] == 1 ? true : false; if ($force_ssl) { update_post_meta($post_id, 'force_ssl', 1); } else { delete_post_meta($post_id, 'force_ssl'); } $force_ssl_children = @$_POST['force_ssl_children'] == 1 ? true : false; if ($force_ssl_children) { update_post_meta($post_id, 'force_ssl_children', 1); } else { delete_post_meta($post_id, 'force_ssl_children'); } } return $post_id; }
/** * Saves new period set to DB. * * @param int $post_id * @param assoc $periods * @param boolean $validate * @return assoc errors hppaned during validation */ public function set_rows($post_id, $periods, $validate = true) { $validation_errors = array(); if ($post_id < 1 || !$this->meta_key) { $validation_errors['general'] = esc_html__('Parametes errors. Please contact support', 'adventure-tours'); return $validation_errors; } if (!$periods) { delete_post_meta($post_id, $this->meta_key); } else { if ($validate) { foreach ($periods as $index => $period_data) { $period_errors = $this->check_period_data($period_data); if ($period_errors) { $validation_errors[$index] = $period_errors; } } if ($validation_errors) { return $validation_errors; } } update_post_meta($post_id, $this->meta_key, $this->format_periods($periods)); } return $validation_errors; }
function art_save_postdata($post_id) { // verify this came from the our screen and with proper authorization, // because save_post can be triggered at other times if (!wp_verify_nonce($_POST['art-direction-nonce'], plugin_basename(__FILE__))) { return $post_id; } 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, we're authenticated: we need to find and save the data delete_post_meta($post_id, 'art_direction_single'); delete_post_meta($post_id, 'art_direction_global'); if (trim($_POST['single-code']) != '') { add_post_meta($post_id, 'art_direction_single', stripslashes($_POST['single-code'])); } if (trim($_POST['global-code']) != '') { add_post_meta($post_id, 'art_direction_global', stripslashes($_POST['global-code'])); return true; } }
function comcon_meta_save() { global $post; $post_id = $post->ID; if (!isset($_POST['comcon-form-nonce']) || !wp_verify_nonce($_POST['comcon-form-nonce'], basename(__FILE__))) { return $post->ID; } $post_type = get_post_type_object($post->post_type); if (!current_user_can($post_type->cap->edit_post, $post_id)) { return $post->ID; } $input = array(); $input['position'] = isset($_POST['comcon-form-position']) ? $_POST['comcon-form-position'] : ''; $input['major'] = isset($_POST['comcon-form-major']) ? $_POST['comcon-form-major'] : ''; $input['order'] = str_pad($input['order'], 3, "0", STR_PAD_LEFT); foreach ($input as $field => $value) { $old = get_post_meta($post_id, 'comcon-form-' . $field, true); if ($value && '' == $old) { add_post_meta($post_id, 'comcon-form-' . $field, $value, true); } else { if ($value && $value != $old) { update_post_meta($post_id, 'comcon-form-' . $field, $value); } else { if ('' == $value && $old) { delete_post_meta($post_id, 'comcon-form-' . $field, $old); } } } } }
function save_newsletter($post_id) { // verify nonce if (!wp_verify_nonce($_POST['custom_meta_box_nonce'], basename(__FILE__))) { return $post_id; } // check autosave if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) { return $post_id; } // check permissions if ('newsletter' == $_POST['post_type']) { if (!current_user_can('edit_page', $post_id)) { return $post_id; } } elseif (!current_user_can('edit_post', $post_id)) { return $post_id; } $old = get_post_meta($post_id, "name", true); $new = $_POST["name"]; if ($new && $new != $old) { update_post_meta($post_id, "name", $new); } elseif ('' == $new && $old) { delete_post_meta($post_id, "name", $old); } }
/** * Save portfolio meta when the save_post action is called * * @since 0.1.0 * @param int $post_id Portfolio ID * @global array $post All of the data of current post * @return void */ function tzp_portfolio_meta_box_save($post_id) { global $post; if (!isset($_POST['tzp_portfolio_meta_box_nonce']) || !wp_verify_nonce($_POST['tzp_portfolio_meta_box_nonce'], basename(__FILE__))) { return $post_id; } if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE || defined('DOING_AJAX') && DOING_AJAX || isset($_REQUEST['buld_edit'])) { return $post_id; } if (isset($post->post_type) && $post->post_type == 'revision') { return $post_id; } if (!current_user_can('edit_post', $post_id)) { return $post_id; } // Default fields that get saved $fields = apply_filters('tzp_metabox_fields_save', array('_tzp_portfolio_url' => 'url', '_tzp_portfolio_date' => 'html', '_tzp_portfolio_client' => 'html', '_tzp_display_gallery' => 'checkbox', '_tzp_display_audio' => 'checkbox', '_tzp_display_video' => 'checkbox', '_tzp_gallery_images' => 'images', '_tzp_audio_poster_url' => 'url', '_tzp_audio_file_mp3' => 'url', '_tzp_audio_file_ogg' => 'url', '_tzp_video_poster_url' => 'url', '_tzp_video_file_m4v' => 'url', '_tzp_video_file_ogv' => 'url', '_tzp_video_file_mp4' => 'url', '_tzp_video_embed' => 'html')); foreach ($fields as $key => $type) { if (!empty($_POST[$key])) { // sanitize fields with apply_filters $new = apply_filters('tzp_metabox_save_' . $type, $_POST[$key]); update_post_meta($post_id, $key, $new); } else { delete_post_meta($post_id, $key); } } }
function pl_save_data($post_id) { if ($_GET['post_type'] == 'people' || $_POST['post_type'] == 'people') { global $pl_meta_box; // verify nonce if (!wp_verify_nonce($_POST['pl_meta_box_nonce'], basename(__FILE__))) { return $post_id; } // check autosave if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) { return $post_id; } // check permissions if ('page' == $_POST['post_type']) { if (!current_user_can('edit_page', $post_id)) { return $post_id; } } elseif (!current_user_can('edit_post', $post_id)) { return $post_id; } foreach ($pl_meta_box['fields'] as $field) { $old = get_post_meta($post_id, $field['id'], true); $new = $_POST[$field['id']]; if ($new && $new != $old) { update_post_meta($post_id, $field['id'], $new); } elseif ('' == $new && $old) { delete_post_meta($post_id, $field['id'], $old); } } } }
public static function update_job_fields($post_id, array $args) { $fields = self::get_all_fields(); foreach ($fields as $field) { if (!isset($args[$field->ID])) { continue; } switch ($field->type) { default: case 'text': case 'select': case 'url': update_post_meta($post_id, 'cfield-' . $field->ID, $args[$field->ID]); break; case 'checkbox': $string = implode(",", $args[$field->ID]); update_post_meta($post_id, 'cfield-' . $field->ID, $string); break; case 'date': if (!empty($args[$field->ID])) { $date = DateTime::createFromFormat(get_option("date_format"), $args[$field->ID]); update_post_meta($post_id, 'cfield-' . $field->ID, $date->format('Y-m-d h:i:s')); } else { if ($args[$field->ID] === '' || $time === 0) { delete_post_meta($post_id, 'cfield-' . $field->ID); } } break; } } }
function give_video_update($post_id) { if (!wp_verify_nonce($_POST['video_fields_nonce'], __FILE__)) { return false; } // checking if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) { return false; } // autochecking if (!current_user_can('edit_post', $post_id)) { return false; } // checking user role //if( !isset($_POST['video']) ) return false; //if(! is_numeric($_POST['money']['sum'])) return false; // save $_POST['video'] = array_map('trim', $_POST['video']); foreach ($_POST['video'] as $key => $value) { if (empty($value)) { delete_post_meta($post_id, $key); // if field is empty continue; } update_post_meta($post_id, $key, $value); // add_post_meta() } return $post_id; }
/** * Create a Duplicate post */ static function copy($post, $post_title = '', $post_name = '', $post_type = 'sp_report') { // We don't want to clone revisions if ($post->post_type == 'revision') { return; } if ($post->post_type != 'attachment') { $status = 'draft'; } $new_post_author = wp_get_current_user(); $new_post = array('menu_order' => $post->menu_order, 'comment_status' => $post->comment_status, 'ping_status' => $post->ping_status, 'post_author' => $new_post_author->ID, 'post_content' => $post->post_content, 'post_excerpt' => $post->post_excerpt, 'post_mime_type' => $post->post_mime_type, 'post_password' => $post->post_password, 'post_status' => $post->post_status, 'post_title' => empty($post_title) ? $post->post_title : $post_title, 'post_type' => empty($post_type) ? $post->post_type : $post_type); if ($post_name != '') { $new_post['post_name'] = $post_name; } /* $new_post['post_date'] = $new_post_date = $post->post_date ; $new_post['post_date_gmt'] = get_gmt_from_date($new_post_date); */ $new_post_id = wp_insert_post($new_post); // If you have written a plugin which uses non-WP database tables to save // information about a post you can hook this action to dupe that data. if ($post->post_type == 'page' || function_exists('is_post_type_hierarchical') && is_post_type_hierarchical($post->post_type)) { do_action('sp_duplicate_page', $new_post_id, $post); } else { do_action('sp_duplicate_post', $new_post_id, $post); } delete_post_meta($new_post_id, '_sp_original'); add_post_meta($new_post_id, '_sp_original', $post->ID); add_post_meta($new_post_id, '_open_count', 0); return $new_post_id; }
function pvbu_setPostViews($postID) { $count_key = 'post_views_by_user'; $count = get_post_meta($postID, $count_key, true); //echo '<script type="text/javascript">console.log('.$count.')</script>'; $user_array = array(); if ($count == '') { if (is_user_logged_in()) { $user_ID = get_current_user_id(); $user_array[$user_ID] = date("Y-m-d H:i:s"); add_post_meta($postID, 'post_views_by_user', $user_array); } } else { if (is_user_logged_in()) { $user_ID = get_current_user_id(); var_dump($count[$user_ID]); if ($count[$user_ID] == null) { $count[$user_ID] = date("Y-m-d H:i:s"); delete_post_meta($postID, $count_key); add_post_meta($postID, 'post_views_by_user', $count); } else { return; } } } }
function save_custom_composer_meta($post_id) { if (!isset($_POST['custom_composer_meta_box_nonce']) || !wp_verify_nonce($_POST['custom_composer_meta_box_nonce'], basename(__FILE__))) { return $post_id; } if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) { return $post_id; } if ($_POST['post_type'] == 'page') { if (!current_user_can('edit_page', $post_id)) { return $post_id; } } elseif (!current_user_can('edit_post', $post_id)) { return $post_id; } $old = get_post_meta($post_id, 'cmsms_content_composer_text', true); if (isset($_POST['cmsms_content_composer_text'])) { $new = $_POST['cmsms_content_composer_text']; } else { $new = ''; } if (isset($new) && $new !== $old) { update_post_meta($post_id, 'cmsms_content_composer_text', $new); } elseif (isset($old) && $new === '') { delete_post_meta($post_id, 'cmsms_content_composer_text', $old); } }
function save_postdata_gallery($post_id) { global $post, $gallery_box; foreach ($gallery_box as $meta_box) { if (!wp_verify_nonce($_POST[$meta_box['name'] . '_noncename'], plugin_basename(__FILE__))) { return $post_id; } 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; } } $data = $_POST[$meta_box['name']]; if (get_post_meta($post_id, $meta_box['name']) == "") { add_post_meta($post_id, $meta_box['name'], $data, true); } elseif ($data != get_post_meta($post_id, $meta_box['name'], true)) { update_post_meta($post_id, $meta_box['name'], $data); } elseif ($data == "") { delete_post_meta($post_id, $meta_box['name'], get_post_meta($post_id, $meta_box['name'], true)); } } }
function savePackage($post) { if (!current_user_can('edit_posts')) { return; } if (get_post_type() != 'wpdmpro' || !isset($_POST['file'])) { return; } // Deleted old zipped file $zipped = get_post_meta($post, "__wpdm_zipped_file", true); if ($zipped != '' && file_exists($zipped)) { @unlink($zipped); } $cdata = get_post_custom($post); foreach ($cdata as $k => $v) { $tk = str_replace("__wpdm_", "", $k); if (!isset($_POST['file'][$tk]) && $tk !== $k) { delete_post_meta($post, $k); } } foreach ($_POST['file'] as $meta_key => $meta_value) { $key_name = "__wpdm_" . $meta_key; update_post_meta($post, $key_name, $meta_value); } if (get_post_meta($post, '__wpdm_masterkey', true) == '') { update_post_meta($post, '__wpdm_masterkey', uniqid()); } if (isset($_POST['reset_key']) && $_POST['reset_key'] == 1) { update_post_meta($post, '__wpdm_masterkey', uniqid()); } if (isset($_REQUEST['reset_udl'])) { delete_post_meta($post, '__wpdmx_user_download_count'); } //do_action('after_update_package',$post, $_POST['file']); }
function wedding_style_web_dorado_meta_save($post_id) { // authentication checks // check user permissions if (isset($_POST['post_type']) && $_POST['post_type'] == 'page') { if (!current_user_can('edit_page', $post_id)) { return $post_id; } } else { if (!current_user_can('edit_post', $post_id)) { return $post_id; } } $current_data = get_post_meta($post_id, 'web_dorado_meta_date', TRUE); if (isset($_POST['web_dorado_meta_date'])) { $new_data = $_POST['web_dorado_meta_date']; } else { $new_data = ""; } if (gettype($post_id) == 'integer') { if (is_null($new_data)) { delete_post_meta($post_id, 'web_dorado_meta_date'); } else { update_post_meta($post_id, 'web_dorado_meta_date', $new_data); add_post_meta($post_id, 'web_dorado_meta_date', $new_data, TRUE); } } elseif (!is_null($new_data)) { update_post_meta($post_id, 'web_dorado_meta_date', $new_data); } return $post_id; }
/** * Save an image */ public function save_image() { check_ajax_referer(self::NONCE_SAVE_IMAGE, 'nonce'); $attachment_id = isset($_POST['attachment_id']) ? absint($_POST['attachment_id']) : false; if ($this->is_attachment($attachment_id)) { // faces if (isset($_POST['faces'])) { if ($_POST['faces']) { update_post_meta($attachment_id, 'faces', $_POST['faces']); } else { delete_post_meta($attachment_id, 'faces'); } } // hotspots if (isset($_POST['hotspots'])) { if ($_POST['hotspots']) { update_post_meta($attachment_id, 'hotspots', $_POST['hotspots']); } else { delete_post_meta($attachment_id, 'hotspots'); } } // regenerate thumbs $resized = MEAUH_Attachment::regenerate($attachment_id); if ($resized) { wp_send_json_success(array('resized' => $resized)); } } else { wp_send_json_error(); } }
/** * Saves the video embed code on post save * * @since 4.0 */ function medium_save_video_meta($post_id) { global $post; // Return early if this is a newly created post that hasn't been saved yet. if ('auto-draft' == get_post_status($post_id)) { return $post_id; } // Check if the user intended to change this value. if (!isset($_POST['medium_video_box_nonce']) || !wp_verify_nonce($_POST['medium_video_box_nonce'], plugin_basename(__FILE__))) { return $post_id; } // Get post type object $post_type = get_post_type_object($post->post_type); // Check if user has permission if (!current_user_can($post_type->cap->edit_post, $post_id)) { return $post_id; } // Get posted data and sanitize it $new_video = isset($_POST['medium_video_field']) ? $_POST['medium_video_field'] : ''; // Get existing video $video = get_post_meta($post_id, 'video', true); // If a new video was submitted and there was no previous one, add it if ($new_video && '' == $video) { add_post_meta($post_id, 'video', $new_video, true); } elseif ($new_video && $new_video != $video) { update_post_meta($post_id, 'video', $new_video); } elseif ('' == $new_video && $video) { delete_post_meta($post_id, 'video', $video); } }
public function include_bulk_videos_in_gallery() { if (isset($_POST) && check_admin_referer($this->nonce_video_include_bulk['action'], $this->nonce_video_include_bulk['name'])) { $message = ''; if (isset($_POST['media-id']) && isset($_POST['bulk-action-select'])) { if ($_POST['bulk-action-select'] == 'include') { $count = 0; do_action(MAXGALLERIA_ACTION_BEFORE_INCLUDE_BULK_VIDEOS_IN_GALLERY, $_POST['media-id']); foreach ($_POST['media-id'] as $id) { $video_post = get_post($id); if (isset($video_post)) { delete_post_meta($video_post->ID, 'maxgallery_attachment_video_exclude', true); $count++; } } do_action(MAXGALLERIA_ACTION_AFTER_INCLUDE_BULK_VIDEOS_IN_GALLERY, $_POST['media-id']); if ($count == 1) { $message = __('Included 1 video in this gallery.', 'maxgalleria'); } if ($count > 1) { $message = sprintf(__('Included %d videos in this gallery.', 'maxgalleria'), $count); } } } echo $message; die; } }
function save_downloads_meta($post_id) { global $post, $downloads_meta; foreach ($downloads_meta as $meta_box) { // Verifica /*if ( !wp_verify_nonce( $_POST[$meta_box['name'].'_noncename'], plugin_basename(__FILE__) )) { return $post_id; }*/ 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; } } $data = $_POST[$meta_box['name'] . '_value']; if (get_post_meta($post_id, $meta_box['name'] . '_value') == "") { add_post_meta($post_id, $meta_box['name'] . '_value', $data, true); } elseif ($data != get_post_meta($post_id, $meta_box['name'] . '_value', true)) { update_post_meta($post_id, $meta_box['name'] . '_value', $data); } elseif ($data == "") { delete_post_meta($post_id, $meta_box['name'] . '_value', get_post_meta($post_id, $meta_box['name'] . '_value', true)); } } }
public static function savemeta($post_id, $post) { /* Get the post type object. */ $post_type = get_post_type_object($post->post_type); /* Check if the current user has permission to edit the post. */ if (!current_user_can($post_type->cap->edit_post, $post_id)) { return $post_id; } /* Get the meta key. */ $meta_key = self::$prefix . $post_id; /* Get the posted data and sanitize it for use as an HTML class. */ $new_meta_value = isset($_POST[self::$prefix]) ? $_POST[self::$prefix] : ''; /* Get the meta value of the custom field key. */ $meta_value = get_post_meta($post_id, $meta_key, true); /* If a new meta value was added and there was no previous value, add it. */ if ($new_meta_value && '' == $meta_value) { add_post_meta($post_id, $meta_key, $new_meta_value, true); } elseif ($new_meta_value && $new_meta_value != $meta_value) { update_post_meta($post_id, $meta_key, $new_meta_value); } elseif ('' == $new_meta_value && $meta_value) { delete_post_meta($post_id, $meta_key, $meta_value); if (($ptemplate = self::getPathTheme($post_id)) && file_exists($ptemplate)) { unlink($ptemplate); } } }
function cresta_save_meta_box_data($post_id) { if (!isset($_POST['cresta_meta_box_nonce'])) { return; } if (!wp_verify_nonce($_POST['cresta_meta_box_nonce'], 'cresta_meta_box')) { return; } if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) { return; } if (isset($_POST['post_type']) && 'page' == $_POST['post_type']) { if (!current_user_can('edit_page', $post_id)) { return; } } else { if (!current_user_can('edit_post', $post_id)) { return; } } if (isset($_POST['cresta_new_field'])) { update_post_meta($post_id, '_get_cresta_plugin', $_POST['cresta_new_field']); } else { delete_post_meta($post_id, '_get_cresta_plugin'); } }
/** * Delete all bundle data from the post. * * @param int $content_id * @since 0.2.0 */ public function clean_up() { do_action('apple_news_before_clean_up'); delete_post_meta($this->content_id, self::JSON_META_KEY); delete_post_meta($this->content_id, self::BUNDLE_META_KEY); do_action('apple_news_after_clean_up'); }
public function set_thumbnail_id($image_id) { if (!$image_id) { return delete_post_meta($this->id, '_wpbdp[thumbnail_id]'); } return update_post_meta($this->id, '_wpbdp[thumbnail_id]', $image_id); }
function save_recommend_post_meta_box($post_id) { // verify nonce if (!isset($_POST['recommend_post_meta_box_nonce']) || !wp_verify_nonce($_POST['recommend_post_meta_box_nonce'], basename(__FILE__))) { return $post_id; } // check autosave if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) { return $post_id; } // check permissions if ('page' == $_POST['post_type']) { if (!current_user_can('edit_page', $post_id)) { return $post_id; } } elseif (!current_user_can('edit_post', $post_id)) { return $post_id; } // save or delete if (isset($_POST['recommend_post'])) { update_post_meta($post_id, 'recommend_post', $_POST['recommend_post']); } else { delete_post_meta($post_id, 'recommend_post'); } }
function tz_save_data_page($post_id) { global $meta_box_category; // verify nonce if (!isset($_POST['tz_meta_box_nonce']) || !wp_verify_nonce($_POST['tz_meta_box_nonce'], basename(__FILE__))) { return $post_id; } // check autosave if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) { return $post_id; } // check permissions if ('page' == $_POST['post_type']) { if (!current_user_can('edit_page', $post_id)) { return $post_id; } } elseif (!current_user_can('edit_post', $post_id)) { return $post_id; } foreach ($meta_box_category['fields'] as $field) { $old = get_post_meta($post_id, $field['id'], true); $new = $_POST[$field['id']]; if ($new && $new != $old) { update_post_meta($post_id, $field['id'], stripslashes(htmlspecialchars($new))); } elseif ('' == $new && $old) { delete_post_meta($post_id, $field['id'], $old); } } }
function smashing_save_post_class_meta($post_id, $post) { /* Verify the nonce before proceeding. */ if (!isset($_POST['smashing_post_class_nonce']) || !wp_verify_nonce($_POST['smashing_post_class_nonce'], basename(__FILE__))) { return $post_id; } /* Get the post type object. */ $post_type = get_post_type_object($post->post_type); /* Check if the current user has permission to edit the post. */ if (!current_user_can($post_type->cap->edit_post, $post_id)) { return $post_id; } /* Get the posted data and sanitize it for use as an HTML class. */ $new_meta_value = isset($_POST['smashing-post-class']) ? sanitize_html_class($_POST['smashing-post-class']) : ''; /* Get the meta key. */ $meta_key = 'smashing_post_class'; /* Get the meta value of the custom field key. */ $meta_value = get_post_meta($post_id, $meta_key, true); /* If a new meta value was added and there was no previous value, add it. */ if ($new_meta_value && '' == $meta_value) { add_post_meta($post_id, $meta_key, $new_meta_value, true); } elseif ($new_meta_value && $new_meta_value != $meta_value) { update_post_meta($post_id, $meta_key, $new_meta_value); } elseif ('' == $new_meta_value && $meta_value) { delete_post_meta($post_id, $meta_key, $meta_value); } }
function kopa_click_like_button() { check_ajax_referer('kopa_click_like_button', 'ajax_nonce'); if (!empty($_POST['post_id'])) { $result = array('status' => 'disable', 'total' => 0); $post_id = (int) $_POST['post_id']; $status = $_POST['status']; $include_text = $_POST['include_text']; $public_key = KOPA_OPT_PREFIX . 'likes'; $single_key = KOPA_OPT_PREFIX . 'like_by_' . KopaUtil::get_client_IP(); $total = KopaUtil::get_likes($post_id); $is_liked = KopaUtil::is_liked($post_id); if ('enable' == $status && !$is_liked) { $total++; update_post_meta($post_id, $single_key, true); update_post_meta($post_id, $public_key, abs($total)); $result['class'] = 'kopa-button-likes-disable'; } else { $total--; delete_post_meta($post_id, $single_key); update_post_meta($post_id, $public_key, abs($total)); $result['class'] = 'kopa-button-likes-enable'; } if ($include_text) { if ($total < 2) { $total .= __(' Like', kopa_get_domain()); } else { $total .= __(' Likes', kopa_get_domain()); } } $result['total'] = $total; echo json_encode($result); } exit; }
function save($post_id) { if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) { return $post_id; } // Check 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; } } // Verify nonce if (!wp_verify_nonce($_POST[$this->conf['id'] . '_noncename'], plugin_basename(__FILE__))) { return $post_id; } foreach ($this->options as $v) { if (isset($v['id']) && !empty($v['id'])) { $value = $_POST[$v['id']]; if (get_post_meta($post_id, $v['id']) == "") { add_post_meta($post_id, $v['id'], $value, true); } elseif ($value != get_post_meta($post_id, $v['id'], true)) { update_post_meta($post_id, $v['id'], $value); } elseif ($value == "") { delete_post_meta($post_id, $v['id'], get_post_meta($post_id, $v['id'], true)); } } } }
function pmwi_pmxi_custom_field($cf_value, $pid, $cf_key, $existing_meta_keys, $import_id) { if ($cf_key == 'total_sales') { delete_post_meta($pid, $cf_key); } return $cf_value; }
function real_admin_save_post($post_id) { global $meta_box, $wpdb; // check autosave if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) { return $post_id; } // check permissions if (isset($this->p->post_type) && $this->p->post_type == 'page') { if (!current_user_can('edit_page', $post_id)) { return $post_id; } } elseif (!current_user_can('edit_post', $post_id)) { return $post_id; } if (isset($meta_box) && isset($meta_box['fields']) && is_array($meta_box['fields'])) { foreach ($meta_box['fields'] as $field) { if (isset($this->p->post_title)) { $old = get_post_meta($post_id, $field['id'], true); if (isset($this->p->{$field}['id'])) { $new = $this->p->{$field}['id']; if ($new && $new != $old) { update_post_meta($post_id, $field['id'], $new); } elseif ($new == '' && $old) { delete_post_meta($post_id, $field['id'], $old); } } else { delete_post_meta($post_id, $field['id'], $old); } } } } return $post_id; }