Astra_Admin_Ajax::required_plugin_deactivate()
Required Plugin Activate
Description
Source
File: admin/includes/class-astra-admin-ajax.php
public function required_plugin_deactivate() { $response_data = array( 'message' => $this->get_error_msg( 'permission' ) ); if ( ! current_user_can( 'manage_options' ) ) { wp_send_json_error( $response_data ); } if ( empty( $_POST ) ) { $response_data = array( 'message' => $this->get_error_msg( 'invalid' ) ); wp_send_json_error( $response_data ); } /** * Nonce verification. */ if ( ! check_ajax_referer( 'astra_plugin_manager_nonce', 'security', false ) ) { $response_data = array( 'message' => $this->get_error_msg( 'nonce' ) ); wp_send_json_error( $response_data ); } /** @psalm-suppress PossiblyInvalidArgument */ // phpcs:ignore Generic.Commenting.DocComment.MissingShort if ( ! current_user_can( 'install_plugins' ) || ! isset( $_POST['init'] ) || ! sanitize_text_field( wp_unslash( $_POST['init'] ) ) ) { /** @psalm-suppress PossiblyInvalidArgument */ // phpcs:ignore Generic.Commenting.DocComment.MissingShort wp_send_json_error( array( 'success' => false, 'message' => __( 'No plugin specified', 'astra' ), ) ); } /** @psalm-suppress PossiblyInvalidArgument */ // phpcs:ignore Generic.Commenting.DocComment.MissingShort $plugin_init = ( isset( $_POST['init'] ) ) ? sanitize_text_field( wp_unslash( $_POST['init'] ) ) : ''; /** @psalm-suppress PossiblyInvalidArgument */ // phpcs:ignore Generic.Commenting.DocComment.MissingShort $deactivate = deactivate_plugins( $plugin_init, true, false ); if ( is_wp_error( $deactivate ) ) { wp_send_json_error( array( 'success' => false, 'message' => $deactivate->get_error_message(), ) ); } wp_send_json_success( array( 'success' => true, 'message' => __( 'Plugin Successfully Deactivated', 'astra' ), ) ); }
Expand full source code Collapse full source code View on Trac
Changelog
Version | Description |
---|---|
1.2.4 | Introduced. |