Open twaiiiin opened 5 years ago
I like the idea!
Here is my first try at it: Untested of course.
<?php
/*
* Add Simple history to a metabox on Page/Post
*/
//Define vars
$show_metabox_post_type = 'post'; //Show Metabox: all, post, page, or post type
$location ='side'; // Context
$priority = 'default'; // Priority
$filter_posttype = 'all'; //Filter by posttypes: all, post, page, or post type
$filter_author = 123; //Author id(s)
/* Fire our meta box setup function on the post editor screen. */
add_action( 'load-post.php', 'simple_history_post_metabox_setup' );
add_action( 'load-post-new.php', 'simple_history_post_metabox_setup' );
/* Meta box setup function. */
function simple_history_post_metabox_setup() {
/* Add meta boxes on the 'add_meta_boxes' hook. */
add_action( 'add_meta_boxes', 'simple_history_post_meta_boxes' );
}
/* Create one or more meta boxes to be displayed on the post editor screen. */
function simple_history_post_meta_boxes() {
add_meta_box(
'sh-mb-post-class', // Unique ID
esc_html__( 'Simple History Box', 'shmb' ), // Title
'simple_history_post_class_meta_box', // Callback function
$show_metabox_post_type,
$location,
$priority
);
}
/* Display the post meta box. */
function simple_history_post_class_meta_box( $post ) { ?>
<?php wp_nonce_field( basename( __FILE__ ), 'sh_post_class_nonce' ); ?>
<p>
<label for="sh-mb-post-class"><?php _e( "Current Logs for this Post", 'shmb' ); ?></label>
<br />
<p>
<?php
/*
For all possible queries refer to: https://codex.wordpress.org/Class_Reference/WP_Query
*/
$args = array(
'posts_per_page' => 5,
'post_type' => array($filter_posttype),
'orderby' => 'modified',
'author' => array($filter_author),
);
$logQuery = new SimpleHistoryLogQuery();
$queryResults = $logQuery->query( $args );
echo $queryResults;
?>
<p>
</p>
<?php }
Actually I just view this: https://github.com/bonny/WordPress-Simple-History/blob/master/examples/examples.php
So if that can be tied into my above code, then we might have something sweet!
Also, need to wrap with if Simple History Class.
Hello,
Feature request: A new metabox on the post editing page to see the changes made to this post. But that is maybe too much a duplicate with the "Revisions" metabox. What do you think about it?
Thank you for your great work.