Add WooCommerce Extension environment scaffold (#35755)
This commit is contained in:
parent
2a56407ba1
commit
d45d7dd64b
|
@ -0,0 +1,84 @@
|
|||
<?php
|
||||
/**
|
||||
* Plugin Name: {{title}}
|
||||
{{#description}}
|
||||
* Description: {{description}}
|
||||
{{/description}}
|
||||
* Version: {{version}}
|
||||
{{#author}}
|
||||
* Author: {{author}}
|
||||
{{/author}}
|
||||
* Author URI: https://woocommerce.com
|
||||
* Text Domain: {{textdomain}}
|
||||
* Domain Path: /languages
|
||||
*
|
||||
* License: GNU General Public License v3.0
|
||||
* License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
||||
*
|
||||
* @package {{namespace}}
|
||||
*/
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
if ( ! defined( 'MAIN_PLUGIN_FILE' ) ) {
|
||||
define( 'MAIN_PLUGIN_FILE', __FILE__ );
|
||||
}
|
||||
|
||||
require_once plugin_dir_path( __FILE__ ) . '/vendor/autoload_packages.php';
|
||||
|
||||
use {{slugPascalCase}}\Admin\Setup;
|
||||
|
||||
/**
|
||||
* {{slugPascalCase}} class.
|
||||
*/
|
||||
class {{slugPascalCase}} {
|
||||
/**
|
||||
* This class instance.
|
||||
*
|
||||
* @var \{{slugPascalCase}} single instance of this class.
|
||||
*/
|
||||
private static $instance;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public function __construct() {
|
||||
add_action( 'plugins_loaded', array( $this, 'init' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Init the plugin once WP is loaded.
|
||||
*/
|
||||
public function init() {
|
||||
// If WooCommerce does not exist, deactivate plugin.
|
||||
if ( ! class_exists( 'WooCommerce' ) ) {
|
||||
deactivate_plugins( plugin_basename( __FILE__ ) );
|
||||
}
|
||||
|
||||
if ( is_admin() ) {
|
||||
// Load plugin translations.
|
||||
$plugin_rel_path = basename( dirname( __FILE__ ) ) . '/languages'; /* Relative to WP_PLUGIN_DIR */
|
||||
load_plugin_textdomain( '{{slug}}', false, $plugin_rel_path );
|
||||
|
||||
new Setup();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the main instance.
|
||||
*
|
||||
* Ensures only one instance can be loaded.
|
||||
*
|
||||
* @return \{{slugPascalCase}}
|
||||
*/
|
||||
public static function instance() {
|
||||
|
||||
if ( null === self::$instance ) {
|
||||
self::$instance = new self();
|
||||
}
|
||||
|
||||
return self::$instance;
|
||||
}
|
||||
}
|
||||
|
||||
{{slugPascalCase}}::instance();
|
|
@ -0,0 +1,27 @@
|
|||
# This file is for unifying the coding style for different editors and IDEs
|
||||
# editorconfig.org
|
||||
|
||||
# WordPress Coding Standards
|
||||
# https://make.wordpress.org/core/handbook/coding-standards/
|
||||
|
||||
root = true
|
||||
|
||||
[*]
|
||||
charset = utf-8
|
||||
end_of_line = lf
|
||||
indent_size = 4
|
||||
tab_width = 4
|
||||
indent_style = tab
|
||||
insert_final_newline = true
|
||||
trim_trailing_whitespace = true
|
||||
|
||||
[*.txt]
|
||||
trim_trailing_whitespace = false
|
||||
|
||||
[*.{md,json,yml}]
|
||||
trim_trailing_whitespace = false
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
|
||||
[*.json]
|
||||
indent_style = tab
|
|
@ -0,0 +1,6 @@
|
|||
module.exports = {
|
||||
extends: [ 'plugin:@woocommerce/eslint-plugin/recommended' ],
|
||||
rules: {
|
||||
'react/react-in-jsx-scope': 'off',
|
||||
},
|
||||
};
|
|
@ -0,0 +1,62 @@
|
|||
|
||||
# Operating System files
|
||||
.DS_Store
|
||||
Thumbs.db
|
||||
|
||||
# IDE files
|
||||
.idea
|
||||
.vscode/*
|
||||
project.xml
|
||||
project.properties
|
||||
.project
|
||||
.settings*
|
||||
*.sublime-project
|
||||
*.sublime-workspace
|
||||
.sublimelinterrc
|
||||
|
||||
# Sass
|
||||
.sass-cache/
|
||||
|
||||
# Logs
|
||||
logs/
|
||||
|
||||
# Environment files
|
||||
wp-cli.local.yml
|
||||
yarn-error.log
|
||||
npm-debug.log
|
||||
.pnpm-debug.log
|
||||
|
||||
# Build files
|
||||
*.sql
|
||||
*.swp
|
||||
*.zip
|
||||
|
||||
# Built packages
|
||||
build/
|
||||
build-module/
|
||||
build-style/
|
||||
build-types/
|
||||
dist/
|
||||
|
||||
# Project files
|
||||
node_modules/
|
||||
vendor/
|
||||
|
||||
# TypeScript files
|
||||
tsconfig.tsbuildinfo
|
||||
|
||||
# Node Package Dependencies
|
||||
package-lock.json
|
||||
|
||||
# wp-env config
|
||||
.wp-env.override.json
|
||||
|
||||
# Unit tests
|
||||
tmp/
|
||||
|
||||
# Composer
|
||||
vendor/
|
||||
bin/composer/**/vendor/
|
||||
lib/vendor/
|
||||
contributors.md
|
||||
contributors.html
|
|
@ -0,0 +1 @@
|
|||
"@wordpress/prettier-config"
|
|
@ -0,0 +1,13 @@
|
|||
{
|
||||
"phpVersion": null,
|
||||
"core": null,
|
||||
"plugins": [
|
||||
"https://downloads.wordpress.org/plugin/woocommerce.7.1.0.zip",
|
||||
"."
|
||||
],
|
||||
"config": {
|
||||
"JETPACK_AUTOLOAD_DEV": true,
|
||||
"WP_DEBUG": true,
|
||||
"SCRIPT_DEBUG": true
|
||||
}
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
# @woocommerce/create-extension
|
||||
|
||||
This is a template to be used with `@wordpress/create-block` to create a WooCommerce Extension starting point.
|
||||
|
||||
## Installation
|
||||
|
||||
```
|
||||
npx @wordpress/create-block -t @woocommerce/create-extension
|
||||
```
|
||||
|
||||
When this has completed, go to your WordPress plugins page and activate the plugin.
|
||||
|
||||
## Development
|
||||
|
||||
Install from a local directory.
|
||||
|
||||
```
|
||||
npx @wordpress/create-block -t ./path/to/woocommerce/packages/js/create-extension
|
||||
```
|
|
@ -0,0 +1,20 @@
|
|||
# Woo Plugin Setup
|
||||
|
||||
A boilerplate for modern WooCommerce development. This project adds a React page to WooCommerce Admin and a corresponding navigation item.
|
||||
|
||||
## Getting Started
|
||||
|
||||
### Prerequisites
|
||||
|
||||
- [NPM](https://www.npmjs.com/)
|
||||
- [wp-env](https://developer.wordpress.org/block-editor/reference-guides/packages/packages-env/)
|
||||
|
||||
### Installation and Build
|
||||
|
||||
```
|
||||
npm install
|
||||
npm build
|
||||
wp-env start
|
||||
```
|
||||
|
||||
Visit the added page at http://localhost:8888/wp-admin/admin.php?page=wc-admin&path=%2Fexample.
|
|
@ -0,0 +1,5 @@
|
|||
Significance: patch
|
||||
Type: dev
|
||||
Comment: Initial PR
|
||||
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
{
|
||||
"name": "woocommerce/extend-cart-checkout-block",
|
||||
"description": "A template to be used with `@wordpress/create-block` to create a WooCommerce extension.",
|
||||
"type": "library",
|
||||
"license": "GPL-3.0-or-later",
|
||||
"minimum-stability": "dev",
|
||||
"require-dev": {
|
||||
"automattic/jetpack-changelogger": "3.1.3"
|
||||
},
|
||||
"config": {
|
||||
"platform": {
|
||||
"php": "7.2"
|
||||
}
|
||||
},
|
||||
"extra": {
|
||||
"changelogger": {
|
||||
"formatter": {
|
||||
"filename": "../../../tools/changelogger/class-package-formatter.php"
|
||||
},
|
||||
"types": {
|
||||
"fix": "Fixes an existing bug",
|
||||
"add": "Adds functionality",
|
||||
"update": "Update existing functionality",
|
||||
"dev": "Development related task",
|
||||
"tweak": "A minor adjustment to the codebase",
|
||||
"performance": "Address performance issues",
|
||||
"enhancement": "Improve existing functionality"
|
||||
},
|
||||
"changelog": "CHANGELOG.md"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
{
|
||||
"name": "{{namespace}}/{{slug}}",
|
||||
"description": "WooCommerce plugin",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"{{slugPascalCase}}\\": "includes/"
|
||||
}
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^9.0",
|
||||
"automattic/jetpack-autoloader": "^2"
|
||||
},
|
||||
"config": {
|
||||
"allow-plugins": {
|
||||
"automattic/jetpack-autoloader": true
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,483 @@
|
|||
{
|
||||
"_readme": [
|
||||
"This file locks the dependencies of your project to a known state",
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "af64b929c80c204120d9eccb66330d6c",
|
||||
"packages": [],
|
||||
"packages-dev": [
|
||||
{
|
||||
"name": "automattic/jetpack-changelogger",
|
||||
"version": "v3.1.3",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/Automattic/jetpack-changelogger.git",
|
||||
"reference": "cdd256d8ba6369f82d9377de7e9e2598e3e16ae0"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/Automattic/jetpack-changelogger/zipball/cdd256d8ba6369f82d9377de7e9e2598e3e16ae0",
|
||||
"reference": "cdd256d8ba6369f82d9377de7e9e2598e3e16ae0",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.6",
|
||||
"symfony/console": "^3.4 || ^5.2",
|
||||
"symfony/process": "^3.4 || ^5.2",
|
||||
"wikimedia/at-ease": "^1.2 || ^2.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"wikimedia/testing-access-wrapper": "^1.0 || ^2.0",
|
||||
"yoast/phpunit-polyfills": "1.0.3"
|
||||
},
|
||||
"bin": [
|
||||
"bin/changelogger"
|
||||
],
|
||||
"type": "project",
|
||||
"extra": {
|
||||
"autotagger": true,
|
||||
"branch-alias": {
|
||||
"dev-trunk": "3.1.x-dev"
|
||||
},
|
||||
"mirror-repo": "Automattic/jetpack-changelogger",
|
||||
"version-constants": {
|
||||
"::VERSION": "src/Application.php"
|
||||
},
|
||||
"changelogger": {
|
||||
"link-template": "https://github.com/Automattic/jetpack-changelogger/compare/${old}...${new}"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Automattic\\Jetpack\\Changelog\\": "lib",
|
||||
"Automattic\\Jetpack\\Changelogger\\": "src"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"GPL-2.0-or-later"
|
||||
],
|
||||
"description": "Jetpack Changelogger tool. Allows for managing changelogs by dropping change files into a changelog directory with each PR.",
|
||||
"support": {
|
||||
"source": "https://github.com/Automattic/jetpack-changelogger/tree/v3.1.3"
|
||||
},
|
||||
"time": "2022-06-21T07:31:56+00:00"
|
||||
},
|
||||
{
|
||||
"name": "psr/log",
|
||||
"version": "1.1.4",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/php-fig/log.git",
|
||||
"reference": "d49695b909c3b7628b6289db5479a1c204601f11"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/php-fig/log/zipball/d49695b909c3b7628b6289db5479a1c204601f11",
|
||||
"reference": "d49695b909c3b7628b6289db5479a1c204601f11",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.0"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.1.x-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Psr\\Log\\": "Psr/Log/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "PHP-FIG",
|
||||
"homepage": "https://www.php-fig.org/"
|
||||
}
|
||||
],
|
||||
"description": "Common interface for logging libraries",
|
||||
"homepage": "https://github.com/php-fig/log",
|
||||
"keywords": [
|
||||
"log",
|
||||
"psr",
|
||||
"psr-3"
|
||||
],
|
||||
"support": {
|
||||
"source": "https://github.com/php-fig/log/tree/1.1.4"
|
||||
},
|
||||
"time": "2021-05-03T11:20:27+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/console",
|
||||
"version": "3.4.x-dev",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/console.git",
|
||||
"reference": "a10b1da6fc93080c180bba7219b5ff5b7518fe81"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/console/zipball/a10b1da6fc93080c180bba7219b5ff5b7518fe81",
|
||||
"reference": "a10b1da6fc93080c180bba7219b5ff5b7518fe81",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": "^5.5.9|>=7.0.8",
|
||||
"symfony/debug": "~2.8|~3.0|~4.0",
|
||||
"symfony/polyfill-mbstring": "~1.0"
|
||||
},
|
||||
"conflict": {
|
||||
"symfony/dependency-injection": "<3.4",
|
||||
"symfony/process": "<3.3"
|
||||
},
|
||||
"provide": {
|
||||
"psr/log-implementation": "1.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"psr/log": "~1.0",
|
||||
"symfony/config": "~3.3|~4.0",
|
||||
"symfony/dependency-injection": "~3.4|~4.0",
|
||||
"symfony/event-dispatcher": "~2.8|~3.0|~4.0",
|
||||
"symfony/lock": "~3.4|~4.0",
|
||||
"symfony/process": "~3.3|~4.0"
|
||||
},
|
||||
"suggest": {
|
||||
"psr/log": "For using the console logger",
|
||||
"symfony/event-dispatcher": "",
|
||||
"symfony/lock": "",
|
||||
"symfony/process": ""
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Symfony\\Component\\Console\\": ""
|
||||
},
|
||||
"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": "Symfony Console Component",
|
||||
"homepage": "https://symfony.com",
|
||||
"support": {
|
||||
"source": "https://github.com/symfony/console/tree/3.4"
|
||||
},
|
||||
"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": "2020-10-24T10:57:07+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/debug",
|
||||
"version": "4.4.x-dev",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/debug.git",
|
||||
"reference": "1a692492190773c5310bc7877cb590c04c2f05be"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/debug/zipball/1a692492190773c5310bc7877cb590c04c2f05be",
|
||||
"reference": "1a692492190773c5310bc7877cb590c04c2f05be",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=7.1.3",
|
||||
"psr/log": "^1|^2|^3"
|
||||
},
|
||||
"conflict": {
|
||||
"symfony/http-kernel": "<3.4"
|
||||
},
|
||||
"require-dev": {
|
||||
"symfony/http-kernel": "^3.4|^4.0|^5.0"
|
||||
},
|
||||
"default-branch": true,
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Symfony\\Component\\Debug\\": ""
|
||||
},
|
||||
"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": "Provides tools to ease debugging PHP code",
|
||||
"homepage": "https://symfony.com",
|
||||
"support": {
|
||||
"source": "https://github.com/symfony/debug/tree/v4.4.44"
|
||||
},
|
||||
"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"
|
||||
}
|
||||
],
|
||||
"abandoned": "symfony/error-handler",
|
||||
"time": "2022-07-28T16:29:46+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/polyfill-mbstring",
|
||||
"version": "dev-main",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/polyfill-mbstring.git",
|
||||
"reference": "8ad114f6b39e2c98a8b0e3bd907732c207c2b534"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/8ad114f6b39e2c98a8b0e3bd907732c207c2b534",
|
||||
"reference": "8ad114f6b39e2c98a8b0e3bd907732c207c2b534",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=7.1"
|
||||
},
|
||||
"provide": {
|
||||
"ext-mbstring": "*"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-mbstring": "For best performance"
|
||||
},
|
||||
"default-branch": true,
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-main": "1.27-dev"
|
||||
},
|
||||
"thanks": {
|
||||
"name": "symfony/polyfill",
|
||||
"url": "https://github.com/symfony/polyfill"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"files": [
|
||||
"bootstrap.php"
|
||||
],
|
||||
"psr-4": {
|
||||
"Symfony\\Polyfill\\Mbstring\\": ""
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Nicolas Grekas",
|
||||
"email": "p@tchwork.com"
|
||||
},
|
||||
{
|
||||
"name": "Symfony Community",
|
||||
"homepage": "https://symfony.com/contributors"
|
||||
}
|
||||
],
|
||||
"description": "Symfony polyfill for the Mbstring extension",
|
||||
"homepage": "https://symfony.com",
|
||||
"keywords": [
|
||||
"compatibility",
|
||||
"mbstring",
|
||||
"polyfill",
|
||||
"portable",
|
||||
"shim"
|
||||
],
|
||||
"support": {
|
||||
"source": "https://github.com/symfony/polyfill-mbstring/tree/v1.27.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": "2022-11-03T14:55:06+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/process",
|
||||
"version": "3.4.x-dev",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/process.git",
|
||||
"reference": "b8648cf1d5af12a44a51d07ef9bf980921f15fca"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/process/zipball/b8648cf1d5af12a44a51d07ef9bf980921f15fca",
|
||||
"reference": "b8648cf1d5af12a44a51d07ef9bf980921f15fca",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": "^5.5.9|>=7.0.8"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Symfony\\Component\\Process\\": ""
|
||||
},
|
||||
"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": "Symfony Process Component",
|
||||
"homepage": "https://symfony.com",
|
||||
"support": {
|
||||
"source": "https://github.com/symfony/process/tree/3.4"
|
||||
},
|
||||
"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": "2020-10-24T10:57:07+00:00"
|
||||
},
|
||||
{
|
||||
"name": "wikimedia/at-ease",
|
||||
"version": "v2.0.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/wikimedia/at-ease.git",
|
||||
"reference": "013ac61929797839c80a111a3f1a4710d8248e7a"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/wikimedia/at-ease/zipball/013ac61929797839c80a111a3f1a4710d8248e7a",
|
||||
"reference": "013ac61929797839c80a111a3f1a4710d8248e7a",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.6.99"
|
||||
},
|
||||
"require-dev": {
|
||||
"jakub-onderka/php-console-highlighter": "0.3.2",
|
||||
"jakub-onderka/php-parallel-lint": "1.0.0",
|
||||
"mediawiki/mediawiki-codesniffer": "22.0.0",
|
||||
"mediawiki/minus-x": "0.3.1",
|
||||
"ockcyp/covers-validator": "0.5.1 || 0.6.1",
|
||||
"phpunit/phpunit": "4.8.36 || ^6.5"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"files": [
|
||||
"src/Wikimedia/Functions.php"
|
||||
],
|
||||
"psr-4": {
|
||||
"Wikimedia\\AtEase\\": "src/Wikimedia/AtEase/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"GPL-2.0-or-later"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Tim Starling",
|
||||
"email": "tstarling@wikimedia.org"
|
||||
},
|
||||
{
|
||||
"name": "MediaWiki developers",
|
||||
"email": "wikitech-l@lists.wikimedia.org"
|
||||
}
|
||||
],
|
||||
"description": "Safe replacement to @ for suppressing warnings.",
|
||||
"homepage": "https://www.mediawiki.org/wiki/at-ease",
|
||||
"support": {
|
||||
"source": "https://github.com/wikimedia/at-ease/tree/master"
|
||||
},
|
||||
"time": "2018-10-10T15:39:06+00:00"
|
||||
}
|
||||
],
|
||||
"aliases": [],
|
||||
"minimum-stability": "dev",
|
||||
"stability-flags": [],
|
||||
"prefer-stable": false,
|
||||
"prefer-lowest": false,
|
||||
"platform": [],
|
||||
"platform-dev": [],
|
||||
"platform-overrides": {
|
||||
"php": "7.2"
|
||||
},
|
||||
"plugin-api-version": "2.3.0"
|
||||
}
|
|
@ -0,0 +1,81 @@
|
|||
<?php
|
||||
|
||||
namespace {{slugPascalCase}}\Admin;
|
||||
|
||||
/**
|
||||
* {{slugPascalCase}} Setup Class
|
||||
*/
|
||||
class Setup {
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function __construct() {
|
||||
add_action( 'admin_enqueue_scripts', array( $this, 'register_scripts' ) );
|
||||
add_action( 'admin_menu', array( $this, 'register_page' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Load all necessary dependencies.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function register_scripts() {
|
||||
if ( ! method_exists( 'Automattic\WooCommerce\Admin\PageController', 'is_admin_or_embed_page' ) ||
|
||||
! \Automattic\WooCommerce\Admin\PageController::is_admin_or_embed_page()
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
$script_path = '/build/index.js';
|
||||
$script_asset_path = dirname( MAIN_PLUGIN_FILE ) . '/build/index.asset.php';
|
||||
$script_asset = file_exists( $script_asset_path )
|
||||
? require $script_asset_path
|
||||
: array(
|
||||
'dependencies' => array(),
|
||||
'version' => filemtime( $script_path ),
|
||||
);
|
||||
$script_url = plugins_url( $script_path, MAIN_PLUGIN_FILE );
|
||||
|
||||
wp_register_script(
|
||||
'{{slug}}',
|
||||
$script_url,
|
||||
$script_asset['dependencies'],
|
||||
$script_asset['version'],
|
||||
true
|
||||
);
|
||||
|
||||
wp_register_style(
|
||||
'{{slug}}',
|
||||
plugins_url( '/build/index.css', MAIN_PLUGIN_FILE ),
|
||||
// Add any dependencies styles may have, such as wp-components.
|
||||
array(),
|
||||
filemtime( dirname( MAIN_PLUGIN_FILE ) . '/build/index.css' )
|
||||
);
|
||||
|
||||
wp_enqueue_script( '{{slug}}' );
|
||||
wp_enqueue_style( '{{slug}}' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Register page in wc-admin.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function register_page() {
|
||||
|
||||
if ( ! function_exists( 'wc_admin_register_page' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
wc_admin_register_page(
|
||||
array(
|
||||
'id' => '{{slugSnakeCase}}-example-page',
|
||||
'title' => __( '{{title}}', '{{slugSnakeCase}}' ),
|
||||
'parent' => 'woocommerce',
|
||||
'path' => '/{{slug}}',
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
module.exports = {
|
||||
templatesPath: __dirname,
|
||||
defaultValues: {
|
||||
npmDependencies: [ '@wordpress/hooks', '@wordpress/i18n' ],
|
||||
npmDevDependencies: [
|
||||
'@woocommerce/dependency-extraction-webpack-plugin',
|
||||
'@woocommerce/eslint-plugin',
|
||||
'@wordpress/prettier-config',
|
||||
'@wordpress/scripts',
|
||||
],
|
||||
namespace: 'extension',
|
||||
license: 'GPL-3.0+',
|
||||
},
|
||||
customScripts: {
|
||||
postinstall: 'composer install',
|
||||
},
|
||||
};
|
|
@ -0,0 +1,45 @@
|
|||
# Copyright (C) 2022 WooCommerce
|
||||
# This file is distributed under the GNU General Public License v3.0.
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Woo Plugin Setup 1.0.0\n"
|
||||
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/{{slug}}\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"POT-Creation-Date: 2022-11-27T21:35:18+00:00\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"X-Generator: WP-CLI 2.7.1\n"
|
||||
"X-Domain: {{slug}}\n"
|
||||
|
||||
#. Plugin Name of the plugin
|
||||
msgid "Woo Plugin Setup"
|
||||
msgstr ""
|
||||
|
||||
#. Plugin URI of the plugin
|
||||
msgid "https://github.com/psealock/woo-plugin-setup"
|
||||
msgstr ""
|
||||
|
||||
#. Description of the plugin
|
||||
msgid "This is an example of an extension template to follow."
|
||||
msgstr ""
|
||||
|
||||
#. Author of the plugin
|
||||
msgid "WooCommerce"
|
||||
msgstr ""
|
||||
|
||||
#. Author URI of the plugin
|
||||
msgid "https://woocommerce.com"
|
||||
msgstr ""
|
||||
|
||||
#: build/index.js:1
|
||||
#: src/index.js:13
|
||||
msgid "My Example Extension"
|
||||
msgstr ""
|
||||
|
||||
#: build/index.js:1
|
||||
#: src/index.js:20
|
||||
msgid "My Example Page"
|
||||
msgstr ""
|
|
@ -0,0 +1,25 @@
|
|||
{
|
||||
"name": "@woocommerce/create-extension",
|
||||
"version": "1.0.0",
|
||||
"description": "A template to be used with `@wordpress/create-block` to create a WooCommerce extension.",
|
||||
"main": "index.js",
|
||||
"engines": {
|
||||
"node": "^16.13.1",
|
||||
"pnpm": "^7.13.3"
|
||||
},
|
||||
"scripts": {
|
||||
"postinstall": "composer install",
|
||||
"changelog": "composer exec -- changelogger"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/woocommerce/woocommerce.git"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "GPL-3.0+",
|
||||
"bugs": {
|
||||
"url": "https://github.com/woocommerce/woocommerce/issues"
|
||||
},
|
||||
"homepage": "https://github.com/woocommerce/woocommerce/tree/trunk/packages/js/create-extensionv#readme"
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
/**
|
||||
* External dependencies
|
||||
*/
|
||||
import { addFilter } from '@wordpress/hooks';
|
||||
import { __ } from '@wordpress/i18n';
|
||||
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
import './index.scss';
|
||||
|
||||
const MyExamplePage = () => (
|
||||
<h2>{ __( 'My Example Extension', '{{textdomain}}' ) }</h2>
|
||||
);
|
||||
|
||||
addFilter( 'woocommerce_admin_pages_list', '{{slug}}', ( pages ) => {
|
||||
pages.push( {
|
||||
container: MyExamplePage,
|
||||
path: '/{{slug}}',
|
||||
breadcrumbs: [ __( '{{title}}', '{{textdomain}}' ) ],
|
||||
navArgs: {
|
||||
id: '{{slugSnakeCase}}',
|
||||
},
|
||||
} );
|
||||
|
||||
return pages;
|
||||
} );
|
|
@ -0,0 +1,3 @@
|
|||
h1 {
|
||||
background-color: gold;
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
<?php
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* Basic unit tests.
|
||||
*/
|
||||
final class Test extends TestCase {
|
||||
|
||||
/**
|
||||
* Test if 1 === 1.
|
||||
*/
|
||||
public function testEquality(): void {
|
||||
$this->assertEquals( 1, 1 );
|
||||
}
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
const defaultConfig = require( '@wordpress/scripts/config/webpack.config' );
|
||||
const WooCommerceDependencyExtractionWebpackPlugin = require( '@woocommerce/dependency-extraction-webpack-plugin' );
|
||||
|
||||
module.exports = {
|
||||
...defaultConfig,
|
||||
plugins: [
|
||||
...defaultConfig.plugins.filter(
|
||||
( plugin ) =>
|
||||
plugin.constructor.name !== 'DependencyExtractionWebpackPlugin'
|
||||
),
|
||||
new WooCommerceDependencyExtractionWebpackPlugin(),
|
||||
],
|
||||
};
|
Loading…
Reference in New Issue