Compare commits

...

5 Commits

7 changed files with 103 additions and 150 deletions

View File

@ -11,15 +11,15 @@
}
],
"require": {
"php": ">=8.0.2",
"php": "~8.1",
"eftec/bladeone": "^3.52"
},
"require-dev": {
"php-parallel-lint/php-parallel-lint": "^1.3.2",
"phpstan/extension-installer": "^1.1",
"phpstan/phpstan": "^1.8",
"szepeviktor/phpstan-wordpress": "^1.1",
"wp-cli/i18n-command": "^2.4.0",
"phpstan/extension-installer": "^1.3.1",
"phpstan/phpstan": "^1.10.26",
"szepeviktor/phpstan-wordpress": "^1.3.0",
"wp-cli/i18n-command": "^2.4.3",
"wp-coding-standards/wpcs": "^2.3.0"
},
"config": {

195
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "6fa6e29e5c44798ae9959277f4a2a98a",
"content-hash": "c26471e5df77f5b3c095f9afae81388f",
"packages": [
{
"name": "eftec/bladeone",
@ -223,16 +223,16 @@
},
{
"name": "mck89/peast",
"version": "v1.15.1",
"version": "v1.15.2",
"source": {
"type": "git",
"url": "https://github.com/mck89/peast.git",
"reference": "cf06286910b7efc9dce7503553ebee314df3d3d3"
"reference": "07d82a271d372c6f37897a70b0381ca2ec2e364a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/mck89/peast/zipball/cf06286910b7efc9dce7503553ebee314df3d3d3",
"reference": "cf06286910b7efc9dce7503553ebee314df3d3d3",
"url": "https://api.github.com/repos/mck89/peast/zipball/07d82a271d372c6f37897a70b0381ca2ec2e364a",
"reference": "07d82a271d372c6f37897a70b0381ca2ec2e364a",
"shasum": ""
},
"require": {
@ -245,7 +245,7 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.15.1-dev"
"dev-master": "1.15.2-dev"
}
},
"autoload": {
@ -267,9 +267,9 @@
"description": "Peast is PHP library that generates AST for JavaScript code",
"support": {
"issues": "https://github.com/mck89/peast/issues",
"source": "https://github.com/mck89/peast/tree/v1.15.1"
"source": "https://github.com/mck89/peast/tree/v1.15.2"
},
"time": "2023-01-21T13:18:17+00:00"
"time": "2023-07-15T12:25:27+00:00"
},
{
"name": "mustache/mustache",
@ -380,16 +380,16 @@
},
{
"name": "php-stubs/wordpress-stubs",
"version": "v6.1.1",
"version": "v6.2.1",
"source": {
"type": "git",
"url": "https://github.com/php-stubs/wordpress-stubs.git",
"reference": "601c429ba8d91ef50a2a1bec05a7cd38b88064ff"
"reference": "0009429e639b748eef1c955200ea0d4e5ad5627d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-stubs/wordpress-stubs/zipball/601c429ba8d91ef50a2a1bec05a7cd38b88064ff",
"reference": "601c429ba8d91ef50a2a1bec05a7cd38b88064ff",
"url": "https://api.github.com/repos/php-stubs/wordpress-stubs/zipball/0009429e639b748eef1c955200ea0d4e5ad5627d",
"reference": "0009429e639b748eef1c955200ea0d4e5ad5627d",
"shasum": ""
},
"require-dev": {
@ -397,7 +397,8 @@
"php": "~7.3 || ~8.0",
"php-stubs/generator": "^0.8.3",
"phpdocumentor/reflection-docblock": "^5.3",
"phpstan/phpstan": "^1.2"
"phpstan/phpstan": "^1.10.12",
"phpunit/phpunit": "^9.5"
},
"suggest": {
"paragonie/sodium_compat": "Pure PHP implementation of libsodium",
@ -418,28 +419,28 @@
],
"support": {
"issues": "https://github.com/php-stubs/wordpress-stubs/issues",
"source": "https://github.com/php-stubs/wordpress-stubs/tree/v6.1.1"
"source": "https://github.com/php-stubs/wordpress-stubs/tree/v6.2.1"
},
"time": "2023-02-09T11:10:35+00:00"
"time": "2023-05-18T04:35:23+00:00"
},
{
"name": "phpstan/extension-installer",
"version": "1.2.0",
"version": "1.3.1",
"source": {
"type": "git",
"url": "https://github.com/phpstan/extension-installer.git",
"reference": "f06dbb052ddc394e7896fcd1cfcd533f9f6ace40"
"reference": "f45734bfb9984c6c56c4486b71230355f066a58a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpstan/extension-installer/zipball/f06dbb052ddc394e7896fcd1cfcd533f9f6ace40",
"reference": "f06dbb052ddc394e7896fcd1cfcd533f9f6ace40",
"url": "https://api.github.com/repos/phpstan/extension-installer/zipball/f45734bfb9984c6c56c4486b71230355f066a58a",
"reference": "f45734bfb9984c6c56c4486b71230355f066a58a",
"shasum": ""
},
"require": {
"composer-plugin-api": "^2.0",
"php": "^7.2 || ^8.0",
"phpstan/phpstan": "^1.8.0"
"phpstan/phpstan": "^1.9.0"
},
"require-dev": {
"composer/composer": "^2.0",
@ -462,22 +463,22 @@
"description": "Composer plugin for automatic installation of PHPStan extensions",
"support": {
"issues": "https://github.com/phpstan/extension-installer/issues",
"source": "https://github.com/phpstan/extension-installer/tree/1.2.0"
"source": "https://github.com/phpstan/extension-installer/tree/1.3.1"
},
"time": "2022-10-17T12:59:16+00:00"
"time": "2023-05-24T08:59:17+00:00"
},
{
"name": "phpstan/phpstan",
"version": "1.10.6",
"version": "1.10.26",
"source": {
"type": "git",
"url": "https://github.com/phpstan/phpstan.git",
"reference": "50d089a3e0904b0fe7e2cf2d4fd37d427d64235a"
"reference": "5d660cbb7e1b89253a47147ae44044f49832351f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/50d089a3e0904b0fe7e2cf2d4fd37d427d64235a",
"reference": "50d089a3e0904b0fe7e2cf2d4fd37d427d64235a",
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/5d660cbb7e1b89253a47147ae44044f49832351f",
"reference": "5d660cbb7e1b89253a47147ae44044f49832351f",
"shasum": ""
},
"require": {
@ -506,8 +507,11 @@
"static analysis"
],
"support": {
"docs": "https://phpstan.org/user-guide/getting-started",
"forum": "https://github.com/phpstan/phpstan/discussions",
"issues": "https://github.com/phpstan/phpstan/issues",
"source": "https://github.com/phpstan/phpstan/tree/1.10.6"
"security": "https://github.com/phpstan/phpstan/security/policy",
"source": "https://github.com/phpstan/phpstan-src"
},
"funding": [
{
@ -523,67 +527,7 @@
"type": "tidelift"
}
],
"time": "2023-03-09T16:55:12+00:00"
},
{
"name": "rmccue/requests",
"version": "v1.8.1",
"source": {
"type": "git",
"url": "https://github.com/WordPress/Requests.git",
"reference": "82e6936366eac3af4d836c18b9d8c31028fe4cd5"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/WordPress/Requests/zipball/82e6936366eac3af4d836c18b9d8c31028fe4cd5",
"reference": "82e6936366eac3af4d836c18b9d8c31028fe4cd5",
"shasum": ""
},
"require": {
"php": ">=5.2"
},
"require-dev": {
"dealerdirect/phpcodesniffer-composer-installer": "^0.7",
"php-parallel-lint/php-console-highlighter": "^0.5.0",
"php-parallel-lint/php-parallel-lint": "^1.3",
"phpcompatibility/php-compatibility": "^9.0",
"phpunit/phpunit": "^4.8 || ^5.7 || ^6.5 || ^7.5",
"requests/test-server": "dev-master",
"squizlabs/php_codesniffer": "^3.5",
"wp-coding-standards/wpcs": "^2.0"
},
"type": "library",
"autoload": {
"psr-0": {
"Requests": "library/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"ISC"
],
"authors": [
{
"name": "Ryan McCue",
"homepage": "http://ryanmccue.info"
}
],
"description": "A HTTP library written in PHP, for human beings.",
"homepage": "http://github.com/WordPress/Requests",
"keywords": [
"curl",
"fsockopen",
"http",
"idna",
"ipv6",
"iri",
"sockets"
],
"support": {
"issues": "https://github.com/WordPress/Requests/issues",
"source": "https://github.com/WordPress/Requests/tree/v1.8.1"
},
"time": "2021-06-04T09:56:25+00:00"
"time": "2023-07-19T12:44:37+00:00"
},
{
"name": "squizlabs/php_codesniffer",
@ -644,16 +588,16 @@
},
{
"name": "symfony/finder",
"version": "v6.2.7",
"version": "v6.3.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/finder.git",
"reference": "20808dc6631aecafbe67c186af5dcb370be3a0eb"
"reference": "d9b01ba073c44cef617c7907ce2419f8d00d75e2"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/finder/zipball/20808dc6631aecafbe67c186af5dcb370be3a0eb",
"reference": "20808dc6631aecafbe67c186af5dcb370be3a0eb",
"url": "https://api.github.com/repos/symfony/finder/zipball/d9b01ba073c44cef617c7907ce2419f8d00d75e2",
"reference": "d9b01ba073c44cef617c7907ce2419f8d00d75e2",
"shasum": ""
},
"require": {
@ -688,7 +632,7 @@
"description": "Finds files and directories via an intuitive fluent interface",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/finder/tree/v6.2.7"
"source": "https://github.com/symfony/finder/tree/v6.3.0"
},
"funding": [
{
@ -704,7 +648,7 @@
"type": "tidelift"
}
],
"time": "2023-02-16T09:57:23+00:00"
"time": "2023-04-02T01:25:41+00:00"
},
{
"name": "symfony/polyfill-php73",
@ -787,22 +731,22 @@
},
{
"name": "szepeviktor/phpstan-wordpress",
"version": "v1.1.7",
"version": "v1.3.0",
"source": {
"type": "git",
"url": "https://github.com/szepeviktor/phpstan-wordpress.git",
"reference": "979dcb81a01942b576b9fbf72dcb9515c57a4aa8"
"reference": "5b5cc77ed51fdaf64efe3f00b5aae4b709d2cfa9"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/szepeviktor/phpstan-wordpress/zipball/979dcb81a01942b576b9fbf72dcb9515c57a4aa8",
"reference": "979dcb81a01942b576b9fbf72dcb9515c57a4aa8",
"url": "https://api.github.com/repos/szepeviktor/phpstan-wordpress/zipball/5b5cc77ed51fdaf64efe3f00b5aae4b709d2cfa9",
"reference": "5b5cc77ed51fdaf64efe3f00b5aae4b709d2cfa9",
"shasum": ""
},
"require": {
"php": "^7.2 || ^8.0",
"php-stubs/wordpress-stubs": "^4.7 || ^5.0 || ^6.0",
"phpstan/phpstan": "^1.8.7",
"phpstan/phpstan": "^1.10.0",
"symfony/polyfill-php73": "^1.12.0"
},
"require-dev": {
@ -840,32 +784,22 @@
],
"support": {
"issues": "https://github.com/szepeviktor/phpstan-wordpress/issues",
"source": "https://github.com/szepeviktor/phpstan-wordpress/tree/v1.1.7"
"source": "https://github.com/szepeviktor/phpstan-wordpress/tree/v1.3.0"
},
"funding": [
{
"url": "https://www.paypal.me/szepeviktor",
"type": "custom"
},
{
"url": "https://github.com/szepeviktor",
"type": "github"
}
],
"time": "2023-02-04T13:10:27+00:00"
"time": "2023-04-23T06:15:06+00:00"
},
{
"name": "wp-cli/i18n-command",
"version": "v2.4.2",
"version": "v2.4.3",
"source": {
"type": "git",
"url": "https://github.com/wp-cli/i18n-command.git",
"reference": "43d5cf8968dbddf90907083ad048f12be5ca3d43"
"reference": "203b020318fe2596a218bf52db25adc6b187f42d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/wp-cli/i18n-command/zipball/43d5cf8968dbddf90907083ad048f12be5ca3d43",
"reference": "43d5cf8968dbddf90907083ad048f12be5ca3d43",
"url": "https://api.github.com/repos/wp-cli/i18n-command/zipball/203b020318fe2596a218bf52db25adc6b187f42d",
"reference": "203b020318fe2596a218bf52db25adc6b187f42d",
"shasum": ""
},
"require": {
@ -918,9 +852,9 @@
"homepage": "https://github.com/wp-cli/i18n-command",
"support": {
"issues": "https://github.com/wp-cli/i18n-command/issues",
"source": "https://github.com/wp-cli/i18n-command/tree/v2.4.2"
"source": "https://github.com/wp-cli/i18n-command/tree/v2.4.3"
},
"time": "2023-02-17T18:14:41+00:00"
"time": "2023-03-24T18:15:59+00:00"
},
{
"name": "wp-cli/mustangostang-spyc",
@ -975,16 +909,16 @@
},
{
"name": "wp-cli/php-cli-tools",
"version": "v0.11.17",
"version": "v0.11.19",
"source": {
"type": "git",
"url": "https://github.com/wp-cli/php-cli-tools.git",
"reference": "f6be76b7c4ee2ef93c9531b8a37bdb7ce42c3728"
"reference": "2d27f0db5c36f5aa0064abecddd6d05f28c4d001"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/wp-cli/php-cli-tools/zipball/f6be76b7c4ee2ef93c9531b8a37bdb7ce42c3728",
"reference": "f6be76b7c4ee2ef93c9531b8a37bdb7ce42c3728",
"url": "https://api.github.com/repos/wp-cli/php-cli-tools/zipball/2d27f0db5c36f5aa0064abecddd6d05f28c4d001",
"reference": "2d27f0db5c36f5aa0064abecddd6d05f28c4d001",
"shasum": ""
},
"require": {
@ -1032,29 +966,28 @@
],
"support": {
"issues": "https://github.com/wp-cli/php-cli-tools/issues",
"source": "https://github.com/wp-cli/php-cli-tools/tree/v0.11.17"
"source": "https://github.com/wp-cli/php-cli-tools/tree/v0.11.19"
},
"time": "2023-01-12T01:18:21+00:00"
"time": "2023-07-21T11:37:15+00:00"
},
{
"name": "wp-cli/wp-cli",
"version": "v2.7.1",
"version": "v2.8.1",
"source": {
"type": "git",
"url": "https://github.com/wp-cli/wp-cli.git",
"reference": "1ddc754f1c15e56fb2cdd1a4e82bd0ec6ca32a76"
"reference": "5dd2340b9a01c3cfdbaf5e93a140759fdd190eee"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/wp-cli/wp-cli/zipball/1ddc754f1c15e56fb2cdd1a4e82bd0ec6ca32a76",
"reference": "1ddc754f1c15e56fb2cdd1a4e82bd0ec6ca32a76",
"url": "https://api.github.com/repos/wp-cli/wp-cli/zipball/5dd2340b9a01c3cfdbaf5e93a140759fdd190eee",
"reference": "5dd2340b9a01c3cfdbaf5e93a140759fdd190eee",
"shasum": ""
},
"require": {
"ext-curl": "*",
"mustache/mustache": "^2.14.1",
"php": "^5.6 || ^7.0 || ^8.0",
"rmccue/requests": "^1.8",
"symfony/finder": ">2.7",
"wp-cli/mustangostang-spyc": "^0.6.3",
"wp-cli/php-cli-tools": "~0.11.2"
@ -1078,7 +1011,7 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.8.x-dev"
"dev-main": "2.9.x-dev"
}
},
"autoload": {
@ -1105,7 +1038,7 @@
"issues": "https://github.com/wp-cli/wp-cli/issues",
"source": "https://github.com/wp-cli/wp-cli"
},
"time": "2022-10-17T23:10:42+00:00"
"time": "2023-06-05T06:55:55+00:00"
},
{
"name": "wp-coding-standards/wpcs",
@ -1165,7 +1098,7 @@
"prefer-stable": true,
"prefer-lowest": false,
"platform": {
"php": ">=8.0.2"
"php": "~8.1"
},
"platform-dev": [],
"plugin-api-version": "2.3.0"

View File

@ -20,6 +20,7 @@ class App {
/**
* Any logic that needs executed when the plugin is activated.
*
* @package PluginNamespace\App
* @since 1.0.0
*
* @return void
@ -37,18 +38,21 @@ class App {
/**
* Any logic that needs executed when the plugin is deactivated.
*
* @package PluginNamespace\App
* @since 1.0.0
*
* @return void
*/
public static function plugin_deactivation(): void {
//
// phpcs:disable
// phpcs:enable
}
/**
* Check that the cache directory for Blade exists and
* if not then attempt to create it.
*
* @package PluginNamespace\App
* @since 1.0.0
*
* @throws \Exception
@ -59,13 +63,13 @@ class App {
if ( ! file_exists( NMSP_PLUGIN_BASE_DIR . '/cache/blade/.gitignore' ) ) {
try {
mkdir( NMSP_PLUGIN_BASE_DIR . '/cache/blade', 0755, true );
} catch ( Exception $e ) {
} catch ( Exception $exp ) {
$error_payload = array(
'level' => 'critical',
'message' => $e->getMessage(),
'message' => $exp->getMessage(),
'context' => array(
'file' => $e->getFile(),
'line' => $e->getLine(),
'file' => $exp->getFile(),
'line' => $exp->getLine(),
),
);
error_log( json_encode( $error_payload, JSON_PRETTY_PRINT ) );
@ -77,12 +81,13 @@ class App {
* Return an instance of this plugin class. If it has
* not been initialized, do so then return it.
*
* @package PluginNamespace\App
* @since 1.0.0
*
* @return \PluginNamespace\App
*/
public static function get_instance(): App {
if ( ! isset( self::$instance ) && ! ( self::$instance instanceof App ) ) {
if ( ! ( self::$instance instanceof App ) ) {
self::$instance = new App();
self::$instance->load_plugin_textdomain();
@ -96,6 +101,7 @@ class App {
/**
* Load your translation files for this plugin.
*
* @package PluginNamespace\App
* @since 1.0.0
*
* @return void
@ -107,14 +113,17 @@ class App {
/**
* Steps to take when initializing this plugin??
*
* @package PluginNamespace\App
* @since 1.0.0
*
* @return void
*/
public function scaffold_plugin(): void {
// phpcs:disable
if ( is_admin() ) {
// admin only logic here
// admin only logic here, remove phpcs calls around this
}
// phpcs:enable
// other logic here
}
@ -126,6 +135,7 @@ class App {
*
* @codeCoverageIgnore
*
* @package PluginNamespace\App
* @since 1.0.0
*
* @return void
@ -148,6 +158,7 @@ class App {
/**
* Load BladeOne as the templating engine for the plugin.
*
* @package PluginNamespace\App
* @since 1.0.0
*
* @param \eftec\bladeone\BladeOne $blade

View File

@ -13,6 +13,7 @@ class NmspCli {
/**
* Class constructor. Can add commands here.
*
* @package PluginNamespace\NmspCli
* @since 1.0.0
*
* @return void
@ -31,6 +32,7 @@ class NmspCli {
/**
* A sample method where something is done by being invoked from WP CLI.
*
* @package PluginNamespace\NmspCli
* @since 1.0.0
*
* @return void

View File

@ -11,6 +11,7 @@ class Rewrites {
/**
* Class constructor.
*
* @package PluginNamespace\Front\Rewrites
* @since 1.0.0
*
* @return void
@ -25,6 +26,7 @@ class Rewrites {
/**
* Generate new rewrite rules and flush the cached values.
*
* @package PluginNamespace\Front\Rewrites
* @since 1.0.0
*
* @return void
@ -50,9 +52,10 @@ class Rewrites {
* Build the array of post IDs that have a slug for the URL
* along with what custom query variable to use.
*
* @package PluginNamespace\Front\Rewrites
* @since 1.0.0
*
* @return array
* @return array<int, array<string, string>>
*/
public function build_rewrite_urls(): array {
$pages = array();
@ -82,11 +85,12 @@ class Rewrites {
* Append custom query variables to the list WordPress maintinas
* with each request.
*
* @package PluginNamespace\Front\Rewrites
* @since 1.0.0
*
* @param array $variable
* @param array<int, string> $vars
*
* @return array
* @return array<int, string>
*/
public function custom_query_vars( array $vars ): array {
$vars[] = 'foo';

View File

@ -6,13 +6,13 @@ use eftec\bladeone\BladeOne;
/**
* Boilerplate Plugin v2
*
* @package BoilerplatePluginv2
* @package BoilerplatePlugin
* @author Plugin Author
* @copyright GPLv3
* @license https://www.gnu.org/licenses/gpl-3.0.en.html
*
* @wordpress-plugin
* Plugin Name: Boilerplate Plugin v2
* Plugin Name: Boilerplate Plugin
* Description: Your plugin description.
* License: GPLv3
* License URI: https://www.gnu.org/licenses/gpl-3.0.en.html
@ -20,7 +20,7 @@ use eftec\bladeone\BladeOne;
* Update URI: https://example.com/my-plugin/
* Version: 1.0.0
* Requires at least: 5.2
* Requires PHP: 8.0.2
* Requires PHP: 8.1
* Author: Plugin Author
* Author URI: https://plugin-author.com
* Text Domain: nmsp-plugin-name-text-domain
@ -65,4 +65,4 @@ $blade = new BladeOne( __DIR__ . '/templates', __DIR__ . '/cache/blade' );
register_activation_hook( __FILE__, array( App::class, 'plugin_activation' ) );
register_deactivation_hook( __FILE__, array( App::class, 'plugin_deactivation' ) );
App::get_instance()->load_blade( $blade );
nmsp_plugin_app()->load_blade( $blade );

View File

@ -1,5 +1,8 @@
parameters:
level: 6
bootstrapFiles:
- bootstrap.php
- nmsp-plugin-name.php
paths:
- admin
- constants