Skip to content

Commit 4615059

Browse files
fix: Incompatibility with JetEngine
1 parent 22a086e commit 4615059

2 files changed

Lines changed: 56 additions & 0 deletions

File tree

inc/compatibilities/jetengine.php

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
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+
add_action( 'jet-engine/listings/ajax/load-more', [ $this, 'setup_tag_replacer' ], PHP_INT_MIN, 1 );
28+
}
29+
30+
31+
/**
32+
* Setup the URL replacer for Load More ajax calls for "Listings Grid" block.
33+
*
34+
* The request is with "POST" method, so the usual checks in should_replace() will fail.
35+
*
36+
* @see ajax:jet_engine_ajax with action:listing_load_more
37+
*
38+
* @return void
39+
*/
40+
public function setup_tag_replacer() {
41+
if ( did_action( 'optml_replacer_setup' ) ) {
42+
return;
43+
}
44+
do_action( 'optml_replacer_setup' );
45+
}
46+
47+
/**
48+
* Should we early load the compatibility?
49+
*
50+
* @return bool Whether to load the compatibility or not.
51+
*/
52+
public function should_load_early() {
53+
return true;
54+
}
55+
}

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
];
104105
/**
105106
* The current state of the buffer.

0 commit comments

Comments
 (0)