| @@ -5,8 +5,15 @@ | ||
| 5 | 5 | |
| 6 | 6 | use DirectoryIterator; |
| 7 | 7 | use Exception; |
| 8 | 8 | |
| 9 | +/** | |
| 10 | + * ACF Compatibility. | |
| 11 | + * | |
| 12 | + * Loaded by the autoloader; activation is gated via `is_installed()` in Integration::init(). | |
| 13 | + * | |
| 14 | + * @since 1.0.0 | |
| 15 | + */ | |
| 9 | 16 | class Acf { |
| 10 | 17 | private static $instance = null; |
| 11 | 18 | private $assets_url; |
| 12 | 19 | private $version; |
| @@ -27,12 +34,9 @@ | ||
| 27 | 34 | $this->settings = Utils::get_settings(); |
| 28 | 35 | $this->content_filter = FilterContent::instance(); |
| 29 | 36 | $this->compatibility = Compatibility::instance(); |
| 30 | 37 | |
| 31 | - if (self::is_installed()) { | |
| 32 | - // Register actions | |
| 33 | - $this->registerActions(); | |
| 34 | - } | |
| 38 | + $this->registerActions(); | |
| 35 | 39 | } |
| 36 | 40 | |
| 37 | 41 | /** |
| 38 | 42 | * Register integration access |
| @@ -85,9 +89,9 @@ | ||
| 85 | 89 | * @return array |
| 86 | 90 | */ |
| 87 | 91 | public function acf_load_config( array $config ): array { |
| 88 | 92 | try { |
| 89 | - $filtered_config = Utils::maybe_unserialize( $this->content_filter->filter_post( serialize( $config ) ) ); | |
| 93 | + $filtered_config = Utils::maybe_unserialize( $this->content_filter->filter_post( Utils::maybe_serialize( $config ) ) ); | |
| 90 | 94 | } catch ( Exception $e ) { |
| 91 | 95 | return $config; |
| 92 | 96 | } |
| 93 | 97 | |
| @@ -135,9 +139,9 @@ | ||
| 135 | 139 | return false; //Attachment not to be removed from server |
| 136 | 140 | } |
| 137 | 141 | |
| 138 | 142 | // Remove the original file from the server |
| 139 | - Item::instance()->may_be_delete_server_files_by_id($original_attachment_id, true); | |
| 143 | + Item::instance()->may_be_delete_server_files_by_id($original_attachment_id, 'media_library', true); | |
| 140 | 144 | |
| 141 | 145 | // Remove marker |
| 142 | 146 | Utils::delete_meta($original_attachment_id, 'acf_cropped_to_remove'); |
| 143 | 147 | |
| @@ -253,13 +257,9 @@ | ||
| 253 | 257 | * |
| 254 | 258 | * @return bool |
| 255 | 259 | */ |
| 256 | 260 | public static function is_installed(): bool { |
| 257 | - if ( class_exists( 'acf', false ) ) { | |
| 258 | - return true; | |
| 259 | - } | |
| 260 | - | |
| 261 | - return false; | |
| 261 | + return class_exists( 'acf', false ); | |
| 262 | 262 | } |
| 263 | 263 | |
| 264 | 264 | /** |
| 265 | 265 | * Singleton instance |