web/wp-admin/includes/dashboard.php
changeset 204 09a1c134465b
parent 194 32102edaa81b
equal deleted inserted replaced
203:f507feede89a 204:09a1c134465b
   129 		$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>';
   129 		$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>';
   130 		wp_add_dashboard_widget( $widget_id, $name, $wp_registered_widgets[$widget_id]['callback'], $wp_registered_widget_controls[$widget_id]['callback'] );
   130 		wp_add_dashboard_widget( $widget_id, $name, $wp_registered_widgets[$widget_id]['callback'], $wp_registered_widget_controls[$widget_id]['callback'] );
   131 	}
   131 	}
   132 
   132 
   133 	if ( 'POST' == $_SERVER['REQUEST_METHOD'] && isset($_POST['widget_id']) ) {
   133 	if ( 'POST' == $_SERVER['REQUEST_METHOD'] && isset($_POST['widget_id']) ) {
       
   134 		check_admin_referer( 'edit-dashboard-widget_' . $_POST['widget_id'], 'dashboard-widget-nonce' );
   134 		ob_start(); // hack - but the same hack wp-admin/widgets.php uses
   135 		ob_start(); // hack - but the same hack wp-admin/widgets.php uses
   135 		wp_dashboard_trigger_widget_control( $_POST['widget_id'] );
   136 		wp_dashboard_trigger_widget_control( $_POST['widget_id'] );
   136 		ob_end_clean();
   137 		ob_end_clean();
   137 		wp_redirect( remove_query_arg( 'edit' ) );
   138 		wp_redirect( remove_query_arg( 'edit' ) );
   138 		exit;
   139 		exit;
   180 }
   181 }
   181 
   182 
   182 function _wp_dashboard_control_callback( $dashboard, $meta_box ) {
   183 function _wp_dashboard_control_callback( $dashboard, $meta_box ) {
   183 	echo '<form action="" method="post" class="dashboard-widget-control-form">';
   184 	echo '<form action="" method="post" class="dashboard-widget-control-form">';
   184 	wp_dashboard_trigger_widget_control( $meta_box['id'] );
   185 	wp_dashboard_trigger_widget_control( $meta_box['id'] );
       
   186 	wp_nonce_field( 'edit-dashboard-widget_' . $meta_box['id'], 'dashboard-widget-nonce' );
   185 	echo '<input type="hidden" name="widget_id" value="' . esc_attr($meta_box['id']) . '" />';
   187 	echo '<input type="hidden" name="widget_id" value="' . esc_attr($meta_box['id']) . '" />';
   186 	submit_button( __('Submit') );
   188 	submit_button( __('Submit') );
   187 	echo '</form>';
   189 	echo '</form>';
   188 }
   190 }
   189 
   191 
   390 		else
   392 		else
   391 			printf( __('Theme <span class="b">%1$s</span>'), $theme->display('Name') );
   393 			printf( __('Theme <span class="b">%1$s</span>'), $theme->display('Name') );
   392 	}
   394 	}
   393 	echo '</p>';
   395 	echo '</p>';
   394 
   396 
   395 	// Check if search engines are blocked.
   397 	// Check if search engines are asked not to index this site.
   396 	if ( !is_network_admin() && !is_user_admin() && current_user_can('manage_options') && '1' != get_option('blog_public') ) {
   398 	if ( !is_network_admin() && !is_user_admin() && current_user_can('manage_options') && '1' != get_option('blog_public') ) {
   397 		$title = apply_filters('privacy_on_link_title', __('Your site is asking search engines not to index its content') );
   399 		$title = apply_filters('privacy_on_link_title', __('Your site is asking search engines not to index its content') );
   398 		$content = apply_filters('privacy_on_link_text', __('Search Engines Blocked') );
   400 		$content = apply_filters('privacy_on_link_text', __('Search Engines Discouraged') );
   399 
   401 
   400 		echo "<p><a href='options-privacy.php' title='$title'>$content</a></p>";
   402 		echo "<p><a href='options-reading.php' title='$title'>$content</a></p>";
   401 	}
   403 	}
   402 
   404 
   403 	update_right_now_message();
   405 	update_right_now_message();
   404 
   406 
   405 	echo "\n\t".'<br class="clear" /></div>';
   407 	echo "\n\t".'<br class="clear" /></div>';
   478 			) );
   480 			) );
   479 
   481 
   480 			if ( $drafts_query->posts )
   482 			if ( $drafts_query->posts )
   481 				$drafts =& $drafts_query->posts;
   483 				$drafts =& $drafts_query->posts;
   482 		}
   484 		}
   483 		printf('<p class="textright">' . __('You can also try %s, easy blogging from anywhere on the Web.') . '</p>', '<a href="' . esc_url( admin_url( 'tools.php' ) ) . '">' . __('Press This') . '</a>' );
   485 		printf('<p class="easy-blogging">' . __('You can also try %s, easy blogging from anywhere on the Web.') . '</p>', '<a href="' . esc_url( admin_url( 'tools.php' ) ) . '">' . __('Press This') . '</a>' );
   484 		$_REQUEST = array(); // hack for get_default_post_to_edit()
   486 		$_REQUEST = array(); // hack for get_default_post_to_edit()
   485 	}
   487 	}
   486 
   488 
   487 	/* Check if a new auto-draft (= no new post_ID) is needed or if the old can be used */
   489 	/* Check if a new auto-draft (= no new post_ID) is needed or if the old can be used */
   488 	$last_post_id = (int) get_user_option( 'dashboard_quick_press_last_post_id' ); // Get the last post_ID
   490 	$last_post_id = (int) get_user_option( 'dashboard_quick_press_last_post_id' ); // Get the last post_ID
   489 	if ( $last_post_id ) {
   491 	if ( $last_post_id ) {
   490 		$post = get_post( $last_post_id );
   492 		$post = get_post( $last_post_id );
   491 		if ( empty( $post ) || $post->post_status != 'auto-draft' ) { // auto-draft doesn't exists anymore
   493 		if ( empty( $post ) || $post->post_status != 'auto-draft' ) { // auto-draft doesn't exists anymore
   492 			$post = get_default_post_to_edit('post', true);
   494 			$post = get_default_post_to_edit('post', true);
   493 			update_user_option( (int) $GLOBALS['current_user']->ID, 'dashboard_quick_press_last_post_id', (int) $post->ID ); // Save post_ID
   495 			update_user_option( get_current_user_id(), 'dashboard_quick_press_last_post_id', (int) $post->ID ); // Save post_ID
   494 		} else {
   496 		} else {
   495 			$post->post_title = ''; // Remove the auto draft title
   497 			$post->post_title = ''; // Remove the auto draft title
   496 		}
   498 		}
   497 	} else {
   499 	} else {
   498 		$post = get_default_post_to_edit('post', true);
   500 		$post = get_default_post_to_edit( 'post' , true);
   499 		update_user_option( (int) $GLOBALS['current_user']->ID, 'dashboard_quick_press_last_post_id', (int) $post->ID ); // Save post_ID
   501 		$user_id = get_current_user_id();
       
   502 		// Don't create an option if this is a super admin who does not belong to this site.
       
   503 		if ( ! ( is_super_admin( $user_id ) && ! in_array( get_current_blog_id(), array_keys( get_blogs_of_user( $user_id ) ) ) ) )
       
   504 			update_user_option( $user_id, 'dashboard_quick_press_last_post_id', (int) $post->ID ); // Save post_ID
   500 	}
   505 	}
   501 
   506 
   502 	$post_ID = (int) $post->ID;
   507 	$post_ID = (int) $post->ID;
       
   508 
       
   509 	$media_settings = array(
       
   510 		'id' => $post->ID,
       
   511 		'nonce' => wp_create_nonce( 'update-post_' . $post->ID ),
       
   512 	);
       
   513 
       
   514 	if ( current_theme_supports( 'post-thumbnails', $post->post_type ) && post_type_supports( $post->post_type, 'thumbnail' ) ) {
       
   515 		$featured_image_id = get_post_meta( $post->ID, '_thumbnail_id', true );
       
   516 		$media_settings['featuredImageId'] = $featured_image_id ? $featured_image_id : -1;
       
   517 	}
   503 ?>
   518 ?>
   504 
   519 
   505 	<form name="post" action="<?php echo esc_url( admin_url( 'post.php' ) ); ?>" method="post" id="quick-press">
   520 	<form name="post" action="<?php echo esc_url( admin_url( 'post.php' ) ); ?>" method="post" id="quick-press">
   506 		<h4 id="quick-post-title"><label for="title"><?php _e('Title') ?></label></h4>
   521 		<div class="input-text-wrap" id="title-wrap">
   507 		<div class="input-text-wrap">
   522 			<label class="screen-reader-text prompt" for="title" id="title-prompt-text"><?php _e( 'Enter title here' ); ?></label>
   508 			<input type="text" name="post_title" id="title" tabindex="1" autocomplete="off" value="<?php echo esc_attr( $post->post_title ); ?>" />
   523 			<input type="text" name="post_title" id="title" autocomplete="off" value="<?php echo esc_attr( $post->post_title ); ?>" />
   509 		</div>
   524 		</div>
   510 
   525 
   511 		<?php if ( current_user_can( 'upload_files' ) ) : ?>
   526 		<?php if ( current_user_can( 'upload_files' ) ) : ?>
   512 		<div id="wp-content-wrap" class="wp-editor-wrap hide-if-no-js wp-media-buttons">
   527 		<div id="wp-content-wrap" class="wp-editor-wrap hide-if-no-js wp-media-buttons">
   513 			<?php do_action( 'media_buttons', 'content' ); ?>
   528 			<?php do_action( 'media_buttons', 'content' ); ?>
   514 		</div>
   529 		</div>
   515 		<?php endif; ?>
   530 		<?php endif; ?>
   516 
   531 
   517 		<h4 id="content-label"><label for="content"><?php _e('Content') ?></label></h4>
       
   518 		<div class="textarea-wrap">
   532 		<div class="textarea-wrap">
   519 			<textarea name="content" id="content" class="mceEditor" rows="3" cols="15" tabindex="2"><?php echo esc_textarea( $post->post_content ); ?></textarea>
   533 			<label class="screen-reader-text" for="content"><?php _e( 'Content' ); ?></label>
       
   534 			<textarea name="content" id="content" class="mceEditor" rows="3" cols="15"><?php echo esc_textarea( $post->post_content ); ?></textarea>
   520 		</div>
   535 		</div>
   521 
   536 
   522 		<script type="text/javascript">edCanvas = document.getElementById('content');edInsertContent = null;</script>
   537 		<script type="text/javascript">
   523 
   538 		edCanvas = document.getElementById('content');
   524 		<h4><label for="tags-input"><?php _e('Tags') ?></label></h4>
   539 		edInsertContent = null;
   525 		<div class="input-text-wrap">
   540 		<?php if ( $_POST ) : ?>
   526 			<input type="text" name="tags_input" id="tags-input" tabindex="3" value="<?php echo get_tags_to_edit( $post->ID ); ?>" />
   541 		wp.media.editor.remove('content');
       
   542 		wp.media.view.settings.post = <?php echo json_encode( $media_settings ); // big juicy hack. ?>;
       
   543 		wp.media.editor.add('content');
       
   544 		<?php endif; ?>
       
   545 		</script>
       
   546 
       
   547 		<div class="input-text-wrap" id="tags-input-wrap">
       
   548 			<label class="screen-reader-text prompt" for="tags-input" id="tags-input-prompt-text"><?php _e( 'Tags (separate with commas)' ); ?></label>
       
   549 			<input type="text" name="tags_input" id="tags-input" value="<?php echo get_tags_to_edit( $post->ID ); ?>" />
   527 		</div>
   550 		</div>
   528 
   551 
   529 		<p class="submit">
   552 		<p class="submit">
       
   553 			<span id="publishing-action">
       
   554 				<input type="submit" name="publish" id="publish" accesskey="p" class="button-primary" value="<?php current_user_can('publish_posts') ? esc_attr_e('Publish') : esc_attr_e('Submit for Review'); ?>" />
       
   555 				<span class="spinner"></span>
       
   556 			</span>
   530 			<input type="hidden" name="action" id="quickpost-action" value="post-quickpress-save" />
   557 			<input type="hidden" name="action" id="quickpost-action" value="post-quickpress-save" />
   531 			<input type="hidden" name="post_ID" value="<?php echo $post_ID; ?>" />
   558 			<input type="hidden" name="post_ID" value="<?php echo $post_ID; ?>" />
   532 			<input type="hidden" name="post_type" value="post" />
   559 			<input type="hidden" name="post_type" value="post" />
   533 			<?php wp_nonce_field('add-post'); ?>
   560 			<?php wp_nonce_field('add-post'); ?>
   534 			<?php submit_button( __( 'Save Draft' ), 'button', 'save', false, array( 'id' => 'save-post', 'tabindex'=> 4 ) ); ?>
   561 			<?php submit_button( __( 'Save Draft' ), 'button', 'save', false, array( 'id' => 'save-post' ) ); ?>
   535 			<input type="reset" value="<?php esc_attr_e( 'Reset' ); ?>" class="button" />
   562 			<input type="reset" value="<?php esc_attr_e( 'Reset' ); ?>" class="button" />
   536 			<span id="publishing-action">
       
   537 				<input type="submit" name="publish" id="publish" accesskey="p" tabindex="5" class="button-primary" value="<?php current_user_can('publish_posts') ? esc_attr_e('Publish') : esc_attr_e('Submit for Review'); ?>" />
       
   538 				<img class="waiting" src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" alt="" />
       
   539 			</span>
       
   540 			<br class="clear" />
   563 			<br class="clear" />
   541 		</p>
   564 		</p>
   542 
   565 
   543 	</form>
   566 	</form>
   544 
   567 
   564 		$list = array();
   587 		$list = array();
   565 		foreach ( $drafts as $draft ) {
   588 		foreach ( $drafts as $draft ) {
   566 			$url = get_edit_post_link( $draft->ID );
   589 			$url = get_edit_post_link( $draft->ID );
   567 			$title = _draft_or_post_title( $draft->ID );
   590 			$title = _draft_or_post_title( $draft->ID );
   568 			$item = "<h4><a href='$url' title='" . sprintf( __( 'Edit &#8220;%s&#8221;' ), 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>';
   591 			$item = "<h4><a href='$url' title='" . sprintf( __( 'Edit &#8220;%s&#8221;' ), 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>';
   569 			if ( $the_content = preg_split( '#\s#', strip_tags( $draft->post_content ), 11, PREG_SPLIT_NO_EMPTY ) )
   592 			if ( $the_content = preg_split( '#[\r\n\t ]#', strip_tags( $draft->post_content ), 11, PREG_SPLIT_NO_EMPTY ) )
   570 				$item .= '<p>' . join( ' ', array_slice( $the_content, 0, 10 ) ) . ( 10 < count( $the_content ) ? '&hellip;' : '' ) . '</p>';
   593 				$item .= '<p>' . join( ' ', array_slice( $the_content, 0, 10 ) ) . ( 10 < count( $the_content ) ? '&hellip;' : '' ) . '</p>';
   571 			$list[] = $item;
   594 			$list[] = $item;
   572 		}
   595 		}
   573 ?>
   596 ?>
   574 	<ul>
   597 	<ul>
   612 		$comments_query['offset'] += $comments_query['number'];
   635 		$comments_query['offset'] += $comments_query['number'];
   613 		$comments_query['number'] = $total_items * 10;
   636 		$comments_query['number'] = $total_items * 10;
   614 	}
   637 	}
   615 
   638 
   616 	if ( $comments ) {
   639 	if ( $comments ) {
   617 		echo '<div id="the-comment-list" class="list:comment">';
   640 		echo '<div id="the-comment-list" data-wp-lists="list:comment">';
   618 		foreach ( $comments as $comment )
   641 		foreach ( $comments as $comment )
   619 			_wp_dashboard_recent_comments_row( $comment );
   642 			_wp_dashboard_recent_comments_row( $comment );
   620 		echo '</div>';
   643 		echo '</div>';
   621 
   644 
   622 		if ( current_user_can('edit_posts') )
   645 		if ( current_user_can('edit_posts') )
   655 		$unapprove_url = esc_url( "comment.php?action=unapprovecomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$approve_nonce" );
   678 		$unapprove_url = esc_url( "comment.php?action=unapprovecomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$approve_nonce" );
   656 		$spam_url = esc_url( "comment.php?action=spamcomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$del_nonce" );
   679 		$spam_url = esc_url( "comment.php?action=spamcomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$del_nonce" );
   657 		$trash_url = esc_url( "comment.php?action=trashcomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$del_nonce" );
   680 		$trash_url = esc_url( "comment.php?action=trashcomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$del_nonce" );
   658 		$delete_url = esc_url( "comment.php?action=deletecomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$del_nonce" );
   681 		$delete_url = esc_url( "comment.php?action=deletecomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$del_nonce" );
   659 
   682 
   660 		$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>';
   683 		$actions['approve'] = "<a href='$approve_url' data-wp-lists='dim:the-comment-list:comment-$comment->comment_ID:unapproved:e7e7d3:e7e7d3:new=approved' class='vim-a' title='" . esc_attr__( 'Approve this comment' ) . "'>" . __( 'Approve' ) . '</a>';
   661 		$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>';
   684 		$actions['unapprove'] = "<a href='$unapprove_url' data-wp-lists='dim:the-comment-list:comment-$comment->comment_ID:unapproved:e7e7d3:e7e7d3:new=unapproved' class='vim-u' title='" . esc_attr__( 'Unapprove this comment' ) . "'>" . __( 'Unapprove' ) . '</a>';
   662 		$actions['edit'] = "<a href='comment.php?action=editcomment&amp;c={$comment->comment_ID}' title='" . esc_attr__('Edit comment') . "'>". __('Edit') . '</a>';
   685 		$actions['edit'] = "<a href='comment.php?action=editcomment&amp;c={$comment->comment_ID}' title='" . esc_attr__('Edit comment') . "'>". __('Edit') . '</a>';
   663 		$actions['reply'] = '<a onclick="commentReply.open(\''.$comment->comment_ID.'\',\''.$comment->comment_post_ID.'\');return false;" class="vim-r hide-if-no-js" title="'.esc_attr__('Reply to this comment').'" href="#">' . __('Reply') . '</a>';
   686 		$actions['reply'] = '<a onclick="commentReply.open(\''.$comment->comment_ID.'\',\''.$comment->comment_post_ID.'\');return false;" class="vim-r hide-if-no-js" title="'.esc_attr__('Reply to this comment').'" href="#">' . __('Reply') . '</a>';
   664 		$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>';
   687 		$actions['spam'] = "<a href='$spam_url' data-wp-lists='delete:the-comment-list:comment-$comment->comment_ID::spam=1' class='vim-s vim-destructive' title='" . esc_attr__( 'Mark this comment as spam' ) . "'>" . /* translators: mark as spam link */ _x( 'Spam', 'verb' ) . '</a>';
   665 		if ( !EMPTY_TRASH_DAYS )
   688 		if ( !EMPTY_TRASH_DAYS )
   666 			$actions['delete'] = "<a href='$delete_url' class='delete:the-comment-list:comment-$comment->comment_ID::trash=1 delete vim-d vim-destructive'>" . __('Delete Permanently') . '</a>';
   689 			$actions['delete'] = "<a href='$delete_url' data-wp-lists='delete:the-comment-list:comment-$comment->comment_ID::trash=1' class='delete vim-d vim-destructive'>" . __('Delete Permanently') . '</a>';
   667 		else
   690 		else
   668 			$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>';
   691 			$actions['trash'] = "<a href='$trash_url' data-wp-lists='delete:the-comment-list:comment-$comment->comment_ID::trash=1' class='delete vim-d vim-destructive' title='" . esc_attr__( 'Move this comment to the trash' ) . "'>" . _x('Trash', 'verb') . '</a>';
   669 
   692 
   670 		$actions = apply_filters( 'comment_row_actions', array_filter($actions), $comment );
   693 		$actions = apply_filters( 'comment_row_actions', array_filter($actions), $comment );
   671 
   694 
   672 		$i = 0;
   695 		$i = 0;
   673 		foreach ( $actions as $action => $link ) {
   696 		foreach ( $actions as $action => $link ) {
   811 			$text = __( '%1$s linked here <a href="%2$s">saying</a>, "%3$s"' );
   834 			$text = __( '%1$s linked here <a href="%2$s">saying</a>, "%3$s"' );
   812 		else
   835 		else
   813 			/* translators: incoming links feed, %1$s is other person, %3$s is content */
   836 			/* translators: incoming links feed, %1$s is other person, %3$s is content */
   814 			$text = __( '%1$s linked here saying, "%3$s"' );
   837 			$text = __( '%1$s linked here saying, "%3$s"' );
   815 
   838 
   816 		if ( !empty($show_date) ) {
   839 		if ( !empty( $show_date ) ) {
   817 			if ( !empty($show_author) || !empty($show_summary) )
   840 			if ( $link )
   818 				/* translators: incoming links feed, %4$s is the date */
   841 				/* translators: incoming links feed, %1$s is other person, %3$s is content, %4$s is the date */
   819 				$text .= ' ' . __( 'on %4$s' );
   842 				$text = __( '%1$s linked here <a href="%2$s">saying</a>, "%3$s" on %4$s' );
       
   843 			else
       
   844 				/* translators: incoming links feed, %1$s is other person, %3$s is content, %4$s is the date */
       
   845 				$text = __( '%1$s linked here saying, "%3$s" on %4$s' );
   820 			$date = esc_html( strip_tags( $item->get_date() ) );
   846 			$date = esc_html( strip_tags( $item->get_date() ) );
   821 			$date = strtotime( $date );
   847 			$date = strtotime( $date );
   822 			$date = gmdate( get_option( 'date_format' ), $date );
   848 			$date = gmdate( get_option( 'date_format' ), $date );
   823 		}
   849 		}
   824 
   850 
   911 	$popular = fetch_feed( 'http://wordpress.org/extend/plugins/rss/browse/popular/' );
   937 	$popular = fetch_feed( 'http://wordpress.org/extend/plugins/rss/browse/popular/' );
   912 	$new     = fetch_feed( 'http://wordpress.org/extend/plugins/rss/browse/new/' );
   938 	$new     = fetch_feed( 'http://wordpress.org/extend/plugins/rss/browse/new/' );
   913 
   939 
   914 	if ( false === $plugin_slugs = get_transient( 'plugin_slugs' ) ) {
   940 	if ( false === $plugin_slugs = get_transient( 'plugin_slugs' ) ) {
   915 		$plugin_slugs = array_keys( get_plugins() );
   941 		$plugin_slugs = array_keys( get_plugins() );
   916 		set_transient( 'plugin_slugs', $plugin_slugs, 86400 );
   942 		set_transient( 'plugin_slugs', $plugin_slugs, DAY_IN_SECONDS );
   917 	}
   943 	}
   918 
   944 
   919 	foreach ( array( 'popular' => __('Most Popular'), 'new' => __('Newest Plugins') ) as $feed => $label ) {
   945 	foreach ( array( 'popular' => __('Most Popular'), 'new' => __('Newest Plugins') ) as $feed => $label ) {
   920 		if ( is_wp_error($$feed) || !$$feed->get_item_quantity() )
   946 		if ( is_wp_error($$feed) || !$$feed->get_item_quantity() )
   921 			continue;
   947 			continue;
   959 			unset($items[$item_key]);
   985 			unset($items[$item_key]);
   960 
   986 
   961 		if ( !isset($items[$item_key]) )
   987 		if ( !isset($items[$item_key]) )
   962 			continue;
   988 			continue;
   963 
   989 
   964 		// current bbPress feed item titles are: user on "topic title"
   990 		$title = esc_html( $item->get_title() );
   965 		if ( preg_match( '/&quot;(.*)&quot;/s', $item->get_title(), $matches ) )
       
   966 			$title = $matches[1];
       
   967 		else // but let's make it forward compatible if things change
       
   968 			$title = $item->get_title();
       
   969 		$title = esc_html( $title );
       
   970 
   991 
   971 		$description = esc_html( strip_tags(@html_entity_decode($item->get_description(), ENT_QUOTES, get_option('blog_charset'))) );
   992 		$description = esc_html( strip_tags(@html_entity_decode($item->get_description(), ENT_QUOTES, get_option('blog_charset'))) );
   972 
   993 
   973 		$ilink = wp_nonce_url('plugin-install.php?tab=plugin-information&plugin=' . $slug, 'install-plugin_' . $slug) .
   994 		$ilink = wp_nonce_url('plugin-install.php?tab=plugin-information&plugin=' . $slug, 'install-plugin_' . $slug) .
   974 							'&amp;TB_iframe=true&amp;width=600&amp;height=800';
   995 							'&amp;TB_iframe=true&amp;width=600&amp;height=800';
  1024 	if ( $callback && is_callable( $callback ) ) {
  1045 	if ( $callback && is_callable( $callback ) ) {
  1025 		$args = array_slice( func_get_args(), 2 );
  1046 		$args = array_slice( func_get_args(), 2 );
  1026 		array_unshift( $args, $widget_id );
  1047 		array_unshift( $args, $widget_id );
  1027 		ob_start();
  1048 		ob_start();
  1028 		call_user_func_array( $callback, $args );
  1049 		call_user_func_array( $callback, $args );
  1029 		set_transient( $cache_key, ob_get_flush(), 43200); // Default lifetime in cache of 12 hours (same as the feeds)
  1050 		set_transient( $cache_key, ob_get_flush(), 12 * HOUR_IN_SECONDS ); // Default lifetime in cache of 12 hours (same as the feeds)
  1030 	}
  1051 	}
  1031 
  1052 
  1032 	return true;
  1053 	return true;
  1033 }
  1054 }
  1034 
  1055 
  1097 function wp_dashboard_quota() {
  1118 function wp_dashboard_quota() {
  1098 	if ( !is_multisite() || !current_user_can('upload_files') || get_site_option( 'upload_space_check_disabled' ) )
  1119 	if ( !is_multisite() || !current_user_can('upload_files') || get_site_option( 'upload_space_check_disabled' ) )
  1099 		return true;
  1120 		return true;
  1100 
  1121 
  1101 	$quota = get_space_allowed();
  1122 	$quota = get_space_allowed();
  1102 	$used = get_dirsize( BLOGUPLOADDIR ) / 1024 / 1024;
  1123 	$used = get_space_used();
  1103 
  1124 
  1104 	if ( $used > $quota )
  1125 	if ( $used > $quota )
  1105 		$percentused = '100';
  1126 		$percentused = '100';
  1106 	else
  1127 	else
  1107 		$percentused = ( $used / $quota ) * 100;
  1128 		$percentused = ( $used / $quota ) * 100;
  1112 	?>
  1133 	?>
  1113 	<p class="sub musub"><?php _e( 'Storage Space' ); ?></p>
  1134 	<p class="sub musub"><?php _e( 'Storage Space' ); ?></p>
  1114 	<div class="table table_content musubtable">
  1135 	<div class="table table_content musubtable">
  1115 	<table>
  1136 	<table>
  1116 		<tr class="first">
  1137 		<tr class="first">
  1117 			<td class="first b b-posts"><?php printf( __( '<a href="%1$s" title="Manage Uploads" class="musublink">%2$sMB</a>' ), esc_url( admin_url( 'upload.php' ) ), $quota ); ?></td>
  1138 			<td class="first b b-posts"><?php printf( __( '<a href="%1$s" title="Manage Uploads" class="musublink">%2$sMB</a>' ), esc_url( admin_url( 'upload.php' ) ), number_format_i18n( $quota ) ); ?></td>
  1118 			<td class="t posts"><?php _e( 'Space Allowed' ); ?></td>
  1139 			<td class="t posts"><?php _e( 'Space Allowed' ); ?></td>
  1119 		</tr>
  1140 		</tr>
  1120 	</table>
  1141 	</table>
  1121 	</div>
  1142 	</div>
  1122 	<div class="table table_discussion musubtable">
  1143 	<div class="table table_discussion musubtable">
  1123 	<table>
  1144 	<table>
  1124 		<tr class="first">
  1145 		<tr class="first">
  1125 			<td class="b b-comments"><?php printf( __( '<a href="%1$s" title="Manage Uploads" class="musublink">%2$sMB (%3$s%%)</a>' ), esc_url( admin_url( 'upload.php' ) ), $used, $percentused ); ?></td>
  1146 			<td class="b b-comments"><?php printf( __( '<a href="%1$s" title="Manage Uploads" class="musublink">%2$sMB (%3$s%%)</a>' ), esc_url( admin_url( 'upload.php' ) ), number_format_i18n( $used, 2 ), $percentused ); ?></td>
  1126 			<td class="last t comments<?php echo $used_color;?>"><?php _e( 'Space Used' );?></td>
  1147 			<td class="last t comments<?php echo $used_color;?>"><?php _e( 'Space Used' );?></td>
  1127 		</tr>
  1148 		</tr>
  1128 	</table>
  1149 	</table>
  1129 	</div>
  1150 	</div>
  1130 	<br class="clear" />
  1151 	<br class="clear" />
  1215 		$response = maybe_unserialize( wp_remote_retrieve_body( $response ) );
  1236 		$response = maybe_unserialize( wp_remote_retrieve_body( $response ) );
  1216 
  1237 
  1217 		if ( ! is_array( $response ) )
  1238 		if ( ! is_array( $response ) )
  1218 			return false;
  1239 			return false;
  1219 
  1240 
  1220 		set_site_transient( 'browser_' . $key, $response, 604800 ); // cache for 1 week
  1241 		set_site_transient( 'browser_' . $key, $response, WEEK_IN_SECONDS );
  1221 	}
  1242 	}
  1222 
  1243 
  1223 	return $response;
  1244 	return $response;
  1224 }
  1245 }
  1225 
  1246 
  1232  * Displays a welcome panel to introduce users to WordPress.
  1253  * Displays a welcome panel to introduce users to WordPress.
  1233  *
  1254  *
  1234  * @since 3.3.0
  1255  * @since 3.3.0
  1235  */
  1256  */
  1236 function wp_welcome_panel() {
  1257 function wp_welcome_panel() {
  1237 	global $wp_version;
       
  1238 
       
  1239 	if ( ! current_user_can( 'edit_theme_options' ) )
       
  1240 		return;
       
  1241 
       
  1242 	$classes = 'welcome-panel';
       
  1243 
       
  1244 	$option = get_user_meta( get_current_user_id(), 'show_welcome_panel', true );
       
  1245 	// 0 = hide, 1 = toggled to show or single site creator, 2 = multisite site owner
       
  1246 	$hide = 0 == $option || ( 2 == $option && wp_get_current_user()->user_email != get_option( 'admin_email' ) );
       
  1247 	if ( $hide )
       
  1248 		$classes .= ' hidden';
       
  1249 
       
  1250 	list( $display_version ) = explode( '-', $wp_version );
       
  1251 	?>
  1258 	?>
  1252 	<div id="welcome-panel" class="<?php echo esc_attr( $classes ); ?>">
       
  1253 	<?php wp_nonce_field( 'welcome-panel-nonce', 'welcomepanelnonce', false ); ?>
       
  1254 	<a class="welcome-panel-close" href="<?php echo esc_url( admin_url( '?welcome=0' ) ); ?>"><?php _e('Dismiss'); ?></a>
       
  1255 	<div class="wp-badge"><?php printf( __( 'Version %s' ), $display_version ); ?></div>
       
  1256 
       
  1257 	<div class="welcome-panel-content">
  1259 	<div class="welcome-panel-content">
  1258 	<h3><?php _e( 'Welcome to your new WordPress site!' ); ?></h3>
  1260 	<h3><?php _e( 'Welcome to WordPress!' ); ?></h3>
  1259 	<p class="about-description"><?php _e( 'If you need help getting started, check out our documentation on <a href="http://codex.wordpress.org/First_Steps_With_WordPress">First Steps with WordPress</a>. If you&#8217;d rather dive right in, here are a few things most people do first when they set up a new WordPress site. If you need help, use the Help tabs in the upper right corner to get information on how to use your current screen and where to go for more assistance.' ); ?></p>
  1261 	<p class="about-description"><?php _e( 'We&#8217;ve assembled some links to get you started:' ); ?></p>
  1260 	<div class="welcome-panel-column-container">
  1262 	<div class="welcome-panel-column-container">
  1261 	<div class="welcome-panel-column">
  1263 	<div class="welcome-panel-column">
  1262 		<h4><span class="icon16 icon-settings"></span> <?php _e( 'Basic Settings' ); ?></h4>
  1264 		<h4><?php _e( 'Get Started' ); ?></h4>
  1263 		<p><?php _e( 'Here are a few easy things you can do to get your feet wet. Make sure to click Save on each Settings screen.' ); ?></p>
  1265 		<a class="button button-primary button-hero load-customize hide-if-no-customize" href="<?php echo wp_customize_url(); ?>"><?php _e( 'Customize Your Site' ); ?></a>
  1264 		<ul>
  1266 		<a class="button button-primary button-hero hide-if-customize" href="<?php echo admin_url( 'themes.php' ); ?>"><?php _e( 'Customize Your Site' ); ?></a>
  1265 		<li><?php echo sprintf(	__( '<a href="%s">Choose your privacy setting</a>' ), esc_url( admin_url('options-privacy.php') ) ); ?></li>
  1267 		<?php if ( current_user_can( 'install_themes' ) || ( current_user_can( 'switch_themes' ) && count( wp_get_themes( array( 'allowed' => true ) ) ) > 1 ) ) : ?>
  1266 		<li><?php echo sprintf( __( '<a href="%s">Select your tagline and time zone</a>' ), esc_url( admin_url('options-general.php') ) ); ?></li>
  1268 			<p class="hide-if-no-customize"><?php printf( __( 'or, <a href="%s">change your theme completely</a>' ), admin_url( 'themes.php' ) ); ?></p>
  1267 		<li><?php echo sprintf( __( '<a href="%s">Turn comments on or off</a>' ), esc_url( admin_url('options-discussion.php') ) ); ?></li>
  1269 		<?php endif; ?>
  1268 		<li><?php echo sprintf( __( '<a href="%s">Fill in your profile</a>' ), esc_url( admin_url('profile.php') ) ); ?></li>
       
  1269 		</ul>
       
  1270 	</div>
  1270 	</div>
  1271 	<div class="welcome-panel-column">
  1271 	<div class="welcome-panel-column">
  1272 		<h4><span class="icon16 icon-page"></span> <?php _e( 'Add Real Content' ); ?></h4>
  1272 		<h4><?php _e( 'Next Steps' ); ?></h4>
  1273 		<p><?php _e( 'Check out the sample page & post editors to see how it all works, then delete the default content and write your own!' ); ?></p>
       
  1274 		<ul>
  1273 		<ul>
  1275 		<li><?php echo sprintf( __( 'View the <a href="%1$s">sample page</a> and <a href="%2$s">post</a>' ), esc_url( get_permalink( 2 ) ), esc_url( get_permalink( 1 ) ) ); ?></li>
  1274 		<?php if ( 'page' == get_option( 'show_on_front' ) && ! get_option( 'page_for_posts' ) ) : ?>
  1276 		<li><?php echo sprintf( __( 'Delete the <a href="%1$s">sample page</a> and <a href="%2$s">post</a>' ), esc_url( admin_url('edit.php?post_type=page') ), esc_url( admin_url('edit.php') ) ); ?></li>
  1275 			<li><?php printf( '<a href="%s" class="welcome-icon welcome-edit-page">' . __( 'Edit your front page' ) . '</a>', get_edit_post_link( get_option( 'page_on_front' ) ) ); ?></li>
  1277 		<li><?php echo sprintf( __( '<a href="%s">Create an About Me page</a>' ), esc_url( admin_url('edit.php?post_type=page') ) ); ?></li>
  1276 			<li><?php printf( '<a href="%s" class="welcome-icon welcome-add-page">' . __( 'Add additional pages' ) . '</a>', admin_url( 'post-new.php?post_type=page' ) ); ?></li>
  1278 		<li><?php echo sprintf( __( '<a href="%s">Write your first post</a>' ), esc_url( admin_url('post-new.php') ) ); ?></li>
  1277 		<?php elseif ( 'page' == get_option( 'show_on_front' ) ) : ?>
       
  1278 			<li><?php printf( '<a href="%s" class="welcome-icon welcome-edit-page">' . __( 'Edit your front page' ) . '</a>', get_edit_post_link( get_option( 'page_on_front' ) ) ); ?></li>
       
  1279 			<li><?php printf( '<a href="%s" class="welcome-icon welcome-add-page">' . __( 'Add additional pages' ) . '</a>', admin_url( 'post-new.php?post_type=page' ) ); ?></li>
       
  1280 			<li><?php printf( '<a href="%s" class="welcome-icon welcome-write-blog">' . __( 'Add a blog post' ) . '</a>', admin_url( 'post-new.php' ) ); ?></li>
       
  1281 		<?php else : ?>
       
  1282 			<li><?php printf( '<a href="%s" class="welcome-icon welcome-write-blog">' . __( 'Write your first blog post' ) . '</a>', admin_url( 'post-new.php' ) ); ?></li>
       
  1283 			<li><?php printf( '<a href="%s" class="welcome-icon welcome-add-page">' . __( 'Add an About page' ) . '</a>', admin_url( 'post-new.php?post_type=page' ) ); ?></li>
       
  1284 		<?php endif; ?>
       
  1285 			<li><?php printf( '<a href="%s" class="welcome-icon welcome-view-site">' . __( 'View your site' ) . '</a>', home_url( '/' ) ); ?></li>
  1279 		</ul>
  1286 		</ul>
  1280 	</div>
  1287 	</div>
  1281 	<div class="welcome-panel-column welcome-panel-last">
  1288 	<div class="welcome-panel-column welcome-panel-last">
  1282 		<h4><span class="icon16 icon-appearance"></span> <?php _e( 'Customize Your Site' ); ?></h4>
  1289 		<h4><?php _e( 'More Actions' ); ?></h4>
  1283 		<?php
  1290 		<ul>
  1284 		$theme = wp_get_theme();
  1291 			<li><?php printf( '<div class="welcome-icon welcome-widgets-menus">' . __( 'Manage <a href="%1$s">widgets</a> or <a href="%2$s">menus</a>' ) . '</div>', admin_url( 'widgets.php' ), admin_url( 'nav-menus.php' ) ); ?></li>
  1285 		if ( $theme->errors() ) :
  1292 			<li><?php printf( '<a href="%s" class="welcome-icon welcome-comments">' . __( 'Turn comments on or off' ) . '</a>', admin_url( 'options-discussion.php' ) ); ?></li>
  1286 			echo '<p>';
  1293 			<li><?php printf( '<a href="%s" class="welcome-icon welcome-learn-more">' . __( 'Learn more about getting started' ) . '</a>', __( 'http://codex.wordpress.org/First_Steps_With_WordPress' ) ); ?></li>
  1287 			printf( __( '<a href="%s">Install a theme</a> to get started customizing your site.' ), esc_url( admin_url( 'themes.php' ) ) );
  1294 		</ul>
  1288 			echo '</p>';
       
  1289 		else:
       
  1290 			$customize_links = array();
       
  1291 			if ( 'twentyeleven' == $theme->get_stylesheet() )
       
  1292 				$customize_links[] = sprintf( __( '<a href="%s">Choose light or dark</a>' ), esc_url( admin_url( 'themes.php?page=theme_options' ) ) );
       
  1293 
       
  1294 			if ( current_theme_supports( 'custom-background' ) )
       
  1295 				$customize_links[] = sprintf( __( '<a href="%s">Set a background color</a>' ), esc_url( admin_url( 'themes.php?page=custom-background' ) ) );
       
  1296 
       
  1297 			if ( current_theme_supports( 'custom-header' ) )
       
  1298 				$customize_links[] = sprintf( __( '<a href="%s">Select a new header image</a>' ), esc_url( admin_url( 'themes.php?page=custom-header' ) ) );
       
  1299 
       
  1300 			if ( current_theme_supports( 'widgets' ) )
       
  1301 				$customize_links[] = sprintf( __( '<a href="%s">Add some widgets</a>' ), esc_url( admin_url( 'widgets.php' ) ) );
       
  1302 
       
  1303 			if ( ! empty( $customize_links ) ) {
       
  1304 				echo '<p>';
       
  1305 				printf( __( 'Use the current theme &mdash; %1$s &mdash; or <a href="%2$s">choose a new one</a>. If you stick with %1$s, here are a few ways to make your site look unique.' ), $theme->display('Name'), esc_url( admin_url( 'themes.php' ) ) );
       
  1306 				echo '</p>';
       
  1307 			?>
       
  1308 			<ul>
       
  1309 				<?php foreach ( $customize_links as $customize_link ) : ?>
       
  1310 				<li><?php echo $customize_link ?></li>
       
  1311 				<?php endforeach; ?>
       
  1312 			</ul>
       
  1313 			<?php
       
  1314 			} else {
       
  1315 				echo '<p>';
       
  1316 				printf( __( 'Use the current theme &mdash; %1$s &mdash; or <a href="%2$s">choose a new one</a>.' ), $theme->display('Name'), esc_url( admin_url( 'themes.php' ) ) );
       
  1317 				echo '</p>';
       
  1318 			}
       
  1319 		endif; ?>
       
  1320 	</div>
  1295 	</div>
  1321 	</div>
       
  1322 	<p class="welcome-panel-dismiss"><?php printf( __( 'Already know what you&#8217;re doing? <a href="%s">Dismiss this message</a>.' ), esc_url( admin_url( '?welcome=0' ) ) ); ?></p>
       
  1323 	</div>
  1296 	</div>
  1324 	</div>
  1297 	</div>
  1325 	<?php
  1298 	<?php
  1326 }
  1299 }