Skip to content

Commit 023ad6f

Browse files
authored
Merge pull request #3 from tarosky/update-wp-6-5
Remove withState and bump supporting version of WP and PHP
2 parents 387b57a + 3d5f31f commit 023ad6f

File tree

10 files changed

+14191
-56
lines changed

10 files changed

+14191
-56
lines changed

.eslintrc

+2-6
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,10 @@
88
"wp": false,
99
"jQuery": false,
1010
"angular": false,
11-
"Hametuha": true,
12-
"wpApiSettings": false,
13-
"ga": false,
14-
"Hashboard": true,
15-
"Vue": false
11+
"wpApiSettings": false
1612
},
1713
"extends": [
18-
"plugin:@wordpress/eslint-plugin/recommended"
14+
"plugin:@wordpress/eslint-plugin/recommended-with-formatting"
1915
],
2016
"rules": {
2117
"no-alert": "off",

.github/workflows/wordpress.yml

+39-21
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,15 @@ on:
88
- '*'
99
pull_request:
1010
branches:
11-
- master
11+
- main
1212

1313
jobs:
1414
test:
15-
runs-on: ${{ matrix.operating-system }}
15+
runs-on: ubuntu-latest
1616
strategy:
1717
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.4' ] # WordPress version to check.
18+
php: [ '7.2', '7.4', '8.0' ] # PHP versions to check.
19+
wp: [ 'latest', '5.9' ] # WordPress version to check.
2120
services:
2221
mysql:
2322
image: mysql:5.7
@@ -28,12 +27,15 @@ jobs:
2827
MYSQL_ROOT_PASSWORD: root
2928
name: WordPress ${{ matrix.wp }} in PHP ${{ matrix.php }} UnitTest
3029
steps:
31-
- uses: actions/checkout@master
30+
- uses: actions/checkout@main
3231

33-
- name: Setup PHP
34-
uses: nanasess/setup-php@master
32+
- name: Setup PHP with composer v2
33+
uses: shivammathur/setup-php@v2
3534
with:
3635
php-version: ${{ matrix.php }}
36+
tools: composer
37+
env:
38+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3739

3840
- name: Validate composer.json and composer.lock
3941
run: composer validate
@@ -47,38 +49,54 @@ jobs:
4749
- name: Install WordPress
4850
run: bash bin/install-wp-tests.sh wordpress root root 127.0.0.1:3306 ${{ matrix.wp }}
4951

52+
- name: Check PHP syntax
53+
run: composer test
54+
55+
lint:
56+
name: Check JS & CSS syntax
57+
runs-on: ubuntu-latest
58+
steps:
59+
- uses: actions/checkout@main
60+
5061
- name: Install Node
51-
uses: actions/setup-node@v1
62+
uses: actions/setup-node@v3
5263
with:
53-
node-version: '12'
64+
node-version: '14'
5465

5566
- name: Install NPM Packages
5667
run: npm install
5768

58-
- name: Check PHP syntax
59-
run: composer test
60-
6169
- name: Check JS & CSS syntax
6270
run: npm run lint
6371

72+
status-check:
73+
name: Status Check
74+
runs-on: ubuntu-latest
75+
needs: [ lint, test ]
76+
steps:
77+
- run: echo "Status Check"
78+
6479
release:
6580
name: Deploy WordPress.org
66-
needs: test
81+
needs: status-check
6782
if: contains(github.ref, 'tags/')
68-
runs-on: ubuntu-18.04
83+
runs-on: ubuntu-latest
6984
steps:
7085
- name: Checkout code
71-
uses: actions/checkout@v2
86+
uses: actions/checkout@main
7287

73-
- name: Setup PHP
74-
uses: nanasess/setup-php@master
88+
- name: Setup PHP with composer v2
89+
uses: shivammathur/setup-php@v2
7590
with:
76-
php-version: 5.6
91+
php-version: 7.2
92+
tools: composer
93+
env:
94+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
7795

7896
- name: Install Node
79-
uses: actions/setup-node@v1
97+
uses: actions/setup-node@v3
8098
with:
81-
node-version: '12'
99+
node-version: '14'
82100

83101
- name: Build Plugin
84102
run: bash bin/build.sh ${{ github.ref }}

.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,3 @@
33
/wordpress
44
/dist
55
composer.lock
6-
package-lock.json
File renamed without changes.

README.md

+10-3
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
Tags: gutenberg, block editor, iframe
44
Contributors: tarosky, Takahashi_Fumiki
5-
Tested up to: 5.7
6-
Requires at least: 5.4
7-
Requires PHP: 5.6
5+
Tested up to: 6.5
6+
Requires at least: 5.9
7+
Requires PHP: 7.2
88
Stable Tag: nightly
99
License: GPLv3 or later
1010
License URI: http://www.gnu.org/licenses/gpl-3.0.txt
@@ -48,6 +48,13 @@ Create a new [issue](https://github.com/tarosky/taro-iframe-block/issues) or sen
4848

4949
## Changelog
5050

51+
### 1.1.0
52+
53+
* Drop support for PHP 5.6 and minimum PHP version is 7.2.
54+
* Minimum WordPress version is now 5.9.
55+
* Update JS for the latest block editor.
56+
57+
5158
### 1.0.3
5259

5360
* Add quick hack for JS translation in GlotPress([detail](https://wordpress.slack.com/archives/C02RP50LK/p1635254887019500))

assets/js/block.js

+15-18
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@
22
* iframe block
33
*
44
* @handle taro-iframe-block-editor
5-
* @deps wp-i18n, wp-components, wp-blocks, wp-block-editor, wp-server-side-render, wp-compose, wp-data
5+
* @deps wp-i18n, wp-components, wp-blocks, wp-block-editor, wp-server-side-render, wp-data, wp-element
66
*/
77

88
/* global TaroIframeBlockEditor:false */
99

1010
const { registerBlockType } = wp.blocks;
11+
const { useState } = wp.element;
1112
const { __, sprintf } = wp.i18n;
1213
const { InspectorControls } = wp.blockEditor;
1314
const { PanelBody, ToggleControl, TextControl, TextareaControl, Button } = wp.components;
1415
const { serverSideRender: ServerSideRender } = wp;
15-
const { withState } = wp.compose;
1616
const { dispatch } = wp.data;
1717

1818
/**
@@ -41,7 +41,7 @@ const convertHtmlToOptions = ( string ) => {
4141
// error.
4242
dispatch( 'core/notices' ).createNotice( 'error', __( 'Sorry, but failed to parse iframe tag.', 'taro-iframe-block' ), {
4343
type: 'snackbar',
44-
} ).then( res => {
44+
} ).then( ( res ) => {
4545
setTimeout( () => {
4646
dispatch( 'core/notices' ).removeNotice( res.notice.id );
4747
}, 3000 );
@@ -76,14 +76,13 @@ const convertHtmlToOptions = ( string ) => {
7676
return false;
7777
};
7878

79-
const IframeInserter = withState( {
80-
html: ''
81-
} )( ( { html, setState, onConvert } ) => {
79+
const IframeInserter = ( { onConvert } ) => {
80+
const [ html, setHtmlState ] = useState( '' );
8281
return (
8382
<>
8483
<TextareaControl label={ __( 'iframe tag', 'taro-iframe-block' ) } value={ html }
85-
onChange={ ( newHtml ) => setState( { html: newHtml } ) }
86-
help={ __( 'Paste html tag here and convert into options.', 'taro-iframe-block' ) }
84+
onChange={ ( newHtml ) => setHtmlState( newHtml ) }
85+
help={ __( 'Paste html tag here and convert into options.', 'taro-iframe-block' ) }
8786
placeholder={ 'e.g. <iframe src="https://example.com" width="640" height="480" />' } rows={ 4 } />
8887
<Button onClick={ () => {
8988
if ( onConvert ) {
@@ -97,7 +96,7 @@ const IframeInserter = withState( {
9796
</Button>
9897
</>
9998
);
100-
} );
99+
};
101100

102101
registerBlockType( 'taro/iframe-block', {
103102

@@ -129,7 +128,7 @@ registerBlockType( 'taro/iframe-block', {
129128
example: {
130129
src: 'https://wordpress.org',
131130
width: 320,
132-
height: 180
131+
height: 180,
133132
},
134133

135134
keywords: [ 'iframe', __( 'Embed', 'taro-iframe-block' ) ],
@@ -139,8 +138,6 @@ registerBlockType( 'taro/iframe-block', {
139138
description: __( 'Add responsive iframe block which keep original aspect ratio.', 'taro-iframe-block' ),
140139

141140
edit( { attributes, setAttributes } ) {
142-
143-
144141
let responsiveHelp;
145142
if ( attributes.responsive ) {
146143
if ( /^\d+$/.test( attributes.width ) && /^\d+$/.test( attributes.height ) && 0 < attributes.width * attributes.height ) {
@@ -157,16 +154,16 @@ registerBlockType( 'taro/iframe-block', {
157154
<>
158155
<InspectorControls>
159156
<PanelBody defaultOpen={ true } title={ __( 'Display Setting', 'taro-iframe-block' ) } >
160-
<TextControl type="url" label={ __( 'SRC attribute', 'taro-iframe-block' ) } value={ attributes.src } onChange={ src => setAttributes( { src } ) } />
161-
<TextControl label={ __( 'Width', 'taro-iframe-block' ) } value={ attributes.width } onChange={ width => setAttributes( { width } ) } />
162-
<TextControl label={ __( 'Height', 'taro-iframe-block' ) } value={ attributes.height } onChange={ height => setAttributes( { height } ) } />
163-
<ToggleControl checked={ attributes.responsive } label={ __( 'Responsive', 'taro-iframe-block' ) } onChange={ responsive => setAttributes( { responsive } ) }
157+
<TextControl type="url" label={ __( 'SRC attribute', 'taro-iframe-block' ) } value={ attributes.src } onChange={ ( src ) => setAttributes( { src } ) } />
158+
<TextControl label={ __( 'Width', 'taro-iframe-block' ) } value={ attributes.width } onChange={ ( width ) => setAttributes( { width } ) } />
159+
<TextControl label={ __( 'Height', 'taro-iframe-block' ) } value={ attributes.height } onChange={ ( height ) => setAttributes( { height } ) } />
160+
<ToggleControl checked={ attributes.responsive } label={ __( 'Responsive', 'taro-iframe-block' ) } onChange={ ( responsive ) => setAttributes( { responsive } ) }
164161
help={ responsiveHelp } />
165-
<ToggleControl checked={ attributes.fullscreen } label={ __( 'Allow Fullscreen', 'taro-iframe-block' ) } onChange={ fullscreen => setAttributes( { fullscreen } ) } />
162+
<ToggleControl checked={ attributes.fullscreen } label={ __( 'Allow Fullscreen', 'taro-iframe-block' ) } onChange={ ( fullscreen ) => setAttributes( { fullscreen } ) } />
166163
<TextControl label={ __( 'Other Attributes', 'taro-iframe-block' ) }
167164
placeholder={ 'e.g. id="frame" name="my-map"' }
168165
help={ __( 'Add other attribute here.', 'taro-iframe-block' ) }
169-
value={ attributes.other } onChange={ other => setAttributes( { other } ) } />
166+
value={ attributes.other } onChange={ ( other ) => setAttributes( { other } ) } />
170167
</PanelBody>
171168
<PanelBody defaultOpen={ false } title={ __( 'Converter', 'taro-iframe-block' ) }>
172169
<IframeInserter onConvert={ ( newAttr ) => setAttributes( newAttr ) } />

composer.json

+11-5
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
{
22
"name": "tarosky/taro-iframe-block",
3-
"description": "WordPress plguin fro simple iframe block.",
3+
"description": "WordPress plugin for simple iframe block.",
44
"minimum-stability": "stable",
55
"license": "GPL-3.0-or-later",
66
"scripts": {
77
"test": [
8-
"phpcs --config-set installed_paths $(pwd)/vendor/wp-coding-standards/wpcs",
98
"phpcs --standard=phpcs.ruleset.xml $(find ./ -name '*.php')"
109
],
1110
"fix": [
12-
"phpcs --config-set installed_paths $(pwd)/vendor/wp-coding-standards/wpcs",
1311
"phpcbf --standard=phpcs.ruleset.xml $(find ./ -name '*.php')"
1412
]
1513
},
@@ -20,10 +18,18 @@
2018
}
2119
],
2220
"require": {
23-
"php": "^5.6|^7.0"
21+
"php": ">=7.2"
2422
},
2523
"require-dev": {
2624
"squizlabs/php_codesniffer": "^3.0",
27-
"wp-coding-standards/wpcs": "^2.0"
25+
"wp-coding-standards/wpcs": "^2.0",
26+
"phpcompatibility/php-compatibility": "^9.3",
27+
"dealerdirect/phpcodesniffer-composer-installer": "^1.0"
28+
},
29+
"config": {
30+
"allow-plugins": {
31+
"dealerdirect/phpcodesniffer-composer-installer": true
32+
}
2833
}
34+
2935
}

0 commit comments

Comments
 (0)