diff --git a/bin/.jshintrc b/bin/.jshintrc
index a2bb92b..bf11264 100644
--- a/bin/.jshintrc
+++ b/bin/.jshintrc
@@ -1,63 +1,20 @@
-// --------------------------------------------------------------------
-// WordPress JSHint Configuration
-// --------------------------------------------------------------------
{
- "bitwise" : true, // Prohibit bitwise operators (&, |, ^, etc.).
- "curly" : true, // Require {} for every new block or scope.
- "eqeqeq" : true, // Require triple equals i.e. `===`.
- "forin" : true, // Tolerate `for in` loops without `hasOwnPrototype`.
- "immed" : true, // Require immediate invocations to be wrapped in parens e.g. `( function(){}() );`
- "latedef" : true, // Prohibit variable use before definition.
- "newcap" : true, // Require capitalization of all constructor functions e.g. `new F()`.
- "noarg" : true, // Prohibit use of `arguments.caller` and `arguments.callee`.
- "noempty" : true, // Prohibit use of empty blocks.
- "nonew" : true, // Prohibit use of constructors for side-effects.
- "plusplus" : false, // Prohibit use of `++` & `--`.
- "regexp" : false, // Prohibit `.` and `[^...]` in regular expressions.
- "undef" : true, // Require all non-global variables be declared before they are used.
- "strict" : true, // Require `use strict` pragma in every file.
- "trailing" : true, // Prohibit trailing whitespaces.
- "asi" : false, // Tolerate Automatic Semicolon Insertion (no semicolons).
- "boss" : false, // Tolerate assignments inside if, for & while. Usually conditions & loops are for comparison, not assignments.
- "debug" : false, // Allow debugger statements e.g. browser breakpoints.
- "eqnull" : false, // Tolerate use of `== null`.
- "es5" : false, // Allow EcmaScript 5 syntax.
- "esnext" : false, // Allow ES.next specific features such as `const` and `let`.
- "evil" : false, // Tolerate use of `eval`.
- "expr" : false, // Tolerate `ExpressionStatement` as Programs.
- "funcscope" : false, // Tolerate declarations of variables inside of control structures while accessing them later from the outside.
- "globalstrict" : false, // Allow global "use strict" (also enables 'strict').
- "iterator" : false, // Allow usage of __iterator__ property.
- "lastsemic" : false, // Tolerate missing semicolons when it is omitted for the last statement in a one-line block.
- "laxbreak" : false, // Tolerate unsafe line breaks e.g. `return [\n] x` without semicolons.
- "laxcomma" : false, // Suppress warnings about comma-first coding style.
- "loopfunc" : false, // Allow functions to be defined within loops.
- "multistr" : false, // Tolerate multi-line strings.
- "onecase" : false, // Tolerate switches with just one case.
- "proto" : false, // Tolerate __proto__ property. This property is deprecated.
- "regexdash" : false, // Tolerate unescaped last dash i.e. `[-...]`.
- "scripturl" : false, // Tolerate script-targeted URLs.
- "smarttabs" : false, // Tolerate mixed tabs and spaces when the latter are used for alignmnent only.
- "shadow" : false, // Allows re-define variables later in code e.g. `var x=1; x=2;`.
- "sub" : false, // Tolerate all forms of subscript notation besides dot notation e.g. `dict['key']` instead of `dict.key`.
- "supernew" : true, // Tolerate `new function () { ... };` and `new Object;`.
- "validthis" : false, // Tolerate strict violations when the code is running in strict mode and you use this in a non-constructor function.
- "browser" : true, // Standard browser globals e.g. `window`, `document`.
- "couch" : false, // Enable globals exposed by CouchDB.
- "devel" : false, // Allow development statements e.g. `console.log();`.
- "dojo" : false, // Enable globals exposed by Dojo Toolkit.
- "jquery" : true, // Enable globals exposed by jQuery JavaScript library.
- "mootools" : false, // Enable globals exposed by MooTools JavaScript framework.
- "node" : false, // Enable globals available when code is running inside of the NodeJS runtime environment.
- "nonstandard" : false, // Define non-standard but widely adopted globals such as escape and unescape.
- "prototypejs" : false, // Enable globals exposed by Prototype JavaScript framework.
- "rhino" : false, // Enable globals available when your code is running inside of the Rhino runtime environment.
- "wsh" : false, // Enable globals available when your code is running as a script for the Windows Script Host.
- "nomen" : false, // Prohibit use of initial or trailing underbars in names.
- "onevar" : false, // Allow only one `var` statement per function.
- "passfail" : false, // Stop on first error.
- "white" : false, // Check against strict whitespace and indentation rules.
- "maxerr" : 100, // Maximum errors before stopping.
- "predef" : [], // Extra globals.
- "indent" : 4 // Specify indentation spacing
-}
\ No newline at end of file
+ "boss": true,
+ "curly": true,
+ "eqeqeq": true,
+ "eqnull": true,
+ "expr": true,
+ "immed": true,
+ "noarg": true,
+ "quotmark": "single",
+ "trailing": true,
+ "undef": true,
+ "unused": true,
+
+ "browser": true,
+
+ "globals": {
+ "jQuery": false,
+ "wp": false
+ }
+}
diff --git a/bin/.travis.yml b/bin/.travis.yml
index 854a58c..ae1da44 100644
--- a/bin/.travis.yml
+++ b/bin/.travis.yml
@@ -12,8 +12,8 @@ node_js:
env:
- WP_VERSION=master WP_MULTISITE=0
- WP_VERSION=master WP_MULTISITE=1
- - WP_VERSION=3.7 WP_MULTISITE=0
- - WP_VERSION=3.7 WP_MULTISITE=1
+ - WP_VERSION=latest WP_MULTISITE=0
+ - WP_VERSION=latest WP_MULTISITE=1
before_script:
- export WP_TESTS_DIR=/tmp/wordpress-tests/
diff --git a/bin/class-wordpress-readme-parser.php b/bin/class-wordpress-readme-parser.php
index 0a4f52e..784b219 100644
--- a/bin/class-wordpress-readme-parser.php
+++ b/bin/class-wordpress-readme-parser.php
@@ -83,11 +83,20 @@ function __construct( $args = array() ) {
*/
function to_markdown( $params = array() ) {
+ $general_section_formatter = function ( $body ) use ( $params ) {
+ $body = preg_replace(
+ '#\[youtube\s+(?:http://www\.youtube\.com/watch\?v=|http://youtu\.be/)(.+?)\]#',
+ '[](http://www.youtube.com/watch?v=$1)',
+ $body
+ );
+ return $body;
+ };
+
// Parse sections
$section_formatters = array(
'Description' => function ( $body ) use ( $params ) {
if ( isset( $params['travis_ci_url'] ) ) {
- $body .= sprintf( "\n\n[](%s)", $params['travis_ci_url'], $params['travis_ci_url'] );
+ $body .= sprintf( "\n\n[](%s)", $params['travis_ci_url'], $params['travis_ci_url'] );
}
return $body;
},
@@ -170,9 +179,12 @@ function ( $tag ) {
$markdown .= "\n";
$body = $section['body'];
+
+ $body = call_user_func( $general_section_formatter, $body );
if ( isset( $section_formatters[$section['heading']] ) ) {
$body = trim( call_user_func( $section_formatters[$section['heading']], $body ) );
}
+
if ( $body ) {
$markdown .= sprintf( "%s\n", $body );
}
diff --git a/bin/install-wp-tests.sh b/bin/install-wp-tests.sh
index 82cd598..464772b 100755
--- a/bin/install-wp-tests.sh
+++ b/bin/install-wp-tests.sh
@@ -16,7 +16,14 @@ set -ex
# set up a WP install
WP_CORE_DIR=/tmp/wordpress/
mkdir -p $WP_CORE_DIR
-wget -nv -O /tmp/wordpress.tar.gz https://github.com/WordPress/WordPress/tarball/$WP_VERSION
+
+if [ $WP_VERSION == 'latest' ]; then
+ ARCHIVE_URL='http://wordpress.org/latest.tar.gz'
+else
+ ARCHIVE_URL="https://github.com/WordPress/WordPress/tarball/$WP_VERSION"
+fi
+
+wget -nv -O /tmp/wordpress.tar.gz $ARCHIVE_URL
tar --strip-components=1 -zxmf /tmp/wordpress.tar.gz -C $WP_CORE_DIR
# set up testing suite
diff --git a/bin/phpcs.ruleset.xml b/bin/phpcs.ruleset.xml
new file mode 100644
index 0000000..aeb1d34
--- /dev/null
+++ b/bin/phpcs.ruleset.xml
@@ -0,0 +1,27 @@
+
+
+ Generally-applicable sniffs for WordPress plugins
+
+
+
+
+
+
+
+ /tests/*
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/bin/readme.md b/bin/readme.md
index 7f5cd3c..38c5812 100644
--- a/bin/readme.md
+++ b/bin/readme.md
@@ -26,11 +26,12 @@ git subtree push --prefix bin \
git@github.com:x-team/wp-plugin-dev-lib.git master
```
-Symlink to the `.travis.yml` and `.jshintrc` inside of the `bin/` directory you added:
+Symlink to the `.travis.yml`, `.jshintrc`, and `phpcs.ruleset.xml` inside of the `bin/` directory you added:
```bash
ln -s bin/.travis.yml . && git add .travis.yml
ln -s bin/.jshintrc . && git add .jshintrc
+ln -s bin/phpcs.ruleset.xml . && git add phpcs.ruleset.xml
```
Symlink to `pre-commit` from your project's `.git/hooks/pre-commit`:
diff --git a/bin/svn-push b/bin/svn-push
index b783985..c573756 100755
--- a/bin/svn-push
+++ b/bin/svn-push
@@ -1,6 +1,6 @@
#!/bin/bash
# Given a svn-url file one directory up, export the latest git commits to the specified SVN repo.
-# Create a git release tag from the verison specified in the plugin file.
+# Create a git release tag from the version specified in the plugin file.
# Author: Weston Ruter (@westonruter)
set -e
@@ -154,4 +154,4 @@ rm $svn_commit_file
# Restore branch
if [ $current_branch != 'master' ]; then
git checkout $current_branch
-fi
\ No newline at end of file
+fi
diff --git a/dependency-minification.php b/dependency-minification.php
index cd2bbf1..21966d5 100644
--- a/dependency-minification.php
+++ b/dependency-minification.php
@@ -2,7 +2,7 @@
/**
* Plugin Name: Dependency Minification
* Description: Concatenates and minifies scripts and stylesheets. Please install and activate scribu's Proper Network Activation plugin before activating this plugin network-wide.
- * Version: 0.9.7
+ * Version: 0.9.8
* Author: X-Team
* Author URI: http://x-team.com/wordpress/
* Text Domain: dependency-minification
@@ -59,6 +59,7 @@ static function setup() {
'admin_page_capability' => 'edit_theme_options',
'show_error_messages' => ( defined( 'WP_DEBUG' ) && WP_DEBUG ),
'disable_if_wp_debug' => true,
+ 'print_manifest' => true,
),
self::$options
) );
@@ -398,7 +399,7 @@ static function admin_page() {
$_link_params = $link_params;
$_link_params['depmin_task'] = 'purge';
?>
-
+
@@ -413,14 +414,14 @@ static function admin_page() {
$_link_params = $link_params;
$_link_params['depmin_task'] = 'expire';
?>
- |
+ |
- |
+ |
@@ -431,7 +432,7 @@ static function admin_page() {
$_link_params = $link_params;
$_link_params['depmin_task'] = 'purge';
?>
-
+
@@ -866,13 +867,15 @@ static function minify( $cached ) {
$contents = '';
// Print a manifest of the dependencies
- $contents .= sprintf("/*! This minified dependency bundle includes:\n");
- $i = 0;
- foreach ( $srcs as $src ) {
- $i += 1;
- $contents .= sprintf( " * %02d. %s\n", $i, $src );
+ if ( self::$options['print_manifest'] ) {
+ $contents .= sprintf("/*! This minified dependency bundle includes:\n");
+ $i = 0;
+ foreach ( $srcs as $src ) {
+ $i += 1;
+ $contents .= sprintf( " * %02d. %s\n", $i, $src );
+ }
+ $contents .= sprintf(" */\n\n");
}
- $contents .= sprintf(" */\n\n");
// Minify
// Note: semicolon needed in case a file lacks trailing semicolon
diff --git a/minify/JS/ClosureCompiler.php b/minify/JS/ClosureCompiler.php
index 51f7cd1..d4358a0 100644
--- a/minify/JS/ClosureCompiler.php
+++ b/minify/JS/ClosureCompiler.php
@@ -14,7 +14,10 @@
* @todo can use a stream wrapper to unit test this?
*/
class Minify_JS_ClosureCompiler {
- const URL = 'http://closure-compiler.appspot.com/compile';
+ /**
+ * @var $url URL to compiler server. defaults to google server
+ */
+ protected $url = 'http://closure-compiler.appspot.com/compile';
/**
* Minify Javascript code via HTTP request to the Closure Compiler API
@@ -34,12 +37,17 @@ public static function minify($js, array $options = array())
* @param array $options
*
* fallbackFunc : default array($this, 'fallback');
+ * compilerUrl : URL to closure compiler server
*/
public function __construct(array $options = array())
{
$this->_fallbackFunc = isset($options['fallbackMinifier'])
? $options['fallbackMinifier']
: array($this, '_fallback');
+
+ if (isset($options['compilerUrl'])) {
+ $this->url = $options['compilerUrl'];
+ }
}
public function min($js)
@@ -76,7 +84,7 @@ protected function _getResponse($postBody)
{
$allowUrlFopen = preg_match('/1|yes|on|true/i', ini_get('allow_url_fopen'));
if ($allowUrlFopen) {
- $contents = file_get_contents(self::URL, false, stream_context_create(array(
+ $contents = file_get_contents($this->url, false, stream_context_create(array(
'http' => array(
'method' => 'POST',
'header' => "Content-type: application/x-www-form-urlencoded\r\nConnection: close\r\n",
@@ -86,7 +94,7 @@ protected function _getResponse($postBody)
)
)));
} elseif (defined('CURLOPT_POST')) {
- $ch = curl_init(self::URL);
+ $ch = curl_init($this->url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-type: application/x-www-form-urlencoded'));
diff --git a/minify/JS/JSMin.php b/minify/JS/JSMin.php
index c84dd84..9840d8b 100644
--- a/minify/JS/JSMin.php
+++ b/minify/JS/JSMin.php
@@ -200,8 +200,9 @@ protected function action($command)
break;
}
if ($this->isEOF($this->a)) {
+ $byte = $this->inputIndex - 1;
throw new JSMin_UnterminatedStringException(
- "JSMin: Unterminated String at byte {$this->inputIndex}: {$str}");
+ "JSMin: Unterminated String at byte {$byte}: {$str}");
}
$str .= $this->a;
if ($this->a === '\\') {
@@ -251,8 +252,9 @@ protected function action($command)
$this->a = $this->get();
$pattern .= $this->a;
} elseif ($this->isEOF($this->a)) {
+ $byte = $this->inputIndex - 1;
throw new JSMin_UnterminatedRegExpException(
- "JSMin: Unterminated RegExp at byte {$this->inputIndex}: {$pattern}");
+ "JSMin: Unterminated RegExp at byte {$byte}: {$pattern}");
}
$this->output .= $this->a;
$this->lastByteOut = $this->a;
@@ -272,23 +274,33 @@ protected function isRegexpLiteral()
// we obviously aren't dividing
return true;
}
- if ($this->a === ' ' || $this->a === "\n") {
- $length = strlen($this->output);
- if ($length < 2) { // weird edge case
- return true;
+
+ // we have to check for a preceding keyword, and we don't need to pattern
+ // match over the whole output.
+ $recentOutput = substr($this->output, -10);
+
+ // check if return/typeof directly precede a pattern without a space
+ foreach (array('return', 'typeof') as $keyword) {
+ if ($this->a !== substr($keyword, -1)) {
+ // certainly wasn't keyword
+ continue;
}
- // you can't divide a keyword
- if (preg_match('/(?:case|else|in|return|typeof)$/', $this->output, $m)) {
- if ($this->output === $m[0]) { // odd but could happen
- return true;
- }
- // make sure it's a keyword, not end of an identifier
- $charBeforeKeyword = substr($this->output, $length - strlen($m[0]) - 1, 1);
- if (! $this->isAlphaNum($charBeforeKeyword)) {
+ if (preg_match("~(^|[\\s\\S])" . substr($keyword, 0, -1) . "$~", $recentOutput, $m)) {
+ if ($m[1] === '' || !$this->isAlphaNum($m[1])) {
return true;
}
}
}
+
+ // check all keywords
+ if ($this->a === ' ' || $this->a === "\n") {
+ if (preg_match('~(^|[\\s\\S])(?:case|else|in|return|typeof)$~', $recentOutput, $m)) {
+ if ($m[1] === '' || !$this->isAlphaNum($m[1])) {
+ return true;
+ }
+ }
+ }
+
return false;
}
diff --git a/minify/update b/minify/update
new file mode 100755
index 0000000..289175d
--- /dev/null
+++ b/minify/update
@@ -0,0 +1,25 @@
+#!/usr/bin/env php
+ "https://raw.github.com/mrclay/minify/master/min/lib/Minify/JS/ClosureCompiler.php",
+ "JS/JSMin.php" => "https://raw.github.com/mrclay/minify/master/min/lib/JSMin.php",
+ "JS/JSMinPlus.php" => "https://raw.github.com/mrclay/minify/master/min/lib/JSMinPlus.php",
+ "CSS/Compressor.php" => "https://raw.github.com/mrclay/minify/master/min/lib/Minify/CSS/Compressor.php",
+ "CSS/UriRewriter.php" => "https://raw.github.com/mrclay/minify/master/min/lib/Minify/CSS/UriRewriter.php",
+ "CommentPreserver.php" => "https://raw.github.com/mrclay/minify/master/min/lib/Minify/CommentPreserver.php",
+);
+
+foreach( $sources as $path => $url ) {
+ echo "$path => $url\n";
+ $contents = file_get_contents( $url );
+ file_put_contents( $path, $contents ) || exit( 1 );
+ system( sprintf( 'git add %s', escapeshellarg( $path ) ) );
+}
diff --git a/readme.md b/readme.md
index e4b4591..52d467d 100644
--- a/readme.md
+++ b/readme.md
@@ -6,7 +6,7 @@ Automatically concatenates and minifies any scripts and stylesheets enqueued usi
**Contributors:** [x-team](http://profiles.wordpress.org/x-team), [westonruter](http://profiles.wordpress.org/westonruter), [fjarrett](http://profiles.wordpress.org/fjarrett), [kucrut](http://profiles.wordpress.org/kucrut), [shadyvb](http://profiles.wordpress.org/shadyvb), [alex-ye](http://profiles.wordpress.org/alex-ye), [c3mdigital](http://profiles.wordpress.org/c3mdigital), [lkraav](http://profiles.wordpress.org/lkraav)
**Tags:** [performance](http://wordpress.org/plugins/tags/performance), [dependencies](http://wordpress.org/plugins/tags/dependencies), [minify](http://wordpress.org/plugins/tags/minify), [concatenate](http://wordpress.org/plugins/tags/concatenate), [compress](http://wordpress.org/plugins/tags/compress), [js](http://wordpress.org/plugins/tags/js), [javascript](http://wordpress.org/plugins/tags/javascript), [scripts](http://wordpress.org/plugins/tags/scripts), [css](http://wordpress.org/plugins/tags/css), [styles](http://wordpress.org/plugins/tags/styles), [stylesheets](http://wordpress.org/plugins/tags/stylesheets), [gzip](http://wordpress.org/plugins/tags/gzip), [yslow](http://wordpress.org/plugins/tags/yslow), [pagespeed](http://wordpress.org/plugins/tags/pagespeed), [caching](http://wordpress.org/plugins/tags/caching)
**Requires at least:** 3.5
-**Tested up to:** 3.6.1
+**Tested up to:** 3.8
**Stable tag:** trunk (master)
**License:** [GPLv2 or later](http://www.gnu.org/licenses/gpl-2.0.html)
@@ -50,10 +50,16 @@ If you are using Nginx with the default Varying Vagrant Vagrants config, you'll
log_not_found off;
}
-[](https://travis-ci.org/x-team/wp-dependency-minification)
+[](https://travis-ci.org/x-team/wp-dependency-minification)
## Changelog ##
+### 0.9.8 ###
+* Fix rewrite rule broken by filtering home_url ([#49](https://github.com/x-team/wp-dependency-minification/pull/49)). Props [c3mdigital](http://profiles.wordpress.org/c3mdigital/).
+ * Switch from JSMin to JSMinPlus due to repeated issues with JSMin causing execution timeouts.
+ * Update plugin to indicate WordPress 3.8 compatibility.
+ * Fix expire and purge links.
+
### 0.9.7 ###
Improve how the plugin guesses the sources' absolute paths ([#34](https://github.com/x-team/wp-dependency-minification/pull/34)). Props [alex-ye](http://profiles.wordpress.org/alex-ye/).
diff --git a/readme.txt b/readme.txt
index 2b3752a..c7a394b 100644
--- a/readme.txt
+++ b/readme.txt
@@ -1,7 +1,7 @@
=== Dependency Minification ===
Contributors: X-team, westonruter, fjarrett, kucrut, shadyvb, alex-ye, c3mdigital, lkraav
Tags: performance, dependencies, minify, concatenate, compress, js, javascript, scripts, css, styles, stylesheets, gzip, yslow, pagespeed, caching
-Tested up to: 3.6.1
+Tested up to: 3.8
Requires at least: 3.5
Stable tag: trunk
License: GPLv2 or later
@@ -52,6 +52,12 @@ If you are using Nginx with the default Varying Vagrant Vagrants config, you'll
== Changelog ==
+= 0.9.8 =
+ * Fix rewrite rule broken by filtering home_url ([#49](https://github.com/x-team/wp-dependency-minification/pull/49)). Props [c3mdigital](http://profiles.wordpress.org/c3mdigital/).
+ * Switch from JSMin to JSMinPlus due to repeated issues with JSMin causing execution timeouts.
+ * Update plugin to indicate WordPress 3.8 compatibility.
+ * Fix expire and purge links.
+
= 0.9.7 =
Improve how the plugin guesses the sources' absolute paths ([#34](https://github.com/x-team/wp-dependency-minification/pull/34)). Props [alex-ye](http://profiles.wordpress.org/alex-ye/).