WC_Helper::_helper_plugin_deactivate()private staticWC 1.0

Deactivate a plugin.

Метод класса: WC_Helper{}

Хуков нет.

Возвращает

null. Ничего (null).

Использование

$result = WC_Helper::_helper_plugin_deactivate();

Код WC_Helper::_helper_plugin_deactivate() WC 8.7.0

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();
}