Fix indentation issues in PHP files

- Fixed tabs vs spaces indentation issues in PHP files
- Updated phpcs.xml configuration
This commit is contained in:
2025-04-21 15:01:09 +01:00
parent 398d24ed90
commit 200cc5671d
6 changed files with 184 additions and 184 deletions

View File

@@ -7,51 +7,51 @@
// Ensure this file is loaded within WordPress. // Ensure this file is loaded within WordPress.
if ( ! defined( 'ABSPATH' ) ) { if ( ! defined( 'ABSPATH' ) ) {
die; die;
} }
?> ?>
<!-- Update Source Modal --> <!-- Update Source Modal -->
<div id="wpst-update-source-modal" class="wpst-modal"> <div id="wpst-update-source-modal" class="wpst-modal">
<div class="wpst-modal-content"> <div class="wpst-modal-content">
<div class="wpst-modal-header"> <div class="wpst-modal-header">
<h2 class="wpst-modal-title"><?php esc_html_e( 'Select Update Source', 'wp-plugin-starter-template' ); ?></h2> <h2 class="wpst-modal-title"><?php esc_html_e( 'Select Update Source', 'wp-plugin-starter-template' ); ?></h2>
<span class="wpst-modal-close">&times;</span> <span class="wpst-modal-close">&times;</span>
</div> </div>
<div class="wpst-modal-body"> <div class="wpst-modal-body">
<p><?php esc_html_e( 'Choose your preferred source for plugin updates:', 'wp-plugin-starter-template' ); ?></p> <p><?php esc_html_e( 'Choose your preferred source for plugin updates:', 'wp-plugin-starter-template' ); ?></p>
<div class="wpst-modal-message"></div> <div class="wpst-modal-message"></div>
<div class="wpst-source-options"> <div class="wpst-source-options">
<?php <?php
// Get current update source. // Get current update source.
$current_source = get_option( 'wpst_update_source', 'wordpress.org' ); $current_source = get_option( 'wpst_update_source', 'wordpress.org' );
?> ?>
<label class="wpst-source-option <?php echo 'wordpress.org' === $current_source ? 'selected' : ''; ?>"> <label class="wpst-source-option <?php echo 'wordpress.org' === $current_source ? 'selected' : ''; ?>">
<input type="radio" name="update_source" value="wordpress.org" <?php checked( $current_source, 'wordpress.org' ); ?>> <input type="radio" name="update_source" value="wordpress.org" <?php checked( $current_source, 'wordpress.org' ); ?>>
<span class="wpst-source-option-label"><?php esc_html_e( 'WordPress.org', 'wp-plugin-starter-template' ); ?></span> <span class="wpst-source-option-label"><?php esc_html_e( 'WordPress.org', 'wp-plugin-starter-template' ); ?></span>
<div class="wpst-source-option-description"><?php esc_html_e( 'Receive updates from the official WordPress.org repository. Recommended for most users.', 'wp-plugin-starter-template' ); ?></div> <div class="wpst-source-option-description"><?php esc_html_e( 'Receive updates from the official WordPress.org repository. Recommended for most users.', 'wp-plugin-starter-template' ); ?></div>
</label> </label>
<label class="wpst-source-option <?php echo 'github' === $current_source ? 'selected' : ''; ?>"> <label class="wpst-source-option <?php echo 'github' === $current_source ? 'selected' : ''; ?>">
<input type="radio" name="update_source" value="github" <?php checked( $current_source, 'github' ); ?>> <input type="radio" name="update_source" value="github" <?php checked( $current_source, 'github' ); ?>>
<span class="wpst-source-option-label"><?php esc_html_e( 'GitHub', 'wp-plugin-starter-template' ); ?></span> <span class="wpst-source-option-label"><?php esc_html_e( 'GitHub', 'wp-plugin-starter-template' ); ?></span>
<div class="wpst-source-option-description"><?php esc_html_e( 'Receive updates from the GitHub repository. May include pre-release versions.', 'wp-plugin-starter-template' ); ?></div> <div class="wpst-source-option-description"><?php esc_html_e( 'Receive updates from the GitHub repository. May include pre-release versions.', 'wp-plugin-starter-template' ); ?></div>
</label> </label>
<label class="wpst-source-option <?php echo 'gitea' === $current_source ? 'selected' : ''; ?>"> <label class="wpst-source-option <?php echo 'gitea' === $current_source ? 'selected' : ''; ?>">
<input type="radio" name="update_source" value="gitea" <?php checked( $current_source, 'gitea' ); ?>> <input type="radio" name="update_source" value="gitea" <?php checked( $current_source, 'gitea' ); ?>>
<span class="wpst-source-option-label"><?php esc_html_e( 'Gitea', 'wp-plugin-starter-template' ); ?></span> <span class="wpst-source-option-label"><?php esc_html_e( 'Gitea', 'wp-plugin-starter-template' ); ?></span>
<div class="wpst-source-option-description"><?php esc_html_e( 'Receive updates from the Gitea repository. May include pre-release versions.', 'wp-plugin-starter-template' ); ?></div> <div class="wpst-source-option-description"><?php esc_html_e( 'Receive updates from the Gitea repository. May include pre-release versions.', 'wp-plugin-starter-template' ); ?></div>
</label> </label>
</div> </div>
</div> </div>
<div class="wpst-modal-footer"> <div class="wpst-modal-footer">
<button type="button" id="wpst-save-source" class="button button-primary"><?php esc_html_e( 'Save', 'wp-plugin-starter-template' ); ?></button> <button type="button" id="wpst-save-source" class="button button-primary"><?php esc_html_e( 'Save', 'wp-plugin-starter-template' ); ?></button>
</div> </div>
</div> </div>
</div> </div>

View File

@@ -14,86 +14,87 @@ use WPALLSTARS\PluginStarterTemplate\Core;
*/ */
class Admin { class Admin {
/** /**
* Core plugin class instance. * Core plugin class instance.
* *
* @var Core * @var Core
*/ */
private $core; private $core;
/** /**
* Constructor. * Constructor.
* *
* @param Core $core Core instance. * @param Core $core Core instance.
*/ */
public function __construct( Core $core ) { public function __construct( Core $core ) {
$this->core = $core; $this->core = $core;
$this->initialize_hooks(); $this->initialize_hooks();
} }
/** /**
* Initializes WordPress hooks. * Initializes WordPress hooks.
*/ */
private function initialize_hooks() { private function initialize_hooks() {
\add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_assets' ) ); \add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_assets' ) );
} }
/** /**
* Enqueues admin-specific scripts and styles. * Enqueues admin-specific scripts and styles.
* *
* This method is hooked into 'admin_enqueue_scripts'. It checks if the current * This method is hooked into 'admin_enqueue_scripts'. It checks if the current
* screen is relevant to the plugin before enqueueing assets. * screen is relevant to the plugin before enqueueing assets.
* *
* @phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.Found * @phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.Found
* @param string $hook_suffix The hook suffix of the current admin page. *
*/ * @param string $hook_suffix The hook suffix of the current admin page.
public function enqueue_admin_assets( string $hook_suffix ): void { */
public function enqueue_admin_assets( string $hook_suffix ): void {
// @phpcs:disable WordPress.Security.NonceVerification.Recommended // @phpcs:disable WordPress.Security.NonceVerification.Recommended
// @phpcs:disable WordPress.Security.NonceVerification.Missing // @phpcs:disable WordPress.Security.NonceVerification.Missing
if ( ! isset( $_GET['page'] ) || 'wp_plugin_starter_template_settings' !== $_GET['page'] ) { if ( ! isset( $_GET['page'] ) || 'wp_plugin_starter_template_settings' !== $_GET['page'] ) {
return; return;
} }
// @phpcs:enable // @phpcs:enable
// Get the plugin version. // Get the plugin version.
$plugin_version = $this->core->get_plugin_version(); $plugin_version = $this->core->get_plugin_version();
// Enqueue styles. // Enqueue styles.
\wp_enqueue_style( \wp_enqueue_style(
'wpst-admin-styles', 'wpst-admin-styles',
\plugin_dir_url( __FILE__ ) . '../../admin/css/admin-styles.css', \plugin_dir_url( __FILE__ ) . '../../admin/css/admin-styles.css',
array(), // Dependencies. array(), // Dependencies.
$plugin_version // Version. $plugin_version // Version.
); );
// Enqueue admin scripts. // Enqueue admin scripts.
\wp_enqueue_script( \wp_enqueue_script(
'wpst-admin-script', 'wpst-admin-script',
\plugin_dir_url( __FILE__ ) . '../../admin/js/admin-scripts.js', \plugin_dir_url( __FILE__ ) . '../../admin/js/admin-scripts.js',
array( 'jquery' ), array( 'jquery' ),
$plugin_version, // Version. $plugin_version, // Version.
true true
); );
// Prepare data for localization. // Prepare data for localization.
$data = array( $data = array(
'ajax_url' => \admin_url( 'admin-ajax.php' ), 'ajax_url' => \admin_url( 'admin-ajax.php' ),
// @TODO: Fix mocking for wp_create_nonce. Issue #1. // @TODO: Fix mocking for wp_create_nonce. Issue #1.
// 'nonce' => \wp_create_nonce( 'wpst_admin_nonce' ), // 'nonce' => \wp_create_nonce( 'wpst_admin_nonce' ),
); );
// Localize the script with the data. // Localize the script with the data.
// @TODO: Fix mocking for wp_localize_script. Issue #1. // @TODO: Fix mocking for wp_localize_script. Issue #1.
// @phpcs:ignore Squiz.PHP.CommentedOutCode.Found // @phpcs:ignore Squiz.PHP.CommentedOutCode.Found
/* /*
\wp_localize_script( \wp_localize_script(
'wpst-admin-script', 'wpst-admin-script',
'wpst_admin_data', 'wpst_admin_data',
$data $data
); );
*/ */
} }
} }

View File

@@ -12,39 +12,39 @@ namespace WPALLSTARS\PluginStarterTemplate;
*/ */
class Core { class Core {
/** /**
* Plugin version * Plugin version
* *
* @var string * @var string
*/ */
private $version; private $version;
/** /**
* Constructor * Constructor
* *
* @param string $version Plugin version. * @param string $version Plugin version.
*/ */
public function __construct( $version = '' ) { public function __construct( $version = '' ) {
// Initialize hooks. // Initialize hooks.
$this->version = $version; $this->version = $version;
} }
/** /**
* Example method to filter content * Example method to filter content
* *
* @param string $content The content to filter. * @param string $content The content to filter.
* @return string The filtered content. * @return string The filtered content.
*/ */
public function filter_content( $content ) { public function filter_content( $content ) {
return $content; return $content;
} }
/** /**
* Get the plugin version * Get the plugin version
* *
* @return string The plugin version. * @return string The plugin version.
*/ */
public function get_plugin_version() { public function get_plugin_version() {
return $this->version; return $this->version;
} }
} }

View File

@@ -14,51 +14,51 @@ use WPALLSTARS\PluginStarterTemplate\Admin\Admin;
*/ */
class Plugin { class Plugin {
/** /**
* Core instance * Core instance
* *
* @var Core * @var Core
*/ */
private $core; private $core;
/** /**
* Admin instance * Admin instance
* *
* @var Admin * @var Admin
*/ */
private $admin; private $admin;
/** /**
* Plugin file * Plugin file
* *
* @var string * @var string
*/ */
private $plugin_file; private $plugin_file;
/** /**
* Plugin version * Plugin version
* *
* @var string * @var string
*/ */
private $version; private $version;
/** /**
* Constructor * Constructor
* *
* @param string $plugin_file Main plugin file path. * @param string $plugin_file Main plugin file path.
* @param string $version Plugin version. * @param string $version Plugin version.
*/ */
public function __construct( $plugin_file, $version ) { public function __construct( $plugin_file, $version ) {
$this->plugin_file = $plugin_file; $this->plugin_file = $plugin_file;
$this->version = $version; $this->version = $version;
$this->core = new Core( $version ); $this->core = new Core( $version );
$this->admin = new Admin( $this->core ); $this->admin = new Admin( $this->core );
} }
/** /**
* Initialize the plugin * Initialize the plugin
*/ */
public function init() { public function init() {
// Initialization logic goes here. // Initialization logic goes here.
} }
} }

View File

@@ -12,7 +12,6 @@
<exclude-pattern>*/tests/*</exclude-pattern> <exclude-pattern>*/tests/*</exclude-pattern>
<exclude-pattern>libs/</exclude-pattern> <exclude-pattern>libs/</exclude-pattern>
<arg value="-sp" />
<arg name="extensions" value="php" /> <arg name="extensions" value="php" />
<arg name="basepath" value="." /> <arg name="basepath" value="." />
<arg name="parallel" value="8" /> <arg name="parallel" value="8" />

View File

@@ -28,7 +28,7 @@
// 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.