Make WordPress Core


Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/3.1/wp-admin/includes/dashboard.php

    r18314 r17557  
    11<?php
    22/**
    3  * WordPress Dashboard Widget Administration Screen API
     3 * WordPress Dashboard Widget Administration Panel API
    44 *
    55 * @package WordPress
     
    2525
    2626    /* Register Widgets and Controls */
    27 
    28     $response = wp_check_browser_version();
    29 
    30     if ( $response && $response['upgrade'] ) {
    31         add_filter( 'postbox_classes_dashboard_dashboard_browser_nag', 'dashboard_browser_nag_class' );
    32         if ( $response['insecure'] )
    33             wp_add_dashboard_widget( 'dashboard_browser_nag', __( 'You are using an insecure browser!' ), 'wp_dashboard_browser_nag' );
    34         else
    35             wp_add_dashboard_widget( 'dashboard_browser_nag', __( 'Your browser is out of date!' ), 'wp_dashboard_browser_nag' );
    36     }
    3727
    3828    // Right Now
     
    172162    if ( in_array($widget_id, $side_widgets) )
    173163        $location = 'side';
    174 
    175     $priority = 'core';
    176     if ( 'dashboard_browser_nag' === $widget_id )
    177         $priority = 'high';
    178 
    179     add_meta_box( $widget_id, $widget_name, $callback, $screen->id, $location, $priority );
     164    add_meta_box( $widget_id, $widget_name , $callback, $screen->id, $location, 'core' );
    180165}
    181166
     
    400385
    401386        $switch_themes = $ct->title;
    402         if ( current_user_can( 'switch_themes') )
     387        if ( current_user_can( 'switch_themes') ) {
     388            echo '<a href="themes.php" class="button rbutton">' . __('Change Theme') . '</a>';
    403389            $switch_themes = '<a href="themes.php">' . $switch_themes . '</a>';
     390        }
    404391        if ( current_user_can( 'edit_theme_options' ) ) {
    405392            printf(_n('Theme <span class="b">%1$s</span> with <span class="b"><a href="widgets.php">%2$s Widget</a></span>', 'Theme <span class="b">%1$s</span> with <span class="b"><a href="widgets.php">%2$s Widgets</a></span>', $num_widgets), $switch_themes, $num);
     
    408395        }
    409396    } else {
    410         if ( current_user_can( 'switch_themes' ) )
     397        if ( current_user_can( 'switch_themes' ) ) {
     398            echo '<a href="themes.php" class="button rbutton">' . __('Change Theme') . '</a>';
    411399            printf( __('Theme <span class="b"><a href="themes.php">%1$s</a></span>'), $ct->title );
    412         else
     400        } else {
    413401            printf( __('Theme <span class="b">%1$s</span>'), $ct->title );
     402        }
    414403    }
    415404    echo '</p>';
    416 
    417     // Check if search engines are blocked.
    418     if ( !is_network_admin() && !is_user_admin() && current_user_can('manage_options') && '1' != get_option('blog_public') ) {
    419         $title = apply_filters('privacy_on_link_title', __('Your site is asking search engines not to index its content') );
    420         $content = apply_filters('privacy_on_link_text', __('Search Engines Blocked') );
    421 
    422         echo "<p><a href='options-privacy.php' title='$title'>$content</a></p>";
    423     }
    424405
    425406    update_right_now_message();
     
    477458}
    478459
    479 function wp_dashboard_quick_press() {
     460function wp_dashboard_quick_press_output() {
    480461    global $post_ID;
    481462
     
    558539            <span id="publishing-action">
    559540                <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'); ?>" />
    560                 <img class="waiting" src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" alt="" />
     541                <img class="waiting" src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" />
    561542            </span>
    562543            <br class="clear" />
     
    568549    if ( $drafts )
    569550        wp_dashboard_recent_drafts( $drafts );
     551}
     552
     553function wp_dashboard_quick_press() {
     554    echo '<p class="widget-loading hide-if-no-js">' . __( 'Loading&#8230;' ) . '</p><p class="describe hide-if-js">' . __('This widget requires JavaScript.') . '</p>';
    570555}
    571556
     
    597582        <li><?php echo join( "</li>\n<li>", $list ); ?></li>
    598583    </ul>
    599     <p class="textright"><a href="edit.php?post_status=draft" ><?php _e('View all'); ?></a></p>
     584    <p class="textright"><a href="edit.php?post_status=draft" class="button"><?php _e('View all'); ?></a></p>
    600585<?php
    601586    } else {
     
    650635<?php
    651636        if ( current_user_can('edit_posts') ) { ?>
    652             <?php _get_list_table('WP_Comments_List_Table')->views(); ?>
     637            <p class="textright"><a href="edit-comments.php" class="button"><?php _e('View all'); ?></a></p>
    653638<?php   }
    654639
     
    783768
    784769function wp_dashboard_incoming_links() {
    785     wp_dashboard_cached_rss_widget( 'dashboard_incoming_links', 'wp_dashboard_incoming_links_output' );
     770    echo '<p class="widget-loading hide-if-no-js">' . __( 'Loading&#8230;' ) . '</p><p class="describe hide-if-js">' . __('This widget requires JavaScript.') . '</p>';
    786771}
    787772
     
    871856
    872857function wp_dashboard_primary() {
    873     wp_dashboard_cached_rss_widget( 'dashboard_primary', 'wp_dashboard_rss_output' );
     858    echo '<p class="widget-loading hide-if-no-js">' . __( 'Loading&#8230;' ) . '</p><p class="describe hide-if-js">' . __('This widget requires JavaScript.') . '</p>';
    874859}
    875860
     
    893878
    894879function wp_dashboard_secondary() {
    895     wp_dashboard_cached_rss_widget( 'dashboard_secondary', 'wp_dashboard_secondary_output' );
     880    echo '<p class="widget-loading hide-if-no-js">' . __( 'Loading&#8230;' ) . '</p><p class="describe hide-if-js">' . __('This widget requires JavaScript.') . '</p>';
    896881}
    897882
     
    932917
    933918function wp_dashboard_plugins() {
    934     wp_dashboard_cached_rss_widget( 'dashboard_plugins', 'wp_dashboard_plugins_output', array(
    935         'http://wordpress.org/extend/plugins/rss/browse/popular/',
    936         'http://wordpress.org/extend/plugins/rss/browse/new/',
    937         'http://wordpress.org/extend/plugins/rss/browse/updated/'
    938     ) );
     919    echo '<p class="widget-loading hide-if-no-js">' . __( 'Loading&#8230;' ) . '</p><p class="describe hide-if-js">' . __('This widget requires JavaScript.') . '</p>';
    939920}
    940921
     
    10361017 */
    10371018function wp_dashboard_cached_rss_widget( $widget_id, $callback, $check_urls = array() ) {
    1038     $loading = '<p class="widget-loading hide-if-no-js">' . __( 'Loading&#8230;' ) . '</p><p class="hide-if-js">' . __( 'This widget requires JavaScript.' ) . '</p>';
    1039     $doing_ajax = ( defined('DOING_AJAX') && DOING_AJAX );
     1019    $loading = '<p class="widget-loading">' . __( 'Loading&#8230;' ) . '</p>';
    10401020
    10411021    if ( empty($check_urls) ) {
    10421022        $widgets = get_option( 'dashboard_widget_options' );
    1043         if ( empty($widgets[$widget_id]['url']) && ! $doing_ajax ) {
     1023        if ( empty($widgets[$widget_id]['url']) ) {
    10441024            echo $loading;
    10451025            return false;
     
    10481028    }
    10491029
    1050     $cache_key = 'dash_' . md5( $widget_id );
    1051     if ( false !== ( $output = get_transient( $cache_key ) ) ) {
    1052         echo $output;
    1053         return true;
    1054     }
    1055 
    1056     if ( ! $doing_ajax ) {
    1057         echo $loading;
    1058         return false;
     1030    include_once ABSPATH . WPINC . '/class-feed.php';
     1031    foreach ( $check_urls as $check_url ) {
     1032        $cache = new WP_Feed_Cache_Transient('', md5($check_url), '');
     1033        if ( ! $cache->load() ) {
     1034            echo $loading;
     1035            return false;
     1036        }
    10591037    }
    10601038
     
    10621040        $args = array_slice( func_get_args(), 2 );
    10631041        array_unshift( $args, $widget_id );
    1064         ob_start();
    10651042        call_user_func_array( $callback, $args );
    1066         set_transient( $cache_key, ob_get_flush(), 43200); // Default lifetime in cache of 12 hours (same as the feeds)
    10671043    }
    10681044
     
    11241100        }
    11251101        update_option( 'dashboard_widget_options', $widget_options );
    1126         $cache_key = 'dash_' . md5( $widget_id );
    1127         delete_transient( $cache_key );
    11281102    }
    11291103
     
    11331107// Display File upload quota on dashboard
    11341108function wp_dashboard_quota() {
    1135     if ( !is_multisite() || !current_user_can('upload_files') || get_site_option( 'upload_space_check_disabled' ) )
     1109    if ( !is_multisite() || !current_user_can('edit_posts') || get_site_option( 'upload_space_check_disabled' ) )
    11361110        return true;
    11371111
     
    11431117    else
    11441118        $percentused = ( $used / $quota ) * 100;
    1145     $used_color = ( $percentused >= 70 ) ? ' spam' : '';
     1119    $used_color = ( $percentused < 70 ) ? ( ( $percentused >= 40 ) ? 'waiting' : 'approved' ) : 'spam';
    11461120    $used = round( $used, 2 );
    11471121    $percentused = number_format( $percentused );
     
    11611135        <tr class="first">
    11621136            <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>
    1163             <td class="last t comments<?php echo $used_color;?>"><?php _e( 'Space Used' );?></td>
     1137            <td class="last t comments <?php echo $used_color;?>"><?php _e( 'Space Used' );?></td>
    11641138        </tr>
    11651139    </table>
     
    11701144add_action( 'activity_box_end', 'wp_dashboard_quota' );
    11711145
    1172 // Display Browser Nag Meta Box
    1173 function wp_dashboard_browser_nag() {
    1174     $notice = '';
    1175     $response = wp_check_browser_version();
    1176 
    1177     if ( $response ) {
    1178         if ( $response['insecure'] ) {
    1179             $msg = sprintf( __( "It looks like you're using an insecure version of <a href='%s'>%s</a>. Using an outdated browser makes your computer unsafe. For the best WordPress experience, please update your browser." ), esc_attr( $response['update_url'] ), esc_html( $response['name'] ) );
    1180         } else {
    1181             $msg = sprintf( __( "It looks like you're using an old version of <a href='%s'>%s</a>. For the best WordPress experience, please update your browser." ), esc_attr( $response['update_url'] ), esc_html( $response['name'] ) );
    1182         }
    1183 
    1184         $browser_nag_class = '';
    1185         if ( !empty( $response['img_src'] ) ) {
    1186             $img_src = ( is_ssl() && ! empty( $response['img_src_ssl'] ) )? $response['img_src_ssl'] : $response['img_src'];
    1187 
    1188             $notice .= '<div class="alignright browser-icon"><a href="' . esc_attr($response['update_url']) . '"><img src="' . esc_attr( $img_src ) . '" alt="" /></a></div>';
    1189             $browser_nag_class = ' has-browser-icon';
    1190         }
    1191         $notice .= "<p class='browser-update-nag{$browser_nag_class}'>{$msg}</p>";
    1192         $notice .= sprintf( __( '<p><a href="%1$s" class="update-browser-link">Update %2$s</a> or learn how to <a href="%3$s" class="browse-happy-link">browse happy</a></p>' ), esc_attr( $response['update_url'] ), esc_html( $response['name'] ), 'http://browsehappy.com/' );
    1193         $notice .= '<p class="hide-if-no-js"><a href="" class="dismiss">' . __( 'Dismiss' ) . '</a></p>';
    1194         $notice .= '<div class="clear"></div>';
    1195     }
    1196 
    1197     echo apply_filters( 'browse-happy-notice', $notice, $response );
    1198 }
    1199 
    1200 function dashboard_browser_nag_class( $classes ) {
    1201     $response = wp_check_browser_version();
    1202 
    1203     if ( $response && $response['insecure'] )
    1204         $classes[] = 'browser-insecure';
    1205 
    1206     return $classes;
    1207 }
    1208 
    1209 /**
    1210  * Check if the user needs a browser update
    1211  *
    1212  * @since 3.2.0
    1213  *
    1214  * @return array|bool False on failure, array of browser data on success.
    1215  */
    1216 function wp_check_browser_version() {
    1217     if ( empty( $_SERVER['HTTP_USER_AGENT'] ) )
    1218         return false;
    1219 
    1220     $key = md5( $_SERVER['HTTP_USER_AGENT'] );
    1221 
    1222     if ( false === ($response = get_site_transient('browser_' . $key) ) ) {
    1223         global $wp_version;
    1224 
    1225         $options = array(
    1226             'body'          => array( 'useragent' => $_SERVER['HTTP_USER_AGENT'] ),
    1227             'user-agent'    => 'WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' )
    1228         );
    1229 
    1230         $response = wp_remote_post( 'http://api.wordpress.org/core/browse-happy/1.0/', $options );
    1231 
    1232         if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) )
    1233             return false;
    1234 
    1235         /**
    1236          * Response should be an array with:
    1237          *  'name' - string - A user friendly browser name
    1238          *  'version' - string - The most recent version of the browser
    1239          *  'current_version' - string - The version of the browser the user is using
    1240          *  'upgrade' - boolean - Whether the browser needs an upgrade
    1241          *  'insecure' - boolean - Whether the browser is deemed insecure
    1242          *  'upgrade_url' - string - The url to visit to upgrade
    1243          *  'img_src' - string - An image representing the browser
    1244          *  'img_src_ssl' - string - An image (over SSL) representing the browser
    1245          */
    1246         $response = unserialize( wp_remote_retrieve_body( $response ) );
    1247 
    1248         if ( ! $response )
    1249             return false;
    1250 
    1251         set_site_transient( 'browser_' . $key, $response, 604800 ); // cache for 1 week
    1252     }
    1253 
    1254     return $response;
    1255 }
    1256 
    12571146/**
    12581147 * Empty function usable by plugins to output empty dashboard widget (to be populated later by JS).
Note: See TracChangeset for help on using the changeset viewer.