Skip to content

Commit 3b66c03

Browse files
authored
Merge pull request #952 from Codeinwp/fix/jetengine-comp
fix: Incompatibility with JetEngine
2 parents d0e3652 + 3986b1e commit 3b66c03

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed

inc/compatibilities/jetengine.php

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<?php
2+
3+
/**
4+
* Class Optml_jetengine
5+
*
6+
* @reason Add support for JetEngine plugin custom endpoints.
7+
*/
8+
class Optml_jetengine extends Optml_compatibility {
9+
10+
/**
11+
* Should we load the integration logic.
12+
*
13+
* @return bool Should we load.
14+
*/
15+
public function should_load() {
16+
include_once ABSPATH . 'wp-admin/includes/plugin.php';
17+
18+
return is_plugin_active( 'jet-engine/jet-engine.php' );
19+
}
20+
21+
/**
22+
* Register integration details.
23+
*
24+
* @return void
25+
*/
26+
public function register() {
27+
Optml_Url_Replacer::instance()->init();
28+
add_filter(
29+
'jet-engine/ajax/listing_load_more/response',
30+
function ( $response ) {
31+
if ( isset( $response['html'] ) && ! empty( $response['html'] ) ) {
32+
$response['html'] = Optml_Main::instance()->manager->replace_content( $response['html'], true );
33+
}
34+
35+
return $response;
36+
},
37+
10,
38+
);
39+
}
40+
41+
/**
42+
* Should we early load the compatibility?
43+
*
44+
* @return bool Whether to load the compatibility or not.
45+
*/
46+
public function should_load_early() {
47+
return true;
48+
}
49+
}

inc/manager.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ final class Optml_Manager {
100100
'otter_blocks',
101101
'spectra',
102102
'wpsp',
103+
'jetengine',
103104
'jetpack',
104105
];
105106
/**

0 commit comments

Comments
 (0)