public function wp_dashboard_setup()
{
if (self::is_active()) {
add_action('jetpack_dashboard_widget', array(__CLASS__, 'dashboard_widget_footer'), 999);
$widget_title = __('Site Stats', 'jetpack');
} elseif (!self::is_development_mode() && current_user_can('jetpack_connect')) {
add_action('jetpack_dashboard_widget', array($this, 'dashboard_widget_connect_to_wpcom'));
$widget_title = __('Please Connect Jetpack', 'jetpack');
}
if (has_action('jetpack_dashboard_widget')) {
wp_add_dashboard_widget('jetpack_summary_widget', $widget_title, array(__CLASS__, 'dashboard_widget'));
wp_enqueue_style('jetpack-dashboard-widget', plugins_url('css/dashboard-widget.css', JETPACK__PLUGIN_FILE), array(), JETPACK__VERSION);
// If we're inactive and not in development mode, sort our box to the top.
if (!self::is_active() && !self::is_development_mode()) {
global $wp_meta_boxes;
$dashboard = $wp_meta_boxes['dashboard']['normal']['core'];
$ours = array('jetpack_summary_widget' => $dashboard['jetpack_summary_widget']);
$wp_meta_boxes['dashboard']['normal']['core'] = array_merge($ours, $dashboard);
}
}
}