Skip to content

Commit 4f2e54b

Browse files
committed
Merge branch 'develop' of ssh://github.com/johnbillion/extended-cpts into develop
2 parents 850cdc9 + d6d83bb commit 4f2e54b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+2153
-1594
lines changed

.editorconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ trim_trailing_whitespace = true
1111
[*.md]
1212
trim_trailing_whitespace = false
1313

14-
[{*.json,*.yml}]
14+
[*.yml]
1515
indent_style = space
1616
indent_size = 2

.gitattributes

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
/.editorconfig export-ignore
99
/.gitattributes export-ignore
1010
/.gitignore export-ignore
11+
/codeception.dist.yml export-ignore
1112
/CONTRIBUTING.md export-ignore
1213
/phpcs.xml.dist export-ignore
13-
/phpunit.xml.dist export-ignore
14+
/phpstan.neon.dist export-ignore

.github/workflows/test-nightly.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Test Nightly
2+
on:
3+
# Once weekly on Wednesdays at 02:00 UTC.
4+
schedule:
5+
- cron: '0 2 * * 3'
6+
workflow_dispatch:
7+
8+
jobs:
9+
build:
10+
strategy:
11+
matrix:
12+
php: ['8.1','8.0','7.4']
13+
fail-fast: false
14+
name: WP nightly / PHP ${{ matrix.php }}
15+
runs-on: ubuntu-18.04
16+
steps:
17+
- name: Checkout repository
18+
uses: actions/checkout@v2
19+
20+
- name: Install PHP
21+
uses: shivammathur/[email protected]
22+
with:
23+
php-version: ${{ matrix.php }}
24+
extensions: mysqli, xmlwriter
25+
coverage: none
26+
27+
- name: Install dependencies
28+
run: |
29+
sudo systemctl start mysql.service
30+
composer install --prefer-dist
31+
composer require --dev --update-with-dependencies --prefer-dist roots/wordpress="dev-nightly"
32+
mysqladmin -uroot -proot create wordpress_test
33+
34+
- name: Run the tests
35+
run: composer test

.github/workflows/test.yml

Lines changed: 32 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,30 @@
11
name: Test
2-
on: [push, pull_request]
2+
on:
3+
push:
4+
branches:
5+
- 'develop'
6+
- 'trunk'
7+
pull_request:
8+
branches:
9+
- '**'
310

411
jobs:
512
build:
6-
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
713
strategy:
814
matrix:
9-
php: ['7.4', '7.0']
10-
wp: ['4.9', '*', 'dev-nightly']
15+
php: ['7.4']
16+
wp: ['5.8','5.6']
17+
include:
18+
- php: '8.0'
19+
wp: '5.8'
20+
- php: '8.1'
21+
wp: '5.8'
1122
fail-fast: false
1223
name: WP ${{ matrix.wp }} / PHP ${{ matrix.php }}
1324
runs-on: ubuntu-18.04
14-
services:
15-
mysql:
16-
image: mysql:5.7
17-
env:
18-
MYSQL_DATABASE: wordpress
19-
MYSQL_ALLOW_EMPTY_PASSWORD: yes
20-
ports:
21-
- 3306
22-
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
2325
steps:
2426
- name: Checkout repository
25-
uses: actions/checkout@v1
27+
uses: actions/checkout@v2
2628

2729
- name: Composer cache
2830
uses: actions/cache@v1
@@ -32,8 +34,9 @@ jobs:
3234
path: ~/.composer/cache
3335
key: ${{ matrix.php }}-${{ env.cache-name }}-${{ hashFiles('composer.json') }}
3436

35-
- name: PHPCS cache
36-
uses: actions/cache@v1
37+
- name: PHPCS and PHPStan cache
38+
if: matrix.php == '7.4'
39+
uses: actions/cache@v2
3740
env:
3841
cache-name: phpcs
3942
with:
@@ -55,13 +58,20 @@ jobs:
5558
php --version
5659
php -m
5760
composer --version
61+
mysql --version
5862
5963
- name: Install dependencies
6064
run: |
61-
composer install --prefer-dist --no-suggest
62-
composer require --dev --update-with-dependencies --no-suggest --prefer-dist roots/wordpress="${{ matrix.wp }} || *" wp-phpunit/wp-phpunit="${{ matrix.wp }} || *"
65+
sudo systemctl start mysql.service
66+
composer install --prefer-dist
67+
composer require --dev --update-with-dependencies --prefer-dist roots/wordpress="~${{ matrix.wp }}.0"
68+
mysqladmin -uroot -proot create wordpress_test
6369
64-
- name: Run the tests
65-
run: composer test
66-
env:
67-
WP_TESTS_DB_HOST: 127.0.0.1:${{ job.services.mysql.ports['3306'] }}
70+
- name: Run the integration tests
71+
run: composer test:integration
72+
73+
- name: Run the code sniffers
74+
if: matrix.php == '7.4'
75+
run: |
76+
composer test:cs
77+
composer test:analyze

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1+
/codeception.yml
12
/composer.lock
23
/phpcs.xml
3-
/phpunit.xml
4+
/phpstan.neon
5+
/tests/_output/
6+
/tests/_support/_generated
47
/tests/.env
58
/tests/cache
69
/tests/wordpress

README.md

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
[![Build Status](https://img.shields.io/github/workflow/status/johnbillion/extended-cpts/Test/develop?style=flat-square)](https://github.com/johnbillion/extended-cpts/actions)
2-
[![Stable Release](https://img.shields.io/packagist/v/johnbillion/extended-cpts.svg)](https://packagist.org/packages/johnbillion/extended-cpts)
3-
[![License](https://img.shields.io/badge/license-GPL_v2%2B-blue.svg)](https://github.com/johnbillion/extended-cpts/blob/master/LICENSE)
4-
[![PHP 7](https://img.shields.io/badge/php-7%20/%208-blue.svg)](https://wordpress.org/support/update-php/)
5-
[![Documentation](https://img.shields.io/badge/documentation-wiki-blue.svg)](https://github.com/johnbillion/extended-cpts/wiki)
2+
[![Stable Release](https://img.shields.io/packagist/v/johnbillion/extended-cpts.svg?style=flat-square)](https://packagist.org/packages/johnbillion/extended-cpts)
3+
[![License](https://img.shields.io/badge/license-GPL_v2%2B-blue.svg?style=flat-square)](https://github.com/johnbillion/extended-cpts/blob/trunk/LICENSE)
4+
[![PHP 7 and 8](https://img.shields.io/badge/php-7%20/%208-blue.svg?style=flat-square)](https://wordpress.org/support/update-php/)
5+
[![Documentation](https://img.shields.io/badge/documentation-wiki-blue.svg?style=flat-square)](https://github.com/johnbillion/extended-cpts/wiki)
66

77
# Extended CPTs #
88

@@ -59,11 +59,12 @@ Not your first time here? See [Recent Changes for Developers](https://github.com
5959

6060
## Minimum Requirements ##
6161

62-
* **PHP:** 7.0
63-
- PHP 7.4+ is recommended
64-
- PHP 8 is supported
65-
* **WordPress:** 4.8
66-
- Tested up to WP 5.6
62+
* **PHP:** 7.4
63+
- PHP 8.0 and 8.1 are supported
64+
* **WordPress:** 5.6
65+
- Tested up to WP 5.8
66+
67+
Extended CPTs should work with versions of WordPress back to 4.9 but these versions are not tested and not officially supported.
6768

6869
## Installation ##
6970

@@ -75,8 +76,6 @@ composer require johnbillion/extended-cpts
7576

7677
Other means of installation or usage, particularly bundling within a plugin, is not officially supported and done at your own risk.
7778

78-
Note that *Extended Taxonomies* is part of this library since version 4.0, so there's no need to require that too.
79-
8079
## Usage ##
8180

8281
Need a simple post type with no frills? You can register a post type with a single parameter:
@@ -111,9 +110,6 @@ add_action( 'init', function() {
111110
'nopaging' => true,
112111
],
113112

114-
# Add the post type to the 'Recently Published' section of the dashboard:
115-
'dashboard_activity' => true,
116-
117113
# Add some custom columns to the admin screen:
118114
'admin_cols' => [
119115
'story_featured_image' => [

codeception.dist.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
paths:
2+
tests: tests
3+
output: tests/_output
4+
data: tests/_data
5+
support: tests/_support
6+
envs: tests/_envs
7+
actor_suffix: Tester
8+
extensions:
9+
enabled:
10+
- Codeception\Extension\RunFailed
11+
params:
12+
- tests/.env

composer.json

Lines changed: 39 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,49 +11,71 @@
1111
],
1212
"config": {
1313
"sort-packages": true,
14-
"preferred-install": "dist"
14+
"preferred-install": "dist",
15+
"allow-plugins": {
16+
"cweagans/composer-patches": true,
17+
"dealerdirect/phpcodesniffer-composer-installer": true,
18+
"roots/wordpress-core-installer": true
19+
}
1520
},
1621
"extra": {
22+
"branch-alias": {
23+
"dev-develop": "5.0-dev"
24+
},
25+
"patches": {
26+
"lucatume/wp-browser": {
27+
"https://github.com/lucatume/wp-browser/issues/554": "tests/patches/wp-browser-554.patch"
28+
}
29+
},
1730
"wordpress-install-dir": "tests/wordpress"
1831
},
1932
"require": {
20-
"php": "^7 | ^8"
33+
"php": ">= 7.4.0",
34+
"johnbillion/args": "^0.9.0"
2135
},
2236
"require-dev": {
23-
"automattic/phpcs-neutron-standard": "1.6.0",
37+
"automattic/phpcs-neutron-standard": "1.7.0",
38+
"cweagans/composer-patches": "^1.7",
2439
"dealerdirect/phpcodesniffer-composer-installer": "^0.7",
25-
"johnbillion/falsey-assertequals-detector": "^2",
40+
"johnbillion/falsey-assertequals-detector": "*",
41+
"lucatume/wp-browser": "^3.0",
2642
"phpcompatibility/phpcompatibility-wp": "^2",
27-
"phpunit/phpunit": "^6",
28-
"roots/wordpress": "*",
43+
"phpstan/phpstan": "^1.0",
44+
"phpstan/phpstan-phpunit": "^1.0",
45+
"phpunit/phpunit": "^9",
46+
"roots/wordpress": "^5.8.0",
47+
"szepeviktor/phpstan-wordpress": "^1.0",
2948
"vlucas/phpdotenv": "^3",
30-
"wp-cli/db-command": "^2.0",
31-
"wp-coding-standards/wpcs": "2.3.0",
32-
"wp-phpunit/wp-phpunit": "*"
49+
"wp-cli/core-command": "^2",
50+
"wp-cli/db-command": "^2",
51+
"wp-coding-standards/wpcs": "2.3.0"
3352
},
3453
"scripts": {
3554
"post-update-cmd": [
3655
"@php -r \"! file_exists( 'tests/.env' ) && copy( 'tests/.env.dist', 'tests/.env' );\""
3756
],
3857
"test:cs": [
39-
"vendor/bin/phpcs -nps --colors --report-code --report-summary --report-width=80 --cache=tests/cache/phpcs ."
58+
"phpcs -nps --colors --report-code --report-summary --report-width=80 --cache=tests/cache/phpcs --basepath='./' ."
59+
],
60+
"test:analyze": [
61+
"phpstan analyze"
4062
],
41-
"test:ut": [
42-
"vendor/bin/wp db reset --yes --path=tests/wordpress #",
43-
"export WP_MULTISITE=0 && vendor/bin/phpunit --verbose --colors=always --exclude-group=ms-required",
44-
"export WP_MULTISITE=1 && vendor/bin/phpunit --verbose --colors=always --exclude-group=ms-excluded"
63+
"test:integration": [
64+
"codecept run integration"
4565
],
4666
"test": [
4767
"@test:cs",
48-
"@test:ut"
68+
"@test:analyze",
69+
"@test:integration"
4970
]
5071
},
5172
"autoload": {
5273
"psr-4": {
53-
"ExtCPTs\\Tests\\": "tests/phpunit"
74+
"ExtCPTs\\": "src",
75+
"ExtCPTs\\Tests\\": "tests/integration"
5476
},
5577
"files": [
56-
"extended-cpts.php"
78+
"functions.php"
5779
]
5880
},
5981
"suggest": {

extended-cpts.php

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
declare( strict_types=1 );
33

44
/**
5-
* Extended custom post types for WordPress.
5+
* Extended custom post types and taxonomies for WordPress.
66
*
77
* @package ExtendedCPTs
88
* @author John Blackbourn <https://johnblackbourn.com>
99
* @link https://github.com/johnbillion/extended-cpts
10-
* @copyright 2012-2021 John Blackbourn
10+
* @copyright 2012-2022 John Blackbourn
1111
* @license GPL v2 or later
12-
* @version 4.5.1
12+
* @version 5.0.1
1313
*
1414
* This program is free software; you can redistribute it and/or modify
1515
* it under the terms of the GNU General Public License as published by
@@ -23,7 +23,10 @@
2323
*/
2424

2525
require_once __DIR__ . '/functions.php';
26-
require_once __DIR__ . '/src/class-extended-cpt.php';
27-
require_once __DIR__ . '/src/class-extended-cpt-admin.php';
28-
require_once __DIR__ . '/src/class-extended-taxonomy.php';
29-
require_once __DIR__ . '/src/class-extended-taxonomy-admin.php';
26+
require_once __DIR__ . '/src/PostType.php';
27+
require_once __DIR__ . '/src/PostTypeAdmin.php';
28+
require_once __DIR__ . '/src/Taxonomy.php';
29+
require_once __DIR__ . '/src/TaxonomyAdmin.php';
30+
require_once __DIR__ . '/src/Walker/Checkboxes.php';
31+
require_once __DIR__ . '/src/Walker/Dropdown.php';
32+
require_once __DIR__ . '/src/Walker/Radios.php';

0 commit comments

Comments
 (0)