file // convention above, so it's loaded directly rather than autoloaded. require_once BABILIM_DIR . 'includes/class-babilim.php'; /* * Registered at the top level, before this file (or anything it loads * synchronously below) makes any `__()` call -- required so the * translation-loading layer's filters can be in place before core or * any other plugin's translated strings are requested. */ Babilim_Loader::register(); add_action( 'plugins_loaded', 'babilim_bootstrap' ); /** * Assembles the rest of the plugin once every plugin has had its main * file loaded. Nothing to assemble yet -- see Babilim::init(). */ function babilim_bootstrap() { Babilim::instance()->init(); } if ( function_exists( 'register_deactivation_hook' ) ) { register_deactivation_hook( BABILIM_FILE, 'babilim_deactivate' ); } /** * Clears the `babilim_maintenance` daily cron event and the * `babilim_sync` twice-daily cron event this plugin schedules (see * Babilim::register_maintenance_cron()/register_sync_cron()) so a * deactivated Babilim never leaves a stray wp-cron event behind -- * standard WordPress plugin hygiene (see the wp-plugin-development * skill's references/data-and-cron.md). The same jobs can be run by hand * from the admin screens (Check again now, Rebuild index now, Sweep now); * there is no WP-CLI command. * * @param bool $network_wide Whether this is a network-wide deactivation; then the scheduled events are cleared on every site. */ function babilim_deactivate( $network_wide = false ) { if ( ! function_exists( 'wp_clear_scheduled_hook' ) ) { return; } $clear = static function () { wp_clear_scheduled_hook( 'babilim_maintenance' ); wp_clear_scheduled_hook( 'babilim_sync' ); wp_clear_scheduled_hook( 'babilim_sync_once' ); Babilim_Error_Reporter::for_site()->clear_all(); }; // A network-wide deactivation runs once, on the main site: every // site has its own cron queue, so clear each one. if ( $network_wide && function_exists( 'is_multisite' ) && is_multisite() && function_exists( 'get_sites' ) ) { foreach ( get_sites( array( 'fields' => 'ids', 'number' => 0 ) ) as $site_id ) { switch_to_blog( (int) $site_id ); $clear(); restore_current_blog(); } return; } $clear(); }