PluginProbe
Autoptimize / 0.3
Autoptimize v0.3
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
← All changes | autoptimize.php +85 -87 2.7.30.3 View file →
@@ -1,96 +1,94 @@
1 1 <?php
2 -/**
3 - * Plugin Name: Autoptimize
4 - * Plugin URI: https://autoptimize.com/
5 - * Description: Makes your site faster by optimizing CSS, JS, Images, Google fonts and more.
6 - * Version: 2.7.3
7 - * Author: Frank Goossens (futtta)
8 - * Author URI: https://autoptimize.com/
9 - * Text Domain: autoptimize
10 - * Released under the GNU General Public License (GPL)
11 - * http://www.gnu.org/licenses/gpl.txt
12 - */
2 +/*
3 +Plugin Name: Autoptimize
4 +Plugin URI: http://www.turleando.com.ar/
5 +Description: Optimiza tu sitio web, uniendo el CSS y JavaScript, y comprimi&eacute;ndolo.
6 +Version: 0.3
7 +Author: Emilio López
8 +Author URI: http://www.turleando.com.ar/
9 +Released under the GNU General Public License (GPL)
10 +http://www.gnu.org/licenses/gpl.txt
11 +*/
13 12
14 -/**
15 - * Autoptimize main plugin file.
16 - */
13 +//Load config class
14 +@include(WP_PLUGIN_DIR.'/autoptimize/classes/autoptimizeConfig.php');
17 15
18 -
19 -if ( ! defined( 'ABSPATH' ) ) {
20 - exit;
16 +//Set up the buffering
17 +function autoptimize_start_buffering()
18 +{
19 + //Pre-2.6 compatibility
20 + if(!defined('WP_PLUGIN_URL'))
21 + define('WP_PLUGIN_URL',WP_CONTENT_URL.'/plugins');
22 + if(!defined('WP_PLUGIN_DIR'))
23 + define('WP_PLUGIN_DIR',WP_CONTENT_DIR.'/plugins');
24 +
25 + //Config element
26 + $conf = autoptimizeConfig::instance();
27 +
28 + //Load our always-on classes
29 + @include(WP_PLUGIN_DIR.'/autoptimize/classes/autoptimizeBase.php');
30 + @include(WP_PLUGIN_DIR.'/autoptimize/classes/autoptimizeCache.php');
31 +
32 + //Load extra classes and set some vars
33 + if($conf->get('autoptimize_html'))
34 + {
35 + @include(WP_PLUGIN_DIR.'/autoptimize/classes/autoptimizeHTML.php');
36 + @include(WP_PLUGIN_DIR.'/autoptimize/classes/minify-html.php');
37 + }
38 +
39 + if($conf->get('autoptimize_js'))
40 + {
41 + @include(WP_PLUGIN_DIR.'/autoptimize/classes/autoptimizeScripts.php');
42 + @include(WP_PLUGIN_DIR.'/autoptimize/classes/jsmin-1.1.1.php');
43 + define('CONCATENATE_SCRIPTS',false);
44 + define('COMPRESS_SCRIPTS',false);
45 + }
46 +
47 + if($conf->get('autoptimize_css'))
48 + {
49 + @include(WP_PLUGIN_DIR.'/autoptimize/classes/autoptimizeStyles.php');
50 + @include(WP_PLUGIN_DIR.'/autoptimize/classes/minify-css-compressor.php');
51 + define('COMPRESS_CSS',false);
52 + }
53 +
54 + //Now, start the real thing!
55 + ob_start('autoptimize_end_buffering');
21 56 }
22 57
23 -define( 'AUTOPTIMIZE_PLUGIN_VERSION', '2.7.3' );
24 -
25 -// plugin_dir_path() returns the trailing slash!
26 -define( 'AUTOPTIMIZE_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
27 -define( 'AUTOPTIMIZE_PLUGIN_FILE', __FILE__ );
28 -
29 -// Bail early if attempting to run on non-supported php versions.
30 -if ( version_compare( PHP_VERSION, '5.6', '<' ) ) {
31 - function autoptimize_incompatible_admin_notice() {
32 - echo '<div class="error"><p>' . __( 'Autoptimize requires PHP 5.6 (or higher) to function properly. Please upgrade PHP. The Plugin has been auto-deactivated.', 'autoptimize' ) . '</p></div>';
33 - if ( isset( $_GET['activate'] ) ) {
34 - unset( $_GET['activate'] );
35 - }
36 - }
37 - function autoptimize_deactivate_self() {
38 - deactivate_plugins( plugin_basename( AUTOPTIMIZE_PLUGIN_FILE ) );
39 - }
40 - add_action( 'admin_notices', 'autoptimize_incompatible_admin_notice' );
41 - add_action( 'admin_init', 'autoptimize_deactivate_self' );
42 - return;
58 +//Action on end -
59 +function autoptimize_end_buffering($content)
60 +{
61 + //Config element
62 + $conf = autoptimizeConfig::instance();
63 +
64 + //Choose the classes
65 + $classes = array();
66 + if($conf->get('autoptimize_js'))
67 + $classes[] = 'autoptimizeScripts';
68 + if($conf->get('autoptimize_css'))
69 + $classes[] = 'autoptimizeStyles';
70 + if($conf->get('autoptimize_html'))
71 + $classes[] = 'autoptimizeHTML';
72 +
73 + //Run the classes
74 + foreach($classes as $name)
75 + {
76 + $instance = new $name($content);
77 + if($instance->read())
78 + {
79 + $instance->minify();
80 + $instance->cache();
81 + $content = $instance->getcontent();
82 + }
83 + unset($instance);
84 + }
85 + return $content;
43 86 }
44 87
45 -function autoptimize_autoload( $class_name ) {
46 - if ( in_array( $class_name, array( 'Minify_HTML', 'JSMin' ) ) ) {
47 - $file = strtolower( $class_name );
48 - $file = str_replace( '_', '-', $file );
49 - $path = dirname( __FILE__ ) . '/classes/external/php/';
50 - $filepath = $path . $file . '.php';
51 - } elseif ( false !== strpos( $class_name, 'Autoptimize\\tubalmartin\\CssMin' ) ) {
52 - $file = str_replace( 'Autoptimize\\tubalmartin\\CssMin\\', '', $class_name );
53 - $path = dirname( __FILE__ ) . '/classes/external/php/yui-php-cssmin-bundled/';
54 - $filepath = $path . $file . '.php';
55 - } elseif ( 'autoptimize' === substr( $class_name, 0, 11 ) ) {
56 - // One of our "old" classes.
57 - $file = $class_name;
58 - $path = dirname( __FILE__ ) . '/classes/';
59 - $filepath = $path . $file . '.php';
60 - } elseif ( 'PAnD' === $class_name ) {
61 - $file = 'persist-admin-notices-dismissal';
62 - $path = dirname( __FILE__ ) . '/classes/external/php/persist-admin-notices-dismissal/';
63 - $filepath = $path . $file . '.php';
64 - }
65 88
66 - // If we didn't match one of our rules, bail!
67 - if ( ! isset( $filepath ) ) {
68 - return;
69 - }
70 -
71 - require $filepath;
89 +$conf = autoptimizeConfig::instance();
90 +if($conf->get('autoptimize_html') || $conf->get('autoptimize_js') || $conf->get('autoptimize_css'))
91 +{
92 + //Hook to wordpress
93 + add_action('template_redirect','autoptimize_start_buffering',2);
72 94 }
73 -
74 -spl_autoload_register( 'autoptimize_autoload' );
75 -
76 -// Load WP CLI command(s) on demand.
77 -if ( defined( 'WP_CLI' ) && WP_CLI ) {
78 - require AUTOPTIMIZE_PLUGIN_DIR . 'classes/autoptimizeCLI.php';
79 -}
80 -
81 -/**
82 - * Retrieve the instance of the main plugin class.
83 - *
84 - * @return autoptimizeMain
85 - */
86 -function autoptimize() {
87 - static $plugin = null;
88 -
89 - if ( null === $plugin ) {
90 - $plugin = new autoptimizeMain( AUTOPTIMIZE_PLUGIN_VERSION, AUTOPTIMIZE_PLUGIN_FILE );
91 - }
92 -
93 - return $plugin;
94 -}
95 -
96 -autoptimize()->run();