Skip to content

Commit a1db8ca

Browse files
committed
restructure asset enqueuing
1 parent 4149217 commit a1db8ca

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

php/class-plugin.php

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -262,12 +262,14 @@ public function set_config() {
262262
*/
263263
public function register_hooks() {
264264
add_action( 'plugins_loaded', array( $this, 'init' ), 9 );
265-
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_assets' ), 11 );
265+
add_action( 'admin_enqueue_scripts', array( $this, 'register_enqueue_styles' ), 11 );
266+
add_action( 'admin_footer', array( $this, 'enqueue_assets' ), 11 );
266267
add_action( 'init', array( $this, 'setup' ), 10 );
267268
add_action( 'init', array( $this, 'register_assets' ), 10 );
268269
add_action( 'admin_notices', array( $this, 'admin_notices' ) );
269270
add_filter( 'plugin_row_meta', array( $this, 'force_visit_plugin_site_link' ), 10, 4 );
270271
add_filter( 'cloudinary_api_rest_endpoints', array( $this, 'rest_endpoints' ) );
272+
add_action( 'wp_enqueue_editor', array( $this, 'enqueue_assets' ) );
271273
}
272274

273275
/**
@@ -289,12 +291,10 @@ public function rest_endpoints( $endpoints ) {
289291
}
290292

291293
/**
292-
* Enqueue scripts.
294+
* Register scripts and enqueue styles.
293295
*/
294-
public function enqueue_assets() {
295-
// Enqueue Main.
296-
wp_enqueue_script( 'cloudinary', $this->dir_url . 'js/cloudinary.js', array( 'jquery', 'wp-util' ), $this->version, true );
297-
wp_enqueue_style( 'cloudinary', $this->dir_url . 'css/cloudinary.css', null, $this->version );
296+
public function register_enqueue_styles() {
297+
wp_enqueue_style( 'cloudinary' );
298298
$components = array_filter( $this->components, array( $this, 'is_active_asset_component' ) );
299299

300300
// Enqueue components.
@@ -311,12 +311,24 @@ function ( $component ) {
311311
);
312312
}
313313

314+
/**
315+
* Enqueue the core scripts and styles as needed.
316+
*/
317+
public function enqueue_assets() {
318+
wp_enqueue_style( 'cloudinary' );
319+
wp_enqueue_script( 'cloudinary' );
320+
}
321+
314322
/**
315323
* Register Assets
316324
*
317325
* @since 0.1
318326
*/
319327
public function register_assets() {
328+
// Register Main.
329+
wp_register_script( 'cloudinary', $this->dir_url . 'js/cloudinary.js', array( 'jquery', 'wp-util' ), $this->version, true );
330+
wp_register_style( 'cloudinary', $this->dir_url . 'css/cloudinary.css', null, $this->version );
331+
320332
$components = array_filter( $this->components, array( $this, 'is_asset_component' ) );
321333
array_map(
322334
function ( $component ) {

0 commit comments

Comments
 (0)