Skip to content

Instantly share code, notes, and snippets.

@djrmom
Last active January 26, 2021 16:56
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save djrmom/4aa6097cb4474236dbebe2b9e0246ce1 to your computer and use it in GitHub Desktop.
Save djrmom/4aa6097cb4474236dbebe2b9e0246ce1 to your computer and use it in GitHub Desktop.
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' );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment