當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。