File tree Expand file tree Collapse file tree 2 files changed +60
-0
lines changed Expand file tree Collapse file tree 2 files changed +60
-0
lines changed Original file line number Diff line number Diff line change
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 hack based 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
+ }
Original file line number Diff line number Diff line change @@ -99,6 +99,7 @@ final class Optml_Manager {
99
99
'wpml ' ,
100
100
'otter_blocks ' ,
101
101
'spectra ' ,
102
+ 'wpsp ' ,
102
103
];
103
104
/**
104
105
* The current state of the buffer.
You can’t perform that action at this time.
0 commit comments