OP#499 - Explain PS Plugin to customer in WP Admin #2
@@ -272,26 +272,26 @@ class HostingSupport1984 {
|
|||||||
*
|
*
|
||||||
* @return string[]
|
* @return string[]
|
||||||
*/
|
*/
|
||||||
private function get_protected_plugins(): array {
|
private function get_protected_plugins(): array {
|
||||||
// Always protect this plugin from deactivation/deletion.
|
// Always protect this plugin from deactivation/deletion.
|
||||||
$own = plugin_basename( __FILE__ );
|
$own = plugin_basename( __FILE__ );
|
||||||
$protected = array( $own );
|
$protected = array( $own );
|
||||||
|
|
||||||
// Additionally protect Patchstack - but only while it is active.
|
// Additionally protect Patchstack - but only while it is active.
|
||||||
if ( $this->is_patchstack_active() ) {
|
if ( $this->is_patchstack_active() ) {
|
||||||
$protected[] = 'patchstack/patchstack.php';
|
$protected[] = 'patchstack/patchstack.php';
|
||||||
}
|
}
|
||||||
|
|
||||||
return $protected;
|
return $protected;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Intercept admin actions attempting to deactivate or delete protected plugins and block them.
|
* Intercept admin actions attempting to deactivate or delete protected plugins and block them.
|
||||||
*/
|
*/
|
||||||
public function protect_plugins_admin_actions() {
|
public function protect_plugins_admin_actions() {
|
||||||
// Collect requested action(s).
|
// Collect requested action(s).
|
||||||
$action = isset( $_REQUEST['action'] ) ? sanitize_key( (string) $_REQUEST['action'] ) : '';
|
$action = isset( $_REQUEST['action'] ) ? sanitize_key( (string) $_REQUEST['action'] ) : '';
|
||||||
$action2 = isset( $_REQUEST['action2'] ) ? sanitize_key( (string) $_REQUEST['action2'] ) : '';
|
$action2 = isset( $_REQUEST['action2'] ) ? sanitize_key( (string) $_REQUEST['action2'] ) : '';
|
||||||
|
|
||||||
$targets = array();
|
$targets = array();
|
||||||
if ( ! empty( $_REQUEST['plugin'] ) ) {
|
if ( ! empty( $_REQUEST['plugin'] ) ) {
|
||||||
@@ -319,15 +319,15 @@ class HostingSupport1984 {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$protected = $this->get_protected_plugins();
|
$protected = $this->get_protected_plugins();
|
||||||
$intersect = array_intersect( $targets, $protected );
|
$intersect = array_intersect( $targets, $protected );
|
||||||
if ( ! empty( $intersect ) ) {
|
if ( ! empty( $intersect ) ) {
|
||||||
wp_die(
|
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' ),
|
__( '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
|
403
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$hosting_support_1984 = new HostingSupport1984();
|
$hosting_support_1984 = new HostingSupport1984();
|
||||||
|
|||||||
Reference in New Issue
Block a user