Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added back the Toggle Post Details option to the Story Budget page #504

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 25 additions & 5 deletions modules/story-budget/story-budget.php
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,11 @@ function print_post( $post, $parent_term ) {
?>
<tr id='post-<?php echo esc_attr( $post->ID ); ?>' class='alternate' valign="top">
<?php foreach( (array)$this->term_columns as $key => $name ) {
echo '<td>';
if ( $key === 'title' ) {
echo '<td class="post-title">';
} else {
echo '<td>';
}
if ( method_exists( $this, 'term_column_' . $key ) ) {
$method = 'term_column_' . $key;
echo $this->$method( $post, $parent_term );
Expand Down Expand Up @@ -533,14 +537,30 @@ function term_column_default( $post, $column_name, $parent_term ) {
*/
function term_column_title( $post, $parent_term ) {
$post_title = _draft_or_post_title( $post->ID );

$post_type_object = get_post_type_object( $post->post_type );
$can_edit_post = current_user_can( $post_type_object->cap->edit_post, $post->ID );
if ( $can_edit_post )
$output = '<strong><a href="' . get_edit_post_link( $post->ID ) . '">' . esc_html( $post_title ) . '</a></strong>';
$output = '<strong><a href="' . get_edit_post_link( $post->ID ) . '">' . esc_html( $post_title ) . '</a></strong>';
else
$output = '<strong>' . esc_html( $post_title ) . '</strong>';


/*
* the setup_postadata is still not fixed so the_excerpt cannot be used
* and the logic of get_the_excerpt function is replicated
*/
if ( current_user_can( 'read_post', $post->ID ) ) {
if ( post_password_required( $post ) ) {
$output .= '<p>' . __( 'There is no excerpt because this is a protected post.', 'edit-flow' ) . '</p>';
} elseif ( $post->post_excerpt ) {
$output .= '<p>' . wp_trim_excerpt( $post->post_excerpt ) . '</p>';
} else {
$excerpt_length = apply_filters( 'excerpt_length', 15 );
$excerpt_more = apply_filters( 'excerpt_more', ' ' . '[&hellip;]' );
$output .= '<p>' . wp_trim_words( $post->post_content, $excerpt_length, $excerpt_more ) . '</p>';
}
}

// Edit or Trash or View
$output .= '<div class="row-actions">';
$item_actions = array();
Expand Down Expand Up @@ -629,7 +649,7 @@ function table_navigation() {
</div><!-- /alignleft actions -->

<div class="print-box" style="float:right; margin-right: 30px;"><!-- Print link -->
<a href="#" id="print_link"><?php _e( 'Print', 'edit-flow' ); ?></a>
<a href="#" id="toggle_details"><?php _e( 'Toggle Post Details', 'edit-flow' ); ?></a> | <a href="#" id="print_link"><?php _e( 'Print', 'edit-flow' ); ?></a>
</div>
<div class="clear"></div>

Expand Down