| 1 |
<?php |
| 2 |
|
| 3 |
namespace OptimoleWP\Offload; |
| 4 |
|
| 5 |
/** |
| 6 |
* Class Loader |
| 7 |
* |
| 8 |
* Handles the registration of custom image editors for the Optimole WordPress plugin. |
| 9 |
* This class is responsible for integrating Optimole's custom image processing |
| 10 |
* capabilities into WordPress's image editing system. |
| 11 |
* |
| 12 |
* @package OptimoleWP\Offload |
| 13 |
*/ |
| 14 |
class Loader { |
| 15 |
|
| 16 |
/** |
| 17 |
* Constructor for the Loader class. |
| 18 |
*/ |
| 19 |
public function __construct() { |
| 20 |
} |
| 21 |
|
| 22 |
/** |
| 23 |
* Register WordPress hooks needed for the image editor functionality. |
| 24 |
* |
| 25 |
* Adds filters to integrate the custom image editor into WordPress. |
| 26 |
*/ |
| 27 |
public function register_hooks() { |
| 28 |
if ( has_filter( 'wp_image_editors', 'photon_subsizes_override_image_editors' ) ) { |
| 29 |
return; |
| 30 |
} |
| 31 |
add_filter( 'wp_image_editors', [ $this, 'register_image_editor' ] ); |
| 32 |
} |
| 33 |
|
| 34 |
/** |
| 35 |
* Register the custom ImageEditor class to WordPress's image editors list. |
| 36 |
* |
| 37 |
* Adds Optimole's custom ImageEditor to the beginning of WordPress's image editors array, |
| 38 |
* giving it priority over the default editors. |
| 39 |
* |
| 40 |
* @param array $editors Array of image editor class names. |
| 41 |
* @return array Modified array of image editor class names. |
| 42 |
*/ |
| 43 |
public function register_image_editor( $editors ) { |
| 44 |
array_unshift( $editors, ImageEditor::class ); |
| 45 |
return $editors; |
| 46 |
} |
| 47 |
} |
| 48 |
|