Skip to content

Commit

Permalink
Merge pull request #1000 from cloudinary/fix/plugin-loading
Browse files Browse the repository at this point in the history
Fix plugin loading
  • Loading branch information
pereirinha authored Dec 3, 2024
2 parents ec47e14 + 7d9b7fa commit 7afb8db
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 12 deletions.
8 changes: 7 additions & 1 deletion php/class-delivery.php
Original file line number Diff line number Diff line change
Expand Up @@ -1051,7 +1051,13 @@ public function convert_tags( $content, $context = 'view' ) {
$aliases[ $local_url ] = $cached[ $local_url ];
continue;
}
$cloudinary_url = $this->media->cloudinary_url( $relation['post_id'], explode( 'x', $size ), $relation['transformations'], $public_id );

$cloudinary_url = $this->media->cloudinary_url( $relation['post_id'], explode( 'x', $size ), $relation['transformations'], $public_id );
// The asset is not ready. Carry on.
if ( empty( $cloudinary_url ) ) {
continue;
}

$aliases[ $local_url . '?' ] = $cloudinary_url . '&';
$aliases[ $local_url ] = $cloudinary_url;

Expand Down
31 changes: 20 additions & 11 deletions php/class-plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,15 +101,6 @@ final class Plugin {
* Plugin_Base constructor.
*/
public function __construct() {
require_once ABSPATH . 'wp-admin/includes/plugin.php';
$plugin = get_plugin_data( CLDN_CORE );
$location = $this->locate_plugin();
$this->slug = ! empty( $plugin['TextDomain'] ) ? $plugin['TextDomain'] : $location['dir_basename'];
$this->version = $plugin['Version'];
$this->dir_path = $location['dir_path'];
$this->template_path = $this->dir_path . 'php/templates/';
$this->dir_url = $location['dir_url'];
$this->plugin_file = pathinfo( dirname( CLDN_CORE ), PATHINFO_BASENAME ) . '/' . wp_basename( CLDN_CORE );
$this->setup_endpoints();
spl_autoload_register( array( $this, 'autoload' ) );
$this->register_hooks();
Expand All @@ -122,7 +113,7 @@ public function __construct() {
* after_setup_theme priority 10. This is especially important for plugins
* that extend the Customizer to ensure resources are available in time.
*/
public function init() {
public function plugins_loaded() {
Cron::get_instance();
$this->components['admin'] = new Admin( $this );
$this->components['state'] = new State( $this );
Expand Down Expand Up @@ -279,8 +270,9 @@ public function set_config() {
* Register Hooks for the plugin.
*/
public function register_hooks() {
add_action( 'plugins_loaded', array( $this, 'init' ), 9 );
add_action( 'plugins_loaded', array( $this, 'plugins_loaded' ), 9 );
add_action( 'admin_enqueue_scripts', array( $this, 'register_enqueue_styles' ), 11 );
add_action( 'init', array( $this, 'init' ) );
// Move to 100 and 200 to allow other plugins/systems to add cloudinary filters and actions that are fired within the init hooks.
add_action( 'init', array( $this, 'setup' ), 100 );
add_action( 'init', array( $this, 'register_assets' ), 200 );
Expand Down Expand Up @@ -423,6 +415,23 @@ private function is_notice_component( $component ) {
return $component instanceof Notice;
}

/**
* Init the plugin properties.
*
* @return void
*/
public function init() {
require_once ABSPATH . 'wp-admin/includes/plugin.php';
$plugin = get_plugin_data( CLDN_CORE );
$location = $this->locate_plugin();
$this->slug = ! empty( $plugin['TextDomain'] ) ? $plugin['TextDomain'] : $location['dir_basename'];
$this->version = $plugin['Version'];
$this->dir_path = $location['dir_path'];
$this->template_path = $this->dir_path . 'php/templates/';
$this->dir_url = $location['dir_url'];
$this->plugin_file = pathinfo( dirname( CLDN_CORE ), PATHINFO_BASENAME ) . '/' . wp_basename( CLDN_CORE );
}

/**
* Setup hooks
*
Expand Down

0 comments on commit 7afb8db

Please sign in to comment.