| @@ -48,9 +48,9 @@ | ||
| 48 | 48 | require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | // Get plugin data. |
| 52 | - $plugin_data = get_plugin_data( POWERKIT_PATH . '/powerkit.php', false, false ); | |
| 52 | + $plugin_data = get_plugin_data( POWERKIT_PATH . '/powerkit.php' ); | |
| 53 | 53 | |
| 54 | 54 | // Vars. |
| 55 | 55 | $this->version = $plugin_data['Version']; |
| 56 | 56 | |
| @@ -55,8 +55,9 @@ | ||
| 55 | 55 | $this->version = $plugin_data['Version']; |
| 56 | 56 | |
| 57 | 57 | // Settings. |
| 58 | 58 | $this->settings = array( |
| 59 | + 'name' => esc_html__( 'Powerkit', 'powerkit' ), | |
| 59 | 60 | 'version' => $plugin_data['Version'], |
| 60 | 61 | 'documentation' => $plugin_data['AuthorURI'] . '/documentation/powerkit', |
| 61 | 62 | ); |
| 62 | 63 | |
| @@ -88,9 +89,9 @@ | ||
| 88 | 89 | // Actions. |
| 89 | 90 | add_action( 'powerkit_plugin_activation', array( $this, 'activation' ) ); |
| 90 | 91 | add_action( 'plugins_loaded', array( $this, 'check_version' ) ); |
| 91 | 92 | add_action( 'amp_post_template_css', array( $this, 'amp_enqueue_styles' ) ); |
| 92 | - add_action( 'enqueue_block_assets', array( $this, 'admin_enqueue_scripts' ), 5 ); | |
| 93 | + add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ), 5 ); | |
| 93 | 94 | add_action( 'wp_enqueue_scripts', array( $this, 'wp_enqueue_scripts' ), 5 ); |
| 94 | 95 | add_action( 'after_setup_theme', array( $this, 'after_setup_theme' ) ); |
| 95 | 96 | add_filter( 'style_loader_tag', array( $this, 'style_loader_tag' ), 10, 2 ); |
| 96 | 97 | add_filter( 'wp_kses_allowed_html', array( $this, 'wp_kses_allowed_html' ), 10, 2 ); |
| @@ -207,14 +208,12 @@ | ||
| 207 | 208 | } |
| 208 | 209 | |
| 209 | 210 | /** |
| 210 | 211 | * This function will register scripts and styles for admin dashboard. |
| 212 | + * | |
| 213 | + * @param string $page Current page. | |
| 211 | 214 | */ |
| 212 | - public function admin_enqueue_scripts() { | |
| 213 | - if ( ! ( is_admin() && ! is_customize_preview() ) ) { | |
| 214 | - return; | |
| 215 | - } | |
| 216 | - | |
| 215 | + public function admin_enqueue_scripts( $page ) { | |
| 217 | 216 | wp_enqueue_style( 'powerkit', POWERKIT_URL . 'assets/css/powerkit.css', array(), powerkit_get_setting( 'version' ) ); |
| 218 | 217 | } |
| 219 | 218 | |
| 220 | 219 | /** |
| @@ -220,45 +219,21 @@ | ||
| 220 | 219 | /** |
| 221 | 220 | * This function will register scripts and styles |
| 222 | 221 | */ |
| 223 | 222 | public function wp_enqueue_scripts() { |
| 224 | - $version = powerkit_get_setting( 'version' ); | |
| 225 | - | |
| 226 | - // Register tippy. | |
| 227 | - wp_register_script( 'tippy', POWERKIT_URL . 'assets/js/tippy.all.min.js', array(), $version, true ); | |
| 228 | - | |
| 229 | 223 | // Scripts. |
| 230 | - $dependencies = array( 'jquery' ); | |
| 231 | - | |
| 232 | - // Enqueue only for logged-in users. | |
| 233 | 224 | if ( is_user_logged_in() ) { |
| 234 | - $dependencies[] = 'tippy'; | |
| 225 | + wp_enqueue_script( 'tippy', POWERKIT_URL . 'assets/js/tippy.all.min.js', array( 'jquery' ), powerkit_get_setting( 'version' ), true ); | |
| 235 | 226 | } |
| 236 | 227 | |
| 237 | - wp_enqueue_script( | |
| 238 | - 'powerkit', | |
| 239 | - POWERKIT_URL . 'assets/js/_scripts.js', | |
| 240 | - $dependencies, | |
| 241 | - $version, | |
| 242 | - true | |
| 243 | - ); | |
| 228 | + wp_enqueue_script( 'powerkit', POWERKIT_URL . 'assets/js/_scripts.js', array( 'jquery', 'tippy' ), powerkit_get_setting( 'version' ), true ); | |
| 244 | 229 | |
| 245 | 230 | // Icons. |
| 246 | - wp_enqueue_style( | |
| 247 | - 'powerkit-icons', | |
| 248 | - POWERKIT_URL . 'assets/fonts/powerkit-icons.woff', | |
| 249 | - array(), | |
| 250 | - $version | |
| 251 | - ); | |
| 231 | + wp_enqueue_style( 'powerkit-icons', POWERKIT_URL . 'assets/fonts/powerkit-icons.woff', array(), powerkit_get_setting( 'version' ) ); | |
| 252 | 232 | wp_style_add_data( 'powerkit-icons', 'alt', 'alternate' ); |
| 253 | 233 | |
| 254 | 234 | // Styles. |
| 255 | - wp_enqueue_style( | |
| 256 | - 'powerkit', | |
| 257 | - powerkit_style( POWERKIT_URL . 'assets/css/powerkit.css' ), | |
| 258 | - array(), | |
| 259 | - $version | |
| 260 | - ); | |
| 235 | + wp_enqueue_style( 'powerkit', powerkit_style( POWERKIT_URL . 'assets/css/powerkit.css' ), array(), powerkit_get_setting( 'version' ) ); | |
| 261 | 236 | wp_style_add_data( 'powerkit', 'rtl', 'replace' ); |
| 262 | 237 | } |
| 263 | 238 | |
| 264 | 239 | /** |