From 9becfb4abd9184ca90964327adc1f510ed75f529 Mon Sep 17 00:00:00 2001 From: saevar Date: Wed, 3 Dec 2025 13:36:10 +0000 Subject: [PATCH 1/7] First draft --- 1984-hosting-support.php | 219 ++++++++++++++++++++++++-- icons/patchstack-logo.svg | 86 ++++++++++ js/1984-hosting-support.js | 23 +-- languages/hostingsupport1984-is_IS.mo | Bin 726 -> 1635 bytes languages/hostingsupport1984-is_IS.po | 76 ++++++--- languages/hostingsupport1984.pot | 69 +++++--- style/1984-hosting-support.css | 46 ++---- 7 files changed, 423 insertions(+), 96 deletions(-) create mode 100644 icons/patchstack-logo.svg diff --git a/1984-hosting-support.php b/1984-hosting-support.php index 3cc08bf..73a31a2 100644 --- a/1984-hosting-support.php +++ b/1984-hosting-support.php @@ -2,11 +2,13 @@ /* * Plugin Name: 1984 Hosting Support - * Version: 1.0.1 - * Author: 1984 ehf + * Version: 1.1.0 + * Author: 1984 ehf. * Author URI: https://1984.hosting * Description: Support plugin for 1984 Hosting customers. * Update URI: https://git.1984.is/1984/1984-hosting-support/ + * Text Domain: hostingsupport1984 + * Domain Path: /languages */ /** @@ -19,6 +21,7 @@ * There are other classes that may depend on this file, so only remove it if * you do not intend to use the plugin. */ + class HostingSupport1984 { const HOSTING_SUPPORT_VERSION = '0.4.0'; @@ -51,6 +54,51 @@ class HostingSupport1984 { 'switch_theme', array( $this, 'theme_switch_hook' ) ); + + // Add a clear warning on the Patchstack plugin row to discourage removal. + add_filter( + 'plugin_row_meta', + array( + $this, + 'add_patchstack_warning_row_meta', + ), + 10, + 2 + ); + + // Prevent deactivation/deletion of this plugin and Patchstack via UI links. + add_filter( + 'plugin_action_links', + array( + $this, + 'filter_plugin_action_links', + ), + 10, + 4 + ); + add_filter( + 'network_admin_plugin_action_links', + array( + $this, + 'filter_plugin_action_links', + ), + 10, + 4 + ); + + // Guard against direct requests (single and bulk) on Plugins screens and updater endpoints. + add_action( 'load-plugins.php', array( + $this, + 'protect_plugins_admin_actions', + ) ); + add_action( 'load-plugins-network.php', array( + $this, + 'protect_plugins_admin_actions', + ) ); + add_action( 'load-update.php', array( + $this, + 'protect_plugins_admin_actions', + ) ); } /** @@ -66,15 +114,6 @@ class HostingSupport1984 { ); } - /** - * Check if Patchstack is enabled. - * - * @return Boolean - */ - public function is_patchstack_active() { - return is_plugin_active( 'patchstack/patchstack.php' ); - } - /** * On activation of this plugin, set auto-update option for core, * plus enable auto-updates for installed plugins and themes. @@ -100,6 +139,15 @@ class HostingSupport1984 { update_site_option( 'auto_update_themes', array_keys( $all_themes ) ); } + /** + * Check if Patchstack is enabled. + * + * @return Boolean + */ + public function is_patchstack_active() { + return is_plugin_active( 'patchstack/patchstack.php' ); + } + /** * On plugin activation, add to auto-updated list of plugins. * @@ -111,7 +159,7 @@ class HostingSupport1984 { return; } - $auto_updated_plugins = (array) get_site_option( 'auto_update_plugins', array() ); + $auto_updated_plugins = (array) get_site_option( 'auto_update_plugins', array() ); $auto_updated_plugins[] = $plugin; update_site_option( 'auto_update_plugins', array_unique( $auto_updated_plugins ) ); @@ -131,10 +179,155 @@ class HostingSupport1984 { $all_themes = wp_get_themes(); update_site_option( 'auto_update_themes', array_keys( $all_themes ) ); } + + /** + * Append a prominent warning to the Patchstack plugin row in the Plugins screen. + * + * @param array $links Existing row meta links. + * @param string $file Plugin file path about plugins directory. + * + * @return array Modified row meta-links. + */ + public function add_patchstack_warning_row_meta( array $links, string $file ): array { + // Only show the warning on the Patchstack row AND only if Patchstack is active. + if ( 'patchstack/patchstack.php' !== $file || ! $this->is_patchstack_active() ) { + return $links; + } + + $warning_text = + __( '1984 Hosting: Please do not deactivate or delete this plugin - part of your WordPress Service Pack.', 'hostingsupport1984' ); + + $logo_1984_url = plugins_url( 'icons/1984-hosting-logo.webp', __FILE__ ); + $logo_patchstack = plugins_url( 'icons/patchstack-logo.svg', __FILE__ ); + + $title_1984 = __( 'Visit 1984 Hosting Homepage', 'hostingsupport1984' ); + $title_patchstack = __( 'Visit Patchstack Homepage', 'hostingsupport1984' ); + + $container_open = + ''; + + $warning_icon = + ''; + + $text_html = '' . esc_html( $warning_text ) . ''; + + + $logos_html = + '' + . + '' + . + '1984 Hosting' + . + '' + . + '' + . + 'Patchstack' + . + '' + . + ''; + + $links[] = $container_open . $warning_icon . $text_html . $logos_html . ''; + + return $links; + } + + /** + * Remove Deactivate/Delete action links for protected plugins (single and network admin). + * + * @param array $actions + * @param string $plugin_file + * @param array $plugin_data + * @param string $context + * + * @return array + */ + public function filter_plugin_action_links( + array $actions, string $plugin_file, array $plugin_data, + string $context + ): array { + if ( $this->is_protected_plugin( $plugin_file ) ) { + unset( $actions['deactivate'] ); + unset( $actions['delete'] ); + } + + return $actions; + } + + /** + * Determine if a plugin file is in the protected list. + * + * @param string $plugin_file + * + * @return bool + */ + private function is_protected_plugin( string $plugin_file ): bool { + return in_array( $plugin_file, $this->get_protected_plugins(), true ); + } + + /** + * Return plugin basenames that must be protected from deactivation/deletion. + * + * @return string[] + */ + private function get_protected_plugins(): array { + $own = plugin_basename( __FILE__ ); + + return array( + $own, + 'patchstack/patchstack.php', + ); + } + + /** + * Intercept admin actions attempting to deactivate or delete protected plugins and block them. + */ + public function protect_plugins_admin_actions() { + // Collect requested action(s). + $action = isset( $_REQUEST['action'] ) ? sanitize_key( (string) $_REQUEST['action'] ) : ''; + $action2 = isset( $_REQUEST['action2'] ) ? sanitize_key( (string) $_REQUEST['action2'] ) : ''; + + $targets = array(); + if ( ! empty( $_REQUEST['plugin'] ) ) { + $targets[] = sanitize_text_field( (string) $_REQUEST['plugin'] ); + } + if ( ! empty( $_REQUEST['checked'] ) && is_array( $_REQUEST['checked'] ) ) { + foreach ( $_REQUEST['checked'] as $pf ) { + $targets[] = sanitize_text_field( (string) $pf ); + } + } + + if ( empty( $targets ) ) { + return; + } + + $blocked_actions = array( + 'deactivate', + 'deactivate-selected', + 'delete', + 'delete-selected', + 'delete-plugin', + ); + + if ( ! in_array( $action, $blocked_actions, true ) && ! in_array( $action2, $blocked_actions, true ) ) { + return; + } + + $protected = $this->get_protected_plugins(); + $intersect = array_intersect( $targets, $protected ); + if ( ! empty( $intersect ) ) { + wp_die( + __( 'For security, this action is blocked: 1984 Hosting Support and Patchstack cannot be deactivated or deleted while this policy is active.', 'hostingsupport1984' ), + 403 + ); + } + } } $hosting_support_1984 = new HostingSupport1984(); -define( 'A1984_HOSTING_SUPPORT_BASE_FILE', __FILE__ ); +const A1984_HOSTING_SUPPORT_BASE_FILE = __FILE__; require_once __DIR__ . '/1984-hosting-support-ui.php'; diff --git a/icons/patchstack-logo.svg b/icons/patchstack-logo.svg new file mode 100644 index 0000000..6bc8eb7 --- /dev/null +++ b/icons/patchstack-logo.svg @@ -0,0 +1,86 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/js/1984-hosting-support.js b/js/1984-hosting-support.js index 310ba84..c70d2fe 100644 --- a/js/1984-hosting-support.js +++ b/js/1984-hosting-support.js @@ -4,16 +4,19 @@ * @license https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html GNU General Public License v2.0 */ -function HostingSupport1984CopyEmailAddress( e ) { - e.preventDefault(); - var emailAddressTag = document.querySelector( '#hosting-support-1984-address' ); - emailAddressTag.select(); - document.execCommand( 'copy' ); +function HostingSupport1984CopyEmailAddress(e) { + e.preventDefault(); + const emailAddressTag = document.querySelector('#hosting-support-1984-address'); + navigator.clipboard.writeText(emailAddressTag.value) + .catch(err => console.error("Clipboard write failed:", err)); } -if (document.querySelector( '#hosting-support-1984-link' )) { - document.querySelector( '#hosting-support-1984-link' ).addEventListener( - 'click', - HostingSupport1984CopyEmailAddress - ); +document.querySelector('#hosting-support-1984-link') + ?.addEventListener('click', HostingSupport1984CopyEmailAddress); + +if (document.querySelector('#hosting-support-1984-link')) { + document.querySelector('#hosting-support-1984-link').addEventListener( + 'click', + HostingSupport1984CopyEmailAddress + ); } diff --git a/languages/hostingsupport1984-is_IS.mo b/languages/hostingsupport1984-is_IS.mo index bc9b2ab60c32883729fbed7c4fd4a36b10a25b29..9c81070c3dd3c4d3c3efc229d0c66ce28e3ab8cf 100644 GIT binary patch literal 1635 zcmZ{kO>Y}T7{>=FZ>9o@IDi1@0i;Sm*0HTr3QIvGZ9^g&Vb!VI>tuJlJK6QjYG&5K z2P8Nlap!_^=_OJQl`K`t0YoozLwp9Vd<^)H?KrX2j5Pb(-I;lw|MRl@&s$f1Wf-qv zzK`iJuVMa;8OEE>G4?ii4NSo6;2YpC;LqT1;OpQ=&okBl+u%FkP4H9jKKLH^Bls?O z1RmkcDfkJVdsi6y3H$-P3jPNkfmdIg={Ny{{Xf8CqAnwjOe+EM2F5w`bWrZD$D> zAd)4WNo}1T3S*nBFRgUTtJ_$rcqZm+7Xn$VK*51XT(px$eV9Q~F3Ci@*>1KP_e7{- zv}-e&Mw@kJqdgr{?p$T#)zw23qzVOTYLl(nS;<#t#aj)!qkPs5(R{7Z{VuvEMo_L* zbQ^__snhD*h}xZ~)!A#e<5nwPTl);xR;zKBTNmvau58JjHZk@5@rWDR6edGA^dzpC zkj7e6_NL_mi(dz?O=-WvX_eK;MYJdQFh;*Av3M7wN{!u}-8&a@fM7!(2?d|y3c{TD z-XRuL=L<@5Zme)$-rw7b*3b6^Z3AJVJ1WsBx<01$ed!txqi=)~W+wVUH@bCqhdRx6 z2QD5)vw|asv&_sB6J$5ohM%CkenL7U>uNtyFp5y~1OI5L((GbW#MDOz@nI=4WQ;^n zNV26rEs7B*929=SNsPnQKSi;)ku;KivhSZbd}6u(U6Fv3vUZaA;KFC-pC0%p3N2Sx zyePP;hp^xugH5&t%Y3evZ4AhtnsJs%>mOO?kNpIDVRYdTTQgx0TFwUw50`Wu0>99; zFfffK_s5wF-Y$!47-Cd2Z<372NY{;>A%*@DtioxY5T4R7l1>8=2)&5!IN3YJ#f)6?&US{diA0 ztdDDfBXO78NN?@qHa%m}5Z)n*+Q>326B{Nr%g8irqr7fF=}jUP?h4{bmnbe^vPnEA zAP&X5T}p;FnqEtndh(R~p4f=Vqee$>xq%=qu5&SzHuC)Mt*lxV^s}sbC|5;hC45c{ zN=@G5XrPoY?LxujJ>oJ+^T+I>pdaGs@b8aSzL\n" +"Language-Team: none\n" +"Language: is\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Generator: Loco https://localise.biz/\n" -"X-Loco-Version: 2.4.2; wp-5.6" +"X-Generator: WP-CLI 2.12.0\n" +"X-Domain: hostingsupport1984\n" -#: 1984-hosting-support-ui.php:100 +#. Plugin Name of the plugin +#: 1984-hosting-support.php 1984-hosting-support-ui.php:49 msgid "1984 Hosting Support" -msgstr "Aðstoð og stuðningur hjá 1984" +msgstr "Aðstoð og stuðningur hjá 1984 Hosting" -#. Name of the plugin -msgid "1984-hosting-support.php" +#. Description of the plugin +#: 1984-hosting-support.php +msgid "Support plugin for 1984 Hosting customers." +msgstr "Stuðningsviðbót fyrir viðskiptavini 1984 Hosting." + +#. Author of the plugin +#: 1984-hosting-support.php +msgid "1984 ehf." msgstr "" -#: views/support-dashboard-widget.php:31 +#. Author URI of the plugin +#: 1984-hosting-support.php +msgid "https://1984.hosting" +msgstr "" + +#: 1984-hosting-support.php:197 +msgid "" +"1984 Hosting: Please do not deactivate or delete this plugin - part of your " +"WordPress Service Pack." +msgstr "" +"1984 Hosting: Vinsamlegast ekki slökkva á eða eyða þessari viðbót - hún er " +"hluti af WordPress þjónustupakkanum þínum." + +#: 1984-hosting-support.php:202 +msgid "Visit 1984 Hosting Homepage" +msgstr "Heimsækja heimasíðu 1984 Hosting" + +#: 1984-hosting-support.php:203 +msgid "Visit Patchstack Homepage" +msgstr "Heimsækja heimasíðu Patchstack" + +#: 1984-hosting-support.php:322 +msgid "" +"For security, this action is blocked: 1984 Hosting Support and Patchstack " +"cannot be deactivated or deleted while this policy is active." +msgstr "" +"Af öryggisástæðum er þessari aðgerð hafnað: 1984 Hosting Support og " +"Patchstack er ekki hægt að slökkva á eða eyða meðan þessi regla er virk." + +#: views/support-dashboard-widget.php:21 msgid "My Profile" msgstr "Minn aðgangur" -#: views/support-dashboard-widget.php:15 +#: views/support-dashboard-widget.php:34 msgid "My Sites, Domains & VPSs" msgstr "Vefir, lén og sýndarvélar" -#: views/support-dashboard-widget.php:15 +#: views/support-dashboard-widget.php:48 msgid "Knowledge Base" msgstr "Viskubrunnur 1984" -#: views/support-dashboard-widget.php:15 +#: views/support-dashboard-widget.php:62 msgid "Contact Support" msgstr "Fá aðstoð" - - diff --git a/languages/hostingsupport1984.pot b/languages/hostingsupport1984.pot index 15d27ae..6aafba4 100644 --- a/languages/hostingsupport1984.pot +++ b/languages/hostingsupport1984.pot @@ -1,41 +1,68 @@ +# Copyright (C) 2025 1984 ehf. +# This file is distributed under the same license as the 1984 Hosting Support plugin. msgid "" msgstr "" -"Project-Id-Version: 1984 Big Brother\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2021-01-19 10:05+0000\n" -"PO-Revision-Date: 2021-01-19 10:09+0000\n" -"Last-Translator: \n" -"Language-Team: Íslenska\n" -"Language: is_IS\n" -"Plural-Forms: nplurals=2; plural=n != 1;\n" +"Project-Id-Version: 1984 Hosting Support 1.1.0\n" +"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/1984-hosting-support\n" +"Last-Translator: Sævar Bergur Sigurgeirsson \n" +"Language-Team: none\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Generator: Loco https://localise.biz/\n" -"X-Loco-Version: 2.4.2; wp-5.6" +"POT-Creation-Date: 2025-12-02T11:33:54+00:00\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"X-Generator: WP-CLI 2.12.0\n" +"X-Domain: hostingsupport1984\n" -#: 1984-hosting-support-ui.php:100 +#. Plugin Name of the plugin +#: 1984-hosting-support.php +#: 1984-hosting-support-ui.php:49 msgid "1984 Hosting Support" -msgstr "Aðstoð og stuðningur hjá 1984" - -#. Name of the plugin -msgid "1984-hosting-support.php" msgstr "" -#: views/support-dashboard-widget.php:31 +#. Description of the plugin +#: 1984-hosting-support.php +msgid "Support plugin for 1984 Hosting customers." +msgstr "" + +#. Author of the plugin +#: 1984-hosting-support.php +msgid "1984 ehf." +msgstr "" + +#. Author URI of the plugin +#: 1984-hosting-support.php +msgid "https://1984.hosting" +msgstr "" + +#: 1984-hosting-support.php:197 +msgid "1984 Hosting: Please do not deactivate or delete this plugin - part of your WordPress Service Pack." +msgstr "" + +#: 1984-hosting-support.php:202 +msgid "Visit 1984 Hosting Homepage" +msgstr "" + +#: 1984-hosting-support.php:203 +msgid "Visit Patchstack Homepage" +msgstr "" + +#: 1984-hosting-support.php:322 +msgid "For security, this action is blocked: 1984 Hosting Support and Patchstack cannot be deactivated or deleted while this policy is active." +msgstr "" + +#: views/support-dashboard-widget.php:21 msgid "My Profile" msgstr "" -#: views/support-dashboard-widget.php:15 +#: views/support-dashboard-widget.php:34 msgid "My Sites, Domains & VPSs" msgstr "" -#: views/support-dashboard-widget.php:15 +#: views/support-dashboard-widget.php:48 msgid "Knowledge Base" msgstr "" -#: views/support-dashboard-widget.php:15 +#: views/support-dashboard-widget.php:62 msgid "Contact Support" msgstr "" - - diff --git a/style/1984-hosting-support.css b/style/1984-hosting-support.css index 49ca127..3ccd4fd 100644 --- a/style/1984-hosting-support.css +++ b/style/1984-hosting-support.css @@ -7,51 +7,33 @@ * https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html **/ -#hostingsupport1984_support_widget { - background: #fffbee; -} - -#adminmenu a.toplevel_page_hostingsupport1984_manage { - background-color: #b48701; - font-weight: bold; -} - -#adminmenu a.toplevel_page_hostingsupport1984_manage:hover { - color: #fff; -} - -#adminmenu a.toplevel_page_hostingsupport1984_manage div.wp-menu-image::before { - color: #fff; -} - #hosting-support-1984-main-links { - display: grid; - grid-template-columns: repeat(2, 1fr); - gap: 0.2rem; - list-style-type: none; + display: grid; + grid-template-columns: repeat(2, 1fr); + gap: 0.2rem; + list-style-type: none; } .hosting-support-1984-li { } .hosting-support-1984-icon { - width: 5.3em; - height: auto; - display: block; - margin: auto; + width: 5.3em; + height: auto; + display: block; + margin: auto; } .hosting-support-1984-text { - text-align: center; + text-align: center; } #hosting-support-1984-logo { - display: flex; - justify-content: flex-end; + display: flex; + justify-content: flex-end; } #hosting-support-1984-logo img { - width: auto; - height: 1.5em; -} - + width: auto; + height: 1.5em; +} \ No newline at end of file From 762fc74859e5be4a7ff9d390caf95c15cb0f1b7b Mon Sep 17 00:00:00 2001 From: gdh Date: Mon, 8 Dec 2025 16:01:47 +0000 Subject: [PATCH 2/7] Update languages/hostingsupport1984-is_IS.po --- languages/hostingsupport1984-is_IS.po | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/languages/hostingsupport1984-is_IS.po b/languages/hostingsupport1984-is_IS.po index f1a829b..584674f 100644 --- a/languages/hostingsupport1984-is_IS.po +++ b/languages/hostingsupport1984-is_IS.po @@ -3,7 +3,7 @@ msgid "" msgstr "" "Project-Id-Version: 1984 Hosting Support 1.1.0\n" -"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/1984-hosting-" +"Report-Msgid-Bugs-To: https://git.1984.is/1984/1984-hosting-support" "support\n" "POT-Creation-Date: 2025-12-02T11:33:54+00:00\n" "PO-Revision-Date: 2025-12-02T11:00:44+00:00\n" From a7a00489a44cba080c8dc1178917a1a7c2336cf2 Mon Sep 17 00:00:00 2001 From: gdh Date: Mon, 8 Dec 2025 16:02:12 +0000 Subject: [PATCH 3/7] Update languages/hostingsupport1984-is_IS.po --- languages/hostingsupport1984-is_IS.po | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/languages/hostingsupport1984-is_IS.po b/languages/hostingsupport1984-is_IS.po index 584674f..73b1fe7 100644 --- a/languages/hostingsupport1984-is_IS.po +++ b/languages/hostingsupport1984-is_IS.po @@ -19,7 +19,7 @@ msgstr "" #. Plugin Name of the plugin #: 1984-hosting-support.php 1984-hosting-support-ui.php:49 msgid "1984 Hosting Support" -msgstr "Aðstoð og stuðningur hjá 1984 Hosting" +msgstr "Aðstoð og stuðningur hjá 1984" #. Description of the plugin #: 1984-hosting-support.php From dd313728da68f6f0d08f247f6fed192504ac4e97 Mon Sep 17 00:00:00 2001 From: gdh Date: Mon, 8 Dec 2025 16:04:36 +0000 Subject: [PATCH 4/7] Update languages/hostingsupport1984.pot --- languages/hostingsupport1984.pot | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/languages/hostingsupport1984.pot b/languages/hostingsupport1984.pot index 6aafba4..892a99e 100644 --- a/languages/hostingsupport1984.pot +++ b/languages/hostingsupport1984.pot @@ -3,7 +3,7 @@ msgid "" msgstr "" "Project-Id-Version: 1984 Hosting Support 1.1.0\n" -"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/1984-hosting-support\n" +"Report-Msgid-Bugs-To: https://git.1984.is/1984/1984-hosting-support\n" "Last-Translator: Sævar Bergur Sigurgeirsson \n" "Language-Team: none\n" "MIME-Version: 1.0\n" From af9431da4ebe1f19a2485f15c86b44e467a62fd3 Mon Sep 17 00:00:00 2001 From: gdh Date: Mon, 8 Dec 2025 16:05:44 +0000 Subject: [PATCH 5/7] Update languages/hostingsupport1984-is_IS.po --- languages/hostingsupport1984-is_IS.po | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/languages/hostingsupport1984-is_IS.po b/languages/hostingsupport1984-is_IS.po index 73b1fe7..007bf31 100644 --- a/languages/hostingsupport1984-is_IS.po +++ b/languages/hostingsupport1984-is_IS.po @@ -24,7 +24,7 @@ msgstr "Aðstoð og stuðningur hjá 1984" #. Description of the plugin #: 1984-hosting-support.php msgid "Support plugin for 1984 Hosting customers." -msgstr "Stuðningsviðbót fyrir viðskiptavini 1984 Hosting." +msgstr "Stuðningsviðbót fyrir viðskiptavini 1984." #. Author of the plugin #: 1984-hosting-support.php @@ -46,11 +46,11 @@ msgstr "" #: 1984-hosting-support.php:202 msgid "Visit 1984 Hosting Homepage" -msgstr "Heimsækja heimasíðu 1984 Hosting" +msgstr "Heimsækja vefsíðu 1984 Hosting" #: 1984-hosting-support.php:203 msgid "Visit Patchstack Homepage" -msgstr "Heimsækja heimasíðu Patchstack" +msgstr "Heimsækja vefsíðu Patchstack" #: 1984-hosting-support.php:322 msgid "" From 9bffb8b5e9c8081d624125b6e700a5610c111cd7 Mon Sep 17 00:00:00 2001 From: saevar Date: Wed, 10 Dec 2025 15:30:31 +0000 Subject: [PATCH 6/7] Addressing PR comment. --- 1984-hosting-support.php | 46 +++++++++++++++++++++----------------- js/1984-hosting-support.js | 11 +++------ 2 files changed, 28 insertions(+), 29 deletions(-) diff --git a/1984-hosting-support.php b/1984-hosting-support.php index 73a31a2..22ece69 100644 --- a/1984-hosting-support.php +++ b/1984-hosting-support.php @@ -272,22 +272,26 @@ class HostingSupport1984 { * * @return string[] */ - private function get_protected_plugins(): array { - $own = plugin_basename( __FILE__ ); + private function get_protected_plugins(): array { + // Always protect this plugin from deactivation/deletion. + $own = plugin_basename( __FILE__ ); + $protected = array( $own ); - return array( - $own, - 'patchstack/patchstack.php', - ); - } + // Additionally protect Patchstack - but only while it is active. + if ( $this->is_patchstack_active() ) { + $protected[] = 'patchstack/patchstack.php'; + } + + return $protected; + } /** * Intercept admin actions attempting to deactivate or delete protected plugins and block them. */ - public function protect_plugins_admin_actions() { - // Collect requested action(s). - $action = isset( $_REQUEST['action'] ) ? sanitize_key( (string) $_REQUEST['action'] ) : ''; - $action2 = isset( $_REQUEST['action2'] ) ? sanitize_key( (string) $_REQUEST['action2'] ) : ''; + public function protect_plugins_admin_actions() { + // Collect requested action(s). + $action = isset( $_REQUEST['action'] ) ? sanitize_key( (string) $_REQUEST['action'] ) : ''; + $action2 = isset( $_REQUEST['action2'] ) ? sanitize_key( (string) $_REQUEST['action2'] ) : ''; $targets = array(); if ( ! empty( $_REQUEST['plugin'] ) ) { @@ -315,19 +319,19 @@ class HostingSupport1984 { return; } - $protected = $this->get_protected_plugins(); - $intersect = array_intersect( $targets, $protected ); - if ( ! empty( $intersect ) ) { - wp_die( - __( 'For security, this action is blocked: 1984 Hosting Support and Patchstack cannot be deactivated or deleted while this policy is active.', 'hostingsupport1984' ), - 403 - ); - } - } + $protected = $this->get_protected_plugins(); + $intersect = array_intersect( $targets, $protected ); + if ( ! empty( $intersect ) ) { + wp_die( + __( 'For security, this action is blocked: 1984 Hosting Support cannot be deactivated or deleted. Patchstack cannot be deactivated or deleted while it is active.', 'hostingsupport1984' ), + 403 + ); + } + } } $hosting_support_1984 = new HostingSupport1984(); -const A1984_HOSTING_SUPPORT_BASE_FILE = __FILE__; +define( 'A1984_HOSTING_SUPPORT_BASE_FILE', __FILE__ ); require_once __DIR__ . '/1984-hosting-support-ui.php'; diff --git a/js/1984-hosting-support.js b/js/1984-hosting-support.js index c70d2fe..2d6a6c1 100644 --- a/js/1984-hosting-support.js +++ b/js/1984-hosting-support.js @@ -11,12 +11,7 @@ function HostingSupport1984CopyEmailAddress(e) { .catch(err => console.error("Clipboard write failed:", err)); } -document.querySelector('#hosting-support-1984-link') - ?.addEventListener('click', HostingSupport1984CopyEmailAddress); - -if (document.querySelector('#hosting-support-1984-link')) { - document.querySelector('#hosting-support-1984-link').addEventListener( - 'click', - HostingSupport1984CopyEmailAddress - ); +const hostingSupport1984Link = document.querySelector('#hosting-support-1984-link'); +if (hostingSupport1984Link) { + hostingSupport1984Link.addEventListener('click', HostingSupport1984CopyEmailAddress); } From 7892d30d22793682b39447dea4e993218fef6811 Mon Sep 17 00:00:00 2001 From: saevar Date: Thu, 11 Dec 2025 14:18:46 +0000 Subject: [PATCH 7/7] Fix inconsistent indentation in `1984-hosting-support.php`. --- 1984-hosting-support.php | 46 ++++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/1984-hosting-support.php b/1984-hosting-support.php index 22ece69..6597503 100644 --- a/1984-hosting-support.php +++ b/1984-hosting-support.php @@ -272,26 +272,26 @@ class HostingSupport1984 { * * @return string[] */ - private function get_protected_plugins(): array { - // Always protect this plugin from deactivation/deletion. - $own = plugin_basename( __FILE__ ); - $protected = array( $own ); + private function get_protected_plugins(): array { + // Always protect this plugin from deactivation/deletion. + $own = plugin_basename( __FILE__ ); + $protected = array( $own ); - // Additionally protect Patchstack - but only while it is active. - if ( $this->is_patchstack_active() ) { - $protected[] = 'patchstack/patchstack.php'; - } + // Additionally protect Patchstack - but only while it is active. + if ( $this->is_patchstack_active() ) { + $protected[] = 'patchstack/patchstack.php'; + } - return $protected; - } + return $protected; + } /** * Intercept admin actions attempting to deactivate or delete protected plugins and block them. */ - public function protect_plugins_admin_actions() { - // Collect requested action(s). - $action = isset( $_REQUEST['action'] ) ? sanitize_key( (string) $_REQUEST['action'] ) : ''; - $action2 = isset( $_REQUEST['action2'] ) ? sanitize_key( (string) $_REQUEST['action2'] ) : ''; + public function protect_plugins_admin_actions() { + // Collect requested action(s). + $action = isset( $_REQUEST['action'] ) ? sanitize_key( (string) $_REQUEST['action'] ) : ''; + $action2 = isset( $_REQUEST['action2'] ) ? sanitize_key( (string) $_REQUEST['action2'] ) : ''; $targets = array(); if ( ! empty( $_REQUEST['plugin'] ) ) { @@ -319,15 +319,15 @@ class HostingSupport1984 { return; } - $protected = $this->get_protected_plugins(); - $intersect = array_intersect( $targets, $protected ); - if ( ! empty( $intersect ) ) { - wp_die( - __( 'For security, this action is blocked: 1984 Hosting Support cannot be deactivated or deleted. Patchstack cannot be deactivated or deleted while it is active.', 'hostingsupport1984' ), - 403 - ); - } - } + $protected = $this->get_protected_plugins(); + $intersect = array_intersect( $targets, $protected ); + if ( ! empty( $intersect ) ) { + wp_die( + __( 'For security, this action is blocked: 1984 Hosting Support cannot be deactivated or deleted. Patchstack cannot be deactivated or deleted while it is active.', 'hostingsupport1984' ), + 403 + ); + } + } } $hosting_support_1984 = new HostingSupport1984();