public static function update_orders_value( $post_id, $post ) {
		if ( is_int( wp_is_post_revision( $post_id ) ) ) return;
		if ( is_int( wp_is_post_autosave( $post_id ) ) ) return;
		if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE ) return $post_id;
		if ( ! current_user_can( 'edit_post', $post_id ) ) return $post_id;
		if ( $post->post_type != 'product' ) return $post_id;
		
		if ( version_compare( WC()->version, '2.2.0', '<' ) ) {
			$product 	= get_product( $post );
		} else {
			$product 	= wc_get_product( $post );
		}
		if ( $product ) {
			if ( $product->is_on_sale() ) {
				update_post_meta( $post_id, '_psad_onsale_order', 2 );
			} else {
				update_post_meta( $post_id, '_psad_onsale_order', 1 );
			}
			if ( $product->is_featured() ) {
				update_post_meta( $post_id, '_psad_featured_order', 2 );
			} else {
				update_post_meta( $post_id, '_psad_featured_order', 1 );	
			}
		}
	}
 /**
  * 
  * @param $post
  * @return unknown_type
  * @todo anything in the html that has dodgy characters in it will make DOM unhappy. 
  * Probably best to hold back errors.
  */
 public static function AutoGenThumbs($post)
 {
     $tracker = OnePanelDebug::Track('Trying to autogenerate thumbnails.');
     // Wordpress is crazy
     $post_id = wp_is_post_revision($post);
     OnePanelDebug::Info('Post id: ' . $post_id);
     // Create thumbnail module object?
     OnePanelLib::RequireFileOnce(ONE_PANEL_DIR . '/panel/module.php');
     OnePanelLib::RequireFileOnce(ONE_PANEL_DIR . '/panel/feature.php');
     OnePanelLib::RequireFileOnce(ONE_PANEL_DIR . '/panel/thumbnails.php');
     $thumbnail_feature_object = new Thumbnails();
     // Scan the post for images
     $dom_doc = new DOMDocument();
     @$dom_doc->loadHTML($_POST['content']);
     // Grab the first image
     $first_image = $dom_doc->getElementsByTagName('img')->item(0);
     if (is_null($first_image)) {
         OnePanelDebug::Info('No images found in post');
         return true;
     }
     // Get the location of the image
     $src = str_replace('"', '', $first_image->getAttribute('src'));
     $src = str_replace('\\', '', $src);
     // Get the real path
     $src = str_replace(get_option('siteurl'), '', $src);
     $location = ABSPATH . $src;
     $location = str_replace('//', '/', $location);
     // Generate
     OnePanelDebug::Info('Calling CreateThumbs with ' . $location . ' ' . $post_id);
     $thumbnail_feature_object->CreateThumbs($location, $post_id, 'All', false);
     // All done
     $tracker->Affirm();
     return true;
 }
Exemple #3
0
 function page_metabox_save($post_id)
 {
     if (isset($_POST['nonce_page_metabox'])) {
         // Autosave, do nothing
         if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
             return;
         }
         // Ajax not used here
         if (defined('DOING_AJAX') && DOING_AJAX) {
             return;
         }
         // Check user permissions
         if (!current_user_can('edit_post', $post_id)) {
             return;
         }
         // Return if it's a post revision
         if (false !== wp_is_post_revision($post_id)) {
             return;
         }
         // verify this came from the our screen and with proper authorization
         if (!wp_verify_nonce($_POST['nonce_page_metabox'], plugin_basename(__FILE__))) {
             return;
         }
         // OK, we're authenticated
         global $md_metabox;
         $form_helper = new FORM_HELPER($post_id, $md_metabox);
         $form_helper->metabox_save();
     }
 }
Exemple #4
0
 function save_metabox_values()
 {
     if (defined('DOING_AJAX')) {
         return false;
     }
     // autosave
     global $post;
     $post_id = wp_is_post_revision($post->ID);
     $post_id = $post_id ? $post_id : $post->ID;
     $post_types = $this->_data->get_option('post_types');
     $post_types = $post_types ? $post_types : array();
     if (!in_array($post->post_type, $post_types)) {
         return false;
     }
     $address = !empty($_POST['agm-address']) ? wp_strip_all_tags($_POST['agm-address']) : false;
     $lat = !empty($_POST['agm-latitude']) ? (double) $_POST['agm-latitude'] : false;
     $lng = !empty($_POST['agm-longitude']) ? (double) $_POST['agm-longitude'] : false;
     if ($lat && $lng) {
         return $this->_update_post_geotag($post_id, $lat, $lng);
     }
     if (!$address) {
         return false;
     }
     $result = $this->_data->geocode_address($address);
     return $this->_update_post_geotag($post_id, $result->geometry->location->lat, $result->geometry->location->lng);
 }
 /**
  * Save meta boxes.
  *
  * @param int    $post_id
  * @param object $post
  */
 public function save_meta_boxes($post_id, $post)
 {
     // Can't proceed without a post id or post.
     if (empty($post_id) || empty($post)) {
         return;
     }
     // Don't 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 post being saved has the same id as the post id.
     // This will prevent other save post events.
     if ($this->valid_post_id($post_id)) {
         return;
     }
     // Check if our nonce is vailed.
     if (!wp_verify_nonce(papi_get_sanitized_post('papi_meta_nonce'), 'papi_save_data')) {
         return;
     }
     // Check for any of the capabilities before we save the code.
     if (!current_user_can('edit_posts') || !current_user_can('edit_pages')) {
         return;
     }
     $this->save_properties($post_id);
 }
function add_remove_document_to_solr_index($post_id, $post, $update)
{
    // If this is just a revision, don't go on.
    if (wp_is_post_revision($post_id)) {
        return;
    }
    // If this is just a new post opened in editor, don't go on.
    if ('auto-draft' == $post->post_status) {
        return;
    }
    try {
        if ('publish' == $post->post_status) {
            // post published, add/update it from Solr index
            $solr = WPSolrIndexSolrClient::create_from_post($post);
            $solr->index_data(1, $post);
            // Display confirmation in admin
            set_transient(get_current_user_id() . 'updated_solr_post_save_admin_notice', 'Post/page indexed in Solr');
        } else {
            // post unpublished, remove it from Solr index
            $solr = WPSolrIndexSolrClient::create_from_post($post);
            $solr->delete_document($post);
            // Display confirmation in admin
            set_transient(get_current_user_id() . 'updated_solr_post_save_admin_notice', 'Post/Page deleted from Solr');
        }
    } catch (Exception $e) {
        set_transient(get_current_user_id() . 'error_solr_post_save_admin_notice', htmlentities($e->getMessage()));
    }
}
 public function possiblyAddPostThumbnail($postId, $post = false)
 {
     if (!$post) {
         $post = get_post($postId);
     }
     if (false === (wp_is_post_autosave($postId) || wp_is_post_revision($postId)) && post_type_supports($post->post_type, 'thumbnail')) {
         $thumb = get_post_thumbnail_id($postId);
         if (empty($thumb)) {
             // get images as attachements
             $images = get_posts(array('post_type' => 'attachment', 'post_mime_type' => 'image', 'post_parent' => $postId, 'order' => 'ASC', 'orderby' => 'post_date', 'numberposts' => 1));
             if (!is_array($images) || count($images) == 0) {
                 // if there are no attachments, search post content
                 preg_match_all('|<img.*?src=[\'"](.*?)[\'"].*?>|i', $post->post_content, $matches);
                 // search for uploaded images in the post
                 if (isset($matches) && isset($matches[1][0]) && strlen(trim($matches[1][0])) > 0) {
                     $image = $matches[1][0];
                     $this->uploadThumb($post, $image);
                 }
             } else {
                 $image = array_shift($images);
                 update_post_meta($postId, '_thumbnail_id', $image->ID);
                 return true;
             }
         }
     }
 }
 function save_meta_boxes($post_id)
 {
     if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
         return;
     }
     if (wp_is_post_revision($post_id)) {
         return;
     }
     if (isset($_POST['post_type'])) {
         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;
             }
         }
     }
     foreach ($_POST as $key => $value) {
         if (strpos($key, 'ts_') !== false) {
             update_post_meta($post_id, $key, $value);
         }
     }
 }
Exemple #9
0
function wp_aatags_run($post_ID)
{
    $tags = get_option('wp_aatags_opts');
    $number = get_option('wp_aatags_aadnumber');
    global $wpdb;
    if (get_post($post_ID)->post_type == 'post' && !wp_is_post_revision($post_ID) && !get_the_tags($post_ID)) {
        $post_title = get_post($post_ID)->post_title;
        $post_content = get_post($post_ID)->post_content;
        switch ($tags) {
            case 3:
                $requix = strtolower($post_title . ' ' . wp_trim_words($post_content, 333, ''));
                break;
            case 2:
                $requix = strtolower($post_title . ' ' . wp_trim_words($post_content, 999, ''));
                break;
            default:
                $requix = strtolower($post_title);
                break;
        }
        $body = wp_aatags_keycontents(wp_aatags_html2text($requix), $number);
        if ($body != 'rEr') {
            $keywords = wp_aatags_kwsiconv($body);
            wp_add_post_tags($post_ID, $keywords);
        } else {
            wp_aatags_alts($post_ID, $post_title, $post_content);
        }
    }
}
function woocommerce_meta_boxes_save($post_id, $post)
{
    global $wpdb;
    if (!$_POST) {
        return $post_id;
    }
    if (is_int(wp_is_post_revision($post_id))) {
        return;
    }
    if (is_int(wp_is_post_autosave($post_id))) {
        return;
    }
    if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
        return $post_id;
    }
    if (!isset($_POST['woocommerce_meta_nonce']) || isset($_POST['woocommerce_meta_nonce']) && !wp_verify_nonce($_POST['woocommerce_meta_nonce'], 'woocommerce_save_data')) {
        return $post_id;
    }
    if (!current_user_can('edit_post', $post_id)) {
        return $post_id;
    }
    if ($post->post_type != 'product' && $post->post_type != 'shop_order' && $post->post_type != 'shop_coupon') {
        return $post_id;
    }
    do_action('woocommerce_process_' . $post->post_type . '_meta', $post_id, $post);
}
 function save_post($post_id)
 {
     if (wp_is_post_revision($post_id)) {
         return;
     }
     if ('srp_type' != get_post_type()) {
         return;
     }
     $post_type = isset($_POST['srp_post_types']) ? $_POST['srp_post_types'] : 'none';
     update_post_meta($post_id, '_srp_post_type', $post_type);
     if (isset($_POST['srp_exclude_terms'])) {
         $terms = $_POST['srp_exclude_terms'];
         $terms_clean = array();
         foreach ($_POST['srp_exclude_terms'] as $term_id) {
             $terms_clean[] = absint($term_id);
         }
         update_post_meta($post_id, '_srp_exclude_terms', $terms_clean);
     } else {
         update_post_meta($post_id, '_srp_exclude_terms', array());
     }
     if (isset($_POST['srp-hard-refresh']) && $_POST['srp-hard-refresh'] == '1') {
         $this->get_post_ids($post_id, true);
     }
     if (isset($_POST['srp_time'])) {
         $save_time = absint($_POST['srp_time']);
         update_post_meta($post_id, '_srp_time', $save_time);
     }
 }
 function cp_module_customp_save_postdata($post_id)
 {
     // get post id from the revision id
     if ($parent_id = wp_is_post_revision($post_id)) {
         $post_id = $parent_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['cp_module_customp_nonce'], plugin_basename(__FILE__))) {
         return $post_id;
     }
     // verify if this is an auto save routine. If it is our form has not been submitted, so we dont want to do anything
     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;
         }
     }
     // OK, we're authenticated: we need to find and save the data
     update_post_meta($post_id, 'cp_points_enable', (int) $_POST['cp_module_customp_enable']);
     update_post_meta($post_id, 'cp_points', (int) $_POST['cp_module_customp_points']);
 }
Exemple #13
0
function add_custom_field_automatically($post_ID)
{
    global $wpdb;
    if (!wp_is_post_revision($post_ID)) {
        add_post_meta($post_ID, '_shares_total', '0', true);
    }
}
function qa_add_custom_fields($post_ID)
{
    global $wpdb;
    if (!wp_is_post_revision($post_ID)) {
        add_post_meta($post_ID, 'votes_count', '0', true);
    }
}
 /**
  * Save custom fields
  *
  */
 static function save_postdata($post_id)
 {
     global $post;
     if (wp_is_post_revision($post_id)) {
         return;
     }
     // Verifica o autosave
     if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
         return;
     }
     // Não salva o campo caso seja uma revisão
     $post_type = isset($post->post_type) ? $post->post_type : '';
     if ($post_type == 'revision') {
         return;
     }
     // Verifica o nonce
     $nonce_name = isset($_POST['meta_noncename']) ? $_POST['meta_noncename'] : '';
     if (!wp_verify_nonce($nonce_name, 'save_meta')) {
         return;
     }
     foreach (self::$custom_meta_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);
         }
     }
 }
 /**
  * Save meta data
  *
  * @param int $post_id
  * @param \WP_Post $post
  */
 public function 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['license_wp_nonce']) || !wp_verify_nonce($_POST['license_wp_nonce'], 'save_meta_data')) {
         return;
     }
     if (!current_user_can('edit_post', $post_id)) {
         return;
     }
     if ($post->post_type != 'api_product') {
         return;
     }
     do_action('license_wp_save_api_product', $post_id, $post);
 }
 /**
  * Update post in OpenSearch when it was unpdated in WP
  * Called from save_post action
  * @param integer $postID
  * @param \WP_Post $post
  */
 public function postUpdated($postID, $post)
 {
     // pre('this is postUpdated',$post,$postID);
     // exit;
     if (wp_is_post_revision($postID)) {
         return;
     }
     if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
         return $postID;
     }
     if ($post->post_status !== 'publish') {
         return $postID;
     }
     try {
         $tableName = 'main';
         $detail = static::$doc->detail($postID);
         $item = static::$doc->postToOpenSearchObject($post);
         $docsToUpload[] = $item;
         if ($item) {
             if (empty($detail)) {
                 $result = static::$doc->add($docsToUpload, $tableName);
             } else {
                 $result = static::$doc->update($docsToUpload, $tableName);
             }
             //do_action( 'mvnAlgObjectIndexedOnPostUpdate', $post, $item );
         }
     } catch (Exception $exc) {
     }
 }
function rpr_post_updated_send_email($post_id)
{
    // If this is just a revision, don't send the email.
    if (wp_is_post_revision($post_id)) {
        return;
    }
    if (get_option('readygraph_application_id') && strlen(get_option('readygraph_application_id')) > 0 && get_option('readygraph_send_blog_updates') == "true") {
        $post_title = get_the_title($post_id);
        $post_url = get_permalink($post_id);
        $post_content = get_post($post_id);
        if (get_option('readygraph_send_real_time_post_updates') == 'true') {
            $url = 'http://readygraph.com/api/v1/post.json/';
            $response = wp_remote_post($url, array('body' => array('is_wordpress' => 1, 'is_realtime' => 1, 'message' => $post_title, 'message_link' => $post_url, 'message_excerpt' => wp_trim_words($post_content->post_content, 100), 'client_key' => get_option('readygraph_application_id'), 'email' => get_option('readygraph_email'))));
        } else {
            $response = wp_remote_post($url, array('body' => array('is_wordpress' => 1, 'message' => $post_title, 'message_link' => $post_url, 'message_excerpt' => wp_trim_words($post_content->post_content, 100), 'client_key' => get_option('readygraph_application_id'), 'email' => get_option('readygraph_email'))));
        }
        if (is_wp_error($response)) {
            $error_message = $response->get_error_message();
            //echo "Something went wrong: $error_message";
        } else {
            //echo 'Response:<pre>';
            //print_r( $response );
            //echo '</pre>';
        }
        $app_id = get_option('readygraph_application_id');
        wp_remote_get("http://readygraph.com/api/v1/tracking?event=post_created&app_id={$app_id}");
    } else {
    }
}
 /**
  * Automatically upload external images of a post to Wordpress upload directory
  *
  * @param int $post_id
  */
 public function auto_upload($post_id)
 {
     if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
         return;
     }
     if (defined('DOING_AJAX') && DOING_AJAX) {
         return;
     }
     if (false !== wp_is_post_revision($post_id)) {
         return;
     }
     global $wpdb;
     $content = $wpdb->get_var("SELECT `post_content` FROM {$wpdb->posts} WHERE ID='{$post_id}'");
     $image_urls = $this->get_image_urls($content);
     if ($image_urls) {
         foreach ($image_urls as $image_url) {
             if ($this->is_allowed($image_url) && ($new_image_url = $this->save_image($image_url, $post_id))) {
                 // find image url in content and replace new image url
                 $new_image_url = parse_url($new_image_url);
                 $base_url = $this->site_url == null ? null : "http://{$this->site_url}";
                 $new_image_url = $base_url . $new_image_url['path'];
                 $content = preg_replace('/' . preg_quote($image_url, '/') . '/', $new_image_url, $content);
             }
         }
         return $wpdb->update($wpdb->posts, array('post_content' => $content), array('ID' => $post_id));
     }
     return false;
 }
function site_subheader_metabox_save($post_id)
{
    // Checks save status
    $is_autosave = wp_is_post_autosave($post_id);
    $is_revision = wp_is_post_revision($post_id);
    $is_valid_nonce = isset($_POST['sc_nonce']) && wp_verify_nonce($_POST['sc_nonce'], basename(__FILE__)) ? 'true' : 'false';
    // Exits script depending on save status
    if ($is_autosave || $is_revision || !$is_valid_nonce) {
        return;
    }
    // Checks for input and sanitizes/saves if needed
    if (isset($_POST['site-subheader-title'])) {
        update_post_meta($post_id, 'site-subheader-title', sanitize_text_field($_POST['site-subheader-title']));
    }
    if (isset($_POST['site-subheader-text'])) {
        update_post_meta($post_id, 'site-subheader-text', sanitize_text_field($_POST['site-subheader-text']));
    }
    if (isset($_POST['button-title'])) {
        update_post_meta($post_id, 'button-title', sanitize_text_field($_POST['button-title']));
    }
    if (isset($_POST['button-url'])) {
        update_post_meta($post_id, 'button-url', sanitize_text_field($_POST['button-url']));
    }
    if (isset($_POST['button-alt'])) {
        update_post_meta($post_id, 'button-alt', sanitize_text_field($_POST['button-alt']));
    }
}
 /**
  * @param string $meta_type
  * @param int $object_id
  * @param string $multi_key 'abc' or 'ab/c/def'
  * @param array|string|int|bool $set_value
  */
 public static function set($meta_type, $object_id, $multi_key, $set_value)
 {
     if (empty($multi_key)) {
         trigger_error('Key not specified', E_USER_WARNING);
         return;
     }
     $multi_key = explode('/', $multi_key);
     $key = array_shift($multi_key);
     $multi_key = implode('/', $multi_key);
     // Make sure meta is added to the post, not a revision.
     if ($meta_type === 'post' && ($the_post = wp_is_post_revision($object_id))) {
         $object_id = $the_post;
     }
     $cache_key = self::$cache_key . '/' . $meta_type . '/' . $object_id . '/' . $key;
     if (empty($multi_key) && $multi_key !== '0') {
         /** Replace entire meta */
         fw_update_metadata($meta_type, $object_id, $key, $set_value);
         FW_Cache::del($cache_key);
     } else {
         /** Change only specified key */
         $values = array();
         $values['original'] = self::get($meta_type, $object_id, $key, true);
         $values['prepared'] = self::get($meta_type, $object_id, $key, false);
         fw_aks($multi_key, $set_value, $values['original']);
         fw_aks($multi_key, fw_prepare_option_value($set_value), $values['prepared']);
         FW_Cache::set($cache_key, $values);
         fw_update_metadata($meta_type, $object_id, $key, $values['original']);
     }
 }
Exemple #22
0
 public function new_answer_email($post_id)
 {
     // lets check if post is not revision
     if (!wp_is_post_revision($post_id)) {
         $post = get_post($post_id);
         $emails = ap_get_email_to_notify($post->post_parent, $post->post_author);
         $parent = get_post($post->post_parent);
         $subject = __('New Answer on: ', 'ap') . $parent->post_title;
         $message = sprintf(__('Hello!,<br /><br /> A new answer is posted by %s <br />', 'ap'), ap_user_display_name($post->post_author, true));
         $message .= ap_truncate_chars($post->post_content, 100);
         $message .= "<br /><br /><a href='" . get_permalink($parent->ID) . "#" . $post->ID . "'>" . __('View Answer', 'ap') . "</a><br />";
         $message .= '<p style="color:#777; font-size:11px">' . __('Powered by', 'ap') . '<a href="http://open-wp.com">AnsPress</a></p>';
         //sends email
         if (empty($emails)) {
             foreach ($emails as $email) {
                 wp_mail($email, $subject, $message);
             }
         }
         $admin_email = get_option('admin_email');
         $current_user_email = get_the_author_meta('user_email', $post->post_author);
         if ($admin_email != $current_user_email) {
             wp_mail($admin_email, $subject, $message);
         }
     }
 }
 /**
  * Generate a pdf for the post when it is updated.
  * @param $post_id
  * @param $post
  */
 public static function save_post($post_id, $post)
 {
     if (wp_is_post_autosave($post_id) || wp_is_post_revision($post_id) || !post_type_supports($post->post_type, 'print_pdf') || isset($_REQUEST['bulk_edit'])) {
         return $post_id;
     }
     self::save_pdf($post);
 }
Exemple #24
0
/**
 * Save post metadata.
 *
 * @since 1.0.0
 *
 * @param int $post_id Post ID.
 * @param WP_Post $post Post object.
 */
function metamedia_save_post($post_id, $post)
{
    global $metamedia_meta_boxes;
    // Bail if the data shouldn't be saved.
    $is_autosave = defined('DOING_AUTOSAVE') && DOING_AUTOSAVE;
    $is_revision = wp_is_post_revision($post_id);
    if ($is_autosave || $is_revision || !is_array($metamedia_meta_boxes)) {
        return;
    }
    foreach ($metamedia_meta_boxes as $id => $box) {
        if (empty($box['meta_box_post_type']) || !isset($_POST[$box['meta_key']])) {
            continue;
        }
        // Check if the meta box has been registered for this post type.
        $post_types = (array) $box['meta_box_post_type'];
        if (!in_array($post->post_type, $post_types)) {
            continue;
        }
        // Continue if intention can't be verified.
        $is_valid_nonce = isset($_POST['metamedia_control_nonce-' . $box['meta_key']]) && wp_verify_nonce($_POST['metamedia_control_nonce-' . $box['meta_key']], 'save-metamedia-control-' . $box['meta_key']);
        if (!$is_valid_nonce) {
            continue;
        }
        // Save the data.
        update_post_meta($post_id, $box['meta_key'], $_POST[$box['meta_key']]);
    }
}
Exemple #25
0
function add_custom_field_automatically($post_ID)
{
    global $wpdb;
    if (!wp_is_post_revision($post_ID)) {
        add_post_meta($post_ID, 'summary', 'put your post summary here(only for Easyslider)', true);
    }
}
Exemple #26
0
 function hook_save_post($post_id)
 {
     // Fix bug when auto-saving revisions
     // Since 0.8, thanks to Benoit Gauthier
     $revision_id = wp_is_post_revision($post_id);
     if ($revision_id !== false && $revision_id !== $post_id) {
         return;
     }
     //Iterate over field names and languages and copile into array
     $languages = qtrans_getSortedLanguages();
     $meta = array();
     foreach ($languages as $lang) {
         foreach ($this->field_names as $field => $field_label) {
             //Get field data
             $field_id = "qtrans_meta_{$field}_{$lang}";
             $field_data = trim(str_replace('"', '', $_POST[$field_id]));
             $meta[$field][$lang] = $field_data;
         }
         //end of iterating over field names
     }
     //end of iterating over langauges
     // Join and save
     foreach ($meta as $field => $data) {
         $field_id = "qtrans_meta:{$field}";
         $field_data = qtrans_join($data);
         update_post_meta($post_id, $field_id, $field_data);
     }
 }
 function save($post_id)
 {
     /**
      * Perform checks
      */
     if (wp_is_post_revision($post_id) || wp_is_post_autosave($post_id)) {
         return;
     }
     if (isset($_REQUEST['doing_wp_cron'])) {
         return;
     }
     if (isset($_REQUEST['post_view'])) {
         return;
     }
     if (!isset($_POST['post_type']) || 'gc' != $_POST['post_type']) {
         return;
     }
     /**
      * Save data
      */
     $post = get_post($post_id);
     if (!get_post_meta($post_id, '_gc_id', true) && 'publish' == $post->post_status) {
         update_post_meta($post_id, '_gc_id', self::get_id($post->post_title));
     }
 }
 private function verifySecurity($postID)
 {
     if (empty($_POST)) {
         return false;
     }
     // Don't save on revisions
     if (wp_is_post_revision($postID)) {
         return false;
     }
     // Don't save on autosave
     if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
         return false;
     }
     // Verify our nonce
     if (!check_admin_referer($this->settings['id'], TF . '_' . $this->settings['id'] . '_nonce')) {
         return false;
     }
     // Check permissions
     if ($this->settings['post_type'] == 'page') {
         if (!current_user_can('edit_page', $postID)) {
             return false;
         }
     } else {
         if (!current_user_can('edit_post', $postID)) {
             return false;
         }
     }
     return true;
 }
 public function user_can_save($post_id)
 {
     $is_valid_nonce = isset($_POST['tmj-post-notice-nonce']) && wp_verify_nonce($_POST['tmj-post-notice-nonce'], 'tmj-post-notice-save');
     $is_autosave = wp_is_post_autosave($post_id);
     $is_revision = wp_is_post_revision($post_id);
     return !($is_autosave || $is_revision) && $is_valid_nonce;
 }
Exemple #30
0
 /**
  * Automatically upload external images of a post to Wordpress upload directory
  * @param int $post_id
  */
 public function afterSavePost($post_id)
 {
     if (wp_is_post_revision($post_id)) {
         return false;
     }
     return $this->save(get_post($post_id));
 }