raw
mp-wp_genesis           1 <?php
mp-wp_genesis 2 /**
mp-wp_genesis 3 * WordPress Dashboard Widget Administration Panel API
mp-wp_genesis 4 *
mp-wp_genesis 5 * @package WordPress
mp-wp_genesis 6 * @subpackage Administration
mp-wp_genesis 7 */
mp-wp_genesis 8
mp-wp_genesis 9 /**
mp-wp_genesis 10 * Registers dashboard widgets.
mp-wp_genesis 11 *
mp-wp_genesis 12 * handles POST data, sets up filters.
mp-wp_genesis 13 *
mp-wp_genesis 14 * @since unknown
mp-wp_genesis 15 */
mp-wp_genesis 16 function wp_dashboard_setup() {
mp-wp_genesis 17 global $wp_registered_widgets, $wp_registered_widget_controls, $wp_dashboard_control_callbacks;
mp-wp_genesis 18 $wp_dashboard_control_callbacks = array();
mp-wp_genesis 19
mp-wp_genesis 20 $update = false;
mp-wp_genesis 21 $widget_options = get_option( 'dashboard_widget_options' );
mp-wp_genesis 22 if ( !$widget_options || !is_array($widget_options) )
mp-wp_genesis 23 $widget_options = array();
mp-wp_genesis 24
mp-wp_genesis 25 /* Register Widgets and Controls */
mp-wp_genesis 26
mp-wp_genesis 27 // Right Now
mp-wp_genesis 28 wp_add_dashboard_widget( 'dashboard_right_now', __( 'Right Now' ), 'wp_dashboard_right_now' );
mp-wp_genesis 29
mp-wp_genesis 30 // Recent Comments Widget
mp-wp_genesis 31 $recent_comments_title = __( 'Recent Comments' );
mp-wp_genesis 32 wp_add_dashboard_widget( 'dashboard_recent_comments', $recent_comments_title, 'wp_dashboard_recent_comments' );
mp-wp_genesis 33
mp-wp_genesis 34 // Recent Drafts
mp-wp_genesis 35 if ( current_user_can('edit_posts') )
mp-wp_genesis 36 wp_add_dashboard_widget( 'dashboard_recent_drafts', __('Recent Drafts'), 'wp_dashboard_recent_drafts' );
mp-wp_genesis 37
mp-wp_genesis 38 // Hook to register new widgets
mp-wp_genesis 39 do_action( 'wp_dashboard_setup' );
mp-wp_genesis 40
mp-wp_genesis 41 // Filter widget order
mp-wp_genesis 42 $dashboard_widgets = apply_filters( 'wp_dashboard_widgets', array() );
mp-wp_genesis 43
mp-wp_genesis 44 foreach ( $dashboard_widgets as $widget_id ) {
mp-wp_genesis 45 $name = empty( $wp_registered_widgets[$widget_id]['all_link'] ) ? $wp_registered_widgets[$widget_id]['name'] : $wp_registered_widgets[$widget_id]['name'] . " <a href='{$wp_registered_widgets[$widget_id]['all_link']}' class='edit-box open-box'>" . __('View all') . '</a>';
mp-wp_genesis 46 wp_add_dashboard_widget( $widget_id, $name, $wp_registered_widgets[$widget_id]['callback'], $wp_registered_widget_controls[$widget_id]['callback'] );
mp-wp_genesis 47 }
mp-wp_genesis 48
mp-wp_genesis 49 if ( 'POST' == $_SERVER['REQUEST_METHOD'] && isset($_POST['widget_id']) ) {
mp-wp_genesis 50 ob_start(); // hack - but the same hack wp-admin/widgets.php uses
mp-wp_genesis 51 wp_dashboard_trigger_widget_control( $_POST['widget_id'] );
mp-wp_genesis 52 ob_end_clean();
mp-wp_genesis 53 wp_redirect( remove_query_arg( 'edit' ) );
mp-wp_genesis 54 exit;
mp-wp_genesis 55 }
mp-wp_genesis 56
mp-wp_genesis 57 if ( $update )
mp-wp_genesis 58 update_option( 'dashboard_widget_options', $widget_options );
mp-wp_genesis 59
mp-wp_genesis 60 do_action('do_meta_boxes', 'dashboard', 'normal', '');
mp-wp_genesis 61 do_action('do_meta_boxes', 'dashboard', 'side', '');
mp-wp_genesis 62 }
mp-wp_genesis 63
mp-wp_genesis 64 function wp_add_dashboard_widget( $widget_id, $widget_name, $callback, $control_callback = null ) {
mp-wp_genesis 65 global $wp_dashboard_control_callbacks;
mp-wp_genesis 66 if ( $control_callback && current_user_can( 'edit_dashboard' ) && is_callable( $control_callback ) ) {
mp-wp_genesis 67 $wp_dashboard_control_callbacks[$widget_id] = $control_callback;
mp-wp_genesis 68 if ( isset( $_GET['edit'] ) && $widget_id == $_GET['edit'] ) {
mp-wp_genesis 69 list($url) = explode( '#', add_query_arg( 'edit', false ), 2 );
mp-wp_genesis 70 $widget_name .= ' <span class="postbox-title-action"><a href="' . clean_url( $url ) . '">' . __( 'Cancel' ) . '</a></span>';
mp-wp_genesis 71 add_meta_box( $widget_id, $widget_name, '_wp_dashboard_control_callback', 'dashboard', 'normal', 'core' );
mp-wp_genesis 72 return;
mp-wp_genesis 73 }
mp-wp_genesis 74 list($url) = explode( '#', add_query_arg( 'edit', $widget_id ), 2 );
mp-wp_genesis 75 $widget_name .= ' <span class="postbox-title-action"><a href="' . clean_url( "$url#$widget_id" ) . '" class="edit-box open-box">' . __( 'Configure' ) . '</a></span>';
mp-wp_genesis 76 }
mp-wp_genesis 77 $side_widgets = array('dashboard_quick_press', 'dashboard_recent_drafts', 'dashboard_primary', 'dashboard_secondary');
mp-wp_genesis 78 $location = 'normal';
mp-wp_genesis 79 if ( in_array($widget_id, $side_widgets) )
mp-wp_genesis 80 $location = 'side';
mp-wp_genesis 81 add_meta_box( $widget_id, $widget_name , $callback, 'dashboard', $location, 'core' );
mp-wp_genesis 82 }
mp-wp_genesis 83
mp-wp_genesis 84 function _wp_dashboard_control_callback( $dashboard, $meta_box ) {
mp-wp_genesis 85 echo '<form action="" method="post" class="dashboard-widget-control-form">';
mp-wp_genesis 86 wp_dashboard_trigger_widget_control( $meta_box['id'] );
mp-wp_genesis 87 echo "<p class='submit'><input type='hidden' name='widget_id' value='$meta_box[id]' /><input type='submit' value='" . __( 'Submit' ) . "' /></p>";
mp-wp_genesis 88
mp-wp_genesis 89 echo '</form>';
mp-wp_genesis 90 }
mp-wp_genesis 91
mp-wp_genesis 92 /**
mp-wp_genesis 93 * Displays the dashboard.
mp-wp_genesis 94 *
mp-wp_genesis 95 * @since unknown
mp-wp_genesis 96 */
mp-wp_genesis 97 function wp_dashboard() {
mp-wp_genesis 98 echo "<div id='dashboard-widgets' class='metabox-holder'>\n\n";
mp-wp_genesis 99
mp-wp_genesis 100 echo "<div id='side-info-column' class='inner-sidebar'>\n\n";
mp-wp_genesis 101 $class = do_meta_boxes( 'dashboard', 'side', '' ) ? ' class="has-sidebar"' : '';
mp-wp_genesis 102 echo "</div>\n\n";
mp-wp_genesis 103
mp-wp_genesis 104 echo "<div id='post-body'$class>\n\n";
mp-wp_genesis 105 echo "<div id='dashboard-widgets-main-content' class='has-sidebar-content'>\n\n";
mp-wp_genesis 106 do_meta_boxes( 'dashboard', 'normal', '' );
mp-wp_genesis 107 echo "</div>\n\n";
mp-wp_genesis 108 echo "</div>\n\n";
mp-wp_genesis 109
mp-wp_genesis 110 echo "<form style='display: none' method='get' action=''>\n<p>\n";
mp-wp_genesis 111 wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false );
mp-wp_genesis 112 wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false );
mp-wp_genesis 113 echo "</p>\n</form>\n";
mp-wp_genesis 114
mp-wp_genesis 115 echo "</div>";
mp-wp_genesis 116 }
mp-wp_genesis 117
mp-wp_genesis 118 /* Dashboard Widgets */
mp-wp_genesis 119
mp-wp_genesis 120 function wp_dashboard_right_now() {
mp-wp_genesis 121 $num_posts = wp_count_posts( 'post' );
mp-wp_genesis 122 $num_pages = wp_count_posts( 'page' );
mp-wp_genesis 123
mp-wp_genesis 124 $num_cats = wp_count_terms('category');
mp-wp_genesis 125
mp-wp_genesis 126 $num_tags = wp_count_terms('post_tag');
mp-wp_genesis 127
mp-wp_genesis 128 $num_comm = wp_count_comments( );
mp-wp_genesis 129
mp-wp_genesis 130 echo "\n\t".'<div class="table">'."\n\t".'<table>';
mp-wp_genesis 131 echo "\n\t".'<tr class="first">';
mp-wp_genesis 132
mp-wp_genesis 133 // Posts
mp-wp_genesis 134 $num = number_format_i18n( $num_posts->publish );
mp-wp_genesis 135 if ( current_user_can( 'edit_posts' ) )
mp-wp_genesis 136 $text = "<a href='edit.php'>$num</a>";
mp-wp_genesis 137 else
mp-wp_genesis 138 $text = $num;
mp-wp_genesis 139 echo '<td class="first b b-posts">' . $text . '</td>';
mp-wp_genesis 140 echo '<td class="t posts">' . __ngettext( 'Post', 'Posts', intval($num_posts->publish) ) . '</td>';
mp-wp_genesis 141 /* TODO: Show status breakdown on hover
mp-wp_genesis 142 if ( $can_edit_pages && !empty($num_pages->publish) ) { // how many pages is not exposed in feeds. Don't show if !current_user_can
mp-wp_genesis 143 $post_type_texts[] = '<a href="edit-pages.php">'.sprintf( __ngettext( '%s page', '%s pages', $num_pages->publish ), number_format_i18n( $num_pages->publish ) ).'</a>';
mp-wp_genesis 144 }
mp-wp_genesis 145 if ( $can_edit_posts && !empty($num_posts->draft) ) {
mp-wp_genesis 146 $post_type_texts[] = '<a href="edit.php?post_status=draft">'.sprintf( __ngettext( '%s draft', '%s drafts', $num_posts->draft ), number_format_i18n( $num_posts->draft ) ).'</a>';
mp-wp_genesis 147 }
mp-wp_genesis 148 if ( $can_edit_posts && !empty($num_posts->future) ) {
mp-wp_genesis 149 $post_type_texts[] = '<a href="edit.php?post_status=future">'.sprintf( __ngettext( '%s scheduled post', '%s scheduled posts', $num_posts->future ), number_format_i18n( $num_posts->future ) ).'</a>';
mp-wp_genesis 150 }
mp-wp_genesis 151 if ( current_user_can('publish_posts') && !empty($num_posts->pending) ) {
mp-wp_genesis 152 $pending_text = sprintf( __ngettext( 'There is <a href="%1$s">%2$s post</a> pending your review.', 'There are <a href="%1$s">%2$s posts</a> pending your review.', $num_posts->pending ), 'edit.php?post_status=pending', number_format_i18n( $num_posts->pending ) );
mp-wp_genesis 153 } else {
mp-wp_genesis 154 $pending_text = '';
mp-wp_genesis 155 }
mp-wp_genesis 156 */
mp-wp_genesis 157
mp-wp_genesis 158 // Total Comments
mp-wp_genesis 159 $num = number_format_i18n($num_comm->total_comments);
mp-wp_genesis 160 if ( current_user_can( 'moderate_comments' ) )
mp-wp_genesis 161 $num = "<a href='edit-comments.php'>$num</a>";
mp-wp_genesis 162 echo '<td class="b b-comments">'.$num.'</td>';
mp-wp_genesis 163 echo '<td class="last t comments">' . __ngettext( 'Comment', 'Comments', $num_comm->total_comments ) . '</td>';
mp-wp_genesis 164
mp-wp_genesis 165 echo '</tr><tr>';
mp-wp_genesis 166
mp-wp_genesis 167 // Pages
mp-wp_genesis 168 $num = number_format_i18n( $num_pages->publish );
mp-wp_genesis 169 if ( current_user_can( 'edit_pages' ) )
mp-wp_genesis 170 $num = "<a href='edit-pages.php'>$num</a>";
mp-wp_genesis 171 echo '<td class="first b b_pages">'.$num.'</td>';
mp-wp_genesis 172 echo '<td class="t pages">' . __ngettext( 'Page', 'Pages', $num_pages->publish ) . '</td>';
mp-wp_genesis 173
mp-wp_genesis 174 // Approved Comments
mp-wp_genesis 175 $num = number_format_i18n($num_comm->approved);
mp-wp_genesis 176 if ( current_user_can( 'moderate_comments' ) )
mp-wp_genesis 177 $num = "<a href='edit-comments.php?comment_status=approved'>$num</a>";
mp-wp_genesis 178 echo '<td class="b b_approved">'.$num.'</td>';
mp-wp_genesis 179 echo '<td class="last t approved">' . __ngettext( 'Approved', 'Approved', $num_comm->approved ) . '</td>';
mp-wp_genesis 180
mp-wp_genesis 181 echo "</tr>\n\t<tr>";
mp-wp_genesis 182
mp-wp_genesis 183 // Categories
mp-wp_genesis 184 $num = number_format_i18n( $num_cats );
mp-wp_genesis 185 if ( current_user_can( 'manage_categories' ) )
mp-wp_genesis 186 $num = "<a href='categories.php'>$num</a>";
mp-wp_genesis 187 echo '<td class="first b b-cats">'.$num.'</td>';
mp-wp_genesis 188 echo '<td class="t cats">' . __ngettext( 'Category', 'Categories', $num_cats ) . '</td>';
mp-wp_genesis 189
mp-wp_genesis 190 // Pending Comments
mp-wp_genesis 191 $num = number_format_i18n($num_comm->moderated);
mp-wp_genesis 192 if ( current_user_can( 'moderate_comments' ) )
mp-wp_genesis 193 $num = "<a href='edit-comments.php?comment_status=moderated'><span class='pending-count'>$num</span></a>";
mp-wp_genesis 194 echo '<td class="b b-waiting">'.$num.'</td>';
mp-wp_genesis 195 echo '<td class="last t waiting">' . __ngettext( 'Pending', 'Pending', $num_comm->moderated ) . '</td>';
mp-wp_genesis 196
mp-wp_genesis 197 echo "</tr>\n\t<tr>";
mp-wp_genesis 198
mp-wp_genesis 199 // Tags
mp-wp_genesis 200 $num = number_format_i18n( $num_tags );
mp-wp_genesis 201 if ( current_user_can( 'manage_categories' ) )
mp-wp_genesis 202 $num = "<a href='edit-tags.php'>$num</a>";
mp-wp_genesis 203 echo '<td class="first b b-tags">'.$num.'</td>';
mp-wp_genesis 204 echo '<td class="t tags">' . __ngettext( 'Tag', 'Tags', $num_tags ) . '</td>';
mp-wp_genesis 205
mp-wp_genesis 206 // Spam Comments
mp-wp_genesis 207 $num = number_format_i18n($num_comm->spam);
mp-wp_genesis 208 if ( current_user_can( 'moderate_comments' ) )
mp-wp_genesis 209 $num = "<a href='edit-comments.php?comment_status=spam'><span class='spam-count'>$num</span></a>";
mp-wp_genesis 210 echo '<td class="b b-spam">'.$num.'</td>';
mp-wp_genesis 211 echo '<td class="last t spam">' . __ngettext( 'Spam', 'Spam', $num_comm->spam ) . '</td>';
mp-wp_genesis 212
mp-wp_genesis 213 echo "</tr>";
mp-wp_genesis 214 do_action('right_now_table_end');
mp-wp_genesis 215 echo "\n\t</table>\n\t</div>";
mp-wp_genesis 216
mp-wp_genesis 217 echo "\n\t".'<div class="versions">';
mp-wp_genesis 218 $ct = current_theme_info();
mp-wp_genesis 219 $sidebars_widgets = wp_get_sidebars_widgets();
mp-wp_genesis 220 $num_widgets = array_reduce( $sidebars_widgets, create_function( '$prev, $curr', 'return $prev+count($curr);' ), 0 );
mp-wp_genesis 221 $num = number_format_i18n( $num_widgets );
mp-wp_genesis 222
mp-wp_genesis 223 echo "\n\t<p>";
mp-wp_genesis 224 if ( current_user_can( 'switch_themes' ) ) {
mp-wp_genesis 225 echo '<a href="themes.php" class="button rbutton">' . __('Change Theme') . '</a>';
mp-wp_genesis 226 printf(__ngettext('Theme <span class="b"><a href="themes.php">%1$s</a></span> with <span class="b"><a href="widgets.php">%2$s Widget</a></span>', 'Theme <span class="b"><a href="themes.php">%1$s</a></span> with <span class="b"><a href="widgets.php">%2$s Widgets</a></span>', $num_widgets), $ct->title, $num);
mp-wp_genesis 227 } else {
mp-wp_genesis 228 printf(__ngettext('Theme <span class="b">%1$s</span> with <span class="b">%2$s Widget</span>', 'Theme <span class="b">%1$s</span> with <span class="b">%2$s Widgets</span>', $num_widgets), $ct->title, $num);
mp-wp_genesis 229 }
mp-wp_genesis 230
mp-wp_genesis 231 echo '</p>';
mp-wp_genesis 232 echo "\n\t".'</div>';
mp-wp_genesis 233 do_action( 'rightnow_end' );
mp-wp_genesis 234 do_action( 'activity_box_end' );
mp-wp_genesis 235 }
mp-wp_genesis 236
mp-wp_genesis 237 function wp_dashboard_recent_drafts( $drafts = false ) {
mp-wp_genesis 238 if ( !$drafts ) {
mp-wp_genesis 239 $drafts_query = new WP_Query( array(
mp-wp_genesis 240 'post_type' => 'post',
mp-wp_genesis 241 'what_to_show' => 'posts',
mp-wp_genesis 242 'post_status' => 'draft',
mp-wp_genesis 243 'author' => $GLOBALS['current_user']->ID,
mp-wp_genesis 244 'posts_per_page' => 5,
mp-wp_genesis 245 'orderby' => 'modified',
mp-wp_genesis 246 'order' => 'DESC'
mp-wp_genesis 247 ) );
mp-wp_genesis 248 $drafts =& $drafts_query->posts;
mp-wp_genesis 249 }
mp-wp_genesis 250
mp-wp_genesis 251 if ( $drafts && is_array( $drafts ) ) {
mp-wp_genesis 252 $list = array();
mp-wp_genesis 253 foreach ( $drafts as $draft ) {
mp-wp_genesis 254 $url = get_edit_post_link( $draft->ID );
mp-wp_genesis 255 $title = _draft_or_post_title( $draft->ID );
mp-wp_genesis 256 $item = "<h4><a href='$url' title='" . sprintf( __( 'Edit "%s"' ), attribute_escape( $title ) ) . "'>$title</a> <abbr title='" . get_the_time(__('Y/m/d g:i:s A'), $draft) . "'>" . get_the_time( get_option( 'date_format' ), $draft ) . '</abbr></h4>';
mp-wp_genesis 257 if ( $the_content = preg_split( '#\s#', strip_tags( $draft->post_content ), 11, PREG_SPLIT_NO_EMPTY ) )
mp-wp_genesis 258 $item .= '<p>' . join( ' ', array_slice( $the_content, 0, 10 ) ) . ( 10 < count( $the_content ) ? '&hellip;' : '' ) . '</p>';
mp-wp_genesis 259 $list[] = $item;
mp-wp_genesis 260 }
mp-wp_genesis 261 ?>
mp-wp_genesis 262 <ul>
mp-wp_genesis 263 <li><?php echo join( "</li>\n<li>", $list ); ?></li>
mp-wp_genesis 264 </ul>
mp-wp_genesis 265 <p class="textright"><a href="edit.php?post_status=draft" class="button"><?php _e('View all'); ?></a></p>
mp-wp_genesis 266 <?php
mp-wp_genesis 267 } else {
mp-wp_genesis 268 _e('There are no drafts at the moment');
mp-wp_genesis 269 }
mp-wp_genesis 270 }
mp-wp_genesis 271
mp-wp_genesis 272 /**
mp-wp_genesis 273 * Display recent comments dashboard widget content.
mp-wp_genesis 274 *
mp-wp_genesis 275 * @since unknown
mp-wp_genesis 276 */
mp-wp_genesis 277 function wp_dashboard_recent_comments() {
mp-wp_genesis 278 global $wpdb;
mp-wp_genesis 279
mp-wp_genesis 280 if ( current_user_can('edit_posts') )
mp-wp_genesis 281 $allowed_states = array('0', '1');
mp-wp_genesis 282 else
mp-wp_genesis 283 $allowed_states = array('1');
mp-wp_genesis 284
mp-wp_genesis 285 // Select all comment types and filter out spam later for better query performance.
mp-wp_genesis 286 $comments = array();
mp-wp_genesis 287 $start = 0;
mp-wp_genesis 288
mp-wp_genesis 289 while ( count( $comments ) < 5 && $possible = $wpdb->get_results( "SELECT * FROM $wpdb->comments ORDER BY comment_date_gmt DESC LIMIT $start, 50" ) ) {
mp-wp_genesis 290
mp-wp_genesis 291 foreach ( $possible as $comment ) {
mp-wp_genesis 292 if ( count( $comments ) >= 5 )
mp-wp_genesis 293 break;
mp-wp_genesis 294 if ( in_array( $comment->comment_approved, $allowed_states ) )
mp-wp_genesis 295 $comments[] = $comment;
mp-wp_genesis 296 }
mp-wp_genesis 297
mp-wp_genesis 298 $start = $start + 50;
mp-wp_genesis 299 }
mp-wp_genesis 300
mp-wp_genesis 301 if ( $comments ) :
mp-wp_genesis 302 ?>
mp-wp_genesis 303
mp-wp_genesis 304 <div id="the-comment-list" class="list:comment">
mp-wp_genesis 305 <?php
mp-wp_genesis 306 foreach ( $comments as $comment )
mp-wp_genesis 307 _wp_dashboard_recent_comments_row( $comment );
mp-wp_genesis 308 ?>
mp-wp_genesis 309
mp-wp_genesis 310 </div>
mp-wp_genesis 311
mp-wp_genesis 312 <?php
mp-wp_genesis 313 if ( current_user_can('edit_posts') ) { ?>
mp-wp_genesis 314 <p class="textright"><a href="edit-comments.php" class="button"><?php _e('View all'); ?></a></p>
mp-wp_genesis 315 <?php }
mp-wp_genesis 316
mp-wp_genesis 317 wp_comment_reply( -1, false, 'dashboard', false );
mp-wp_genesis 318
mp-wp_genesis 319 else :
mp-wp_genesis 320 ?>
mp-wp_genesis 321
mp-wp_genesis 322 <p><?php _e( 'No comments yet.' ); ?></p>
mp-wp_genesis 323
mp-wp_genesis 324 <?php
mp-wp_genesis 325 endif; // $comments;
mp-wp_genesis 326 }
mp-wp_genesis 327
mp-wp_genesis 328 function _wp_dashboard_recent_comments_row( &$comment, $show_date = true ) {
mp-wp_genesis 329 $GLOBALS['comment'] =& $comment;
mp-wp_genesis 330
mp-wp_genesis 331 $comment_post_url = get_edit_post_link( $comment->comment_post_ID );
mp-wp_genesis 332 $comment_post_title = get_the_title( $comment->comment_post_ID );
mp-wp_genesis 333 $comment_post_link = "<a href='$comment_post_url'>$comment_post_title</a>";
mp-wp_genesis 334 $comment_link = '<a class="comment-link" href="' . get_comment_link() . '">#</a>';
mp-wp_genesis 335
mp-wp_genesis 336 $delete_url = clean_url( wp_nonce_url( "comment.php?action=deletecomment&p=$comment->comment_post_ID&c=$comment->comment_ID", "delete-comment_$comment->comment_ID" ) );
mp-wp_genesis 337 $approve_url = clean_url( wp_nonce_url( "comment.php?action=approvecomment&p=$comment->comment_post_ID&c=$comment->comment_ID", "approve-comment_$comment->comment_ID" ) );
mp-wp_genesis 338 $unapprove_url = clean_url( wp_nonce_url( "comment.php?action=unapprovecomment&p=$comment->comment_post_ID&c=$comment->comment_ID", "unapprove-comment_$comment->comment_ID" ) );
mp-wp_genesis 339 $spam_url = clean_url( wp_nonce_url( "comment.php?action=deletecomment&dt=spam&p=$comment->comment_post_ID&c=$comment->comment_ID", "delete-comment_$comment->comment_ID" ) );
mp-wp_genesis 340
mp-wp_genesis 341 $actions = array();
mp-wp_genesis 342
mp-wp_genesis 343 $actions_string = '';
mp-wp_genesis 344 if ( current_user_can('edit_post', $comment->comment_post_ID) ) {
mp-wp_genesis 345 $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>';
mp-wp_genesis 346 $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>';
mp-wp_genesis 347 $actions['edit'] = "<a href='comment.php?action=editcomment&amp;c={$comment->comment_ID}' title='" . __('Edit comment') . "'>". __('Edit') . '</a>';
mp-wp_genesis 348 $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>';
mp-wp_genesis 349 $actions['delete'] = "<a href='$delete_url' class='delete:the-comment-list:comment-$comment->comment_ID delete vim-d vim-destructive'>" . __('Delete') . '</a>';
mp-wp_genesis 350
mp-wp_genesis 351 $actions = apply_filters( 'comment_row_actions', $actions, $comment );
mp-wp_genesis 352
mp-wp_genesis 353 $i = 0;
mp-wp_genesis 354 foreach ( $actions as $action => $link ) {
mp-wp_genesis 355 ++$i;
mp-wp_genesis 356 ( ( ('approve' == $action || 'unapprove' == $action) && 2 === $i ) || 1 === $i ) ? $sep = '' : $sep = ' | ';
mp-wp_genesis 357
mp-wp_genesis 358 $actions_string .= "<span class='$action'>$sep$link</span>";
mp-wp_genesis 359 }
mp-wp_genesis 360 }
mp-wp_genesis 361
mp-wp_genesis 362 ?>
mp-wp_genesis 363
mp-wp_genesis 364 <div id="comment-<?php echo $comment->comment_ID; ?>" <?php comment_class( array( 'comment-item', wp_get_comment_status($comment->comment_ID) ) ); ?>>
mp-wp_genesis 365 <?php if ( !$comment->comment_type || 'comment' == $comment->comment_type ) : ?>
mp-wp_genesis 366
mp-wp_genesis 367 <?php echo get_avatar( $comment, 50 ); ?>
mp-wp_genesis 368 <h4 class="comment-meta"><?php printf( __( 'From %1$s on %2$s%3$s' ), '<cite class="comment-author">' . get_comment_author_link() . '</cite>', $comment_post_link." ".$comment_link, ' <span class="approve">' . __( '[Pending]' ) . '</span>' ); ?></h4>
mp-wp_genesis 369
mp-wp_genesis 370 <?php
mp-wp_genesis 371 else :
mp-wp_genesis 372 switch ( $comment->comment_type ) :
mp-wp_genesis 373 case 'pingback' :
mp-wp_genesis 374 $type = __( 'Pingback' );
mp-wp_genesis 375 break;
mp-wp_genesis 376 case 'trackback' :
mp-wp_genesis 377 $type = __( 'Trackback' );
mp-wp_genesis 378 break;
mp-wp_genesis 379 default :
mp-wp_genesis 380 $type = ucwords( $comment->comment_type );
mp-wp_genesis 381 endswitch;
mp-wp_genesis 382 $type = wp_specialchars( $type );
mp-wp_genesis 383 ?>
mp-wp_genesis 384
mp-wp_genesis 385 <h4 class="comment-meta"><?php printf( __( '%1$s on %2$s' ), "<strong>$type</strong>", $comment_post_link ); ?></h4>
mp-wp_genesis 386 <p class="comment-author"><?php comment_author_link(); ?></p>
mp-wp_genesis 387
mp-wp_genesis 388 <?php endif; // comment_type ?>
mp-wp_genesis 389 <blockquote><p><?php comment_excerpt(); ?></p></blockquote>
mp-wp_genesis 390 <p class="row-actions"><?php echo $actions_string; ?></p>
mp-wp_genesis 391
mp-wp_genesis 392 <div id="inline-<?php echo $comment->comment_ID; ?>" class="hidden">
mp-wp_genesis 393 <textarea class="comment" rows="3" cols="10"><?php echo $comment->comment_content; ?></textarea>
mp-wp_genesis 394 <div class="author-email"><?php echo attribute_escape( $comment->comment_author_email ); ?></div>
mp-wp_genesis 395 <div class="author"><?php echo attribute_escape( $comment->comment_author ); ?></div>
mp-wp_genesis 396 <div class="author-url"><?php echo attribute_escape( $comment->comment_author_url ); ?></div>
mp-wp_genesis 397 <div class="comment_status"><?php echo $comment->comment_approved; ?></div>
mp-wp_genesis 398 </div>
mp-wp_genesis 399
mp-wp_genesis 400 </div>
mp-wp_genesis 401 <?php
mp-wp_genesis 402 }
mp-wp_genesis 403
mp-wp_genesis 404 function wp_dashboard_incoming_links() {
mp-wp_genesis 405 wp_dashboard_cached_rss_widget( 'dashboard_incoming_links', 'wp_dashboard_incoming_links_output' );
mp-wp_genesis 406 }
mp-wp_genesis 407
mp-wp_genesis 408 /**
mp-wp_genesis 409 * Display incoming links dashboard widget content.
mp-wp_genesis 410 *
mp-wp_genesis 411 * @since unknown
mp-wp_genesis 412 */
mp-wp_genesis 413 function wp_dashboard_incoming_links_output() {
mp-wp_genesis 414 $widgets = get_option( 'dashboard_widget_options' );
mp-wp_genesis 415 @extract( @$widgets['dashboard_incoming_links'], EXTR_SKIP );
mp-wp_genesis 416 $rss = @fetch_rss( $url );
mp-wp_genesis 417 if ( isset($rss->items) && 0 < count($rss->items) ) {
mp-wp_genesis 418
mp-wp_genesis 419 echo "<ul>\n";
mp-wp_genesis 420
mp-wp_genesis 421 $rss->items = array_slice($rss->items, 0, $items);
mp-wp_genesis 422 foreach ( $rss->items as $item ) {
mp-wp_genesis 423 $publisher = '';
mp-wp_genesis 424 $site_link = '';
mp-wp_genesis 425 $link = '';
mp-wp_genesis 426 $content = '';
mp-wp_genesis 427 $date = '';
mp-wp_genesis 428 $link = clean_url( strip_tags( $item['link'] ) );
mp-wp_genesis 429
mp-wp_genesis 430 if ( isset( $item['author_uri'] ) )
mp-wp_genesis 431 $site_link = clean_url( strip_tags( $item['author_uri'] ) );
mp-wp_genesis 432
mp-wp_genesis 433 if ( !$publisher = wp_specialchars( strip_tags( isset($item['dc']['publisher']) ? $item['dc']['publisher'] : $item['author_name'] ) ) )
mp-wp_genesis 434 $publisher = __( 'Somebody' );
mp-wp_genesis 435 if ( $site_link )
mp-wp_genesis 436 $publisher = "<a href='$site_link'>$publisher</a>";
mp-wp_genesis 437 else
mp-wp_genesis 438 $publisher = "<strong>$publisher</strong>";
mp-wp_genesis 439
mp-wp_genesis 440 if ( isset($item['description']) )
mp-wp_genesis 441 $content = $item['description'];
mp-wp_genesis 442 elseif ( isset($item['summary']) )
mp-wp_genesis 443 $content = $item['summary'];
mp-wp_genesis 444 elseif ( isset($item['atom_content']) )
mp-wp_genesis 445 $content = $item['atom_content'];
mp-wp_genesis 446 else
mp-wp_genesis 447 $content = __( 'something' );
mp-wp_genesis 448 $content = wp_html_excerpt($content, 50) . ' ...';
mp-wp_genesis 449 if ( $link )
mp-wp_genesis 450 $text = _c( '%1$s linked here <a href="%2$s">saying</a>, "%3$s"|feed_display' );
mp-wp_genesis 451 else
mp-wp_genesis 452 $text = _c( '%1$s linked here saying, "%3$s"|feed_display' );
mp-wp_genesis 453
mp-wp_genesis 454 if ( $show_date ) {
mp-wp_genesis 455 if ( $show_author || $show_summary )
mp-wp_genesis 456 $text .= _c( ' on %4$s|feed_display' );
mp-wp_genesis 457 $date = wp_specialchars( strip_tags( isset($item['pubdate']) ? $item['pubdate'] : $item['published'] ) );
mp-wp_genesis 458 $date = strtotime( $date );
mp-wp_genesis 459 $date = gmdate( get_option( 'date_format' ), $date );
mp-wp_genesis 460 }
mp-wp_genesis 461
mp-wp_genesis 462 echo "\t<li>" . sprintf( _c( "$text|feed_display" ), $publisher, $link, $content, $date ) . "</li>\n";
mp-wp_genesis 463 }
mp-wp_genesis 464
mp-wp_genesis 465 echo "</ul>\n";
mp-wp_genesis 466
mp-wp_genesis 467 } else {
mp-wp_genesis 468 echo '<p>' . __('This dashboard widget queries <a href="http://blogsearch.google.com/">Google Blog Search</a> so that when another blog links to your site it will show up here. It has found no incoming links&hellip; yet. It&#8217;s okay &#8212; there is no rush.') . "</p>\n";
mp-wp_genesis 469 }
mp-wp_genesis 470 }
mp-wp_genesis 471
mp-wp_genesis 472 function wp_dashboard_incoming_links_control() {
mp-wp_genesis 473 wp_dashboard_rss_control( 'dashboard_incoming_links', array( 'title' => false, 'show_summary' => false, 'show_author' => false ) );
mp-wp_genesis 474 }
mp-wp_genesis 475
mp-wp_genesis 476 function wp_dashboard_primary() {
mp-wp_genesis 477 wp_dashboard_cached_rss_widget( 'dashboard_primary', 'wp_dashboard_rss_output' );
mp-wp_genesis 478 }
mp-wp_genesis 479
mp-wp_genesis 480 function wp_dashboard_primary_control() {
mp-wp_genesis 481 wp_dashboard_rss_control( 'dashboard_primary' );
mp-wp_genesis 482 }
mp-wp_genesis 483
mp-wp_genesis 484 /**
mp-wp_genesis 485 * {@internal Missing Short Description}}
mp-wp_genesis 486 *
mp-wp_genesis 487 * @since unknown
mp-wp_genesis 488 *
mp-wp_genesis 489 * @param int $widget_id
mp-wp_genesis 490 */
mp-wp_genesis 491 function wp_dashboard_rss_output( $widget_id ) {
mp-wp_genesis 492 $widgets = get_option( 'dashboard_widget_options' );
mp-wp_genesis 493 echo "<div class='rss-widget'>";
mp-wp_genesis 494 wp_widget_rss_output( $widgets[$widget_id] );
mp-wp_genesis 495 echo "</div>";
mp-wp_genesis 496 }
mp-wp_genesis 497
mp-wp_genesis 498 function wp_dashboard_secondary() {
mp-wp_genesis 499 wp_dashboard_cached_rss_widget( 'dashboard_secondary', 'wp_dashboard_secondary_output' );
mp-wp_genesis 500 }
mp-wp_genesis 501
mp-wp_genesis 502 function wp_dashboard_secondary_control() {
mp-wp_genesis 503 wp_dashboard_rss_control( 'dashboard_secondary' );
mp-wp_genesis 504 }
mp-wp_genesis 505
mp-wp_genesis 506 /**
mp-wp_genesis 507 * Display secondary dashboard RSS widget feed.
mp-wp_genesis 508 *
mp-wp_genesis 509 * @since unknown
mp-wp_genesis 510 *
mp-wp_genesis 511 * @return unknown
mp-wp_genesis 512 */
mp-wp_genesis 513 function wp_dashboard_secondary_output() {
mp-wp_genesis 514 $widgets = get_option( 'dashboard_widget_options' );
mp-wp_genesis 515 @extract( @$widgets['dashboard_secondary'], EXTR_SKIP );
mp-wp_genesis 516 $rss = @fetch_rss( $url );
mp-wp_genesis 517
mp-wp_genesis 518 if ( !isset($rss->items) || 0 == count($rss->items) )
mp-wp_genesis 519 return false;
mp-wp_genesis 520
mp-wp_genesis 521 $rss->items = array_slice($rss->items, 0, $items);
mp-wp_genesis 522
mp-wp_genesis 523 if ( 'http://planet.wordpress.org/' == $rss->channel['link'] ) {
mp-wp_genesis 524 foreach ( array_keys($rss->items) as $i ) {
mp-wp_genesis 525 list($site, $description) = explode( ':', wp_specialchars($rss->items[$i]['title']), 2 );
mp-wp_genesis 526 $rss->items[$i]['dc']['creator'] = trim($site);
mp-wp_genesis 527 $rss->items[$i]['title'] = trim($description);
mp-wp_genesis 528 }
mp-wp_genesis 529 }
mp-wp_genesis 530
mp-wp_genesis 531 echo "<div class='rss-widget'>";
mp-wp_genesis 532 wp_widget_rss_output( $rss, $widgets['dashboard_secondary'] );
mp-wp_genesis 533 echo "</div>";
mp-wp_genesis 534 }
mp-wp_genesis 535
mp-wp_genesis 536 /**
mp-wp_genesis 537 * Checks to see if all of the feed url in $check_urls are cached.
mp-wp_genesis 538 *
mp-wp_genesis 539 * If $check_urls is empty, look for the rss feed url found in the dashboard
mp-wp_genesis 540 * widget optios of $widget_id. If cached, call $callback, a function that
mp-wp_genesis 541 * echoes out output for this widget. If not cache, echo a "Loading..." stub
mp-wp_genesis 542 * which is later replaced by AJAX call (see top of /wp-admin/index.php)
mp-wp_genesis 543 *
mp-wp_genesis 544 * @since unknown
mp-wp_genesis 545 *
mp-wp_genesis 546 * @param int $widget_id
mp-wp_genesis 547 * @param callback $callback
mp-wp_genesis 548 * @param array $check_urls RSS feeds
mp-wp_genesis 549 * @return bool False on failure. True on success.
mp-wp_genesis 550 */
mp-wp_genesis 551 function wp_dashboard_cached_rss_widget( $widget_id, $callback, $check_urls = array() ) {
mp-wp_genesis 552 $loading = '<p class="widget-loading">' . __( 'Loading&#8230;' ) . '</p>';
mp-wp_genesis 553
mp-wp_genesis 554 if ( empty($check_urls) ) {
mp-wp_genesis 555 $widgets = get_option( 'dashboard_widget_options' );
mp-wp_genesis 556 if ( empty($widgets[$widget_id]['url']) ) {
mp-wp_genesis 557 echo $loading;
mp-wp_genesis 558 return false;
mp-wp_genesis 559 }
mp-wp_genesis 560 $check_urls = array( $widgets[$widget_id]['url'] );
mp-wp_genesis 561 }
mp-wp_genesis 562
mp-wp_genesis 563
mp-wp_genesis 564 require_once( ABSPATH . WPINC . '/rss.php' );
mp-wp_genesis 565 init(); // initialize rss constants
mp-wp_genesis 566
mp-wp_genesis 567 $cache = new RSSCache( MAGPIE_CACHE_DIR, MAGPIE_CACHE_AGE );
mp-wp_genesis 568
mp-wp_genesis 569 foreach ( $check_urls as $check_url ) {
mp-wp_genesis 570 $status = $cache->check_cache( $check_url );
mp-wp_genesis 571 if ( 'HIT' !== $status ) {
mp-wp_genesis 572 echo $loading;
mp-wp_genesis 573 return false;
mp-wp_genesis 574 }
mp-wp_genesis 575 }
mp-wp_genesis 576
mp-wp_genesis 577 if ( $callback && is_callable( $callback ) ) {
mp-wp_genesis 578 $args = array_slice( func_get_args(), 2 );
mp-wp_genesis 579 array_unshift( $args, $widget_id );
mp-wp_genesis 580 call_user_func_array( $callback, $args );
mp-wp_genesis 581 }
mp-wp_genesis 582
mp-wp_genesis 583 return true;
mp-wp_genesis 584 }
mp-wp_genesis 585
mp-wp_genesis 586 /* Dashboard Widgets Controls */
mp-wp_genesis 587
mp-wp_genesis 588 // Calls widget_control callback
mp-wp_genesis 589 /**
mp-wp_genesis 590 * Calls widget control callback.
mp-wp_genesis 591 *
mp-wp_genesis 592 * @since unknown
mp-wp_genesis 593 *
mp-wp_genesis 594 * @param int $widget_control_id Registered Widget ID.
mp-wp_genesis 595 */
mp-wp_genesis 596 function wp_dashboard_trigger_widget_control( $widget_control_id = false ) {
mp-wp_genesis 597 global $wp_dashboard_control_callbacks;
mp-wp_genesis 598
mp-wp_genesis 599 if ( is_scalar($widget_control_id) && $widget_control_id && isset($wp_dashboard_control_callbacks[$widget_control_id]) && is_callable($wp_dashboard_control_callbacks[$widget_control_id]) ) {
mp-wp_genesis 600 call_user_func( $wp_dashboard_control_callbacks[$widget_control_id], '', array( 'id' => $widget_control_id, 'callback' => $wp_dashboard_control_callbacks[$widget_control_id] ) );
mp-wp_genesis 601 }
mp-wp_genesis 602 }
mp-wp_genesis 603
mp-wp_genesis 604 /**
mp-wp_genesis 605 * The RSS dashboard widget control.
mp-wp_genesis 606 *
mp-wp_genesis 607 * Sets up $args to be used as input to wp_widget_rss_form(). Handles POST data
mp-wp_genesis 608 * from RSS-type widgets.
mp-wp_genesis 609 *
mp-wp_genesis 610 * @since unknown
mp-wp_genesis 611 *
mp-wp_genesis 612 * @param string widget_id
mp-wp_genesis 613 * @param array form_inputs
mp-wp_genesis 614 */
mp-wp_genesis 615 function wp_dashboard_rss_control( $widget_id, $form_inputs = array() ) {
mp-wp_genesis 616 if ( !$widget_options = get_option( 'dashboard_widget_options' ) )
mp-wp_genesis 617 $widget_options = array();
mp-wp_genesis 618
mp-wp_genesis 619 if ( !isset($widget_options[$widget_id]) )
mp-wp_genesis 620 $widget_options[$widget_id] = array();
mp-wp_genesis 621
mp-wp_genesis 622 $number = 1; // Hack to use wp_widget_rss_form()
mp-wp_genesis 623 $widget_options[$widget_id]['number'] = $number;
mp-wp_genesis 624
mp-wp_genesis 625 if ( 'POST' == $_SERVER['REQUEST_METHOD'] && isset($_POST['widget-rss'][$number]) ) {
mp-wp_genesis 626 $_POST['widget-rss'][$number] = stripslashes_deep( $_POST['widget-rss'][$number] );
mp-wp_genesis 627 $widget_options[$widget_id] = wp_widget_rss_process( $_POST['widget-rss'][$number] );
mp-wp_genesis 628 // title is optional. If black, fill it if possible
mp-wp_genesis 629 if ( !$widget_options[$widget_id]['title'] && isset($_POST['widget-rss'][$number]['title']) ) {
mp-wp_genesis 630 require_once(ABSPATH . WPINC . '/rss.php');
mp-wp_genesis 631 $rss = fetch_rss($widget_options[$widget_id]['url']);
mp-wp_genesis 632 $widget_options[$widget_id]['title'] = htmlentities(strip_tags($rss->channel['title']));
mp-wp_genesis 633 }
mp-wp_genesis 634 update_option( 'dashboard_widget_options', $widget_options );
mp-wp_genesis 635 }
mp-wp_genesis 636
mp-wp_genesis 637 wp_widget_rss_form( $widget_options[$widget_id], $form_inputs );
mp-wp_genesis 638 }
mp-wp_genesis 639
mp-wp_genesis 640 /**
mp-wp_genesis 641 * Empty function usable by plugins to output empty dashboard widget (to be populated later by JS).
mp-wp_genesis 642 */
mp-wp_genesis 643 function wp_dashboard_empty() {}
mp-wp_genesis 644
mp-wp_genesis 645 ?>