Compare commits
4
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
31d475beca | ||
|
|
af48e84614 | ||
|
|
5083fcee50 | ||
|
|
79d1314aed |
No files matched your search
@@ -150,7 +150,15 @@ If the plugin is hosted on WordPress.org:
|
|||||||
|
|
||||||
After releasing a new version:
|
After releasing a new version:
|
||||||
|
|
||||||
1. Update the wiki documentation if needed
|
1. Update the wiki documentation:
|
||||||
2. Announce the release in relevant channels
|
- Update the Changelog.md file in the .wiki directory to match the main CHANGELOG.md
|
||||||
3. Monitor for any issues or feedback
|
- Add the new version information to the Home.md file in the Latest Updates section
|
||||||
4. Start planning the next release
|
- Ensure all wiki pages are up-to-date with the new features or changes
|
||||||
|
- Verify that the _Sidebar.md file has the correct navigation structure
|
||||||
|
2. Verify that GitHub Actions workflows are running correctly:
|
||||||
|
- Check that the release workflow created the release with the correct assets
|
||||||
|
- Check that the sync-wiki workflow synced the wiki changes
|
||||||
|
- Fix any permissions issues in the workflow files if needed
|
||||||
|
3. Announce the release in relevant channels
|
||||||
|
4. Monitor for any issues or feedback
|
||||||
|
5. Start planning the next release
|
||||||
@@ -8,6 +8,7 @@ The wiki documentation is organized into the following sections:
|
|||||||
|
|
||||||
1. **User Documentation**:
|
1. **User Documentation**:
|
||||||
- Home
|
- Home
|
||||||
|
- Starter Prompt (must be listed before Installation Guide)
|
||||||
- Installation Guide
|
- Installation Guide
|
||||||
- Usage Instructions
|
- Usage Instructions
|
||||||
- Frequently Asked Questions
|
- Frequently Asked Questions
|
||||||
@@ -88,8 +89,10 @@ Documentation should be updated:
|
|||||||
|
|
||||||
1. Identify the relevant wiki file(s) in the `.wiki/` directory
|
1. Identify the relevant wiki file(s) in the `.wiki/` directory
|
||||||
2. Make the necessary changes
|
2. Make the necessary changes
|
||||||
3. Commit and push the changes to the `main` branch
|
3. **Always ensure the Changelog.md in the wiki is updated to match the main CHANGELOG.md file**
|
||||||
4. The GitHub Actions workflow will automatically sync the changes with the GitHub wiki
|
4. **Always ensure the _Sidebar.md file has the correct navigation structure with Starter Prompt listed before Installation Guide**
|
||||||
|
5. Commit and push the changes to the `main` branch
|
||||||
|
6. The GitHub Actions workflow will automatically sync the changes with the GitHub wiki
|
||||||
|
|
||||||
### Creating New Pages
|
### Creating New Pages
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,8 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
php-versions: ['7.0', '7.4', '8.0']
|
php-versions: ['7.0', '7.4', '8.0']
|
||||||
|
fail-fast: false
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
@@ -26,7 +27,15 @@ jobs:
|
|||||||
tools: composer:v2
|
tools: composer:v2
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: composer install --prefer-dist --no-progress
|
run: |
|
||||||
|
if [[ "${{ matrix.php-versions }}" == "7.0" ]]; then
|
||||||
|
composer require --dev phpunit/phpunit:"^6.5" --update-with-dependencies
|
||||||
|
composer require --dev 10up/wp_mock:"0.3.0" --update-with-dependencies
|
||||||
|
composer require --dev antecedent/patchwork:"^2.1.21" --update-with-dependencies
|
||||||
|
else
|
||||||
|
composer install --prefer-dist --no-progress
|
||||||
|
composer require --dev 10up/wp_mock:"0.3.0" --update-with-dependencies
|
||||||
|
fi
|
||||||
|
|
||||||
- name: Run tests
|
- name: Run tests
|
||||||
run: ./vendor/bin/phpunit
|
run: ./vendor/bin/phpunit
|
||||||
@@ -34,7 +43,7 @@ jobs:
|
|||||||
code-style:
|
code-style:
|
||||||
name: Code Style
|
name: Code Style
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
@@ -50,4 +59,4 @@ jobs:
|
|||||||
run: composer install --prefer-dist --no-progress
|
run: composer install --prefer-dist --no-progress
|
||||||
|
|
||||||
- name: Run PHPCS
|
- name: Run PHPCS
|
||||||
run: ./vendor/bin/phpcs --standard=WordPress
|
run: ./vendor/bin/phpcs --standard=WordPress --runtime-set installed_paths vendor/wp-coding-standards/wpcs ./includes ./admin ./wp-plugin-starter-template.php
|
||||||
+43
-7
@@ -2,12 +2,48 @@
|
|||||||
|
|
||||||
This page documents all notable changes to the WordPress Plugin Starter Template.
|
This page documents all notable changes to the WordPress Plugin Starter Template.
|
||||||
|
|
||||||
|
## Version 0.1.6 (2025-04-19)
|
||||||
|
### Fixed
|
||||||
|
- GitHub Actions workflows permissions for releases and wiki sync
|
||||||
|
|
||||||
|
## Version 0.1.5 (2025-04-19)
|
||||||
|
### Fixed
|
||||||
|
- Release workflow to use correct plugin directory name
|
||||||
|
|
||||||
|
### Added
|
||||||
|
- Testing setup with wp-env and Cypress
|
||||||
|
- Multisite compatibility
|
||||||
|
- npm scripts for development and testing
|
||||||
|
|
||||||
|
## Version 0.1.3 (2025-04-19)
|
||||||
|
### Added
|
||||||
|
- Improved AI IDE context recommendations in documentation
|
||||||
|
- Enhanced Starter Prompt with guidance on pinning .ai-assistant.md and .ai-workflows/
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
- Updated README.md and readme.txt with AI IDE context recommendations
|
||||||
|
- Improved documentation for AI-assisted development
|
||||||
|
- Moved Starter Prompt to the wiki for better organization
|
||||||
|
|
||||||
|
## Version 0.1.2 (2025-04-18)
|
||||||
|
### Added
|
||||||
|
- STARTER-PROMPT.md with comprehensive guide for customizing the template
|
||||||
|
- Additional AI workflow files for better development guidance
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
- Updated documentation files with improved instructions
|
||||||
|
|
||||||
|
## Version 0.1.1 (2025-04-18)
|
||||||
|
### Changed
|
||||||
|
- Updated LICENSE file with correct GPL-2.0 text
|
||||||
|
|
||||||
## Version 0.1.0 (2025-04-17)
|
## Version 0.1.0 (2025-04-17)
|
||||||
|
### Added
|
||||||
- Initial release with basic template structure
|
- Initial release with basic template structure
|
||||||
- Added core plugin architecture with OOP approach
|
- Core plugin architecture with OOP approach
|
||||||
- Added admin interface components and styling
|
- Admin interface components and styling
|
||||||
- Added update mechanism with multiple source options
|
- Update mechanism with multiple source options
|
||||||
- Added documentation templates for users and developers
|
- Documentation templates for users and developers
|
||||||
- Added AI workflow documentation for AI-assisted development
|
- AI workflow documentation for AI-assisted development
|
||||||
- Added GitHub Actions workflows for automated tasks
|
- GitHub Actions workflows for automated tasks
|
||||||
- Added wiki documentation templates
|
- Wiki documentation templates
|
||||||
@@ -4,6 +4,11 @@ Welcome to the documentation wiki for the WordPress Plugin Starter Template.
|
|||||||
|
|
||||||
This template provides a solid foundation for developing WordPress plugins with best practices for AI-assisted development.
|
This template provides a solid foundation for developing WordPress plugins with best practices for AI-assisted development.
|
||||||
|
|
||||||
|
## Latest Updates
|
||||||
|
|
||||||
|
- Version 0.1.6: Fixed GitHub Actions workflows permissions for releases and wiki sync
|
||||||
|
- Version 0.1.5: Added testing setup with wp-env and Cypress, multisite compatibility
|
||||||
|
|
||||||
## Quick Links
|
## Quick Links
|
||||||
|
|
||||||
- [Starter Prompt](Starter-Prompt)
|
- [Starter Prompt](Starter-Prompt)
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
## User Documentation
|
## User Documentation
|
||||||
* [Home](Home)
|
* [Home](Home)
|
||||||
|
* [Starter Prompt](Starter-Prompt)
|
||||||
* [Installation Guide](Installation-Guide)
|
* [Installation Guide](Installation-Guide)
|
||||||
* [Usage Instructions](Usage-Instructions)
|
* [Usage Instructions](Usage-Instructions)
|
||||||
* [Frequently Asked Questions](Frequently-Asked-Questions)
|
* [Frequently Asked Questions](Frequently-Asked-Questions)
|
||||||
|
|||||||
@@ -1,5 +1,9 @@
|
|||||||
All notable changes to this project should be documented both here and in the main Readme files.
|
All notable changes to this project should be documented both here and in the main Readme files.
|
||||||
|
|
||||||
|
#### [0.1.6] - 2025-04-19
|
||||||
|
#### Fixed
|
||||||
|
- GitHub Actions workflows permissions for releases and wiki sync
|
||||||
|
|
||||||
#### [0.1.5] - 2025-04-19
|
#### [0.1.5] - 2025-04-19
|
||||||
#### Fixed
|
#### Fixed
|
||||||
- Release workflow to use correct plugin directory name
|
- Release workflow to use correct plugin directory name
|
||||||
|
|||||||
@@ -278,6 +278,9 @@ For more information on Git Updater integration, see the [Git Updater Required H
|
|||||||
|
|
||||||
## Changelog
|
## Changelog
|
||||||
|
|
||||||
|
### 0.1.6
|
||||||
|
* Fixed: GitHub Actions workflows permissions for releases and wiki sync
|
||||||
|
|
||||||
### 0.1.5
|
### 0.1.5
|
||||||
* Fixed: Release workflow to use correct plugin directory name
|
* Fixed: Release workflow to use correct plugin directory name
|
||||||
* Added: Testing setup with wp-env and Cypress
|
* Added: Testing setup with wp-env and Cypress
|
||||||
|
|||||||
@@ -1 +1,75 @@
|
|||||||
<?php
|
<?php
|
||||||
|
/**
|
||||||
|
* Admin functionality
|
||||||
|
*
|
||||||
|
* @package WPALLSTARS\PluginStarterTemplate
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace WPALLSTARS\PluginStarterTemplate\Admin;
|
||||||
|
|
||||||
|
use WPALLSTARS\PluginStarterTemplate\Core;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Admin class
|
||||||
|
*/
|
||||||
|
class Admin {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Core instance
|
||||||
|
*
|
||||||
|
* @var Core
|
||||||
|
*/
|
||||||
|
private $core;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
*
|
||||||
|
* @param Core $core Core instance.
|
||||||
|
*/
|
||||||
|
public function __construct( $core ) {
|
||||||
|
$this->core = $core;
|
||||||
|
add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_admin_assets' ] );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize admin
|
||||||
|
*/
|
||||||
|
public function init() {
|
||||||
|
// Initialize admin
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enqueue admin assets
|
||||||
|
*
|
||||||
|
* @param string $hook Current admin page.
|
||||||
|
*/
|
||||||
|
public function enqueue_admin_assets( $hook ) {
|
||||||
|
wp_enqueue_style(
|
||||||
|
'wpst-admin-styles',
|
||||||
|
WPST_PLUGIN_URL . 'assets/css/admin.css',
|
||||||
|
[],
|
||||||
|
WPST_VERSION
|
||||||
|
);
|
||||||
|
|
||||||
|
wp_enqueue_script(
|
||||||
|
'wpst-admin-scripts',
|
||||||
|
WPST_PLUGIN_URL . 'assets/js/admin.js',
|
||||||
|
[ 'jquery' ],
|
||||||
|
WPST_VERSION,
|
||||||
|
true
|
||||||
|
);
|
||||||
|
|
||||||
|
wp_localize_script(
|
||||||
|
'wpst-admin-scripts',
|
||||||
|
'wpstData',
|
||||||
|
[
|
||||||
|
'ajaxUrl' => admin_url( 'admin-ajax.php' ),
|
||||||
|
'nonce' => wp_create_nonce( 'wpst-admin-nonce' ),
|
||||||
|
'strings' => [
|
||||||
|
'success' => esc_html__( 'Success!', 'wp-plugin-starter-template' ),
|
||||||
|
'error' => esc_html__( 'Error!', 'wp-plugin-starter-template' ),
|
||||||
|
],
|
||||||
|
]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
+5
-2
@@ -14,9 +14,12 @@
|
|||||||
"php": ">=7.0"
|
"php": ">=7.0"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"phpunit/phpunit": "^7.5",
|
"phpunit/phpunit": "^6.5 || ^7.5 || ^8.0 || ^9.0",
|
||||||
"squizlabs/php_codesniffer": "^3.5",
|
"squizlabs/php_codesniffer": "^3.5",
|
||||||
"wp-coding-standards/wpcs": "^2.3"
|
"wp-coding-standards/wpcs": "^2.3",
|
||||||
|
"dealerdirect/phpcodesniffer-composer-installer": "^0.7.0",
|
||||||
|
"10up/wp_mock": "0.3.0",
|
||||||
|
"antecedent/patchwork": "^2.1.21"
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-4": {
|
"psr-4": {
|
||||||
|
|||||||
@@ -1 +1,31 @@
|
|||||||
<?php
|
<?php
|
||||||
|
/**
|
||||||
|
* Core functionality for the plugin
|
||||||
|
*
|
||||||
|
* @package WPALLSTARS\PluginStarterTemplate
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace WPALLSTARS\PluginStarterTemplate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Core class
|
||||||
|
*/
|
||||||
|
class Core {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
*/
|
||||||
|
public function __construct() {
|
||||||
|
// Initialize hooks
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Example method to filter content
|
||||||
|
*
|
||||||
|
* @param string $content The content to filter.
|
||||||
|
* @return string The filtered content.
|
||||||
|
*/
|
||||||
|
public function filter_content( $content ) {
|
||||||
|
return $content;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1 +1,54 @@
|
|||||||
<?php
|
<?php
|
||||||
|
/**
|
||||||
|
* Main plugin class
|
||||||
|
*
|
||||||
|
* @package WPALLSTARS\PluginStarterTemplate
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace WPALLSTARS\PluginStarterTemplate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Plugin class
|
||||||
|
*/
|
||||||
|
class Plugin {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Core instance
|
||||||
|
*
|
||||||
|
* @var Core
|
||||||
|
*/
|
||||||
|
private $core;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Plugin file
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $plugin_file;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Plugin version
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $version;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
*
|
||||||
|
* @param string $plugin_file Main plugin file path.
|
||||||
|
* @param string $version Plugin version.
|
||||||
|
*/
|
||||||
|
public function __construct($plugin_file, $version) {
|
||||||
|
$this->plugin_file = $plugin_file;
|
||||||
|
$this->version = $version;
|
||||||
|
$this->core = new Core();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize the plugin
|
||||||
|
*/
|
||||||
|
public function init() {
|
||||||
|
// Initialize plugin.
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1 +1,58 @@
|
|||||||
<?php
|
<?php
|
||||||
|
/**
|
||||||
|
* Updater functionality for the plugin
|
||||||
|
*
|
||||||
|
* @package WPALLSTARS\PluginStarterTemplate
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace WPALLSTARS\PluginStarterTemplate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updater class
|
||||||
|
*/
|
||||||
|
class Updater {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Plugin file
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $plugin_file;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
*
|
||||||
|
* @param string $plugin_file Main plugin file path.
|
||||||
|
*/
|
||||||
|
public function __construct($plugin_file) {
|
||||||
|
$this->plugin_file = $plugin_file;
|
||||||
|
$this->init();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize the updater
|
||||||
|
*/
|
||||||
|
public function init() {
|
||||||
|
add_filter('plugin_action_links_' . plugin_basename($this->plugin_file), array($this, 'add_update_source_link'));
|
||||||
|
add_action('admin_post_wpst_update_source', array($this, 'handle_update_source'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add update source link to plugin actions
|
||||||
|
*
|
||||||
|
* @param array $links Plugin action links.
|
||||||
|
* @return array Modified plugin action links.
|
||||||
|
*/
|
||||||
|
public function add_update_source_link($links) {
|
||||||
|
$update_source_link = '<a href="' . admin_url('admin-post.php?action=wpst_update_source&plugin=' . plugin_basename($this->plugin_file)) . '">' . esc_html__('Update Source', 'wp-plugin-starter-template') . '</a>';
|
||||||
|
array_unshift($links, $update_source_link);
|
||||||
|
return $links;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle update source selection
|
||||||
|
*/
|
||||||
|
public function handle_update_source() {
|
||||||
|
// Handle update source selection.
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
{
|
||||||
|
"name": "wp-plugin-starter-template-for-ai-coding",
|
||||||
|
"version": "0.1.6",
|
||||||
|
"description": "A comprehensive starter template for WordPress plugins with best practices for AI-assisted development.",
|
||||||
|
"main": "index.js",
|
||||||
|
"scripts": {
|
||||||
|
"start": "wp-env start",
|
||||||
|
"stop": "wp-env stop",
|
||||||
|
"wp-env": "wp-env",
|
||||||
|
"multisite": "wp-env start --config=.wp-env.multisite.json",
|
||||||
|
"test:e2e": "cypress open --config-file tests/e2e/cypress.json",
|
||||||
|
"test:e2e:headless": "cypress run --config-file tests/e2e/cypress.json",
|
||||||
|
"build": "./build.sh",
|
||||||
|
"lint:php": "composer run-script phpcs",
|
||||||
|
"fix:php": "composer run-script phpcbf",
|
||||||
|
"test:php": "composer run-script test"
|
||||||
|
},
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git+https://github.com/wpallstars/wp-plugin-starter-template-for-ai-coding.git"
|
||||||
|
},
|
||||||
|
"keywords": [
|
||||||
|
"wordpress",
|
||||||
|
"plugin",
|
||||||
|
"template",
|
||||||
|
"ai",
|
||||||
|
"coding"
|
||||||
|
],
|
||||||
|
"author": "WPALLSTARS",
|
||||||
|
"license": "GPL-2.0-or-later",
|
||||||
|
"bugs": {
|
||||||
|
"url": "https://github.com/wpallstars/wp-plugin-starter-template-for-ai-coding/issues"
|
||||||
|
},
|
||||||
|
"homepage": "https://github.com/wpallstars/wp-plugin-starter-template-for-ai-coding#readme",
|
||||||
|
"devDependencies": {
|
||||||
|
"@wordpress/env": "^5.0.0",
|
||||||
|
"cypress": "^9.7.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
+7
-1
@@ -5,7 +5,7 @@ Tags: starter, template, boilerplate, plugin development, ai coding
|
|||||||
Requires at least: 5.0
|
Requires at least: 5.0
|
||||||
Tested up to: 6.4
|
Tested up to: 6.4
|
||||||
Requires PHP: 7.0
|
Requires PHP: 7.0
|
||||||
Stable tag: 0.1.5
|
Stable tag: 0.1.6
|
||||||
License: GPL-2.0+
|
License: GPL-2.0+
|
||||||
License URI: https://www.gnu.org/licenses/gpl-2.0.html
|
License URI: https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
|
|
||||||
@@ -205,6 +205,9 @@ npm run multisite
|
|||||||
|
|
||||||
== Changelog ==
|
== Changelog ==
|
||||||
|
|
||||||
|
= 0.1.6 =
|
||||||
|
* Fixed: GitHub Actions workflows permissions for releases and wiki sync
|
||||||
|
|
||||||
= 0.1.5 =
|
= 0.1.5 =
|
||||||
* Fixed: Release workflow to use correct plugin directory name
|
* Fixed: Release workflow to use correct plugin directory name
|
||||||
* Added: Testing setup with wp-env and Cypress
|
* Added: Testing setup with wp-env and Cypress
|
||||||
@@ -238,6 +241,9 @@ npm run multisite
|
|||||||
|
|
||||||
== Upgrade Notice ==
|
== Upgrade Notice ==
|
||||||
|
|
||||||
|
= 0.1.6 =
|
||||||
|
Fixed GitHub Actions workflows permissions for releases and wiki sync.
|
||||||
|
|
||||||
= 0.1.5 =
|
= 0.1.5 =
|
||||||
Fixed release workflow and added testing setup with wp-env and Cypress, multisite compatibility, and npm scripts for development and testing.
|
Fixed release workflow and added testing setup with wp-env and Cypress, multisite compatibility, and npm scripts for development and testing.
|
||||||
|
|
||||||
|
|||||||
+14
-14
@@ -11,7 +11,7 @@ use WPALLSTARS\PluginStarterTemplate\Core;
|
|||||||
/**
|
/**
|
||||||
* Admin test case.
|
* Admin test case.
|
||||||
*/
|
*/
|
||||||
class AdminTest extends WP_Mock\Tools\TestCase {
|
class AdminTest extends \WP_Mock\Tools\TestCase {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test instance
|
* Test instance
|
||||||
@@ -30,21 +30,21 @@ class AdminTest extends WP_Mock\Tools\TestCase {
|
|||||||
/**
|
/**
|
||||||
* Set up test environment
|
* Set up test environment
|
||||||
*/
|
*/
|
||||||
public function setUp(): void {
|
public function setUp() {
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
// Set up mocks
|
// Set up mocks
|
||||||
WP_Mock::setUp();
|
WP_Mock::setUp();
|
||||||
|
|
||||||
// Mock Core class
|
// Mock Core class
|
||||||
$this->core = $this->createMock(Core::class);
|
$this->core = $this->createMock(Core::class);
|
||||||
|
|
||||||
// Set up WordPress function mocks
|
// Set up WordPress function mocks
|
||||||
WP_Mock::userFunction('add_action', [
|
WP_Mock::userFunction('add_action', [
|
||||||
'times' => 1,
|
'times' => 1,
|
||||||
'args' => ['admin_enqueue_scripts', \WP_Mock\Functions::type('array')],
|
'args' => ['admin_enqueue_scripts', \WP_Mock\Functions::type('array')],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// Create instance of Admin class
|
// Create instance of Admin class
|
||||||
$this->admin = new Admin($this->core);
|
$this->admin = new Admin($this->core);
|
||||||
}
|
}
|
||||||
@@ -52,7 +52,7 @@ class AdminTest extends WP_Mock\Tools\TestCase {
|
|||||||
/**
|
/**
|
||||||
* Tear down test environment
|
* Tear down test environment
|
||||||
*/
|
*/
|
||||||
public function tearDown(): void {
|
public function tearDown() {
|
||||||
WP_Mock::tearDown();
|
WP_Mock::tearDown();
|
||||||
parent::tearDown();
|
parent::tearDown();
|
||||||
}
|
}
|
||||||
@@ -74,38 +74,38 @@ class AdminTest extends WP_Mock\Tools\TestCase {
|
|||||||
'times' => 1,
|
'times' => 1,
|
||||||
'args' => ['wpst-admin-styles', \WP_Mock\Functions::type('string'), [], \WP_Mock\Functions::type('string')],
|
'args' => ['wpst-admin-styles', \WP_Mock\Functions::type('string'), [], \WP_Mock\Functions::type('string')],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
WP_Mock::userFunction('wp_enqueue_script', [
|
WP_Mock::userFunction('wp_enqueue_script', [
|
||||||
'times' => 1,
|
'times' => 1,
|
||||||
'args' => ['wpst-admin-scripts', \WP_Mock\Functions::type('string'), ['jquery'], \WP_Mock\Functions::type('string'), true],
|
'args' => ['wpst-admin-scripts', \WP_Mock\Functions::type('string'), ['jquery'], \WP_Mock\Functions::type('string'), true],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
WP_Mock::userFunction('wp_localize_script', [
|
WP_Mock::userFunction('wp_localize_script', [
|
||||||
'times' => 1,
|
'times' => 1,
|
||||||
'args' => ['wpst-admin-scripts', 'wpstData', \WP_Mock\Functions::type('array')],
|
'args' => ['wpst-admin-scripts', 'wpstData', \WP_Mock\Functions::type('array')],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
WP_Mock::userFunction('esc_html__', [
|
WP_Mock::userFunction('esc_html__', [
|
||||||
'times' => 2,
|
'times' => 2,
|
||||||
'args' => [\WP_Mock\Functions::type('string'), 'wp-plugin-starter-template'],
|
'args' => [\WP_Mock\Functions::type('string'), 'wp-plugin-starter-template'],
|
||||||
'return' => 'Translated string',
|
'return' => 'Translated string',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
WP_Mock::userFunction('admin_url', [
|
WP_Mock::userFunction('admin_url', [
|
||||||
'times' => 1,
|
'times' => 1,
|
||||||
'args' => ['admin-ajax.php'],
|
'args' => ['admin-ajax.php'],
|
||||||
'return' => 'http://example.org/wp-admin/admin-ajax.php',
|
'return' => 'http://example.org/wp-admin/admin-ajax.php',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
WP_Mock::userFunction('wp_create_nonce', [
|
WP_Mock::userFunction('wp_create_nonce', [
|
||||||
'times' => 1,
|
'times' => 1,
|
||||||
'args' => ['wpst-admin-nonce'],
|
'args' => ['wpst-admin-nonce'],
|
||||||
'return' => '1234567890',
|
'return' => '1234567890',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// Call the method
|
// Call the method
|
||||||
$this->admin->enqueue_admin_assets('plugins.php');
|
$this->admin->enqueue_admin_assets('plugins.php');
|
||||||
|
|
||||||
// If we get here, the test passed
|
// If we get here, the test passed
|
||||||
$this->assertTrue(true);
|
$this->assertTrue(true);
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-6
@@ -10,7 +10,7 @@ use WPALLSTARS\PluginStarterTemplate\Core;
|
|||||||
/**
|
/**
|
||||||
* Core test case.
|
* Core test case.
|
||||||
*/
|
*/
|
||||||
class CoreTest extends WP_Mock\Tools\TestCase {
|
class CoreTest extends \WP_Mock\Tools\TestCase {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test instance
|
* Test instance
|
||||||
@@ -22,12 +22,12 @@ class CoreTest extends WP_Mock\Tools\TestCase {
|
|||||||
/**
|
/**
|
||||||
* Set up test environment
|
* Set up test environment
|
||||||
*/
|
*/
|
||||||
public function setUp(): void {
|
public function setUp() {
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
// Set up mocks
|
// Set up mocks
|
||||||
WP_Mock::setUp();
|
WP_Mock::setUp();
|
||||||
|
|
||||||
// Create instance of Core class
|
// Create instance of Core class
|
||||||
$this->core = new Core();
|
$this->core = new Core();
|
||||||
}
|
}
|
||||||
@@ -35,7 +35,7 @@ class CoreTest extends WP_Mock\Tools\TestCase {
|
|||||||
/**
|
/**
|
||||||
* Tear down test environment
|
* Tear down test environment
|
||||||
*/
|
*/
|
||||||
public function tearDown(): void {
|
public function tearDown() {
|
||||||
WP_Mock::tearDown();
|
WP_Mock::tearDown();
|
||||||
parent::tearDown();
|
parent::tearDown();
|
||||||
}
|
}
|
||||||
@@ -53,7 +53,7 @@ class CoreTest extends WP_Mock\Tools\TestCase {
|
|||||||
*/
|
*/
|
||||||
public function test_filter_content() {
|
public function test_filter_content() {
|
||||||
$content = 'Test content';
|
$content = 'Test content';
|
||||||
|
|
||||||
// Test that filter_content returns the content
|
// Test that filter_content returns the content
|
||||||
$this->assertEquals($content, $this->core->filter_content($content));
|
$this->assertEquals($content, $this->core->filter_content($content));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
* Plugin Name: WordPress Plugin Starter Template
|
* Plugin Name: WordPress Plugin Starter Template
|
||||||
* Plugin URI: https://www.wpallstars.com
|
* Plugin URI: https://www.wpallstars.com
|
||||||
* Description: A comprehensive starter template for WordPress plugins with best practices for AI-assisted development.
|
* Description: A comprehensive starter template for WordPress plugins with best practices for AI-assisted development.
|
||||||
* Version: 0.1.5
|
* Version: 0.1.6
|
||||||
* Author: Your Name & The WPALLSTARS Team
|
* Author: Your Name & The WPALLSTARS Team
|
||||||
* Author URI: https://www.wpallstars.com
|
* Author URI: https://www.wpallstars.com
|
||||||
* License: GPL-2.0+
|
* License: GPL-2.0+
|
||||||
@@ -27,12 +27,12 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// If this file is called directly, abort.
|
// If this file is called directly, abort.
|
||||||
if (!defined('WPINC')) {
|
if ( ! defined( 'WPINC' ) ) {
|
||||||
die;
|
die;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load the main plugin class
|
// Load the main plugin class.
|
||||||
require_once plugin_dir_path(__FILE__) . 'includes/plugin.php';
|
require_once plugin_dir_path( __FILE__ ) . 'includes/plugin.php';
|
||||||
|
|
||||||
// Initialize the plugin
|
// Initialize the plugin.
|
||||||
new WPALLSTARS\PluginStarterTemplate\Plugin(__FILE__, '0.1.5');
|
new WPALLSTARS\PluginStarterTemplate\Plugin( __FILE__, '0.1.7' );
|
||||||
Reference in new issue
Block a user