Permalink
Browse files

Don't load the publishing interface if archived

When archived, we don't initialise the liveblog's
JavaScript at all, so if we want the publishing interface
we will need to selective init some parts. For example
we will need the form template and some hooks.
  • Loading branch information...
1 parent 694c0d0 commit 5781e5588b9726c16dc01fa7c90f2b4fa386c40c @nb nb committed Jan 17, 2013
Showing with 9 additions and 9 deletions.
  1. +2 −2 classes/class-wpcom-liveblog-entry.php
  2. +6 −6 liveblog.php
  3. +1 −1 templates/liveblog-single-entry.php
@@ -86,7 +86,7 @@ public function render() {
$entry_date = get_comment_date( get_option('date_format'), $entry_id );
$entry_time = get_comment_date( get_option('time_format'), $entry_id );
$timestamp = get_comment_date( 'U', $entry_id );
- $can_edit_liveblog = WPCOM_Liveblog::current_user_can_edit_liveblog();
+ $is_liveblog_editable = WPCOM_Liveblog::is_liveblog_editable();
return WPCOM_Liveblog::get_template_part( 'liveblog-single-entry.php', compact(
'post_id',
@@ -99,7 +99,7 @@ public function render() {
'entry_date',
'entry_time',
'timestamp',
- 'can_edit_liveblog'
+ 'is_liveblog_editable'
) );
}
View
@@ -468,7 +468,7 @@ public static function enqueue_scripts() {
wp_enqueue_script( self::key, plugins_url( 'js/liveblog.js', __FILE__ ), array( 'jquery', 'jquery-color', 'backbone', 'jquery-throttle', 'moment' ), self::version, true );
- if ( self::current_user_can_edit_liveblog() ) {
+ if ( self::is_liveblog_editable() ) {
wp_enqueue_script( 'liveblog-publisher', plugins_url( 'js/liveblog-publisher.js', __FILE__ ), array( self::key ), self::version, true );
wp_enqueue_script( 'liveblog-plupload', plugins_url( 'js/plupload.js', __FILE__ ), array( self::key, 'wp-plupload', 'jquery' ) );
self::add_default_plupload_settings();
@@ -595,13 +595,9 @@ public static function add_liveblog_to_content( $content ) {
* @return string
*/
private static function get_editor_output() {
- if ( ! self::current_user_can_edit_liveblog() )
+ if ( !self::is_liveblog_editable() )
return;
- if ( 'archive' == self::get_liveblog_state() ) {
- return;
- }
- // Get the template part
return self::get_template_part( 'liveblog-form.php' );
}
@@ -717,6 +713,10 @@ public static function current_user_can_edit_liveblog() {
return (bool) current_user_can( apply_filters( 'liveblog_edit_cap', self::edit_cap ) );
}
+ public static function is_liveblog_editable() {
+ return self::current_user_can_edit_liveblog() && 'enable' == self::get_liveblog_state();
+ }
+
/**
* Can the current user edit liveblog data (ajax)
*
@@ -7,7 +7,7 @@
<div class="liveblog-entry-text" data-original-content="<?php echo esc_attr( $original_content ); ?>">
<?php echo $content; ?>
</div>
-<?php if ( $can_edit_liveblog ): ?>
+<?php if ( $is_liveblog_editable ): ?>
<ul class="liveblog-entry-actions">
<li><button class="liveblog-entry-edit"><?php _e( 'Edit', 'liveblog' ); ?></button><button class="liveblog-entry-delete"><?php _e( 'Delete', 'liveblog' ); ?></button></li>
</ul>

0 comments on commit 5781e55

Please sign in to comment.