From 1bc96bcc00076180937b4926bd3a78080f725af2 Mon Sep 17 00:00:00 2001 From: Mukesh Panchal Date: Tue, 24 Oct 2023 16:56:51 +0530 Subject: [PATCH 1/8] Save categories value --- assets/js/plugin-check-admin.js | 25 +++++++++++++++++++++++++ includes/Admin/Admin_Page.php | 9 ++++++++- templates/admin-page.php | 13 ++++++++++++- 3 files changed, 45 insertions(+), 2 deletions(-) diff --git a/assets/js/plugin-check-admin.js b/assets/js/plugin-check-admin.js index 089b32bf8..962b0a359 100644 --- a/assets/js/plugin-check-admin.js +++ b/assets/js/plugin-check-admin.js @@ -35,6 +35,31 @@ canRunChecks(); pluginsList.addEventListener( 'change', canRunChecks ); + /** + * Saves the user settings. + * + * @since n.e.x.t + */ + function saveUserSettings() { + const selectedCategories = []; + + // Assuming you have a list of category checkboxes, find the selected ones. + categoriesList.forEach( function ( checkbox ) { + if ( checkbox.checked ) { + selectedCategories.push( checkbox.value ); + } + } ); + + // Join the selected category slugs with '__' and save it as a user setting. + const settingValue = selectedCategories.join( '__' ); + window.setUserSetting( 'category_preferences', settingValue ); + } + + // Attach the saveUserSettings function when a category checkbox is clicked. + categoriesList.forEach( function ( checkbox ) { + checkbox.addEventListener( 'change', saveUserSettings ); + } ); + // When the Check it button is clicked. checkItButton.addEventListener( 'click', ( e ) => { e.preventDefault(); diff --git a/includes/Admin/Admin_Page.php b/includes/Admin/Admin_Page.php index 51588bdef..40ef5765a 100644 --- a/includes/Admin/Admin_Page.php +++ b/includes/Admin/Admin_Page.php @@ -150,9 +150,14 @@ private function get_available_plugins() { * Renders the "Plugin Check" page. * * @since n.e.x.t + * + * @global array $available_plugins The list of available plugins. + * @global string $selected_plugin_basename The selected plugin basename. + * @global array $categories An array of categories. + * @global mixed $user_settings The user interface setting value. */ public function render_page() { - global $available_plugins, $selected_plugin_basename, $categories; + global $available_plugins, $selected_plugin_basename, $categories, $user_settings; $available_plugins = $this->get_available_plugins(); @@ -160,6 +165,8 @@ public function render_page() { $categories = Check_Categories::get_categories(); + $user_settings = get_user_setting( 'category_preferences' ); + require WP_PLUGIN_CHECK_PLUGIN_DIR_PATH . 'templates/admin-page.php'; } diff --git a/templates/admin-page.php b/templates/admin-page.php index 2188fa656..a9dd14648 100644 --- a/templates/admin-page.php +++ b/templates/admin-page.php @@ -45,7 +45,18 @@
From 678e5341421ec207b56bd1c6c2cd4db93a3fb157 Mon Sep 17 00:00:00 2001 From: Mukesh Panchal Date: Wed, 25 Oct 2023 10:16:38 +0530 Subject: [PATCH 2/8] Address review feedback --- assets/js/plugin-check-admin.js | 7 +------ includes/Admin/Admin_Page.php | 4 +++- templates/admin-page.php | 13 +------------ 3 files changed, 5 insertions(+), 19 deletions(-) diff --git a/assets/js/plugin-check-admin.js b/assets/js/plugin-check-admin.js index 962b0a359..9b971588e 100644 --- a/assets/js/plugin-check-admin.js +++ b/assets/js/plugin-check-admin.js @@ -35,11 +35,6 @@ canRunChecks(); pluginsList.addEventListener( 'change', canRunChecks ); - /** - * Saves the user settings. - * - * @since n.e.x.t - */ function saveUserSettings() { const selectedCategories = []; @@ -52,7 +47,7 @@ // Join the selected category slugs with '__' and save it as a user setting. const settingValue = selectedCategories.join( '__' ); - window.setUserSetting( 'category_preferences', settingValue ); + window.setUserSetting( 'plugin_check_category_preferences', settingValue ); } // Attach the saveUserSettings function when a category checkbox is clicked. diff --git a/includes/Admin/Admin_Page.php b/includes/Admin/Admin_Page.php index 40ef5765a..9b070c74a 100644 --- a/includes/Admin/Admin_Page.php +++ b/includes/Admin/Admin_Page.php @@ -165,7 +165,9 @@ public function render_page() { $categories = Check_Categories::get_categories(); - $user_settings = get_user_setting( 'category_preferences' ); + // Get user settings for category preferences and set a default value to check all categories by default. + $user_settings = get_user_setting( 'plugin_check_category_preferences', 'all_categories' ); + $user_settings = explode( '__', $user_settings ); require WP_PLUGIN_CHECK_PLUGIN_DIR_PATH . 'templates/admin-page.php'; } diff --git a/templates/admin-page.php b/templates/admin-page.php index a9dd14648..905a5b138 100644 --- a/templates/admin-page.php +++ b/templates/admin-page.php @@ -45,18 +45,7 @@
From 9ffdd9da75d5895b93715e8c2813f03365b98475 Mon Sep 17 00:00:00 2001 From: Mukesh Panchal Date: Wed, 25 Oct 2023 10:20:00 +0530 Subject: [PATCH 3/8] Fix JS lint --- assets/js/plugin-check-admin.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/assets/js/plugin-check-admin.js b/assets/js/plugin-check-admin.js index 9b971588e..086eef5c4 100644 --- a/assets/js/plugin-check-admin.js +++ b/assets/js/plugin-check-admin.js @@ -47,7 +47,10 @@ // Join the selected category slugs with '__' and save it as a user setting. const settingValue = selectedCategories.join( '__' ); - window.setUserSetting( 'plugin_check_category_preferences', settingValue ); + window.setUserSetting( + 'plugin_check_category_preferences', + settingValue + ); } // Attach the saveUserSettings function when a category checkbox is clicked. From 8a7bea21d60e18d0e5c9bbbb9149d1828ca9ba17 Mon Sep 17 00:00:00 2001 From: Mukesh Panchal Date: Wed, 25 Oct 2023 10:25:42 +0530 Subject: [PATCH 4/8] Remove global variable --- includes/Admin/Admin_Page.php | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/includes/Admin/Admin_Page.php b/includes/Admin/Admin_Page.php index 9b070c74a..bf5c3d020 100644 --- a/includes/Admin/Admin_Page.php +++ b/includes/Admin/Admin_Page.php @@ -151,14 +151,9 @@ private function get_available_plugins() { * * @since n.e.x.t * - * @global array $available_plugins The list of available plugins. - * @global string $selected_plugin_basename The selected plugin basename. - * @global array $categories An array of categories. - * @global mixed $user_settings The user interface setting value. + * @SuppressWarnings(PHPMD.UnusedLocalVariable) */ public function render_page() { - global $available_plugins, $selected_plugin_basename, $categories, $user_settings; - $available_plugins = $this->get_available_plugins(); $selected_plugin_basename = filter_input( INPUT_GET, 'plugin', FILTER_SANITIZE_FULL_SPECIAL_CHARS ); From 7ab9fa1a2aa80034d4080f0193c30d80217b166a Mon Sep 17 00:00:00 2001 From: Mukesh Panchal Date: Wed, 25 Oct 2023 14:33:32 +0530 Subject: [PATCH 5/8] Implement plugin deploy workflow --- .gitattributes | 31 ++++++++++++++++++++++++++ .github/workflows/deploy.yml | 34 +++++++++++++++++++++++++++++ .wordpress-org/banner-1544x500.png | Bin 0 -> 4195 bytes .wordpress-org/banner-772x250.png | Bin 0 -> 1659 bytes .wordpress-org/banner.svg | 6 +++++ .wordpress-org/icon.svg | 4 ++++ 6 files changed, 75 insertions(+) create mode 100644 .gitattributes create mode 100644 .github/workflows/deploy.yml create mode 100644 .wordpress-org/banner-1544x500.png create mode 100644 .wordpress-org/banner-772x250.png create mode 100644 .wordpress-org/banner.svg create mode 100644 .wordpress-org/icon.svg diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 000000000..a3659bba8 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,31 @@ +/.git export-ignore +/.github export-ignore +/.wordpress-org export-ignore +/node_modules export-ignore + +/docs export-ignore +/tests export-ignore +/build-cs export-ignore + +/*.DS_store export-ignore +/.DS_store? export-ignore + +/.editorconfig export-ignore +/.eslintrc.js export-ignore +/.nvmrc export-ignore +/.wp-env.json export-ignore +/composer.json export-ignore +/composer.lock export-ignore +/package.json export-ignore +/package-lock.json export-ignore +/phpcs.xml.dist export-ignore +/phpstan.neon.dist export-ignore +/phpunit.xml.dist export-ignore + +/CODE_OF_CONDUCT.md export-ignore +/CONTRIBUTING.md export-ignore +/SECURITY.md export-ignore +/README.md export-ignore + +/.gitattributes export-ignore +/.gitignore export-ignore diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 000000000..cff15c961 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,34 @@ +name: Deploy + +# Run deploy only on published releases. +on: + release: + types: [published] + +jobs: + + deploy: + name: Deploy to WordPress.org + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: WordPress Plugin Deploy + id: deploy + uses: 10up/action-wordpress-plugin-deploy@stable + with: + generate-zip: true + env: + #SVN_USERNAME: ${{ secrets.SVN_USERNAME }} + #SVN_PASSWORD: ${{ secrets.SVN_PASSWORD }} + + - name: Upload release asset + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ github.event.release.upload_url }} + asset_path: ${{ steps.deploy.outputs.zip-path }} + asset_name: ${{ github.event.repository.name }}.zip + asset_content_type: application/zip \ No newline at end of file diff --git a/.wordpress-org/banner-1544x500.png b/.wordpress-org/banner-1544x500.png new file mode 100644 index 0000000000000000000000000000000000000000..fa08d1d2b89d5e8c8d4789ed3976c4e88a64693d GIT binary patch literal 4195 zcmeHJXH=8P8vYQ3tOYirA|T-63X80;iUJFUvVe$6QIMt>Tv-qS0qLQGic)nIK?Fh( zkrsLhC81Z75L&27AV5N>N=FFy`&iHZxc8hrcfI@b=A7@GnaMlP%)IY2&pc0!40QMJ z5!nL(z<#}p+SdSp7X|=aOE7M5gr;TsBLM8OF}h-+1Gr@$2`rS4C|7-6^;2YpXmHVP z&)h=+1-H^0lN$SGW@fV62X1FH*}ZQe3^OD`i%Uqur^3qxd@&5>6uPPJT2dXhi>e!k zi>~gf?xvEd6U-@g#}LCZwV{hTp%Ygl9afs#F=&8;hgYBkG6cUG{s=K&7 za?+bA8Lj;f^4bfDL%1Fq%qv&(Wi@qz)kmK^_ON)5cV6CyLFH$ae#Hc%#M;XV_$l`E z-K-Y4Uw#F7B&d`aR?+zY)9#LGkFV=BMb|rIw>syx6%dB%DRi56&8>rDg8uo>aorZF z4Yrvr^vNmNr)Ab}n+)I7{+iLG6yEs@}B@jfN7uIxG0=^DXQQ!>*{u^S_L;~Ezam0N z8L@#fdNCdsT1M)kP4J^Izr@zG4~?0pG~CZ^Q;Na%&?k0#=Dcm`PpI$JepNF%In~@h z`mHZ!c%1pelhWW);?<-&k)T3+FYR7dYfN>QYhHU$2@#pz_^P(&#N(0=!;DepR8Gg> z^z=+!AKl+6 z
;^2moFMoJTFg%>$!1(i(=xS&zy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4HNs9OZjndvf^oB>YoR|2~AGP>%D! z;7hq<(4BKSd0n1X$Q(b#&-RJ{Pia*x|EWt#t}*T9gHo&*$VzAFHFzI-BtT zHJwF#RM#o?pqR(_j+p&P-zZ30Jat^W3zp|bMWLGIq3GFlT~_l~c>sU%J3i_S`5Nch zBq&S<8%Q2WC(Y-3sTIs+KqHgl$^`{3a~n)wcC0|aMX;*6#x4PC^iP?5eYgBevdr5tOo{5@5ioZ8B(~> z7T<7u!}g-Z#7v;q;b7utVve-h>Uy?{o$~gh{eRqv7mK*j)-B{_*TS@~m+Y>f0Q)P% zdnA|14hIHuKpDKqDi|ybSLx-q@wiY1+6h6&$lu9vZRO*4P|r9#Ma83G<`fdjkwP9! zT=~38m0NuzbT)f1lJRC*SHM67OofB0$4_3Aay$LW!zi1e54KV)`s%ZQObv6A@k}h&fj45QG%N8c z8_rb(@+)8Tzt6w_Fa`er!~neVGkbo-y?Iq0J74z{EhnDTrUs_AFIU8Tqt0iUwY7>k zn+lV}ub+m=-z^QaP_@h+ob)Eo8;BMY;0+Hu} zcPNKgSZI7C0dn@1{amotkhJqA#45zJKP0bju`nr)P{{Fs+&?-ZW*0aT`cQE} z3*g3RHw5bub5@FJC~AfQtBe4}P5K;WI18-e+tWXLflUx)r>TTV1Z4+m<`j!62CM{u z8+bk`S%JIFU>^S>e6{)UfVcKtxm|d7emea2CHUI89w3GX(z&L!YV|AJoeIXFI!-iy zY>E=xQAZ)o<(%iEcLEWLUsTSdd<3uPJ6!gWbO^K%gp(oJ8~IJ!95i}s-kG1XvMuGG z4auP=d`auSvv&VL6~od5DP)xRk9ueiI2g_ zYXnGdey5VlWC}=YBZX4-5-UGPk%JKuLvw1fpw+he*wB=eDW6g5EQsN3t0%+#uYaw< g|Np$d$Uxt^pyiQ~q7&^wR#23lj)6Aj7weFJ0fSJBZvX%Q literal 0 HcmV?d00001 diff --git a/.wordpress-org/banner-772x250.png b/.wordpress-org/banner-772x250.png new file mode 100644 index 0000000000000000000000000000000000000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G?F<0tdhx*j dZ}xlaCusG@x8@Ps@l^{!_qlpts4jsCe*tUm7F+-T literal 0 HcmV?d00001 diff --git a/.wordpress-org/banner.svg b/.wordpress-org/banner.svg new file mode 100644 index 000000000..2e4d362e2 --- /dev/null +++ b/.wordpress-org/banner.svg @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.wordpress-org/icon.svg b/.wordpress-org/icon.svg new file mode 100644 index 000000000..d49322898 --- /dev/null +++ b/.wordpress-org/icon.svg @@ -0,0 +1,4 @@ + + + + \ No newline at end of file From 91e36c023597ceee842744424687f9a64ab227a3 Mon Sep 17 00:00:00 2001 From: Mukesh Panchal Date: Wed, 25 Oct 2023 14:35:35 +0530 Subject: [PATCH 6/8] Add new line at end of file --- .github/workflows/deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index cff15c961..e451b5d1f 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -31,4 +31,4 @@ jobs: upload_url: ${{ github.event.release.upload_url }} asset_path: ${{ steps.deploy.outputs.zip-path }} asset_name: ${{ github.event.repository.name }}.zip - asset_content_type: application/zip \ No newline at end of file + asset_content_type: application/zip From 5b63e14e8e8469fd15286c2af858c1929e758a72 Mon Sep 17 00:00:00 2001 From: Mukesh Panchal Date: Thu, 26 Oct 2023 11:41:12 +0530 Subject: [PATCH 7/8] Thanks @felixarntz for suggestion Co-authored-by: Felix Arntz --- includes/Admin/Admin_Page.php | 2 +- templates/admin-page.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/includes/Admin/Admin_Page.php b/includes/Admin/Admin_Page.php index bf5c3d020..c36f81c00 100644 --- a/includes/Admin/Admin_Page.php +++ b/includes/Admin/Admin_Page.php @@ -162,7 +162,7 @@ public function render_page() { // Get user settings for category preferences and set a default value to check all categories by default. $user_settings = get_user_setting( 'plugin_check_category_preferences', 'all_categories' ); - $user_settings = explode( '__', $user_settings ); + $user_settings = 'all_categories' === $user_settings ? $categories : explode( '__', $user_settings ); require WP_PLUGIN_CHECK_PLUGIN_DIR_PATH . 'templates/admin-page.php'; } diff --git a/templates/admin-page.php b/templates/admin-page.php index 905a5b138..0f11986ba 100644 --- a/templates/admin-page.php +++ b/templates/admin-page.php @@ -45,7 +45,7 @@
From 423147bee5eeaa78931197ad22d4629c1705c56a Mon Sep 17 00:00:00 2001 From: Mukesh Panchal Date: Thu, 26 Oct 2023 11:45:33 +0530 Subject: [PATCH 8/8] Use a more descriptive variable name --- includes/Admin/Admin_Page.php | 4 ++-- templates/admin-page.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/includes/Admin/Admin_Page.php b/includes/Admin/Admin_Page.php index c36f81c00..4e6b61c6b 100644 --- a/includes/Admin/Admin_Page.php +++ b/includes/Admin/Admin_Page.php @@ -161,8 +161,8 @@ public function render_page() { $categories = Check_Categories::get_categories(); // Get user settings for category preferences and set a default value to check all categories by default. - $user_settings = get_user_setting( 'plugin_check_category_preferences', 'all_categories' ); - $user_settings = 'all_categories' === $user_settings ? $categories : explode( '__', $user_settings ); + $user_enabled_categories = get_user_setting( 'plugin_check_category_preferences', 'all_categories' ); + $user_enabled_categories = 'all_categories' === $user_enabled_categories ? $categories : explode( '__', $user_enabled_categories ); require WP_PLUGIN_CHECK_PLUGIN_DIR_PATH . 'templates/admin-page.php'; } diff --git a/templates/admin-page.php b/templates/admin-page.php index 0f11986ba..37445e1c8 100644 --- a/templates/admin-page.php +++ b/templates/admin-page.php @@ -45,7 +45,7 @@