module_url = $this->get_module_url( __FILE__ );
// Register the module with Edit Flow
$args = array(
'title' => __( 'Editorial Comments', 'edit-flow' ),
'short_description' => __( 'Share internal notes with your team.', 'edit-flow' ),
'extended_description' => __( 'Use editorial comments to hold a private discussion about a post. Communicate directly with your writers or editors about what works and what needs to be improved for each piece.', 'edit-flow' ),
'module_url' => $this->module_url,
'img_url' => $this->module_url . 'lib/editorial_comments_s128.png',
'slug' => 'editorial-comments',
'default_options' => array(
'enabled' => 'on',
'post_types' => array(
'post' => 'on',
'page' => 'on',
),
),
'configure_page_cb' => 'print_configure_view',
'configure_link_text' => __( 'Choose Post Types', 'edit-flow' ),
'autoload' => false,
'settings_help_tab' => array(
'id' => 'ef-editorial-comments-overview',
'title' => __('Overview', 'edit-flow'),
'content' => __('
Editorial comments help you cut down on email overload and keep the conversation close to where it matters: your content. Threaded commenting in the admin, similar to what you find at the end of a blog post, allows writers and editors to privately leave feedback and discuss what needs to be changed before publication.
Anyone with access to view the story in progress will also have the ability to comment on it. If you have notifications enabled, those following the post will receive an email every time a comment is left.
', 'edit-flow' ),
);
$this->module = EditFlow()->register_module( 'editorial_comments', $args );
}
/**
* Initialize the rest of the stuff in the class if the module is active
*/
function init() {
add_action( 'add_meta_boxes', array ( $this, 'add_post_meta_box' ) );
add_action( 'admin_init', array( $this, 'register_settings' ) );
add_action( 'admin_enqueue_scripts', array( $this, 'add_admin_scripts' ) );
add_action( 'wp_ajax_editflow_ajax_insert_comment', array( $this, 'ajax_insert_comment' ) );
}
/**
* Upgrade our data in case we need to
*
* @since 0.7
*/
function upgrade( $previous_version ) {
global $edit_flow;
// Upgrade path to v0.7
if ( version_compare( $previous_version, '0.7' , '<' ) ) {
// Technically we've run this code before so we don't want to auto-install new data
$edit_flow->update_module_option( $this->module->name, 'loaded_once', true );
}
}
/**
* Load any of the admin scripts we need but only on the pages we need them
*/
function add_admin_scripts( ) {
global $pagenow;
$post_type = $this->get_current_post_type();
$supported_post_types = $this->get_post_types_for_module( $this->module );
if ( !in_array( $post_type, $supported_post_types ) )
return;
if ( !in_array( $pagenow, array( 'post.php', 'page.php', 'post-new.php', 'page-new.php' ) ) )
return;
wp_enqueue_script( 'edit_flow-post_comment', $this->module_url . 'lib/editorial-comments.js', array( 'jquery', 'wp-ajax-response' ), EDIT_FLOW_VERSION, true );
wp_localize_script( 'edit_flow-post_comment', '__ef_localize_post_comment', array(
'and' => esc_html__( 'and', 'edit-flow' ),
'none_notified' => esc_html__( 'No one will be notified.', 'edit-flow' ),
) );
wp_enqueue_style( 'edit-flow-editorial-comments-css', $this->module_url . 'lib/editorial-comments.css', false, EDIT_FLOW_VERSION, 'all' );
$thread_comments = (int) get_option('thread_comments');
?>
get_post_types_for_module( $this->module );
foreach ( $supported_post_types as $post_type )
add_meta_box('edit-flow-editorial-comments', __('Editorial Comments', 'edit-flow'), array($this, 'editorial_comments_meta_box'), $post_type, 'normal' );
}
function editorial_comments_meta_box( ) {
global $post, $post_ID;
?>
%1$s said on %2$s at %3$s', 'edit-flow'), comment_author_email_link( $comment->comment_author ), get_comment_date( get_option( 'date_format' ) ), get_comment_time() ); ?>
maybe_output_comment_meta( $comment->comment_ID ); ?>