Dashboard backwards compatibility updates.
* Restore missing wp_dashboard_rss_control() helper. * Restore all original 3.7 functions, deprecating many, reusing others. * Rename and remove functions so as not to clash with the original dash plugin. * Filter cleanup/restoration. see #25824, #26334. Built from https://develop.svn.wordpress.org/trunk@26690 git-svn-id: http://core.svn.wordpress.org/trunk@26580 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
8e352c8187
commit
1788d5840f
|
@ -44,7 +44,7 @@ function wp_dashboard_setup() {
|
||||||
|
|
||||||
// Activity Widget
|
// Activity Widget
|
||||||
if ( is_blog_admin() ) {
|
if ( is_blog_admin() ) {
|
||||||
wp_add_dashboard_widget( 'dashboard_activity', __( 'Activity' ), 'wp_dashboard_activity' );
|
wp_add_dashboard_widget( 'dashboard_activity', __( 'Activity' ), 'wp_dashboard_site_activity' );
|
||||||
}
|
}
|
||||||
|
|
||||||
// QuickPress Widget
|
// QuickPress Widget
|
||||||
|
@ -343,17 +343,28 @@ function wp_dashboard_quick_press( $error_msg = false ) {
|
||||||
|
|
||||||
</form>
|
</form>
|
||||||
<?php
|
<?php
|
||||||
$query_args = array(
|
wp_dashboard_recent_drafts();
|
||||||
'post_type' => 'post',
|
}
|
||||||
'post_status' => 'draft',
|
|
||||||
'author' => get_current_user_id(),
|
/**
|
||||||
'posts_per_page' => 4,
|
* Show recent drafts of the user on the dashboard.
|
||||||
'orderby' => 'modified',
|
*
|
||||||
'order' => 'DESC'
|
* @since 2.7.0
|
||||||
);
|
*/
|
||||||
$drafts = get_posts( $query_args );
|
function wp_dashboard_recent_drafts( $drafts = false ) {
|
||||||
if ( ! $drafts ) {
|
if ( ! $drafts ) {
|
||||||
return;
|
$query_args = array(
|
||||||
|
'post_type' => 'post',
|
||||||
|
'post_status' => 'draft',
|
||||||
|
'author' => get_current_user_id(),
|
||||||
|
'posts_per_page' => 4,
|
||||||
|
'orderby' => 'modified',
|
||||||
|
'order' => 'DESC'
|
||||||
|
);
|
||||||
|
$drafts = get_posts( $query_args );
|
||||||
|
if ( ! $drafts ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
echo '<div class="drafts">';
|
echo '<div class="drafts">';
|
||||||
|
@ -475,13 +486,11 @@ function _wp_dashboard_recent_comments_row( &$comment, $show_date = true ) {
|
||||||
*
|
*
|
||||||
* @since 3.8.0
|
* @since 3.8.0
|
||||||
*/
|
*/
|
||||||
function wp_dashboard_activity() {
|
function wp_dashboard_site_activity() {
|
||||||
|
|
||||||
echo '<div id="activity-widget">';
|
echo '<div id="activity-widget">';
|
||||||
|
|
||||||
do_action( 'dashboard_activity_beginning' );
|
$future_posts = wp_dashboard_recent_posts( array(
|
||||||
|
|
||||||
$future_posts = dashboard_show_published_posts( array(
|
|
||||||
'display' => 2,
|
'display' => 2,
|
||||||
'max' => 5,
|
'max' => 5,
|
||||||
'status' => 'future',
|
'status' => 'future',
|
||||||
|
@ -489,7 +498,7 @@ function wp_dashboard_activity() {
|
||||||
'title' => __( 'Publishing Soon' ),
|
'title' => __( 'Publishing Soon' ),
|
||||||
'id' => 'future-posts',
|
'id' => 'future-posts',
|
||||||
) );
|
) );
|
||||||
$recent_posts = dashboard_show_published_posts( array(
|
$recent_posts = wp_dashboard_recent_posts( array(
|
||||||
'display' => 2,
|
'display' => 2,
|
||||||
'max' => 5,
|
'max' => 5,
|
||||||
'status' => 'publish',
|
'status' => 'publish',
|
||||||
|
@ -498,9 +507,7 @@ function wp_dashboard_activity() {
|
||||||
'id' => 'published-posts',
|
'id' => 'published-posts',
|
||||||
) );
|
) );
|
||||||
|
|
||||||
do_action( 'dashboard_activity_middle' );
|
$recent_comments = wp_dashboard_recent_comments();
|
||||||
|
|
||||||
$recent_comments = dashboard_comments();
|
|
||||||
|
|
||||||
if ( !$future_posts && !$recent_posts && !$recent_comments ) {
|
if ( !$future_posts && !$recent_posts && !$recent_comments ) {
|
||||||
echo '<div class="no-activity">';
|
echo '<div class="no-activity">';
|
||||||
|
@ -509,8 +516,6 @@ function wp_dashboard_activity() {
|
||||||
echo '</div>';
|
echo '</div>';
|
||||||
}
|
}
|
||||||
|
|
||||||
do_action( 'dashboard_activity_end' );
|
|
||||||
|
|
||||||
echo '</div>';
|
echo '</div>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -521,8 +526,7 @@ function wp_dashboard_activity() {
|
||||||
*
|
*
|
||||||
* @param array $args
|
* @param array $args
|
||||||
*/
|
*/
|
||||||
function dashboard_show_published_posts( $args ) {
|
function wp_dashboard_recent_posts( $args ) {
|
||||||
|
|
||||||
$query_args = array(
|
$query_args = array(
|
||||||
'post_type' => 'post',
|
'post_type' => 'post',
|
||||||
'post_status' => $args['status'],
|
'post_status' => $args['status'],
|
||||||
|
@ -532,7 +536,6 @@ function dashboard_show_published_posts( $args ) {
|
||||||
'no_found_rows' => true,
|
'no_found_rows' => true,
|
||||||
'cache_results' => false
|
'cache_results' => false
|
||||||
);
|
);
|
||||||
$query_args = apply_filters( 'dash_show_published_posts_query_args', $query_args );
|
|
||||||
$posts = new WP_Query( $query_args );
|
$posts = new WP_Query( $query_args );
|
||||||
|
|
||||||
if ( $posts->have_posts() ) {
|
if ( $posts->have_posts() ) {
|
||||||
|
@ -548,12 +551,25 @@ function dashboard_show_published_posts( $args ) {
|
||||||
echo '<ul>';
|
echo '<ul>';
|
||||||
|
|
||||||
$i = 0;
|
$i = 0;
|
||||||
|
$today = date( 'Y-m-d', current_time( 'timestamp' ) );
|
||||||
|
$tomorrow = date( 'Y-m-d', strtotime( '+1 day', current_time( 'timestamp' ) ) );
|
||||||
|
|
||||||
while ( $posts->have_posts() ) {
|
while ( $posts->have_posts() ) {
|
||||||
$posts->the_post();
|
$posts->the_post();
|
||||||
|
|
||||||
|
$time = get_the_time( 'U' );
|
||||||
|
if ( date( 'Y-m-d', $time ) == $today ) {
|
||||||
|
$relative = __( 'Today' );
|
||||||
|
} elseif ( date( 'Y-m-d', $time ) == $tomorrow ) {
|
||||||
|
$relative = __( 'Tomorrow' );
|
||||||
|
} else {
|
||||||
|
$relative = date( 'M jS', $time );
|
||||||
|
}
|
||||||
|
|
||||||
printf(
|
printf(
|
||||||
'<li%s><span>%s, %s</span> <a href="%s">%s</a></li>',
|
'<li%s><span>%s, %s</span> <a href="%s">%s</a></li>',
|
||||||
( $i >= intval ( $args['display'] ) ? ' class="hidden"' : '' ),
|
( $i >= intval ( $args['display'] ) ? ' class="hidden"' : '' ),
|
||||||
dashboard_relative_date( get_the_time( 'U' ) ),
|
$relative,
|
||||||
get_the_time(),
|
get_the_time(),
|
||||||
get_edit_post_link(),
|
get_edit_post_link(),
|
||||||
_draft_or_post_title()
|
_draft_or_post_title()
|
||||||
|
@ -580,7 +596,7 @@ function dashboard_show_published_posts( $args ) {
|
||||||
*
|
*
|
||||||
* @param int $total_items
|
* @param int $total_items
|
||||||
*/
|
*/
|
||||||
function dashboard_comments( $total_items = 5 ) {
|
function wp_dashboard_recent_comments( $total_items = 5 ) {
|
||||||
global $wpdb;
|
global $wpdb;
|
||||||
|
|
||||||
// Select all comment types and filter out spam later for better query performance.
|
// Select all comment types and filter out spam later for better query performance.
|
||||||
|
@ -630,28 +646,6 @@ function dashboard_comments( $total_items = 5 ) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Return relative date for given timestamp.
|
|
||||||
*
|
|
||||||
* @since 3.8.0
|
|
||||||
*
|
|
||||||
* @param int $time Unix $timestamp.
|
|
||||||
*/
|
|
||||||
function dashboard_relative_date( $time ) {
|
|
||||||
|
|
||||||
$today = date( 'Y-m-d', current_time( 'timestamp' ) );
|
|
||||||
$tomorrow = date( 'Y-m-d', strtotime( '+1 day', current_time( 'timestamp' ) ) );
|
|
||||||
|
|
||||||
if ( date( 'Y-m-d', $time ) == $today )
|
|
||||||
return __( 'Today' );
|
|
||||||
|
|
||||||
if ( date( 'Y-m-d', $time ) == $tomorrow )
|
|
||||||
return __( 'Tomorrow' );
|
|
||||||
|
|
||||||
return date( 'M jS', $time);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Display generic dashboard RSS widget feed.
|
* Display generic dashboard RSS widget feed.
|
||||||
*
|
*
|
||||||
|
@ -734,6 +728,50 @@ function wp_dashboard_trigger_widget_control( $widget_control_id = false ) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
* @since 2.5.0
|
||||||
|
*
|
||||||
|
* @param string $widget_id
|
||||||
|
* @param array $form_inputs
|
||||||
|
*/
|
||||||
|
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] = wp_unslash( $_POST['widget-rss'][$number] );
|
||||||
|
$widget_options[$widget_id] = wp_widget_rss_process( $_POST['widget-rss'][$number] );
|
||||||
|
$widget_options[$widget_id]['number'] = $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 );
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* WordPress News dashboard widget.
|
* WordPress News dashboard widget.
|
||||||
*
|
*
|
||||||
|
@ -744,7 +782,7 @@ function wp_dashboard_primary() {
|
||||||
'news' => array(
|
'news' => array(
|
||||||
'link' => apply_filters( 'dashboard_primary_link', __( 'http://wordpress.org/news/' ) ),
|
'link' => apply_filters( 'dashboard_primary_link', __( 'http://wordpress.org/news/' ) ),
|
||||||
'url' => apply_filters( 'dashboard_primary_feed', __( 'http://wordpress.org/news/feed/' ) ),
|
'url' => apply_filters( 'dashboard_primary_feed', __( 'http://wordpress.org/news/feed/' ) ),
|
||||||
'title' => '',
|
'title' => apply_filters( 'dashboard_primary_title', __( 'WordPress Blog' ) ),
|
||||||
'items' => 1,
|
'items' => 1,
|
||||||
'show_summary' => 1,
|
'show_summary' => 1,
|
||||||
'show_author' => 0,
|
'show_author' => 0,
|
||||||
|
@ -753,7 +791,7 @@ function wp_dashboard_primary() {
|
||||||
'planet' => array(
|
'planet' => array(
|
||||||
'link' => apply_filters( 'dashboard_secondary_link', __( 'http://planet.wordpress.org/' ) ),
|
'link' => apply_filters( 'dashboard_secondary_link', __( 'http://planet.wordpress.org/' ) ),
|
||||||
'url' => apply_filters( 'dashboard_secondary_feed', __( 'http://planet.wordpress.org/feed/' ) ),
|
'url' => apply_filters( 'dashboard_secondary_feed', __( 'http://planet.wordpress.org/feed/' ) ),
|
||||||
'title' => '',
|
'title' => apply_filters( 'dashboard_secondary_title', __( 'Other WordPress News' ) ),
|
||||||
'items' => 3,
|
'items' => 3,
|
||||||
'show_summary' => 0,
|
'show_summary' => 0,
|
||||||
'show_author' => 0,
|
'show_author' => 0,
|
||||||
|
|
|
@ -1149,3 +1149,28 @@ function get_screen_icon() {
|
||||||
return '<!-- Screen icons are no longer used as of WordPress 3.8. -->';
|
return '<!-- Screen icons are no longer used as of WordPress 3.8. -->';
|
||||||
}
|
}
|
||||||
/**#@-*/
|
/**#@-*/
|
||||||
|
|
||||||
|
/**#@+
|
||||||
|
* Deprecated dashboard widget controls.
|
||||||
|
*
|
||||||
|
* @since 2.5.0
|
||||||
|
* @deprecated 3.8.0
|
||||||
|
*/
|
||||||
|
function wp_dashboard_incoming_links_output() {}
|
||||||
|
function wp_dashboard_secondary_output() {}
|
||||||
|
/**#@-*/
|
||||||
|
|
||||||
|
/**#@+
|
||||||
|
* Deprecated dashboard widget controls.
|
||||||
|
*
|
||||||
|
* @since 2.7.0
|
||||||
|
* @deprecated 3.8.0
|
||||||
|
*/
|
||||||
|
function wp_dashboard_incoming_links() {}
|
||||||
|
function wp_dashboard_incoming_links_control() {}
|
||||||
|
function wp_dashboard_plugins() {}
|
||||||
|
function wp_dashboard_primary_control() {}
|
||||||
|
function wp_dashboard_recent_comments_control() {}
|
||||||
|
function wp_dashboard_secondary() {}
|
||||||
|
function wp_dashboard_secondary_control() {}
|
||||||
|
/**#@-*/
|
||||||
|
|
Loading…
Reference in New Issue