Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.0 #44

Open
wants to merge 32 commits into
base: master
Choose a base branch
from
Open

1.0 #44

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
a7f751e
+ Adds a new Tabbed Settings page
shadyvb Aug 25, 2013
a0c2b87
+ Exposes the option of defaulting to exclude the external dependenci…
shadyvb Aug 25, 2013
f290168
* Fix manage_plugins to manage_options
shadyvb Aug 25, 2013
41dd172
Squashed 'bin/' changes from 5614813..774bdc3
westonruter Oct 14, 2013
e1c8ed8
Merge commit '41dd1729ab2967fcc2d553a6b43f1bf786a76a86' into develop
westonruter Oct 14, 2013
8c7cb6e
Add travis, jshint, and phpcs ruleset
westonruter Oct 14, 2013
15a7139
Notices / CS fixes, Related #27
shadyvb Oct 14, 2013
18f79f6
Merge remote-tracking branch 'upstream/develop' into options_ui
shadyvb Oct 14, 2013
caa114b
Default exclude_dependencies to array to prevent notices if no settin…
shadyvb Oct 14, 2013
c02ea10
CS fixes
shadyvb Oct 16, 2013
4f1449c
Fix notices on settings screen on first install.
shadyvb Oct 16, 2013
a18558f
Remove faulty esc_html
shadyvb Oct 16, 2013
65c599c
Merge pull request #27 from shadyvb/options_ui
westonruter Oct 30, 2013
ac189ac
Merge branch 'master' into develop
westonruter Oct 30, 2013
aac4b03
Fix some phpdoc comments
westonruter Oct 30, 2013
ef17d91
Fix small CS issues
shadyvb Nov 4, 2013
910bb6a
Change esc_attr to esc_html
shadyvb Nov 5, 2013
5980d28
Skip escaping args inside of add_query_arg, since it does escaping al…
shadyvb Nov 5, 2013
41cb811
Better sanitizing input var
shadyvb Nov 5, 2013
211c66a
Merge pull request #46 from x-team/cs-fixes
westonruter Nov 5, 2013
71afac6
Add tests skeleton for #6
Jun 13, 2014
deaa1c8
Merge branch 'master' into develop
westonruter Jul 30, 2014
b83ad90
Squashed 'bin/' changes from cc5a003..2dbb4ca
westonruter Jul 30, 2014
6be9f33
Merge commit 'b83ad90304f6eb77b722151d5910921efe80090d' into develop
westonruter Jul 30, 2014
2dec6b7
Use .ci-env.sh to specify PHPCS_IGNORE
westonruter Jul 30, 2014
90598f4
Fix regex for readme.txt section frontmatter
westonruter Jul 30, 2014
6bbb1e1
Merge branch 'tests' of github.com:x-team/wp-dependency-minification …
westonruter Jul 30, 2014
88cdbca
Fixing code sniffs
frankiejarrett Aug 22, 2014
cbc133e
Fixing strange indentation sniffs
frankiejarrett Aug 22, 2014
b55cf15
Another indentation sniff fix
frankiejarrett Aug 22, 2014
bb5c4a9
Added max_age header
mehigh Jun 6, 2016
43a95f1
Merge pull request #74 from xwp/feature/headers-improvement
westonruter Jun 6, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .ci-env.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export PHPCS_IGNORE=minify/*
13 changes: 13 additions & 0 deletions admin.css
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,16 @@
.fixed .column-expires {
width: 12%;
}

.nav-tab-content {
display: none;
}
.form-table th small {
display: block;
clear: both;
color: #999;
}
.form-table td label {
display: block;
clear:both;
}
23 changes: 23 additions & 0 deletions admin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
jQuery( function( $ ) {

// Admin page tabs
var $tabs = $( '.nav-tab-wrapper' ),
$panels = $( '.nav-tab-content' ),
currentHash = window.location.hash;

$tabs.on( 'click', 'a', function() {
var hash = $( this ).attr( 'href' ).replace( '#tab-', '#tab-content-' ); // prevents page scrolling if hash is present

$panels.hide().filter( hash ).show();

$tabs.find( 'a' ).removeClass( 'nav-tab-active' ).filter( $( this ) ).addClass( 'nav-tab-active' );
});

$tabs.find( currentHash ? 'a[href="' + currentHash + '"]' : ':first' ).trigger( 'click' );

// Fix input-inside-label glitch
$panels.on( 'click', 'input[type=text]', function( e ) {
e.preventDefault();
});

});
4 changes: 4 additions & 0 deletions bin/.coveralls.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
service_name: travis-ci
src_dir: .
coverage_clover: build/logs/clover.xml
json_path: build/logs/coveralls-upload.json
30 changes: 21 additions & 9 deletions bin/.travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,36 @@ node_js:
- 0.10

env:
- WP_VERSION=master WP_MULTISITE=0
- WP_VERSION=master WP_MULTISITE=1
- WP_VERSION=latest WP_MULTISITE=0
- WP_VERSION=latest WP_MULTISITE=1
- WP_VERSION=3.8 WP_MULTISITE=0
- WP_VERSION=3.8 WP_MULTISITE=1

before_script:
- export WP_TESTS_DIR=/tmp/wordpress-tests/
- export PLUGIN_DIR=$(pwd)
- export PLUGIN_SLUG=$(basename $(pwd) | sed 's/^wp-//')
- if [ -e phpunit.xml ] || [ -e phpunit.xml.dist ]; then bash bin/install-wp-tests.sh wordpress_test root '' localhost $WP_VERSION; cd /tmp/wordpress/wp-content/plugins; ln -s $PLUGIN_DIR $PLUGIN_SLUG; cd $PLUGIN_DIR; fi
- pear config-set auto_discover 1
- pear install PHP_CodeSniffer
- git clone git://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards.git $(pear config-get php_dir)/PHP/CodeSniffer/Standards/WordPress
- phpenv rehash
- export PHPCS_DIR=/tmp/phpcs
- export PHPCS_GITHUB_SRC=squizlabs/PHP_CodeSniffer
- export PHPCS_GIT_TREE=master
- export PHPCS_IGNORE='tests/*,vendor/*'
- export WPCS_DIR=/tmp/wpcs
- export WPCS_GITHUB_SRC=WordPress-Coding-Standards/WordPress-Coding-Standards
- export WPCS_GIT_TREE=master
- export WPCS_STANDARD=$(if [ -e phpcs.ruleset.xml ]; then echo phpcs.ruleset.xml; else echo WordPress-Core; fi)
- if [ -e .ci-env.sh ]; then source .ci-env.sh; fi
- if [ -e phpunit.xml ] || [ -e phpunit.xml.dist ]; then wget -O /tmp/install-wp-tests.sh https://raw.githubusercontent.com/wp-cli/wp-cli/master/templates/install-wp-tests.sh; bash /tmp/install-wp-tests.sh wordpress_test root '' localhost $WP_VERSION; cd /tmp/wordpress/wp-content/plugins; ln -s $PLUGIN_DIR $PLUGIN_SLUG; cd $PLUGIN_DIR; fi
- mkdir -p $PHPCS_DIR && curl -L https://github.com/$PHPCS_GITHUB_SRC/archive/$PHPCS_GIT_TREE.tar.gz | tar xvz --strip-components=1 -C $PHPCS_DIR
- mkdir -p $WPCS_DIR && curl -L https://github.com/$WPCS_GITHUB_SRC/archive/$WPCS_GIT_TREE.tar.gz | tar xvz --strip-components=1 -C $WPCS_DIR
- $PHPCS_DIR/scripts/phpcs --config-set installed_paths $WPCS_DIR
- npm install -g jshint
- if [ -e composer.json ]; then wget http://getcomposer.org/composer.phar && php composer.phar install --dev; fi

script:
- find . -path ./bin -prune -o \( -name '*.php' -o -name '*.inc' \) -exec php -lf {} \;
- if [ -e phpunit.xml ] || [ -e phpunit.xml.dist ]; then phpunit; fi
- phpcs --standard=$(if [ -e ruleset.xml ]; then echo ruleset.xml; else echo WordPress; fi) $(find . -name '*.php')
- if [ -e phpunit.xml ] || [ -e phpunit.xml.dist ]; then phpunit $( if [ -e .coveralls.yml ]; then echo --coverage-clover build/logs/clover.xml; fi ); fi
- $PHPCS_DIR/scripts/phpcs --standard=$WPCS_STANDARD $(if [ -n "$PHPCS_IGNORE" ]; then echo --ignore=$PHPCS_IGNORE; fi) $(find . -name '*.php')
- jshint .

after_script:
- if [ -e .coveralls.yml ]; then php vendor/bin/coveralls; fi
35 changes: 23 additions & 12 deletions bin/class-wordpress-readme-parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function __construct( $args = array() ) {
throw new Exception( "Parse error in $metadatum" );
}
list( $name, $value ) = array_slice( $metadataum_matches, 1, 2 );
$this->metadata[$name] = $value;
$this->metadata[ $name ] = $value;
}
$this->metadata['Contributors'] = preg_split( '/\s*,\s*/', $this->metadata['Contributors'] );
$this->metadata['Tags'] = preg_split( '/\s*,\s*/', $this->metadata['Tags'] );
Expand All @@ -58,11 +58,17 @@ function __construct( $args = array() ) {
$body = trim( array_shift( $section_match ) );
$subsections = array();

// @todo Parse out front matter /(.+?)(\n=\s+.+$)/s
// Check if there is front matter
if ( preg_match( '/^(\s*[^=].+?)(?=\n=|$)(.*$)/s', $body, $matches ) ) {
$body = $matches[1];
$subsection_search_area = $matches[2];
} else {
$subsection_search_area = $body;
$body = null;
}

// Parse subsections
if ( preg_match_all( '/(?:^|\n)= (.+?) =\n(.+?)(?=\n= |$)/s', $body, $subsection_matches, PREG_SET_ORDER ) ) {
$body = null;
if ( preg_match_all( '/(?:^|\n)= (.+?) =\n(.+?)(?=\n= |$)/s', $subsection_search_area, $subsection_matches, PREG_SET_ORDER ) ) {
foreach ( $subsection_matches as $subsection_match ) {
array_shift( $subsection_match );
$subsections[] = array(
Expand Down Expand Up @@ -94,12 +100,6 @@ function to_markdown( $params = array() ) {

// Parse sections
$section_formatters = array(
'Description' => function ( $body ) use ( $params ) {
if ( isset( $params['travis_ci_url'] ) ) {
$body .= sprintf( "\n\n[![Build Status](%s.png?branch=master)](%s)", $params['travis_ci_url'], $params['travis_ci_url'] );
}
return $body;
},
'Screenshots' => function ( $body ) {
$body = trim( $body );
$new_body = '';
Expand Down Expand Up @@ -172,6 +172,17 @@ function ( $tag ) {
foreach ( $formatted_metadata as $name => $value ) {
$markdown .= sprintf( "**%s:** %s \n", $name, $value );
}

if ( isset( $params['travis_ci_url'] ) || isset( $params['coveralls_url'] ) ) {
$markdown .= "\n";
if ( isset( $params['travis_ci_url'] ) ) {
$markdown .= sprintf( '[![Build Status](%s.png?branch=master)](%s) ', $params['travis_ci_url'], $params['travis_ci_url'] );
}
if ( isset( $params['coveralls_url'] ) ) {
$markdown .= sprintf( '[![Build Status](%s?branch=master)](%s) ', $params['coveralls_badge_src'], $params['coveralls_url'] );
}
$markdown .= "\n";
}
$markdown .= "\n";

foreach ( $this->sections as $section ) {
Expand All @@ -181,8 +192,8 @@ function ( $tag ) {
$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 ( isset( $section_formatters[ $section['heading'] ] ) ) {
$body = trim( call_user_func( $section_formatters[ $section['heading'] ], $body ) );
}

if ( $body ) {
Expand Down
8 changes: 7 additions & 1 deletion bin/generate-markdown-readme
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,14 @@ try {
$readme = new WordPress_Readme_Parser( array( 'path' => $readme_txt_path ) );

$md_args = array();
$github_url_regex = '#.+github\.com[:/]([^/]+/[^/]+)\.git$#';
$origin_url = trim( `git config --get remote.origin.url` );
if ( file_exists( $readme_root . '/.travis.yml' ) ) {
$md_args['travis_ci_url'] = preg_replace( '/^.+?:(.+)\.git$/', 'https://travis-ci.org/$1', trim( `git config --get remote.origin.url` ) );
$md_args['travis_ci_url'] = preg_replace( $github_url_regex, 'https://travis-ci.org/$1', $origin_url );
}
if ( file_exists( $readme_root . '/.coveralls.yml' ) ) {
$md_args['coveralls_badge_src'] = preg_replace( $github_url_regex, 'https://coveralls.io/repos/$1/badge.png', $origin_url );
$md_args['coveralls_url'] = preg_replace( $github_url_regex, 'https://coveralls.io/r/$1', $origin_url );
}
$markdown = $readme->to_markdown( $md_args );

Expand Down
65 changes: 0 additions & 65 deletions bin/install-wp-tests.sh

This file was deleted.

22 changes: 2 additions & 20 deletions bin/phpcs.ruleset.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,8 @@
<ruleset name="WordPress Coding Standards for Plugins">
<description>Generally-applicable sniffs for WordPress plugins</description>

<rule ref="WordPress">
<exclude name="WordPress.VIP.RestrictedFunctions"/>
<exclude name="WordPress.VIP.SuperGlobalInputUsage"/>
<exclude name="WordPress.VIP.ValidatedSanitizedInput"/>
</rule>
<rule ref="WordPress.NamingConventions.ValidFunctionName">
<exclude-pattern>/tests/*</exclude-pattern><!-- because of PHPUnit method names -->
</rule>
<rule ref="WordPress-Extra" />

<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace"/>
<rule ref="Generic.PHP.DisallowShortOpenTag"/>
<rule ref="Generic.Files.ByteOrderMark"/>
<rule ref="Generic.PHP.LowerCaseConstant"/>
<rule ref="Generic.WhiteSpace.DisallowSpaceIndent"/>
<rule ref="Generic.PHP.NoSilencedErrors" />
<rule ref="Generic.ControlStructures.InlineControlStructure" />
<rule ref="Generic.Files.LineEndings">
<properties>
<property name="eolChar" value="\n"/>
</properties>
</rule>
<exclude-pattern>/tests/*,/vendor/*</exclude-pattern>

</ruleset>
35 changes: 30 additions & 5 deletions bin/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@

set -e

WPCS_STANDARD=$(if [ -e phpcs.ruleset.xml ]; then echo phpcs.ruleset.xml; else echo WordPress-Core; fi)
if [ -e .ci-env.sh ]; then
source .ci-env.sh
fi

message="Checking staged changes..."
git_status_egrep='^[MARC].+'

Expand Down Expand Up @@ -44,9 +49,30 @@ if [ ${#staged_php_files[@]} != 0 ]; then
# PHPUnit
if [ -e phpunit.xml ] || [ -e phpunit.xml.dist ]; then
echo "## phpunit"
if [ "$USER" != 'vagrant' ] && command -v vagrant >/dev/null 2>&1 && command -v vassh >/dev/null 2>&1; then
echo "Running phpunit in vagrant..."
vassh phpunit
if [ "$USER" != 'vagrant' ]; then

# Check if we're in VVV
plugin_dir=$(pwd)
while [ ! -e Vagrantfile ]; do
if [ $(pwd) == '/' ] || [ "$last_dir" == $(pwd) ]; then
break
fi
last_dir=$(pwd)
cd ..
done
if [ -e Vagrantfile ] && grep -q vvv Vagrantfile; then
vvv_root=$(pwd)
absolute_vvv_plugin_path=/srv${plugin_dir:${#vvv_root}}
fi
cd $plugin_dir

if [ ! -z "$absolute_vvv_plugin_path" ]; then
echo "Running phpunit in VVV"
vagrant ssh -c "cd $absolute_vvv_plugin_path && phpunit"
elif command -v vassh >/dev/null 2>&1; then
echo "Running phpunit in vagrant via vassh..."
vassh phpunit
fi
elif ! command -v phpunit >/dev/null 2>&1;then
echo "Skipping phpunit since not installed"
elif [ -z "$WP_TESTS_DIR" ]; then
Expand All @@ -59,8 +85,7 @@ if [ ${#staged_php_files[@]} != 0 ]; then
# PHP_CodeSniffer WordPress Coding Standards
echo "## phpcs"
if command -v phpcs >/dev/null 2>&1; then
phpcs_standard=$(if [ -e ruleset.xml ]; then echo ruleset.xml; else echo WordPress; fi)
phpcs -p -s -v --standard=$phpcs_standard "${staged_php_files[@]}"
phpcs -p -s -v --standard=$WPCS_STANDARD $(if [ -n "$PHPCS_IGNORE" ]; then echo --ignore=$PHPCS_IGNORE; fi) "${staged_php_files[@]}"
else
echo "Skipping phpcs since not installed"
fi
Expand Down
11 changes: 11 additions & 0 deletions bin/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,17 @@ cd .git/hooks
ln -s ../../bin/pre-commit .
```

You may customize the behavior of the `.travis.yml` and `pre-commit` hook by
specifying a `.ci-env.sh` in the root of the repo, for example:

```bash
export PHPCS_GITHUB_SRC=x-team/PHP_CodeSniffer
export PHPCS_GIT_TREE=master
export WPCS_GIT_TREE=develop
export WPCS_STANDARD=WordPress-Core
export PHPCS_IGNORE='tests/*,includes/vendor/*'
```

The library includes a WordPress README [parser](class-wordpress-readme-parser.php) and [converter](generate-markdown-readme) to Markdown,
so you don't have to manually keep your `readme.txt` on WordPress.org in sync with the `readme.md` you have on GitHub. The
converter will also automatically recognize the presence of projects with Travis CI and include the status image
Expand Down
Loading