From f87ba61313749b74fbde807ee388fd8b6e73b620 Mon Sep 17 00:00:00 2001 From: Jakaria Istauk Date: Tue, 28 Nov 2023 11:58:10 +0600 Subject: [PATCH 01/18] Plugin check UX improvement for results --- assets/js/plugin-check-admin.js | 53 +++++++++++++++++++++++++++++++++ templates/results-table.php | 5 +++- 2 files changed, 57 insertions(+), 1 deletion(-) diff --git a/assets/js/plugin-check-admin.js b/assets/js/plugin-check-admin.js index 45b35d03d..4d96aaa76 100644 --- a/assets/js/plugin-check-admin.js +++ b/assets/js/plugin-check-admin.js @@ -108,6 +108,11 @@ for ( let i = 0; i < categoriesList.length; i++ ) { categoriesList[ i ].disabled = false; } + + //Adding Open All/Collapse All button + if( resultsContainer.innerHTML !== '' ){ + resultsContainer.innerHTML = '
' + resultsContainer.innerHTML; + } } /** @@ -469,4 +474,52 @@ const template = templates[ templateSlug ]; return template( data ); } + + //Manage collapse/open tables click event + document.addEventListener('click', function(e) { + e.preventDefault(); + let button = e.target; + + //Manage Collapse/Open All tables separately + if( button.classList.contains('collapse-btn') ){ + var heading = button.closest('.plugin-check__results-heading'); + var dataIndex = heading.getAttribute('data-index'); + var tableContainer = document.querySelector('#plugin-check__results-table-'+dataIndex); + + // Toggle the visibility of the table container + if (tableContainer.style.display === 'none') { + tableContainer.style.display = 'table'; + button.innerHTML = 'Collapse'; + } else { + tableContainer.style.display = 'none'; + button.innerHTML = 'Open'; + } + } + + //Manage Collapse/Open All tables together + if( button.classList.contains('clollaps-all') ){ + var tableContainers = document.querySelectorAll('.plugin-check__results-table'); + var buttons = document.querySelectorAll('.collapse-btn'); + var state = button.getAttribute('data-state'); + var isVisible = state && state === 'open'; + + //Collapase/Open All tables + tableContainers.forEach(function(tableContainer) { + tableContainer.style.display = isVisible ? 'none' : 'table'; + }); + + //Change All buttons text + buttons.forEach(function(_button) { + _button.innerHTML = isVisible ? 'Open' : 'Collapse'; + _button.setAttribute( 'data-state', isVisible ? 'closed' : 'open' ); + }); + + //Change Collapse All/Open All Button text + button.innerHTML = isVisible ? 'Open All' : 'Collapse All'; + + //Change Collapse All/Open All Button attribute + button.setAttribute( 'data-state', isVisible ? 'closed' : 'open' ); + } + }); + } )( PLUGIN_CHECK ); /* global PLUGIN_CHECK */ diff --git a/templates/results-table.php b/templates/results-table.php index 2c10949b2..aa16d285e 100644 --- a/templates/results-table.php +++ b/templates/results-table.php @@ -1,4 +1,7 @@ -

{{ data.file }}

+

+ {{ data.file }} + +

From 5980a972ffc1d4cae22c8878c4de55114e10fe3b Mon Sep 17 00:00:00 2001 From: Jakaria Istauk Date: Tue, 28 Nov 2023 12:13:36 +0600 Subject: [PATCH 02/18] Fix js lint --- assets/js/plugin-check-admin.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/assets/js/plugin-check-admin.js b/assets/js/plugin-check-admin.js index 4d96aaa76..3c5fb7065 100644 --- a/assets/js/plugin-check-admin.js +++ b/assets/js/plugin-check-admin.js @@ -110,8 +110,8 @@ } //Adding Open All/Collapse All button - if( resultsContainer.innerHTML !== '' ){ - resultsContainer.innerHTML = '
' + resultsContainer.innerHTML; + if ( resultsContainer.innerHTML !== '' ) { + resultsContainer.innerHTML = '
' +resultsContainer.innerHTML; } } @@ -482,9 +482,9 @@ //Manage Collapse/Open All tables separately if( button.classList.contains('collapse-btn') ){ - var heading = button.closest('.plugin-check__results-heading'); - var dataIndex = heading.getAttribute('data-index'); - var tableContainer = document.querySelector('#plugin-check__results-table-'+dataIndex); + let heading = button.closest('.plugin-check__results-heading'), + dataIndex = heading.getAttribute('data-index'), + tableContainer = document.querySelector('#plugin-check__results-table-'+dataIndex); // Toggle the visibility of the table container if (tableContainer.style.display === 'none') { @@ -498,10 +498,10 @@ //Manage Collapse/Open All tables together if( button.classList.contains('clollaps-all') ){ - var tableContainers = document.querySelectorAll('.plugin-check__results-table'); - var buttons = document.querySelectorAll('.collapse-btn'); - var state = button.getAttribute('data-state'); - var isVisible = state && state === 'open'; + let tableContainers = document.querySelectorAll('.plugin-check__results-table'), + buttons = document.querySelectorAll('.collapse-btn'), + state = button.getAttribute('data-state'), + isVisible = state && state === 'open'; //Collapase/Open All tables tableContainers.forEach(function(tableContainer) { From 84928e07875a082303994bfc2023eb159ca4adb9 Mon Sep 17 00:00:00 2001 From: Jakaria Istauk Date: Tue, 28 Nov 2023 12:24:26 +0600 Subject: [PATCH 03/18] Fix js lint --- assets/js/plugin-check-admin.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/assets/js/plugin-check-admin.js b/assets/js/plugin-check-admin.js index 3c5fb7065..8f17a4c59 100644 --- a/assets/js/plugin-check-admin.js +++ b/assets/js/plugin-check-admin.js @@ -111,7 +111,7 @@ //Adding Open All/Collapse All button if ( resultsContainer.innerHTML !== '' ) { - resultsContainer.innerHTML = '
' +resultsContainer.innerHTML; + resultsContainer.innerHTML = '
' + resultsContainer.innerHTML; } } @@ -474,7 +474,7 @@ const template = templates[ templateSlug ]; return template( data ); } - + //Manage collapse/open tables click event document.addEventListener('click', function(e) { e.preventDefault(); @@ -512,7 +512,7 @@ buttons.forEach(function(_button) { _button.innerHTML = isVisible ? 'Open' : 'Collapse'; _button.setAttribute( 'data-state', isVisible ? 'closed' : 'open' ); - }); + } ); //Change Collapse All/Open All Button text button.innerHTML = isVisible ? 'Open All' : 'Collapse All'; @@ -520,6 +520,6 @@ //Change Collapse All/Open All Button attribute button.setAttribute( 'data-state', isVisible ? 'closed' : 'open' ); } - }); + } ); } )( PLUGIN_CHECK ); /* global PLUGIN_CHECK */ From f539b5abe12f16a5d2a8e6b276ef0d87258697b4 Mon Sep 17 00:00:00 2001 From: Jakaria Istauk Date: Wed, 29 Nov 2023 09:34:41 +0600 Subject: [PATCH 04/18] Fix js lint error --- assets/js/plugin-check-admin.js | 42 ++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/assets/js/plugin-check-admin.js b/assets/js/plugin-check-admin.js index 8f17a4c59..c727e9f0f 100644 --- a/assets/js/plugin-check-admin.js +++ b/assets/js/plugin-check-admin.js @@ -474,20 +474,22 @@ const template = templates[ templateSlug ]; return template( data ); } - - //Manage collapse/open tables click event - document.addEventListener('click', function(e) { + + /** + * Manage collapse/open tables click event + */ + document.addEventListener( 'click' , function( e ) { e.preventDefault(); - let button = e.target; - + const button = e.target; //Manage Collapse/Open All tables separately - if( button.classList.contains('collapse-btn') ){ - let heading = button.closest('.plugin-check__results-heading'), - dataIndex = heading.getAttribute('data-index'), - tableContainer = document.querySelector('#plugin-check__results-table-'+dataIndex); + if( button.classList.contains( 'collapse-btn' ) ){ + const dataIndex = button.closest( '.plugin-check__results-heading' ).getAttribute( 'data-index' ); + const tableContainer = document.querySelector( + '#plugin-check__results-table-' + dataIndex + ); // Toggle the visibility of the table container - if (tableContainer.style.display === 'none') { + if ( tableContainer.style.display === 'none' ) { tableContainer.style.display = 'table'; button.innerHTML = 'Collapse'; } else { @@ -497,21 +499,23 @@ } //Manage Collapse/Open All tables together - if( button.classList.contains('clollaps-all') ){ - let tableContainers = document.querySelectorAll('.plugin-check__results-table'), - buttons = document.querySelectorAll('.collapse-btn'), - state = button.getAttribute('data-state'), - isVisible = state && state === 'open'; + if( button.classList.contains( 'clollaps-all' ) ){ + const tableContainers = document.querySelectorAll( '.plugin-check__results-table' ); + const buttons = document.querySelectorAll( '.collapse-btn' ); + const state = button.getAttribute( 'data-state' ); + const isVisible = state && state === 'open'; //Collapase/Open All tables - tableContainers.forEach(function(tableContainer) { + tableContainers.forEach( function ( tableContainer ) { tableContainer.style.display = isVisible ? 'none' : 'table'; - }); + } ); //Change All buttons text - buttons.forEach(function(_button) { + buttons.forEach( function ( _button ) { _button.innerHTML = isVisible ? 'Open' : 'Collapse'; - _button.setAttribute( 'data-state', isVisible ? 'closed' : 'open' ); + _button.setAttribute( 'data-state', + isVisible ? 'closed' : 'open' + ); } ); //Change Collapse All/Open All Button text From f2d7f8004965c28fabba5ecaa2f6fc1eec8d1339 Mon Sep 17 00:00:00 2001 From: Jakaria Istauk Date: Wed, 29 Nov 2023 09:59:20 +0600 Subject: [PATCH 05/18] Prevent click error fix --- assets/js/plugin-check-admin.js | 1 - 1 file changed, 1 deletion(-) diff --git a/assets/js/plugin-check-admin.js b/assets/js/plugin-check-admin.js index c727e9f0f..7379f225d 100644 --- a/assets/js/plugin-check-admin.js +++ b/assets/js/plugin-check-admin.js @@ -479,7 +479,6 @@ * Manage collapse/open tables click event */ document.addEventListener( 'click' , function( e ) { - e.preventDefault(); const button = e.target; //Manage Collapse/Open All tables separately if( button.classList.contains( 'collapse-btn' ) ){ From 5a2255ee5f4e73197dd4913994f996119baf2738 Mon Sep 17 00:00:00 2001 From: Mukesh Panchal Date: Tue, 12 Dec 2023 16:13:40 +0530 Subject: [PATCH 06/18] Fix JS lint --- assets/js/plugin-check-admin.js | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/assets/js/plugin-check-admin.js b/assets/js/plugin-check-admin.js index 7379f225d..f22b0bbef 100644 --- a/assets/js/plugin-check-admin.js +++ b/assets/js/plugin-check-admin.js @@ -111,7 +111,9 @@ //Adding Open All/Collapse All button if ( resultsContainer.innerHTML !== '' ) { - resultsContainer.innerHTML = '
' + resultsContainer.innerHTML; + resultsContainer.innerHTML = + '
' + + resultsContainer.innerHTML; } } @@ -474,18 +476,20 @@ const template = templates[ templateSlug ]; return template( data ); } - + /** * Manage collapse/open tables click event */ - document.addEventListener( 'click' , function( e ) { + document.addEventListener( 'click', function ( e ) { const button = e.target; //Manage Collapse/Open All tables separately - if( button.classList.contains( 'collapse-btn' ) ){ - const dataIndex = button.closest( '.plugin-check__results-heading' ).getAttribute( 'data-index' ); - const tableContainer = document.querySelector( - '#plugin-check__results-table-' + dataIndex - ); + if ( button.classList.contains( 'collapse-btn' ) ) { + const dataIndex = button + .closest( '.plugin-check__results-heading' ) + .getAttribute( 'data-index' ); + const tableContainer = document.querySelector( + '#plugin-check__results-table-' + dataIndex + ); // Toggle the visibility of the table container if ( tableContainer.style.display === 'none' ) { @@ -498,8 +502,10 @@ } //Manage Collapse/Open All tables together - if( button.classList.contains( 'clollaps-all' ) ){ - const tableContainers = document.querySelectorAll( '.plugin-check__results-table' ); + if ( button.classList.contains( 'clollaps-all' ) ) { + const tableContainers = document.querySelectorAll( + '.plugin-check__results-table' + ); const buttons = document.querySelectorAll( '.collapse-btn' ); const state = button.getAttribute( 'data-state' ); const isVisible = state && state === 'open'; @@ -512,7 +518,8 @@ //Change All buttons text buttons.forEach( function ( _button ) { _button.innerHTML = isVisible ? 'Open' : 'Collapse'; - _button.setAttribute( 'data-state', + _button.setAttribute( + 'data-state', isVisible ? 'closed' : 'open' ); } ); @@ -523,6 +530,5 @@ //Change Collapse All/Open All Button attribute button.setAttribute( 'data-state', isVisible ? 'closed' : 'open' ); } - } ); - + } ); } )( PLUGIN_CHECK ); /* global PLUGIN_CHECK */ From 51e00ea08c8ebf05f5ee9c42a4ed6948d5ca17ba Mon Sep 17 00:00:00 2001 From: Jakaria Istauk Date: Tue, 12 Dec 2023 22:36:16 +0600 Subject: [PATCH 07/18] Fix according feedback --- assets/js/plugin-check-admin.js | 22 +++++++++++----------- includes/Admin/Admin_Page.php | 4 ++++ templates/results-table.php | 2 +- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/assets/js/plugin-check-admin.js b/assets/js/plugin-check-admin.js index f22b0bbef..222b6ed10 100644 --- a/assets/js/plugin-check-admin.js +++ b/assets/js/plugin-check-admin.js @@ -109,10 +109,10 @@ categoriesList[ i ].disabled = false; } - //Adding Open All/Collapse All button + // Adding Open All/Collapse All button if ( resultsContainer.innerHTML !== '' ) { resultsContainer.innerHTML = - '
' + + '
' + resultsContainer.innerHTML; } } @@ -482,7 +482,7 @@ */ document.addEventListener( 'click', function ( e ) { const button = e.target; - //Manage Collapse/Open All tables separately + // Manage Collapse/Open All tables separately if ( button.classList.contains( 'collapse-btn' ) ) { const dataIndex = button .closest( '.plugin-check__results-heading' ) @@ -494,14 +494,14 @@ // Toggle the visibility of the table container if ( tableContainer.style.display === 'none' ) { tableContainer.style.display = 'table'; - button.innerHTML = 'Collapse'; + button.innerHTML = PLUGIN_CHECK.collapse; } else { tableContainer.style.display = 'none'; - button.innerHTML = 'Open'; + button.innerHTML = PLUGIN_CHECK.open; } } - //Manage Collapse/Open All tables together + // Manage Collapse/Open All tables together if ( button.classList.contains( 'clollaps-all' ) ) { const tableContainers = document.querySelectorAll( '.plugin-check__results-table' @@ -510,12 +510,12 @@ const state = button.getAttribute( 'data-state' ); const isVisible = state && state === 'open'; - //Collapase/Open All tables + // Collapase/Open All tables tableContainers.forEach( function ( tableContainer ) { tableContainer.style.display = isVisible ? 'none' : 'table'; } ); - //Change All buttons text + // Change All buttons text buttons.forEach( function ( _button ) { _button.innerHTML = isVisible ? 'Open' : 'Collapse'; _button.setAttribute( @@ -524,10 +524,10 @@ ); } ); - //Change Collapse All/Open All Button text - button.innerHTML = isVisible ? 'Open All' : 'Collapse All'; + // Change Collapse All/Open All Button text + button.innerHTML = isVisible ? PLUGIN_CHECK.openAll : PLUGIN_CHECK.collapsAll; - //Change Collapse All/Open All Button attribute + // Change Collapse All/Open All Button attribute button.setAttribute( 'data-state', isVisible ? 'closed' : 'open' ); } } ); diff --git a/includes/Admin/Admin_Page.php b/includes/Admin/Admin_Page.php index ba790c737..6c799299e 100644 --- a/includes/Admin/Admin_Page.php +++ b/includes/Admin/Admin_Page.php @@ -118,6 +118,10 @@ public function enqueue_scripts() { 'actionCleanUpRuntimeEnvironment' => Admin_AJAX::ACTION_CLEAN_UP_ENVIRONMENT, 'successMessage' => __( 'No errors found.', 'plugin-check' ), 'errorMessage' => __( 'Errors were found.', 'plugin-check' ), + 'collapsAll' => __( 'Clollaps All', 'plugin-check' ), + 'openAll' => __( 'Open All', 'plugin-check' ), + 'collapse' => __( 'Collapse', 'plugin-check' ), + 'open' => __( 'Open', 'plugin-check' ), ) ), 'before' diff --git a/templates/results-table.php b/templates/results-table.php index aa16d285e..12d891c22 100644 --- a/templates/results-table.php +++ b/templates/results-table.php @@ -1,6 +1,6 @@

{{ data.file }} - +

From 461e727fe6128c5ecc8383ba2d8186a410e4b817 Mon Sep 17 00:00:00 2001 From: Jakaria Istauk Date: Tue, 12 Dec 2023 22:39:34 +0600 Subject: [PATCH 08/18] code formatted by lint-js --- assets/js/plugin-check-admin.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/assets/js/plugin-check-admin.js b/assets/js/plugin-check-admin.js index 222b6ed10..4b6149a7a 100644 --- a/assets/js/plugin-check-admin.js +++ b/assets/js/plugin-check-admin.js @@ -112,7 +112,9 @@ // Adding Open All/Collapse All button if ( resultsContainer.innerHTML !== '' ) { resultsContainer.innerHTML = - '
' + + '
' + resultsContainer.innerHTML; } } @@ -525,7 +527,9 @@ } ); // Change Collapse All/Open All Button text - button.innerHTML = isVisible ? PLUGIN_CHECK.openAll : PLUGIN_CHECK.collapsAll; + button.innerHTML = isVisible + ? PLUGIN_CHECK.openAll + : PLUGIN_CHECK.collapsAll; // Change Collapse All/Open All Button attribute button.setAttribute( 'data-state', isVisible ? 'closed' : 'open' ); From 81a48f05fc98dac94a965ecaf3ad14d6bef932e9 Mon Sep 17 00:00:00 2001 From: Jakaria Istauk Date: Tue, 12 Dec 2023 22:44:54 +0600 Subject: [PATCH 09/18] Fix according feedback --- assets/js/plugin-check-admin.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/assets/js/plugin-check-admin.js b/assets/js/plugin-check-admin.js index 4b6149a7a..1993ab69d 100644 --- a/assets/js/plugin-check-admin.js +++ b/assets/js/plugin-check-admin.js @@ -484,7 +484,7 @@ */ document.addEventListener( 'click', function ( e ) { const button = e.target; - // Manage Collapse/Open All tables separately + // Manage Collapse/Open All tables separately. if ( button.classList.contains( 'collapse-btn' ) ) { const dataIndex = button .closest( '.plugin-check__results-heading' ) @@ -493,7 +493,7 @@ '#plugin-check__results-table-' + dataIndex ); - // Toggle the visibility of the table container + // Toggle the visibility of the table container. if ( tableContainer.style.display === 'none' ) { tableContainer.style.display = 'table'; button.innerHTML = PLUGIN_CHECK.collapse; @@ -503,7 +503,7 @@ } } - // Manage Collapse/Open All tables together + // Manage Collapse/Open All tables together. if ( button.classList.contains( 'clollaps-all' ) ) { const tableContainers = document.querySelectorAll( '.plugin-check__results-table' @@ -512,12 +512,12 @@ const state = button.getAttribute( 'data-state' ); const isVisible = state && state === 'open'; - // Collapase/Open All tables + // Collapase/Open All tables. tableContainers.forEach( function ( tableContainer ) { tableContainer.style.display = isVisible ? 'none' : 'table'; } ); - // Change All buttons text + // Change All buttons text. buttons.forEach( function ( _button ) { _button.innerHTML = isVisible ? 'Open' : 'Collapse'; _button.setAttribute( @@ -526,12 +526,12 @@ ); } ); - // Change Collapse All/Open All Button text + // Change Collapse All/Open All Button text. button.innerHTML = isVisible ? PLUGIN_CHECK.openAll : PLUGIN_CHECK.collapsAll; - // Change Collapse All/Open All Button attribute + // Change Collapse All/Open All Button attribute. button.setAttribute( 'data-state', isVisible ? 'closed' : 'open' ); } } ); From b1fc29d75826e80d890efe619d7339893603b65d Mon Sep 17 00:00:00 2001 From: Jakaria Istauk Date: Tue, 12 Dec 2023 23:00:18 +0600 Subject: [PATCH 10/18] Spelling fix --- assets/js/plugin-check-admin.js | 4 ++-- includes/Admin/Admin_Page.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/assets/js/plugin-check-admin.js b/assets/js/plugin-check-admin.js index 1993ab69d..ea807818f 100644 --- a/assets/js/plugin-check-admin.js +++ b/assets/js/plugin-check-admin.js @@ -113,7 +113,7 @@ if ( resultsContainer.innerHTML !== '' ) { resultsContainer.innerHTML = '
' + resultsContainer.innerHTML; } @@ -529,7 +529,7 @@ // Change Collapse All/Open All Button text. button.innerHTML = isVisible ? PLUGIN_CHECK.openAll - : PLUGIN_CHECK.collapsAll; + : PLUGIN_CHECK.collapseAll; // Change Collapse All/Open All Button attribute. button.setAttribute( 'data-state', isVisible ? 'closed' : 'open' ); diff --git a/includes/Admin/Admin_Page.php b/includes/Admin/Admin_Page.php index 6c799299e..85fdea7fd 100644 --- a/includes/Admin/Admin_Page.php +++ b/includes/Admin/Admin_Page.php @@ -118,7 +118,7 @@ public function enqueue_scripts() { 'actionCleanUpRuntimeEnvironment' => Admin_AJAX::ACTION_CLEAN_UP_ENVIRONMENT, 'successMessage' => __( 'No errors found.', 'plugin-check' ), 'errorMessage' => __( 'Errors were found.', 'plugin-check' ), - 'collapsAll' => __( 'Clollaps All', 'plugin-check' ), + 'collapseAll' => __( 'Clollapse All', 'plugin-check' ), 'openAll' => __( 'Open All', 'plugin-check' ), 'collapse' => __( 'Collapse', 'plugin-check' ), 'open' => __( 'Open', 'plugin-check' ), From 186fa4302a65a55d3389ffaab0aa093d954994e8 Mon Sep 17 00:00:00 2001 From: Jakaria Istauk Date: Wed, 13 Dec 2023 07:58:13 +0600 Subject: [PATCH 11/18] PHP lint error fixed --- includes/Admin/Admin_Page.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/includes/Admin/Admin_Page.php b/includes/Admin/Admin_Page.php index 85fdea7fd..00b92e881 100644 --- a/includes/Admin/Admin_Page.php +++ b/includes/Admin/Admin_Page.php @@ -119,9 +119,9 @@ public function enqueue_scripts() { 'successMessage' => __( 'No errors found.', 'plugin-check' ), 'errorMessage' => __( 'Errors were found.', 'plugin-check' ), 'collapseAll' => __( 'Clollapse All', 'plugin-check' ), - 'openAll' => __( 'Open All', 'plugin-check' ), + 'openAll' => __( 'Open All', 'plugin-check' ), 'collapse' => __( 'Collapse', 'plugin-check' ), - 'open' => __( 'Open', 'plugin-check' ), + 'open' => __( 'Open', 'plugin-check' ), ) ), 'before' From 8fce4aed9f46c1894eae3b9b1c8d34a2d1cb7433 Mon Sep 17 00:00:00 2001 From: Mukesh Panchal Date: Tue, 19 Dec 2023 21:01:58 +0530 Subject: [PATCH 12/18] Fix no check category issue --- includes/Admin/Admin_AJAX.php | 1 + 1 file changed, 1 insertion(+) diff --git a/includes/Admin/Admin_AJAX.php b/includes/Admin/Admin_AJAX.php index 28ba6ea2c..60c177795 100644 --- a/includes/Admin/Admin_AJAX.php +++ b/includes/Admin/Admin_AJAX.php @@ -109,6 +109,7 @@ public function set_up_environment() { } $checks = filter_input( INPUT_POST, 'checks', FILTER_DEFAULT, FILTER_FORCE_ARRAY ); + $checks = is_null( $checks ) ? array() : $checks; $plugin = filter_input( INPUT_POST, 'plugin', FILTER_SANITIZE_FULL_SPECIAL_CHARS ); try { From c3f05efd8637fb0d36a545c135c20b2ffbab2dda Mon Sep 17 00:00:00 2001 From: Nilambar Sharma Date: Wed, 20 Dec 2023 17:19:32 +0545 Subject: [PATCH 13/18] Remove HTML tag from messages --- includes/Checker/Checks/Trademarks_Check.php | 24 +++++++++---------- .../Checker/Checks/Trademarks_Check_Tests.php | 14 +++++------ 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/includes/Checker/Checks/Trademarks_Check.php b/includes/Checker/Checks/Trademarks_Check.php index 7c8093164..8e9180e4b 100644 --- a/includes/Checker/Checks/Trademarks_Check.php +++ b/includes/Checker/Checks/Trademarks_Check.php @@ -348,24 +348,24 @@ private function validate_name_has_no_trademarks( $plugin_name ) { // Trademarks that do NOT end in "-", but are within the FOR_USE_EXCEPTIONS array can be used, but only if it ends with 'for x'. $message = sprintf( /* translators: 1: plugin name, 2: found trademarked term */ - __( 'The plugin name includes a restricted term. Your chosen plugin name - %1$s - contains the restricted term "%2$s" which cannot be used within in your plugin name, unless your plugin name ends with "for %2$s". The term must still not appear anywhere else in your name.', 'plugin-check' ), - '' . esc_html( $plugin_name ) . '', + __( 'The plugin name includes a restricted term. Your chosen plugin name - "%1$s" - contains the restricted term "%2$s" which cannot be used within in your plugin name, unless your plugin name ends with "for %2$s". The term must still not appear anywhere else in your name.', 'plugin-check' ), + esc_html( $plugin_name ), esc_html( trim( $check, '-' ) ) ); } elseif ( trim( $check, '-' ) === $check ) { // Trademarks that do NOT end in "-" indicate slug cannot contain term at all. $message = sprintf( /* translators: 1: plugin name, 2: found trademarked term */ - __( 'The plugin name includes a restricted term. Your chosen plugin name - %1$s - contains the restricted term "%2$s" which cannot be used at all in your plugin name.', 'plugin-check' ), - '' . esc_html( $plugin_name ) . '', + __( 'The plugin name includes a restricted term. Your chosen plugin name - "%1$s" - contains the restricted term "%2$s" which cannot be used at all in your plugin name.', 'plugin-check' ), + esc_html( $plugin_name ), esc_html( trim( $check, '-' ) ) ); } else { // Trademarks ending in "-" indicate slug cannot BEGIN with that term. $message = sprintf( /* translators: 1: plugin name, 2: found trademarked term */ - __( 'The plugin name includes a restricted term. Your chosen plugin name - %1$s - contains the restricted term "%2$s" and cannot be used to begin your plugin name. We disallow the use of certain terms in ways that are abused, or potentially infringe on and/or are misleading with regards to trademarks. You may use the term "%2$s" elsewhere in your plugin name, such as "... for %2$s".', 'plugin-check' ), - '' . esc_html( $plugin_name ) . '', + __( 'The plugin name includes a restricted term. Your chosen plugin name - "%1$s" - contains the restricted term "%2$s" and cannot be used to begin your plugin name. We disallow the use of certain terms in ways that are abused, or potentially infringe on and/or are misleading with regards to trademarks. You may use the term "%2$s" elsewhere in your plugin name, such as "... for %2$s".', 'plugin-check' ), + esc_html( $plugin_name ), esc_html( trim( $check, '-' ) ) ); } @@ -395,24 +395,24 @@ private function validate_slug_has_no_trademarks( $plugin_slug ) { // Trademarks that do NOT end in "-", but are within the FOR_USE_EXCEPTIONS array can be used, but only if it ends with 'for x'. $message = sprintf( /* translators: 1: plugin slug, 2: found trademarked term */ - __( 'The plugin slug includes a restricted term. Your plugin slug - %1$s - contains the restricted term "%2$s" which cannot be used within in your plugin slug, unless your plugin slug ends with "for %2$s". The term must still not appear anywhere else in your plugin slug.', 'plugin-check' ), - '' . esc_html( $plugin_slug ) . '', + __( 'The plugin slug includes a restricted term. Your plugin slug - "%1$s" - contains the restricted term "%2$s" which cannot be used within in your plugin slug, unless your plugin slug ends with "for %2$s". The term must still not appear anywhere else in your plugin slug.', 'plugin-check' ), + esc_html( $plugin_slug ), esc_html( trim( $check, '-' ) ) ); } elseif ( trim( $check, '-' ) === $check ) { // Trademarks that do NOT end in "-" indicate slug cannot contain term at all. $message = sprintf( /* translators: 1: plugin slug, 2: found trademarked term */ - __( 'The plugin slug includes a restricted term. Your plugin slug - %1$s - contains the restricted term "%2$s" which cannot be used at all in your plugin slug.', 'plugin-check' ), - '' . esc_html( $plugin_slug ) . '', + __( 'The plugin slug includes a restricted term. Your plugin slug - "%1$s" - contains the restricted term "%2$s" which cannot be used at all in your plugin slug.', 'plugin-check' ), + esc_html( $plugin_slug ), esc_html( trim( $check, '-' ) ) ); } else { // Trademarks ending in "-" indicate slug cannot BEGIN with that term. $message = sprintf( /* translators: 1: plugin slug, 2: found trademarked term */ - __( 'The plugin slug includes a restricted term. Your plugin slug - %1$s - contains the restricted term "%2$s" and cannot be used to begin your plugin slug. We disallow the use of certain terms in ways that are abused, or potentially infringe on and/or are misleading with regards to trademarks. You may use the term "%2$s" elsewhere in your plugin slug, such as "... for %2$s".', 'plugin-check' ), - '' . esc_html( $plugin_slug ) . '', + __( 'The plugin slug includes a restricted term. Your plugin slug - "%1$s" - contains the restricted term "%2$s" and cannot be used to begin your plugin slug. We disallow the use of certain terms in ways that are abused, or potentially infringe on and/or are misleading with regards to trademarks. You may use the term "%2$s" elsewhere in your plugin slug, such as "... for %2$s".', 'plugin-check' ), + esc_html( $plugin_slug ), esc_html( trim( $check, '-' ) ) ); } diff --git a/tests/phpunit/tests/Checker/Checks/Trademarks_Check_Tests.php b/tests/phpunit/tests/Checker/Checks/Trademarks_Check_Tests.php index 1d9976ccf..018788895 100644 --- a/tests/phpunit/tests/Checker/Checks/Trademarks_Check_Tests.php +++ b/tests/phpunit/tests/Checker/Checks/Trademarks_Check_Tests.php @@ -55,43 +55,43 @@ public function data_trademarks_check() { Trademarks_Check::TYPE_README, 'test-trademarks-plugin-readme-errors/load.php', 'readme.txt', - 'The plugin name includes a restricted term. Your chosen plugin name - Test Plugin with readme - contains the restricted term "plugin" which cannot be used at all in your plugin name.', + 'The plugin name includes a restricted term. Your chosen plugin name - " Test Plugin with readme " - contains the restricted term "plugin" which cannot be used at all in your plugin name.', ), 'Plugin header - Test Trademarks Plugin Header Name Errors' => array( Trademarks_Check::TYPE_NAME, 'test-trademarks-plugin-header-name-errors/load.php', 'load.php', - 'The plugin name includes a restricted term. Your chosen plugin name - Test Trademarks Plugin Header Name Errors - contains the restricted term "plugin" which cannot be used at all in your plugin name.', + 'The plugin name includes a restricted term. Your chosen plugin name - "Test Trademarks Plugin Header Name Errors" - contains the restricted term "plugin" which cannot be used at all in your plugin name.', ), 'Plugin slug - test-trademarks-plugin-header-slug-errors' => array( Trademarks_Check::TYPE_SLUG, 'test-trademarks-plugin-header-slug-errors/load.php', 'load.php', - 'The plugin slug includes a restricted term. Your plugin slug - test-trademarks-plugin-header-slug-errors - contains the restricted term "plugin" which cannot be used at all in your plugin slug.', + 'The plugin slug includes a restricted term. Your plugin slug - "test-trademarks-plugin-header-slug-errors" - contains the restricted term "plugin" which cannot be used at all in your plugin slug.', ), 'Plugin headers - WooCommerce Example String' => array( Trademarks_Check::TYPE_NAME, 'test-trademarks-plugin-header-woocommerce-string/load.php', 'load.php', - 'The plugin name includes a restricted term. Your chosen plugin name - WooCommerce Example String - contains the restricted term "woocommerce" which cannot be used within in your plugin name, unless your plugin name ends with "for woocommerce". The term must still not appear anywhere else in your name.', + 'The plugin name includes a restricted term. Your chosen plugin name - "WooCommerce Example String" - contains the restricted term "woocommerce" which cannot be used within in your plugin name, unless your plugin name ends with "for woocommerce". The term must still not appear anywhere else in your name.', ), 'Plugin headers - WooCommerce String for WooCommerce' => array( Trademarks_Check::TYPE_NAME, 'test-trademarks-plugin-header-woocommerce-string-for-woocommerce/load.php', 'load.php', - 'The plugin name includes a restricted term. Your chosen plugin name - WooCommerce String for WooCommerce - contains the restricted term "woocommerce" which cannot be used within in your plugin name, unless your plugin name ends with "for woocommerce". The term must still not appear anywhere else in your name.', + 'The plugin name includes a restricted term. Your chosen plugin name - "WooCommerce String for WooCommerce" - contains the restricted term "woocommerce" which cannot be used within in your plugin name, unless your plugin name ends with "for woocommerce". The term must still not appear anywhere else in your name.', ), 'Plugin headers - WordPress String for WooCommerce' => array( Trademarks_Check::TYPE_NAME, 'test-trademarks-plugin-header-wordpress-string-for-woocommerce/load.php', 'load.php', - 'The plugin name includes a restricted term. Your chosen plugin name - WordPress String for WooCommerce - contains the restricted term "wordpress" which cannot be used at all in your plugin name.', + 'The plugin name includes a restricted term. Your chosen plugin name - "WordPress String for WooCommerce" - contains the restricted term "wordpress" which cannot be used at all in your plugin name.', ), 'Plugin headers portmanteaus' => array( Trademarks_Check::TYPE_NAME, 'test-trademarks-plugin-header-portmanteaus/load.php', 'load.php', - 'The plugin name includes a restricted term. Your chosen plugin name - WooXample - contains the restricted term "woo" which cannot be used at all in your plugin name.', + 'The plugin name includes a restricted term. Your chosen plugin name - "WooXample" - contains the restricted term "woo" which cannot be used at all in your plugin name.', ), ); } From 25252f75b93bcdd4ae5767e1164e5b66c87202a0 Mon Sep 17 00:00:00 2001 From: Nilambar Sharma Date: Thu, 21 Dec 2023 11:15:28 +0545 Subject: [PATCH 14/18] Fix plugin name from readme in Trademarks check --- includes/Checker/Checks/Trademarks_Check.php | 2 +- tests/phpunit/tests/Checker/Checks/Trademarks_Check_Tests.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/includes/Checker/Checks/Trademarks_Check.php b/includes/Checker/Checks/Trademarks_Check.php index 8e9180e4b..0c4a2650b 100644 --- a/includes/Checker/Checks/Trademarks_Check.php +++ b/includes/Checker/Checks/Trademarks_Check.php @@ -256,7 +256,7 @@ private function check_for_name_in_readme( Check_Result $result, array $files ) return; } - $name = $matches[1]; + $name = trim( $matches[1] ); try { $this->validate_name_has_no_trademarks( $name ); diff --git a/tests/phpunit/tests/Checker/Checks/Trademarks_Check_Tests.php b/tests/phpunit/tests/Checker/Checks/Trademarks_Check_Tests.php index 018788895..ad7a92a7a 100644 --- a/tests/phpunit/tests/Checker/Checks/Trademarks_Check_Tests.php +++ b/tests/phpunit/tests/Checker/Checks/Trademarks_Check_Tests.php @@ -55,7 +55,7 @@ public function data_trademarks_check() { Trademarks_Check::TYPE_README, 'test-trademarks-plugin-readme-errors/load.php', 'readme.txt', - 'The plugin name includes a restricted term. Your chosen plugin name - " Test Plugin with readme " - contains the restricted term "plugin" which cannot be used at all in your plugin name.', + 'The plugin name includes a restricted term. Your chosen plugin name - "Test Plugin with readme" - contains the restricted term "plugin" which cannot be used at all in your plugin name.', ), 'Plugin header - Test Trademarks Plugin Header Name Errors' => array( Trademarks_Check::TYPE_NAME, From 2c1e34157697f99c4ce960addce744ce2173d575 Mon Sep 17 00:00:00 2001 From: Nilambar Sharma Date: Wed, 13 Dec 2023 16:45:35 +0545 Subject: [PATCH 15/18] Add blueprint for preview --- .wordpress-org/blueprints/blueprint.json | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 .wordpress-org/blueprints/blueprint.json diff --git a/.wordpress-org/blueprints/blueprint.json b/.wordpress-org/blueprints/blueprint.json new file mode 100644 index 000000000..858aca502 --- /dev/null +++ b/.wordpress-org/blueprints/blueprint.json @@ -0,0 +1,24 @@ +{ + "$schema": "https://playground.wordpress.net/blueprint-schema.json", + "landingPage": "\/wp-admin\/tools.php?page=plugin-check", + "phpExtensionBundles": [ + "kitchen-sink" + ], + "steps": [ + { + "step": "login", + "username": "admin", + "password": "password" + }, + { + "step": "installPlugin", + "pluginZipFile": { + "resource": "wordpress.org\/plugins", + "slug": "plugin-check" + }, + "options": { + "activate": true + } + } + ] +} From a3757e77c15ad1e4a1cd34b8de9117a6a3867107 Mon Sep 17 00:00:00 2001 From: Nilambar Sharma Date: Mon, 18 Dec 2023 11:40:53 +0545 Subject: [PATCH 16/18] Fix plugins dropdown --- templates/admin-page.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/templates/admin-page.php b/templates/admin-page.php index 37445e1c8..65338e975 100644 --- a/templates/admin-page.php +++ b/templates/admin-page.php @@ -23,7 +23,9 @@