Skip to content

Commit 43e271e

Browse files
authored
Revamp (#2)
1 parent 67fbd8e commit 43e271e

File tree

17 files changed

+221
-471
lines changed

17 files changed

+221
-471
lines changed

.github/workflows/php.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: PHP
2+
3+
on: [pull_request]
4+
5+
jobs:
6+
lint:
7+
name: Lint
8+
runs-on: ubuntu-latest
9+
10+
steps:
11+
- uses: actions/checkout@v3
12+
13+
- name: Setup PHP
14+
uses: shivammathur/setup-php@v2
15+
with:
16+
php-version: 8.2
17+
18+
- name: Install dependencies
19+
run: composer build:dev
20+
21+
- name: Validate against coding standards
22+
run: composer lint

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@
33

44
# Files
55
composer.lock
6+
.phpunit.result.cache
7+
*.log

.travis.yml

Lines changed: 0 additions & 65 deletions
This file was deleted.

README.md

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
# WordPress Plugin Template
2-
This template uses concepts such as OOP and DI to make everything more "central" in your next WordPress plugin. This is opposed to the "fragmented" way WordPress code is usually developed.
1+
# WordPress Plugin Template
32

4-
If you're unfamiliar with OOP (object-oriented programming) then I recommend you [read this introduction](https://www.tutorialspoint.com/php/php_object_oriented.htm).
5-
6-
If you're unfamiliar with DI (dependency injection) then I recommend you [read this introduction](http://codeinphp.github.io/post/dependency-injection-in-php/).
3+
A simple plugin template for writing WordPress plugins in a modern way.

bin/install-wp-tests.sh

Lines changed: 0 additions & 155 deletions
This file was deleted.

composer.json

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"authors": [
55
{
66
"name": "Seb Kay",
7-
"email": "seb@sebkay.com"
7+
"email": "seb@fhoke.com"
88
}
99
],
1010
"minimum-stability": "stable",
@@ -13,29 +13,29 @@
1313
"WPT\\": "src/"
1414
}
1515
},
16-
"autoload-dev": {
17-
"psr-4": {
18-
"Tests\\": "tests/"
19-
}
20-
},
2116
"require": {
22-
"php": "^7.4"
17+
"php": "^8.2",
18+
"illuminate/collections": "^10.28",
19+
"saloonphp/saloon": "^3.0",
20+
"monolog/monolog": "^3.4"
2321
},
2422
"require-dev": {
25-
"phpunit/phpunit": "^5.0",
26-
"phpcompatibility/phpcompatibility-wp": "*",
27-
"wp-coding-standards/wpcs": "^2.3",
28-
"dealerdirect/phpcodesniffer-composer-installer": "^0.7",
29-
"squizlabs/php_codesniffer": "^3.5",
30-
"spatie/ray": "^1.3"
23+
"spatie/ray": "^1.39",
24+
"php-stubs/wordpress-stubs": "^6.3",
25+
"laravel/pint": "^1.13"
3126
},
3227
"scripts": {
33-
"refresh" : "git clean -xffd && composer install --ansi",
34-
"install:phpcs-rules" : "Dealerdirect\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\Plugin::run",
35-
"install:wptests": "bin/install-wp-tests.sh plugin_testing_tests root 'root' 127.0.0.1:8889 latest true",
36-
"fix:php" : "./vendor/bin/phpcbf wordpress-plugin-template.php ./src",
37-
"lint:php" : "./vendor/bin/phpcs ./ --extensions=php --ignore=vendor/,tests/",
38-
"test:php": "./vendor/bin/phpunit --colors=always",
39-
"test:php-testdox": "@test:php --testdox"
28+
"build:dev": [
29+
"composer install"
30+
],
31+
"build:prod": [
32+
"composer install --no-dev --optimize-autoloader"
33+
],
34+
"lint": [
35+
"./vendor/bin/pint --test -v"
36+
],
37+
"fix": [
38+
"./vendor/bin/pint"
39+
]
4040
}
4141
}

inc/options.php

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
<?php defined('ABSPATH') or exit; ?>
2+
3+
<div class="wrap">
4+
<h1>
5+
<?php echo WPT_PLUGIN_NAME; ?>
6+
</h1>
7+
8+
<form method="post" action="options.php">
9+
<?php settings_fields('wpt-options'); ?>
10+
<?php do_settings_sections('wpt-options'); ?>
11+
12+
<h2 class="title">
13+
<?php _e('API', 'wp-plugin-template'); ?>
14+
</h2>
15+
16+
<table class="form-table">
17+
<tr valign="top">
18+
<th scope="row">
19+
<?php _e('Text', 'wp-plugin-template'); ?>
20+
</th>
21+
<td>
22+
<input type="text" name="wpt_text_option" value="<?php echo esc_attr(get_option('wpt_text_option')); ?>">
23+
</td>
24+
</tr>
25+
26+
<tr valign="top">
27+
<th scope="row">
28+
<?php _e('Radio', 'wp-plugin-template'); ?>
29+
</th>
30+
<td>
31+
<label>
32+
<input type="radio" name="wpt_radio_option" value="0" <?php checked(0, esc_attr(get_option('wpt_radio_option', 0))); ?>>
33+
<span>
34+
No
35+
</span>
36+
</label>
37+
<br><br>
38+
<label>
39+
<input type="radio" name="wpt_radio_option" value="1" <?php checked(1, esc_attr(get_option('wpt_radio_option', 0))); ?>>
40+
<span>
41+
Yes
42+
</span>
43+
</label>
44+
</td>
45+
</tr>
46+
47+
<tr valign="top">
48+
<th scope="row">
49+
<?php _e('Select', 'wp-plugin-template'); ?>
50+
</th>
51+
<td>
52+
<select name="wpt_select_option">
53+
<option value="1" <?php selected(get_option('wpt_select_option'), 1); ?>>1</option>
54+
<option value="10" <?php selected(get_option('wpt_select_option'), 10); ?>>10</option>
55+
<option value="25" <?php selected(get_option('wpt_select_option'), 25); ?>>25</option>
56+
</select>
57+
</td>
58+
</tr>
59+
</table>
60+
61+
<hr>
62+
63+
<?php submit_button(); ?>
64+
</form>
65+
</div>

0 commit comments

Comments
 (0)