| @@ -7,11 +7,10 @@ | ||
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | 9 | namespace ElasticPress\Indexable\Comment; |
| 10 | 10 | |
| 11 | -use ElasticPress\Indexables as Indexables; | |
| 12 | -use ElasticPress\Elasticsearch as Elasticsearch; | |
| 13 | -use ElasticPress\SyncManager as SyncManagerAbstract; | |
| 11 | +use ElasticPress\Elasticsearch; | |
| 12 | +use ElasticPress\Indexables; | |
| 14 | 13 | |
| 15 | 14 | if ( ! defined( 'ABSPATH' ) ) { |
| 16 | 15 | exit; // Exit if accessed directly. |
| 17 | 16 | } |
| @@ -18,9 +17,16 @@ | ||
| 18 | 17 | |
| 19 | 18 | /** |
| 20 | 19 | * Sync manager class |
| 21 | 20 | */ |
| 22 | -class SyncManager extends SyncManagerAbstract { | |
| 21 | +class SyncManager extends \ElasticPress\SyncManager { | |
| 22 | + /** | |
| 23 | + * Indexable slug | |
| 24 | + * | |
| 25 | + * @since 4.7.0 | |
| 26 | + * @var string | |
| 27 | + */ | |
| 28 | + public $indexable_slug = 'comment'; | |
| 23 | 29 | |
| 24 | 30 | /** |
| 25 | 31 | * Setup actions and filters |
| 26 | 32 | * |
| @@ -44,8 +50,13 @@ | ||
| 44 | 50 | |
| 45 | 51 | add_action( 'added_comment_meta', [ $this, 'action_queue_meta_sync' ], 10, 2 ); |
| 46 | 52 | add_action( 'deleted_comment_meta', [ $this, 'action_queue_meta_sync' ], 10, 2 ); |
| 47 | 53 | add_action( 'updated_comment_meta', [ $this, 'action_queue_meta_sync' ], 10, 2 ); |
| 54 | + | |
| 55 | + // Clear index settings cache | |
| 56 | + add_action( 'ep_update_index_settings', [ $this, 'clear_index_settings_cache' ] ); | |
| 57 | + add_action( 'ep_after_put_mapping', [ $this, 'clear_index_settings_cache' ] ); | |
| 58 | + add_action( 'ep_saved_weighting_configuration', [ $this, 'clear_index_settings_cache' ] ); | |
| 48 | 59 | } |
| 49 | 60 | |
| 50 | 61 | /** |
| 51 | 62 | * Un-setup actions and filters (for multisite). |
| @@ -60,8 +71,13 @@ | ||
| 60 | 71 | remove_action( 'deleted_comment', [ $this, 'action_sync_on_delete' ] ); |
| 61 | 72 | remove_action( 'added_comment_meta', [ $this, 'action_queue_meta_sync' ] ); |
| 62 | 73 | remove_action( 'deleted_comment_meta', [ $this, 'action_queue_meta_sync' ] ); |
| 63 | 74 | remove_action( 'updated_comment_meta', [ $this, 'action_queue_meta_sync' ] ); |
| 75 | + | |
| 76 | + // Clear index settings cache | |
| 77 | + remove_action( 'ep_update_index_settings', [ $this, 'clear_index_settings_cache' ] ); | |
| 78 | + remove_action( 'ep_after_put_mapping', [ $this, 'clear_index_settings_cache' ] ); | |
| 79 | + remove_action( 'ep_saved_weighting_configuration', [ $this, 'clear_index_settings_cache' ] ); | |
| 64 | 80 | } |
| 65 | 81 | |
| 66 | 82 | /** |
| 67 | 83 | * Sync ES index when new comments are saved |
| @@ -210,6 +226,5 @@ | ||
| 210 | 226 | } |
| 211 | 227 | } |
| 212 | 228 | } |
| 213 | 229 | } |
| 214 | - | |
| 215 | 230 | } |