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 -88 2.7.40.3 View file →
@@ -1,97 +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.4
7 - * Author: Frank Goossens (futtta)
8 - * Author URI: https://autoptimize.com/
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 - */
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 +*/
14 12
15 -/**
16 - * Autoptimize main plugin file.
17 - */
13 +//Load config class
14 +@include(WP_PLUGIN_DIR.'/autoptimize/classes/autoptimizeConfig.php');
18 15
19 -
20 -if ( ! defined( 'ABSPATH' ) ) {
21 - 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');
22 56 }
23 57
24 -define( 'AUTOPTIMIZE_PLUGIN_VERSION', '2.7.4' );
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>' . __( '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;
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;
44 86 }
45 87
46 -function autoptimize_autoload( $class_name ) {
47 - if ( in_array( $class_name, array( '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 88
67 - // If we didn't match one of our rules, bail!
68 - if ( ! isset( $filepath ) ) {
69 - return;
70 - }
71 -
72 - 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);
73 94 }
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 -/**
83 - * Retrieve the instance of the main plugin class.
84 - *
85 - * @return autoptimizeMain
86 - */
87 -function autoptimize() {
88 - static $plugin = null;
89 -
90 - if ( null === $plugin ) {
91 - $plugin = new autoptimizeMain( AUTOPTIMIZE_PLUGIN_VERSION, AUTOPTIMIZE_PLUGIN_FILE );
92 - }
93 -
94 - return $plugin;
95 -}
96 -
97 -autoptimize()->run();