| 1 |
<?php |
| 2 |
/** |
| 3 |
* Plugin Name: Leverage Browser Caching |
| 4 |
* Description: Speed up WordPress with browser caching. Automatically adds expiry headers for images, CSS, JS & fonts via .htaccess Zero config (Apache only) |
| 5 |
* Version: 3.0 |
| 6 |
* Author: Rinku Yadav |
| 7 |
* Author URI: https://lbcache.com |
| 8 |
* License: GPLv2 or later |
| 9 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html |
| 10 |
* Text Domain: lbrowserc |
| 11 |
* |
| 12 |
* @package Leverage Browser Caching |
| 13 |
*/ |
| 14 |
|
| 15 |
// Exit if directly accessed files. |
| 16 |
if ( ! defined( 'ABSPATH' ) ) { |
| 17 |
exit; |
| 18 |
} |
| 19 |
|
| 20 |
// Set path to constant. |
| 21 |
if ( ! defined( 'LBROWSERC_PATH' ) ) { |
| 22 |
define( 'LBROWSERC_PATH', wp_normalize_path( plugin_dir_path( __FILE__ ) ) ); |
| 23 |
} |
| 24 |
|
| 25 |
// Set url to constant. |
| 26 |
if ( ! defined( 'LBROWSERC_URL' ) ) { |
| 27 |
define( 'LBROWSERC_URL', plugin_dir_url( __FILE__ ) ); |
| 28 |
} |
| 29 |
|
| 30 |
// Set __FILE__ to constant. |
| 31 |
if ( ! defined( 'LBROWSERC_FILE' ) ) { |
| 32 |
define( 'LBROWSERC_FILE', __FILE__ ); |
| 33 |
} |
| 34 |
|
| 35 |
// Set plugin base. |
| 36 |
if ( ! defined( 'LBROWSERC_BASE_FILE' ) ) { |
| 37 |
define( 'LBROWSERC_BASE_FILE', plugin_basename( __FILE__ ) ); |
| 38 |
} |
| 39 |
|
| 40 |
// Load core class. |
| 41 |
require_once LBROWSERC_PATH . 'inc/classes/class-lbrowserc-core.php'; |
| 42 |
|
| 43 |
$lbrowserc = new Lbrowserc_Core(); |
| 44 |
|
| 45 |
// Write caching rules to .htaccess on activation; remove them on deactivation. |
| 46 |
register_activation_hook( LBROWSERC_FILE, array( $lbrowserc, 'add_code' ) ); |
| 47 |
register_deactivation_hook( LBROWSERC_FILE, array( $lbrowserc, 'remove_code' ) ); |
| 48 |
|
| 49 |
// Load admin-only classes: plugin action links, dismissible notice, and admin page. |
| 50 |
if ( is_admin() ) { |
| 51 |
require_once LBROWSERC_PATH . 'inc/classes/class-lbrowserc-links.php'; |
| 52 |
new Lbrowserc_Links(); |
| 53 |
|
| 54 |
require_once LBROWSERC_PATH . 'inc/classes/class-lbrowserc-notice.php'; |
| 55 |
$lbrowserc_notice = new Lbrowserc_Notice(); |
| 56 |
|
| 57 |
// Clear dismissed state on deactivation so notice reappears after re-activation. |
| 58 |
register_deactivation_hook( LBROWSERC_FILE, array( $lbrowserc_notice, 'reset_notice' ) ); |
| 59 |
|
| 60 |
require_once LBROWSERC_PATH . 'inc/classes/class-lbrowserc-admin-page.php'; |
| 61 |
new Lbrowserc_Admin_Page(); |
| 62 |
} |
| 63 |
|
| 64 |
|
| 65 |
|