Skip to content

Commit 7afb8db

Browse files
authored
Merge pull request #1000 from cloudinary/fix/plugin-loading
Fix plugin loading
2 parents ec47e14 + 7d9b7fa commit 7afb8db

2 files changed

Lines changed: 27 additions & 12 deletions

File tree

php/class-delivery.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1051,7 +1051,13 @@ public function convert_tags( $content, $context = 'view' ) {
10511051
$aliases[ $local_url ] = $cached[ $local_url ];
10521052
continue;
10531053
}
1054-
$cloudinary_url = $this->media->cloudinary_url( $relation['post_id'], explode( 'x', $size ), $relation['transformations'], $public_id );
1054+
1055+
$cloudinary_url = $this->media->cloudinary_url( $relation['post_id'], explode( 'x', $size ), $relation['transformations'], $public_id );
1056+
// The asset is not ready. Carry on.
1057+
if ( empty( $cloudinary_url ) ) {
1058+
continue;
1059+
}
1060+
10551061
$aliases[ $local_url . '?' ] = $cloudinary_url . '&';
10561062
$aliases[ $local_url ] = $cloudinary_url;
10571063

php/class-plugin.php

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -101,15 +101,6 @@ final class Plugin {
101101
* Plugin_Base constructor.
102102
*/
103103
public function __construct() {
104-
require_once ABSPATH . 'wp-admin/includes/plugin.php';
105-
$plugin = get_plugin_data( CLDN_CORE );
106-
$location = $this->locate_plugin();
107-
$this->slug = ! empty( $plugin['TextDomain'] ) ? $plugin['TextDomain'] : $location['dir_basename'];
108-
$this->version = $plugin['Version'];
109-
$this->dir_path = $location['dir_path'];
110-
$this->template_path = $this->dir_path . 'php/templates/';
111-
$this->dir_url = $location['dir_url'];
112-
$this->plugin_file = pathinfo( dirname( CLDN_CORE ), PATHINFO_BASENAME ) . '/' . wp_basename( CLDN_CORE );
113104
$this->setup_endpoints();
114105
spl_autoload_register( array( $this, 'autoload' ) );
115106
$this->register_hooks();
@@ -122,7 +113,7 @@ public function __construct() {
122113
* after_setup_theme priority 10. This is especially important for plugins
123114
* that extend the Customizer to ensure resources are available in time.
124115
*/
125-
public function init() {
116+
public function plugins_loaded() {
126117
Cron::get_instance();
127118
$this->components['admin'] = new Admin( $this );
128119
$this->components['state'] = new State( $this );
@@ -279,8 +270,9 @@ public function set_config() {
279270
* Register Hooks for the plugin.
280271
*/
281272
public function register_hooks() {
282-
add_action( 'plugins_loaded', array( $this, 'init' ), 9 );
273+
add_action( 'plugins_loaded', array( $this, 'plugins_loaded' ), 9 );
283274
add_action( 'admin_enqueue_scripts', array( $this, 'register_enqueue_styles' ), 11 );
275+
add_action( 'init', array( $this, 'init' ) );
284276
// Move to 100 and 200 to allow other plugins/systems to add cloudinary filters and actions that are fired within the init hooks.
285277
add_action( 'init', array( $this, 'setup' ), 100 );
286278
add_action( 'init', array( $this, 'register_assets' ), 200 );
@@ -423,6 +415,23 @@ private function is_notice_component( $component ) {
423415
return $component instanceof Notice;
424416
}
425417

418+
/**
419+
* Init the plugin properties.
420+
*
421+
* @return void
422+
*/
423+
public function init() {
424+
require_once ABSPATH . 'wp-admin/includes/plugin.php';
425+
$plugin = get_plugin_data( CLDN_CORE );
426+
$location = $this->locate_plugin();
427+
$this->slug = ! empty( $plugin['TextDomain'] ) ? $plugin['TextDomain'] : $location['dir_basename'];
428+
$this->version = $plugin['Version'];
429+
$this->dir_path = $location['dir_path'];
430+
$this->template_path = $this->dir_path . 'php/templates/';
431+
$this->dir_url = $location['dir_url'];
432+
$this->plugin_file = pathinfo( dirname( CLDN_CORE ), PATHINFO_BASENAME ) . '/' . wp_basename( CLDN_CORE );
433+
}
434+
426435
/**
427436
* Setup hooks
428437
*

0 commit comments

Comments
 (0)