当前位置: 首页>>代码示例>>PHP>>正文


PHP wp_get_post_revision函数代码示例

本文整理汇总了PHP中wp_get_post_revision函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_get_post_revision函数的具体用法?PHP wp_get_post_revision怎么用?PHP wp_get_post_revision使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了wp_get_post_revision函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: revision_delete_action

 /**
  * Ajax callback to handle deleting the revision, then redirecting
  * back to the post edit page with a confirmation message.
  */
 public function revision_delete_action()
 {
     /**
      * Bail if required values unset.
      */
     if (!isset($_GET['revision'])) {
         return;
     }
     $revision_id = sanitize_key($_GET['revision']);
     /**
      * Verify revision ID valud.
      */
     if (!($revision = wp_get_post_revision($revision_id))) {
         break;
     }
     /**
      * Verify parent post valid.
      */
     if (!($post = get_post($revision->post_parent))) {
         break;
     }
     /**
      * Verify current user can edit parent post.
      */
     if (!current_user_can('edit_post', $post)) {
         break;
     }
     /**
      * Verify revisions not disabled and we're not looking at an autosave.
      */
     if (!constant('WP_POST_REVISIONS') && !wp_is_post_autosave($revision)) {
         break;
     }
     /**
      * Check the nonce.
      */
     check_admin_referer("delete-revision_{$post->ID}|{$revision->ID}");
     /**
      * Every checks out, delete the revision.
      */
     wp_delete_post_revision($revision->ID);
     wp_redirect(add_query_arg(array('message' => 99, 'revision' => $revision->ID), get_edit_post_link($post->ID, 'url')));
     exit;
 }
开发者ID:adamsilverstein,项目名称:wp-post-revision-delete-action,代码行数:48,代码来源:wp-post-revision-delete-action.php

示例2: wp_delete_post_revision

/**
 * Deletes a revision.
 *
 * Deletes the row from the posts table corresponding to the specified revision.
 *
 * @since 2.6.0
 *
 * @param int|WP_Post $revision_id Revision ID or revision object.
 * @return array|false|WP_Post|WP_Error|null Null or WP_Error if error, deleted post if success.
 */
function wp_delete_post_revision($revision_id)
{
    if (!($revision = wp_get_post_revision($revision_id))) {
        return $revision;
    }
    $delete = wp_delete_post($revision->ID);
    if ($delete) {
        /**
         * Fires once a post revision has been deleted.
         *
         * @since 2.6.0
         *
         * @param int          $revision_id Post revision ID.
         * @param object|array $revision    Post revision object or array.
         */
        do_action('wp_delete_post_revision', $revision->ID, $revision);
    }
    return $delete;
}
开发者ID:AndreyLanko,项目名称:perevorot-prozorro-wp,代码行数:29,代码来源:revision.php

示例3: check_admin_referer

     if (!wp_revisions_enabled($post)) {
         $redirect = 'edit.php?post_type=' . $post->post_type;
         break;
     }
     // Don't allow revision restore when post is locked
     if (wp_check_post_lock($post->ID)) {
         break;
     }
     check_admin_referer("restore-post_{$revision->ID}");
     wp_restore_post_revision($revision->ID);
     $redirect = add_query_arg(array('message' => 5, 'revision' => $revision->ID), get_edit_post_link($post->ID, 'url'));
     break;
 case 'view':
 case 'edit':
 default:
     if (!($revision = wp_get_post_revision($revision_id))) {
         break;
     }
     if (!($post = get_post($revision->post_parent))) {
         break;
     }
     if (!current_user_can('read_post', $revision->ID) || !current_user_can('read_post', $post->ID)) {
         break;
     }
     // Revisions disabled and we're not looking at an autosave
     if (!wp_revisions_enabled($post) && !wp_is_post_autosave($revision)) {
         $redirect = 'edit.php?post_type=' . $post->post_type;
         break;
     }
     $post_title = '<a href="' . get_edit_post_link() . '">' . _draft_or_post_title() . '</a>';
     $h2 = sprintf(__('Compare Revisions of &#8220;%1$s&#8221;'), $post_title);
开发者ID:palimadra,项目名称:bubblegraphics-wpsite,代码行数:31,代码来源:revision.php

示例4: get_adjacent_post_revision

 /**
  * Get an adjacent post revision ID
  *
  * @param int $revision_id
  * @param bool $previous
  *
  * @return int $revision_id
  */
 public function get_adjacent_post_revision($revision_id, $previous = true)
 {
     if (empty($revision_id) || !wp_is_post_revision($revision_id)) {
         return false;
     }
     $revision = wp_get_post_revision($revision_id);
     $operator = $previous ? '<' : '>';
     $order = $previous ? 'DESC' : 'ASC';
     global $wpdb;
     $revision_id = $wpdb->get_var($wpdb->prepare("SELECT p.ID\n\t\t\t\tFROM {$wpdb->posts} AS p\n\t\t\t\tWHERE p.post_date {$operator} %s\n\t\t\t\t\tAND p.post_type = 'revision'\n\t\t\t\t\tAND p.post_parent = %d\n\t\t\t\tORDER BY p.post_date {$order}\n\t\t\t\tLIMIT 1", $revision->post_date, $revision->post_parent));
     $revision_id = absint($revision_id);
     if (!wp_is_post_revision($revision_id)) {
         return false;
     }
     return $revision_id;
 }
开发者ID:azanebrain,项目名称:representme,代码行数:24,代码来源:class-connector-posts.php

示例5: wp_delete_post_revision

/**
 * Deletes a revision.
 *
 * Deletes the row from the posts table corresponding to the specified revision.
 *
 * @package WordPress
 * @subpackage Post_Revisions
 * @since 2.6.0
 *
 * @uses wp_get_post_revision()
 * @uses wp_delete_post()
 *
 * @param int|object $revision_id Revision ID or revision object.
 * @param array $fields Optional. What fields to restore from.  Defaults to all.
 * @return mixed Null if error, false if no fields to restore, (int) post ID if success.
 */
function wp_delete_post_revision( $revision_id ) {
	if ( !$revision = wp_get_post_revision( $revision_id ) )
		return $revision;

	$delete = wp_delete_post( $revision->ID );
	if ( is_wp_error( $delete ) )
		return $delete;

	if ( $delete )
		do_action( 'wp_delete_post_revision', $revision->ID, $revision );

	return $delete;
}
开发者ID:realfluid,项目名称:umbaugh,代码行数:29,代码来源:post.php

示例6: wp_restoreRevision

 /**
  * Restore a post revision
  *
  * @since 3.5.0
  *
  * @uses wp_restore_post_revision()
  *
  * @param array $args Method parameters. Contains:
  *  - int     $blog_id
  *  - string  $username
  *  - string  $password
  *  - int     $post_id
  * @return bool false if there was an error restoring, true if success.
  */
 function wp_restoreRevision($args)
 {
     if (!$this->minimum_args($args, 3)) {
         return $this->error;
     }
     $this->escape($args);
     $blog_id = (int) $args[0];
     $username = $args[1];
     $password = $args[2];
     $revision_id = (int) $args[3];
     if (!($user = $this->login($username, $password))) {
         return $this->error;
     }
     do_action('xmlrpc_call', 'wp.restoreRevision');
     if (!($revision = wp_get_post_revision($revision_id))) {
         return new IXR_Error(404, __('Invalid post ID'));
     }
     if (wp_is_post_autosave($revision)) {
         return new IXR_Error(404, __('Invalid post ID'));
     }
     if (!($post = get_post($revision->post_parent))) {
         return new IXR_Error(404, __('Invalid post ID'));
     }
     if (!current_user_can('edit_post', $revision->post_parent)) {
         return new IXR_Error(401, __('Sorry, you cannot edit this post.'));
     }
     // Check if revisions are disabled.
     if (!WP_POST_REVISIONS || !post_type_supports($post->post_type, 'revisions')) {
         return new IXR_Error(401, __('Sorry, revisions are disabled.'));
     }
     $post = wp_restore_post_revision($revision_id);
     return (bool) $post;
 }
开发者ID:jospintedjou,项目名称:wordpress,代码行数:47,代码来源:class-wp-xmlrpc-server.php

示例7: replace_current_with_revision

 /**
  * If a loop started, check if it's the main query, in which case, add filters to append divs.
  *
  * @since 1.0.0
  * @access public
  *
  * @param WP_Query $wp_query
  */
 function replace_current_with_revision($wp_query)
 {
     if ($wp_query->is_main_query() && isset($_POST['revview_revision_id']) && !empty($_POST['revview_revision_id']) && is_numeric($_POST['revview_revision_id'])) {
         $this->requested_revision = wp_get_post_revision($_POST['revview_revision_id']);
         if ($this->requested_revision instanceof WP_Post) {
             $parent = get_post($this->requested_revision->post_parent);
             if ($parent instanceof WP_Post) {
                 $parent_post_status = get_post_status_object($parent->post_status);
                 /**
                  * Filters the status of the parent entry whose revision was requested.
                  *
                  * @param bool $parent_post_status_public Whether the post status of the parent entry is public or not.
                  * @param int $post The ID of the entry parent of the requested revision.
                  */
                 if (apply_filters('revview_allow_revision_load', $parent_post_status->public && empty($parent->post_password), $parent->ID)) {
                     add_filter('the_title', array($this, 'revview_title'), 0);
                     add_filter('the_content', array($this, 'revview_content'), 0);
                     add_filter('the_excerpt', array($this, 'revview_excerpt'), 0);
                 }
             }
         }
     }
 }
开发者ID:eliorivero,项目名称:revview,代码行数:31,代码来源:revview.php

示例8: pull

 /**
  * Reads the Webhook payload and syncs posts as necessary
  *
  * @param stdClass $payload
  *
  * @return array
  */
 public function pull($payload)
 {
     if (strtolower($payload->repository->full_name) !== strtolower($this->api->repository())) {
         $msg = strtolower($payload->repository->full_name) . __(' is an invalid repository.', 'wordpress-github-sync');
         WordPress_GitHub_Sync::write_log($msg);
         return array('result' => 'error', 'message' => $msg);
     }
     // the last term in the ref is the branch name
     $refs = explode('/', $payload->ref);
     $branch = array_pop($refs);
     if ('master' !== $branch) {
         $msg = __('Not on the master branch.', 'wordpress-github-sync');
         WordPress_GitHub_Sync::write_log($msg);
         return array('result' => 'error', 'message' => $msg);
     }
     // We add wpghs to commits we push out, so we shouldn't pull them in again
     if ('wpghs' === substr($payload->head_commit->message, -5)) {
         $msg = __('Already synced this commit.', 'wordpress-github-sync');
         WordPress_GitHub_Sync::write_log($msg);
         return array('result' => 'error', 'message' => $msg);
     }
     $commit = $this->api->get_commit($payload->head_commit->id);
     if (is_wp_error($commit)) {
         $msg = sprintf(__('Failed getting commit with error: %s', 'wordpress-github-sync'), $commit->get_error_message());
         WordPress_GitHub_Sync::write_log($msg);
         return array('result' => 'error', 'message' => $msg);
     }
     $import = new WordPress_GitHub_Sync_Import();
     $import->run($commit->tree->sha);
     $user = get_user_by('email', $payload->head_commit->author->email);
     if (!$user) {
         // use the default user
         $user = get_user_by('id', get_option('wpghs_default_user'));
     }
     // if we can't find a user and a default hasn't been set,
     // we're just going to set the revision author to 0
     update_option('_wpghs_export_user_id', $user ? $user->ID : 0);
     global $wpdb;
     if ($updated_posts = $import->updated_posts()) {
         foreach ($updated_posts as $post_id) {
             $revision = wp_get_post_revision($post_id);
             if (!$revision) {
                 $revision = wp_save_post_revision($post_id);
                 if (!$revision || is_wp_error($revision)) {
                     // there was a problem saving a new revision
                     continue;
                 }
                 // wp_save_post_revision returns the ID, whereas get_post_revision returns the whole object
                 // in order to be consistent, let's make sure we have the whole object before continuing
                 $revision = get_post($revision);
             }
             $wpdb->update($wpdb->posts, array('post_author' => (int) get_option('_wpghs_export_user_id')), array('ID' => $revision->ID), array('%d'), array('%d'));
         }
     }
     // Deleting posts from a payload is the only place
     // we need to search posts by path; another way?
     $removed = array();
     foreach ($payload->commits as $commit) {
         $removed = array_merge($removed, $commit->removed);
     }
     foreach (array_unique($removed) as $path) {
         $post = new WordPress_GitHub_Sync_Post($path);
         wp_delete_post($post->id);
     }
     if ($new_posts = $import->new_posts()) {
         // disable the lock to allow exporting
         global $wpghs;
         $wpghs->push_lock = false;
         WordPress_GitHub_Sync::write_log(sprintf(__('Updating new posts with IDs: %s', 'wordpress-github-sync'), implode(', ', $new_posts)));
         foreach ($new_posts as $post_id) {
             $wpdb->update($wpdb->posts, array('post_author' => (int) get_option('_wpghs_export_user_id')), array('ID' => $post_id), array('%d'), array('%d'));
         }
         $msg = apply_filters('wpghs_commit_msg_new_posts', 'Updating new posts from WordPress at ' . site_url() . ' (' . get_bloginfo('name') . ')') . ' - wpghs';
         $export = new WordPress_GitHub_Sync_Export($new_posts, $msg);
         $export->run();
     }
     $msg = __('Payload processed', 'wordpress-github-sync');
     WordPress_GitHub_Sync::write_log($msg);
     return array('result' => 'success', 'message' => $msg);
 }
开发者ID:rexcode,项目名称:rexappz-wordpress,代码行数:87,代码来源:controller.php

示例9: setup_action

 /**
  * Determines what the user is trying to do on this page view.
  *
  * This determination is made mostly on the basis of the information passed in the URL
  * parameters. This function is also responsible for some of the object setup (getting the
  * revision post(s), etc).
  *
  * This is cribbed nearly wholesale from wp-admin/revision.php. In the future I would like
  * to clean it up to be less WordPressy and more pluginish.
  *
  * @package BuddyPress Docs
  * @since 1.1
  */
 function setup_action()
 {
     global $bp;
     if (!bp_docs_is_existing_doc()) {
         return;
     }
     wp_enqueue_script('list-revisions');
     $redirect = false;
     switch ($this->action) {
         case 'restore':
             if (!($this->revision = wp_get_post_revision($this->revision_id))) {
                 break;
             }
             if (!current_user_can('bp_docs_edit')) {
                 break;
             }
             if (!($post = get_post($this->revision->post_parent))) {
                 break;
             }
             // Revisions disabled and we're not looking at an autosave
             if (!wp_revisions_enabled($post) && !wp_is_post_autosave($this->revision)) {
                 $redirect = 'edit.php?post_type=' . $post->post_type;
                 break;
             }
             $referer = 'restore-post_' . $post->ID . '|' . $this->revision->ID;
             check_admin_referer($referer);
             wp_restore_post_revision($this->revision->ID);
             bp_core_add_message(sprintf(__('You have successfully restored the Doc to the revision from %s.', 'bp-docs'), $this->revision->post_date));
             $redirect = get_permalink($post->ID) . '/' . BP_DOCS_HISTORY_SLUG . '/';
             break;
         case 'diff':
             if (!($this->left_revision = get_post($this->left))) {
                 break;
             }
             if (!($this->right_revision = get_post($this->right))) {
                 break;
             }
             // Don't allow reverse diffs?
             if (strtotime($this->right_revision->post_modified_gmt) < strtotime($this->left_revision->post_modified_gmt)) {
                 $redirect = add_query_arg(array('left' => $this->right, 'right' => $this->left));
                 break;
             }
             if ($this->left_revision->ID == $this->right_revision->post_parent) {
                 // right is a revision of left
                 $post =& $this->left_revision;
             } elseif ($this->left_revision->post_parent == $this->right_revision->ID) {
                 // left is a revision of right
                 $post =& $this->right_revision;
             } elseif ($this->left_revision->post_parent == $this->right_revision->post_parent) {
                 // both are revisions of common parent
                 $post = get_post($this->left_revision->post_parent);
             } else {
                 break;
             }
             // Don't diff two unrelated revisions
             if (!wp_revisions_enabled($post)) {
                 // Revisions disabled
                 if (!wp_is_post_autosave($this->left_revision) && !wp_is_post_autosave($this->right_revision) || $post->ID !== $this->left_revision->ID && $post->ID !== $this->right_revision->ID) {
                     $redirect = 'edit.php?post_type=' . $post->post_type;
                     break;
                 }
             }
             if ($this->left_revision->ID == $this->right_revision->ID || !wp_get_post_revision($this->left_revision->ID) && !wp_get_post_revision($this->right_revision->ID)) {
                 break;
             }
             $post_title = '<a href="' . get_edit_post_link() . '">' . get_the_title() . '</a>';
             $h2 = sprintf(__('Compare Revisions of &#8220;%1$s&#8221;', 'bp-docs'), $post_title);
             $title = __('Revisions', 'bp-docs');
             $this->left = $this->left_revision->ID;
             $this->right = $this->right_revision->ID;
             $redirect = false;
             break;
         case 'view':
         default:
             if (!($this->revision = wp_get_post_revision($this->revision_id))) {
                 if ($this->revision = get_post($this->revision_id)) {
                     $this->is_latest = true;
                 } else {
                     break;
                 }
             }
             if (!($post = get_post($this->revision->post_parent))) {
                 break;
             }
             // Revisions disabled and we're not looking at an autosave
             if (!wp_revisions_enabled($post) && !wp_is_post_autosave($this->revision)) {
                 $redirect = 'edit.php?post_type=' . $post->post_type;
//.........这里部分代码省略.........
开发者ID:pausaura,项目名称:agora_nodes,代码行数:101,代码来源:addon-history.php

示例10: wp_momento_content_filter

function wp_momento_content_filter($content)
{
    if (is_singular() && get_query_var('revision')) {
        // Get the revision id
        $revision_id = get_query_var('revision');
        // Verify that it is a revision
        if (wp_is_post_revision($revision_id)) {
            // Remove the filer to avoid triggering an infinite loop
            remove_filter('the_content', 'wp_momento_content_filter');
            // Query this revision from the database
            $revision_id = get_query_var('revision');
            $revision = wp_get_post_revision($revision_id);
            // Render the content using this older data
            $rev_content = apply_filters('the_content', $revision->post_content);
            // Put the filter override back on so we can use it again
            add_filter('the_content', 'wp_momento_content_filter');
            // Return the revision content
            return $rev_content;
        }
        // If this a normal post and not a revision
        // then nothing special should happen
        if (is_single($revision_id)) {
            return $content;
        }
        // If it's none of the above just return the normal content.
        // Through perhaps we should have this raise a 404 or something.
        return $content;
    } else {
        return $content;
    }
}
开发者ID:pastpages,项目名称:wordpress-memento-plugin,代码行数:31,代码来源:memento.php

示例11: add_filter

add_filter('the_content', function ($content) {
    global $post;
    if (is_admin()) {
        return $content;
    }
    foreach (wpb_block_context() as $post_type) {
        if (get_post_type() == $post_type) {
            $page_blocks = wpb_get_blocks($post->ID);
            if ($page_blocks) {
                ob_start();
                foreach ($page_blocks as $page_block) {
                    if (!isset($page_block['buid']) || !isset($page_block['page_id']) || !isset($page_block['post_id'])) {
                        continue;
                    }
                    if (is_preview() === false && isset($page_block['post_revision_id'])) {
                        $rev = wp_get_post_revision($page_block['post_revision_id']);
                        if ($rev) {
                            $page_block['post_id'] = $rev->ID;
                        }
                    }
                    if ($page_block['into_id'] == 0) {
                        wpb_render_block_template($page_block['buid'], $page_block['post_id'], $page_block['page_id']);
                    }
                }
                $content = ob_get_contents();
                ob_end_clean();
            }
        }
    }
    return $content;
}, 20);
开发者ID:jblpdev,项目名称:wp-page-block,代码行数:31,代码来源:wp-page-block.php

示例12: compare_revisions_iframe

    static function compare_revisions_iframe()
    {
        //add_action('admin_init', 'register_admin_colors', 1);
        set_current_screen('revision-edit');
        $left = isset($_GET['left']) ? absint($_GET['left']) : false;
        $right = isset($_GET['right']) ? absint($_GET['right']) : false;
        if (!($left_revision = get_post($left))) {
            return;
        }
        if (!($right_revision = get_post($right))) {
            return;
        }
        if (!current_user_can('read_post', $left_revision->ID) || !current_user_can('read_post', $right_revision->ID)) {
            return;
        }
        // Don't allow reverse diffs?
        if (strtotime($right_revision->post_modified_gmt) < strtotime($left_revision->post_modified_gmt)) {
            //$redirect = add_query_arg( array( 'left' => $right, 'right' => $left ) );
            // Switch-a-roo
            $temp_revision = $left_revision;
            $left_revision = $right_revision;
            $right_revision = $temp_revision;
            unset($temp_revision);
        }
        global $post;
        if ($left_revision->ID == $right_revision->post_parent) {
            // right is a revision of left
            $post = $left_revision;
        } elseif ($left_revision->post_parent == $right_revision->ID) {
            // left is a revision of right
            $post = $right_revision;
        } elseif ($left_revision->post_parent == $right_revision->post_parent) {
            // both are revisions of common parent
            $post = get_post($left_revision->post_parent);
        } else {
            wp_die(__('Sorry, But you cant compare unrelated Revisions.', 'revision-control'));
        }
        // Don't diff two unrelated revisions
        if ($left_revision->ID == $right_revision->ID || !wp_get_post_revision($left_revision->ID) && !wp_get_post_revision($right_revision->ID)) {
            wp_die(__('Sorry, But you cant compare a Revision to itself.', 'revision-control'));
        }
        $title = sprintf(__('Compare Revisions of &#8220;%1$s&#8221;', 'revision-control'), get_the_title());
        $left = $left_revision->ID;
        $right = $right_revision->ID;
        $GLOBALS['hook_suffix'] = 'revision-control';
        wp_enqueue_style('revision-control');
        iframe_header();
        ?>
		<div class="wrap">
		
		<h2 class="long-header center"><?php 
        echo $title;
        ?>
</h2>
		
		<table class="form-table ie-fixed">
			<col class="th" />
		<tr id="revision">
			<th scope="col" class="th-full">
				<?php 
        printf(__('Older: %s', 'revision-control'), wp_post_revision_title($left_revision, false));
        ?>
				<span class="alignright"><?php 
        printf(__('Newer: %s', 'revision-control'), wp_post_revision_title($right_revision, false));
        ?>
</span>
			</th>
		</tr>
		<?php 
        $fields = _wp_post_revision_fields();
        foreach (get_object_taxonomies($post->post_type) as $taxonomy) {
            $t = get_taxonomy($taxonomy);
            $fields[$taxonomy] = $t->label;
            $left_terms = $right_terms = array();
            foreach (wp_get_object_terms($left_revision->ID, $taxonomy) as $term) {
                $left_terms[] = $term->name;
            }
            foreach (wp_get_object_terms($right_revision->ID, $taxonomy) as $term) {
                $right_terms[] = $term->name;
            }
            $left_revision->{$taxonomy} = (empty($left_terms) ? '' : "* ") . join("\n* ", $left_terms);
            $right_revision->{$taxonomy} = (empty($right_terms) ? '' : "* ") . join("\n* ", $right_terms);
        }
        $fields['postmeta'] = __('Post Meta', 'revision-control');
        $left_revision->postmeta = $right_revision->postmeta = array();
        foreach ((array) has_meta($right_revision->ID) as $meta) {
            if ('_' == $meta['meta_key'][0]) {
                continue;
            }
            $right_revision->postmeta[] = $meta['meta_key'] . ': ' . $meta['meta_value'];
            $left_val = get_post_meta('post', $left_revision->ID, $meta['meta_key'], true);
            if (!empty($left_val)) {
                $left_revision->postmeta[] = $meta['meta_key'] . ': ' . $left_val;
            }
        }
        $right_revision->postmeta = implode("\n", $right_revision->postmeta);
        $left_revision->postmeta = implode("\n", $left_revision->postmeta);
        $identical = true;
        foreach ($fields as $field => $field_title) {
            if (!($content = wp_text_diff($left_revision->{$field}, $right_revision->{$field}))) {
//.........这里部分代码省略.........
开发者ID:Karpec,项目名称:geo-mac,代码行数:101,代码来源:revision-control.php

示例13: compare_revisions_iframe

    function compare_revisions_iframe()
    {
        if (function_exists('register_admin_colors')) {
            add_action('admin_init', 'register_admin_colors', 1);
        } else {
            // Hard coded translation strings here as the translations are not required, just the name and stlesheet.
            wp_admin_css_color('classic', 'Blue', admin_url("css/colors-classic.css"), array('#073447', '#21759B', '#EAF3FA', '#BBD8E7'));
            wp_admin_css_color('fresh', 'Gray', admin_url("css/colors-fresh.css"), array('#464646', '#6D6D6D', '#F1F1F1', '#DFDFDF'));
        }
        $left = isset($_GET['left']) ? absint($_GET['left']) : false;
        $right = isset($_GET['right']) ? absint($_GET['right']) : false;
        if (!($left_revision = get_post($left))) {
            break;
        }
        if (!($right_revision = get_post($right))) {
            break;
        }
        if (!current_user_can('read_post', $left_revision->ID) || !current_user_can('read_post', $right_revision->ID)) {
            break;
        }
        // Don't allow reverse diffs?
        if (strtotime($right_revision->post_modified_gmt) < strtotime($left_revision->post_modified_gmt)) {
            //$redirect = add_query_arg( array( 'left' => $right, 'right' => $left ) );
            // Switch-a-roo
            $temp_revision = $left_revision;
            $left_revision = $right_revision;
            $right_revision = $temp_revision;
            unset($temp_revision);
        }
        global $post;
        if ($left_revision->ID == $right_revision->post_parent) {
            // right is a revision of left
            $post = $left_revision;
        } elseif ($left_revision->post_parent == $right_revision->ID) {
            // left is a revision of right
            $post = $right_revision;
        } elseif ($left_revision->post_parent == $right_revision->post_parent) {
            // both are revisions of common parent
            $post = get_post($left_revision->post_parent);
        } else {
            wp_die(__('Sorry, But you cant compare unrelated Revisions.', 'revision-control'));
        }
        // Don't diff two unrelated revisions
        if ($left_revision->ID == $right_revision->ID || !wp_get_post_revision($left_revision->ID) && !wp_get_post_revision($right_revision->ID)) {
            wp_die(__('Sorry, But you cant compare a Revision to itself.', 'revision-control'));
        }
        $title = sprintf(__('Compare Revisions of &#8220;%1$s&#8221;', 'revision-control'), get_the_title());
        $left = $left_revision->ID;
        $right = $right_revision->ID;
        iframe_header();
        ?>
		<div class="wrap">
		
		<h2 class="long-header center"><?php 
        echo $title;
        ?>
</h2>
		
		<table class="form-table ie-fixed">
			<col class="th" />
		<tr id="revision">
			<th scope="col" class="th-full">
				<?php 
        printf(__('Older: %s', 'revision-control'), wp_post_revision_title($left_revision, false));
        ?>
				<span class="alignright"><?php 
        printf(__('Newer: %s', 'revision-control'), wp_post_revision_title($right_revision, false));
        ?>
</span>
			</th>
		</tr>
		<?php 
        $fields = _wp_post_revision_fields();
        foreach (get_object_taxonomies($post->post_type) as $taxonomy) {
            $t = get_taxonomy($taxonomy);
            $fields[$taxonomy] = $t->label;
            $left_terms = $right_terms = array();
            foreach (wp_get_object_terms($left_revision->ID, $taxonomy) as $term) {
                $left_terms[] = $term->name;
            }
            foreach (wp_get_object_terms($right_revision->ID, $taxonomy) as $term) {
                $right_terms[] = $term->name;
            }
            $left_revision->{$taxonomy} = (empty($left_terms) ? '' : "* ") . join("\n* ", $left_terms);
            $right_revision->{$taxonomy} = (empty($right_terms) ? '' : "* ") . join("\n* ", $right_terms);
        }
        $identical = true;
        foreach ($fields as $field => $field_title) {
            if (!($content = wp_text_diff($left_revision->{$field}, $right_revision->{$field}))) {
                continue;
            }
            // There is no difference between left and right
            $identical = false;
            ?>
			<tr>
				<th scope="row"><strong><?php 
            echo esc_html($field_title);
            ?>
</strong></th>
			</tr>
//.........这里部分代码省略.........
开发者ID:niko-lgdcom,项目名称:archives,代码行数:101,代码来源:revision-control.php

示例14: wp_get_post_revisions

echo $h1;
?>
</h1>
		</header>
		<div class="entry-content">
		<?php 
$revisions = wp_get_post_revisions($post->ID);
$revision_id = @$_REQUEST['revision'];
$old_revision = @$_REQUEST['old'];
$new_revision = @$_REQUEST['new'];
$view_revision = @$_REQUEST['view_revision'];
if ($revision_id) {
    // Compare revision with current post
    require_once PACOWIKI_PLUGIN_PATH . 'library/Diff.php';
    require_once PACOWIKI_PLUGIN_PATH . 'library/Diff/Renderer/Html/Inline.php';
    $revision = wp_get_post_revision($revision_id);
    $new_content = explode("\n", $post->post_content);
    $old_content = explode("\n", $revision->post_content);
    // Options for generating the diff
    $options = array('ignoreWhitespace' => false, 'ignoreCase' => false);
    // Initialize the diff class
    $diff = new Diff($new_content, $old_content, $options);
    $renderer = new Diff_Renderer_Html_Inline();
    $diff_output = $diff->Render($renderer);
    if (empty($diff_output)) {
        echo '<p>' . __('No changes were found in post content of this revision!', 'pacowiki') . '</p>';
    } else {
        echo $diff_output;
    }
} elseif ($old_revision) {
    // Compare two different revisions
开发者ID:PacoWiki,项目名称:PacoWiki,代码行数:31,代码来源:single-pacowiki-history.php

示例15: wp_restoreRevision

 /**
  * Restore a post revision
  *
  * @since 3.5.0
  *
  * @uses wp_restore_post_revision()
  *
  * @param array $args Method parameters. Contains:
  *  - int     $blog_id (unused)
  *  - string  $username
  *  - string  $password
  *  - int     $post_id
  * @return bool|IXR_Error false if there was an error restoring, true if success.
  */
 public function wp_restoreRevision($args)
 {
     if (!$this->minimum_args($args, 3)) {
         return $this->error;
     }
     $this->escape($args);
     $username = $args[1];
     $password = $args[2];
     $revision_id = (int) $args[3];
     if (!($user = $this->login($username, $password))) {
         return $this->error;
     }
     /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
     do_action('xmlrpc_call', 'wp.restoreRevision');
     if (!($revision = wp_get_post_revision($revision_id))) {
         return new IXR_Error(404, __('Invalid post ID'));
     }
     if (wp_is_post_autosave($revision)) {
         return new IXR_Error(404, __('Invalid post ID'));
     }
     if (!($post = get_post($revision->post_parent))) {
         return new IXR_Error(404, __('Invalid post ID'));
     }
     if (!current_user_can('edit_post', $revision->post_parent)) {
         return new IXR_Error(401, __('Sorry, you cannot edit this post.'));
     }
     // Check if revisions are disabled.
     if (!wp_revisions_enabled($post)) {
         return new IXR_Error(401, __('Sorry, revisions are disabled.'));
     }
     $post = wp_restore_post_revision($revision_id);
     return (bool) $post;
 }
开发者ID:sb-xs,项目名称:que-pour-elle,代码行数:47,代码来源:class-wp-xmlrpc-server.php


注:本文中的wp_get_post_revision函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。