Skip to content

Commit 20ccfbb

Browse files
fix: use replace content for JetEngine compatiblity
1 parent 4615059 commit 20ccfbb

1 file changed

Lines changed: 12 additions & 18 deletions

File tree

inc/compatibilities/jetengine.php

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -24,24 +24,18 @@ public function should_load() {
2424
* @return void
2525
*/
2626
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' );
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+
);
4539
}
4640

4741
/**

0 commit comments

Comments
 (0)