diff --git a/classes/class-admin.php b/classes/class-admin.php index 40b6d83ce..d72754a17 100644 --- a/classes/class-admin.php +++ b/classes/class-admin.php @@ -334,24 +334,24 @@ public function register_menu() { * @return void */ public function admin_enqueue_scripts( $hook ) { - wp_register_script( 'select2', $this->plugin->locations['url'] . 'ui/lib/select2/select2.js', array( 'jquery' ), '3.5.2', true ); - wp_register_style( 'select2', $this->plugin->locations['url'] . 'ui/lib/select2/select2.css', array(), '3.5.2' ); - wp_register_script( 'timeago', $this->plugin->locations['url'] . 'ui/lib/timeago/jquery.timeago.js', array(), '1.4.1', true ); + $script_screens = array( 'plugins.php' ); - $locale = strtolower( substr( get_locale(), 0, 2 ) ); - $file_tmpl = 'ui/lib/timeago/locales/jquery.timeago.%s.js'; + if ( in_array( $hook, $this->screen_id ) || in_array( $hook, $script_screens ) ) { + wp_register_script( 'select2', $this->plugin->locations['url'] . 'ui/lib/select2/select2.js', array( 'jquery' ), '3.5.2', true ); + wp_register_style( 'select2', $this->plugin->locations['url'] . 'ui/lib/select2/select2.css', array(), '3.5.2' ); + wp_register_script( 'timeago', $this->plugin->locations['url'] . 'ui/lib/timeago/jquery.timeago.js', array(), '1.4.1', true ); - if ( file_exists( $this->plugin->locations['dir'] . sprintf( $file_tmpl, $locale ) ) ) { - wp_register_script( 'timeago-locale', $this->plugin->locations['url'] . sprintf( $file_tmpl, $locale ), array( 'timeago' ), '1' ); - } else { - wp_register_script( 'timeago-locale', $this->plugin->locations['url'] . sprintf( $file_tmpl, 'en' ), array( 'timeago' ), '1' ); - } + $locale = strtolower( substr( get_locale(), 0, 2 ) ); + $file_tmpl = 'ui/lib/timeago/locales/jquery.timeago.%s.js'; - wp_enqueue_style( 'wp-stream-admin', $this->plugin->locations['url'] . 'ui/css/admin.css', array(), $this->plugin->get_version() ); + if ( file_exists( $this->plugin->locations['dir'] . sprintf( $file_tmpl, $locale ) ) ) { + wp_register_script( 'timeago-locale', $this->plugin->locations['url'] . sprintf( $file_tmpl, $locale ), array( 'timeago' ), '1' ); + } else { + wp_register_script( 'timeago-locale', $this->plugin->locations['url'] . sprintf( $file_tmpl, 'en' ), array( 'timeago' ), '1' ); + } - $script_screens = array( 'plugins.php' ); + wp_enqueue_style( 'wp-stream-admin', $this->plugin->locations['url'] . 'ui/css/admin.css', array(), $this->plugin->get_version() ); - if ( in_array( $hook, $this->screen_id ) || in_array( $hook, $script_screens ) ) { wp_enqueue_script( 'select2' ); wp_enqueue_style( 'select2' );