| @@ -1,6 +1,9 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | +use Optimole\Sdk\Resource\ImageProperty\ResizeTypeProperty; | |
| 4 | +use Optimole\Sdk\ValueObject\Position; | |
| 5 | + | |
| 3 | 6 | /** |
| 4 | 7 | * Class Optml_shortcode_ultimate. |
| 5 | 8 | * |
| 6 | 9 | * @reason The gallery output contains a different src attribute used for lazyload |
| @@ -12,10 +15,10 @@ | ||
| 12 | 15 | * Should we load the integration logic. |
| 13 | 16 | * |
| 14 | 17 | * @return bool Should we load. |
| 15 | 18 | */ |
| 16 | - function should_load() { | |
| 17 | - include_once( ABSPATH . 'wp-admin/includes/plugin.php' ); | |
| 19 | + public function should_load() { | |
| 20 | + include_once ABSPATH . 'wp-admin/includes/plugin.php'; | |
| 18 | 21 | |
| 19 | 22 | return ( is_plugin_active( 'envira-gallery-lite/envira-gallery-lite.php' ) || is_plugin_active( 'envira-gallery/envira-gallery.php' ) ); |
| 20 | 23 | } |
| 21 | 24 | |
| @@ -22,11 +25,11 @@ | ||
| 22 | 25 | /** |
| 23 | 26 | * Register integration details. |
| 24 | 27 | */ |
| 25 | 28 | public function register() { |
| 26 | - add_filter( 'optml_possible_lazyload_flags', [ $this, 'add_lazyflag' ], 10, 2 ); | |
| 29 | + add_filter( 'optml_possible_lazyload_flags', [ $this, 'add_lazyflag' ], 10 ); | |
| 27 | 30 | add_filter( 'optml_parse_resize_from_tag', [ $this, 'check_resize_tag' ], 10, 2 ); |
| 28 | - add_filter( 'envira_gallery_image_src', [ $this, 'revert_src' ], 10, 1 ); | |
| 31 | + add_filter( 'envira_gallery_image_src', [ $this, 'revert_src' ], 10 ); | |
| 29 | 32 | } |
| 30 | 33 | |
| 31 | 34 | /** |
| 32 | 35 | * Revert the optimole url to the original state in |
| @@ -35,11 +38,11 @@ | ||
| 35 | 38 | * @param string $image Image url. |
| 36 | 39 | * |
| 37 | 40 | * @return string Original url. |
| 38 | 41 | */ |
| 39 | - function revert_src( $image ) { | |
| 40 | - | |
| 41 | - if ( ( $pos = strpos( $image, '/http' ) ) !== false ) { | |
| 42 | + public function revert_src( $image ) { | |
| 43 | + $pos = strpos( $image, '/http' ); | |
| 44 | + if ( $pos !== false ) { | |
| 42 | 45 | return ltrim( substr( $image, $pos ), '/' ); |
| 43 | 46 | } |
| 44 | 47 | |
| 45 | 48 | return $image; |
| @@ -52,13 +55,13 @@ | ||
| 52 | 55 | * @param string $tag Image tag. |
| 53 | 56 | * |
| 54 | 57 | * @return array Resize conf. |
| 55 | 58 | */ |
| 56 | - function check_resize_tag( $old_resize, $tag ) { | |
| 59 | + public function check_resize_tag( $old_resize, $tag ) { | |
| 57 | 60 | if ( preg_match( '/(_c)\.(?:' . implode( '|', array_keys( Optml_Config::$image_extensions ) ) . ')/i', $tag, $match ) ) { |
| 58 | 61 | return [ |
| 59 | - 'type' => Optml_Resize::RESIZE_FILL, | |
| 60 | - 'gravity' => Optml_Resize::GRAVITY_CENTER, | |
| 62 | + 'type' => ResizeTypeProperty::FILL, | |
| 63 | + 'gravity' => Position::CENTER, | |
| 61 | 64 | ]; |
| 62 | 65 | } |
| 63 | 66 | |
| 64 | 67 | return []; |
| @@ -70,9 +73,9 @@ | ||
| 70 | 73 | * @param array $strings Old strings. |
| 71 | 74 | * |
| 72 | 75 | * @return array New flags. |
| 73 | 76 | */ |
| 74 | - function add_lazyflag( $strings = array() ) { | |
| 77 | + public function add_lazyflag( $strings = [] ) { | |
| 75 | 78 | |
| 76 | 79 | $strings[] = 'envira-gallery-image'; |
| 77 | 80 | |
| 78 | 81 | return $strings; |