Moving admin to it's own directory, trying to fix up docblocks and stuff

This commit is contained in:
Brian 2021-09-14 11:37:30 -06:00
parent c94414dc0e
commit ecd4099038
Signed by: brian
GPG Key ID: DE1A5390A3B84CD8
17 changed files with 1095 additions and 396 deletions

1
.gitignore vendored
View File

@ -1,6 +1,5 @@
### Project Specific
# Files
.env
phpcs.xml
phpunit.xml
.phpunit.result.cache

90
admin/class-settings.php Normal file
View File

@ -0,0 +1,90 @@
<?php
namespace PluginNamespace\Admin;
class Settings {
/**
* Class constructor.
*
* @since 1.0.0
*
* @return void
*/
public function __construct() {
add_action( 'admin_menu', array( $this, 'append_to_admin_menu' ), 12 );
add_action( 'admin_enqueue_scripts', array( $this, 'register_scripts' ) );
}
/**
* Append to the admin menu (prevents doubling).
*
* @since 1.0.0
*
* @return void
*/
public function append_to_admin_menu(): void {
$parent_slug = 'nmsp-plugin-name-menu-slug';
$page_title = __( 'Namespace Plugin Name - Settings', 'nmsp_plugin_name_settings_title' );
$menu_title = __( 'Settings', 'nmsp_plugin_name_settings_title' );
$capability = 'manage_options';
$menu_slug = $parent_slug;
$callback = array( $this, 'show_main_settings_page' );
add_submenu_page( $parent_slug, $page_title, $menu_title, $capability, $menu_slug, $callback );
}
/**
* Show the settings page.
*
* @since 1.0.0
*
* @return string
*/
public function show_main_settings_page(): string {
$data = array();
$this->localize_script();
ob_start();
echo nmsp_plugin_app()->blade->run( 'admin.settings', $data );
$output = ob_get_clean();
return wp_kses_post( $output );
}
/**
* Register and enqueue stylesheets and javascript files.
*
* @since 1.0.0
*
* @return void
*/
public function register_scripts(): void {
wp_enqueue_style( 'nmsp-plugin-name-admin-css', plugins_url( '../assets/css/nmsp-plugin-name-admin.css', __FILE__ ), array(), '1.0.0', 'screen' );
wp_register_script( 'nmsp-plugin-name-admin-js', plugins_url( '../assets/js/nmsp-plugin-name-admin.js', __FILE__ ), array( 'jquery' ), '1.0.0', false );
}
/**
* Description
*
* @since 1.0.0
*
* @param array $additional_data (optional) Additional key-value paired data to pass to JavaScript.
*
* @return void
*/
private function localize_script( array $additional_data = array() ): void {
wp_enqueue_script( 'nmsp-plugin-name-admin-js' );
$payload = array(
'wp_ajax_url' => admin_url( 'admin-ajax.php' ),
'_nonce' => wp_create_nonce( NMSP_PLUGIN_NONCE ),
);
wp_localize_script( 'nmsp-plugin-name-admin-js', 'nmspPluginAdminApi', $payload );
}
}
new Settings();

1
admin/index.php Normal file
View File

@ -0,0 +1 @@
<?php // silence is golden

View File

@ -1,7 +1,5 @@
<?php
use PluginNamespace\App;
/**
| ----------------------------------------------------------------
| Bootstrap
@ -18,7 +16,7 @@ require_once 'constants/base.php';
require_once 'constants/rewrites.php';
if ( ! function_exists( 'nmsp_plugin_app' ) ) {
function nmsp_plugin_app(): App {
return App::get_instance();
function nmsp_plugin_app(): \PluginNamespace\App {
return \PluginNamespace\App::get_instance();
}
}

View File

@ -15,6 +15,8 @@
"eftec/bladeone": "^3.52"
},
"require-dev": {
"php-parallel-lint/php-parallel-lint": "^1.3.0",
"wp-cli/i18n-command": "^2.2.8",
"wp-coding-standards/wpcs": "^2.3.0"
},
"config": {
@ -41,6 +43,9 @@
"minimum-stability": "dev",
"prefer-stable": true,
"scripts": {
"lint:wpcs": "@php ./vendor/squizlabs/php_codesniffer/bin/phpcs -p -v --no-cache --ignore=*/tests/,*/vendor/ --extensions=php .",
"lint:php": "@php ./vendor/bin/parallel-lint --exclude .git --exclude vendor .",
"make-pot": "wp i18n make-pot --include=constants,includes,templates . languages/nmsp-plugin-name.pot",
"post-autoload-dump": [],
"post-root-package-install": []
}

662
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": "ee716afb08c53b3b3561235990805632",
"content-hash": "2684d1770bbee2bb8f671fbbb3919f1e",
"packages": [
{
"name": "eftec/bladeone",
@ -66,6 +66,368 @@
}
],
"packages-dev": [
{
"name": "gettext/gettext",
"version": "v4.8.4",
"source": {
"type": "git",
"url": "https://github.com/php-gettext/Gettext.git",
"reference": "58bc0f7f37e78efb0f9758f93d4a0f669f0f84a1"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-gettext/Gettext/zipball/58bc0f7f37e78efb0f9758f93d4a0f669f0f84a1",
"reference": "58bc0f7f37e78efb0f9758f93d4a0f669f0f84a1",
"shasum": ""
},
"require": {
"gettext/languages": "^2.3",
"php": ">=5.4.0"
},
"require-dev": {
"illuminate/view": "*",
"phpunit/phpunit": "^4.8|^5.7|^6.5",
"squizlabs/php_codesniffer": "^3.0",
"symfony/yaml": "~2",
"twig/extensions": "*",
"twig/twig": "^1.31|^2.0"
},
"suggest": {
"illuminate/view": "Is necessary if you want to use the Blade extractor",
"symfony/yaml": "Is necessary if you want to use the Yaml extractor/generator",
"twig/extensions": "Is necessary if you want to use the Twig extractor",
"twig/twig": "Is necessary if you want to use the Twig extractor"
},
"type": "library",
"autoload": {
"psr-4": {
"Gettext\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Oscar Otero",
"email": "oom@oscarotero.com",
"homepage": "http://oscarotero.com",
"role": "Developer"
}
],
"description": "PHP gettext manager",
"homepage": "https://github.com/oscarotero/Gettext",
"keywords": [
"JS",
"gettext",
"i18n",
"mo",
"po",
"translation"
],
"support": {
"email": "oom@oscarotero.com",
"issues": "https://github.com/oscarotero/Gettext/issues",
"source": "https://github.com/php-gettext/Gettext/tree/v4.8.4"
},
"funding": [
{
"url": "https://paypal.me/oscarotero",
"type": "custom"
},
{
"url": "https://github.com/oscarotero",
"type": "github"
},
{
"url": "https://www.patreon.com/misteroom",
"type": "patreon"
}
],
"time": "2021-03-10T19:35:49+00:00"
},
{
"name": "gettext/languages",
"version": "2.6.0",
"source": {
"type": "git",
"url": "https://github.com/php-gettext/Languages.git",
"reference": "38ea0482f649e0802e475f0ed19fa993bcb7a618"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-gettext/Languages/zipball/38ea0482f649e0802e475f0ed19fa993bcb7a618",
"reference": "38ea0482f649e0802e475f0ed19fa993bcb7a618",
"shasum": ""
},
"require": {
"php": ">=5.3"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^2.16.0",
"phpunit/phpunit": "^4.8 || ^5.7 || ^6.5 || ^7.5 || ^8.4"
},
"bin": [
"bin/export-plural-rules"
],
"type": "library",
"autoload": {
"psr-4": {
"Gettext\\Languages\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Michele Locati",
"email": "mlocati@gmail.com",
"role": "Developer"
}
],
"description": "gettext languages with plural rules",
"homepage": "https://github.com/php-gettext/Languages",
"keywords": [
"cldr",
"i18n",
"internationalization",
"l10n",
"language",
"languages",
"localization",
"php",
"plural",
"plural rules",
"plurals",
"translate",
"translations",
"unicode"
],
"support": {
"issues": "https://github.com/php-gettext/Languages/issues",
"source": "https://github.com/php-gettext/Languages/tree/2.6.0"
},
"time": "2019-11-13T10:30:21+00:00"
},
{
"name": "mck89/peast",
"version": "v1.13.0",
"source": {
"type": "git",
"url": "https://github.com/mck89/peast.git",
"reference": "db38b1524f5bda921cbda2385e440c2bb71d18b4"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/mck89/peast/zipball/db38b1524f5bda921cbda2385e440c2bb71d18b4",
"reference": "db38b1524f5bda921cbda2385e440c2bb71d18b4",
"shasum": ""
},
"require": {
"php": ">=5.4.0"
},
"require-dev": {
"phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0 || ^8.0 || ^9.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.13.0-dev"
}
},
"autoload": {
"psr-4": {
"Peast\\": "lib/Peast/",
"Peast\\test\\": "test/Peast/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Marco Marchiò",
"email": "marco.mm89@gmail.com"
}
],
"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.13.0"
},
"time": "2021-05-22T16:06:09+00:00"
},
{
"name": "mustache/mustache",
"version": "v2.13.0",
"source": {
"type": "git",
"url": "https://github.com/bobthecow/mustache.php.git",
"reference": "e95c5a008c23d3151d59ea72484d4f72049ab7f4"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/bobthecow/mustache.php/zipball/e95c5a008c23d3151d59ea72484d4f72049ab7f4",
"reference": "e95c5a008c23d3151d59ea72484d4f72049ab7f4",
"shasum": ""
},
"require": {
"php": ">=5.2.4"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "~1.11",
"phpunit/phpunit": "~3.7|~4.0|~5.0"
},
"type": "library",
"autoload": {
"psr-0": {
"Mustache": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Justin Hileman",
"email": "justin@justinhileman.info",
"homepage": "http://justinhileman.com"
}
],
"description": "A Mustache implementation in PHP.",
"homepage": "https://github.com/bobthecow/mustache.php",
"keywords": [
"mustache",
"templating"
],
"support": {
"issues": "https://github.com/bobthecow/mustache.php/issues",
"source": "https://github.com/bobthecow/mustache.php/tree/master"
},
"time": "2019-11-23T21:40:31+00:00"
},
{
"name": "php-parallel-lint/php-parallel-lint",
"version": "v1.3.0",
"source": {
"type": "git",
"url": "https://github.com/php-parallel-lint/PHP-Parallel-Lint.git",
"reference": "772a954e5f119f6f5871d015b23eabed8cbdadfb"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-parallel-lint/PHP-Parallel-Lint/zipball/772a954e5f119f6f5871d015b23eabed8cbdadfb",
"reference": "772a954e5f119f6f5871d015b23eabed8cbdadfb",
"shasum": ""
},
"require": {
"ext-json": "*",
"php": ">=5.3.0"
},
"replace": {
"grogy/php-parallel-lint": "*",
"jakub-onderka/php-parallel-lint": "*"
},
"require-dev": {
"nette/tester": "^1.3 || ^2.0",
"php-parallel-lint/php-console-highlighter": "~0.3",
"squizlabs/php_codesniffer": "^3.5"
},
"suggest": {
"php-parallel-lint/php-console-highlighter": "Highlight syntax in code snippet"
},
"bin": [
"parallel-lint"
],
"type": "library",
"autoload": {
"classmap": [
"./"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-2-Clause"
],
"authors": [
{
"name": "Jakub Onderka",
"email": "ahoj@jakubonderka.cz"
}
],
"description": "This tool check syntax of PHP files about 20x faster than serial check.",
"homepage": "https://github.com/php-parallel-lint/PHP-Parallel-Lint",
"support": {
"issues": "https://github.com/php-parallel-lint/PHP-Parallel-Lint/issues",
"source": "https://github.com/php-parallel-lint/PHP-Parallel-Lint/tree/v1.3.0"
},
"time": "2021-04-07T14:42:48+00:00"
},
{
"name": "rmccue/requests",
"version": "v1.8.0",
"source": {
"type": "git",
"url": "https://github.com/WordPress/Requests.git",
"reference": "afbe4790e4def03581c4a0963a1e8aa01f6030f1"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/WordPress/Requests/zipball/afbe4790e4def03581c4a0963a1e8aa01f6030f1",
"reference": "afbe4790e4def03581c4a0963a1e8aa01f6030f1",
"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.0"
},
"time": "2021-04-27T11:05:25+00:00"
},
{
"name": "squizlabs/php_codesniffer",
"version": "3.6.0",
@ -122,6 +484,304 @@
},
"time": "2021-04-09T00:54:41+00:00"
},
{
"name": "symfony/finder",
"version": "v5.3.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/finder.git",
"reference": "0ae3f047bed4edff6fd35b26a9a6bfdc92c953c6"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/finder/zipball/0ae3f047bed4edff6fd35b26a9a6bfdc92c953c6",
"reference": "0ae3f047bed4edff6fd35b26a9a6bfdc92c953c6",
"shasum": ""
},
"require": {
"php": ">=7.2.5"
},
"type": "library",
"autoload": {
"psr-4": {
"Symfony\\Component\\Finder\\": ""
},
"exclude-from-classmap": [
"/Tests/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Finds files and directories via an intuitive fluent interface",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/finder/tree/v5.3.0"
},
"funding": [
{
"url": "https://symfony.com/sponsor",
"type": "custom"
},
{
"url": "https://github.com/fabpot",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
"type": "tidelift"
}
],
"time": "2021-05-26T12:52:38+00:00"
},
{
"name": "wp-cli/i18n-command",
"version": "v2.2.8",
"source": {
"type": "git",
"url": "https://github.com/wp-cli/i18n-command.git",
"reference": "8bc234617edc533590ac0f41080164a8d85ec9ce"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/wp-cli/i18n-command/zipball/8bc234617edc533590ac0f41080164a8d85ec9ce",
"reference": "8bc234617edc533590ac0f41080164a8d85ec9ce",
"shasum": ""
},
"require": {
"gettext/gettext": "^4.8",
"mck89/peast": "^1.8",
"wp-cli/wp-cli": "^2.5"
},
"require-dev": {
"wp-cli/scaffold-command": "^1.2 || ^2",
"wp-cli/wp-cli-tests": "^3.0.11"
},
"type": "wp-cli-package",
"extra": {
"branch-alias": {
"dev-master": "2.x-dev"
},
"bundled": true,
"commands": [
"i18n",
"i18n make-pot",
"i18n make-json"
]
},
"autoload": {
"psr-4": {
"WP_CLI\\I18n\\": "src/"
},
"files": [
"i18n-command.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Pascal Birchler",
"homepage": "https://pascalbirchler.com/"
}
],
"description": "Provides internationalization tools for WordPress projects.",
"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.2.8"
},
"time": "2021-05-10T10:24:16+00:00"
},
{
"name": "wp-cli/mustangostang-spyc",
"version": "0.6.3",
"source": {
"type": "git",
"url": "https://github.com/wp-cli/spyc.git",
"reference": "6aa0b4da69ce9e9a2c8402dab8d43cf32c581cc7"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/wp-cli/spyc/zipball/6aa0b4da69ce9e9a2c8402dab8d43cf32c581cc7",
"reference": "6aa0b4da69ce9e9a2c8402dab8d43cf32c581cc7",
"shasum": ""
},
"require": {
"php": ">=5.3.1"
},
"require-dev": {
"phpunit/phpunit": "4.3.*@dev"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "0.5.x-dev"
}
},
"autoload": {
"psr-4": {
"Mustangostang\\": "src/"
},
"files": [
"includes/functions.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "mustangostang",
"email": "vlad.andersen@gmail.com"
}
],
"description": "A simple YAML loader/dumper class for PHP (WP-CLI fork)",
"homepage": "https://github.com/mustangostang/spyc/",
"support": {
"source": "https://github.com/wp-cli/spyc/tree/autoload"
},
"time": "2017-04-25T11:26:20+00:00"
},
{
"name": "wp-cli/php-cli-tools",
"version": "v0.11.12",
"source": {
"type": "git",
"url": "https://github.com/wp-cli/php-cli-tools.git",
"reference": "e472e08489f7504d9e8c5c5a057e1419cd1b2b3e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/wp-cli/php-cli-tools/zipball/e472e08489f7504d9e8c5c5a057e1419cd1b2b3e",
"reference": "e472e08489f7504d9e8c5c5a057e1419cd1b2b3e",
"shasum": ""
},
"require": {
"php": ">= 5.3.0"
},
"type": "library",
"autoload": {
"psr-0": {
"cli": "lib/"
},
"files": [
"lib/cli/cli.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Daniel Bachhuber",
"email": "daniel@handbuilt.co",
"role": "Maintainer"
},
{
"name": "James Logsdon",
"email": "jlogsdon@php.net",
"role": "Developer"
}
],
"description": "Console utilities for PHP",
"homepage": "http://github.com/wp-cli/php-cli-tools",
"keywords": [
"cli",
"console"
],
"support": {
"issues": "https://github.com/wp-cli/php-cli-tools/issues",
"source": "https://github.com/wp-cli/php-cli-tools/tree/v0.11.12"
},
"time": "2021-03-03T12:43:49+00:00"
},
{
"name": "wp-cli/wp-cli",
"version": "v2.5.0",
"source": {
"type": "git",
"url": "https://github.com/wp-cli/wp-cli.git",
"reference": "0bcf0c54f4d35685211d435e25219cc7acbe6d48"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/wp-cli/wp-cli/zipball/0bcf0c54f4d35685211d435e25219cc7acbe6d48",
"reference": "0bcf0c54f4d35685211d435e25219cc7acbe6d48",
"shasum": ""
},
"require": {
"ext-curl": "*",
"mustache/mustache": "~2.13",
"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"
},
"require-dev": {
"roave/security-advisories": "dev-master",
"wp-cli/db-command": "^1.3 || ^2",
"wp-cli/entity-command": "^1.2 || ^2",
"wp-cli/extension-command": "^1.1 || ^2",
"wp-cli/package-command": "^1 || ^2",
"wp-cli/wp-cli-tests": "^3.0.7"
},
"suggest": {
"ext-readline": "Include for a better --prompt implementation",
"ext-zip": "Needed to support extraction of ZIP archives when doing downloads or updates"
},
"bin": [
"bin/wp",
"bin/wp.bat"
],
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.5.x-dev"
}
},
"autoload": {
"psr-0": {
"WP_CLI\\": "php/"
},
"classmap": [
"php/class-wp-cli.php",
"php/class-wp-cli-command.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"description": "WP-CLI framework",
"homepage": "https://wp-cli.org",
"keywords": [
"cli",
"wordpress"
],
"support": {
"docs": "https://make.wordpress.org/cli/handbook/",
"issues": "https://github.com/wp-cli/wp-cli/issues",
"source": "https://github.com/wp-cli/wp-cli"
},
"time": "2021-05-14T13:44:51+00:00"
},
{
"name": "wp-coding-standards/wpcs",
"version": "2.3.0",

View File

@ -1,73 +0,0 @@
<?php
namespace PluginNamespace;
class Settings {
/**
* Class constructor.
*
* @since 1.0.0
*
* @return void
*/
public function __construct() {
add_action( 'admin_menu', array( $this, 'append_to_admin_menu' ), 12 );
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
}
/**
* Append to the admin menu (prevents doubling).
*
* @since 1.0.0
*
* @return void
*/
public function append_to_admin_menu(): void {
$parent_slug = 'nmsp-plugin-name-menu-slug';
$page_title = __( 'Namespace Plugin Name - Settings', 'nmsp_plugin_name_settings_title' );
$menu_title = __( 'Settings', 'nmsp_plugin_name_settings_title' );
$capability = 'manage_options';
$menu_slug = $parent_slug;
$callback = array( $this, 'show_main_settings_page' );
add_submenu_page( $parent_slug, $page_title, $menu_title, $capability, $menu_slug, $callback );
}
/**
* Show the settings page.
*
* @since 1.0.0
*
* @return void
*/
public function show_main_settings_page(): void {
$data = array();
echo nmsp_plugin_app()->blade->run( 'admin.settings', $data );
}
/**
* Register and enqueue stylesheets and javascript files.
*
* @since 1.0.0
*
* @return void
*/
public function enqueue_scripts(): void {
wp_enqueue_style( 'nmsp-plugin-name-admin-css', plugins_url( '../../assets/css/nmsp-plugin-name-admin.css', __FILE__ ), array(), '1.0.0', 'screen' );
wp_register_script( 'nmsp-plugin-name-admin-js', plugins_url( '../../assets/js/nmsp-plugin-name-admin.js', __FILE__ ), array( 'jquery' ), '1.0.0', false );
wp_enqueue_script( 'nmsp-plugin-name-admin-js' );
$payload = array(
'wp_ajax_url' => admin_url( 'admin-ajax.php' ),
'_nonce' => wp_create_nonce( NMSP_PLUGIN_NONCE ),
);
wp_localize_script( 'nmsp-plugin-name-admin-js', 'nmspPluginAdminApi', $payload );
}
}
new Settings();

View File

@ -139,7 +139,7 @@ class App {
public function includes(): void {
// Files to include on the admin.
if ( is_admin() ) {
require_once __DIR__ . '/admin/class-settings.php';
require_once NMSP_PLUGIN_BASE_DIR . '/admin/class-settings.php';
}
//
@ -147,13 +147,11 @@ class App {
//
// Files to include that may be sub-namespaced.
if ( is_single() ) {
require_once __DIR__ . '/front/class-custompage.php';
}
}
/**
* .
* Load Blade as the templating engine for the plugin.
*
* @since 1.0.0
*

View File

@ -29,7 +29,7 @@ class NmspCli {
}
/**
* A sample method where something is done.
* A sample method where something is done by being invoked from WP CLI.
*
* @since 1.0.0
*

View File

@ -53,9 +53,10 @@ class CustomPage {
),
);
// phpcs:disable WordPress.Security.EscapeOutput
return nmsp_plugin_app()->blade->run( 'front.custom-page', $data );
// phpcs:enable WordPress.Security.EscapeOutput
ob_start();
echo nmsp_plugin_app()->blade->run( 'front.custom-page', $data );
$output = ob_get_clean();
return wp_kses_post( $output );
}
}

1
includes/front/index.php Normal file
View File

@ -0,0 +1 @@
<?php // silence is golden

1
includes/index.php Normal file
View File

@ -0,0 +1 @@
<?php // silence is golden

1
index.php Normal file
View File

@ -0,0 +1 @@
<?php // silence is golden

View File

@ -1,17 +1,26 @@
<?php
use PluginNamespace\App;
use eftec\bladeone\BladeOne;
/*
Plugin Name: Boilerplate Plugin
Plugin URI: https://domain.com
Description: Your plugin description
Version: 1.0.0
Author: Plugin Author
Author URI: https://plugin-author.com
License: GPL v2
Text Domain: nmsp-plugin-name-text-domain
/**
* Boilerplate Plugin
*
* @package BoilerplatePlugin
* @author
* @copyright
* @license
*
* @wordpress-plugin
* Plugin Name: Boilerplate Plugin
* Description: Your plugin description.
* License: GPL v2
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
* Plugin URI: https://domain.com
* Update URI: https://example.com/my-plugin/
* Version: 1.0.0
* Requires at least: 5.2
* Requires PHP: 7.2
* Author: Plugin Author
* Author URI: https://plugin-author.com
* Text Domain: nmsp-plugin-name-text-domain
*/
if ( ! defined( 'ABSPATH' ) ) {
@ -28,9 +37,10 @@ if ( defined( 'WP_CLI' ) && WP_CLI ) {
require_once __DIR__ . '/includes/class-nmspcli.php';
}
$blade = new BladeOne( __DIR__ . '/templates', __DIR__ . '/cache/blade', BladeOne::MODE_DEBUG ); // BladeOne::MODE_AUTO
$mode = \eftec\bladeone\BladeOne::MODE_AUTO; // Can also be MODE_DEBUG
$blade = new \eftec\bladeone\BladeOne( __DIR__ . '/templates', __DIR__ . '/cache/blade', $mode );
register_activation_hook( __FILE__, array( App::class, 'plugin_activation' ) );
register_deactivation_hook( __FILE__, array( App::class, 'plugin_deactivation') );
register_activation_hook( __FILE__, array( \PluginNamespace\App::class, 'plugin_activation' ) );
register_deactivation_hook( __FILE__, array( \PluginNamespace\App::class, 'plugin_deactivation' ) );
nmsp_plugin_app()->load_blade( $blade );

View File

@ -2,7 +2,7 @@
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="PHP_CodeSniffer" xsi:noNamespaceSchemaLocation="phpcs.xsd">
<description>CodeSniffing standards for this project.</description>
<config name="installed_paths" value="./vendor/wp-coding-standards/wpcs" />
<config name="installed_paths" value="vendor/wp-coding-standards/wpcs" />
<file>bootstrap.php</file>
<file>nmsp-plugin-name.php</file>
@ -10,9 +10,16 @@
<file>constants</file>
<file>includes</file>
<exclude-pattern>*/assets/*$</exclude-pattern>
<exclude-pattern>*/cache/*$</exclude-pattern>
<exclude-pattern>*/languages/*$</exclude-pattern>
<exclude-pattern>*/node_modules/*$</exclude-pattern>
<exclude-pattern>*/resources/*$</exclude-pattern>
<exclude-pattern>*/tests/*$</exclude-pattern>
<exclude-pattern>*/vendor/*$</exclude-pattern>
<arg name="basepath" value="./" />
<arg name="colors" />
<arg name="parallel" value="75" />
<arg name="report" value="full" />
<arg name="extensions" value="php" />
<arg value="nps" />