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


PHP wp_get_post_revisions函数代码示例

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


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

示例1: test_get_previous_revision

 function test_get_previous_revision()
 {
     $instance = $this->get_instance();
     //start out with a softball
     $fork = $this->create_fork(true);
     $revs = wp_get_post_revisions(get_post($fork)->post_parent);
     $this->assertEquals(reset($revs)->ID, $instance->revisions->get_previous_revision($fork));
 }
开发者ID:ZitaArlen,项目名称:post-forking,代码行数:8,代码来源:test_post_forking_revisions.php

示例2: render

 /**
  * @param WP_Post $post
  */
 public function render(WP_Post $post)
 {
     $revisions = wp_get_post_revisions($post->ID);
     $nonceField = wp_nonce_field($this->getKey() . '_meta_box', $this->getKey() . '_meta_box_nonce', true, false);
     $items = array_reduce($this->items, function ($html, MetaboxItemInterface $item) use($post, $revisions) {
         return $html . $item->render($post, $revisions);
     }, '');
     echo $nonceField . $items;
 }
开发者ID:tmf,项目名称:wp-metabox-helper,代码行数:12,代码来源:class-metabox.php

示例3: get_post_latest_revision

 function get_post_latest_revision($post_id)
 {
     // vars
     $revisions = wp_get_post_revisions($post_id);
     // shift off and return first revision (will return null if no revisions)
     $revision = array_shift($revisions);
     // return
     return $revision;
 }
开发者ID:Garth619,项目名称:Femi9,代码行数:9,代码来源:revisions.php

示例4: setUp

 function setUp()
 {
     parent::setUp();
     $this->post_id = $this->factory->post->create(array('post_content' => 'edit1'));
     wp_insert_post(array('ID' => $this->post_id, 'post_content' => 'edit2'));
     $revisions = wp_get_post_revisions($this->post_id);
     $revision = array_shift($revisions);
     $this->revision_id = $revision->ID;
 }
开发者ID:rmccue,项目名称:wordpress-unit-tests,代码行数:9,代码来源:restoreRevision.php

示例5: setUp

 public function setUp()
 {
     parent::setUp();
     $revisions = wp_get_post_revisions(self::$post_id);
     $this->revision_1 = array_pop($revisions);
     $this->revision_id1 = $this->revision_1->ID;
     $this->revision_2 = array_pop($revisions);
     $this->revision_id2 = $this->revision_2->ID;
 }
开发者ID:aaemnnosttv,项目名称:develop.git.wordpress.org,代码行数:9,代码来源:rest-revisions-controller.php

示例6: test_is_revision_dont_flush_cache

 public function test_is_revision_dont_flush_cache()
 {
     $post = $this->factory->post->create_and_get();
     wp_update_post(array('post_status' => 'draft', 'post_title' => 'some-post', 'post_type' => 'post', 'post_content' => 'some_content', 'ID' => $post->ID));
     $salt = $this->obj->cache_salt;
     $revisions = wp_get_post_revisions($post->ID);
     $revision = array_shift($revisions);
     $this->obj->clean_post_cache($revision->ID, $revision);
     $this->assertsame($salt, $this->obj->cache_salt);
 }
开发者ID:timeincoss,项目名称:enhanced-post-cache,代码行数:10,代码来源:test-flush-cache.php

示例7: test_get_previous_revision

 function test_get_previous_revision()
 {
     $instance = $this->get_instance();
     //start out with a softball
     $fork = $this->create_fork(true);
     $revs = wp_get_post_revisions(get_post($fork)->post_parent);
     $this->assertEquals(reset($revs)->ID, $instance->revisions->get_previous_revision($fork));
     //best guess approach, should return parent post
     $fork = $this->create_fork(false, false);
     $this->assertEquals(get_post($fork)->post_parent, $instance->revisions->get_previous_revision($fork));
 }
开发者ID:fancyguy,项目名称:post-forking,代码行数:11,代码来源:test_post_forking_revisions.php

示例8: get_current_revision

 function get_current_revision()
 {
     if (!($js = $this->get_js_post())) {
         return false;
     }
     if (!empty($js['ID'])) {
         $revisions = wp_get_post_revisions($js['ID'], 'orderby=ID&order=DESC&limit=1');
     }
     if (empty($revisions)) {
         return $js;
     }
     return get_object_vars(array_shift($revisions));
 }
开发者ID:hwasawoo,项目名称:Custom-Javascript-Editor,代码行数:13,代码来源:custom-javascript-editor.php

示例9: get_items

 /**
  * Get a collection of revisions
  *
  * @param WP_REST_Request $request Full data about the request.
  * @return WP_Error|WP_REST_Response
  */
 public function get_items($request)
 {
     $parent = get_post($request['parent_id']);
     if (!$request['parent_id'] || !$parent || $this->parent_post_type !== $parent->post_type) {
         return new WP_Error('rest_post_invalid_parent_id', __('Invalid post parent ID.'), array('status' => 404));
     }
     $revisions = wp_get_post_revisions($request['parent_id']);
     $struct = array();
     foreach ($revisions as $revision) {
         $struct[] = $this->prepare_item_for_response($revision, $request);
     }
     return $struct;
 }
开发者ID:nathansh,项目名称:gifzone,代码行数:19,代码来源:class-wp-rest-revisions-controller.php

示例10: get_items

 /**
  * Get a collection of revisions
  *
  * @param WP_REST_Request $request Full data about the request.
  * @return WP_Error|WP_REST_Response
  */
 public function get_items($request)
 {
     $parent = get_post($request['parent_id']);
     if (!$request['parent_id'] || !$parent || $this->parent_post_type !== $parent->post_type) {
         return new WP_Error('rest_post_invalid_parent_id', __('Invalid post parent id.'), array('status' => 404));
     }
     $revisions = wp_get_post_revisions($request['parent_id']);
     $response = array();
     foreach ($revisions as $revision) {
         $data = $this->prepare_item_for_response($revision, $request);
         $response[] = $this->prepare_response_for_collection($data);
     }
     return rest_ensure_response($response);
 }
开发者ID:Datartisan,项目名称:datartery-wp,代码行数:20,代码来源:class-wp-rest-revisions-controller.php

示例11: setUp

 public function setUp()
 {
     parent::setUp();
     $this->post_id = $this->factory->post->create();
     $this->page_id = $this->factory->post->create(array('post_type' => 'page'));
     $this->editor_id = $this->factory->user->create(array('role' => 'editor'));
     $this->contributor_id = $this->factory->user->create(array('role' => 'contributor'));
     wp_update_post(array('post_content' => 'This content is better.', 'ID' => $this->post_id));
     wp_update_post(array('post_content' => 'This content is marvelous.', 'ID' => $this->post_id));
     $revisions = wp_get_post_revisions($this->post_id);
     $this->revision_1 = array_pop($revisions);
     $this->revision_id1 = $this->revision_1->ID;
     $this->revision_2 = array_pop($revisions);
     $this->revision_id2 = $this->revision_2->ID;
 }
开发者ID:nathansh,项目名称:gifzone,代码行数:15,代码来源:test-rest-revisions-controller.php

示例12: get

 /**
  * Get revisions for a post
  *
  * @since 0.9.5
  *
  * @param array $data
  *
  * @return array
  */
 public static function get($data)
 {
     $args = array();
     if (isset($data['limit'])) {
         $args['posts_per_page'] = $data['limit'];
     } else {
         $args['posts_per_page'] = 6;
         // we start at revision 0
     }
     $revisions = wp_get_post_revisions($data['postid'], $args);
     if (is_array($revisions) && !empty($revisions)) {
         self::set_revisions($data['postid'], $revisions);
     }
     return self::$revisions;
 }
开发者ID:rhurling,项目名称:lasso,代码行数:24,代码来源:revision.php

示例13: hook

 /**
  * Conditionally hooks the filters needed to fetch a revision meta data.
  */
 public function hook()
 {
     $is_event_revision = $this->is_previewing() || $this->is_saving_preview();
     if ($is_event_revision) {
         $this->event_id = $this->get_event_id();
         if (empty($this->event_id)) {
             return;
         }
         $revisions = wp_get_post_revisions($this->event_id);
         if (empty($revisions)) {
             return;
         }
         $this->latest_revision = reset($revisions);
         add_filter('get_post_metadata', array($this, 'intercept_post_metadata'), 50, 4);
     }
 }
开发者ID:nullify005,项目名称:shcc-website,代码行数:19,代码来源:Preview.php

示例14: get_revisions

 /**
  * Get revisions for a specific post.
  *
  * @param int $id Post ID
  * @uses wp_get_post_revisions
  * @return WP_JSON_Response
  */
 public function get_revisions($id)
 {
     $id = (int) $id;
     $parent = get_post($id, ARRAY_A);
     if (empty($id) || empty($parent['ID'])) {
         return new WP_Error('json_post_invalid_id', __('Invalid post ID.'), array('status' => 404));
     }
     if (!json_check_post_permission($parent, 'edit')) {
         return new WP_Error('json_cannot_view', __('Sorry, you cannot view the revisions for this post.'), array('status' => 403));
     }
     // Todo: Query args filter for wp_get_post_revisions
     $revisions = wp_get_post_revisions($id);
     $struct = array();
     foreach ($revisions as $revision) {
         $post = get_object_vars($revision);
         $struct[] = $this->prepare_post($post, 'view-revision');
     }
     return $struct;
 }
开发者ID:safetycat,项目名称:edibleurban,代码行数:26,代码来源:class-wp-json-posts.php

示例15: get_revisions

 /**
  * Get revisions for a specific post.
  *
  * @param int $id Post ID
  * @uses wp_get_post_revisions
  * @return WP_JSON_Response
  */
 public function get_revisions($id)
 {
     $id = (int) $id;
     $parent = get_post($id, ARRAY_A);
     if (empty($id) || empty($parent['ID'])) {
         json_error(BigAppErr::$post['code'], "Invalid post ID.");
     }
     if (!json_check_post_permission($parent, 'edit')) {
         json_error(BigAppErr::$post['code'], __("Sorry, you cannot view the revisions for this post."));
     }
     // Todo: Query args filter for wp_get_post_revisions
     $revisions = wp_get_post_revisions($id);
     $struct = array();
     foreach ($revisions as $revision) {
         $post = get_object_vars($revision);
         $struct[] = $this->prepare_post($post, 'view-revision');
     }
     return $struct;
 }
开发者ID:Mushan3420,项目名称:BigApp-PHP7,代码行数:26,代码来源:class-wp-json-posts.php


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