A free newsletter plugin for WordPress
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.circleci Use latest PHPStan Dec 10, 2018
.tx Bundle translations completed by 75%, remove PO files in build [MAILP… May 23, 2017
assets Merge pull request #1725 from mailpoet/webpack-upgrade Jan 15, 2019
generated Move container dump from application code to Robofile and to generate… Dec 12, 2018
lib Merge pull request #1648 from mailpoet/poll-success-send Jan 11, 2019
plugin_repository/assets Update second step in wizard Jan 9, 2019
prefixer Run composer for prefixed deps only if necessary Dec 3, 2018
tasks Add ability to register premium service as a dependency of free plugin Dec 12, 2018
tests Add size detection for images without specified size Jan 10, 2019
views Add workaround fix for Webpack 4 & Premium plugin Jan 14, 2019
.babelrc Upgrade Babel to v7 Dec 12, 2018
.env.sample Merge WP_ROOT and WP_TEST_PATH environment vars Nov 1, 2018
.eslintignore Move prefixed dependencies from lib/Dependencies to vendor-prefixed Nov 20, 2018
.eslintrc.es5.json Remove temporary eslint rules Apr 18, 2018
.eslintrc.es6.json Update to React 15.5 in preparation for code adjustments Oct 31, 2018
.eslintrc.tests.json Tests: padded-blocks Oct 25, 2017
.gitignore Add PHPStan build to .gitignore Dec 10, 2018
CONTRIBUTING.md Updating README and CONTRIBUTING Oct 9, 2018
Dockerfile Merge WP_ROOT and WP_TEST_PATH environment vars Nov 1, 2018
README.md Add ./do qa:phpstan to README Dec 10, 2018
RoboFile.php Move container dump from application code to Robofile and to generate… Dec 12, 2018
build.sh Move container dump from application code to Robofile and to generate… Dec 12, 2018
codeception.yml Unify Codeception configs Oct 29, 2018
composer.json Upgrade codeception and lucatume/wp-browser and minor deps versions Jan 3, 2019
composer.lock Upgrade codeception and lucatume/wp-browser and minor deps versions Jan 3, 2019
do ... added do command with ln -nsf flags Aug 18, 2015
docker-compose.yml Freeze mailhog to avoid problems in the future Oct 24, 2018
docker-entrypoint.sh Unify Codeception configs Oct 29, 2018
index.php First structure. Jul 9, 2015
license.txt Update license.txt, readme.txt and link to plugin's repo page Oct 19, 2016
mailpoet-cron.php Update the PHP version message Nov 27, 2018
mailpoet.php Release 3.18.0 Jan 15, 2019
mailpoet_initializer.php - Moves plugin initialization into a separate file that's included after Jan 23, 2017
package-lock.json Replace UglifyJS with Terser webpack plugin (new Webpack default) Jan 14, 2019
package.json Replace UglifyJS with Terser webpack plugin (new Webpack default) Jan 14, 2019
readme.txt Release 3.18.0 Jan 15, 2019
uninstall.php First structure. Jul 9, 2015
webpack.config.js Add comments to clarify some Webpack settings Jan 14, 2019

README.md

MailPoet

MailPoet done the right way.

Contents

Setup

Requirements

  • PHP 5.6+
  • NodeJS
  • WordPress
  • Docker & Docker Compose

Installation

# go to WP plugins directory
$ cd path_to_wp_directory/wp-content/plugins
# clone this repository
$ git clone https://github.com/mailpoet/mailpoet.git
$ cd mailpoet
# create the .env file
$ cp .env.sample .env
# change the values on .env file
# download composer
$ curl -sS https://getcomposer.org/installer | php
$ chmod +x ./composer.phar
# download a PHP-Scoper
$ curl -sL https://github.com/humbug/php-scoper/releases/download/0.11.4/php-scoper.phar --output php-scoper.phar
$ chmod +x ./php-scoper.phar
# install PHP dependencies
$ ./composer.phar install
# install all dependencies (PHP and JS)
$ ./do install
# compile JS and CSS files
$ ./do compile:all

Frameworks and libraries

Workflow Commands

$ ./do install             # install PHP and JS dependencies
$ ./do update              # update PHP and JS dependencies

$ ./do compile:css         # compiles Stylus files into CSS.
$ ./do compile:js          # bundles JS files for the browser.
$ ./do compile:all         # compiles CSS and JS files.

$ ./do watch:css           # watch CSS files for changes and compile them.
$ ./do watch:js            # watch JS files for changes and compile them.
$ ./do watch               # watch CSS and JS files for changes and compile them.

$ ./do test:unit [--file=...] [--debug]
  # runs the PHP unit tests.
  # if --file specified then only tests on that file are executed.
  # if --debug then tests are executed in debugging mode.
$ ./do test:integration [--file=...] [--multisite] [--debug]
  # runs the PHP integration tests.
  # if --file specified then only tests on that file are executed.
  # if --multisite then tests are executed in a multisite wordpress setup.
  # if --debug then tests are executed in debugging mode.
$ ./do test:multisite:integration # alias for ./do test:integration --multisite
$ ./do test:debug:unit            # alias for ./do test:unit --debug
$ ./do test:debug:integration     # alias for ./do test:integration --debug
$ ./do test:failed:unit           # run the last failing unit test.
$ ./do test:failed:integration    # run the last failing integration test.
$ ./do test:coverage              # run tests and output coverage information.
$ ./do test:javascript            # run the JS tests.
$ ./do test:acceptance [--file=...] [--skip-deps]
  # run acceptances tests into a docker environment.
  # if --file given then only tests on that file are executed.
  # if --skip-deps then it skips installation of composer dependencies.
$ ./do test:acceptance:multisite [--file=...] [--skip-deps]
  # same as test:acceptance but runs into a multisite wordpress setup.
$ ./do delete:docker      # stop and remove all running docker containers.

$ ./do qa:lint             # PHP code linter.
$ ./do qa:lint:javascript  # JS code linter.
$ ./do qa:phpstan          # PHP code static analysis using PHPStan.
$ ./do qa                  # PHP and JS linters.

$ ./do container:dump      # Generates DI container cache.

Coding and Testing

DI

We use Symfony/dependency-injection container. Container configuration can be found in libs/DI/ContainerFactory.php The container is configured and used with minimum sub-dependencies to keep final package size small. You can check the docs to learn more about Symfony Container.

PHP-Scoper

We use PHP-Scoper package to prevent plugin libraries conflicts in PHP. Two plugins may be using different versions of a library. PHP-Scoper prefix dependencies namespaces and they are then moved into vendor-prefixed directory. Dependencies handled by PHP-Scoper are configured in extra configuration files prefixer/composer.json and prefixer/scoper.inc.php. Installation and processing is triggered in post scripts of the main composer.json file.

i18n

We use functions __(), _n() and _x() with domain mailpoet to translate strings.

in PHP code

__('text to translate', 'mailpoet');
_n('single text', 'plural text', $number, 'mailpoet');
_x('text to translate', 'context for translators', 'mailpoet');

in Twig views

<%= __('text to translate') %>
<%= _n('single text', 'plural text', $number) %>
<%= _x('text to translate', 'context for translators') %>

The domain mailpoet will be added automatically by the Twig functions.

in Javascript code

First add the string to the translations block in the Twig view:

<% block translations %>
  <%= localize({
    'key': __('string to translate'),
    ...
  }) %>
<% endblock %>

Then use MailPoet.I18n.t('key') to get the translated string on your Javascript code.

Acceptance testing

We are using Gravity Flow plugin's setup as an example for our acceptance test suite: https://www.stevenhenty.com/learn-acceptance-testing-deeply/

From the article above:

Windows users only: enable hard drive sharing in the Docker settings.

The browser runs in a docker container. You can use a VNC client to watch the test run, follow instructions in official repo: https://github.com/SeleniumHQ/docker-selenium If you’re on a Mac, you can open vnc://localhost:5900 in Safari to watch the tests running in Chrome. If you’re on Windows, you’ll need a VNC client. Password: secret.