| 1 |
<?php |
| 2 |
/** |
| 3 |
* Plugin Name: Nginx Helper |
| 4 |
* Plugin URI: https://rtcamp.com/nginx-helper/ |
| 5 |
* Description: Cleans nginx's fastcgi/proxy cache or redis-cache whenever a post is edited/published. Also does few more things. |
| 6 |
* Version: 2.4.0 |
| 7 |
* Author: rtCamp |
| 8 |
* Author URI: https://rtcamp.com |
| 9 |
* Text Domain: nginx-helper |
| 10 |
* Domain Path: /languages |
| 11 |
* Requires at least: 3.0 |
| 12 |
* Tested up to: 7.1 |
| 13 |
* |
| 14 |
* @link https://rtcamp.com/nginx-helper/ |
| 15 |
* @since 2.0.0 |
| 16 |
* @package nginx-helper |
| 17 |
*/ |
| 18 |
|
| 19 |
// If this file is called directly, abort. |
| 20 |
if ( ! defined( 'WPINC' ) ) { |
| 21 |
die; |
| 22 |
} |
| 23 |
|
| 24 |
/** |
| 25 |
* Base URL of plugin |
| 26 |
*/ |
| 27 |
if ( ! defined( 'NGINX_HELPER_BASEURL' ) ) { |
| 28 |
define( 'NGINX_HELPER_BASEURL', plugin_dir_url( __FILE__ ) ); |
| 29 |
} |
| 30 |
|
| 31 |
/** |
| 32 |
* Base Name of plugin |
| 33 |
*/ |
| 34 |
if ( ! defined( 'NGINX_HELPER_BASENAME' ) ) { |
| 35 |
define( 'NGINX_HELPER_BASENAME', plugin_basename( __FILE__ ) ); |
| 36 |
} |
| 37 |
|
| 38 |
/** |
| 39 |
* Base PATH of plugin |
| 40 |
*/ |
| 41 |
if ( ! defined( 'NGINX_HELPER_BASEPATH' ) ) { |
| 42 |
define( 'NGINX_HELPER_BASEPATH', plugin_dir_path( __FILE__ ) ); |
| 43 |
} |
| 44 |
|
| 45 |
/** |
| 46 |
* The code that runs during plugin activation. |
| 47 |
* This action is documented in includes/class-nginx-helper-activator.php |
| 48 |
*/ |
| 49 |
function activate_nginx_helper() { |
| 50 |
require_once NGINX_HELPER_BASEPATH . 'includes/class-nginx-helper-activator.php'; |
| 51 |
Nginx_Helper_Activator::activate(); |
| 52 |
} |
| 53 |
|
| 54 |
/** |
| 55 |
* The code that runs during plugin deactivation. |
| 56 |
* This action is documented in includes/class-nginx-helper-deactivator.php |
| 57 |
*/ |
| 58 |
function deactivate_nginx_helper() { |
| 59 |
require_once NGINX_HELPER_BASEPATH . 'includes/class-nginx-helper-deactivator.php'; |
| 60 |
Nginx_Helper_Deactivator::deactivate(); |
| 61 |
} |
| 62 |
|
| 63 |
register_activation_hook( __FILE__, 'activate_nginx_helper' ); |
| 64 |
register_deactivation_hook( __FILE__, 'deactivate_nginx_helper' ); |
| 65 |
|
| 66 |
/** |
| 67 |
* The core plugin class that is used to define internationalization, |
| 68 |
* admin-specific hooks, and public-facing site hooks. |
| 69 |
*/ |
| 70 |
require NGINX_HELPER_BASEPATH . 'includes/class-nginx-helper.php'; |
| 71 |
|
| 72 |
/** |
| 73 |
* Begins execution of the plugin. |
| 74 |
* |
| 75 |
* Since everything within the plugin is registered via hooks, |
| 76 |
* then kicking off the plugin from this point in the file does |
| 77 |
* not affect the page life cycle. |
| 78 |
* |
| 79 |
* @since 2.0.0 |
| 80 |
*/ |
| 81 |
function run_nginx_helper() { |
| 82 |
|
| 83 |
global $nginx_helper; |
| 84 |
|
| 85 |
$nginx_helper = new Nginx_Helper(); |
| 86 |
$nginx_helper->run(); |
| 87 |
|
| 88 |
// Load WP-CLI command. |
| 89 |
if ( defined( 'WP_CLI' ) && WP_CLI ) { |
| 90 |
|
| 91 |
require_once NGINX_HELPER_BASEPATH . 'class-nginx-helper-wp-cli-command.php'; |
| 92 |
\WP_CLI::add_command( 'nginx-helper', 'Nginx_Helper_WP_CLI_Command' ); |
| 93 |
|
| 94 |
} |
| 95 |
|
| 96 |
} |
| 97 |
run_nginx_helper(); |
| 98 |
|