diff --git a/plugins/otter-pro/inc/plugins/class-live-search.php b/plugins/otter-pro/inc/plugins/class-live-search.php
index 00318fda0..c43c76216 100644
--- a/plugins/otter-pro/inc/plugins/class-live-search.php
+++ b/plugins/otter-pro/inc/plugins/class-live-search.php
@@ -23,6 +23,7 @@ class Live_Search {
*/
public function init() {
add_filter( 'render_block', array( $this, 'render_blocks' ), 10, 2 );
+ add_action( 'otter_load_live_search_deps', array( $this, 'load_deps' ) );
}
/**
@@ -39,6 +40,44 @@ public function render_blocks( $block_content, $block ) {
return $block_content;
}
+ do_action( 'otter_load_live_search_deps' );
+
+ $post_types_data = '';
+ if ( isset( $block['attrs']['otterSearchQuery']['post_type'] ) ) {
+ $post_types_data = 'data-post-types=' . wp_json_encode( $block['attrs']['otterSearchQuery']['post_type'] );
+ }
+
+ // Insert hidden fields to filter core's search results.
+ $query_params_markup = '';
+ if ( isset( $block['attrs']['otterSearchQuery'] ) && count( $block['attrs']['otterSearchQuery'] ) > 0 ) {
+ foreach ( $block['attrs']['otterSearchQuery'] as $param => $value ) {
+ $query_params_markup .= sprintf(
+ '',
+ esc_attr( $param ),
+ esc_attr( implode( ',', $value ) )
+ );
+ }
+ }
+
+ $block_content = substr( $block_content, 0, strpos( $block_content, '' ) ) . $query_params_markup . substr( $block_content, strpos( $block_content, '' ) );
+ return '
' . $block_content . '
';
+ }
+
+ /**
+ * Load the live search dependencies.
+ *
+ * @return void
+ *
+ * @static
+ */
+ public static function load_deps() {
+
+ $has_license = in_array( License::get_license_type(), array( 2, 3 ) ) || ( License::has_active_license() && isset( License::get_license_data()->otter_pro ) );
+
+ if ( ! $has_license ) {
+ return;
+ }
+
$asset_file = include OTTER_BLOCKS_PATH . '/build/blocks/live-search.asset.php';
wp_enqueue_script(
'otter-live-search',
@@ -64,26 +103,6 @@ public function render_blocks( $block_content, $block ) {
$asset_file = include OTTER_BLOCKS_PATH . '/build/blocks/live-search-style.asset.php';
wp_enqueue_style( 'otter-live-search-style', OTTER_BLOCKS_URL . 'build/blocks/live-search-style.css', $asset_file['dependencies'], $asset_file['version'] );
-
- $post_types_data = '';
- if ( isset( $block['attrs']['otterSearchQuery']['post_type'] ) ) {
- $post_types_data = 'data-post-types=' . wp_json_encode( $block['attrs']['otterSearchQuery']['post_type'] );
- }
-
- // Insert hidden fields to filter core's search results.
- $query_params_markup = '';
- if ( isset( $block['attrs']['otterSearchQuery'] ) && count( $block['attrs']['otterSearchQuery'] ) > 0 ) {
- foreach ( $block['attrs']['otterSearchQuery'] as $param => $value ) {
- $query_params_markup .= sprintf(
- '',
- esc_attr( $param ),
- esc_attr( implode( ',', $value ) )
- );
- }
- }
-
- $block_content = substr( $block_content, 0, strpos( $block_content, '' ) ) . $query_params_markup . substr( $block_content, strpos( $block_content, '' ) );
- return '' . $block_content . '
';
}
/**