| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* Plugin Name: RabbitLoader |
| 5 |
* Plugin URI: https://rabbitloader.com |
| 6 |
* Author: RabbitLoader |
| 7 |
* Author URI: https://rabbitloader.com/ |
| 8 |
* Description: RabbitLoader can improve Google PageSpeed score and get you 100 out of 100 by improving the page load time to just a few milliseconds. It improves the Core Web Vitals score for your pages and boost PageSpeed score to help better search rankings and best the experience for your end user. |
| 9 |
* Version: 2.18.5 |
| 10 |
* Text Domain: rabbit-loader |
| 11 |
*/ |
| 12 |
/* |
| 13 |
RabbitLoader is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 2 of the License, or any later version. */ |
| 14 |
|
| 15 |
defined( 'ABSPATH' ) or die( 'ABSPATH not defined' ); |
| 16 |
|
| 17 |
$plug_dir = dirname(__FILE__) . '/'; |
| 18 |
include_once($plug_dir.'autoload.php'); |
| 19 |
|
| 20 |
add_action( 'save_post', function($post_ID, $post, $update){ |
| 21 |
RabbitLoader_21_Util_WP::onPostChange($post_ID); |
| 22 |
}, 10, 3 ); |
| 23 |
add_action( 'wp_insert_post', function($post_ID, $post, $update){ |
| 24 |
RabbitLoader_21_Util_WP::onPostChange($post_ID); |
| 25 |
}, 10, 3 ); |
| 26 |
add_action( 'draft_to_publish', function($post){ |
| 27 |
if(!empty($post)){ |
| 28 |
RabbitLoader_21_Util_WP::onPostChange($post->ID); |
| 29 |
} |
| 30 |
}, 10, 1 ); |
| 31 |
add_action( 'pending_to_publish', function($post){ |
| 32 |
if(!empty($post)){ |
| 33 |
RabbitLoader_21_Util_WP::onPostChange($post->ID); |
| 34 |
} |
| 35 |
}, 10, 1); |
| 36 |
add_action( 'transition_post_status', function($new_status, $old_status, $post){ |
| 37 |
//No need to purge if the post was not public before and its not even now |
| 38 |
if('publish' !== $old_status && 'publish' !== $new_status){ |
| 39 |
return; |
| 40 |
} |
| 41 |
RabbitLoader_21_Util_WP::onPostChange($post->ID); |
| 42 |
}, 10, 3); |
| 43 |
add_action( 'transition_comment_status', function($new_status, $old_status, $comment){ |
| 44 |
RabbitLoader_21_Util_WP::onPostChange($comment->comment_post_ID); |
| 45 |
}, 10, 3); |
| 46 |
add_action( 'comment_post', function($comment_ID, $comment_approved, $commentdata){ |
| 47 |
if($comment_approved==1){ |
| 48 |
$comment = get_comment( $comment_ID ); |
| 49 |
RabbitLoader_21_Util_WP::onPostChange($comment->comment_post_ID); |
| 50 |
} |
| 51 |
}, 10, 3); |
| 52 |
|
| 53 |
add_action( 'switch_theme', function(){ |
| 54 |
RabbitLoader_21_Admin::onPostChange('all'); |
| 55 |
}, 10, 0); |
| 56 |
|
| 57 |
add_action( 'woocommerce_updated_product_stock', function($product_id){ |
| 58 |
RabbitLoader_21_Util_WP::onPostChange($product_id); |
| 59 |
}, 10, 1); |
| 60 |
add_action( 'woocommerce_updated_product_price', function($product_id){ |
| 61 |
RabbitLoader_21_Util_WP::onPostChange($product_id); |
| 62 |
}, 10, 1); |
| 63 |
add_action( 'woocommerce_rest_insert_product', function($post, $request, $creating) { |
| 64 |
RabbitLoader_21_Util_WP::onPostChange($post->ID); |
| 65 |
}, 10, 3); |
| 66 |
add_action( 'woocommerce_rest_insert_product_object', function($product, $request, $creating) { |
| 67 |
RabbitLoader_21_Util_WP::onPostChange($product->id); |
| 68 |
}, 10, 3); |
| 69 |
add_action( 'woocommerce_product_object_updated_props', function($product, $updated) { |
| 70 |
RabbitLoader_21_Util_WP::onPostChange($product->get_id()); |
| 71 |
}, 0, 2); |
| 72 |
register_shutdown_function(function(){ |
| 73 |
RabbitLoader_21_Util_WP::execute_purge(); |
| 74 |
}); |
| 75 |
if (is_admin() ) { |
| 76 |
|
| 77 |
register_activation_hook( __FILE__, 'RabbitLoader_21_Admin::activate_advanced_cache'); |
| 78 |
register_deactivation_hook( __FILE__, 'RabbitLoader_21_Admin::plugin_deactivate'); |
| 79 |
register_uninstall_hook(__FILE__, 'RabbitLoader_21_Admin::plugin_uninstall'); |
| 80 |
add_filter( 'plugin_action_links_rabbit-loader/rabbit-loader.php', 'RabbitLoader_21_Admin::settings_link' ); |
| 81 |
|
| 82 |
if(!defined('RABBITLOADER_UNINSTALL_MODE')){ |
| 83 |
RabbitLoader_21_Admin::addActions(); |
| 84 |
} |
| 85 |
}else{ |
| 86 |
if(!defined('RABBITLOADER_AC_ACTIVE')){ |
| 87 |
//advance cache failed to work, as a fallback we can intercept requests here |
| 88 |
RabbitLoader_21_Public::process_incoming_request('fallback'); |
| 89 |
} |
| 90 |
RabbitLoader_21_Public::addActions(); |
| 91 |
} |
| 92 |
|
| 93 |
if(defined("WP_CLI") && WP_CLI){ |
| 94 |
include_once($plug_dir.'wp-cli.php'); |
| 95 |
} |
| 96 |
?> |