Skip to content

Commit d8449d1

Browse files
authored
Merge pull request #5 from tarosky/feature/deploy-script-renewal
Feature/deploy script renewal
2 parents 4127c9a + 99c69d6 commit d8449d1

File tree

10 files changed

+121
-103
lines changed

10 files changed

+121
-103
lines changed

Diff for: .eslintrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"Vue": false
1616
},
1717
"extends": [
18-
"plugin:@wordpress/eslint-plugin/recommended"
18+
"plugin:@wordpress/eslint-plugin/recommended-with-formatting"
1919
],
2020
"rules": {
2121
"no-alert": "off",

Diff for: .github/workflows/wordpress.yml

+67-55
Original file line numberDiff line numberDiff line change
@@ -2,65 +2,66 @@ name: Deploy Plugin
22

33
on:
44
push:
5-
branches:
6-
- main
75
tags:
86
- '*'
97
pull_request:
108
branches:
119
- main
1210

1311
jobs:
14-
test:
15-
runs-on: ${{ matrix.operating-system }}
16-
strategy:
17-
matrix:
18-
operating-system: [ ubuntu-18.04 ] # OS. ubuntu-18.04 is also available.
19-
php: [ '5.6', '7.2', '7.4' ] # PHP versions to check.
20-
wp: [ 'latest', '5.5' ] # WordPress version to check.
21-
services:
22-
mysql:
23-
image: mysql:5.7
24-
options: --health-cmd "mysqladmin ping --host 127.0.0.1 --port 3306" --health-interval 20s --health-timeout 10s --health-retries 10
25-
ports:
26-
- 3306/tcp
27-
env:
28-
MYSQL_ROOT_PASSWORD: root
29-
name: WordPress ${{ matrix.wp }} in PHP ${{ matrix.php }} UnitTest
30-
steps:
31-
- uses: actions/checkout@master
32-
33-
- name: Setup PHP
34-
uses: nanasess/setup-php@master
35-
with:
36-
php-version: ${{ matrix.php }}
37-
38-
- name: Validate composer.json and composer.lock
39-
run: composer validate
40-
41-
- name: Install dependencies
42-
run: composer install --prefer-dist --no-progress --no-suggest
43-
44-
- name: Start MySQL
45-
run: sudo systemctl start mysql
46-
47-
- name: Install WordPress
48-
run: bash bin/install-wp-tests.sh wordpress root root 127.0.0.1:3306 ${{ matrix.wp }}
49-
50-
- name: Check PHP Unit
51-
run: composer test
52-
53-
- name: Check PHP styntax
54-
run: composer lint
12+
# test:
13+
# runs-on: ${{ matrix.operating-system }}
14+
# strategy:
15+
# matrix:
16+
# operating-system: [ ubuntu-18.04 ] # OS. ubuntu-18.04 is also available.
17+
# php: [ '7.2', '7.4' ] # PHP versions to check.
18+
# wp: [ 'latest', '5.9' ] # WordPress version to check.
19+
# services:
20+
# mysql:
21+
# image: mysql:5.7
22+
# options: --health-cmd "mysqladmin ping --host 127.0.0.1 --port 3306" --health-interval 20s --health-timeout 10s --health-retries 10
23+
# ports:
24+
# - 3306/tcp
25+
# env:
26+
# MYSQL_ROOT_PASSWORD: root
27+
# name: WordPress ${{ matrix.wp }} in PHP ${{ matrix.php }} UnitTest
28+
# steps:
29+
# - uses: actions/checkout@master
30+
#
31+
# - name: Setup PHP
32+
# uses: nanasess/setup-php@master
33+
# with:
34+
# php-version: ${{ matrix.php }}
35+
#
36+
# - name: Validate composer.json and composer.lock
37+
# run: composer validate
38+
#
39+
# - name: Install dependencies
40+
# run: composer install --prefer-dist --no-progress --no-suggest
41+
#
42+
# - name: Start MySQL
43+
# run: sudo systemctl start mysql
44+
#
45+
# - name: Install WordPress
46+
# run: bash bin/install-wp-tests.sh wordpress root root 127.0.0.1:3306 ${{ matrix.wp }}
47+
#
48+
# - name: Check PHP Unit
49+
# run: composer test
50+
51+
lint:
52+
name: Check PHP styntax
53+
uses: tarosky/workflows/.github/workflows/phpcs.yml@main
54+
with:
55+
version: 7.4
5556

5657
assets:
5758
name: Check Assets
58-
runs-on: ubuntu-18.04
59+
runs-on: ubuntu-latest
5960
steps:
60-
- uses: actions/checkout@master
61+
- uses: actions/checkout@main
6162

6263
- name: Install Node
63-
uses: actions/setup-node@v1
64+
uses: actions/setup-node@v4
6465
with:
6566
node-version: '12'
6667

@@ -70,24 +71,36 @@ jobs:
7071
- name: Check JS & CSS syntax
7172
run: npm run lint
7273

74+
status-check:
75+
name: Status Check
76+
runs-on: ubuntu-latest
77+
if: always()
78+
needs: [ lint, assets ]
79+
steps:
80+
- uses: re-actors/alls-green@release/v1
81+
with:
82+
jobs: ${{ toJSON(needs) }}
83+
84+
7385
release:
7486
name: Deploy GitHub Release
75-
needs: [ test, assets ]
87+
needs: [ status-check ]
7688
if: contains(github.ref, 'tags/')
77-
runs-on: ubuntu-18.04
89+
runs-on: ubuntu-latest
7890
steps:
79-
- uses: actions/checkout@master
91+
- uses: actions/checkout@main
8092

81-
- name: Confirm
82-
run: echo ${{ needs.pre_release.outputs.upload_url }}
93+
- name: Install Subversion
94+
run: sudo apt-get install subversion
8395

8496
- name: Setup PHP
85-
uses: nanasess/setup-php@master
97+
uses: shivammathur/setup-php@v2
8698
with:
87-
php-version: '5.6'
99+
php-version: '7.4'
100+
tools: composer
88101

89102
- name: Install NPM
90-
uses: actions/setup-node@v1
103+
uses: actions/setup-node@v4
91104
with:
92105
node-version: '12'
93106

@@ -103,7 +116,6 @@ jobs:
103116
SVN_USERNAME: ${{ secrets.WP_ORG_USERNAME_TAROSKY }}
104117
SVN_PASSWORD: ${{ secrets.WP_ORG_PASSWORD_TAROSKY }}
105118

106-
107119
- name: Create Release
108120
id: pre_release
109121
uses: actions/[email protected]

Diff for: README.md

+9-4
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ Taro CPT Front
33

44
Contributors: tarosky,Takahashi_Fumiki
55
Tags: CPT
6-
Requires at least: 5.5.0
7-
Requires PHP: 5.6
8-
Tested up to: 5.8
6+
Requires at least: 5.9
7+
Requires PHP: 7.4
8+
Tested up to: 6.7
99
Stable Tag: nightly
1010
License: GPLv3 or later
1111
License URI: http://www.gnu.org/licenses/gpl-3.0.txt
@@ -38,6 +38,11 @@ Create new ticket at Support forum. Or else, create [new issue](https://github.c
3838

3939
## Changelog
4040

41+
### 1.1.0
42+
43+
* Bump required PHP version.
44+
* Fix small bugs.
45+
4146
### 1.0.0
4247

43-
* Initial release.
48+
* Initial release.

Diff for: composer.json

+10-11
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,8 @@
55
"license": "GPL-3.0-or-later",
66
"scripts": {
77
"test": "phpunit",
8-
"lint": [
9-
"phpcs --config-set installed_paths $(pwd)/vendor/wp-coding-standards/wpcs",
10-
"phpcs --standard=phpcs.ruleset.xml $(find ./ -name '*.php')"
11-
],
12-
"fix": [
13-
"phpcs --config-set installed_paths $(pwd)/vendor/wp-coding-standards/wpcs",
14-
"phpcbf --standard=phpcs.ruleset.xml $(find ./ -name '*.php')"
15-
]
8+
"lint": "phpcs --standard=phpcs.ruleset.xml $(find ./ -name '*.php')",
9+
"fix": "phpcbf --standard=phpcs.ruleset.xml $(find ./ -name '*.php')"
1610
},
1711
"authors": [
1812
{
@@ -21,12 +15,17 @@
2115
}
2216
],
2317
"require": {
24-
"php": "^5.6|^7.0"
18+
"php": ">=7.0"
2519
},
2620
"require-dev": {
27-
"phpunit/phpunit": "^5.7|^6",
21+
"phpunit/phpunit": ">=6",
2822
"squizlabs/php_codesniffer": "^3.0",
29-
"wp-coding-standards/wpcs": "^2.0",
23+
"wp-coding-standards/wpcs": "^3.0",
3024
"yoast/phpunit-polyfills": "^1.0"
25+
},
26+
"config": {
27+
"allow-plugins": {
28+
"dealerdirect/phpcodesniffer-composer-installer": true
29+
}
3130
}
3231
}

Diff for: includes/editor.php

+5-6
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* @param string[] $states States.
1212
* @param WP_Post $post Post object.
1313
*/
14-
add_filter( 'display_post_states', function( $states, $post ) {
14+
add_filter( 'display_post_states', function ( $states, $post ) {
1515
if ( ! ts_cptf_is_front( $post ) ) {
1616
return $states;
1717
}
@@ -22,7 +22,7 @@
2222
/**
2323
* Save pst dat.
2424
*/
25-
add_action( 'save_post', function( $post_id, $post ) {
25+
add_action( 'save_post', function ( $post_id, $post ) {
2626
if ( ! wp_verify_nonce( filter_input( INPUT_POST, '_tscptfnonce' ), 'tscptf_update' ) ) {
2727
return;
2828
}
@@ -31,19 +31,18 @@
3131
} else {
3232
delete_post_meta( $post_id, '_tscptf_is_front' );
3333
}
34-
3534
}, 10, 2 );
3635

3736
/**
3837
* Register meta box.
3938
*
4039
* @param string $post_type Post type.
4140
*/
42-
add_action( 'add_meta_boxes', function( $post_type ) {
41+
add_action( 'add_meta_boxes', function ( $post_type ) {
4342
if ( ! ts_cptf_available( $post_type ) ) {
4443
return;
4544
}
46-
add_meta_box( 'tscpf-is-front', __( 'Front Page Setting', 'tscptf' ), function( WP_Post $post ) {
45+
add_meta_box( 'tscpf-is-front', __( 'Front Page Setting', 'tscptf' ), function ( WP_Post $post ) {
4746
$front = ts_cptf_get_front_page( $post->post_type );
4847
if ( $front && $front->ID !== $post->ID ) {
4948
// Other page is front.
@@ -57,7 +56,7 @@
5756
} else {
5857
wp_nonce_field( 'tscptf_update', '_tscptfnonce', false );
5958
$is_front = $front ? 1 : 0;
60-
foreach ( [ __( 'Not a Front Page', 'tscptf' ), __( 'Set as a Front Page', 'tscptf' ) ] as $index => $label ) {
59+
foreach ( array( __( 'Not a Front Page', 'tscptf' ), __( 'Set as a Front Page', 'tscptf' ) ) as $index => $label ) {
6160
printf(
6261
'<p><label><input type="radio" value="%s" name="tscptf-is-front" %s /> %s</label></p>',
6362
esc_attr( $index ),

Diff for: includes/functions.php

+9-9
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ function ts_cptf_available( $post_type ) {
2222
* @return string[]
2323
*/
2424
function ts_cptf_post_types() {
25-
return (array) get_option( 'ts-cptf-post-types', [] );
25+
return (array) get_option( 'ts-cptf-post-types', array() );
2626
}
2727

2828
/**
@@ -46,19 +46,19 @@ function ts_cptf_is_front( $post = null ) {
4646
* @return WP_Post|null
4747
*/
4848
function ts_cptf_get_front_page( $post_type ) {
49-
$query = new WP_Query( [
49+
$query = new WP_Query( array(
5050
'post_type' => $post_type,
5151
'post_status' => 'any',
5252
'posts_per_page' => 1,
5353
'no_fround_rows' => true,
5454
'ignore_sticky' => true,
55-
'meta_query' => [
56-
[
55+
'meta_query' => array(
56+
array(
5757
'key' => '_tscptf_is_front',
5858
'value' => '1',
59-
],
60-
],
61-
] );
59+
),
60+
),
61+
) );
6262
foreach ( $query->posts as $post ) {
6363
return $post;
6464
}
@@ -75,9 +75,9 @@ function ts_cptf_post_type_struct( $post_type ) {
7575
global $wp_rewrite;
7676
$post_type_obj = get_post_type_object( $post_type );
7777
if ( ! $post_type_obj ) {
78-
return [];
78+
return array();
7979
}
80-
$struct = [ trim( $post_type_obj->rewrite['slug'], '/' ) ];
80+
$struct = array( trim( $post_type_obj->rewrite['slug'], '/' ) );
8181
if ( $post_type_obj->rewrite['with_front'] && ( '/' !== $wp_rewrite->front ) ) {
8282
array_unshift( $struct, trim( $wp_rewrite->front, '/' ) );
8383
}

Diff for: includes/rewrite.php

+9-9
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
/**
1010
* Filter permalink.
1111
*/
12-
add_filter( 'post_type_link', function( $link, $post ) {
12+
add_filter( 'post_type_link', function ( $link, $post ) {
1313
if ( ts_cptf_is_front( $post ) && get_option( 'rewrite_rules' ) ) {
1414
// This is front page.
1515
// Generate original pemalink.
@@ -24,7 +24,7 @@
2424
*
2525
* @aram string[] $vars Query vars.
2626
*/
27-
add_filter( 'query_vars', function( $vars ) {
27+
add_filter( 'query_vars', function ( $vars ) {
2828
$vars[] = 'root_of';
2929
return $vars;
3030
} );
@@ -35,8 +35,8 @@
3535
* @param string[] $rules Rewrite rules.
3636
* @return string[]
3737
*/
38-
add_filter( 'rewrite_rules_array', function( $rules ) {
39-
$new_rules = [];
38+
add_filter( 'rewrite_rules_array', function ( $rules ) {
39+
$new_rules = array();
4040
foreach ( ts_cptf_post_types() as $post_type ) {
4141
$struct = ts_cptf_post_type_struct( $post_type );
4242
if ( empty( $struct ) ) {
@@ -56,7 +56,7 @@
5656
*
5757
* @param WP_Query $wp_query Query object.
5858
*/
59-
add_action( 'pre_get_posts', function( $wp_query ) {
59+
add_action( 'pre_get_posts', function ( $wp_query ) {
6060
$is_front = $wp_query->get( 'root_of' );
6161
if ( ! $is_front ) {
6262
return;
@@ -65,11 +65,11 @@
6565
$wp_query->set( 'posts_per_page', 1 );
6666
$wp_query->set( 'no_found_rows', true );
6767
$wp_query->set( 'ignore_sticky', true );
68-
$wp_query->set( 'meta_query', [
69-
[
68+
$wp_query->set( 'meta_query', array(
69+
array(
7070
'key' => '_tscptf_is_front',
7171
'value' => '1',
72-
],
73-
] );
72+
),
73+
) );
7474
$wp_query->singular = true;
7575
} );

0 commit comments

Comments
 (0)