本文整理汇总了PHP中wp_is_post_revision函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_is_post_revision函数的具体用法?PHP wp_is_post_revision怎么用?PHP wp_is_post_revision使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wp_is_post_revision函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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 );
}
}
}
示例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;
}
示例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();
}
}
示例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);
}
示例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);
}
示例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()));
}
}
示例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;
}
}
}
}
示例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);
}
}
}
示例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);
}
}
}
示例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);
}
示例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);
}
}
示例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']);
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
}