Thanks for taking the time to contribute!
To start, clone this repository into your WordPress install being used for development:
cd wp-content/plugins && git clone --recursive git@github.com:Automattic/amp-wp.git amp
If you happened to have cloned without --recursive
previously, please do git submodule update --init
to ensure the dev-lib submodule is available for development.
Lastly, to get the plugin running in your WordPress install, run composer install
and then activate the plugin via the WordPress dashboard or wp plugin activate amp
.
To install the pre-commit
hook, do bash dev-lib/install-pre-commit-hook.sh
.
Note that pull requests will be checked against WordPress-Coding-Standards with PHPCS, and for JavaScript linting is done with ESLint and (for now) JSCS and JSHint.
To edit JavaScript code which is built/complied, run npm run dev
to watch the files which Webpack will build. These complied files are excluded from version control but they are included in the release packages.
To create a build of the plugin for installing in WordPress as a ZIP package, do:
git submodule update --init # (if you haven't done so yet)
composer install # (if you haven't done so yet)
npm install # (if you haven't done so yet)
npm run build
This will create an amp.zip
in the plugin directory which you can install. The contents of this ZIP are also located in the build
directory which you can rsync
somewhere as well.
The file class-amp-allowed-tags-generated.php
has the AMP specification's allowed tags and attributes. It's used in sanitization.
To update that file:
cd
to the root of this plugin- run
bash bin/amphtml-update.sh
That script is intended for a Linux environment like VVV.
The following script creates a post in order to test support for WordPress media and embeds. To run it:
ssh
into an environment like VVVcd
to the root of this plugin- run
wp eval-file bin/create-embed-test-post.php
- go to the URL that is output in the command line
The following script adds an instance of every default WordPress widget to the first registered sidebar. To run it:
ssh
into an environment like VVVcd
to the root of this plugin- run
wp eval-file bin/add-test-widgets-to-sidebar.php
- There will be a message indicating which sidebar has the widgets. Please visit a page with that sidebar.
The following script creates a post with comments in order to test support for WordPress comments. To run it:
ssh
into an environment like VVVcd
to the root of this plugin- run
wp eval-file bin/create-comments-on-test-post.php
- go to the URL that is output in the command line
The following script creates a post with all core Gutenberg blocks. To run it:
ssh
into an environment like VVVcd
to the root of this plugin- run
bash bin/create-gutenberge-test-post.sh
- go to the URL that is output in the command line
Please run these tests in an environment with WordPress unit tests installed, like VVV.
Run tests:
$ phpunit
Run tests with an HTML coverage report:
$ phpunit --coverage-html /tmp/report
When you push a commit to your PR, Travis CI will run the PHPUnit tests and sniffs against the WordPress Coding Standards.
Contributors who want to make a new release, follow these steps:
- Do
npm run build
and install theamp.zip
onto a normal WordPress install running a stable release build; do smoke test to ensure it works. - Bump plugin versions in
amp.php
(×2: the metadata block in the header and also theAMP__VERSION
constant). - Add changelog entry to readme.
- Draft blog post about the new release.
- Draft new release on GitHub targeting the release branch, with the new plugin version as the tag and release title. Attaching the
amp.zip
build to the release. Include link to changelog in release tag. - Run
npm run deploy
to to commit the plugin to WordPress.org. - Confirm the release is available on WordPress.org; try installing it on a WordPress install and confirm it works.
- Publish GitHub release.
- Create built release tag:
git fetch --tags && git checkout $(git tag | tail -n1) && ./bin/tag-built.sh
(then add link from release) - Merge release branch into
develop
. - Merge release tag into
master
. - Publish release blog post, including link to GitHub release.
- Close the GitHub milestone and project.
- Make announcements.