From 61d2e1afaf546048db10fe17eda06ba1b9472ad8 Mon Sep 17 00:00:00 2001 From: Jon Gilkison Date: Wed, 30 Nov 2022 17:27:17 +0700 Subject: [PATCH] * Media Cloud will now import setting from Leopard Offload if you are upgrading. This only works for S3 and S3 compatible cloud storage. If you are using Google, you will have to set that up manually. * When upgrading from Leopard Offload, your links will be migrated as needed, but you can manually run a background task to do them all in one go. * If using Leopard Offload with WooCommerce, after migrating to Media Cloud you must run the command line tool `wp mediacloud:integrations fixLeopardWooLinks` to replace the weird link shortcode that Leopard Offload uses. This tool is only in the premium version. --- classes/Tools/Storage/StorageGlobals.php | 201 --------------- classes/Tools/Storage/StorageTool.php | 135 ++++++++++ .../Tools/Storage/StorageToolMigrations.php | 75 ++++++ config/storage.config.php | 4 + .../includes/sdk/FreemiusWordPress.php | 236 +++++++++--------- ilab-media-tools.php | 10 +- readme.txt | 12 +- 7 files changed, 350 insertions(+), 323 deletions(-) diff --git a/classes/Tools/Storage/StorageGlobals.php b/classes/Tools/Storage/StorageGlobals.php index 7f1e8d3b..258c0716 100644 --- a/classes/Tools/Storage/StorageGlobals.php +++ b/classes/Tools/Storage/StorageGlobals.php @@ -385,85 +385,6 @@ public static function alternativeFormatTypes() { } //endregion - //region Migration - - public static function migrateFromOtherPlugin() { - $beenHereBefore = get_option('mcloud-other-plugins-migrated'); - if (!empty($beenHereBefore)) { - return; - } - - $migratedFrom = null; - $migrated = false; - $statelessVersion = get_option('wp-stateless-current-version'); - if (!empty($statelessVersion)) { - $migrated = static::migrateStatelessSettings(); - $migratedFrom = 'WP-Stateless'; - } else { - $migrated = static::migrateOffloadSettings(); - $migratedFrom = 'WP Offload Media'; - } - - if (!empty($migrated)) { - Environment::UpdateOption('mcloud-tool-enabled-storage', true); - if (current_user_can('manage_options')) { - NoticeManager::instance()->displayAdminNotice('info', "Media Cloud noticed you were using {$migratedFrom} and has migrated your settings automatically. Everything should be working as before, but make sure to double check your Cloud Storage settings.", true, 'mcloud-migrated-other-plugin', 'forever'); - } - update_option('mcloud-other-plugins-did-migrate', $migratedFrom); - } - - update_option('mcloud-other-plugins-migrated', true); - } - - //endregion - - //region Stateless Migrations - - private static function migrateStatelessSettings() { - $jsonConfigData = get_option('sm_key_json'); - if (empty($jsonConfigData)) { - return false; - } - - $bucket = get_option('sm_bucket'); - if (empty($bucket)) { - return false; - } - - $mode = get_option('sm_mode', 'cdn'); - if ($mode === 'disabled') { - return false; - } - - Environment::UpdateOption('mcloud-storage-provider', 'google'); - Environment::UpdateOption('mcloud-storage-google-credentials', $jsonConfigData); - Environment::UpdateOption('mcloud-storage-google-bucket', $bucket); - - $deleteUploads = ($mode === 'stateless'); - if (!empty($deleteUploads)) { - Environment::UpdateOption("mcloud-storage-delete-uploads", true); - } - - $cdn = get_option('sm_custom_domain'); - if (!empty($cdn)) { - Environment::UpdateOption("mcloud-storage-cdn-base", $cdn); - } - - $uploadDir = trim(get_option('sm_root_dir'), '/'); - if (!empty($uploadDir)) { - Environment::UpdateOption("mcloud-storage-prefix", $uploadDir); - } - - $cacheControl = get_option('sm_cache_control'); - if (!empty($cacheControl)) { - Environment::UpdateOption("mcloud-storage-cache-control", $cacheControl); - } - - return true; - } - - //endregion - //region Maintenance public static function reloadSettings() { @@ -471,126 +392,4 @@ public static function reloadSettings() { } //endregion - - //region Offload Migrations - - private static function migrateOffloadMiscSettings($offloadConfig) { - $deleteUploads = arrayPath($offloadConfig, 'remove-local-file', false); - $cdn = arrayPath($offloadConfig, 'cloudfront', null); - $prefix = arrayPath($offloadConfig, 'object-prefix', null); - $usePrefix = arrayPath($offloadConfig, 'enable-object-prefix', false); - - if (!empty($deleteUploads)) { - Environment::UpdateOption("mcloud-storage-delete-uploads", true); - } - - if (!empty($cdn)) { - Environment::UpdateOption("mcloud-storage-cdn-base", 'https://'.$cdn); - } - - if (!empty($prefix) && !empty($usePrefix)) { - $prefix = rtrim($prefix, '/'); - - $useYearMonth = arrayPath($offloadConfig, 'use-yearmonth-folders', false); - if (!empty($useYearMonth)) { - $prefix = trailingslashit($prefix).'@{date:Y/m}'; - } - - $useVersioning = arrayPath($offloadConfig, 'object-versioning', false); - if ($useVersioning) { - $prefix = trailingslashit($prefix).'@{versioning}'; - } - - Environment::UpdateOption("mcloud-storage-prefix", $prefix); - } - } - - private static function migrateOffload($provider, $key, $secret) { - $offloadConfig = get_option('tantan_wordpress_s3'); - $bucket = arrayPath($offloadConfig, 'bucket', null); - $region = arrayPath($offloadConfig, 'region', 'auto'); - if (empty($bucket)) { - return false; - } - - Environment::UpdateOption('mcloud-storage-provider', $provider); - Environment::UpdateOption("mcloud-storage-s3-access-key", $key); - Environment::UpdateOption("mcloud-storage-s3-secret", $secret); - Environment::UpdateOption("mcloud-storage-s3-bucket", $bucket); - - if ($provider === 'do') { - Environment::UpdateOption("mcloud-storage-s3-endpoint", "https://{$region}.digitaloceanspaces.com"); - } else { - Environment::UpdateOption("mcloud-storage-s3-region", $region); - } - - static::migrateOffloadMiscSettings($offloadConfig); - - return true; - } - - private static function migrateOffloadFromConfig($data) { - $provider = arrayPath($data, 'provider', null); - if (empty($provider) || !in_array($provider, ['aws', 'do', 'gcp'])) { - return false; - } - - $providerMap = ['aws' => 's3', 'do' => 'do', 'gcp' => 'google']; - $provider = $providerMap[$provider]; - - if ($provider !== 'google') { - $key = arrayPath($data, 'access-key-id'); - $secret = arrayPath($data, 'secret-access-key'); - - return static::migrateOffload($provider, $key, $secret); - } - - $keyPath = arrayPath($data, 'key-file-path', null); - if (!empty($keyPath) && file_exists($keyPath)) { - $googleConfig = file_get_contents($keyPath); - } else { - $googleConfigData = arrayPath($data, 'key-file', null); - if (empty($googleConfigData) || !is_array($googleConfigData)) { - return false; - } - - $googleConfig = json_encode($googleConfigData, JSON_PRETTY_PRINT); - } - - if (empty($googleConfig)) { - return false; - } - - $offloadConfig = get_option('tantan_wordpress_s3'); - $bucket = arrayPath($offloadConfig, 'bucket', null); - if (empty($bucket)) { - return false; - } - - Environment::UpdateOption('mcloud-storage-provider', 'google'); - Environment::UpdateOption('mcloud-storage-google-credentials', $googleConfig); - Environment::UpdateOption('mcloud-storage-google-bucket', $bucket); - - static::migrateOffloadMiscSettings($offloadConfig); - - return true; - } - - public static function migrateOffloadSettings() { - $migrated = false; - if (defined('AS3CF_SETTINGS')) { - $data = unserialize(constant('AS3CF_SETTINGS')); - if (!empty($data)) { - $migrated = static::migrateOffloadFromConfig($data); - } - } else { - $offloadConfig = get_option('tantan_wordpress_s3'); - if (!empty($offloadConfig)) { - $migrated = static::migrateOffloadFromConfig($offloadConfig); - } - } - - return $migrated; - } - //endregion } \ No newline at end of file diff --git a/classes/Tools/Storage/StorageTool.php b/classes/Tools/Storage/StorageTool.php index ce2afb5c..56dc62b1 100644 --- a/classes/Tools/Storage/StorageTool.php +++ b/classes/Tools/Storage/StorageTool.php @@ -2094,9 +2094,16 @@ public function getAttachmentURL( $url, $post_id ) $new_url = $this->importOffloadMetadata( $post_id, $meta, $offloadS3Info ); } else { $statelessInfo = get_post_meta( $post_id, 'sm_cloud', true ); + if ( !empty($statelessInfo) ) { $new_url = $this->importStatelessMetadata( $post_id, $meta, $statelessInfo ); + } else { + $leopardInfo = get_post_meta( $post_id, '_nou_leopard_wom_amazonS3_info', true ); + if ( !empty($leopardInfo) ) { + $new_url = $this->importLeopardMetadata( $post_id, $meta, $leopardInfo ); + } } + } } @@ -4914,6 +4921,127 @@ private function getOffloadS3URL( return null; } + /** + * Generates a URL from Leopard Offload + * + * @param $provider + * @param $region + * @param $bucket + * @param $key + * + * @return string|null + * + * @throws StorageException + */ + private function getLeopardURL( + string $provider, + $region, + $bucket, + $key + ) + { + $prefixFix = Environment::Option( 'mcloud-leopard-prefix-fix', null, false ); + if ( !empty($prefixFix) ) { + $key = $prefixFix . '/' . $key; + } + if ( $provider === StorageToolSettings::driver() && $bucket === $this->client->bucket() ) { + return $this->client->url( $key ); + } + + if ( $provider === 's3' ) { + if ( empty($region) ) { + return "https://s3.amazonaws.com/{$bucket}/{$key}"; + } + return "https://s3-{$region}.amazonaws.com/{$bucket}/{$key}"; + } + + if ( $provider === 'do' ) { + return "https://{$region}.digitaloceanspaces.com/{$bucket}/{$key}"; + } + if ( $provider === 'google' ) { + return "https://storage.googleapis.com/{$bucket}/{$key}"; + } + return null; + } + + private function importLeopardMetadata( $postId, $meta, $leopardMetadata ) + { + $provider = arrayPath( $leopardMetadata, 'provider', 'aws' ); + $bucket = arrayPath( $leopardMetadata, 'bucket', null ); + $region = arrayPath( $leopardMetadata, 'region', null ); + $key = arrayPath( $leopardMetadata, 'key', null ); + $prefix = Environment::Option( 'mcloud-leopard-prefix-fix', null, false ); + if ( empty($provider) || empty($bucket) || empty($key) || !in_array( $provider, [ + 's3', + 'aws', + 'do', + 'gcp' + ] ) ) { + return null; + } + $providerMap = [ + 'aws' => 's3', + 's3' => 's3', + 'do' => 'do', + 'gcp' => 'google', + ]; + $provider = $providerMap[$provider]; + $mime = get_post_mime_type( $postId ); + $hasMeta = !empty($meta); + if ( empty($meta) ) { + $meta = []; + } + $s3Info = [ + 'url' => $this->getLeopardURL( + $provider, + $region, + $bucket, + $key + ), + 'provider' => $provider, + 'bucket' => $bucket, + 'key' => ( !empty($prefix) ? $prefix . '/' . $key : $key ), + 'privacy' => 'public-read', + 'v' => MEDIA_CLOUD_INFO_VERSION, + 'mime-type' => $mime, + ]; + if ( $provider !== 'google' ) { + $s3Info['region'] = $region; + } + $meta['s3'] = $s3Info; + + if ( isset( $meta['sizes'] ) ) { + $baseKey = ltrim( pathinfo( '/' . $key, PATHINFO_DIRNAME ), '/' ); + $newSizes = []; + foreach ( $meta['sizes'] as $size => $sizeData ) { + $sizeKey = trailingslashit( $baseKey ) . $sizeData['file']; + $sizeS3Info = $s3Info; + $sizeS3Info['url'] = $this->getLeopardURL( + $provider, + $region, + $bucket, + $sizeKey + ); + $sizeS3Info['key'] = ( !empty($prefix) ? $prefix . '/' . $sizeKey : $sizeKey ); + $sizeS3Info['mime-type'] = $sizeData['mime-type']; + $sizeData['s3'] = $sizeS3Info; + $newSizes[$size] = $sizeData; + } + $meta['sizes'] = $newSizes; + } + + + if ( $hasMeta ) { + update_post_meta( $postId, '_wp_attachment_metadata', $meta ); + } else { + update_post_meta( $postId, 'ilab_s3_info', [ + 's3' => $s3Info, + ] ); + } + + return $s3Info['url']; + } + /** * Imports metadata from WP-Stateless * @@ -5148,9 +5276,16 @@ public function migratePostFromOtherPlugin( $postId ) $new_url = $this->importOffloadMetadata( $postId, $meta, $offloadS3Info ); } else { $statelessInfo = get_post_meta( $postId, 'sm_cloud', true ); + if ( !empty($statelessInfo) ) { $new_url = $this->importStatelessMetadata( $postId, $meta, $statelessInfo ); + } else { + $leopardInfo = get_post_meta( $postId, '_nou_leopard_wom_amazonS3_info', true ); + if ( !empty($leopardInfo) ) { + $new_url = $this->importLeopardMetadata( $postId, $meta, $leopardInfo ); + } } + } return !empty($new_url); diff --git a/classes/Tools/Storage/StorageToolMigrations.php b/classes/Tools/Storage/StorageToolMigrations.php index c3dd2da0..be520687 100644 --- a/classes/Tools/Storage/StorageToolMigrations.php +++ b/classes/Tools/Storage/StorageToolMigrations.php @@ -16,6 +16,7 @@ namespace MediaCloud\Plugin\Tools\Storage; +use function MediaCloud\Plugin\Utilities\anyEmpty; use function MediaCloud\Plugin\Utilities\arrayPath; use MediaCloud\Plugin\Utilities\Environment; use MediaCloud\Plugin\Utilities\NoticeManager; @@ -35,9 +36,13 @@ public static function migrateFromOtherPlugin() { $migratedFrom = null; $migrated = false; $statelessVersion = get_option('wp-stateless-current-version'); + $leopardSchemaVersion = get_option('leopard_schema_version'); if (!empty($statelessVersion)) { $migrated = static::migrateStatelessSettings(); $migratedFrom = 'WP-Stateless'; + } else if (!empty($leopardSchemaVersion)) { + $migrated = static::migrateLeopardSettings(); + $migratedFrom = 'Leopard Offload'; } else { $migrated = static::migrateOffloadSettings(); $migratedFrom = 'WP Offload Media'; @@ -48,6 +53,7 @@ public static function migrateFromOtherPlugin() { if (current_user_can('manage_options')) { NoticeManager::instance()->displayAdminNotice('info', "Media Cloud noticed you were using {$migratedFrom} and has migrated your settings automatically. Everything should be working as before, but make sure to double check your Cloud Storage settings.", true, 'mcloud-migrated-other-plugin', 'forever'); } + update_option('mcloud-other-plugins-did-migrate', $migratedFrom); } @@ -207,6 +213,75 @@ private static function migrateOffloadFromConfig($data) { return true; } + public static function migrateLeopardSettings() { + $settings = get_option('nou_leopard_offload_media', null); + if (empty($settings)) { + return false; + } + + $provider = arrayPath($settings, 'provider', null); + $key = arrayPath($settings, 'access_key', null); + $secret = arrayPath($settings, 'secret_access_key', null); + + if (anyEmpty($provider, $key, $secret)) { + return false; + } + + $providerMap = ['aws' => 's3', 's3' => 's3', 'do' => 'do']; + if (!in_array($provider, array_keys($providerMap))) { + return false; + } + $provider = $providerMap[$provider]; + + $weirdBucketRegionThing = get_option('nou_leopard_offload_media_connection_bucket_selected_select'); + if (strpos($weirdBucketRegionThing, '_nou_wc_as3s_separator_') === false) { + return false; + } + + $bucketRegion = explode('_nou_wc_as3s_separator_', $weirdBucketRegionThing); + if (count($bucketRegion) !== 2) { + return false; + } + + $bucket = $bucketRegion[0]; + $region = $bucketRegion[1]; + + Environment::UpdateOption('mcloud-storage-provider', $provider); + Environment::UpdateOption("mcloud-storage-s3-access-key", $key); + Environment::UpdateOption("mcloud-storage-s3-secret", $secret); + Environment::UpdateOption("mcloud-storage-s3-bucket", $bucket); + + if ($provider === 'do') { + Environment::UpdateOption("mcloud-storage-s3-endpoint", "https://{$region}.digitaloceanspaces.com"); + } else { + Environment::UpdateOption("mcloud-storage-s3-region", $region); + } + + $prefix = get_option('nou_leopard_offload_media_bucket_folder_main', null); + $deleteUploads = get_option('nou_leopard_offload_media_remove_from_server_checkbox', null); + $cdn = get_option('nou_leopard_offload_media_cname'); + + if ($deleteUploads === 'on') { + Environment::UpdateOption("mcloud-storage-delete-uploads", true); + } + + if (!empty($cdn)) { + Environment::UpdateOption("mcloud-storage-cdn-base", 'https://'.$cdn); + } + + if (!empty($prefix)) { + $prefix = ltrim(rtrim($prefix, '/'), '/'); + Environment::UpdateOption('mcloud-leopard-prefix-fix', $prefix); + + $prefix .= '/@{date:Y/m}'; + Environment::UpdateOption("mcloud-storage-prefix", $prefix); + } + + + + return true; + } + public static function migrateOffloadSettings() { $migrated = false; if (defined('AS3CF_SETTINGS')) { diff --git a/config/storage.config.php b/config/storage.config.php index f23d1019..545b034f 100644 --- a/config/storage.config.php +++ b/config/storage.config.php @@ -49,6 +49,10 @@ "plugin" => "image-sizes/image-sizes.php", "description" => "A useless plugin that can cause media uploads to fail, with or without Media Cloud. Not exactly sure how it has so many stars." ], + "Leopard Offload" => [ + "plugin" => "leopard-wordpress-offload-media/leopard-wordpress-offload-media.php", + "description" => "An offloading plugin. Not compatible with Media Cloud." + ], ], "CLI" => [ "\\MediaCloud\\Plugin\\Tools\\Storage\\CLI\\StorageCommands" diff --git a/external/Freemius/includes/sdk/FreemiusWordPress.php b/external/Freemius/includes/sdk/FreemiusWordPress.php index 5368796e..078582c9 100644 --- a/external/Freemius/includes/sdk/FreemiusWordPress.php +++ b/external/Freemius/includes/sdk/FreemiusWordPress.php @@ -1,91 +1,91 @@ '7.37' ); +$curl_version = FS_SDK__HAS_CURL ? + curl_version() : + array( 'version' => '7.37' ); - if ( ! defined( 'FS_API__PROTOCOL' ) ) { - define( 'FS_API__PROTOCOL', version_compare( $curl_version['version'], '7.37', '>=' ) ? 'https' : 'http' ); - } +if ( ! defined( 'FS_API__PROTOCOL' ) ) { + define( 'FS_API__PROTOCOL', version_compare( $curl_version['version'], '7.37', '>=' ) ? 'https' : 'http' ); +} - if ( ! defined( 'FS_API__LOGGER_ON' ) ) { - define( 'FS_API__LOGGER_ON', false ); - } +if ( ! defined( 'FS_API__LOGGER_ON' ) ) { + define( 'FS_API__LOGGER_ON', false ); +} - if ( ! defined( 'FS_API__ADDRESS' ) ) { - define( 'FS_API__ADDRESS', '://api.freemius.com' ); - } - if ( ! defined( 'FS_API__SANDBOX_ADDRESS' ) ) { - define( 'FS_API__SANDBOX_ADDRESS', '://sandbox-api.freemius.com' ); - } +if ( ! defined( 'FS_API__ADDRESS' ) ) { + define( 'FS_API__ADDRESS', '://api.freemius.com' ); +} +if ( ! defined( 'FS_API__SANDBOX_ADDRESS' ) ) { + define( 'FS_API__SANDBOX_ADDRESS', '://sandbox-api.freemius.com' ); +} - if ( ! class_exists( 'Freemius_Api_WordPress' ) ) { +if ( ! class_exists( 'Freemius_Api_WordPress' ) ) { class Freemius_Api_WordPress extends Freemius_Api_Base { private static $_logger = array(); @@ -233,12 +233,12 @@ function GenerateAuthorizationParams( $date = date( 'r', $now ); if ( in_array( $pMethod, array( 'POST', 'PUT' ) ) ) { - $content_type = 'application/json'; + $content_type = 'application/json'; - if ( ! empty( $pPostParams ) ) { - $content_md5 = md5( $pPostParams ); - } - } + if ( ! empty( $pPostParams ) ) { + $content_md5 = md5( $pPostParams ); + } + } $string_to_sign = implode( $eol, array( $pMethod, @@ -255,10 +255,10 @@ function GenerateAuthorizationParams( $auth = array( 'date' => $date, 'authorization' => $auth_type . ' ' . $this->_id . ':' . - $this->_public . ':' . - self::Base64UrlEncode( hash_hmac( - 'sha256', $string_to_sign, $this->_secret - ) ) + $this->_public . ':' . + self::Base64UrlEncode( hash_hmac( + 'sha256', $string_to_sign, $this->_secret + ) ) ); if ( ! empty( $content_md5 ) ) { @@ -270,8 +270,8 @@ function GenerateAuthorizationParams( /** * Get API request URL signed via query string. - * - * @since 1.2.3 Stopped using http_build_query(). Instead, use urlencode(). In some environments the encoding of http_build_query() can generate a URL that once used with a redirect, the `&` querystring separator is escaped to `&` which breaks the URL (Added by @svovaf). + * + * @since 1.2.3 Stopped using http_build_query(). Instead, use urlencode(). In some environments the encoding of http_build_query() can generate a URL that once used with a redirect, the `&` querystring separator is escaped to `&` which breaks the URL (Added by @svovaf). * * @param string $pPath * @@ -279,19 +279,19 @@ function GenerateAuthorizationParams( * * @return string */ - function GetSignedUrl( $pPath ) { - $resource = explode( '?', $this->CanonizePath( $pPath ) ); - $pResourceUrl = $resource[0]; - - $auth = $this->GenerateAuthorizationParams( $pResourceUrl ); - - return Freemius_Api_WordPress::GetUrl( - $pResourceUrl . '?' . - ( 1 < count( $resource ) && ! empty( $resource[1] ) ? $resource[1] . '&' : '' ) . - 'authorization=' . urlencode( $auth['authorization'] ) . - '&auth_date=' . urlencode( $auth['date'] ) - , $this->_isSandbox ); - } + function GetSignedUrl( $pPath ) { + $resource = explode( '?', $this->CanonizePath( $pPath ) ); + $pResourceUrl = $resource[0]; + + $auth = $this->GenerateAuthorizationParams( $pResourceUrl ); + + return Freemius_Api_WordPress::GetUrl( + $pResourceUrl . '?' . + ( 1 < count( $resource ) && ! empty( $resource[1] ) ? $resource[1] . '&' : '' ) . + 'authorization=' . urlencode( $auth['authorization'] ) . + '&auth_date=' . urlencode( $auth['date'] ) + , $this->_isSandbox ); + } /** * @author Vova Feldman @@ -302,7 +302,7 @@ function GetSignedUrl( $pPath ) { * @return mixed */ private static function ExecuteRequest( $pUrl, &$pWPRemoteArgs ) { - $bt = debug_backtrace(); + $bt = debug_backtrace(); $start = microtime( true ); @@ -369,7 +369,7 @@ private static function MakeStaticRequest( if ( empty( $pWPRemoteArgs ) ) { $user_agent = 'Freemius/WordPress-SDK/' . Freemius_Api_Base::VERSION . '; ' . - home_url(); + home_url(); $pWPRemoteArgs = array( 'method' => strtoupper( $pMethod ), @@ -383,35 +383,35 @@ private static function MakeStaticRequest( } if ( ! isset( $pWPRemoteArgs['headers'] ) || - ! is_array( $pWPRemoteArgs['headers'] ) + ! is_array( $pWPRemoteArgs['headers'] ) ) { $pWPRemoteArgs['headers'] = array(); } if ( in_array( $pMethod, array( 'POST', 'PUT' ) ) ) { - $pWPRemoteArgs['headers']['Content-type'] = 'application/json'; + $pWPRemoteArgs['headers']['Content-type'] = 'application/json'; - if ( is_array( $pParams ) && 0 < count( $pParams ) ) { - $pWPRemoteArgs['body'] = json_encode( $pParams ); - } + if ( is_array( $pParams ) && 0 < count( $pParams ) ) { + $pWPRemoteArgs['body'] = json_encode( $pParams ); + } } $request_url = self::GetUrl( $pCanonizedPath, $pIsSandbox ); $resource = explode( '?', $pCanonizedPath ); - if ( FS_SDK__HAS_CURL ) { - // Disable the 'Expect: 100-continue' behaviour. This causes cURL to wait - // for 2 seconds if the server does not support this header. - $pWPRemoteArgs['headers']['Expect'] = ''; - } + if ( FS_SDK__HAS_CURL ) { + // Disable the 'Expect: 100-continue' behaviour. This causes cURL to wait + // for 2 seconds if the server does not support this header. + $pWPRemoteArgs['headers']['Expect'] = ''; + } if ( 'https' === substr( strtolower( $request_url ), 0, 5 ) ) { $pWPRemoteArgs['sslverify'] = FS_SDK__SSLVERIFY; } if ( false !== $pBeforeExecutionFunction && - is_callable( $pBeforeExecutionFunction ) + is_callable( $pBeforeExecutionFunction ) ) { $pWPRemoteArgs = call_user_func( $pBeforeExecutionFunction, $resource[0], $pWPRemoteArgs ); } @@ -465,11 +465,11 @@ private static function MakeStaticRequest( if ( is_null( $decoded ) ) { if ( preg_match( '/Please turn JavaScript on/i', $response_body ) && - preg_match( '/text\/javascript/', $response_body ) + preg_match( '/text\/javascript/', $response_body ) ) { self::ThrowCloudFlareDDoSException( $response_body ); } else if ( preg_match( '/Access control configuration prevents your request from being allowed at this time. Please contact your service provider if you feel this is incorrect./', $response_body ) && - preg_match( '/squid/', $response_body ) + preg_match( '/squid/', $response_body ) ) { self::ThrowSquidAclException( $response_body ); } else { @@ -712,4 +712,4 @@ private static function ThrowSquidAclException( $pResult = '' ) { #endregion } - } \ No newline at end of file +} \ No newline at end of file diff --git a/ilab-media-tools.php b/ilab-media-tools.php index 6f04d0f3..4e65bad6 100644 --- a/ilab-media-tools.php +++ b/ilab-media-tools.php @@ -5,7 +5,7 @@ Plugin URI: https://github.com/interfacelab/ilab-media-tools Description: Automatically upload media to Amazon S3 and integrate with Imgix, a real-time image processing CDN. Boosts site performance and simplifies workflows. Author: interfacelab -Version: 4.5.12 +Version: 4.5.14 Requires PHP: 7.4 Author URI: http://interfacelab.io */ @@ -55,7 +55,11 @@

+ ?> You are using PHP ..