How can I keep the content of my pages version controlled?

We have a WordPress-based website that provides documentation to our REST API. Since our API is constantly changing, so

We have a WordPress-based website that provides documentation to our REST API. Since our API is constantly changing, so is the documentation. However, we would like to keep the documentation version controlled so it can be matched against API commits. Is there a way to have WordPress pages get their content from a remote repository (GitHub, for example)? Or is there a way to push content to WordPress from some repository?

We have a WordPress-based website that provides documentation to our REST API. Since our API is constantly changing, so is the documentation. However, we would like to keep the documentation version controlled so it can be matched against API commits. Is there a way to have WordPress pages get their content from a remote repository (GitHub, for example)? Or is there a way to push content to WordPress from some repository?

Share Improve this question asked Oct 29, 2012 at 18:30 Elliot CameronElliot Cameron 2311 silver badge5 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 6

You already got something like this built in: Revisions.

// Define the nr of saved revisions in your wp-config.php
define( 'WP_POST_REVISIONS', 30 );

You can simply grab them by calling get_posts() with a post_type of revision.

To show the difference between two revisions simply use wp_text_diff().

// Example
$revisions = get_posts( array(
    'post_type' => 'revision'
) );
echo wp_text_diff(
     $revisions[0]['post_content']
    ,$revisions[1]['post_content']
    ,array(
         'title'       => 'Revision diff'
        ,'title_left'  => $revisions[0]['post_title']
        ,'title_right' => $revisions[1]['post_title']
     )
);

To diff for e.g. the last version with the version prior to the last, you could use end( $revisions )['post_content'] and diff it with $revisions[ count( $revisions ) -2 ]['post_content']. (Note: -2 as the arrays index start with zero and you want the version prior to the last.).

You could use a Git hook and post per XML-RPC to WordPress. A Git hook can be any executable file, even PHP.

Another option – on GitHub – is to use the email hook: Go to https://github/username/projectname/admin/hooks, select Email and send an email to the blog. Enable the Post per email feature.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745196594a4616121.html

相关推荐

  • How can I keep the content of my pages version controlled?

    We have a WordPress-based website that provides documentation to our REST API. Since our API is constantly changing, so

    21小时前
    10

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信