PluginProbe
Autoptimize / 3.1.11
Autoptimize v3.1.11
2.2.2 2.3.0 2.3.1 2.3.2 2.3.3 2.3.4 2.4.0 2.4.1 2.4.2 2.4.3 2.4.4 2.5.0 2.5.1 2.6.0 2.6.1 2.6.2 2.7.0 2.7.1 2.7.2 2.7.3 2.7.4 2.7.5 2.7.6 2.7.7 2.7.8 All 107 releases
autoptimize / autoptimize.php

autoptimize.php in Autoptimize 3.1.11, at autoptimize.php

103 lines 3.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Plugin Name: Autoptimize
4 * Plugin URI: https://autoptimize.com/pro/
5 * Description: Makes your site faster by optimizing CSS, JS, Images, Google fonts and more.
6 * Version: 3.1.11
7 * Author: Frank Goossens (futtta)
8 * Author URI: https://autoptimize.com/pro/
9 * Text Domain: autoptimize
10 * License: GPLv2
11 * Released under the GNU General Public License (GPL)
12 * https://www.gnu.org/licenses/old-licenses/gpl-2.0.txt
13 */
14
15 /**
16 * Autoptimize main plugin file.
17 */
18
19
20 if ( ! defined( 'ABSPATH' ) ) {
21 exit;
22 }
23
24 define( 'AUTOPTIMIZE_PLUGIN_VERSION', '3.1.11' );
25
26 // plugin_dir_path() returns the trailing slash!
27 define( 'AUTOPTIMIZE_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
28 define( 'AUTOPTIMIZE_PLUGIN_FILE', __FILE__ );
29
30 // Bail early if attempting to run on non-supported php versions.
31 if ( version_compare( PHP_VERSION, '5.6', '<' ) ) {
32 function autoptimize_incompatible_admin_notice() {
33 echo '<div class="error"><p>' . esc_html__( 'Autoptimize requires PHP 5.6 (or higher) to function properly. Please upgrade PHP. The Plugin has been auto-deactivated.', 'autoptimize' ) . '</p></div>';
34 if ( isset( $_GET['activate'] ) ) {
35 unset( $_GET['activate'] );
36 }
37 }
38 function autoptimize_deactivate_self() {
39 deactivate_plugins( plugin_basename( AUTOPTIMIZE_PLUGIN_FILE ) );
40 }
41 add_action( 'admin_notices', 'autoptimize_incompatible_admin_notice' );
42 add_action( 'admin_init', 'autoptimize_deactivate_self' );
43 return;
44 }
45
46 function autoptimize_autoload( $class_name ) {
47 if ( in_array( $class_name, array( 'AO_Minify_HTML', 'JSMin' ) ) ) {
48 $file = strtolower( $class_name );
49 $file = str_replace( '_', '-', $file );
50 $path = dirname( __FILE__ ) . '/classes/external/php/';
51 $filepath = $path . $file . '.php';
52 } elseif ( false !== strpos( $class_name, 'Autoptimize\\tubalmartin\\CssMin' ) ) {
53 $file = str_replace( 'Autoptimize\\tubalmartin\\CssMin\\', '', $class_name );
54 $path = dirname( __FILE__ ) . '/classes/external/php/yui-php-cssmin-bundled/';
55 $filepath = $path . $file . '.php';
56 } elseif ( 'autoptimize' === substr( $class_name, 0, 11 ) ) {
57 // One of our "old" classes.
58 $file = $class_name;
59 $path = dirname( __FILE__ ) . '/classes/';
60 $filepath = $path . $file . '.php';
61 } elseif ( 'PAnD' === $class_name ) {
62 $file = 'persist-admin-notices-dismissal';
63 $path = dirname( __FILE__ ) . '/classes/external/php/persist-admin-notices-dismissal/';
64 $filepath = $path . $file . '.php';
65 }
66
67 // If we didn't match one of our rules, bail!
68 if ( ! isset( $filepath ) || ! is_readable( $filepath ) ) {
69 return;
70 }
71
72 require $filepath;
73 }
74
75 spl_autoload_register( 'autoptimize_autoload' );
76
77 // Load WP CLI command(s) on demand.
78 if ( defined( 'WP_CLI' ) && WP_CLI ) {
79 require AUTOPTIMIZE_PLUGIN_DIR . 'classes/autoptimizeCLI.php';
80 }
81
82 // filter to disable AO both on front- and backend.
83 if ( apply_filters( 'autoptimize_filter_disable_plugin', false ) ) {
84 return;
85 }
86
87 /**
88 * Retrieve the instance of the main plugin class.
89 *
90 * @return autoptimizeMain
91 */
92 function autoptimize() {
93 static $plugin = null;
94
95 if ( null === $plugin ) {
96 $plugin = new autoptimizeMain( AUTOPTIMIZE_PLUGIN_VERSION, AUTOPTIMIZE_PLUGIN_FILE );
97 }
98
99 return $plugin;
100 }
101
102 autoptimize()->run();
103