Last active
January 26, 2021 16:56
-
-
Save djrmom/4aa6097cb4474236dbebe2b9e0246ce1 to your computer and use it in GitHub Desktop.
facetwp schedule indexer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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