wp_dashboard_rss_control

Definition:
function wp_dashboard_rss_control( $widget_id, $form_inputs = array() {}

The RSS dashboard widget control.
Sets up $args to be used as input to wp_widget_rss_form(). Handles POST data from RSS-type widgets.

Parameters

  • string $widget_id
  • array $form_inputs

Source code

function wp_dashboard_rss_control( $widget_id, $form_inputs = array() ) {

	if ( !$widget_options = get_option( 'dashboard_widget_options' ) )

		$widget_options = array();



	if ( !isset($widget_options[$widget_id]) )

		$widget_options[$widget_id] = array();



	$number = 1; // Hack to use wp_widget_rss_form()

	$widget_options[$widget_id]['number'] = $number;



	if ( 'POST' == $_SERVER['REQUEST_METHOD'] && isset($_POST['widget-rss'][$number]) ) {

		$_POST['widget-rss'][$number] = stripslashes_deep( $_POST['widget-rss'][$number] );

		$widget_options[$widget_id] = wp_widget_rss_process( $_POST['widget-rss'][$number] );

		// title is optional.  If black, fill it if possible

		if ( !$widget_options[$widget_id]['title'] && isset($_POST['widget-rss'][$number]['title']) ) {

			$rss = fetch_feed($widget_options[$widget_id]['url']);

			if ( is_wp_error($rss) ) {

				$widget_options[$widget_id]['title'] = htmlentities(__('Unknown Feed'));

			} else {

				$widget_options[$widget_id]['title'] = htmlentities(strip_tags($rss->get_title()));

				$rss->__destruct();

				unset($rss);

			}

		}

		update_option( 'dashboard_widget_options', $widget_options );

		$cache_key = 'dash_' . md5( $widget_id );

		delete_transient( $cache_key );

	}



	wp_widget_rss_form( $widget_options[$widget_id], $form_inputs );

}

3559

wp_dashboard_right_now

Definition:
function wp_dashboard_right_now() {}

Defined filters

  • privacy_on_link_title
    apply_filters('privacy_on_link_title', __('Your site is asking search engines not to index its content')
  • privacy_on_link_text
    apply_filters('privacy_on_link_text', __('Search Engines Blocked')

Defined actions

  • right_now_content_table_end
    do_action('right_now_content_table_end');
  • right_now_table_end
    do_action('right_now_table_end');
  • right_now_discussion_table_end
    do_action('right_now_discussion_table_end');
  • rightnow_end
    do_action( 'rightnow_end' );
  • activity_box_end
    do_action( 'activity_box_end' );

Source code

function wp_dashboard_right_now() {

	global $wp_registered_sidebars;



	$num_posts = wp_count_posts( 'post' );

	$num_pages = wp_count_posts( 'page' );



	$num_cats  = wp_count_terms('category');



	$num_tags = wp_count_terms('post_tag');



	$num_comm = wp_count_comments( );



	echo "\n\t".'<div class="table table_content">';

	echo "\n\t".'<p class="sub">' . __('Content') . '</p>'."\n\t".'<table>';

	echo "\n\t".'<tr class="first">';



	// Posts

	$num = number_format_i18n( $num_posts->publish );

	$text = _n( 'Post', 'Posts', intval($num_posts->publish) );

	if ( current_user_can( 'edit_posts' ) ) {

		$num = "<a href='edit.php'>$num</a>";

		$text = "<a href='edit.php'>$text</a>";

	}

	echo '<td class="first b b-posts">' . $num . '</td>';

	echo '<td class="t posts">' . $text . '</td>';



	echo '</tr><tr>';

	/* TODO: Show status breakdown on hover

	if ( $can_edit_pages && !empty($num_pages->publish) ) { // how many pages is not exposed in feeds.  Don't show if !current_user_can

		$post_type_texts[] = '<a href="edit-pages.php">'.sprintf( _n( '%s page', '%s pages', $num_pages->publish ), number_format_i18n( $num_pages->publish ) ).'</a>';

	}

	if ( $can_edit_posts && !empty($num_posts->draft) ) {

		$post_type_texts[] = '<a href="edit.php?post_status=draft">'.sprintf( _n( '%s draft', '%s drafts', $num_posts->draft ), number_format_i18n( $num_posts->draft ) ).'</a>';

	}

	if ( $can_edit_posts && !empty($num_posts->future) ) {

		$post_type_texts[] = '<a href="edit.php?post_status=future">'.sprintf( _n( '%s scheduled post', '%s scheduled posts', $num_posts->future ), number_format_i18n( $num_posts->future ) ).'</a>';

	}

	if ( current_user_can('publish_posts') && !empty($num_posts->pending) ) {

		$pending_text = sprintf( _n( '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 ) );

	} else {

		$pending_text = '';

	}

	*/



	// Pages

	$num = number_format_i18n( $num_pages->publish );

	$text = _n( 'Page', 'Pages', $num_pages->publish );

	if ( current_user_can( 'edit_pages' ) ) {

		$num = "<a href='edit.php?post_type=page'>$num</a>";

		$text = "<a href='edit.php?post_type=page'>$text</a>";

	}

	echo '<td class="first b b_pages">' . $num . '</td>';

	echo '<td class="t pages">' . $text . '</td>';



	echo '</tr><tr>';



	// Categories

	$num = number_format_i18n( $num_cats );

	$text = _n( 'Category', 'Categories', $num_cats );

	if ( current_user_can( 'manage_categories' ) ) {

		$num = "<a href='edit-tags.php?taxonomy=category'>$num</a>";

		$text = "<a href='edit-tags.php?taxonomy=category'>$text</a>";

	}

	echo '<td class="first b b-cats">' . $num . '</td>';

	echo '<td class="t cats">' . $text . '</td>';



	echo '</tr><tr>';



	// Tags

	$num = number_format_i18n( $num_tags );

	$text = _n( 'Tag', 'Tags', $num_tags );

	if ( current_user_can( 'manage_categories' ) ) {

		$num = "<a href='edit-tags.php'>$num</a>";

		$text = "<a href='edit-tags.php'>$text</a>";

	}

	echo '<td class="first b b-tags">' . $num . '</td>';

	echo '<td class="t tags">' . $text . '</td>';



	echo "</tr>";

	do_action('right_now_content_table_end');

	echo "\n\t</table>\n\t</div>";





	echo "\n\t".'<div class="table table_discussion">';

	echo "\n\t".'<p class="sub">' . __('Discussion') . '</p>'."\n\t".'<table>';

	echo "\n\t".'<tr class="first">';



	// Total Comments

	$num = '<span class="total-count">' . number_format_i18n($num_comm->total_comments) . '</span>';

	$text = _n( 'Comment', 'Comments', $num_comm->total_comments );

	if ( current_user_can( 'moderate_comments' ) ) {

		$num = '<a href="edit-comments.php">' . $num . '</a>';

		$text = '<a href="edit-comments.php">' . $text . '</a>';

	}

	echo '<td class="b b-comments">' . $num . '</td>';

	echo '<td class="last t comments">' . $text . '</td>';



	echo '</tr><tr>';



	// Approved Comments

	$num = '<span class="approved-count">' . number_format_i18n($num_comm->approved) . '</span>';

	$text = _nx( 'Approved', 'Approved', $num_comm->approved, 'Right Now' );

	if ( current_user_can( 'moderate_comments' ) ) {

		$num = "<a href='edit-comments.php?comment_status=approved'>$num</a>";

		$text = "<a class='approved' href='edit-comments.php?comment_status=approved'>$text</a>";

	}

	echo '<td class="b b_approved">' . $num . '</td>';

	echo '<td class="last t">' . $text . '</td>';



	echo "</tr>\n\t<tr>";



	// Pending Comments

	$num = '<span class="pending-count">' . number_format_i18n($num_comm->moderated) . '</span>';

	$text = _n( 'Pending', 'Pending', $num_comm->moderated );

	if ( current_user_can( 'moderate_comments' ) ) {

		$num = "<a href='edit-comments.php?comment_status=moderated'>$num</a>";

		$text = "<a class='waiting' href='edit-comments.php?comment_status=moderated'>$text</a>";

	}

	echo '<td class="b b-waiting">' . $num . '</td>';

	echo '<td class="last t">' . $text . '</td>';



	echo "</tr>\n\t<tr>";



	// Spam Comments

	$num = number_format_i18n($num_comm->spam);

	$text = _nx( 'Spam', 'Spam', $num_comm->spam, 'comment' );

	if ( current_user_can( 'moderate_comments' ) ) {

		$num = "<a href='edit-comments.php?comment_status=spam'><span class='spam-count'>$num</span></a>";

		$text = "<a class='spam' href='edit-comments.php?comment_status=spam'>$text</a>";

	}

	echo '<td class="b b-spam">' . $num . '</td>';

	echo '<td class="last t">' . $text . '</td>';



	echo "</tr>";

	do_action('right_now_table_end');

	do_action('right_now_discussion_table_end');

	echo "\n\t</table>\n\t</div>";



	echo "\n\t".'<div class="versions">';

	$ct = current_theme_info();



	echo "\n\t<p>";

	if ( !empty($wp_registered_sidebars) ) {

		$sidebars_widgets = wp_get_sidebars_widgets();

		$num_widgets = 0;

		foreach ( (array) $sidebars_widgets as $k => $v ) {

			if ( 'wp_inactive_widgets' == $k )

				continue;

			if ( is_array($v) )

				$num_widgets = $num_widgets + count($v);

		}

		$num = number_format_i18n( $num_widgets );



		$switch_themes = $ct->title;

		if ( current_user_can( 'switch_themes') )

			$switch_themes = '<a href="themes.php">' . $switch_themes . '</a>';

		if ( current_user_can( 'edit_theme_options' ) ) {

			printf(_n('Theme <span class="b">%1$s</span> with <span class="b"><a href="widgets.php">%2$s Widget</a></span>', 'Theme <span class="b">%1$s</span> with <span class="b"><a href="widgets.php">%2$s Widgets</a></span>', $num_widgets), $switch_themes, $num);

		} else {

			printf(_n('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), $switch_themes, $num);

		}

	} else {

		if ( current_user_can( 'switch_themes' ) )

			printf( __('Theme <span class="b"><a href="themes.php">%1$s</a></span>'), $ct->title );

		else

			printf( __('Theme <span class="b">%1$s</span>'), $ct->title );

	}

	echo '</p>';



	// Check if search engines are blocked.

	if ( !is_network_admin() && !is_user_admin() && current_user_can('manage_options') && '1' != get_option('blog_public') ) {

		$title = apply_filters('privacy_on_link_title', __('Your site is asking search engines not to index its content') );

		$content = apply_filters('privacy_on_link_text', __('Search Engines Blocked') );



		echo "<p><a href='options-privacy.php' title='$title'>$content</a></p>";

	}



	update_right_now_message();



	echo "\n\t".'<br class="clear" /></div>';

	do_action( 'rightnow_end' );

	do_action( 'activity_box_end' );

}

3557

wp_dashboard_recent_drafts

Definition:
function wp_dashboard_recent_drafts( $drafts = false ) {}

Parameters

  • $drafts

Source code

function wp_dashboard_recent_drafts( $drafts = false ) {

	if ( !$drafts ) {

		$drafts_query = new WP_Query( array(

			'post_type' => 'post',

			'post_status' => 'draft',

			'author' => $GLOBALS['current_user']->ID,

			'posts_per_page' => 5,

			'orderby' => 'modified',

			'order' => 'DESC'

		) );

		$drafts =& $drafts_query->posts;

	}



	if ( $drafts && is_array( $drafts ) ) {

		$list = array();

		foreach ( $drafts as $draft ) {

			$url = get_edit_post_link( $draft->ID );

			$title = _draft_or_post_title( $draft->ID );

			$item = "<h4><a href='$url' title='" . sprintf( __( 'Edit “%s”' ), esc_attr( $title ) ) . "'>" . esc_html($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>';

			if ( $the_content = preg_split( '#\s#', strip_tags( $draft->post_content ), 11, PREG_SPLIT_NO_EMPTY ) )

				$item .= '<p>' . join( ' ', array_slice( $the_content, 0, 10 ) ) . ( 10 < count( $the_content ) ? '&hellip;' : '' ) . '</p>';

			$list[] = $item;

		}

?>

	<ul>

		<li><?php echo join( "</li>\n<li>", $list ); ?></li>

	</ul>

	<p class="textright"><a href="edit.php?post_status=draft" ><?php _e('View all'); ?></a></p>

<?php

	} else {

		_e('There are no drafts at the moment');

	}

}

3555

wp_dashboard_recent_comments_control

Definition:
function wp_dashboard_recent_comments_control() {}

The recent comments dashboard widget control.

Source code

function wp_dashboard_recent_comments_control() {

	if ( !$widget_options = get_option( 'dashboard_widget_options' ) )

		$widget_options = array();



	if ( !isset($widget_options['dashboard_recent_comments']) )

		$widget_options['dashboard_recent_comments'] = array();



	if ( 'POST' == $_SERVER['REQUEST_METHOD'] && isset($_POST['widget-recent-comments']) ) {

		$number = absint( $_POST['widget-recent-comments']['items'] );

		$widget_options['dashboard_recent_comments']['items'] = $number;

		update_option( 'dashboard_widget_options', $widget_options );

	}



	$number = isset( $widget_options['dashboard_recent_comments']['items'] ) ? (int) $widget_options['dashboard_recent_comments']['items'] : '';



	echo '<p><label for="comments-number">' . __('Number of comments to show:') . '</label>';

	echo '<input id="comments-number" name="widget-recent-comments[items]" type="text" value="' . $number . '" size="3" /></p>';

}

3553

wp_dashboard_recent_comments

Definition:
function wp_dashboard_recent_comments() {}

Display recent comments dashboard widget content.

Source code

function wp_dashboard_recent_comments() {

	global $wpdb;



	if ( current_user_can('edit_posts') )

		$allowed_states = array('0', '1');

	else

		$allowed_states = array('1');



	// Select all comment types and filter out spam later for better query performance.

	$comments = array();

	$start = 0;



	$widgets = get_option( 'dashboard_widget_options' );

	$total_items = isset( $widgets['dashboard_recent_comments'] ) && isset( $widgets['dashboard_recent_comments']['items'] )

		? absint( $widgets['dashboard_recent_comments']['items'] ) : 5;



	while ( count( $comments ) < $total_items && $possible = $wpdb->get_results( "SELECT * FROM $wpdb->comments c LEFT JOIN $wpdb->posts p ON c.comment_post_ID = p.ID WHERE p.post_status != 'trash' ORDER BY c.comment_date_gmt DESC LIMIT $start, 50" ) ) {



		foreach ( $possible as $comment ) {

			if ( count( $comments ) >= $total_items )

				break;

			if ( in_array( $comment->comment_approved, $allowed_states ) && current_user_can( 'read_post', $comment->comment_post_ID ) )

				$comments[] = $comment;

		}



		$start = $start + 50;

	}



	if ( $comments ) :

?>



		<div id="the-comment-list" class="list:comment">

<?php

		foreach ( $comments as $comment )

			_wp_dashboard_recent_comments_row( $comment );

?>



		</div>



<?php

		if ( current_user_can('edit_posts') ) { ?>

			<?php _get_list_table('WP_Comments_List_Table')->views(); ?>

<?php	}



		wp_comment_reply( -1, false, 'dashboard', false );

		wp_comment_trashnotice();



	else :

?>



	<p><?php _e( 'No comments yet.' ); ?></p>



<?php

	endif; // $comments;

}

3551