facetwp schedule indexer

<?php
/*
Plugin Name: FacetWP Schedule Indexer
Plugin URI: https://facetwp.com/
Description: Runs indexer periodically by cron
Version: 1.0
Author: FacetWP, LLC
*/

add_action( 'fwp_scheduled_index', 'fwp_scheduled_index' );
function fwp_scheduled_index() {
    FWP()->indexer->index();
}

register_activation_hook( __FILE__, 'fwp_schedule_indexder_activation' );
function fwp_schedule_indexder_activation() {
    if ( ! wp_next_scheduled( 'fwp_scheduled_index' ) ) { 
        wp_schedule_event( time(), 'hourly', 'fwp_scheduled_index' );
    }
}

register_deactivation_hook( __FILE__, 'fwp_schedule_indexder_deactivation' );
function fwp_schedule_indexder_deactivation() {
    wp_clear_scheduled_hook( 'fwp_scheduled_index' );
}