diff --git a/wp-admin/includes/dashboard.php b/wp-admin/includes/dashboard.php index 155459813d..55ccdcbbad 100644 --- a/wp-admin/includes/dashboard.php +++ b/wp-admin/includes/dashboard.php @@ -35,6 +35,33 @@ function wp_dashboard_setup() { array( 'all_link' => 'edit-comments.php', 'notice' => $notice, 'width' => 'half' ) ); + + // QuickPress Widget + if ( 'post' === strtolower( $_SERVER['REQUEST_METHOD'] ) && isset( $_POST['action'] ) && 0 === strpos( $_POST['action'], 'post-quickpress' ) ) { + $view = get_permalink( $_POST['post_ID'] ); + $edit = clean_url( get_edit_post_link( $_POST['post_ID'] ) ); + if ( 'post-quickpress-publish' == $_POST['action'] ) + $notice = sprintf( __( 'Post Published. View post | Edit post' ), clean_url( $view ), $edit ); + else + $notice = sprintf( __( 'Draft Saved. Preview post | Edit post' ), clean_url( add_query_arg( 'preview', 1, $view ) ), $edit ); + } else { + $notice = ''; + } + wp_register_sidebar_widget( 'dashboard_quick_press', __( 'QuickPress' ), 'wp_dashboard_quick_press', + array( 'all_link' => array( 'edit.php?post_status=draft', __('View All Drafts') ), 'width' => 'half', 'height' => 'double', 'notice' => $notice ) + ); + wp_register_widget_control( 'dashboard_quick_press', __( 'QuickPress' ), 'wp_dashboard_empty_control', + array( 'widget_id' => 'dashboard_quick_press' ) + ); + + // Inbox Widget + wp_register_sidebar_widget( 'dashboard_inbox', __( 'Inbox' ), 'wp_dashboard_inbox', + array( 'all_link' => 'inbox.php', 'height' => 'double' ) + ); + wp_register_widget_control( 'dashboard_inbox', __( 'Inbox' ), 'wp_dashboard_empty_control', + array( 'widget_id' => 'dashboard_inbox' ) + ); + // Incoming Links Widget if ( !isset( $widget_options['dashboard_incoming_links'] ) || !isset( $widget_options['dashboard_incoming_links']['home'] ) || $widget_options['dashboard_incoming_links']['home'] != get_option('home') ) { $update = true; @@ -106,7 +133,7 @@ function wp_dashboard_setup() { /* Dashboard Widget Template wp_register_sidebar_widget( $widget_id (unique slug) , $widget_title, $output_callback, array( - 'all_link' => full url for "See All" link, + 'all_link' => full url for "View All" link, 'feed_link' => full url for "RSS" link, 'width' => 'fourth', 'third', 'half', 'full' (defaults to 'half'), 'height' => 'single', 'double' (defaults to 'single'), @@ -132,15 +159,23 @@ function wp_dashboard_setup() { // Hard code the sidebar's widgets and order $dashboard_widgets = array(); + $dashboard_widgets[] = 'dashboard_inbox'; + $dashboard_widgets[] = 'dashboard_quick_press'; +/* $dashboard_widgets[] = 'dashboard_recent_comments'; $dashboard_widgets[] = 'dashboard_incoming_links'; $dashboard_widgets[] = 'dashboard_primary'; if ( current_user_can( 'activate_plugins' ) ) $dashboard_widgets[] = 'dashboard_plugins'; +*/ $dashboard_widgets[] = 'dashboard_secondary'; // Filter widget order $dashboard_widgets = apply_filters( 'wp_dashboard_widgets', $dashboard_widgets ); + if ( in_array( 'dashboard_quick_press', $dashboard_widgets ) ) { +// add_action( 'admin_head', 'wp_teeny_mce' ); + add_action( 'admin_head', 'wp_dashboard_quick_press_js' ); + } $wp_dashboard_sidebars = array( 'wp_dashboard' => $dashboard_widgets, 'array_version' => 3.5 ); @@ -205,9 +240,11 @@ function wp_dashboard_dynamic_sidebar_params( $params ) { if ( $the_classes ) $sidebar_before_widget = str_replace( "
' . __( 'See All' ) . ''; + $top_links = $bottom_links = array(); + if ( $widget_all_link ) { + $widget_all_link = (array) $widget_all_link; + $bottom_links[] = '' . ( isset($widget_all_link[1]) ? $widget_all_link[1] : __( 'View All' ) ) . ''; + } $content_class = 'dashboard-widget-content'; if ( current_user_can( 'edit_dashboard' ) && isset($wp_registered_widget_controls[$widget_id]) && is_callable($wp_registered_widget_controls[$widget_id]['callback']) ) { @@ -219,22 +256,16 @@ function wp_dashboard_dynamic_sidebar_params( $params ) { $params[1] = 'wp_dashboard_trigger_widget_control'; $sidebar_before_widget .= '
'; $sidebar_after_widget = "
$sidebar_after_widget"; - $links[] = '' . __( 'Cancel' ) . ''; + $top_links[] = '' . __( 'Cancel' ) . ''; } else { - $links[] = '' . __( 'Edit' ) . ''; + $top_links[] = '' . __( 'Edit' ) . ''; } } if ( $widget_feed_link ) - $links[] = '' . __( 'rss icon' ) . ' ' . __( 'RSS' ) . ''; + $bottom_links[] = '' . __( 'rss icon' ) . ' ' . __( 'RSS' ) . ''; - $links = apply_filters( "wp_dashboard_widget_links_$widget_id", $links ); - - // Add links to widget's title bar - if ( $links ) { - $sidebar_before_title .= ''; - $sidebar_after_title = '' . join( ' | ', $links ) . "
$sidebar_after_title"; - } + $bottom_links = apply_filters( "wp_dashboard_widget_links_$widget_id", $bottom_links ); // Could have put this in widget-content. Doesn't really matter if ( $widget_notice ) @@ -245,6 +276,16 @@ function wp_dashboard_dynamic_sidebar_params( $params ) { $sidebar_after_title .= "\t\t\t
\n\n"; + // Add links to widget's title bar + if ( $top_links ) { + $sidebar_before_title .= ''; + $sidebar_after_title = '' . join( ' | ', $top_links ) . "
$sidebar_after_title"; + } + + // Add links to bottom of widget + if ( $bottom_links ) + $sidebar_after_widget .= ""; + $sidebar_after_widget .= "\t\t\t
\n\n"; foreach( array_keys( $params[0] ) as $key ) @@ -258,6 +299,216 @@ function wp_dashboard_dynamic_sidebar_params( $params ) { /* Dashboard Widgets */ +function wp_dashboard_quick_press( $sidebar_args ) { + extract( $sidebar_args, EXTR_SKIP ); + + echo $before_widget; + + echo $before_title; + echo $widget_name; + echo $after_title; + + if ( ( 'post' === strtolower( $_SERVER['REQUEST_METHOD'] ) ) && 'post-quickpress-save-cont' === $_POST['action'] ) { + $post = get_post_to_edit( $_POST['post_ID'] ); + } else { + $_REQUEST = array(); // hack + $post = get_default_post_to_edit(); + } +?> + +
+

+
+ +
+ +

+
+ +
+ +

+
+ +
+

+ +

+ + + + + + +

+ + 'post', + 'what_to_show' => 'posts', + 'post_status' => 'draft', + 'author' => $GLOBALS['current_user']->ID, + 'posts_per_page' => 5, + 'orderby' => 'modified', + 'order' => 'DESC' + ) ); + + if ( $drafts_query->posts ) : + $list = array(); + foreach ( $drafts_query->posts as $draft ) { + $url = get_edit_post_link( $draft->ID ); + $title = get_the_title( $draft->ID ); + $list[] = "$title"; + } +?> + +

+

+ +

+ + + +
+ + + + + + + + +
+

+
+
+ + +
+ +