Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
ff8eeaa
Docs: Cleanup readme
GaryJones Mar 14, 2022
b0ad249
Merge pull request #121 from Automattic/fix/readme
GaryJones Mar 14, 2022
bc108f5
Docs: Rearrange sections, and further tidying
GaryJones Mar 14, 2022
4976f7b
Merge pull request #122 from Automattic/fix/readme
GaryJones Mar 14, 2022
095f98a
Deploy: Add workflow for pushing to WPORG
GaryJones Mar 14, 2022
21c3a29
Merge pull request #126 from Automattic/add/wporg-deploy
GaryJones Mar 14, 2022
bad1ad9
Composer: Update dependencies
GaryJones Mar 14, 2022
41652fc
Merge pull request #127 from Automattic/fix/composer-dependencies
GaryJones Mar 14, 2022
62142ca
Tests: Fix broken testing structure
GaryJones Mar 14, 2022
bb5c6e6
Tests workflow: Revise matrix
GaryJones Mar 14, 2022
1dac8b0
Lint: Refresh linting workflow
GaryJones Mar 14, 2022
6b37485
Merge pull request #128 from Automattic/fix/tests
GaryJones Mar 14, 2022
4323b7d
Bump min PHP and WP versions
GaryJones Mar 14, 2022
b23f005
Merge pull request #131 from Automattic/add/higher-min-versions
GaryJones Mar 14, 2022
b1ec158
Tests: Remove PHP 8.2 check
GaryJones Mar 14, 2022
2b5aea8
Merge pull request #132 from Automattic/remove/test-8.2
GaryJones Mar 14, 2022
8168f1d
Tests: Remove PHP 8.2 check
GaryJones Mar 14, 2022
44c39eb
Merge pull request #133 from Automattic/remove/test-8.2
GaryJones Mar 15, 2022
9c51981
Add escaping and improve code styles
christianc1 May 18, 2017
34b9bb2
Remove unnecessary escaping of constants and string literals
christianc1 May 18, 2017
0e893e3
Escape output
christianc1 May 18, 2017
03c28d3
Add escaping
christianc1 May 18, 2017
acb66e1
Add escaping
christianc1 May 18, 2017
5119b36
fix PHPCS errors in ad-code-manager.php
shantanu2704 Nov 2, 2018
a5c02dd
CS: Fix some issues
GaryJones Mar 15, 2022
9b188d8
Merge pull request #135 from Automattic/fix/coding-standards
GaryJones Mar 15, 2022
4bcec10
Allow filtering the TTL for matching ad codes (#111)
dlh01 Mar 15, 2022
49592f1
Extract Ad_Code_Manager class to own file
GaryJones Mar 15, 2022
6e04530
Simplify defined constants
GaryJones Mar 15, 2022
7fd4ed7
Move views directory to top level
GaryJones Mar 15, 2022
77e118b
Move Providers files into src directory
GaryJones Mar 15, 2022
00f4602
Move other PHP files into src directory
GaryJones Mar 15, 2022
d70e003
Move CSS and JS files out of deep directories
GaryJones Mar 15, 2022
b1d6b81
Update coverage directories for PHPUnit
GaryJones Mar 15, 2022
3940c2c
Change how main plugin class is initialized
GaryJones Mar 15, 2022
e79e729
Update main plugin file
GaryJones Mar 15, 2022
0de97ec
Merge pull request #137 from Automattic/fix/code-structure
GaryJones Mar 15, 2022
9c37ec3
Add banner image from WPORG
GaryJones Mar 15, 2022
1a44d69
Merge pull request #138 from Automattic/add/banner
GaryJones Mar 15, 2022
1a6231a
Merge pull request #139 from Automattic/fix/code-structure
GaryJones Mar 15, 2022
60ed0ee
Check post type of the received post ID before deletion
rbcorrales Mar 15, 2022
db95d6d
Add test to show that can't delete non-ad via ID
GaryJones Mar 15, 2022
d93fac9
Merge pull request #140 from Automattic/add-delete-guard
GaryJones Mar 15, 2022
a51856b
Fix: Bulk deletes not working
GaryJones Mar 15, 2022
2c47e0a
Merge pull request #141 from Automattic/fix/bulk-delete
GaryJones Mar 15, 2022
0b640f9
Create LICENSE
GaryJones Mar 15, 2022
134430d
Merge pull request #142 from Automattic/add-license-1
GaryJones Mar 15, 2022
fab7e15
Create dependabot.yml
GaryJones Mar 15, 2022
817d678
Merge pull request #143 from Automattic/add/dependabot
GaryJones Mar 15, 2022
81837db
Add .gitattributes file
GaryJones Mar 15, 2022
edb2be7
Merge pull request #144 from Automattic/add/gitattributes-file
GaryJones Mar 15, 2022
a7ca897
Fix dependabot config
GaryJones Mar 15, 2022
0509c11
Merge pull request #145 from Automattic/fix/dependabot-config
GaryJones Mar 15, 2022
d29ac79
CS: Fix auto-fixable errors
GaryJones Mar 16, 2022
88532f3
Merge pull request #146 from Automattic/fix/auto-fixable-cs
GaryJones Mar 16, 2022
77dae01
Fix untranslatable strings
GaryJones Mar 16, 2022
b7fd8b7
Merge pull request #147 from Automattic/fix/untranslatable-strings
GaryJones Mar 16, 2022
6427b4c
Move settings page
GaryJones Mar 17, 2022
6933be5
Merge pull request #148 from Automattic/move-settings-page
GaryJones Mar 17, 2022
55789d0
Add link to settings page on plugin page
GaryJones Mar 17, 2022
6446cfb
Merge pull request #149 from Automattic/add/settings-page-link
GaryJones Mar 17, 2022
374913f
Refactor action_acm_tag()
GaryJones Mar 17, 2022
a992f5a
Merge pull request #150 from Automattic/fix/refactor-action_acm_tag
GaryJones Mar 17, 2022
dd8861e
Refresh contextual help
GaryJones Mar 18, 2022
1248ce1
Merge pull request #151 from Automattic/fix/contextual-help
GaryJones Mar 18, 2022
d37569d
Refresh screenshots
GaryJones Mar 18, 2022
83bbac2
Merge pull request #152 from Automattic/fix/screenshots
GaryJones Mar 18, 2022
9cadcfd
Automate changelog from release notes
GaryJones Mar 18, 2022
5eff559
Merge pull request #153 from Automattic/experiement/changelog
GaryJones Mar 18, 2022
fbece2d
Add script to bump version numbers
GaryJones Mar 18, 2022
8274133
Update readme.md to README.md
GaryJones Mar 18, 2022
851a32b
Merge pull request #154 from Automattic/add/version-bump
GaryJones Mar 18, 2022
93e3d37
Version 0.6.0.
GaryJones Mar 18, 2022
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
25 changes: 25 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Exclude these files from release archives.

# This will also make them unavailable when using Composer with `--prefer-dist`.

# If you develop for this package using Composer, use `--prefer-source`.
# https://www.reddit.com/r/PHP/comments/2jzp6k/i_dont_need_your_tests_in_my_production
# https://blog.madewithlove.be/post/gitattributes/

# They are also used when pushing to WordPress.org SVN using the
# https://github.com/10up/action-wordpress-plugin-deploy GitHub Action.

# Directories
/.github export-ignore
/.wordpress-org export-ignore
/bin export-ignore
/tests export-ignore

# Files
/.editorconfig export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
/.phpcs.xml.dist export-ignore
/CHANGELOG.md export-ignore
/composer.json export-ignore
/phpunit.xml.dist export-ignore
19 changes: 19 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:

# Maintain dependencies for GitHub Actions
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"

# Maintain dependencies for Composer
- package-ecosystem: "composer"
directory: "/"
schedule:
interval: "daily"
52 changes: 52 additions & 0 deletions .github/workflows/changelog.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// Replaces the `<!-- changelog -->` comment in the README.md with the release notes from GitHub.
// Usage locally:
// TOKEN=... GITHUB_REPOSITORY='Automattic/ad-code-manager' node .github/workflows/changelog.js
// Where TOKEN is a personal GitHub token that has access to the repo: https://github.com/settings/tokens
// In a GitHub Workflow, TOKEN can be passed the special ${{ secrets.GITHUB_TOKEN }} token.

const github = require('@actions/github');
const semver = require('semver');
const replace = require('replace-in-file');

const filename = process.argv[2] || 'README.md';
const myToken = process.env.TOKEN;

async function run() {
const api = new github.GitHub(myToken);

const { data: releases } = await api.repos.listReleases( github.context.repo );

let published = releases.filter( release =>
! release.draft && ! release.prerelease
);

let sorted = published.sort( ( a, b ) =>
semver.rcompare( semver.coerce( a.tag_name ), semver.coerce( b.tag_name ) )
);

let changelog = sorted.reduce( ( changelog, release ) =>
`${changelog}

### ${release.tag_name}

${release.body}`
, '## Changelog' );

try {
const results = await replace( {
files: filename,
from: '<!-- changelog -->',
to: changelog,
} );

if ( results.filter( result => ! result.hasChanged ).length ) {
console.error( 'No replacements made' );
process.exitCode = 1;
}
} catch( exception ) {
console.error( exception );
process.exitCode = 1;
}
}

run();
49 changes: 28 additions & 21 deletions .github/workflows/cs-lint.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: CS & Lint
name: Lint PHP & XML

on:
# Run on all pushes and on all pull requests.
Expand All @@ -7,22 +7,34 @@ on:
paths-ignore:
- "**.md"
pull_request:

# Allow manually triggering the workflow.
workflow_dispatch:

jobs:
checkcs:
name: "Basic CS and QA checks"
name: Lint checks for PHP ${{ matrix.php }}
runs-on: ubuntu-latest

env:
XMLLINT_INDENT: " "

strategy:
matrix:
php: ['7.1', '8.1']
experimental: [false]
include:
- php: '8.2'
experimental: true
fail-fast: false

continue-on-error: ${{ matrix.experimental }}

steps:
- name: Setup PHP
- name: Setup PHP ${{ matrix.php }}
uses: shivammathur/setup-php@v2
with:
php-version: "7.4"
php-version: ${{ matrix.php }}
coverage: none
tools: cs2pr

Expand All @@ -37,34 +49,29 @@ jobs:
uses: korelstar/xmllint-problem-matcher@v1

- name: Checkout code
uses: actions/checkout@v2

# Validate the composer.json file.
# @link https://getcomposer.org/doc/03-cli.md#validate
- name: Validate Composer installation
run: composer validate --no-check-all
uses: actions/checkout@v3

# Install dependencies and handle caching in one go.
# @link https://github.com/marketplace/actions/install-composer-dependencies
# @link https://github.com/marketplace/actions/install-php-dependencies-with-composer
- name: Install Composer dependencies
uses: ramsey/composer-install@v1
if: ${{ matrix.php < 8.2 }}
uses: ramsey/composer-install@v2

- name: Install Composer dependencies for PHP >= 8.2
if: ${{ matrix.php >= 8.2 }}
uses: ramsey/composer-install@v2
with:
composer-options: --ignore-platform-reqs

# Lint PHP.
- name: Lint PHP against parse errors
run: composer lint-ci | cs2pr
run: composer lint-ci --no-interaction | cs2pr

# Needed as runs-on: system doesn't have xml-lint by default.
# @link https://github.com/marketplace/actions/xml-lint
- name: Lint phpunit.xml.dist
if: ${{ matrix.php >= 7.3 }}
uses: ChristophWurst/xmllint-action@v1
with:
xml-file: ./phpunit.xml.dist
xml-schema-file: ./vendor/phpunit/phpunit/phpunit.xsd

# Check the code-style consistency of the PHP files.
# - name: Check PHP code style
# continue-on-error: true
# run: vendor/bin/phpcs --report-full --report-checkstyle=./phpcs-report.xml

# - name: Show PHPCS results in PR
# run: cs2pr ./phpcs-report.xml
29 changes: 29 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Deploy to WordPress.org
on:
release:
types: [released]
jobs:
tag:
name: New tag
runs-on: ubuntu-20.04
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Configure NPM cache
uses: c-hive/gha-npm-cache@v1

- name: Install Dependencies
run: npm install

- name: Populate Changelog
run: node .github/workflows/changelog.js
env:
TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: WordPress Plugin Deploy
uses: 10up/action-wordpress-plugin-deploy@stable
env:
SVN_PASSWORD: ${{ secrets.SVN_PASSWORD }}
SVN_USERNAME: ${{ secrets.SVN_USERNAME }}
SLUG: ad-code-manager
74 changes: 36 additions & 38 deletions .github/workflows/integrations.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,79 +7,77 @@ on:
paths-ignore:
- "**.md"
pull_request:

# Allow manually triggering the workflow.
workflow_dispatch:

jobs:
test:
name: WP ${{ matrix.wordpress }} on PHP ${{ matrix.php }}
# Ubuntu-20.x includes MySQL 8.0, which causes `caching_sha2_password` issues with PHP < 7.4
# https://www.php.net/manual/en/mysqli.requirements.php
# TODO: change to ubuntu-latest when we no longer support PHP < 7.4
runs-on: ubuntu-18.04
runs-on: ubuntu-20.04

env:
WP_VERSION: ${{ matrix.wordpress }}

strategy:
# PHP 7.1 uses PHPUnit 7.5.20
# PHP 7.2 uses PHPUnit 8.5.21
# PHP 7.3 uses PHPUnit 9.5.10
# PHP 7.4 uses PHPUnit 9.5.10
# PHP 8.0 uses PHPUnit 9.5.10
# PHP 8.1 uses PHPUnit 9.5.10
# PHP 8.2 uses PHPUnit 9.5.10
# Key:
# - coverage: Whether to run the tests with code coverage.
# - experimental: Whether the build is "allowed to fail".
matrix:
wordpress: ["5.5", "5.6", "5.7"]
php: ["5.6", "7.0", "7.1", "7.2", "7.3", "7.4"]
php: ['7.2', '7.3', '7.4', '8.0', '8.1']
wordpress: ['5.5', '5.6', '5.7', '5.8', '5.9']
experimental: [false]
coverage: [none]
include:
- php: "8.0"
# Ignore platform requirements, so that PHPUnit 7.5 can be installed on PHP 8.0 (and above).
composer-options: "--ignore-platform-reqs"
extensions: pcov
ini-values: pcov.directory=., "pcov.exclude=\"~(vendor|tests)~\""
coverage: pcov
exclude:
- php: "8.0"
wordpress: "5.5"
- php: '7.1'
wordpress: '5.8.3'
experimental: false
coverage: none
fail-fast: false

continue-on-error: ${{ matrix.experimental }}
steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Setup PHP ${{ matrix.php }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: ${{ matrix.extensions }}
ini-values: ${{ matrix.ini-values }}
coverage: ${{ matrix.coverage }}

- name: Setup problem matchers for PHP
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"

# Setup PCOV since we're using PHPUnit < 8 which has it integrated. Requires PHP 7.1.
# Ignore platform reqs to make it install on PHP 8.
# https://github.com/krakjoe/pcov-clobber
- name: Setup PCOV
if: ${{ matrix.php == 8.0 }}
run: |
composer require pcov/clobber --ignore-platform-reqs
vendor/bin/pcov clobber

- name: Setup Problem Matchers for PHPUnit
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"

- name: Install Composer dependencies
uses: ramsey/composer-install@v1
if: ${{ matrix.php < 8.2 }}
uses: ramsey/composer-install@v2

- name: Install Composer dependencies for PHP >= 8.2
if: ${{ matrix.php >= 8.2 }}
uses: ramsey/composer-install@v2
with:
composer-options: "${{ matrix.composer-options }}"
composer-options: --ignore-platform-reqs

- name: Start MySQL Service
run: sudo systemctl start mysql.service

- name: Setting mysql_native_password for PHP <= 7.3
if: ${{ matrix.php <= 7.3 }}
run: mysql -u root -proot -e "ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'root';"

- name: Prepare environment for integration tests
run: composer prepare-ci
run: composer prepare-ci --no-interaction

- name: Run integration tests (single site)
if: ${{ matrix.php != 8.0 }}
run: composer test
- name: Run integration tests (single site with code coverage)
if: ${{ matrix.php == 8.0 }}
run: composer coverage-ci
- name: Run integration tests (multisite)
run: composer test-ms
- name: Run integration tests
run: composer test --no-interaction
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
composer.lock
/.phpunit.result.cache
/composer.lock
/package-lock.json
/vendor
8 changes: 7 additions & 1 deletion .phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<rule ref="PHPCompatibilityWP"/>
<!-- For help in understanding this testVersion:
https://github.com/PHPCompatibility/PHPCompatibility#sniffing-your-code-for-compatibility-with-specific-php-versions -->
<config name="testVersion" value="5.6-"/>
<config name="testVersion" value="7.1-"/>

<!-- Rules: WordPress Coding Standards - see
https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards -->
Expand All @@ -49,6 +49,8 @@
<properties>
<property name="prefixes" type="array">
<element value="ad_code_manager"/>
<element value="acm"/>
<element value="Automattic\AdCodeManager"/>
</property>
</properties>
</rule>
Expand All @@ -67,4 +69,8 @@
</properties>
</rule>

<rule ref="WordPress.Files.FileName">
<exclude-pattern>tests/</exclude-pattern>
</rule>

</ruleset>
Binary file added .wordpress-org/banner-772x250.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed .wordpress-org/screenshot-1.jpg
Binary file not shown.
Binary file added .wordpress-org/screenshot-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed .wordpress-org/screenshot-2.jpg
Binary file not shown.
Binary file added .wordpress-org/screenshot-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed .wordpress-org/screenshot-3.jpg
Binary file not shown.
Binary file added .wordpress-org/screenshot-3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified .wordpress-org/screenshot-4.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed .wordpress-org/screenshot-5.jpg
Binary file not shown.
Loading