Fix: Update PHPUnit bootstrap and fix comment punctuation

This commit is contained in:
2025-04-18 18:16:31 +01:00
parent 0e219975ae
commit 71c0a77a31
5 changed files with 35 additions and 35 deletions

View File

@@ -15,10 +15,10 @@
* Initialize * Initialize
*/ */
init: function () { init: function () {
// Initialize components // Initialize components.
this.initComponents(); this.initComponents();
// Bind events // Bind events.
this.bindEvents(); this.bindEvents();
}, },
@@ -26,17 +26,17 @@
* Initialize components * Initialize components
*/ */
initComponents: function () { initComponents: function () {
// Initialize any components here // Initialize any components here.
}, },
/** /**
* Bind events * Bind events
*/ */
bindEvents: function () { bindEvents: function () {
// Example: Toggle sections // Example: Toggle sections.
$( '.wpst-toggle-section' ).on( 'click', this.toggleSection ); $( '.wpst-toggle-section' ).on( 'click', this.toggleSection );
// Example: Form submission // Example: Form submission.
$( '#wpst-settings-form' ).on( 'submit', this.handleFormSubmit ); $( '#wpst-settings-form' ).on( 'submit', this.handleFormSubmit );
}, },
@@ -67,10 +67,10 @@
const $submitButton = $form.find( 'input[type="submit"]' ); const $submitButton = $form.find( 'input[type="submit"]' );
const formData = $form.serialize(); const formData = $form.serialize();
// Disable submit button and show loading state // Disable submit button and show loading state.
$submitButton.prop( 'disabled', true ).addClass( 'loading' ); $submitButton.prop( 'disabled', true ).addClass( 'loading' );
// Send AJAX request // Send AJAX request.
$.ajax( $.ajax(
{ {
url: wpstData.ajaxUrl, url: wpstData.ajaxUrl,
@@ -91,7 +91,7 @@
WPSTAdmin.showNotice( 'error', 'An error occurred. Please try again.' ); WPSTAdmin.showNotice( 'error', 'An error occurred. Please try again.' );
}, },
complete: function () { complete: function () {
// Re-enable submit button and remove loading state // Re-enable submit button and remove loading state.
$submitButton.prop( 'disabled', false ).removeClass( 'loading' ); $submitButton.prop( 'disabled', false ).removeClass( 'loading' );
} }
} }
@@ -107,10 +107,10 @@
showNotice: function (type, message) { showNotice: function (type, message) {
const $notice = $( '<div class="wpst-notice ' + type + '"><p>' + message + '</p></div>' ); const $notice = $( '<div class="wpst-notice ' + type + '"><p>' + message + '</p></div>' );
// Add notice to the page // Add notice to the page.
$( '.wpst-notices' ).html( $notice ); $( '.wpst-notices' ).html( $notice );
// Automatically remove notice after 5 seconds // Automatically remove notice after 5 seconds.
setTimeout( setTimeout(
function () { function () {
$notice.fadeOut( $notice.fadeOut(
@@ -125,7 +125,7 @@
} }
}; };
// Initialize when document is ready // Initialize when document is ready.
$( document ).ready( $( document ).ready(
function () { function () {
WPSTAdmin.init(); WPSTAdmin.init();

View File

@@ -25,10 +25,10 @@
* Initialize * Initialize
*/ */
init: function () { init: function () {
// Cache DOM elements // Cache DOM elements.
this.$modal = $( '#wpst-update-source-modal' ); this.$modal = $( '#wpst-update-source-modal' );
// Bind events // Bind events.
this.bindEvents(); this.bindEvents();
}, },
@@ -36,10 +36,10 @@
* Bind events * Bind events
*/ */
bindEvents: function () { bindEvents: function () {
// Open modal when clicking on the update source link // Open modal when clicking on the update source link.
$( document ).on( 'click', '.wpst-update-source-selector', this.openModal.bind( this ) ); $( document ).on( 'click', '.wpst-update-source-selector', this.openModal.bind( this ) );
// Close modal when clicking on the close button or outside the modal // Close modal when clicking on the close button or outside the modal.
this.$modal.on( 'click', '.wpst-modal-close', this.closeModal.bind( this ) ); this.$modal.on( 'click', '.wpst-modal-close', this.closeModal.bind( this ) );
$( document ).on( $( document ).on(
'click', 'click',
@@ -51,10 +51,10 @@
} }
); );
// Select source option // Select source option.
this.$modal.on( 'click', '.wpst-source-option', this.selectSource.bind( this ) ); this.$modal.on( 'click', '.wpst-source-option', this.selectSource.bind( this ) );
// Save source selection // Save source selection.
this.$modal.on( 'click', '#wpst-save-source', this.saveSource.bind( this ) ); this.$modal.on( 'click', '#wpst-save-source', this.saveSource.bind( this ) );
}, },
@@ -83,14 +83,14 @@
selectSource: function (e) { selectSource: function (e) {
const $option = $( e.currentTarget ); const $option = $( e.currentTarget );
// Update selected state // Update selected state.
this.$modal.find( '.wpst-source-option' ).removeClass( 'selected' ); this.$modal.find( '.wpst-source-option' ).removeClass( 'selected' );
$option.addClass( 'selected' ); $option.addClass( 'selected' );
// Update radio button // Update radio button.
$option.find( 'input[type="radio"]' ).prop( 'checked', true ); $option.find( 'input[type="radio"]' ).prop( 'checked', true );
// Store selected source // Store selected source.
this.selectedSource = $option.find( 'input[type="radio"]' ).val(); this.selectedSource = $option.find( 'input[type="radio"]' ).val();
}, },
@@ -98,31 +98,31 @@
* Save the selected source * Save the selected source
*/ */
saveSource: function () { saveSource: function () {
// Validate selection // Validate selection.
if ( ! this.selectedSource) { if ( ! this.selectedSource) {
this.showMessage( 'error', 'Please select an update source.' ); this.showMessage( 'error', 'Please select an update source.' );
return; return;
} }
// Show loading state // Show loading state.
const $saveButton = $( '#wpst-save-source' ); const $saveButton = $( '#wpst-save-source' );
$saveButton.prop( 'disabled', true ).html( '<span class="wpst-loading"></span> Saving...' ); $saveButton.prop( 'disabled', true ).html( '<span class="wpst-loading"></span> Saving...' );
// Send AJAX request // Send AJAX request.
$.ajax( $.ajax(
{ {
url: wpstModalData.ajaxUrl, url: wpstModalData.ajaxUrl, // WordPress AJAX URL.
type: 'POST', type: 'POST',
data: { data: {
action: 'wpst_set_update_source', action: 'wpst_set_update_source', // AJAX action hook.
nonce: wpstModalData.nonce, nonce: wpstModalData.nonce, // Security nonce.
source: this.selectedSource source: this.selectedSource
}, },
success: function (response) { success: function (response) {
if (response.success) { if (response.success) {
WPSTUpdateSourceSelector.showMessage( 'success', response.data.message ); WPSTUpdateSourceSelector.showMessage( 'success', response.data.message );
// Close modal after a short delay // Close modal after a short delay.
setTimeout( setTimeout(
function () { function () {
WPSTUpdateSourceSelector.closeModal(); WPSTUpdateSourceSelector.closeModal();
@@ -137,7 +137,7 @@
WPSTUpdateSourceSelector.showMessage( 'error', 'An error occurred. Please try again.' ); WPSTUpdateSourceSelector.showMessage( 'error', 'An error occurred. Please try again.' );
}, },
complete: function () { complete: function () {
// Reset button state // Reset button state.
$saveButton.prop( 'disabled', false ).text( wpstModalData.i18n.confirm ); $saveButton.prop( 'disabled', false ).text( wpstModalData.i18n.confirm );
} }
} }
@@ -153,10 +153,10 @@
showMessage: function (type, message) { showMessage: function (type, message) {
const $message = this.$modal.find( '.wpst-modal-message' ); const $message = this.$modal.find( '.wpst-modal-message' );
// Set message content and type // Set message content and type.
$message.html( message ).removeClass( 'success error' ).addClass( type ).show(); $message.html( message ).removeClass( 'success error' ).addClass( type ).show();
// Hide message after a delay for success messages // Hide message after a delay for success messages.
if (type === 'success') { if (type === 'success') {
setTimeout( setTimeout(
function () { function () {
@@ -168,7 +168,7 @@
} }
}; };
// Initialize when document is ready // Initialize when document is ready.
$( document ).ready( $( document ).ready(
function () { function () {
WPSTUpdateSourceSelector.init(); WPSTUpdateSourceSelector.init();

View File

@@ -26,7 +26,7 @@ if ( ! defined( 'ABSPATH' ) ) {
<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' );
?> ?>

View File

@@ -49,6 +49,6 @@ class Plugin {
* Initialize the plugin * Initialize the plugin
*/ */
public function init() { public function init() {
// Initialization logic goes here // Initialization logic goes here.
} }
} }

View File

@@ -24,6 +24,6 @@ define('WPST_VERSION', '0.1.0');
* Now we include any plugin files that we need to be able to run the tests. * Now we include any plugin files that we need to be able to run the tests.
* This should be files that define the functions and classes you're going to test. * This should be files that define the functions and classes you're going to test.
*/ */
require_once WPST_PLUGIN_DIR . 'includes/core.php'; require_once WPST_PLUGIN_DIR . 'includes/class-core.php';
require_once WPST_PLUGIN_DIR . 'includes/plugin.php'; require_once WPST_PLUGIN_DIR . 'includes/class-plugin.php';
require_once WPST_PLUGIN_DIR . 'admin/lib/admin.php'; require_once WPST_PLUGIN_DIR . 'admin/lib/admin.php';