function update_post() { global $rcl_options, $user_ID; $post_content = ''; $post_excerpt = isset($_POST['post_excerpt']) ? $_POST['post_excerpt'] : ''; if (!is_array($_POST['post_content'])) { $post_content = $_POST['post_content']; } $postdata = array('post_type' => $this->post_type, 'post_title' => sanitize_text_field($_POST['post_title']), 'post_excerpt' => $post_excerpt, 'post_content' => $post_content); $id_form = intval(base64_decode($_POST['id_form'])); if ($this->post_id) { $postdata['ID'] = $this->post_id; } else { $postdata['post_author'] = $user_ID; } $postdata = apply_filters('pre_update_postdata_rcl', $postdata, $this); if (!$postdata) { return false; } $user_info = get_userdata($user_ID); if (!$postdata['post_status'] || $user_info->user_level == 10) { $postdata['post_status'] = 'publish'; } do_action('pre_update_post_rcl', $postdata); if (!$this->post_id) { $this->post_id = wp_insert_post($postdata); if ($id_form > 1) { add_post_meta($this->post_id, 'publicform-id', $id_form); } } else { wp_update_post($postdata); } $this->update_thumbnail(); if ($_POST['add-gallery-rcl'] == 1) { update_post_meta($this->post_id, 'recall_slider', 1); } else { delete_post_meta($this->post_id, 'recall_slider'); } rcl_update_post_custom_fields($this->post_id, $id_form); do_action('update_post_rcl', $this->post_id, $postdata, $this->update); if ($postdata['post_status'] == 'pending') { if ($user_ID) { $redirect_url = get_bloginfo('wpurl') . '/?p=' . $this->post_id . '&preview=true'; } else { $redirect_url = get_permalink($rcl_options['guest_post_redirect']); } } else { $redirect_url = get_permalink($this->post_id); } if (defined('DOING_AJAX') && DOING_AJAX) { echo json_encode(array('redirect' => $redirect_url)); exit; } wp_redirect($redirect_url); exit; }
function rcl_custom_fields_update($post_id) { if (!isset($_POST['custom_fields_nonce_rcl'])) { return false; } if (!wp_verify_nonce($_POST['custom_fields_nonce_rcl'], __FILE__)) { return false; } if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) { return false; } if (!current_user_can('edit_post', $post_id)) { return false; } rcl_update_post_custom_fields($post_id); return $post_id; }