Changeset 8751
- Timestamp:
- 08/27/2008 07:36:12 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/includes/dashboard.php
r8600 r8751 34 34 wp_register_sidebar_widget( 'dashboard_recent_comments', __( 'Recent Comments' ), 'wp_dashboard_recent_comments', 35 35 array( 'all_link' => 'edit-comments.php', 'notice' => $notice, 'width' => 'half' ) 36 ); 37 38 39 // QuickPress Widget 40 if ( 'post' === strtolower( $_SERVER['REQUEST_METHOD'] ) && isset( $_POST['action'] ) && 0 === strpos( $_POST['action'], 'post-quickpress' ) ) { 41 $view = get_permalink( $_POST['post_ID'] ); 42 $edit = clean_url( get_edit_post_link( $_POST['post_ID'] ) ); 43 if ( 'post-quickpress-publish' == $_POST['action'] ) 44 $notice = sprintf( __( 'Post Published. <a href="%s">View post</a> | <a href="%s">Edit post</a>' ), clean_url( $view ), $edit ); 45 else 46 $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 ); 47 } else { 48 $notice = ''; 49 } 50 wp_register_sidebar_widget( 'dashboard_quick_press', __( 'QuickPress' ), 'wp_dashboard_quick_press', 51 array( 'all_link' => array( 'edit.php?post_status=draft', __('View All Drafts') ), 'width' => 'half', 'height' => 'double', 'notice' => $notice ) 52 ); 53 wp_register_widget_control( 'dashboard_quick_press', __( 'QuickPress' ), 'wp_dashboard_empty_control', 54 array( 'widget_id' => 'dashboard_quick_press' ) 55 ); 56 57 // Inbox Widget 58 wp_register_sidebar_widget( 'dashboard_inbox', __( 'Inbox' ), 'wp_dashboard_inbox', 59 array( 'all_link' => 'inbox.php', 'height' => 'double' ) 60 ); 61 wp_register_widget_control( 'dashboard_inbox', __( 'Inbox' ), 'wp_dashboard_empty_control', 62 array( 'widget_id' => 'dashboard_inbox' ) 36 63 ); 37 64 … … 107 134 wp_register_sidebar_widget( $widget_id (unique slug) , $widget_title, $output_callback, 108 135 array( 109 'all_link' => full url for " SeeAll" link,136 'all_link' => full url for "View All" link, 110 137 'feed_link' => full url for "RSS" link, 111 138 'width' => 'fourth', 'third', 'half', 'full' (defaults to 'half'), … … 133 160 // Hard code the sidebar's widgets and order 134 161 $dashboard_widgets = array(); 162 $dashboard_widgets[] = 'dashboard_inbox'; 163 $dashboard_widgets[] = 'dashboard_quick_press'; 164 /* 135 165 $dashboard_widgets[] = 'dashboard_recent_comments'; 136 166 $dashboard_widgets[] = 'dashboard_incoming_links'; … … 138 168 if ( current_user_can( 'activate_plugins' ) ) 139 169 $dashboard_widgets[] = 'dashboard_plugins'; 170 */ 140 171 $dashboard_widgets[] = 'dashboard_secondary'; 141 172 142 173 // Filter widget order 143 174 $dashboard_widgets = apply_filters( 'wp_dashboard_widgets', $dashboard_widgets ); 175 if ( in_array( 'dashboard_quick_press', $dashboard_widgets ) ) { 176 // add_action( 'admin_head', 'wp_teeny_mce' ); 177 add_action( 'admin_head', 'wp_dashboard_quick_press_js' ); 178 } 144 179 145 180 $wp_dashboard_sidebars = array( 'wp_dashboard' => $dashboard_widgets, 'array_version' => 3.5 ); … … 206 241 $sidebar_before_widget = str_replace( "<div class='dashboard-widget-holder ", "<div class='dashboard-widget-holder " . join( ' ', $the_classes ) . ' ', $sidebar_before_widget ); 207 242 208 $links = array(); 209 if ( $widget_all_link ) 210 $links[] = '<a href="' . clean_url( $widget_all_link ) . '">' . __( 'See All' ) . '</a>'; 243 $top_links = $bottom_links = array(); 244 if ( $widget_all_link ) { 245 $widget_all_link = (array) $widget_all_link; 246 $bottom_links[] = '<a href="' . clean_url( $widget_all_link[0] ) . '">' . ( isset($widget_all_link[1]) ? $widget_all_link[1] : __( 'View All' ) ) . '</a>'; 247 } 211 248 212 249 $content_class = 'dashboard-widget-content'; … … 220 257 $sidebar_before_widget .= '<form action="' . clean_url(remove_query_arg( 'edit' )) . '" method="post">'; 221 258 $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"; 222 $ links[] = '<a href="' . clean_url(remove_query_arg( 'edit' )) . '">' . __( 'Cancel' ) . '</a>';259 $top_links[] = '<a href="' . clean_url(remove_query_arg( 'edit' )) . '">' . __( 'Cancel' ) . '</a>'; 223 260 } else { 224 $ links[] = '<a href="' . clean_url(add_query_arg( 'edit', $widget_id )) . "#$widget_id" . '">' . __( 'Edit' ) . '</a>';261 $top_links[] = '<a href="' . clean_url(add_query_arg( 'edit', $widget_id )) . "#$widget_id" . '">' . __( 'Edit' ) . '</a>'; 225 262 } 226 263 } 227 264 228 265 if ( $widget_feed_link ) 229 $links[] = '<img class="rss-icon" src="' . includes_url('images/rss.png') . '" alt="' . __( 'rss icon' ) . '" /> <a href="' . clean_url( $widget_feed_link ) . '">' . __( 'RSS' ) . '</a>'; 230 231 $links = apply_filters( "wp_dashboard_widget_links_$widget_id", $links ); 232 233 // Add links to widget's title bar 234 if ( $links ) { 235 $sidebar_before_title .= '<span>'; 236 $sidebar_after_title = '</span><small>' . join( ' | ', $links ) . "</small><br class='clear' />$sidebar_after_title"; 237 } 266 $bottom_links[] = '<img class="rss-icon" src="' . includes_url('images/rss.png') . '" alt="' . __( 'rss icon' ) . '" /> <a href="' . clean_url( $widget_feed_link ) . '">' . __( 'RSS' ) . '</a>'; 267 268 $bottom_links = apply_filters( "wp_dashboard_widget_links_$widget_id", $bottom_links ); 238 269 239 270 // Could have put this in widget-content. Doesn't really matter … … 246 277 $sidebar_after_title .= "\t\t\t<div class='$content_class'>\n\n"; 247 278 279 // Add links to widget's title bar 280 if ( $top_links ) { 281 $sidebar_before_title .= '<span>'; 282 $sidebar_after_title = '</span><small>' . join( ' | ', $top_links ) . "</small><br class='clear' />$sidebar_after_title"; 283 } 284 285 // Add links to bottom of widget 286 if ( $bottom_links ) 287 $sidebar_after_widget .= "<p class='dashboard-widget-links'>" . join( ' | ', $bottom_links ) . "</p>"; 288 248 289 $sidebar_after_widget .= "\t\t\t</div>\n\n"; 249 290 … … 258 299 259 300 /* Dashboard Widgets */ 301 302 function wp_dashboard_quick_press( $sidebar_args ) { 303 extract( $sidebar_args, EXTR_SKIP ); 304 305 echo $before_widget; 306 307 echo $before_title; 308 echo $widget_name; 309 echo $after_title; 310 311 if ( ( 'post' === strtolower( $_SERVER['REQUEST_METHOD'] ) ) && 'post-quickpress-save-cont' === $_POST['action'] ) { 312 $post = get_post_to_edit( $_POST['post_ID'] ); 313 } else { 314 $_REQUEST = array(); // hack 315 $post = get_default_post_to_edit(); 316 } 317 ?> 318 319 <form name="post" action="<?php echo clean_url( admin_url( 'post.php' ) ); ?>" method="post" id="quick-press"> 320 <h3 id="quick-post-title"><label for="title"><?php _e('Title') ?></label></h3> 321 <div class="input-text-wrap"> 322 <input type="text" name="post_title" id="title" autocomplete="off" value="<?php echo attribute_escape( $post->post_title ); ?>" /> 323 </div> 324 325 <h3><label for="content"><?php _e('Post') ?></label></h3> 326 <div class="textarea-wrap"> 327 <textarea name="content" id="quickpress-content" class="mceEditor" rows="3" cols="15"><?php echo $post->post_content; ?></textarea> 328 </div> 329 330 <h3><label for="tags-input"><?php _e('Tags') ?></label></h3> 331 <div class="input-text-wrap"> 332 <input type="text" name="tags_input" id="tags-input" value="<?php echo get_tags_to_edit( $post->ID ); ?>" /> 333 </div> 334 <p class='field-tip'><?php _e('Separate tags with commas'); ?></p> 335 336 <p class="submit"> 337 <input type="hidden" name="action" id="quickpost-action" value="post-quickpress-save" /> 338 <input type="hidden" name="quickpress_post_ID" value="<?php echo (int) $post->ID; ?>" /> 339 <?php wp_nonce_field('add-post'); ?> 340 <input type="submit" name="save" id="save-post" class="button" value="<?php _e('Save'); ?>" /> 341 <input type="submit" name="save-cont" id="save-cont" class="button" value="<?php _e('Save and Continue'); ?>" /> 342 <input type="submit" name="publish" id="publish" accesskey="p" class="button button-highlighted" value="<?php _e('Publish'); ?>" /> 343 </p> 344 345 <?php 346 $drafts_query = new WP_Query( array( 347 'post_type' => 'post', 348 'what_to_show' => 'posts', 349 'post_status' => 'draft', 350 'author' => $GLOBALS['current_user']->ID, 351 'posts_per_page' => 5, 352 'orderby' => 'modified', 353 'order' => 'DESC' 354 ) ); 355 356 if ( $drafts_query->posts ) : 357 $list = array(); 358 foreach ( $drafts_query->posts as $draft ) { 359 $url = get_edit_post_link( $draft->ID ); 360 $title = get_the_title( $draft->ID ); 361 $list[] = "<a href='$url' title='" . sprintf( __( 'Edit "%s"' ), attribute_escape( $title ) ) . "'>$title</a>"; 362 } 363 ?> 364 365 <h3><?php _e('Recent Drafts'); ?></h3> 366 <p id='recent-drafts'> 367 <?php echo join( ', ', $list ); ?> 368 </p> 369 370 <?php 371 372 endif; // drafts 373 374 ?> 375 376 </form> 377 378 <?php 379 380 echo $after_widget; 381 } 382 383 function wp_dashboard_quick_press_js() { 384 ?> 385 <script type="text/javascript"> 386 /* <![CDATA[ */ 387 var quickPressLoad = function($) { 388 var act = $('#quickpost-action'); 389 var t = $('#quick-press').submit( function() { 390 if ( 'post-quickpress-save-cont' == act.val() ) { 391 return true; 392 } 393 394 var head = $('#dashboard_quick_press div.dashboard-widget').children( 'div').hide().end().find('h3 small'); 395 head.prepend( '<img src="images/loading.gif" style="margin: 0 6px 0 0; vertical-align: middle" />' ); 396 397 if ( 'post' == act.val() ) { act.val( 'post-quickpress-publish' ); } 398 399 if ( 'undefined' != typeof tinyMCE ) { 400 tinyMCE.get('quickpress-content').save(); 401 tinyMCE.get('quickpress-content').remove(); 402 } 403 404 $('#dashboard_quick_press').load( t.attr( 'action' ) + ' #dashboard_quick_press > *', t.serializeArray(), function() { 405 if ( 'undefined' != typeof wpTeenyMCEInit && $.isFunction( wpTeenyMCEInit ) ) { wpTeenyMCEInit(); } 406 quickPressLoad($); 407 } ); 408 return false; 409 } ); 410 411 $('#publish').click( function() { act.val( 'post-quickpress-publish' ); } ); 412 $('#save-cont').click( function() { act.val( 'post-quickpress-save-cont' ); t.attr( 'action', 'post.php' ); } ); 413 }; 414 jQuery( quickPressLoad ); 415 /* ]]> */ 416 </script> 417 <?php 418 } 419 420 421 function wp_dashboard_inbox( $sidebar_args ) { 422 extract( $sidebar_args, EXTR_SKIP ); 423 424 echo $before_widget; 425 426 echo $before_title; 427 echo $widget_name; 428 echo $after_title; 429 430 ?> 431 432 <style type="text/css"> 433 #inbox-filter ul { 434 list-style: none; 435 margin: 0; 436 padding: 0; 437 position: relative; 438 } 439 #inbox-filter ul li { 440 position: relative; 441 padding-right: 20px; 442 } 443 #inbox-filter ul input.checkbox { 444 float: left; 445 } 446 #inbox-filter ul p { 447 float: left; 448 margin: 0; 449 margin-left: -40px; 450 width: 100%; 451 position: relative; 452 left: 50px; 453 } 454 #inbox-message { 455 margin:0 0 0 7.5em; 456 padding:5px; 457 } 458 </style> 459 <script type="text/javascript"> 460 jQuery( function($) { 461 $('#inbox-filter').submit( function() { return false; } ) 462 .find( ':button' ).click( function() { 463 var done = $(':checked').size().toString(), txt = (done == '1') ? '<?php _e(' item archived'); ?>' : '<?php _e(' items archived'); ?>'; 464 $(':checked').parent().slideUp( 'normal', function() { 465 $('.inbox-count').text( $('#inbox-filter li:visible').size().toString() ); 466 $('#inbox-message').addClass('updated'); 467 $('#inbox-message').text(done+txt+" (This feature isn't enabled in this prototype)"); 468 } ); 469 } ); 470 } ); 471 </script> 472 473 <form id="inbox-filter" action="" method="get"> 474 <p class="actions"><input type="button" value="Archive" name="archive" class="button"></p> 475 <div id="inbox-message"></div> 476 <br class="clear" /> 477 478 <ul> 479 480 <?php $crazy_posts = array( '', 'some post', 'a post', 'my cool post' ); foreach ( wp_get_inbox_items() as $k => $item ) : // crazyhorse ?> 481 482 <li id="message-<?php echo $k; ?>"> 483 <input type="checkbox" name="messages[]" value="<?php echo $k; ?>" class="checkbox" /> 484 <p><?php 485 if ( $item->href ) 486 echo "<a href='$item->href' class='no-crazy'>"; 487 echo wp_specialchars( $item->text ); 488 if ( strlen( $item->text ) > 180 ) // crazyhorse 489 echo '<br/><span class="inbox-more">more…</span>'; 490 if ( $item->href ) 491 echo '</a>'; 492 ?><br /> 493 -- <cite><?php 494 echo $item->from; 495 if ( 'comment' == $item->type ) // crazyhorse 496 echo " on "<a href='#' class='no-crazy'>{$crazy_posts[$item->parent]}</a>""; 497 ?></cite>, <?php echo "$item->date, $item->time"; ?> 498 </p> 499 <br class="clear" /> 500 </li> 501 502 <?php endforeach; ?> 503 504 </ul> 505 </form> 506 507 <?php 508 509 echo $after_widget; 510 } 260 511 261 512 function wp_dashboard_recent_comments( $sidebar_args ) { … … 510 761 /* Dashboard Widgets Controls. Ssee also wp_dashboard_empty() */ 511 762 763 // Temp 764 function wp_dashboard_empty_control() { 765 echo "This feature isn't enabled in this prototype."; 766 } 767 512 768 // Calls widget_control callback 513 769 function wp_dashboard_trigger_widget_control( $widget_control_id = false ) {
Note: See TracChangeset
for help on using the changeset viewer.