Skip to content

Commit

Permalink
Don't load the publishing interface if archived
Browse files Browse the repository at this point in the history
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
nb committed Jan 17, 2013
1 parent 694c0d0 commit 5781e55
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions classes/class-wpcom-liveblog-entry.php
Expand Up @@ -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',
Expand All @@ -99,7 +99,7 @@ public function render() {
'entry_date',
'entry_time',
'timestamp',
'can_edit_liveblog'
'is_liveblog_editable'
) );
}

Expand Down
12 changes: 6 additions & 6 deletions liveblog.php
Expand Up @@ -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();
Expand Down Expand Up @@ -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' );
}

Expand Down Expand Up @@ -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)
*
Expand Down
2 changes: 1 addition & 1 deletion templates/liveblog-single-entry.php
Expand Up @@ -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>
Expand Down

0 comments on commit 5781e55

Please sign in to comment.