Skip to content
Snippets Groups Projects
Commit 586a44df authored by Sebastian Pisula's avatar Sebastian Pisula
Browse files

Merge branch 'feature/upgrade-template' into 'master'

feature(core): plugin template changes

See merge request !40
parents 17550d61 fd437c10
No related branches found
Tags 2.4.0
1 merge request!40feature(core): plugin template changes
...@@ -4,6 +4,8 @@ ...@@ -4,6 +4,8 @@
# WordPress Coding Standards # WordPress Coding Standards
# https://make.wordpress.org/core/handbook/coding-standards/ # https://make.wordpress.org/core/handbook/coding-standards/
# Configuration for PhpStorm
root = true root = true
[*] [*]
...@@ -12,10 +14,76 @@ end_of_line = lf ...@@ -12,10 +14,76 @@ end_of_line = lf
insert_final_newline = true insert_final_newline = true
trim_trailing_whitespace = true trim_trailing_whitespace = true
indent_style = tab indent_style = tab
indent_size = 4
tab_width = 4
ij_continuation_indent_size = 4
[{*.scss,*.css}]
ij_scss_enforce_quotes_on_format = true
ij_scss_hex_color_long_format = true
ij_scss_hex_color_lower_case = true
[{*.cjs,*.js}]
ij_javascript_do_while_brace_force = always
ij_javascript_if_brace_force = always
ij_javascript_import_sort_module_name = true
ij_javascript_reformat_c_style_comments = true
ij_javascript_space_after_unary_not = true
ij_javascript_space_before_unary_not = true
ij_javascript_spaces_within_array_initializer_brackets = true
ij_javascript_spaces_within_brackets = true
ij_javascript_spaces_within_catch_parentheses = true
ij_javascript_spaces_within_for_parentheses = true
ij_javascript_spaces_within_if_parentheses = true
ij_javascript_spaces_within_imports = true
ij_javascript_spaces_within_interpolation_expressions = true
ij_javascript_spaces_within_method_call_parentheses = true
ij_javascript_spaces_within_method_parentheses = true
ij_javascript_spaces_within_object_literal_braces = true
ij_javascript_spaces_within_parentheses = true
ij_javascript_spaces_within_switch_parentheses = true
ij_javascript_spaces_within_while_parentheses = true
ij_javascript_while_brace_force = always
[*.yml] [{*.ctp,*.hphp,*.inc,*.module,*.php,*.php4,*.php5,*.phtml}]
indent_style = space ij_php_align_assignments = true
indent_size = 2 ij_php_align_class_constants = true
ij_php_align_key_value_pairs = true
ij_php_align_phpdoc_comments = true
ij_php_align_phpdoc_param_names = true
ij_php_class_brace_style = end_of_line
ij_php_comma_after_last_array_element = true
ij_php_else_if_style = combine
ij_php_force_short_declaration_array_style = true
ij_php_getters_setters_naming_style = snake_case
ij_php_if_brace_force = always
ij_php_lower_case_boolean_const = true
ij_php_lower_case_null_const = true
ij_php_method_brace_style = end_of_line
ij_php_phpdoc_blank_line_before_tags = true
ij_php_phpdoc_blank_lines_around_parameters = true
ij_php_phpdoc_keep_blank_lines = false
ij_php_phpdoc_wrap_long_lines = true
ij_php_space_after_type_cast = true
ij_php_space_after_unary_not = true
ij_php_space_before_unary_not = true
ij_php_spaces_around_var_within_brackets = true
ij_php_spaces_within_array_initializer_braces = true
ij_php_spaces_within_catch_parentheses = true
ij_php_spaces_within_for_parentheses = true
ij_php_spaces_within_if_parentheses = true
ij_php_spaces_within_method_call_parentheses = true
ij_php_spaces_within_method_parentheses = true
ij_php_spaces_within_parentheses = true
ij_php_spaces_within_switch_parentheses = true
ij_php_spaces_within_while_parentheses = true
ij_php_ternary_operation_signs_on_next_line = true
ij_php_variable_naming_style = snake_case
[*.md] [{*.htm,*.html,*.ng,*.sht,*.shtm,*.shtml}]
trim_trailing_whitespace = false ij_html_add_new_line_before_tags = div,p,a
\ No newline at end of file ij_html_align_attributes = false
ij_html_do_not_indent_children_of_tags = html,thead,tbody,tfoot
ij_html_new_line_after_last_attribute = when multiline
ij_html_space_inside_empty_tag = true
ij_html_uniform_ident = true
...@@ -15,3 +15,5 @@ TEST_SITE_WP_DOMAIN="${WOOTESTS_IP}" ...@@ -15,3 +15,5 @@ TEST_SITE_WP_DOMAIN="${WOOTESTS_IP}"
TEST_SITE_ADMIN_EMAIL="grola@seostudio.pl" TEST_SITE_ADMIN_EMAIL="grola@seostudio.pl"
TEST_SITE_ADMIN_USERNAME="admin" TEST_SITE_ADMIN_USERNAME="admin"
TEST_SITE_ADMIN_PASSWORD="admin" TEST_SITE_ADMIN_PASSWORD="admin"
SELENIUM_HOST="chrome"
SELENIUM_PORT=4444
...@@ -9,3 +9,7 @@ build-coverage ...@@ -9,3 +9,7 @@ build-coverage
/lang/* /lang/*
!/lang/*_*.po !/lang/*_*.po
/lang/*-*_*.po /lang/*-*_*.po
/.plugin-version
/.release-notes
/assets/dist/
/node_modules/
...@@ -2,5 +2,12 @@ variables: ...@@ -2,5 +2,12 @@ variables:
DISABLE_PHP_5_5: 1 DISABLE_PHP_5_5: 1
DISABLE_ACCEPTANCE: "1" DISABLE_ACCEPTANCE: "1"
DISABLE_FUNCTIONAL: "1" DISABLE_FUNCTIONAL: "1"
DISABLE_INTEGRATION_TESTS: "1"
DISABLE_CODECEPTION: 1
CODECEPTION_PARALLEL: 1
include: 'https://gitlab.com/wpdesk/gitlab-ci/raw/master/gitlab-ci-free.yml'
integration:earliest:
when: manual
include: 'https://gitlab.com/wpdesk/gitlab-ci/raw/master/gitlab-ci-shop.yml'
( function ( $ ) {
} )( jQuery );
File moved
...@@ -11,6 +11,7 @@ extensions: ...@@ -11,6 +11,7 @@ extensions:
# - Codeception\Extension\Recorder: # - Codeception\Extension\Recorder:
# module: WPWebDriver # module: WPWebDriver
# delete_successful: false # keep screenshots of successful tests # delete_successful: false # keep screenshots of successful tests
# delete_orphaned: true #delete recording folders created via previous runs
commands: commands:
- Codeception\Command\GenerateWPUnit - Codeception\Command\GenerateWPUnit
- Codeception\Command\GenerateWPRestApi - Codeception\Command\GenerateWPRestApi
......
...@@ -8,35 +8,42 @@ ...@@ -8,35 +8,42 @@
], ],
"autoload": { "autoload": {
"psr-4": { "psr-4": {
"WPDesk\\PluginTemplate\\": "src/Plugin" "WPDesk\\PluginTemplate\\": "src"
}, },
"classmap": [ "classmap": [
"vendor_prefixed" "vendor_prefixed"
] ]
}, },
"autoload-dev": { "autoload-dev": {
"classmap": [
"tests/unit",
"tests/integration"
]
}, },
"config": { "config": {
"autoloader-suffix": "PluginTemplate",
"sort-packages": true, "sort-packages": true,
"platform": { "platform": {
"php": "7.0" "php": "7.2"
},
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true,
"cweagans/composer-patches": true,
"wpdesk/wp-codeception": true,
"wpdesk/wp-wpdesk-composer": true,
"kylekatarnls/update-helper": true
} }
}, },
"prefer-stable": true,
"minimum-stability": "stable",
"require": { "require": {
"php": ">=7.0", "php": ">=7.2",
"wpdesk/wp-wpdesk-helper-override": "^1.1.0", "psr/log": "^1.1.4",
"psr/log": "^1.0.1" "wpdesk/wp-wpdesk-helper-override": "^1.1.0"
}, },
"require-dev": { "require-dev": {
"10up/wp_mock": "*", "10up/wp_mock": "*",
"wpdesk/wp-plugin-flow": "^2",
"phpunit/phpunit": "<7", "phpunit/phpunit": "<7",
"wpdesk/wp-wpdesk-composer": "^2" "wpdesk/wp-builder": "^2.0.0",
"wpdesk/wp-codeception": "^2.7.4",
"wpdesk/wp-plugin-flow-free": "^1.0.2",
"wpdesk/wp-wpdesk-composer": "^2.20.0"
}, },
"extra": { "extra": {
"text-domain": "plugin-template", "text-domain": "plugin-template",
...@@ -48,12 +55,15 @@ ...@@ -48,12 +55,15 @@
}, },
"po-files": { "po-files": {
"pl_PL": "pl_PL.po" "pl_PL": "pl_PL.po"
} },
"php-requires": "7.2"
}, },
"scripts": { "scripts": {
"test": "echo composer is alive", "test": "echo composer is alive",
"phpcs": "phpcs", "phpcs": "phpcs",
"phpcbf": "phpcbf src",
"phpunit-unit": "phpunit --configuration phpunit-unit.xml --coverage-text --colors=never", "phpunit-unit": "phpunit --configuration phpunit-unit.xml --coverage-text --colors=never",
"phpunit-unit-coverage": "phpunit --configuration phpunit-unit.xml --coverage-html build-coverage",
"phpunit-integration": "phpunit --configuration phpunit-integration.xml --coverage-text --colors=never", "phpunit-integration": "phpunit --configuration phpunit-integration.xml --coverage-text --colors=never",
"docs": "apigen generate" "docs": "apigen generate"
} }
......
This diff is collapsed.
*
!.gitignore
!pl_PL.po
...@@ -3,8 +3,8 @@ msgstr "" ...@@ -3,8 +3,8 @@ msgstr ""
"Project-Id-Version: Plugin Template\n" "Project-Id-Version: Plugin Template\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-11-29 20:03+0100\n" "POT-Creation-Date: 2019-11-29 20:03+0100\n"
"PO-Revision-Date: 2019-11-29 20:03+0100\n" "PO-Revision-Date: 2022-09-21 15:31+0200\n"
"Last-Translator: Krzysztof Dyszczyk <krzysztof.dyszczyk@gmail.com>\n" "Last-Translator: Sebastian Pisula <sebastian.pisula@gmail.com>\n"
"Language-Team: Polish\n" "Language-Team: Polish\n"
"Language: pl_PL\n" "Language: pl_PL\n"
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
...@@ -12,16 +12,30 @@ msgstr "" ...@@ -12,16 +12,30 @@ msgstr ""
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=3; plural=(n==1 ? 0 : n%10 >= 2 && n%10<=4 &&(n" "Plural-Forms: nplurals=3; plural=(n==1 ? 0 : n%10 >= 2 && n%10<=4 &&(n"
"%100<10||n%100 >= 20)? 1 : 2);\n" "%100<10||n%100 >= 20)? 1 : 2);\n"
"X-Generator: Poedit 2.2.4\n"
"X-Loco-Version: 2.3.0; wp-5.2.2X-Poedit-Basepath: ..\n"
"Plural-Forms: nplurals=3; plural=(n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 " "Plural-Forms: nplurals=3; plural=(n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 "
"|| n%100>=20) ? 1 : 2);\n" "|| n%100>=20) ? 1 : 2);\n"
"X-Generator: Poedit 3.1.1\n"
"X-Poedit-SourceCharset: UTF-8\n" "X-Poedit-SourceCharset: UTF-8\n"
"X-Poedit-KeywordsList: __;_e;_n:1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;esc_attr__;" "X-Poedit-KeywordsList: __;_e;_n:1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;esc_attr__;"
"esc_attr_e;esc_attr_x:1,2c;esc_html__;esc_html_e;esc_html_x:1,2c;_n_noop:1,2;" "esc_attr_e;esc_attr_x:1,2c;esc_html__;esc_html_e;esc_html_x:1,2c;_n_noop:1,2;"
"_nx_noop:3c,1,2;__ngettext_noop:1,2\n" "_nx_noop:3c,1,2;__ngettext_noop:1,2\n"
"X-Poedit-Basepath: ..\n" "X-Poedit-Basepath: ..\n"
"X-Poedit-SearchPath-0: .\n" "X-Poedit-WPHeader: plugin-template.php\n"
"X-Poedit-SearchPathExcluded-0: *.js\n" "X-Poedit-SearchPath-0: src\n"
"X-Poedit-SearchPathExcluded-1: vendor\n"
"X-Poedit-SearchPathExcluded-2: vendor_prefixed\n" #. Plugin Name of the plugin/theme
#. Description of the plugin/theme
msgid "WP Desk Plugin Template"
msgstr ""
#. Plugin URI of the plugin/theme
msgid "https://www.wpdesk.net/products/plugin-template/"
msgstr ""
#. Author of the plugin/theme
msgid "WP Desk"
msgstr ""
#. Author URI of the plugin/theme
msgid "https://www.wpdesk.net/"
msgstr ""
This diff is collapsed.
{
"name": "plugin-assets",
"version": "1.0.0",
"main": "webpack.mix.js",
"author": "sebastian.pisula@octolize.com",
"dependencies": {
"@wordpress/i18n": "^4.17.0"
},
"devDependencies": {
"mati-mix": "^2.1.1",
"sass": "^1.54.9",
"sass-loader": "^13.0.2",
"style-loader": "^3.3.1"
},
"scripts": {
"development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --config=node_modules/laravel-mix/setup/webpack.config.js",
"production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --config=node_modules/laravel-mix/setup/webpack.config.js",
"dev": "npm run development",
"watch": "npm run development -- --watch",
"prod": "npm run production"
}
}
...@@ -2,19 +2,14 @@ ...@@ -2,19 +2,14 @@
<ruleset name="WordPress Coding Standards for WP Desk Plugin"> <ruleset name="WordPress Coding Standards for WP Desk Plugin">
<description>Sniffs for WordPress WPDesk plugins</description> <description>Sniffs for WordPress WPDesk plugins</description>
<config name="testVersion" value="5.6-"/> <config name="testVersion" value="7.2-"/>
<config name="text_domain" value="plugin-template"/> <config name="text_domain" value="plugin-template"/>
<arg name="extensions" value="php"/>
<file>./src</file>
<exclude-pattern>*/settings-api/*</exclude-pattern>
<exclude-pattern>tests/*</exclude-pattern> <exclude-pattern>tests/*</exclude-pattern>
<exclude-pattern>scoper\.inc\.php</exclude-pattern> <exclude-pattern>scoper.inc.php</exclude-pattern>
<exclude-pattern>webpack.mix.js</exclude-pattern>
<rule ref="PHPCompatibility"/> <rule ref="WPDeskPlugin"/>
<rule ref="WordPress"/>
<!-- Remove checking if classes are in class- files --> <!-- Remove checking if classes are in class- files -->
<rule ref="WordPress.Files.FileName"> <rule ref="WordPress.Files.FileName">
...@@ -25,7 +20,4 @@ ...@@ -25,7 +20,4 @@
<exclude-pattern>/src/.*\.php</exclude-pattern> <exclude-pattern>/src/.*\.php</exclude-pattern>
</rule> </rule>
<rule ref="WordPress.NamingConventions.ValidVariableName">
<exclude-pattern>/src/.*\.php</exclude-pattern>
</rule>
</ruleset> </ruleset>
# Start command: composer update --classmap-authoritative && vendor/bin/phpstan analyze # Start command: composer update --classmap-authoritative && vendor/bin/phpstan analyze
includes: includes:
# https://github.com/phpstan/phpstan/blob/master/conf/bleedingEdge.neon
- vendor/wpdesk/wp-wpdesk-composer/director/vendor/phpstan/phpstan/conf/bleedingEdge.neon - vendor/wpdesk/wp-wpdesk-composer/director/vendor/phpstan/phpstan/conf/bleedingEdge.neon
# - phar://phpstan.phar/conf/bleedingEdge.neon
- vendor/wpdesk/wp-wpdesk-composer/director/vendor/szepeviktor/phpstan-wordpress/extension.neon - vendor/wpdesk/wp-wpdesk-composer/director/vendor/szepeviktor/phpstan-wordpress/extension.neon
parameters: parameters:
level: max level: max
paths: paths:
- %currentWorkingDirectory%/src/ - %currentWorkingDirectory%/src/
bootstrapFiles: bootstrapFiles:
- %rootDir%/../../php-stubs/wordpress-stubs/wordpress-stubs.php - %currentWorkingDirectory%/vendor/autoload.php
- %currentWorkingDirectory%/vendor/wpdesk/wp-wpdesk-composer/director/woocommerce-stubs.php - %currentWorkingDirectory%/vendor/wpdesk/wp-wpdesk-composer/director/woocommerce-stubs.php
- %currentWorkingDirectory%/vendor/wpdesk/wp-wpdesk-composer/director/woocommerce-packages-stubs.php
excludes_analyse:
- %currentWorkingDirectory%/src/Plugin/view/
ignoreErrors: ignoreErrors:
- '/PluginTemplateVendor\\WPDesk_Plugin_Info/'
# autoload_files:
# # Missing constants, function and class stubs
# - %currentWorkingDirectory%/tests/phpstan/bootstrap.php
# # Plugin stubs
# - %currentWorkingDirectory%/tests/phpstan/PLUGIN-stubs.php
# # Procedural code
# - %currentWorkingDirectory%/myplugin-functions.php
# autoload_directories:
# - %currentWorkingDirectory%/../woocommerce/
...@@ -10,10 +10,6 @@ ...@@ -10,10 +10,6 @@
<filter> <filter>
<whitelist> <whitelist>
<directory suffix=".php">src</directory> <directory suffix=".php">src</directory>
<exclude>
<directory suffix=".php">src/WooCommerceShipping/CustomFields/Templates</directory>
<directory suffix=".php">src/plugin/view</directory>
</exclude>
</whitelist> </whitelist>
</filter> </filter>
......
...@@ -8,10 +8,6 @@ ...@@ -8,10 +8,6 @@
<filter> <filter>
<whitelist> <whitelist>
<directory suffix=".php">src</directory> <directory suffix=".php">src</directory>
<exclude>
<directory suffix=".php">src/WooCommerceShipping/CustomFields/Templates</directory>
<directory suffix=".php">src/plugin/view</directory>
</exclude>
</whitelist> </whitelist>
</filter> </filter>
......
<?php <?php
/** /**
Plugin Name: WP Desk Plugin Template * Plugin Name: WP Desk Plugin Template
Plugin URI: https://www.wpdesk.net/products/plugin-template/ * Plugin URI: https://www.wpdesk.net/products/plugin-template/
Description: WP Desk Plugin Template * Description: WP Desk Plugin Template
Product: WP Desk Plugin Template * Product: WP Desk Plugin Template
Version: 1.0 * Version: 1.0
Author: WP Desk * Author: WP Desk
Author URI: https://www.wpdesk.net/ * Author URI: https://www.wpdesk.net/
Text Domain: plugin-template * Text Domain: plugin-template
Domain Path: /lang/ * Domain Path: /lang/
* ​
@package \WPDesk\PluginTemplate * Requires at least: 5.7
* Tested up to: 6.0
Copyright 2021 WP Desk Ltd. * WC requires at least: 6.6
* WC tested up to: 7.0
This program is free software; you can redistribute it and/or modify * Requires PHP: 7.2
it under the terms of the GNU General Public License as published by *
the Free Software Foundation; either version 2 of the License, or * @package \WPDesk\PluginTemplate
(at your option) any later version. * ​
* Copyright 2022 WP Desk Ltd.
This program is distributed in the hope that it will be useful, * ​
but WITHOUT ANY WARRANTY; without even the implied warranty of * This program is free software; you can redistribute it and/or modify
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * it under the terms of the GNU General Public License as published by
GNU General Public License for more details. * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
You should have received a copy of the GNU General Public License * This program is distributed in the hope that it will be useful,
along with this program; if not, write to the Free Software * but WITHOUT ANY WARRANTY; without even the implied warranty of
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
if ( ! defined( 'ABSPATH' ) ) { use WPDesk\PluginTemplate\Plugin;
exit;
} // Exit if accessed directly defined( 'ABSPATH' ) || exit;
require_once __DIR__ . '/vendor/autoload.php';
/* THESE TWO VARIABLES CAN BE CHANGED AUTOMATICALLY */ /* THESE TWO VARIABLES CAN BE CHANGED AUTOMATICALLY */
$plugin_version = '1.0.0'; $plugin_version = '1.0.0';
$plugin_name = 'WP Desk Plugin Template'; $plugin_name = 'WP Desk Plugin Template';
$plugin_class_name = '\WPDesk\PluginTemplate\Plugin'; $plugin_class_name = Plugin::class;
$plugin_text_domain = 'plugin-template'; $plugin_text_domain = 'plugin-template';
$product_id = 'plugin-template'; $product_id = 'WP Desk Plugin Template';
$plugin_file = __FILE__; $plugin_file = __FILE__;
$plugin_dir = dirname( __FILE__ ); $plugin_dir = __DIR__;
// todo: only for paid plugins.
$plugin_shops = [
'default' => 'https://www.wpdesk.net/',
];
$requirements = [ $requirements = [
'php' => '7.0', 'php' => '7.2',
'wp' => '5.0', 'wp' => '5.7',
'plugins' => [ 'plugins' => [
[ [
'name' => 'woocommerce/woocommerce.php', 'name' => 'woocommerce/woocommerce.php',
'nice_name' => 'WooCommerce', 'nice_name' => 'WooCommerce',
'version' => '4.7', 'version' => '6.6',
], ],
], ],
]; ];
require __DIR__ . '/vendor_prefixed/wpdesk/wp-plugin-flow/src/plugin-init-php52.php'; // todo: only for free plugins.
require __DIR__ . '/vendor_prefixed/wpdesk/wp-plugin-flow-common/src/plugin-init-php52-free.php';
<?php <?php
declare(strict_types=1); declare( strict_types=1 );
use Isolated\Symfony\Component\Finder\Finder; use Isolated\Symfony\Component\Finder\Finder;
return [ return [
// The prefix configuration. If a non null value will be used, a random prefix will be generated. // The prefix configuration. If a non null value will be used, a random prefix will be generated.
'prefix' => 'PluginTemplateVendor', 'prefix' => 'PluginTemplateVendor',
// By default when running php-scoper add-prefix, it will prefix all relevant code found in the current working // By default when running php-scoper add-prefix, it will prefix all relevant code found in the current working
// directory. You can however define which files should be scoped by defining a collection of Finders in the // directory. You can however define which files should be scoped by defining a collection of Finders in the
// following configuration key. // following configuration key.
// //
// For more see: https://github.com/humbug/php-scoper#finders-and-paths // For more see: https://github.com/humbug/php-scoper#finders-and-paths
'finders' => [ 'finders' => [
Finder::create() Finder::create()
->files() ->files()
->ignoreVCS(true) ->ignoreVCS( true )
->name(['*.php', 'composer.json', '*.css', '*.js', '*.jpg', '*.png', '*.wsdl']) ->name( [ '*.php', 'composer.json', '*.css', '*.js', '*.jpg', '*.png', '*.wsdl' ] )
->exclude([ ->exclude( [
'doc', 'doc',
'test', 'test',
'test_old', 'test_old',
'tests', 'tests',
'Tests', 'Tests',
'vendor-bin', 'vendor-bin',
'wp-wpdesk-composer', 'wp-wpdesk-composer',
'wp-wpdesk-helper-override' 'wp-wpdesk-helper-override',
]) 'wp-code-sniffer',
->in(['vendor/monolog', 'vendor/wpdesk']), 'wp-codeception',
], ] )
->in( [ 'vendor/psr', 'vendor/wpdesk', ] ),
],
// Whitelists a list of files. Unlike the other whitelist related features, this one is about completely leaving // Whitelists a list of files. Unlike the other whitelist related features, this one is about completely leaving
// a file untouched. // a file untouched.
// Paths are relative to the configuration file unless if they are already absolute // Paths are relative to the configuration file unless if they are already absolute
'files-whitelist' => [ 'files-whitelist' => [
], ],
// When scoping PHP files, there will be scenarios where some of the code being scoped indirectly references the // When scoping PHP files, there will be scenarios where some of the code being scoped indirectly references the
// original namespace. These will include, for example, strings or string manipulations. PHP-Scoper has limited // original namespace. These will include, for example, strings or string manipulations. PHP-Scoper has limited
// support for prefixing such strings. To circumvent that, you can define patchers to manipulate the file to your // support for prefixing such strings. To circumvent that, you can define patchers to manipulate the file to your
// heart contents. // heart contents.
// //
// For more see: https://github.com/humbug/php-scoper#patchers // For more see: https://github.com/humbug/php-scoper#patchers
'patchers' => [ 'patchers' => [
], ],
// PHP-Scoper's goal is to make sure that all code for a project lies in a distinct PHP namespace. However, you // PHP-Scoper's goal is to make sure that all code for a project lies in a distinct PHP namespace. However, you
// may want to share a common API between the bundled code of your PHAR and the consumer code. For example if // may want to share a common API between the bundled code of your PHAR and the consumer code. For example if
// you have a PHPUnit PHAR with isolated code, you still want the PHAR to be able to understand the // you have a PHPUnit PHAR with isolated code, you still want the PHAR to be able to understand the
// PHPUnit\Framework\TestCase class. // PHPUnit\Framework\TestCase class.
// //
// A way to achieve this is by specifying a list of classes to not prefix with the following configuration key. Note // A way to achieve this is by specifying a list of classes to not prefix with the following configuration key. Note
// that this does not work with functions or constants neither with classes belonging to the global namespace. // that this does not work with functions or constants neither with classes belonging to the global namespace.
// //
// Fore more see https://github.com/humbug/php-scoper#whitelist // Fore more see https://github.com/humbug/php-scoper#whitelist
'whitelist' => [ 'whitelist' => [],
'ABSPATH',
'WPINC',
'WP_LANG_DIR',
'WP_PLUGIN_DIR',
'WP_PLUGIN_URL',
'WP_CONTENT_DIR',
'WP_CONTENT_URL',
'WP_HOME',
'WP_SITEURL',
'WP_TEMP_DIR',
'WPMU_PLUGIN_DIR',
'WPMU_PLUGIN_URL',
'DB_CHARSET',
'DB_COLLATE',
'DB_HOST',
'DB_NAME',
'DB_PASSWORD',
'DB_USER',
'DOING_AUTOSAVE',
'DOING_CRON',
'DOING_AUTOSAVE',
'WP_ADMIN',
'WP_BLOG_ADMIN',
'AUTOSAVE_INTERVAL',
'WPLANG',
'WP_DEFAULT_THEME',
'WP_CRON_LOCK_TIMEOUT',
'DISABLE_WP_CRON',
'WP_MAIL_INTERVAL',
'WP_MAIL_INTERVAL',
'WP_POST_REVISIONS',
'STYLESHEETPATH',
'TEMPLATEPATH',
'NONCE_SALT',
'NONCE_KEY',
'USER_COOKIE',
],
// If `true` then the user defined constants belonging to the global namespace will not be prefixed. // If `true` then the user defined constants belonging to the global namespace will not be prefixed.
// //
// For more see https://github.com/humbug/php-scoper#constants--constants--functions-from-the-global-namespace // For more see https://github.com/humbug/php-scoper#constants--constants--functions-from-the-global-namespace
'whitelist-global-constants' => false, 'whitelist-global-constants' => false,
// If `true` then the user defined functions belonging to the global namespace will not be prefixed. // If `true` then the user defined functions belonging to the global namespace will not be prefixed.
// //
// For more see https://github.com/humbug/php-scoper#constants--constants--functions-from-the-global-namespace // For more see https://github.com/humbug/php-scoper#constants--constants--functions-from-the-global-namespace
'whitelist-global-functions' => false, 'whitelist-global-functions' => false,
'whitelist-global-classes' => false, 'whitelist-global-classes' => false,
]; ];
<?php <?php
/** /**
* Plugin main class. * Plugin main class.
*
* @package WPDesk\PluginTemplate
*/ */
namespace WPDesk\PluginTemplate; namespace WPDesk\PluginTemplate;
use Psr\Log\LoggerAwareInterface;
use Psr\Log\LoggerAwareTrait;
use Psr\Log\NullLogger;
use PluginTemplateVendor\WPDesk_Plugin_Info;
use PluginTemplateVendor\WPDesk\PluginBuilder\Plugin\AbstractPlugin; use PluginTemplateVendor\WPDesk\PluginBuilder\Plugin\AbstractPlugin;
use PluginTemplateVendor\WPDesk\PluginBuilder\Plugin\HookableCollection; use PluginTemplateVendor\WPDesk\PluginBuilder\Plugin\HookableCollection;
use PluginTemplateVendor\WPDesk\PluginBuilder\Plugin\HookableParent; use PluginTemplateVendor\WPDesk\PluginBuilder\Plugin\HookableParent;
use Psr\Log\LoggerAwareInterface;
use Psr\Log\LoggerAwareTrait;
/** /**
* Main plugin class. The most important flow decisions are made here. * Main plugin class. The most important flow decisions are made here.
* *
* @package WPDesk\PluginTemplate * @codeCoverageIgnore
*/ */
class Plugin extends AbstractPlugin implements LoggerAwareInterface, HookableCollection { class Plugin extends AbstractPlugin implements LoggerAwareInterface, HookableCollection {
use LoggerAwareTrait; use LoggerAwareTrait;
use HookableParent; use HookableParent;
/** /**
* Plugin constructor. * Init hooks.
*
* @param WPDesk_Plugin_Info $plugin_info Plugin info.
*/
public function __construct( WPDesk_Plugin_Info $plugin_info ) {
parent::__construct( $plugin_info );
$this->setLogger( new NullLogger() );
$this->plugin_url = $this->plugin_info->get_plugin_url();
$this->plugin_namespace = $this->plugin_info->get_text_domain();
}
/**
* Initializes plugin external state.
*
* The plugin internal state is initialized in the constructor and the plugin should be internally consistent after creation.
* The external state includes hooks execution, communication with other plugins, integration with WC etc.
*
* @return void
*/
public function init() {
parent::init();
}
/**
* Integrate with WordPress and with other plugins using action/filter system.
* *
* @return void * @return void
* @codeCoverageIgnore
*/ */
public function hooks() { public function hooks(): void {
parent::hooks(); parent::hooks();
$this->hooks_on_hookable_objects();
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment