File tree Expand file tree Collapse file tree 3 files changed +61
-3
lines changed Expand file tree Collapse file tree 3 files changed +61
-3
lines changed Original file line number Diff line number Diff line change 2424 run : composer phpcs
2525 phpunit :
2626 name : PHPUnit tests on ${{ matrix.php-versions }}
27- runs-on : ubuntu-latest
27+ runs-on : ubuntu-22.04
2828 strategy :
2929 fail-fast : false
3030 matrix :
4444 php-version : ${{ matrix.php-version }}
4545 extensions : simplexml, mysql
4646 tools : phpunit-polyfills:1.1
47- - name : Install Subversion
48- run : sudo apt-get update && sudo apt-get install -y subversion
4947 - name : Checkout source code
5048 uses : actions/checkout@v4
5149 - name : Install WordPress Test Suite
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 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+ }
Original file line number Diff line number Diff line change @@ -99,6 +99,7 @@ final class Optml_Manager {
9999 'wpml ' ,
100100 'otter_blocks ' ,
101101 'spectra ' ,
102+ 'wpsp ' ,
102103 ];
103104 /**
104105 * The current state of the buffer.
You can’t perform that action at this time.
0 commit comments