/**
  * Enqueue scripts/styles for admin screen
  *
  * @action admin_enqueue_scripts
  *
  * @param $hook
  *
  * @return void
  */
 public static function admin_enqueue_scripts($hook)
 {
     wp_register_script('select2', WP_STREAM_URL . 'ui/select2/select2.min.js', array('jquery'), '3.5.1', true);
     wp_register_style('select2', WP_STREAM_URL . 'ui/select2/select2.css', array(), '3.5.1');
     wp_register_script('timeago', WP_STREAM_URL . 'ui/timeago/timeago.js', array(), '1.4.1', true);
     $locale = substr(get_locale(), 0, 2);
     $file_tmpl = 'ui/timeago/locale/jquery.timeago.%s.js';
     if (file_exists(WP_STREAM_DIR . sprintf($file_tmpl, $locale))) {
         wp_register_script('timeago-locale', WP_STREAM_URL . sprintf($file_tmpl, $locale), array('timeago'), '1');
     } else {
         wp_register_script('timeago-locale', WP_STREAM_URL . sprintf($file_tmpl, 'en'), array('timeago'), '1');
     }
     wp_enqueue_style('wp-stream-admin', WP_STREAM_URL . 'ui/css/admin.css', array(), WP_Stream::VERSION);
     $script_screens = array('plugins.php', 'user-edit.php', 'user-new.php', 'profile.php');
     if ('index.php' === $hook) {
         wp_enqueue_script('wp-stream-dashboard', WP_STREAM_URL . 'ui/js/dashboard.js', array('jquery'), WP_Stream::VERSION);
         wp_enqueue_script('wp-stream-live-updates', WP_STREAM_URL . 'ui/js/live-updates.js', array('jquery', 'heartbeat'), WP_Stream::VERSION);
     } elseif (in_array($hook, self::$screen_id) || in_array($hook, $script_screens)) {
         wp_enqueue_script('select2');
         wp_enqueue_style('select2');
         wp_enqueue_script('timeago');
         wp_enqueue_script('timeago-locale');
         wp_enqueue_script('wp-stream-admin', WP_STREAM_URL . 'ui/js/admin.js', array('jquery', 'select2'), WP_Stream::VERSION);
         wp_enqueue_script('wp-stream-live-updates', WP_STREAM_URL . 'ui/js/live-updates.js', array('jquery', 'heartbeat'), WP_Stream::VERSION);
         wp_localize_script('wp-stream-admin', 'wp_stream', array('i18n' => array('confirm_defaults' => __('Are you sure you want to reset all site settings to default? This cannot be undone.', 'stream')), 'gmt_offset' => get_option('gmt_offset')));
     }
     wp_localize_script('wp-stream-live-updates', 'wp_stream_live_updates', array('current_screen' => $hook, 'current_page' => isset($_GET['paged']) ? esc_js($_GET['paged']) : '1', 'current_order' => isset($_GET['order']) ? esc_js($_GET['order']) : 'desc', 'current_query' => json_encode($_GET)));
     if (WP_Stream_Migrate::show_migrate_notice()) {
         $limit = absint(WP_Stream_Migrate::$limit);
         $record_count = absint(WP_Stream_Migrate::$record_count);
         $estimated_time = $limit < $record_count ? round($record_count / $limit * (0.04 * $limit) / 60) : 0;
         $migrate_time_message = $estimated_time > 1 ? sprintf(__('This will take about %d minutes.', 'stream'), absint($estimated_time)) : __('This could take a few minutes.', 'stream');
         $delete_time_message = $estimated_time > 1 && is_multisite() ? sprintf(__('This will take about %d minutes.', 'stream'), absint($estimated_time)) : __('This could take a few minutes.', 'stream');
         wp_enqueue_script('wp-stream-migrate', WP_STREAM_URL . 'ui/js/migrate.js', array('jquery'), WP_Stream::VERSION);
         wp_localize_script('wp-stream-migrate', 'wp_stream_migrate', array('i18n' => array('migrate_process_title' => __('Migrating Stream Records', 'stream'), 'delete_process_title' => __('Deleting Stream Records', 'stream'), 'error_message' => __('An unknown error occurred during migration. Please try again later or contact support.', 'stream'), 'migrate_process_message' => __('Please do not exit this page until the process has completed.', 'stream') . ' ' . esc_html($migrate_time_message), 'delete_process_message' => __('Please do not exit this page until the process has completed.', 'stream') . ' ' . esc_html($delete_time_message), 'confirm_start_migrate' => $estimated_time > 1 ? sprintf(__('Please note: This process will take about %d minutes to complete.', 'stream'), absint($estimated_time)) : __('Please note: This process could take a few minutes to complete.', 'stream'), 'confirm_migrate_reminder' => __('Please note: Your existing records will not appear in Stream until you have migrated them to your account.', 'stream'), 'confirm_delete_records' => sprintf(__('Are you sure you want to delete all %s existing Stream records without migrating? This will take %s minutes and cannot be undone.', 'stream'), number_format(WP_Stream_Migrate::$record_count), $estimated_time > 1 && is_multisite() ? sprintf(__('about %d', 'stream'), absint($estimated_time)) : __('a few', 'stream'))), 'chunk_size' => absint($limit), 'record_count' => absint($record_count), 'nonce' => wp_create_nonce('wp_stream_migrate-' . absint(get_current_blog_id()) . absint(get_current_user_id()))));
     }
     /**
      * The maximum number of items that can be updated in bulk without receiving a warning.
      *
      * Stream watches for bulk actions performed in the WordPress Admin (such as updating
      * many posts at once) and warns the user before proceeding if the number of items they
      * are attempting to update exceeds this threshold value. Since Stream will try to save
      * a log for each item, it will take longer than usual to complete the operation.
      *
      * The default threshold is 100 items.
      *
      * @return int
      */
     $bulk_actions_threshold = apply_filters('wp_stream_bulk_actions_threshold', 100);
     wp_enqueue_script('wp-stream-bulk-actions', WP_STREAM_URL . 'ui/js/bulk-actions.js', array('jquery'), WP_Stream::VERSION);
     wp_localize_script('wp-stream-bulk-actions', 'wp_stream_bulk_actions', array('i18n' => array('confirm_action' => sprintf(__('Are you sure you want to perform bulk actions on over %d items? This process could take a while to complete.', 'stream'), absint($bulk_actions_threshold)), 'confirm_import' => __('The Stream plugin must be deactivated before you can bulk import content into WordPress.', 'stream')), 'plugins_screen_url' => self_admin_url('plugins.php#stream'), 'threshold' => absint($bulk_actions_threshold)));
 }