本文整理汇总了PHP中wp_is_post_revision函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_is_post_revision函数的具体用法?PHP wp_is_post_revision怎么用?PHP wp_is_post_revision使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wp_is_post_revision函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: update_orders_value
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 );
}
}
}
开发者ID:helloworld-digital,项目名称:katemorgan,代码行数:25,代码来源:class-wc-psad-functions.php
示例2: AutoGenThumbs
/**
*
* @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;
}
开发者ID:karlforshaw,项目名称:One-Panel,代码行数:41,代码来源:onepanelexternals.php
示例3: page_metabox_save
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();
}
}
开发者ID:Beutiste,项目名称:wordpress,代码行数:29,代码来源:metabox.class.php
示例4: save_metabox_values
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);
}
开发者ID:hscale,项目名称:webento,代码行数:26,代码来源:agm-geotag_wp.php
示例5: save_meta_boxes
/**
* 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);
}
开发者ID:ekandreas,项目名称:papi,代码行数:31,代码来源:class-papi-admin-post-handler.php
示例6: add_remove_document_to_solr_index
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()));
}
}
开发者ID:zelle7,项目名称:wpsolr-search-engine,代码行数:28,代码来源:wpsolr_search_engine.php
示例7: possiblyAddPostThumbnail
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;
}
}
}
}
开发者ID:jorgeasaldivar,项目名称:auto-thumbnailer,代码行数:26,代码来源:auto-thumbnailer.php
示例8: save_meta_boxes
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);
}
}
}
开发者ID:ericsoncardosoweb,项目名称:dallia,代码行数:25,代码来源:metaboxes.php
示例9: wp_aatags_run
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);
}
}
}
开发者ID:yszar,项目名称:linuxwp,代码行数:28,代码来源:wp-autotags.php
示例10: woocommerce_meta_boxes_save
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);
}
开发者ID:bidhanbaral,项目名称:fotodep_store,代码行数:26,代码来源:writepanels-init.php
示例11: save_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);
}
}
开发者ID:ronalfy,项目名称:static-random-posts,代码行数:28,代码来源:static-random-posts.php
示例12: cp_module_customp_save_postdata
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']);
}
开发者ID:adisonc,项目名称:MaineLearning,代码行数:29,代码来源:custom_points.php
示例13: add_custom_field_automatically
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);
}
}
开发者ID:juslee,项目名称:e27,代码行数:7,代码来源:functions__.php
示例14: qa_add_custom_fields
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);
}
}
开发者ID:aim-web-projects,项目名称:kobe-chuoh,代码行数:7,代码来源:ratings.php
示例15: save_postdata
/**
* 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);
}
}
}
开发者ID:CoordCulturaDigital-Minc,项目名称:eleicoescnpc,代码行数:34,代码来源:meta_box-feature-url.php
示例16: save
/**
* 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);
}
开发者ID:ChromeOrange,项目名称:license-wp,代码行数:31,代码来源:ApiProductData.php
示例17: postUpdated
/**
* 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) {
}
}
开发者ID:aliyun-beta,项目名称:WordPress-OpenSearch,代码行数:35,代码来源:Indexer.php
示例18: rpr_post_updated_send_email
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 {
}
}
开发者ID:alvarpoon,项目名称:anbig,代码行数:29,代码来源:readygraph-extension.php
示例19: auto_upload
/**
* 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;
}
开发者ID:ripesunflower,项目名称:wp-auto-upload,代码行数:33,代码来源:index.php
示例20: site_subheader_metabox_save
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']));
}
}
开发者ID:steticode,项目名称:steticode-site,代码行数:27,代码来源:site-subheader-metabox.php
注:本文中的wp_is_post_revision函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论