Version Description
- Write plugin description in English
- Set default config to everything off
- Add link from plugins page to options page
- Fix problems with scripts that shouldn't be moved and were moved all the same
Download this release
Release Info
Developer | turl |
Plugin | Autoptimize |
Version | 0.4 |
Comparing to | |
See all releases |
Code changes from version 0.3 to 0.4
- autoptimize.php +8 -8
- classes/autoptimizeConfig.php +41 -4
- classes/autoptimizeScripts.php +6 -2
- readme.txt +7 -1
autoptimize.php
CHANGED
@@ -2,26 +2,26 @@
|
|
2 |
/*
|
3 |
Plugin Name: Autoptimize
|
4 |
Plugin URI: http://www.turleando.com.ar/
|
5 |
-
Description:
|
6 |
-
Version: 0.
|
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 |
*/
|
12 |
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
//Load config class
|
14 |
@include(WP_PLUGIN_DIR.'/autoptimize/classes/autoptimizeConfig.php');
|
15 |
|
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 |
|
2 |
/*
|
3 |
Plugin Name: Autoptimize
|
4 |
Plugin URI: http://www.turleando.com.ar/
|
5 |
+
Description: Optimizes your website, concatenating the CSS and JavaScript code, and compressing it.
|
6 |
+
Version: 0.4
|
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 |
*/
|
12 |
|
13 |
+
//Pre-2.6 compatibility
|
14 |
+
if(!defined('WP_PLUGIN_URL'))
|
15 |
+
define('WP_PLUGIN_URL',WP_CONTENT_URL.'/plugins');
|
16 |
+
if(!defined('WP_PLUGIN_DIR'))
|
17 |
+
define('WP_PLUGIN_DIR',WP_CONTENT_DIR.'/plugins');
|
18 |
+
|
19 |
//Load config class
|
20 |
@include(WP_PLUGIN_DIR.'/autoptimize/classes/autoptimizeConfig.php');
|
21 |
|
22 |
//Set up the buffering
|
23 |
function autoptimize_start_buffering()
|
24 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
//Config element
|
26 |
$conf = autoptimizeConfig::instance();
|
27 |
|
classes/autoptimizeConfig.php
CHANGED
@@ -5,14 +5,24 @@ class autoptimizeConfig
|
|
5 |
private $config = null;
|
6 |
static private $instance = null;
|
7 |
|
|
|
8 |
private function __construct()
|
9 |
{
|
10 |
-
//Singleton
|
11 |
if(is_admin())
|
12 |
{
|
13 |
//Add the admin page and settings
|
14 |
add_action('admin_menu',array($this,'addmenu'));
|
15 |
add_action('admin_init',array($this,'registersettings'));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
}
|
17 |
}
|
18 |
|
@@ -75,14 +85,41 @@ class autoptimizeConfig
|
|
75 |
register_setting('autoptimize','autoptimize_css');
|
76 |
}
|
77 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
78 |
public function get($key)
|
79 |
{
|
80 |
if(!is_array($this->config))
|
81 |
{
|
82 |
//Default config
|
83 |
-
$config = array('autoptimize_html' =>
|
84 |
-
'autoptimize_js' =>
|
85 |
-
'autoptimize_css' =>
|
86 |
|
87 |
//Override with user settings
|
88 |
if(get_option('autoptimize_html')!==false)
|
5 |
private $config = null;
|
6 |
static private $instance = null;
|
7 |
|
8 |
+
//Singleton: private construct
|
9 |
private function __construct()
|
10 |
{
|
|
|
11 |
if(is_admin())
|
12 |
{
|
13 |
//Add the admin page and settings
|
14 |
add_action('admin_menu',array($this,'addmenu'));
|
15 |
add_action('admin_init',array($this,'registersettings'));
|
16 |
+
//Set meta info
|
17 |
+
if(function_exists('plugin_row_meta'))
|
18 |
+
{
|
19 |
+
//2.8+
|
20 |
+
add_filter('plugin_row_meta',array($this,'setmeta'),10,2);
|
21 |
+
}elseif(function_exists('post_class')){
|
22 |
+
//2.7
|
23 |
+
$plugin = plugin_basename(WP_PLUGIN_DIR.'/autoptimize/autoptimize.php');
|
24 |
+
add_filter('plugin_action_links_'.$plugin,array($this,'setmeta'));
|
25 |
+
}
|
26 |
}
|
27 |
}
|
28 |
|
85 |
register_setting('autoptimize','autoptimize_css');
|
86 |
}
|
87 |
|
88 |
+
public function setmeta($links,$file=null)
|
89 |
+
{
|
90 |
+
//Inspired on http://wpengineer.com/meta-links-for-wordpress-plugins/
|
91 |
+
|
92 |
+
//Do it only once - saves time
|
93 |
+
static $plugin;
|
94 |
+
if(empty($plugin))
|
95 |
+
$plugin = plugin_basename(WP_PLUGIN_DIR.'/autoptimize/autoptimize.php');
|
96 |
+
|
97 |
+
if($file===null)
|
98 |
+
{
|
99 |
+
//2.7
|
100 |
+
$settings_link = sprintf('<a href="options-general.php?page=autoptimize">%s</a>', __('Settings'));
|
101 |
+
array_unshift($links,$settings_link);
|
102 |
+
}else{
|
103 |
+
//2.8
|
104 |
+
//If it's us, add the link
|
105 |
+
if($file === $plugin)
|
106 |
+
{
|
107 |
+
$newlink = array(sprintf('<a href="options-general.php?page=autoptimize">%s</a>',__('Settings')));
|
108 |
+
$links = array_merge($links,$newlink);
|
109 |
+
}
|
110 |
+
}
|
111 |
+
|
112 |
+
return $links;
|
113 |
+
}
|
114 |
+
|
115 |
public function get($key)
|
116 |
{
|
117 |
if(!is_array($this->config))
|
118 |
{
|
119 |
//Default config
|
120 |
+
$config = array('autoptimize_html' => 0,
|
121 |
+
'autoptimize_js' => 0,
|
122 |
+
'autoptimize_css' => 0);
|
123 |
|
124 |
//Override with user settings
|
125 |
if(get_option('autoptimize_html')!==false)
|
classes/autoptimizeScripts.php
CHANGED
@@ -32,6 +32,9 @@ class autoptimizeScripts extends autoptimizeBase
|
|
32 |
if($this->ismovable($tag))
|
33 |
{
|
34 |
$this->move[] = $tag;
|
|
|
|
|
|
|
35 |
}
|
36 |
}
|
37 |
}else{
|
@@ -47,9 +50,10 @@ class autoptimizeScripts extends autoptimizeBase
|
|
47 |
if($this->ismovable($tag))
|
48 |
{
|
49 |
$this->move[] = $tag;
|
50 |
-
}
|
51 |
//We shouldn't touch this
|
52 |
-
|
|
|
53 |
}
|
54 |
}
|
55 |
|
32 |
if($this->ismovable($tag))
|
33 |
{
|
34 |
$this->move[] = $tag;
|
35 |
+
}else{
|
36 |
+
//We shouldn't touch this
|
37 |
+
$tag = '';
|
38 |
}
|
39 |
}
|
40 |
}else{
|
50 |
if($this->ismovable($tag))
|
51 |
{
|
52 |
$this->move[] = $tag;
|
53 |
+
}else{
|
54 |
//We shouldn't touch this
|
55 |
+
$tag = '';
|
56 |
+
}
|
57 |
}
|
58 |
}
|
59 |
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Donate link: http://www.turleando.com.ar/autoptimize/
|
|
4 |
Tags: css, html, javascript, js, optimize, speed, cache
|
5 |
Requires at least: 2.6
|
6 |
Tested up to: 2.8
|
7 |
-
Stable tag: 0.
|
8 |
|
9 |
Autoptimize is a Wordpress plugin that speeds up your website, and helps you save bandwidth.
|
10 |
|
@@ -28,6 +28,12 @@ It concatenates all scripts and styles, minifies and compresses them, adds expir
|
|
28 |
|
29 |
== Changelog ==
|
30 |
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
= 0.3 =
|
32 |
* Disable CSS media on @imports - caused an infinite loop
|
33 |
|
4 |
Tags: css, html, javascript, js, optimize, speed, cache
|
5 |
Requires at least: 2.6
|
6 |
Tested up to: 2.8
|
7 |
+
Stable tag: 0.4
|
8 |
|
9 |
Autoptimize is a Wordpress plugin that speeds up your website, and helps you save bandwidth.
|
10 |
|
28 |
|
29 |
== Changelog ==
|
30 |
|
31 |
+
= 0.4 =
|
32 |
+
* Write plugin description in English
|
33 |
+
* Set default config to everything off
|
34 |
+
* Add link from plugins page to options page
|
35 |
+
* Fix problems with scripts that shouldn't be moved and were moved all the same
|
36 |
+
|
37 |
= 0.3 =
|
38 |
* Disable CSS media on @imports - caused an infinite loop
|
39 |
|