Draggable dash, first cut. Props mdawaffe. see #7552

git-svn-id: http://svn.automattic.com/wordpress/trunk@9103 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2008-10-08 23:32:34 +00:00
parent 5d1f8b93eb
commit 637cca38da
25 changed files with 462 additions and 787 deletions

View File

@ -465,7 +465,8 @@ case 'replyto-comment' :
$comment = get_comment($comment_id);
if ( ! $comment ) die('1');
$mode = ( isset($_POST['mode']) && 'single' == $_POST['mode'] ) ? 'single' : 'detail';
$modes = array( 'single', 'detail', 'dashboard' );
$mode = isset($_POST['mode']) && in_array( $_POST['mode'], $modes ) ? $_POST['mode'] : 'detail';
$position = ( isset($_POST['position']) && (int) $_POST['position']) ? (int) $_POST['position'] : '-1';
$checkbox = ( isset($_POST['checkbox']) && true == $_POST['checkbox'] ) ? 1 : 0;
@ -475,7 +476,12 @@ case 'replyto-comment' :
$x = new WP_Ajax_Response();
ob_start();
_wp_comment_row( $comment->comment_ID, $mode, false, $checkbox );
if ( 'dashboard' == $mode ) {
require_once( ABSPATH . 'wp-admin/includes/dashboard.php' );
_wp_dashboard_recent_comments_row( $comment, false );
} else {
_wp_comment_row( $comment->comment_ID, $mode, false, $checkbox );
}
$comment_list_item = ob_get_contents();
ob_end_clean();

View File

@ -80,7 +80,7 @@ if ( 'index.php' == $pagenow ) {
$breadcrumb = '<a href="index.php">' . __('Dashboard') . '</a> &rsaquo; ' . $title;
}
$settings_pages = array( 'categories.php', 'edit.php', 'edit-comments.php', 'edit-form-advanced.php', 'edit-link-categories.php', 'edit-link-form.php', 'edit-page-form.php', 'edit-tags.php', 'link-manager.php', 'upload.php', 'users.php', 'edit-pages.php', 'post-new.php', 'post.php', 'page-new.php', 'page.php' );
$settings_pages = array( 'categories.php', 'edit.php', 'edit-comments.php', 'edit-form-advanced.php', 'edit-link-categories.php', 'edit-link-form.php', 'edit-page-form.php', 'edit-tags.php', 'link-manager.php', 'upload.php', 'users.php', 'edit-pages.php', 'post-new.php', 'post.php', 'page-new.php', 'page.php', 'index.php' );
?>
<img id="logo50" src="images/logo50.png" alt="" /> <h1><?php if ( '' == get_bloginfo('name', 'display') ) echo '&nbsp;'; else echo get_bloginfo('name', 'display'); ?> <a href="<?php echo trailingslashit( get_bloginfo('url') ); ?>" title="View site" id="view-site-link"><img src="<?php echo trailingslashit( bloginfo('wpurl') ) . 'wp-admin/images/new-window-icon.gif'; ?>" alt="" /></a>

View File

@ -7,7 +7,7 @@
#footer {
background-position:99% 10px;
}
#poststuff .closed .togbox, #poststuff .togbox {
.metabox-holder .closed .togbox, .metabox-holder .togbox, #poststuff .closed .togbox, #poststuff .togbox {
background-image: url(../images/toggle-arrow-rtl.gif) !important;
}
.bar {

View File

@ -62,7 +62,7 @@ li.widget-list-control-item h4.widget-title a,
}
li.widget-list-control-item, div.nav, .tablenav, #dashboard-widgets p.dashboard-widget-links,
.form-table tr, #poststuff h3, #replyhandle,
.form-table tr, #poststuff h3, .metabox-holder h3, #replyhandle,
.login form, h3.info-box-title, #post-status-info, #edit-settings-wrap,
#wpbody-content .describe tr, #edithead, #replyhead {
background-color: #cfebf7;
@ -498,23 +498,23 @@ input.readonly {
color: #333;
}
#poststuff .closed .togbox {
.metabox-holder .closed .togbox, #poststuff .closed .togbox {
background-color: #2583ad;
background-image: url(../images/toggle-arrow.gif);
}
#poststuff .postbox, #titlediv, #poststuff .postarea, #poststuff .stuffbox {
.metabox-holder .postbox, #poststuff .postbox, #titlediv, #poststuff .postarea, #poststuff .stuffbox {
border-color: #ebebeb;
border-right-color: #ccc;
border-bottom-color: #ccc;
}
#poststuff .togbox {
.metabox-holder .togbox, #poststuff .togbox {
background-color: #b2b2b2;
background-image: url(../images/toggle-arrow.gif);
}
#poststuff .postbox {
.metabox-holder .postbox, #poststuff .postbox {
background-color: #FFF;
}

View File

@ -15,7 +15,7 @@
border-right-color: transparent;
border-left-color: #ccc;
}
#poststuff .closed .togbox, #poststuff .togbox {
.metabox-holder .closed .togbox, .metabox-holder .togbox, #poststuff .closed .togbox, #poststuff .togbox {
background-image: url(../images/toggle-arrow-rtl.gif);
}
#upload-menu li.current {

View File

@ -62,7 +62,7 @@ li.widget-list-control-item h4.widget-title a,
}
li.widget-list-control-item, div.nav, .tablenav, #dashboard-widgets p.dashboard-widget-links,
.form-table tr, #poststuff h3, #replyhandle,
.form-table tr, #poststuff h3, .metabox-holder h3, #replyhandle,
.login form, h3.info-box-title, #post-status-info, #edit-settings-wrap,
#wpbody-content .describe tr, #edithead, #replyhead {
background-color: #eaf3fa;
@ -482,23 +482,23 @@ input.readonly {
color: #333;
}
#poststuff .closed .togbox {
.metabox-holder .closed .togbox, #poststuff .closed .togbox {
background-color: #2583ad;
background-image: url(../images/toggle-arrow.gif);
}
#poststuff .postbox, #titlediv, #poststuff .postarea, #poststuff .stuffbox {
.metabox-holder .postbox, #poststuff .postbox, #titlediv, #poststuff .postarea, #poststuff .stuffbox {
border-color: #ebebeb;
border-right-color: #ccc;
border-bottom-color: #ccc;
}
#poststuff .togbox {
.metabox-holder .togbox, #poststuff .togbox {
background-color: #b2b2b2;
background-image: url(../images/toggle-arrow.gif);
}
#poststuff .postbox {
.metabox-holder .postbox, #poststuff .postbox {
background-color: #FFF;
}

View File

@ -1,62 +1 @@
/* Right Now */
#rightnow {
margin-right:0;
margin-left: 7px;
}
#rightnow .reallynow span {
text-align: right;
float: right;
}
#rightnow .reallynow a {
text-align: left;
float: left;
margin: 1px 0 0 6px;
}
/* Widgets */
div#dashboard-widgets-wrap {
margin-right:0;
margin-left:-13px;
}
div.dashboard-widget-holder {
float:right;
}
div.dashboard-widget {
margin-right:0;
margin-left: 20px;
}
h3.dashboard-widget-title span {
text-align: right;
float: right;
}
h3.dashboard-widget-title small {
text-align: left;
float:left;
}
div.dashboard-widget-submit input {
font-family: Tahoma;
}
div.dashboard-widget-content ul, div.dashboard-widget-content ol, div.dashboard-widget-content dl {
padding-left:0;
padding-right:15px;
}
#dashboard_secondary div.dashboard-widget-content ul li {
float:right;
}
#dashboard_secondary div.dashboard-widget-content ul li .post {
font-family:arial;
}
#dashboard_secondary div.dashboard-widget-content ul li a {
border-right:0 none;
border-left: 1px solid #dadada;
height:110px;
}
#dashboard_secondary div.dashboard-widget-content ul li a cite {
font-family: Tahoma;
}
#dashboard-widgets .widget_rss ul li span.rss-date {
float:right;
}
#dashboard-widgets .widget_rss ul li a {
float: right;
margin: 0 0 .2em .5em;
}
/* TODO */

View File

@ -29,214 +29,79 @@ form .textarea-wrap textarea {
width: 99%;
}
/* Widgets */
div#dashboard-widgets-wrap {
margin-right: -13px; /* 20 (div.dashboard-widget margin-right) - 7 (#rightnow margin-right) */
form p.field-tip {
font-size: .9em;
font-style: italic;
margin: 0;
padding: 0;
}
div#dashboard-widgets {
width: 100%;
}
div.dashboard-widget-holder {
margin-bottom: 20px;
width: 50%;
float: left;
}
div.dashboard-widget-holder.third {
width: 33.3%;
}
div.dashboard-widget-holder.fourth {
width: 25%;
}
div.dashboard-widget-holder.full {
width: 100%;
}
div.dashboard-widget-holder.double div.dashboard-widget {
height: 54em;
padding-bottom: 28px /* lame */
}
div.dashboard-widget {
position: relative;
margin-right: 20px;
border-width: 1px;
border-style: solid;
height: 27em;
overflow: auto;
font-size: 11px;
}
#dashboard-widgets p.dashboard-widget-links {
padding: 2px;
font-size: 11px;
line-height: 2;
border-width: 1px;
margin: 0 20px 0 0;
padding: 0 7px;
border: 1px solid;
border-top: none;
}
h3.dashboard-widget-title {
margin: 2px;
padding: 0 7px;
font-size: 14px;
line-height: 2;
}
h3.dashboard-widget-title span {
display: block;
text-align: left;
float: left;
}
h3.dashboard-widget-title small {
display: block;
text-align: right;
float: right;
font-size: 75%;
line-height: 2.67; /* math: it works, bitches */
}
p.dashboard-widget-links img.rss-icon {
vertical-align: middle;
}
div.dashboard-widget-notice {
padding: 0 14px;
font-size: 1.2em;
line-height: 2;
}
div.dashboard-widget-error {
padding: 0 20px;
font-size: 1.2em;
line-height: 2;
}
div.dashboard-widget-content {
padding: 10px 15px;
}
div.dashboard-widget-submit {
border-top: 1px solid #ccc;
padding: 1em 0 0 0;
margin: 10px 0 0 0;
}
div.dashboard-widget-submit input {
font-family: "Lucida Grande", "Lucida Sans Unicode", Tahoma, Verdana, sans-serif;
padding: 4px 6px;
#dashboard-widgets .postbox form .submit {
float: none;
margin: .5em 0 0;
padding: 0;
border: none;
font-size: 13px;
-moz-border-radius: 3px;
-khtml-border-radius: 3px;
-webkit-border-radius: 3px;
border-radius: 3px;
cursor: pointer;
text-decoration: none;
}
div.dashboard-widget-content ul, div.dashboard-widget-content ol, div.dashboard-widget-content dl {
margin: 0;
text-indent: 0;
padding-left: 15px;
}
div.dashboard-widget-content li {
margin: .5em 0 1em;
}
div.dashboard-widget-content blockquote {
margin: -1em 0;
}
div#dashboard_recent_comments p {
font-size: 14px;
}
div.dashboard-widget-content p.comment-meta {
font-size: 11px !important;
}
#dashboard_secondary div.dashboard-widget {
height: auto;
}
#dashboard_secondary div.dashboard-widget-content ul {
list-style: none;
padding: 0;
}
#dashboard_secondary div.dashboard-widget-content ul li {
display: block;
width: 19.95%;
padding-bottom: 10px;
margin: 0;
float: left;
font-size: 95%;
}
#dashboard_secondary div.dashboard-widget-content {
margin: 10px 5px;
padding: 0;
}
#dashboard_secondary div.dashboard-widget-content ul li .post {
display:block;
font-family:Georgia,"Times New Roman",Times,serif;
font-size:18px;
line-height: 1.2em;
height:90px;
overflow:hidden;
}
#dashboard_secondary div.dashboard-widget-content ul li a {
display: block;
height:100%;
overflow:hidden;
margin: 5px 10px;
text-decoration: none;
padding: .5em;
border-right: 1px solid #dadada;
border-bottom: 1px solid #dadada;
}
#dashboard_secondary div.dashboard-widget-content ul li a cite {
display: block;
font-family: "Lucida Sans", "Lucida Grande", "Lucida Sans Unicode", Tahoma, Verdana, sans-serif;
}
#dashboard-widgets .widget_rss ul {
list-style: none;
padding: 0;
}
#dashboard-widgets .widget_rss ul li {
clear: both;
}
#dashboard-widgets .widget_rss ul li span.rss-date {
float: left;
#dashboard-widgets-wrap #dashboard-widgets .postbox form .submit input {
margin: 0;
}
#dashboard-widgets .widget_rss ul li a {
float: left;
margin: 0 .5em .2em 0;
font-weight: bold;
#dashboard-widgets-wrap #dashboard-widgets .postbox form .submit #publish {
min-width: 0;
}
#dashboard-widgets .widget_rss ul li div {
clear: both;
line-height: 1.5em;
div.postbox div.inside {
margin: 0 10px 10px;
position: relative;
}
.view-all {
position: absolute;
top: 0;
right: 0;
padding: 0;
margin: 0;
}
#dashboard-widgets h4 {
font-size: 1em;
margin: 0 0 .2em;
padding: 0;
}
/* Recent Comments */
#the-comment-list {
position: relative;
}
#the-comment-list .comment-item {
padding: 5px 5px 5px 47px;
}
#the-comment-list .comment-item .avatar {
position: absolute;
left: 5px;
}
#the-comment-list .comment-item blockquote, #the-comment-list .comment-item blockquote p {
margin: 0;
padding: 0;
display: inline;
}
#dashboard_recent_comments #the-comment-list .trackback blockquote, #dashboard_recent_comments #the-comment-list .pingback blockquote {
display: block;
}
#the-comment-list .comment-item p.comment-actions {
margin: 0;
padding: 0;
}
/* Primary Feed */
#dashboard_primary a.rsswidget, #dashboard_plugins h5 {
font-size: 14px;
}
@ -245,10 +110,7 @@ div.dashboard-widget-content p.comment-meta {
font-size: 14px;
}
#dashboard_plugins h4 {
font-size: 1em;
margin: 0 0 .1em;
}
/* Plugins */
#dashboard_plugins h5 {
margin: 0;
@ -260,41 +122,3 @@ div.dashboard-widget-content p.comment-meta {
margin: 0 0 1em;
line-height: 1.5em;
}
#dashboard_inbox div.dashboard-widget, #dashboard_quick_press div.dashboard-widget {
height: 35em;
padding-bottom: 0;
}
#dashboard_quick_press div.dashboard-widget-content {
padding-bottom: 0;
}
#dashboard_inbox p.actions {
margin-bottom:0pt;
margin-top: 0;
float:left;
}
#dashboard_quick_press h3 {
margin-bottom: 3px;
}
#dashboard_quick_press h3#quick-post-title {
margin-top: 0;
}
#dashboard_quick_press p.field-tip {
margin-top: 0;
font-style: italic;
}
#dashboard_quick_press .submit {
padding: 0 0 1em 0;
border-top: none;
border-bottom: 1px solid #ccc;
}
#dashboard_quick_press p#recent-drafts {
margin: 0;
}

View File

@ -1,4 +1,4 @@
#poststuff .postbox h3 {
.metabox-holder .postbox h3, #poststuff .postbox h3 {
padding-left:0;
padding-right: 23px;
}
@ -20,7 +20,7 @@ div#dashboard-widgets {
#tagchecklist span a {
margin: 4px -9px 0 0;
}
#poststuff .togbox {
.metabox-holder .togbox, #poststuff .togbox {
margin-left:0;
margin-right: -19px;
}

View File

@ -1,6 +1,6 @@
/* Fixes for IE bugs */
#poststuff .postbox h3 {
.metabox-holder .postbox h3, #poststuff .postbox h3 {
padding-left: 23px;
}
@ -31,7 +31,7 @@
position: relative;
}
#wpwrap, #wpcontent, #post, #wrap, #postdivrich, #postdiv, #poststuff, #titlediv, #post-body, #editorcontainer, .tablenav, .widget-control-list, li.widget-list-control-item, #dragHelper, li.widget-list-control-item h4, .widget-sortable, .widget-control-actions {
#wpwrap, #wpcontent, #post, #wrap, #postdivrich, #postdiv, #poststuff, .metabox-holder, #titlediv, #post-body, #editorcontainer, .tablenav, .widget-control-list, li.widget-list-control-item, #dragHelper, li.widget-list-control-item h4, .widget-sortable, .widget-control-actions {
display: block;
zoom: 100%;
}
@ -88,7 +88,7 @@ div#dashboard-widgets {
margin: 4px 0 0 -9px;
}
#poststuff .togbox {
.metabox-holder .togbox, #poststuff .togbox {
margin-left: -19px;
}

View File

@ -445,7 +445,7 @@ else
<?php echo $form_extra ?>
<div id="poststuff">
<div id="poststuff" class="metabox-holder">
<div id="side-info" style="display: none;"><?php // TODO ?>

View File

@ -19,7 +19,7 @@ $form_extra = "' />\n<input type='hidden' name='comment_ID' value='" . $comment-
<?php wp_nonce_field('update-comment_' . $comment->comment_ID) ?>
<div class="wrap">
<div id="poststuff">
<div id="poststuff" class="metabox-holder">
<input type="hidden" name="user_ID" value="<?php echo (int) $user_ID ?>" />
<input type="hidden" name="action" value='<?php echo $form_action . $form_extra ?>' />
<?php

View File

@ -309,7 +309,7 @@ wp_nonce_field( $nonce_action );
wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false );
wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false ); ?>
<div id="poststuff">
<div id="poststuff" class="metabox-holder">
<div id="side-info-column" class="inner-sidebar">
<?php

View File

@ -347,7 +347,7 @@ if ( current_user_can('publish_pages') OR ( $post->post_status == 'publish' AND
-->
<div id="poststuff">
<div id="poststuff" class="metabox-holder">
<div id="side-info-column" class="inner-sidebar">

View File

@ -14,57 +14,24 @@
* @since unknown
*/
function wp_dashboard_setup() {
global $wpdb, $wp_dashboard_sidebars;
global $wp_registered_widgets, $wp_registered_widget_controls, $wp_dashboard_control_callbacks;
$wp_dashboard_control_callbacks = array();
$update = false;
$widget_options = get_option( 'dashboard_widget_options' );
if ( !$widget_options || !is_array($widget_options) )
$widget_options = array();
/* Register WP Dashboard Dynamic Sidebar */
register_sidebar( array(
'name' => 'WordPress Dashboard',
'id' => 'wp_dashboard',
'before_widget' => "\t<div class='dashboard-widget-holder %2\$s' id='%1\$s'>\n\n\t\t<div class='dashboard-widget'>\n\n",
'after_widget' => "\t\t</div>\n\n\t</div>\n\n",
'before_title' => "\t\t\t<h3 class='dashboard-widget-title'>",
'after_title' => "</h3>\n\n"
) );
/* Register Widgets and Controls */
// Recent Comments Widget
$mod_comments = wp_count_comments();
$mod_comments = $mod_comments->moderated;
if ( current_user_can( 'moderate_comments' ) && $mod_comments ) {
$notice = sprintf( __ngettext( '%d comment awaiting moderation', '%d comments awaiting moderation', $mod_comments ), $mod_comments );
$notice = "<a href='edit-comments.php?comment_status=moderated'>$notice</a>";
} else {
$notice = '';
}
wp_register_sidebar_widget( 'dashboard_recent_comments', __( 'Recent Comments' ), 'wp_dashboard_recent_comments',
array( 'all_link' => 'edit-comments.php', 'notice' => $notice, 'width' => 'half' )
);
wp_add_dashboard_widget( 'dashboard_recent_comments', __( 'Recent Comments' ), 'wp_dashboard_recent_comments' );
// 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. <a href="%s">View post</a> | <a href="%s">Edit post</a>' ), clean_url( $view ), $edit );
else
$notice = sprintf( __( 'Draft Saved. <a href="%s">Preview post</a> | <a href="%s">Edit post</a>' ), 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' )
);
wp_add_dashboard_widget( 'dashboard_quick_press', __( 'QuickPress' ), 'wp_dashboard_quick_press', 'wp_dashboard_empty_control' );
// Recent Drafts
wp_add_dashboard_widget( 'dashboard_recent_drafts', __( 'Recent Drafts' ), 'wp_dashboard_recent_drafts' );
// 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') ) {
@ -77,21 +44,11 @@ function wp_dashboard_setup() {
'show_date' => 0
);
}
wp_register_sidebar_widget( 'dashboard_incoming_links', __( 'Incoming Links' ), 'wp_dashboard_empty',
array( 'all_link' => $widget_options['dashboard_incoming_links']['link'], 'feed_link' => $widget_options['dashboard_incoming_links']['url'], 'width' => 'half' ),
'wp_dashboard_cached_rss_widget', 'wp_dashboard_incoming_links_output'
);
wp_register_widget_control( 'dashboard_incoming_links', __( 'Incoming Links' ), 'wp_dashboard_rss_control', array(),
array( 'widget_id' => 'dashboard_incoming_links', 'form_inputs' => array( 'title' => false, 'show_summary' => false, 'show_author' => false ) )
);
wp_add_dashboard_widget( 'dashboard_incoming_links', __( 'Incoming Links' ), 'wp_dashboard_incoming_links', 'wp_dashboard_incoming_links_control' );
// WP Plugins Widget
wp_register_sidebar_widget( 'dashboard_plugins', __( 'Plugins' ), 'wp_dashboard_empty',
array( 'all_link' => 'http://wordpress.org/extend/plugins/', 'feed_link' => 'http://wordpress.org/extend/plugins/rss/topics/', 'width' => 'half' ),
'wp_dashboard_cached_rss_widget', 'wp_dashboard_plugins_output',
array( 'http://wordpress.org/extend/plugins/rss/browse/popular/', 'http://wordpress.org/extend/plugins/rss/browse/new/', 'http://wordpress.org/extend/plugins/rss/browse/updated/' )
);
if ( current_user_can( 'activate_plugins' ) )
wp_add_dashboard_widget( 'dashboard_plugins', __( 'Plugins' ), 'wp_dashboard_plugins' );
// Primary feed (Dev Blog) Widget
if ( !isset( $widget_options['dashboard_primary'] ) ) {
@ -106,14 +63,7 @@ function wp_dashboard_setup() {
'show_date' => 1
);
}
wp_register_sidebar_widget( 'dashboard_primary', $widget_options['dashboard_primary']['title'], 'wp_dashboard_empty',
array( 'all_link' => $widget_options['dashboard_primary']['link'], 'feed_link' => $widget_options['dashboard_primary']['url'], 'width' => 'half', 'class' => 'widget_rss' ),
'wp_dashboard_cached_rss_widget', 'wp_dashboard_rss_output'
);
wp_register_widget_control( 'dashboard_primary', __( 'Primary Feed' ), 'wp_dashboard_rss_control', array(),
array( 'widget_id' => 'dashboard_primary' )
);
wp_add_dashboard_widget( 'dashboard_primary', $widget_options['dashboard_primary']['title'], 'wp_dashboard_primary', 'wp_dashboard_primary_control' );
// Secondary Feed (Planet) Widget
if ( !isset( $widget_options['dashboard_secondary'] ) ) {
@ -125,64 +75,13 @@ function wp_dashboard_setup() {
'items' => 15
);
}
wp_register_sidebar_widget( 'dashboard_secondary', $widget_options['dashboard_secondary']['title'], 'wp_dashboard_empty',
array( 'all_link' => $widget_options['dashboard_secondary']['link'], 'feed_link' => $widget_options['dashboard_secondary']['url'], 'width' => 'full' ),
'wp_dashboard_cached_rss_widget', 'wp_dashboard_secondary_output'
);
wp_register_widget_control( 'dashboard_secondary', __( 'Secondary Feed' ), 'wp_dashboard_rss_control', array(),
array( 'widget_id' => 'dashboard_secondary', 'form_inputs' => array( 'show_summary' => false, 'show_author' => false, 'show_date' => false ) )
);
/* Dashboard Widget Template
wp_register_sidebar_widget( $widget_id (unique slug) , $widget_title, $output_callback,
array(
'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'),
),
$wp_dashboard_empty_callback (only needed if using 'wp_dashboard_empty' as your $output_callback),
$arg, $arg, $arg... (further args passed to callbacks)
);
// optional: if you want users to be able to edit the settings of your widget, you need to register a widget_control
wp_register_widget_control( $widget_id, $widget_control_title, $control_output_callback,
array(), // leave an empty array here: oddity in widget code
array(
'widget_id' => $widget_id, // Yes - again. This is required: oddity in widget code
'arg' => an arg to pass to the $control_output_callback,
'another' => another arg to pass to the $control_output_callback,
...
)
);
*/
wp_add_dashboard_widget( 'dashboard_secondary', $widget_options['dashboard_secondary']['title'], 'wp_dashboard_secondary', 'wp_dashboard_secondary_control' );
// Hook to register new widgets
do_action( 'wp_dashboard_setup' );
// Hard code the sidebar's widgets and order
$dashboard_widgets = array();
$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 );
add_filter( 'dynamic_sidebar_params', 'wp_dashboard_dynamic_sidebar_params' );
$dashboard_widgets = apply_filters( 'wp_dashboard_widgets', array() );
if ( 'POST' == $_SERVER['REQUEST_METHOD'] && isset($_POST['widget_id']) ) {
ob_start(); // hack - but the same hack wp-admin/widgets.php uses
@ -194,6 +93,33 @@ function wp_dashboard_setup() {
if ( $update )
update_option( 'dashboard_widget_options', $widget_options );
foreach ( $dashboard_widgets as $widget_id )
wp_add_dashboard_widget( $widget_id, $wp_registered_widgets[$widget_id]['name'], $wp_registered_widgets[$widget_id]['callback'], $wp_registered_widget_controls[$widget_id]['callback'] );
}
function wp_add_dashboard_widget( $widget_id, $widget_name, $callback, $control_callback = null ) {
global $wp_dashboard_control_callbacks;
if ( $control_callback && current_user_can( 'edit_dashboard' ) && is_callable( $control_callback ) ) {
$wp_dashboard_control_callbacks[$widget_id] = $control_callback;
if ( isset( $_GET['edit'] ) && $widget_id == $_GET['edit'] ) {
list($url) = explode( '#', add_query_arg( 'edit', false ), 2 );
$widget_name .= ' <a href="' . clean_url( $url ) . '">' . __( 'Cancel' ) . '</a>';
add_meta_box( $widget_id, $widget_name, '_wp_dashboard_control_callback', 'dashboard', 'normal', 'core' );
return;
}
list($url) = explode( '#', add_query_arg( 'edit', $widget_id ), 2 );
$widget_name .= ' <a href="' . clean_url( "$url#$widget_id" ) . '" class="open-box">' . __( 'Edit' ) . '</a>';
}
add_meta_box( $widget_id, $widget_name , $callback, 'dashboard', 'normal', 'core' );
}
function _wp_dashboard_control_callback( $dashboard, $meta_box ) {
echo '<form action="" method="post">';
wp_dashboard_trigger_widget_control( $meta_box['id'] );
echo "<p class='submit'><input type='hidden' name='widget_id' value='$meta_box[id]' /><input type='submit' value='" . __( 'Sumbit' ) . "' /></p>";
echo '</form>';
}
/**
@ -202,153 +128,66 @@ function wp_dashboard_setup() {
* @since unknown
*/
function wp_dashboard() {
echo "<div id='dashboard-widgets'>\n\n";
echo "<div id='dashboard-widgets' class='metabox-holder'>\n\n";
// We're already filtering dynamic_sidebar_params obove
add_filter( 'option_sidebars_widgets', 'wp_dashboard_sidebars_widgets' ); // here there be hackery
dynamic_sidebar( 'wp_dashboard' );
remove_filter( 'option_sidebars_widgets', 'wp_dashboard_sidebars_widgets' );
echo "<div id='side-info-column' class='inner-sidebar'>\n\n";
$class = do_meta_boxes( 'dashboard', 'side', '' ) ? ' class="has-sidebar"' : '';
echo "</div>\n\n";
echo "<br class='clear' />\n</div>\n\n\n";
echo "<div id='post-body'$class>\n\n";
echo "<div id='dashboard-widgets-main-content' class='has-sidebar-content'>\n\n";
do_meta_boxes( 'dashboard', 'normal', '' );
echo "</div>\n\n";
echo "</div>\n\n";
echo "<form style='display: none' method='get' action=''>\n<p>\n";
wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false );
wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false );
echo "</p>\n</form>\n";
}
/**
* Makes sidebar_widgets option reflect the dashboard settings.
*
* @since unknown
*
* @return array WordPress Dashboard Widgets list.
*/
function wp_dashboard_sidebars_widgets() { // hackery
return $GLOBALS['wp_dashboard_sidebars'];
}
// Modifies sidbar params on the fly to set up ids, class names, titles for each widget (called once per widget)
// Switches widget to edit mode if $_GET['edit']
/**
* {@internal Missing Short Description}}
*
* @since unknown
*
* @param unknown_type $params
* @return unknown
*/
function wp_dashboard_dynamic_sidebar_params( $params ) {
global $wp_registered_widgets, $wp_registered_widget_controls;
$sidebar_defaults = array('widget_id' => 0, 'before_widget' => '', 'after_widget' => '', 'before_title' => '', 'after_title' => '');
extract( $sidebar_defaults, EXTR_PREFIX_ALL, 'sidebar' );
extract( $params[0], EXTR_PREFIX_ALL, 'sidebar' );
if ( !isset($wp_registered_widgets[$sidebar_widget_id]) || !is_array($wp_registered_widgets[$sidebar_widget_id]) ) {
return $params;
}
$widget_defaults = array('id' => '', 'width' => '', 'height' => '', 'class' => '', 'feed_link' => '', 'all_link' => '', 'notice' => false, 'error' => false);
extract( $widget_defaults, EXTR_PREFIX_ALL, 'widget' );
extract( $wp_registered_widgets[$sidebar_widget_id], EXTR_PREFIX_ALL, 'widget' );
$the_classes = array();
if ( in_array($widget_width, array( 'third', 'fourth', 'full' ) ) )
$the_classes[] = $widget_width;
if ( 'double' == $widget_height )
$the_classes[] = 'double';
if ( $widget_class )
$the_classes[] = $widget_class;
// Add classes to the widget holder
if ( $the_classes )
$sidebar_before_widget = str_replace( "<div class='dashboard-widget-holder ", "<div class='dashboard-widget-holder " . join( ' ', $the_classes ) . ' ', $sidebar_before_widget );
$top_links = $bottom_links = array();
if ( $widget_all_link ) {
$widget_all_link = (array) $widget_all_link;
$bottom_links[] = '<a href="' . clean_url( $widget_all_link[0] ) . '">' . ( isset($widget_all_link[1]) ? $widget_all_link[1] : __( 'View All' ) ) . '</a>';
}
$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']) ) {
// Switch this widget to edit mode
if ( isset($_GET['edit']) && $_GET['edit'] == $widget_id ) {
$content_class .= ' dashboard-widget-control';
$wp_registered_widgets[$widget_id]['callback'] = 'wp_dashboard_empty';
$sidebar_widget_name = $wp_registered_widget_controls[$widget_id]['name'];
$params[1] = 'wp_dashboard_trigger_widget_control';
$sidebar_before_widget .= '<form action="' . clean_url(remove_query_arg( 'edit' )) . '" method="post">';
$sidebar_after_widget = "<div class='dashboard-widget-submit'><input type='hidden' name='sidebar' value='wp_dashboard' /><input type='hidden' name='widget_id' value='$widget_id' /><input type='submit' value='" . __( 'Save' ) . "' /></div></form>$sidebar_after_widget";
$top_links[] = '<a href="' . clean_url(remove_query_arg( 'edit' )) . '">' . __( 'Cancel' ) . '</a>';
} else {
$top_links[] = '<a href="' . clean_url(add_query_arg( 'edit', $widget_id )) . "#$widget_id" . '">' . __( 'Edit' ) . '</a>';
}
}
if ( $widget_feed_link )
$bottom_links[] = '<img class="rss-icon" src="' . includes_url('images/rss.png') . '" alt="' . __( 'rss icon' ) . '" /> <a href="' . clean_url( $widget_feed_link ) . '">' . __( 'RSS' ) . '</a>';
$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 )
$sidebar_after_title .= "\t\t\t<div class='dashboard-widget-notice'>$widget_notice</div>\n\n";
if ( $widget_error )
$sidebar_after_title .= "\t\t\t<div class='dashboard-widget-error'>$widget_error</div>\n\n";
$sidebar_after_title .= "\t\t\t<div class='$content_class'>\n\n";
// Add links to widget's title bar
if ( $top_links ) {
$sidebar_before_title .= '<span>';
$sidebar_after_title = '</span><small>' . join( '&nbsp;|&nbsp;', $top_links ) . "</small><br class='clear' />$sidebar_after_title";
}
// Add links to bottom of widget
if ( $bottom_links )
$sidebar_after_widget .= "<p class='dashboard-widget-links'>" . join( ' | ', $bottom_links ) . "</p>";
$sidebar_after_widget .= "\t\t\t</div>\n\n";
foreach( array_keys( $params[0] ) as $key )
$$key = ${'sidebar_' . $key};
$params[0] = compact( array_keys( $params[0] ) );
return $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();
function wp_dashboard_quick_press( $dashboard, $meta_box ) {
$drafts = false;
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'] ) {
printf( __( 'Post Published. <a href="%s">View post</a> | <a href="%s">Edit post</a>' ), clean_url( $view ), $edit );
} else {
printf( __( 'Draft Saved. <a href="%s">Preview post</a> | <a href="%s">Edit post</a>' ), clean_url( add_query_arg( 'preview', 1, $view ) ), $edit );
$drafts_query = new WP_Query( array(
'post_type' => 'post',
'what_to_show' => 'posts',
'post_status' => 'draft',
'author' => $GLOBALS['current_user']->ID,
'posts_per_page' => 1,
'orderby' => 'modified',
'order' => 'DESC'
) );
if ( $drafts_query->posts )
$drafts =& $drafts_query->posts;
}
$_REQUEST = array(); // hack for get_default_post_to_edit()
}
$post = get_default_post_to_edit();
?>
<form name="post" action="<?php echo clean_url( admin_url( 'post.php' ) ); ?>" method="post" id="quick-press">
<h3 id="quick-post-title"><label for="title"><?php _e('Title') ?></label></h3>
<h4 id="quick-post-title"><label for="title"><?php _e('Title') ?></label></h4>
<div class="input-text-wrap">
<input type="text" name="post_title" id="title" autocomplete="off" value="<?php echo attribute_escape( $post->post_title ); ?>" />
</div>
<h3><label for="content"><?php _e('Post') ?></label></h3>
<h4><label for="content"><?php _e('Post') ?></label></h4>
<div class="textarea-wrap">
<textarea name="content" id="quickpress-content" class="mceEditor" rows="3" cols="15"><?php echo $post->post_content; ?></textarea>
</div>
<h3><label for="tags-input"><?php _e('Tags') ?></label></h3>
<h4><label for="tags-input"><?php _e('Tags') ?></label></h4>
<div class="input-text-wrap">
<input type="text" name="tags_input" id="tags-input" value="<?php echo get_tags_to_edit( $post->ID ); ?>" />
</div>
@ -358,152 +197,178 @@ function wp_dashboard_quick_press( $sidebar_args ) {
<input type="hidden" name="action" id="quickpost-action" value="post-quickpress-save" />
<input type="hidden" name="quickpress_post_ID" value="<?php echo (int) $post->ID; ?>" />
<?php wp_nonce_field('add-post'); ?>
<input type="submit" name="save" id="save-post" class="button" value="<?php _e('Save'); ?>" />
<input type="submit" name="save-cont" id="save-cont" class="button" value="<?php _e('Save and Continue'); ?>" />
<input type="submit" name="publish" id="publish" accesskey="p" class="button button-highlighted" value="<?php _e('Publish'); ?>" />
<input type="submit" name="save" id="save-post" class="button alignleft" value="<?php _e('Save Draft'); ?>" />
<input type="submit" name="publish" id="publish" accesskey="p" class="button button-highlighted alignright" value="<?php _e('Publish'); ?>" />
<br class="clear" />
</p>
<?php
$drafts_query = new WP_Query( array(
'post_type' => 'post',
'what_to_show' => 'posts',
'post_status' => 'draft',
'author' => $GLOBALS['current_user']->ID,
'posts_per_page' => 5,
'orderby' => 'modified',
'order' => 'DESC'
) );
</form>
if ( $drafts_query->posts ) :
<?php
if ( $drafts )
wp_dashboard_recent_drafts( $drafts );
}
function wp_dashboard_recent_drafts( $drafts = false ) {
if ( !$drafts ) {
$drafts_query = new WP_Query( array(
'post_type' => 'post',
'what_to_show' => 'posts',
'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_query->posts as $draft ) {
foreach ( $drafts as $draft ) {
$url = get_edit_post_link( $draft->ID );
$title = _draft_or_post_title( $draft->ID );
$list[] = "<a href='$url' title='" . sprintf( __( 'Edit "%s"' ), attribute_escape( $title ) ) . "'>$title</a>";
}
?>
<h3><?php _e('Recent Drafts'); ?></h3>
<p id='recent-drafts'>
<?php echo join( ', ', $list ); ?>
</p>
<ul>
<li><?php echo join( "</li>\n<li>", $list ); ?></li>
</ul>
<?php
endif; // drafts
?>
</form>
<?php
echo $after_widget;
}
function wp_dashboard_quick_press_js() {
?>
<script type="text/javascript">
/* <![CDATA[ */
var quickPressLoad = function($) {
var act = $('#quickpost-action');
var t = $('#quick-press').submit( function() {
if ( 'post-quickpress-save-cont' == act.val() ) {
return true;
}
var head = $('#dashboard_quick_press div.dashboard-widget').children( 'div').hide().end().find('h3 small');
head.prepend( '<img src="images/loading.gif" style="margin: 0 6px 0 0; vertical-align: middle" />' );
if ( 'post' == act.val() ) { act.val( 'post-quickpress-publish' ); }
if ( 'undefined' != typeof tinyMCE ) {
tinyMCE.get('quickpress-content').save();
tinyMCE.get('quickpress-content').remove();
}
$('#dashboard_quick_press').load( t.attr( 'action' ) + ' #dashboard_quick_press > *', t.serializeArray(), function() {
if ( 'undefined' != typeof wpTeenyMCEInit && $.isFunction( wpTeenyMCEInit ) ) { wpTeenyMCEInit(); }
quickPressLoad($);
} );
return false;
} );
$('#publish').click( function() { act.val( 'post-quickpress-publish' ); } );
$('#save-cont').click( function() { act.val( 'post-quickpress-save-cont' ); t.attr( 'action', 'post.php' ); } );
};
jQuery( quickPressLoad );
/* ]]> */
</script>
<?php
}
/**
* Display recent comments dashboard widget content.
*
* @since unknown
*
* @param unknown_type $sidebar_args
*/
function wp_dashboard_recent_comments( $sidebar_args ) {
global $comment;
extract( $sidebar_args, EXTR_SKIP );
function wp_dashboard_recent_comments() {
list($comments, $total) = _wp_get_comment_list( '', false, 0, 5 );
echo $before_widget;
echo $before_title;
echo $widget_name;
echo $after_title;
$lambda = create_function( '', 'return 5;' );
add_filter( 'option_posts_per_rss', $lambda ); // hack - comments query doesn't accept per_page parameter
$comments_query = new WP_Query(array('feed' => 'rss2', 'withcomments' => 1));
remove_filter( 'option_posts_per_rss', $lambda );
$is_first = true;
if ( $comments_query->have_comments() ) {
while ( $comments_query->have_comments() ) { $comments_query->the_comment();
$comment_post_url = get_permalink( $comment->comment_post_ID );
$comment_post_title = get_the_title( $comment->comment_post_ID );
$comment_post_link = "<a href='$comment_post_url'>$comment_post_title</a>";
$comment_link = '<a class="comment-link" href="' . get_comment_link() . '">#</a>';
$comment_meta = sprintf( __( 'From <strong>%1$s</strong> on %2$s %3$s' ), get_comment_author(), $comment_post_link, $comment_link );
if ( $is_first ) : $is_first = false;
?>
<blockquote><p>&#8220;<?php comment_excerpt(); ?>&#8221;</p></blockquote>
<p class='comment-meta'><?php echo $comment_meta; ?></p>
<?php
if ( $comments_query->comment_count > 1 ) : ?>
<ul id="dashboard-comments-list">
<?php
endif; // comment_count
else : // is_first
if ( $comments ) :
?>
<li class='comment-meta'><?php echo $comment_meta; ?></li>
<p class="view-all"><a href="edit-comments.php"><?php _e( 'View All Comments' ); ?></a></p>
<div id="the-comment-list" class="list:comment">
<?php
endif; // is_first
foreach ( $comments as $comment )
_wp_dashboard_recent_comments_row( $comment );
?>
</div>
<?php
wp_comment_reply( -1, false, 'dashboard', false );
else :
?>
<p><?php _e( 'No comments yet.' ); ?></p>
<?php
endif; // $comments;
}
function _wp_dashboard_recent_comments_row( &$comment, $show_date = true ) {
static $date = false;
static $today = false;
static $yesterday = false;
$GLOBALS['comment'] =& $comment;
if ( $show_date ) {
if ( !$today )
$today = gmdate( get_option( 'date_format' ), time() + get_option( 'gmt_offset' ) );
if ( !$yesterday )
$yesterday = gmdate( get_option( 'date_format' ), strtotime( 'yesterday' ) + get_option( 'gmt_offset' ) );
$wordy_dates = array( $today => __( 'Today' ), $yesterday => __( 'Yesterday' ) );
$comment_date = gmdate( get_option( 'date_format' ), strtotime( $comment->comment_date ) + get_option( 'gmt_offset' ) );
if ( $comment_date != $date ) {
$date = $comment_date;
echo '<h4>' . ( isset( $wordy_dates[$date] ) ? $wordy_dates[$date] : $date ) . ":</h4>\n";
}
if ( $comments_query->comment_count > 1 ) : ?>
</ul>
<?php
endif; // comment_count;
}
echo $after_widget;
$comment_post_url = get_permalink( $comment->comment_post_ID );
$comment_post_title = get_the_title( $comment->comment_post_ID );
$comment_post_link = "<a href='$comment_post_url'>$comment_post_title</a>";
$comment_link = '<a class="comment-link" href="' . get_comment_link() . '">#</a>';
$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" ) );
$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" ) );
$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" ) );
$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" ) );
$actions = array();
if ( current_user_can('edit_post', $comment->comment_post_ID) ) {
$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>';
$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>';
$actions['edit'] = "<a href='comment.php?action=editcomment&amp;c={$comment->comment_ID}' title='" . __('Edit comment') . "'>". __('Edit') . '</a>';
$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' ) . "'>" . __( 'Spam' ) . '</a>';
$actions['delete'] = "<a href='$delete_url' class='delete:the-comment-list:comment-$comment->comment_ID delete vim-d vim-destructive'>" . __('Delete') . '</a>';
$actions['reply'] = '<a onclick="commentReply.open(\''.$comment->comment_ID.'\',\''.$comment->comment_post_ID.'\');return false;" class="vim-r" title="'.__('Reply to this comment').'" href="#">' . __('Reply') . '</a>';
$actions = apply_filters( 'comment_row_actions', $actions, $comment );
$i = 0;
$actions_string = '';
foreach ( $actions as $action => $link ) {
++$i;
( ( ('approve' == $action || 'unapprove' == $action) && 2 === $i ) || 1 === $i ) ? $sep = '' : $sep = ' | ';
// Reply and quickedit need a hide-if-no-js span
if ( 'reply' == $action || 'quickedit' == $action )
$action .= ' hide-if-no-js';
$actions_string .= "<span class='$action'>$sep$link</span>";
}
}
?>
<div id="comment-<?php echo $comment->comment_ID; ?>" <?php comment_class( array( 'comment-item', wp_get_comment_status() ) ); ?>>
<?php if ( !$comment->comment_type || 'comment' == $comment->comment_type ) : ?>
<?php echo get_avatar( $comment, 32 ); ?>
<span class="comment-meta"><?php printf( __( '%1$s in response to %2$s:' ), '<cite>' . get_comment_author() . '</cite>', $comment_post_link ); ?></span>
<?php
else :
switch ( $comment->comment_type ) :
case 'pingback' :
$type = __( 'Pingback' );
break;
case 'trackback' :
$type = __( 'Trackback' );
break;
default :
$type = ucwords( $comment->comment_type );
endswitch;
$type = wp_specialchars( $type );
?>
<span class="comment-meta"><?php printf( __( '%3$s on %2$s: %1$s' ), '<cite>' . get_comment_author() . '</cite>', $comment_post_link, "<strong>$type</strong>" ); ?></span>
<?php endif; // comment_type ?>
<blockquote><p><?php comment_excerpt(); ?></p></blockquote>
<p class="comment-actions"><?php echo $actions_string; ?></p>
</div>
<?php
}
function wp_dashboard_incoming_links() {
wp_dashboard_cached_rss_widget( 'dashboard_incoming_links', 'wp_dashboard_incoming_links_output' );
}
/**
* Display incoming links dashboard widget content.
*
* $sidebar_args are handled by wp_dashboard_empty().
*
* @since unknown
*/
function wp_dashboard_incoming_links_output() {
@ -565,11 +430,21 @@ function wp_dashboard_incoming_links_output() {
}
}
function wp_dashboard_incoming_links_control() {
wp_dashboard_rss_control( 'dashboard_incoming_links', array( 'title' => false, 'show_summary' => false, 'show_author' => false ) );
}
function wp_dashboard_primary() {
wp_dashboard_cached_rss_widget( 'dashboard_primary', 'wp_dashboard_rss_output' );
}
function wp_dashboard_primary_control() {
wp_dashboard_rss_control( 'dashboard_primary' );
}
/**
* {@internal Missing Short Description}}
*
* $sidebar_args are handled by wp_dashboard_empty().
*
* @since unknown
*
* @param int $widget_id
@ -579,11 +454,17 @@ function wp_dashboard_rss_output( $widget_id ) {
wp_widget_rss_output( $widgets[$widget_id] );
}
function wp_dashboard_secondary() {
wp_dashboard_cached_rss_widget( 'dashboard_secondary', 'wp_dashboard_secondary_output' );
}
function wp_dashboard_secondary_control() {
wp_dashboard_rss_control( 'dashboard_secondary', array( 'show_summary' => false, 'show_author' => false, 'show_date' => false ) );
}
/**
* Display secondary dashboard RSS widget feed.
*
* $sidebar_args are handled by wp_dashboard_empty().
*
* @since unknown
*
* @return unknown
@ -609,11 +490,17 @@ function wp_dashboard_secondary_output() {
echo "</ul>\n<br class='clear' />\n";
}
function wp_dashboard_plugins() {
wp_dashboard_cached_rss_widget( 'dashboard_plugins', 'wp_dashboard_plugins_output', array(
'http://wordpress.org/extend/plugins/rss/browse/popular/',
'http://wordpress.org/extend/plugins/rss/browse/new/',
'http://wordpress.org/extend/plugins/rss/browse/updated/'
) );
}
/**
* Display plugins most popular, newest plugins, and recently updated widget text.
*
* $sidebar_args are handled by wp_dashboard_empty().
*
* @since unknown
*/
function wp_dashboard_plugins_output() {
@ -713,37 +600,7 @@ function wp_dashboard_cached_rss_widget( $widget_id, $callback, $check_urls = ar
return true;
}
/**
* Empty widget used for JS/AJAX created output.
*
* Callback inserts content between before_widget and after_widget. Used when
* widget is in edit mode. Can also be used for custom widgets.
*
* @since unknown
*
* @param array $sidebar_args
* @param callback $callback Optional. Only used in edit mode.
*/
function wp_dashboard_empty( $sidebar_args, $callback = false ) {
extract( $sidebar_args, EXTR_SKIP );
echo $before_widget;
echo $before_title;
echo $widget_name;
echo $after_title;
// When in edit mode, the callback passed to this function is the widget_control callback
if ( $callback && is_callable( $callback ) ) {
$args = array_slice( func_get_args(), 2 );
array_unshift( $args, $widget_id );
call_user_func_array( $callback, $args );
}
echo $after_widget;
}
/* Dashboard Widgets Controls. See also wp_dashboard_empty() */
/* Dashboard Widgets Controls */
// Temp
function wp_dashboard_empty_control() {
@ -759,9 +616,11 @@ function wp_dashboard_empty_control() {
* @param int $widget_control_id Registered Widget ID.
*/
function wp_dashboard_trigger_widget_control( $widget_control_id = false ) {
global $wp_registered_widget_controls;
if ( is_scalar($widget_control_id) && $widget_control_id && isset($wp_registered_widget_controls[$widget_control_id]) && is_callable($wp_registered_widget_controls[$widget_control_id]['callback']) )
call_user_func_array( $wp_registered_widget_controls[$widget_control_id]['callback'], $wp_registered_widget_controls[$widget_control_id]['params'] );
global $wp_dashboard_control_callbacks;
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]) ) {
call_user_func( $wp_dashboard_control_callbacks[$widget_control_id], '', array( 'id' => $widget_control_id, 'callback' => $wp_dashboard_control_callbacks[$widget_control_id] ) );
}
}
/**
@ -772,14 +631,10 @@ function wp_dashboard_trigger_widget_control( $widget_control_id = false ) {
*
* @since unknown
*
* @param array $args Expects 'widget_id' and 'form_inputs'.
* @return bool|null False if no widget_id is given. Null on success.
* @param string widget_id
* @param array form_inputs
*/
function wp_dashboard_rss_control( $args ) {
extract( $args );
if ( !$widget_id )
return false;
function wp_dashboard_rss_control( $widget_id, $form_inputs = array() ) {
if ( !$widget_options = get_option( 'dashboard_widget_options' ) )
$widget_options = array();

View File

@ -819,6 +819,8 @@ function wp_edit_attachments_query( $q = false ) {
* @return unknown
*/
function postbox_classes( $id, $page ) {
if ( isset( $_GET['edit'] ) && $_GET['edit'] == $id )
return '';
$current_user = wp_get_current_user();
if ( $closed = get_usermeta( $current_user->ID, 'closedpostboxes_'.$page ) ) {
if ( !is_array( $closed ) ) return '';

View File

@ -2058,7 +2058,7 @@ function _wp_comment_row( $comment_id, $mode, $comment_status, $checkbox = true
* @param unknown_type $checkbox
* @param unknown_type $mode
*/
function wp_comment_reply($position = '1', $checkbox = false, $mode = 'single') {
function wp_comment_reply($position = '1', $checkbox = false, $mode = 'single', $table_row = true) {
global $current_user;
// allow plugin to replace the popup content
@ -2069,8 +2069,12 @@ function wp_comment_reply($position = '1', $checkbox = false, $mode = 'single')
return;
}
?>
<form method="get" action=""><table style="display:none;"><tbody id="com-reply">
<tr id="replyrow"><td colspan="6">
<form method="get" action="">
<?php if ( $table_row ) : ?>
<table style="display:none;"><tbody id="com-reply"><tr id="replyrow"><td colspan="6">
<?php else : ?>
<div id="com-reply" style="display:none;"><div id="replyrow">
<?php endif; ?>
<div id="replyhead" style="display:none;"><?php _e('Reply to Comment'); ?></div>
<div id="edithead" style="display:none;">
@ -2114,8 +2118,11 @@ function wp_comment_reply($position = '1', $checkbox = false, $mode = 'single')
<input type="hidden" name="mode" id="mode" value="<?php echo $mode; ?>" />
<?php wp_nonce_field( 'replyto-comment', '_ajax_nonce', false ); ?>
<?php wp_comment_form_unfiltered_html_nonce(); ?>
</td></tr>
</tbody></table></form>
<?php if ( $table_row ) : ?>
</td></tr></tbody></table></form>
<?php else : ?>
</div></div>
<?php endif; ?>
<?php
}
@ -2643,7 +2650,7 @@ function add_meta_box($id, $title, $callback, $page, $context = 'advanced', $pri
* @param unknown_type $page
* @param unknown_type $context
* @param unknown_type $object
* @return unknown
* @return int number of meta_boxes
*/
function do_meta_boxes($page, $context, $object) {
global $wp_meta_boxes;

View File

@ -19,19 +19,19 @@ require_once (ABSPATH . WPINC . '/rss.php');
switch ( $_GET['jax'] ) {
case 'incominglinks' :
case 'dashboard_incoming_links' :
wp_dashboard_incoming_links_output();
break;
case 'devnews' :
case 'dashboard_primary' :
wp_dashboard_rss_output( 'dashboard_primary' );
break;
case 'planetnews' :
case 'dashboard_secondary' :
wp_dashboard_secondary_output();
break;
case 'plugins' :
case 'dashboard_plugins' :
wp_dashboard_plugins_output();
break;

View File

@ -14,32 +14,7 @@ require_once(ABSPATH . 'wp-admin/includes/dashboard.php');
wp_dashboard_setup();
/**
* Display dashboard widget custom JavaScript.
*
* @since unknown
*/
function index_js() {
?>
<script type="text/javascript">
jQuery(function($) {
var ajaxWidgets = {
dashboard_incoming_links: 'incominglinks',
dashboard_primary: 'devnews',
dashboard_secondary: 'planetnews',
dashboard_plugins: 'plugins'
};
$.each( ajaxWidgets, function(i,a) {
var e = jQuery('#' + i + ' div.dashboard-widget-content').not('.dashboard-widget-control').find('.widget-loading');
if ( e.size() ) { e.parent().load('index-extra.php?jax=' + a); }
} );
});
</script>
<?php
}
add_action( 'admin_head', 'index_js' );
wp_enqueue_script( 'jquery' );
wp_enqueue_script( 'dashboard' );
wp_enqueue_script( 'plugin-install' );
wp_admin_css( 'dashboard' );
wp_admin_css( 'plugin-install' );
@ -52,6 +27,15 @@ require_once('admin-header.php');
$today = current_time('mysql', 1);
?>
<div id="edit-settings-wrap" class="hidden">
<h5><?php _e('Show on screen') ?></h5>
<form id="adv-settings" action="" method="get">
<div class="metabox-prefs">
<?php meta_box_prefs('dashboard') ?>
<br class="clear" />
</div></form>
</div>
<div class="wrap">
<div id="dashboard-widgets-wrap">

48
wp-admin/js/dashboard.js Normal file
View File

@ -0,0 +1,48 @@
jQuery( function($) {
// close postboxes that should be closed
jQuery('.if-js-closed').removeClass('if-js-closed').addClass('closed');
// These widgets are sometimes populated via ajax
var ajaxWidgets = [
'dashboard_incoming_links',
'dashboard_primary',
'dashboard_secondary',
'dashboard_plugins'
];
var ajaxPopulateWidgets = function() {
$.each( ajaxWidgets, function() {
var e = jQuery('#' + this + ':visible div.inside').find('.widget-loading');
if ( e.size() ) { e.parent().load('index-extra.php?jax=' + this); }
} );
};
ajaxPopulateWidgets();
postboxes.add_postbox_toggles('dashboard', { onShow: ajaxPopulateWidgets } );
/* QuickPress */
var quickPressLoad = function() {
var act = $('#quickpost-action');
var t = $('#quick-press').submit( function() {
$('#dashboard_quick_press h3').append( '<img src="images/loading.gif" style="margin: 0 6px 0 0; vertical-align: middle" />' );
if ( 'post' == act.val() ) {
act.val( 'post-quickpress-publish' );
}
$('#dashboard_quick_press div.inside').load( t.attr( 'action' ), t.serializeArray(), function() {
$('#dashboard_quick_press h3 img').remove();
$('#dashboard_quick_press ul').find('li').each( function() {
$('#dashboard_recent_drafts ul').prepend( this );
} ).end().remove();
quickPressLoad();
} );
return false;
} );
$('#publish').click( function() { act.val( 'post-quickpress-publish' ); } );
};
quickPressLoad();
} );

View File

@ -1,18 +1,22 @@
(function($) {
postboxes = {
add_postbox_toggles : function(page) {
add_postbox_toggles : function(page,args) {
$('.postbox h3').before('<a class="togbox">+</a> ');
$('.postbox h3, .postbox a.togbox').click( function() {
$($(this).parent().get(0)).toggleClass('closed');
postboxes.save_state(page);
});
$('.postbox h3 a').click( function(e) {
e.stopPropagation();
} );
$('.hide-postbox-tog').click( function() {
var box = jQuery(this).val();
var show = jQuery(this).attr('checked');
if ( show ) {
if ( jQuery(this).attr('checked') ) {
jQuery('#' + box).show();
if ( $.isFunction( postboxes.onShow ) ) {
postboxes.onShow( box );
}
} else {
jQuery('#' + box).hide();
}
@ -26,7 +30,7 @@
}
$('#wpbody-content').css( 'overflow', 'hidden' );
this.init(page);
this.init(page,args);
},
expandSidebar : function( doIt ) {
@ -39,7 +43,8 @@
}
},
init : function(page) {
init : function(page,args) {
$.extend( this, args || {} );
jQuery('.meta-box-sortables').sortable( {
connectWith: [ '.meta-box-sortables' ],
items: '> .postbox',
@ -83,7 +88,10 @@
closedpostboxesnonce: jQuery('#closedpostboxesnonce').val(),
page: page
});
}
},
/* Callbacks */
onShow : false
};
$(document).ready(function(){postboxes.expandSidebar();});

View File

@ -86,7 +86,6 @@ case 'postajaxpost':
case 'post':
case 'post-quickpress-publish':
case 'post-quickpress-save':
case 'post-quickpress-save-cont':
check_admin_referer('add-post');
if ( 'post-quickpress-publish' == $action )
@ -104,13 +103,11 @@ case 'post-quickpress-save-cont':
$post_ID = 'postajaxpost' == $action ? edit_post() : write_post();
}
if ( 'post-quickpress-save-cont' != $action && 0 === strpos( $action, 'post-quickpress' ) ) {
if ( 0 === strpos( $action, 'post-quickpress' ) ) {
$_POST['post_ID'] = $post_ID;
// output the quickpress dashboard widget
require_once(ABSPATH . 'wp-admin/includes/dashboard.php');
add_filter( 'wp_dashboard_widgets', create_function( '$a', 'return array( "dashboard_quick_press" );' ) );
wp_dashboard_setup();
wp_dashboard();
wp_dashboard_quick_press();
exit;
}

View File

@ -420,7 +420,7 @@ die;
<?php wp_nonce_field('press-this') ?>
<input type="hidden" name="post_type" id="post_type" value="text"/>
<div id="poststuff">
<div id="poststuff" class="metabox-holder">
<div id="side-info-column">
<div class="sleeve">
<h1 id="viewsite"><a class="button" href="<?php echo get_option('home'); ?>/"><?php bloginfo('name'); ?> &rsaquo; <?php _e('Press This') ?></a></span></h1>

View File

@ -1222,14 +1222,14 @@ table.form-table td .updated {
clear: left;
}
#poststuff h3 {
#poststuff h3, .metabox-holder h3 {
font-size: 14px;
font-weight: bold;
padding: 7px;
margin: 0 0 10px;
}
#poststuff .postbox, #poststuff .stuffbox {
.metabox-holder .postbox, #poststuff .postbox, #poststuff .stuffbox {
padding: 2px;
margin-bottom: 20px;
border-width: 1px;
@ -1368,7 +1368,7 @@ table.form-table td .updated {
vertical-align: middle;
}
#poststuff .togbox {
.metabox-holder .togbox, #poststuff .togbox {
background-position: -10px 16px;
background-repeat: no-repeat;
display: block;
@ -1388,15 +1388,15 @@ table.form-table td .updated {
border-bottom-left-radius: 3px;
}
#poststuff .closed .inside {
.metabox-holder .closed .inside, #poststuff .closed .inside {
display: none;
}
#poststuff .closed h3 {
.metabox-holder .closed h3, #poststuff .closed h3 {
margin: 0;
}
#poststuff .closed .togbox {
.metabox-holder .closed .togbox, #poststuff .closed .togbox {
background-position: 4px 15px;
}
@ -2125,6 +2125,9 @@ a.togbox {
margin: 0 5px 0 2px;
}
.metabox-prefs label a {
display: none;
}
/* Inline Editor */
.inline-editor {

View File

@ -279,6 +279,8 @@ function wp_default_scripts( &$scripts ) {
) );
$scripts->add( 'settings-box', '/wp-admin/js/settings-box.js', array( 'jquery' ), '20080925' );
$scripts->add( 'dashboard', '/wp-admin/js/dashboard.js', array( 'jquery', 'admin-comments', 'postbox', 'settings-box' ), '20081008' );
}
}
@ -309,7 +311,7 @@ function wp_default_styles( &$styles ) {
$rtl_styles = array( 'global', 'colors', 'dashboard', 'ie', 'install', 'login', 'media', 'theme-editor', 'upload', 'widgets', 'press-this', 'press-this-ie' );
$styles->add( 'wp-admin', '/wp-admin/wp-admin.css', array(), '20081001' );
$styles->add( 'wp-admin', '/wp-admin/wp-admin.css', array(), '20081008' );
$styles->add_data( 'wp-admin', 'rtl', '/wp-admin/rtl.css' );
$styles->add( 'ie', '/wp-admin/css/ie.css' );
@ -322,7 +324,7 @@ function wp_default_styles( &$styles ) {
$styles->add( 'global', '/wp-admin/css/global.css', array(), '20081001' );
$styles->add( 'media', '/wp-admin/css/media.css', array(), '20080709' );
$styles->add( 'widgets', '/wp-admin/css/widgets.css' );
$styles->add( 'dashboard', '/wp-admin/css/dashboard.css', array(), '20081001' );
$styles->add( 'dashboard', '/wp-admin/css/dashboard.css', array(), '20081008' );
$styles->add( 'install', '/wp-admin/css/install.css', array(), '20080708' );
$styles->add( 'theme-editor', '/wp-admin/css/theme-editor.css' );
$styles->add( 'press-this', '/wp-admin/css/press-this.css', array(), '20080922' );
@ -427,4 +429,4 @@ add_filter( 'wp_print_scripts', 'wp_just_in_time_script_localization' );
add_filter( 'print_scripts_array', 'wp_prototype_before_jquery' );
add_action( 'wp_default_styles', 'wp_default_styles' );
add_filter( 'style_loader_src', 'wp_style_loader_src', 10, 2 );
add_filter( 'style_loader_src', 'wp_style_loader_src', 10, 2 );