From ed160ed51bd37b02486d4040b3ddcfdada9e66cf Mon Sep 17 00:00:00 2001 From: marcusquinn <6428977+marcusquinn@users.noreply.github.com> Date: Mon, 21 Apr 2025 21:15:29 +0100 Subject: [PATCH] Fix code quality issues and Markdown formatting --- .wiki/Multisite-Development.md | 24 ++++++------ .wiki/Testing-Framework.md | 34 +++++++++-------- PR-DESCRIPTION.md | 14 +++---- cypress.config.js | 2 +- includes/Multisite/class-multisite.php | 52 +++++++++++++------------- 5 files changed, 64 insertions(+), 62 deletions(-) diff --git a/.wiki/Multisite-Development.md b/.wiki/Multisite-Development.md index 7f756f0..9c21d62 100644 --- a/.wiki/Multisite-Development.md +++ b/.wiki/Multisite-Development.md @@ -10,7 +10,7 @@ WordPress Multisite allows you to run multiple WordPress sites from a single Wor The plugin includes a dedicated directory for multisite-specific functionality: -``` +```text includes/ └── Multisite/ ├── class-multisite.php # Base class for multisite functionality @@ -23,8 +23,8 @@ includes/ The `Multisite` class in `includes/Multisite/class-multisite.php` provides a foundation for multisite-specific functionality. It includes: -- A constructor for initialization -- Example methods for multisite functionality +* A constructor for initialization +* Example methods for multisite functionality ### 2. Load Multisite Classes @@ -34,7 +34,7 @@ To use multisite-specific functionality, you need to load and initialize the cla // Load multisite support classes if in multisite environment if ( is_multisite() ) { require_once WP_PLUGIN_STARTER_TEMPLATE_PATH . 'includes/Multisite/class-multisite.php'; - + // Initialize multisite support $multisite = new WPALLSTARS\PluginStarterTemplate\Multisite\Multisite(); } @@ -49,14 +49,14 @@ You can extend the base `Multisite` class or create additional classes in the `M namespace WPALLSTARS\PluginStarterTemplate\Multisite; class Domain_Mapping extends Multisite { - + public function __construct() { parent::__construct(); - + // Add hooks for domain mapping functionality add_action( 'init', array( $this, 'register_domain_mapping' ) ); } - + public function register_domain_mapping() { // Implement domain mapping functionality } @@ -96,13 +96,13 @@ add_action( 'wp_initialize_site', array( $this, 'on_site_creation' ), 10, 2 ); public function on_site_creation( $new_site, $args ) { // Get the blog ID $blog_id = $new_site->blog_id; - + // Switch to the new blog switch_to_blog( $blog_id ); - + // Perform site-specific setup update_option( 'your_plugin_option', 'default_value' ); - + // Restore the current blog restore_current_blog(); } @@ -119,10 +119,10 @@ add_action( 'network_admin_edit_your_plugin_action', array( $this, 'save_network public function save_network_settings() { // Check nonce check_admin_referer( 'your_plugin_nonce' ); - + // Save settings update_site_option( 'your_plugin_network_option', sanitize_text_field( $_POST['your_option'] ) ); - + // Redirect back to settings page wp_redirect( add_query_arg( array( 'page' => 'your-plugin-slug', diff --git a/.wiki/Testing-Framework.md b/.wiki/Testing-Framework.md index 3fbc16f..6223ea6 100644 --- a/.wiki/Testing-Framework.md +++ b/.wiki/Testing-Framework.md @@ -19,6 +19,7 @@ We use `@wordpress/env` and Cypress for testing our plugin. ### Installation 1. Clone the repository: + ```bash git clone https://github.com/wpallstars/wp-plugin-starter-template-for-ai-coding.git cd wp-plugin-starter-template-for-ai-coding @@ -37,8 +38,8 @@ We use `@wordpress/env` and Cypress for testing our plugin. ``` This will: - - Start a WordPress environment using wp-env - - Activate our plugin + * Start a WordPress environment using wp-env + * Activate our plugin 2. Run Cypress tests for single site: ```bash @@ -51,8 +52,8 @@ We use `@wordpress/env` and Cypress for testing our plugin. ``` 3. Access the site manually: - - Site: http://localhost:8888 - - Admin login: admin / password + * Site: + * Admin login: admin / password ## Testing in WordPress Multisite @@ -62,10 +63,10 @@ We use `@wordpress/env` and Cypress for testing our plugin. ``` This will: - - Start a WordPress environment using wp-env - - Configure it as a multisite installation - - Create a test subsite - - Network activate our plugin + * Start a WordPress environment using wp-env + * Configure it as a multisite installation + * Create a test subsite + * Network activate our plugin 2. Run Cypress tests for multisite: ```bash @@ -78,9 +79,9 @@ We use `@wordpress/env` and Cypress for testing our plugin. ``` 3. Access the sites manually: - - Main site: http://localhost:8888 - - Test subsite: http://localhost:8888/testsite - - Admin login: admin / password + * Main site: + * Test subsite: + * Admin login: admin / password ## Continuous Integration @@ -111,7 +112,7 @@ Add new multisite tests to `cypress/e2e/multisite.cy.js`. ```bash # For single site wp-env run cli wp plugin activate wp-plugin-starter-template-for-ai-coding - + # For multisite wp-env run cli wp plugin activate wp-plugin-starter-template-for-ai-coding --network ``` @@ -119,7 +120,8 @@ Add new multisite tests to `cypress/e2e/multisite.cy.js`. ### Getting Help If you encounter any issues, please open an issue on our GitHub repository with: -- A description of the problem -- Steps to reproduce -- Any error messages -- Your environment details (OS, Node.js version, etc.) + +* A description of the problem +* Steps to reproduce +* Any error messages +* Your environment details (OS, Node.js version, etc.) diff --git a/PR-DESCRIPTION.md b/PR-DESCRIPTION.md index fa22b64..3e21f32 100644 --- a/PR-DESCRIPTION.md +++ b/PR-DESCRIPTION.md @@ -4,13 +4,13 @@ This PR adds a comprehensive testing framework for our WordPress plugin template ## Changes -- Added wp-env configuration for both single site and multisite environments -- Created Cypress e2e tests for both environments -- Added GitHub Actions workflow to run tests automatically on PRs -- Created a unified setup script for test environments -- Added detailed documentation in the wiki -- Updated README.md to reference the new testing approach -- Added placeholder files for multisite functionality +* Added wp-env configuration for both single site and multisite environments +* Created Cypress e2e tests for both environments +* Added GitHub Actions workflow to run tests automatically on PRs +* Created a unified setup script for test environments +* Added detailed documentation in the wiki +* Updated README.md to reference the new testing approach +* Added placeholder files for multisite functionality ## Testing diff --git a/cypress.config.js b/cypress.config.js index d22986e..9765bb4 100644 --- a/cypress.config.js +++ b/cypress.config.js @@ -3,7 +3,7 @@ const { defineConfig } = require('cypress'); module.exports = defineConfig({ e2e: { baseUrl: 'http://localhost:8888', - setupNodeEvents(on, config) { + setupNodeEvents() { // implement node event listeners here }, }, diff --git a/includes/Multisite/class-multisite.php b/includes/Multisite/class-multisite.php index 83a18be..f45730e 100644 --- a/includes/Multisite/class-multisite.php +++ b/includes/Multisite/class-multisite.php @@ -13,7 +13,7 @@ namespace WPALLSTARS\PluginStarterTemplate\Multisite; // Exit if accessed directly. if ( ! defined( 'ABSPATH' ) ) { - exit; + exit; } /** @@ -23,31 +23,31 @@ if ( ! defined( 'ABSPATH' ) ) { */ class Multisite { - /** - * Constructor. - */ - public function __construct() { - // This is just a placeholder class. - // Add your multisite-specific initialization here. - } + /** + * Constructor. + */ + public function __construct() { + // This is just a placeholder class. + // Add your multisite-specific initialization here. + } - /** - * Example method for multisite functionality. - * - * @return bool Always returns true. - */ - public function is_multisite_compatible() { - return true; - } + /** + * Example method for multisite functionality. + * + * @return bool Always returns true. + */ + public function is_multisite_compatible() { + return true; + } - /** - * Example method to get all sites in the network. - * - * @return array An empty array as this is just a placeholder. - */ - public function get_network_sites() { - // This is just a placeholder method. - // In a real implementation, you might use get_sites() or a custom query. - return array(); - } + /** + * Example method to get all sites in the network. + * + * @return array An empty array as this is just a placeholder. + */ + public function get_network_sites() { + // This is just a placeholder method. + // In a real implementation, you might use get_sites() or a custom query. + return array(); + } }