WC_Helper::_helper_plugin_deactivate()
Deactivate a plugin.
Method of the class: WC_Helper{}
No Hooks.
Return
null
. Nothing (null).
Usage
$result = WC_Helper::_helper_plugin_deactivate();
WC_Helper::_helper_plugin_deactivate() WC Helper:: helper plugin deactivate code WC 9.3.1
private static function _helper_plugin_deactivate() { $product_id = isset( $_GET['wc-helper-product-id'] ) ? absint( $_GET['wc-helper-product-id'] ) : 0; $deactivated = false; if ( empty( $_GET['wc-helper-nonce'] ) || ! wp_verify_nonce( wp_unslash( $_GET['wc-helper-nonce'] ), 'deactivate-plugin:' . $product_id ) ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized self::log( 'Could not verify nonce in _helper_plugin_deactivate' ); wp_die( 'Could not verify nonce' ); } if ( ! current_user_can( 'activate_plugins' ) ) { wp_die( 'You are not allowed to manage plugins on this site.' ); } $local = wp_list_filter( array_merge( self::get_local_woo_plugins(), self::get_local_woo_themes() ), array( '_product_id' => $product_id ) ); // Attempt to deactivate this plugin or theme. if ( ! empty( $local ) ) { $local = array_shift( $local ); if ( is_plugin_active( $local['_filename'] ) ) { deactivate_plugins( $local['_filename'] ); } $deactivated = ! is_plugin_active( $local['_filename'] ); } $redirect_uri = add_query_arg( array( 'page' => 'wc-addons', 'section' => 'helper', 'filter' => self::get_current_filter(), 'wc-helper-status' => $deactivated ? 'deactivate-plugin-success' : 'deactivate-plugin-error', 'wc-helper-product-id' => $product_id, ), admin_url( 'admin.php' ) ); wp_safe_redirect( $redirect_uri ); die(); }