diff --git a/docs/cloudinary_allowed_extensions.html b/docs/cloudinary_allowed_extensions.html
index ff09f24e..93b27396 100644
--- a/docs/cloudinary_allowed_extensions.html
+++ b/docs/cloudinary_allowed_extensions.html
@@ -145,7 +145,7 @@
Parameters:
Source:
diff --git a/docs/cloudinary_apply_breakpoints.html b/docs/cloudinary_apply_breakpoints.html
index a0b58d11..4e1067ee 100644
--- a/docs/cloudinary_apply_breakpoints.html
+++ b/docs/cloudinary_apply_breakpoints.html
@@ -150,7 +150,7 @@ Parameters:
Source:
diff --git a/docs/cloudinary_apply_default_transformations.html b/docs/cloudinary_apply_default_transformations.html
index 4564dc6b..96675e57 100644
--- a/docs/cloudinary_apply_default_transformations.html
+++ b/docs/cloudinary_apply_default_transformations.html
@@ -170,7 +170,7 @@ Parameters:
Source:
diff --git a/docs/cloudinary_asset_payload.html b/docs/cloudinary_asset_payload.html
index 910d3cdf..9538ac96 100644
--- a/docs/cloudinary_asset_payload.html
+++ b/docs/cloudinary_asset_payload.html
@@ -168,7 +168,7 @@ Parameters:
Source:
diff --git a/docs/cloudinary_bypass_seo_url.html b/docs/cloudinary_bypass_seo_url.html
index da3517cd..b26eb8c1 100644
--- a/docs/cloudinary_bypass_seo_url.html
+++ b/docs/cloudinary_bypass_seo_url.html
@@ -145,7 +145,7 @@ Parameters:
Source:
diff --git a/docs/cloudinary_connected.html b/docs/cloudinary_connected.html
index d7a34760..5d485391 100644
--- a/docs/cloudinary_connected.html
+++ b/docs/cloudinary_connected.html
@@ -145,7 +145,7 @@ Parameters:
Source:
diff --git a/docs/cloudinary_content_url.html b/docs/cloudinary_content_url.html
index feb7ad2c..2fb03e2b 100644
--- a/docs/cloudinary_content_url.html
+++ b/docs/cloudinary_content_url.html
@@ -145,7 +145,7 @@ Parameters:
Source:
diff --git a/docs/cloudinary_context_options.html b/docs/cloudinary_context_options.html
index 260a5eae..99475950 100644
--- a/docs/cloudinary_context_options.html
+++ b/docs/cloudinary_context_options.html
@@ -188,7 +188,7 @@ Parameters:
Source:
diff --git a/docs/cloudinary_converted_url.html b/docs/cloudinary_converted_url.html
index 2f981e18..54fd776b 100644
--- a/docs/cloudinary_converted_url.html
+++ b/docs/cloudinary_converted_url.html
@@ -188,7 +188,7 @@ Parameters:
Source:
diff --git a/docs/cloudinary_default_freeform_transformations_%7B$type%7D.html b/docs/cloudinary_default_freeform_transformations_%7B$type%7D.html
index 9db95bdc..39f566b7 100644
--- a/docs/cloudinary_default_freeform_transformations_%7B$type%7D.html
+++ b/docs/cloudinary_default_freeform_transformations_%7B$type%7D.html
@@ -170,7 +170,7 @@ Parameters:
Source:
diff --git a/docs/cloudinary_default_qf_transformations_%7B$type%7D.html b/docs/cloudinary_default_qf_transformations_%7B$type%7D.html
index aec67b2b..951178c1 100644
--- a/docs/cloudinary_default_qf_transformations_%7B$type%7D.html
+++ b/docs/cloudinary_default_qf_transformations_%7B$type%7D.html
@@ -170,7 +170,7 @@ Parameters:
Source:
diff --git a/docs/cloudinary_default_transformations.html b/docs/cloudinary_default_transformations.html
index 98cb29d9..2fa738bd 100644
--- a/docs/cloudinary_default_transformations.html
+++ b/docs/cloudinary_default_transformations.html
@@ -142,7 +142,7 @@ Parameters:
Source:
diff --git a/docs/cloudinary_delivery_searchable_url.html b/docs/cloudinary_delivery_searchable_url.html
index 2942632d..7c848e1c 100644
--- a/docs/cloudinary_delivery_searchable_url.html
+++ b/docs/cloudinary_delivery_searchable_url.html
@@ -191,7 +191,7 @@ Parameters:
Source:
diff --git a/docs/cloudinary_doing_upload.html b/docs/cloudinary_doing_upload.html
index 28ae24d3..418de818 100644
--- a/docs/cloudinary_doing_upload.html
+++ b/docs/cloudinary_doing_upload.html
@@ -148,7 +148,7 @@ Parameters:
Source:
diff --git a/docs/cloudinary_download_asset.html b/docs/cloudinary_download_asset.html
index f88e15e5..266cb014 100644
--- a/docs/cloudinary_download_asset.html
+++ b/docs/cloudinary_download_asset.html
@@ -168,7 +168,7 @@ Parameters:
Source:
diff --git a/docs/cloudinary_edit_asset_permalink.html b/docs/cloudinary_edit_asset_permalink.html
index 78d54ed9..a281609e 100644
--- a/docs/cloudinary_edit_asset_permalink.html
+++ b/docs/cloudinary_edit_asset_permalink.html
@@ -145,7 +145,7 @@ Parameters:
Source:
diff --git a/docs/cloudinary_enable_crop_and_gravity_control.html b/docs/cloudinary_enable_crop_and_gravity_control.html
index 5b2bc342..4332a8ac 100644
--- a/docs/cloudinary_enable_crop_and_gravity_control.html
+++ b/docs/cloudinary_enable_crop_and_gravity_control.html
@@ -150,7 +150,7 @@ Parameters:
Source:
@@ -310,7 +310,7 @@ Parameters:
Source:
diff --git a/docs/cloudinary_filter_out_local.html b/docs/cloudinary_filter_out_local.html
index c6466353..2e5a1a63 100644
--- a/docs/cloudinary_filter_out_local.html
+++ b/docs/cloudinary_filter_out_local.html
@@ -147,7 +147,7 @@ Parameters:
Source:
diff --git a/docs/cloudinary_id.html b/docs/cloudinary_id.html
index 63864427..224a8b87 100644
--- a/docs/cloudinary_id.html
+++ b/docs/cloudinary_id.html
@@ -171,7 +171,7 @@ Parameters:
Source:
diff --git a/docs/cloudinary_init_settings.html b/docs/cloudinary_init_settings.html
index f051e882..98b029ed 100644
--- a/docs/cloudinary_init_settings.html
+++ b/docs/cloudinary_init_settings.html
@@ -145,7 +145,7 @@ Parameters:
Source:
diff --git a/docs/cloudinary_is_content_dir.html b/docs/cloudinary_is_content_dir.html
index 223c8221..1c5ca950 100644
--- a/docs/cloudinary_is_content_dir.html
+++ b/docs/cloudinary_is_content_dir.html
@@ -168,7 +168,7 @@ Parameters:
Source:
diff --git a/docs/cloudinary_is_folder_synced.html b/docs/cloudinary_is_folder_synced.html
index 6e67fdba..2e2740c9 100644
--- a/docs/cloudinary_is_folder_synced.html
+++ b/docs/cloudinary_is_folder_synced.html
@@ -165,7 +165,7 @@ Parameters:
Source:
diff --git a/docs/cloudinary_is_uploadable_media.html b/docs/cloudinary_is_uploadable_media.html
index 74f73674..72182a71 100644
--- a/docs/cloudinary_is_uploadable_media.html
+++ b/docs/cloudinary_is_uploadable_media.html
@@ -168,7 +168,7 @@ Parameters:
Source:
diff --git a/docs/cloudinary_local_url.html b/docs/cloudinary_local_url.html
index be0e1f1c..5d94ff3d 100644
--- a/docs/cloudinary_local_url.html
+++ b/docs/cloudinary_local_url.html
@@ -171,7 +171,7 @@ Parameters:
Source:
diff --git a/docs/cloudinary_max_files_import.html b/docs/cloudinary_max_files_import.html
index a6c0d904..fa5b838d 100644
--- a/docs/cloudinary_max_files_import.html
+++ b/docs/cloudinary_max_files_import.html
@@ -150,7 +150,7 @@ Parameters:
Source:
diff --git a/docs/cloudinary_migrate_legacy_meta.html b/docs/cloudinary_migrate_legacy_meta.html
index 04103925..0048b8bf 100644
--- a/docs/cloudinary_migrate_legacy_meta.html
+++ b/docs/cloudinary_migrate_legacy_meta.html
@@ -145,7 +145,7 @@ Parameters:
Source:
diff --git a/docs/cloudinary_parse_element.html b/docs/cloudinary_parse_element.html
index 181333ee..35bc2c23 100644
--- a/docs/cloudinary_parse_element.html
+++ b/docs/cloudinary_parse_element.html
@@ -145,7 +145,7 @@ Parameters:
Source:
diff --git a/docs/cloudinary_prepare_size.html b/docs/cloudinary_prepare_size.html
index a056d0f2..4e788d74 100644
--- a/docs/cloudinary_prepare_size.html
+++ b/docs/cloudinary_prepare_size.html
@@ -168,7 +168,7 @@ Parameters:
Source:
diff --git a/docs/cloudinary_preview_types.html b/docs/cloudinary_preview_types.html
index d918e4a5..71ba6901 100644
--- a/docs/cloudinary_preview_types.html
+++ b/docs/cloudinary_preview_types.html
@@ -147,7 +147,7 @@ Parameters:
Source:
diff --git a/docs/cloudinary_raw_url.html b/docs/cloudinary_raw_url.html
index 5fb85a0f..e65cead3 100644
--- a/docs/cloudinary_raw_url.html
+++ b/docs/cloudinary_raw_url.html
@@ -171,7 +171,7 @@ Parameters:
Source:
diff --git a/docs/cloudinary_ready.html b/docs/cloudinary_ready.html
index cc1e8911..432e94f1 100644
--- a/docs/cloudinary_ready.html
+++ b/docs/cloudinary_ready.html
@@ -145,7 +145,7 @@ Parameters:
Source:
diff --git a/docs/cloudinary_resource_type.html b/docs/cloudinary_resource_type.html
index 3bc6dbc6..5cdf490d 100644
--- a/docs/cloudinary_resource_type.html
+++ b/docs/cloudinary_resource_type.html
@@ -165,7 +165,7 @@ Parameters:
Source:
diff --git a/docs/cloudinary_set_usable_asset.html b/docs/cloudinary_set_usable_asset.html
index bb8dfd93..c69cddc7 100644
--- a/docs/cloudinary_set_usable_asset.html
+++ b/docs/cloudinary_set_usable_asset.html
@@ -145,7 +145,7 @@ Parameters:
Source:
diff --git a/docs/cloudinary_transformations.html b/docs/cloudinary_transformations.html
index a4911e03..7d940cb4 100644
--- a/docs/cloudinary_transformations.html
+++ b/docs/cloudinary_transformations.html
@@ -165,7 +165,7 @@ Parameters:
Source:
diff --git a/docs/cloudinary_upload_options.html b/docs/cloudinary_upload_options.html
index 5551c9b2..82d8837f 100644
--- a/docs/cloudinary_upload_options.html
+++ b/docs/cloudinary_upload_options.html
@@ -188,7 +188,7 @@ Parameters:
Source:
diff --git a/docs/cloudinary_validate_cloudinary_id.html b/docs/cloudinary_validate_cloudinary_id.html
index 56a58b1c..0ced662d 100644
--- a/docs/cloudinary_validate_cloudinary_id.html
+++ b/docs/cloudinary_validate_cloudinary_id.html
@@ -168,7 +168,7 @@ Parameters:
Source:
diff --git a/docs/php_class-delivery.php.html b/docs/php_class-delivery.php.html
index d0522fee..29e78e2f 100644
--- a/docs/php_class-delivery.php.html
+++ b/docs/php_class-delivery.php.html
@@ -1101,7 +1101,13 @@ Source: php/class-delivery.php
$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;
diff --git a/docs/php_class-media.php.html b/docs/php_class-media.php.html
index c83793c0..80eaa2da 100644
--- a/docs/php_class-media.php.html
+++ b/docs/php_class-media.php.html
@@ -402,22 +402,16 @@ Source: php/class-media.php
if ( ! filter_var( $url, FILTER_VALIDATE_URL ) ) {
return false;
}
- // phpcs:disable WordPress.WP.AlternativeFunctions
- $ch = curl_init( $url );
- curl_setopt( $ch, CURLOPT_NOBODY, true );
- curl_exec( $ch );
- $code = curl_getinfo( $ch, CURLINFO_HTTP_CODE );
-
- if ( 200 === $code ) {
- $status = true;
- } else {
- $status = false;
+
+ $head = wp_safe_remote_head( $url );
+
+ if ( is_wp_error( $head ) ) {
+ return false;
}
- curl_close( $ch );
- // phpcs:enable
+ $code = wp_remote_retrieve_response_code( $head );
- return $status;
+ return 200 === $code;
}
/**
diff --git a/docs/php_class-plugin.php.html b/docs/php_class-plugin.php.html
index 08f6998e..2c5cceec 100644
--- a/docs/php_class-plugin.php.html
+++ b/docs/php_class-plugin.php.html
@@ -135,15 +135,6 @@ Source: php/class-plugin.php
* 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();
@@ -156,7 +147,7 @@ Source: php/class-plugin.php
* 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 );
@@ -313,8 +304,9 @@ Source: php/class-plugin.php
* 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 );
@@ -457,6 +449,23 @@ Source: php/class-plugin.php
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
*
diff --git a/docs/php_sync_class-sync-queue.php.html b/docs/php_sync_class-sync-queue.php.html
index 4f2046d8..d7af8fe5 100644
--- a/docs/php_sync_class-sync-queue.php.html
+++ b/docs/php_sync_class-sync-queue.php.html
@@ -458,18 +458,18 @@ Source: php/sync/class-sync-queue.php
$return = array(
// Original sizes.
'original_size' => $total_local_size,
- 'original_size_percent' => '100%', // The original will always be 100%, as it's the comparison to optimized.
+ 'original_size_percent' => 0 !== $total_assets ? '100%' : '0%', // The original will always be 100%, as it's the comparison to optimized.
'original_size_hr' => size_format( $total_local_size ),
// Optimized size. We use the `original_size` to determine the percentage between for the progress bar.
'optimized_size' => $total_remote_size,
- 'optimized_size_percent' => round( abs( $total_remote_size ) / abs( $total_local_size ) * 100 ) . '%', // This is the percentage difference.
- 'optimized_diff_percent' => round( ( $total_local_size - $total_remote_size ) / $total_local_size * 100 ) . '%', // We use this for the "Size saved.." status text.
+ 'optimized_size_percent' => $total_local_size > 0 ? round( abs( $total_remote_size ) / abs( $total_local_size ) * 100 ) . '%' : '0%', // This is the percentage difference.
+ 'optimized_diff_percent' => $total_local_size > 0 ? round( ( $total_local_size - $total_remote_size ) / $total_local_size * 100 ) . '%' : '0%', // We use this for the "Size saved.." status text.
'optimized_size_hr' => size_format( $total_remote_size ), // This is the formatted byte size.
// Optimized is the % optimized vs unoptimized.
- 'optimized_percent' => round( $total_optimized / $total_assets, 4 ),
- 'optimized_percent_hr' => round( $total_optimized / $total_assets * 100, 1 ) . '%',
+ 'optimized_percent' => $total_assets > 0 ? round( $total_optimized / $total_assets, 4 ) : 0,
+ 'optimized_percent_hr' => $total_assets > 0 ? round( $total_optimized / $total_assets * 100, 1 ) . '%' : '0%',
'optimized_info' => __( 'Optimized assets', 'cloudinary' ),
// Error size: No mockups on what to display here.