PluginProbe
Optimole – Optimize Images | Convert WebP & AVIF | CDN & Lazy Load | Image Optimization / 4.2.11
Optimole – Optimize Images | Convert WebP & AVIF | CDN & Lazy Load | Image Optimization v4.2.11
4.2.13 4.2.12 4.2.11 4.2.10 4.2.9 4.2.8 4.2.7 4.2.6 4.2.5 2.5.5 2.5.6 2.5.7 3.0.0 3.0.1 3.1.0 3.1.1 3.1.2 3.1.3 3.10.0 3.11.0 3.11.1 3.11.2 3.11.3 3.12.0 3.12.1 All 134 releases
optimole-wp / inc / compatibilities / wpsp.php

wpsp.php in Optimole – Optimize Images | Convert WebP & AVIF | CDN & Lazy Load | Image Optimization 4.2.11, at inc/compatibilities/wpsp.php

60 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Class Optml_wpsp
5 *
6 * @reason WP Show Posts is using an image resizer that is not compatible with Optimole.
7 */
8 class Optml_wpsp extends Optml_compatibility {
9 /**
10 * The last attribute used.
11 *
12 * @var array
13 */
14 private static $last_attribute = [];
15
16 /**
17 * Should we load the integration logic.
18 *
19 * @return bool Should we load.
20 */
21 public function should_load() {
22 include_once ABSPATH . 'wp-admin/includes/plugin.php';
23
24 return is_plugin_active( 'wp-show-posts/wp-show-posts.php' );
25 }
26
27 /**
28 * Should we early load the compatibility?
29 *
30 * @return bool Whether to load the compatibility or not.
31 */
32 public function should_load_early() {
33 return true;
34 }
35
36 /**
37 * Register integration details.
38 */
39 public function register() {
40 // This is a hack to fix the breaking images, we can reconsider when this is merged https://github.com/tomusborne/wp-show-posts/issues/50
41 add_filter(
42 'wpsp_image_attributes',
43 function ( $attribute ) {
44 self::$last_attribute = $attribute;
45
46 return '';
47 }
48 );
49 add_filter(
50 'wpsp_default_image_size',
51 function ( $size ) {
52 return isset( self::$last_attribute['width'], self::$last_attribute['height'] ) ? [
53 self::$last_attribute['width'],
54 self::$last_attribute['height'],
55 ] : 'full';
56 }
57 );
58 }
59 }
60