class-feed-fetcher.php $file_name = 'class-' . strtolower( preg_replace( '/([a-z])([A-Z])/', '$1-$2', $class_name ) ) . '.php'; $file = AICA_PLUGIN_DIR . ( $subdir ? $subdir . '/' : '' ) . $file_name; if ( file_exists( $file ) ) { require_once $file; } } ); /** * Activation hook. */ register_activation_hook( __FILE__, function () { \WPAutopilot\Includes\Activator::activate(); } ); /** * Deactivation hook. */ register_deactivation_hook( __FILE__, function () { \WPAutopilot\Includes\Deactivator::deactivate(); } ); /** * Bootstrap the plugin. */ add_action( 'plugins_loaded', function () { // Load settings helper early. \WPAutopilot\Includes\Settings::init(); // Seamless DB upgrades (new tables, new defaults) without reactivation. \WPAutopilot\Includes\Activator::maybe_upgrade(); // Register cron. $cron = new \WPAutopilot\Includes\Cron(); $cron->register(); // Clean up internal links index when a post is deleted or trashed. add_action( 'before_delete_post', function ( $post_id ) { $links = new \WPAutopilot\Includes\InternalLinks(); $links->remove_article( $post_id ); } ); add_action( 'wp_trash_post', function ( $post_id ) { $links = new \WPAutopilot\Includes\InternalLinks(); $links->remove_article( $post_id ); } ); // Re-add to index if a post is untrashed. add_action( 'untrashed_post', function ( $post_id ) { $post = get_post( $post_id ); if ( $post && $post->post_type === 'post' ) { $links = new \WPAutopilot\Includes\InternalLinks(); $links->add_article( $post->ID, $post->post_title, get_permalink( $post->ID ), $post->post_content ); } } ); // Admin panel. if ( is_admin() ) { $admin = new \WPAutopilot\Admin\Admin(); $admin->register(); } } );