WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru
функция не описана

WC_Helper::deactivated_plugin() public WC 1.0

Runs when any plugin is deactivated.

When a user deactivates a plugin, attempt to deactivate any subscriptions associated with the extension.

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

Возвращает

Null. Ничего.

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

$result = WC_Helper::deactivated_plugin( $filename );
$filename(строка) (обязательный)
The filename of the deactivated plugin.

Код WC_Helper::deactivated_plugin() WC 4.5.2

woocommerce/includes/admin/helper/class-wc-helper.php
<?php
public static function deactivated_plugin( $filename ) {
	$plugins = self::get_local_woo_plugins();

	// Not a local woo plugin.
	if ( empty( $plugins[ $filename ] ) ) {
		return;
	}

	// Make sure we have a connection.
	$auth = WC_Helper_Options::get( 'auth' );
	if ( empty( $auth ) ) {
		return;
	}

	$plugin        = $plugins[ $filename ];
	$product_id    = $plugin['_product_id'];
	$subscriptions = self::_get_subscriptions_from_product_id( $product_id, false );
	$site_id       = absint( $auth['site_id'] );

	// No valid subscriptions for this product.
	if ( empty( $subscriptions ) ) {
		return;
	}

	$deactivated = 0;

	foreach ( $subscriptions as $subscription ) {
		// Don't touch subscriptions that aren't activated on this site.
		if ( ! in_array( $site_id, $subscription['connections'], true ) ) {
			continue;
		}

		$product_key           = $subscription['product_key'];
		$deactivation_response = WC_Helper_API::post(
			'deactivate',
			array(
				'authenticated' => true,
				'body'          => wp_json_encode(
					array(
						'product_key' => $product_key,
					)
				),
			)
		);

		if ( wp_remote_retrieve_response_code( $deactivation_response ) === 200 ) {
			$deactivated++;

			/**
			 * Fires when the Helper activates a product successfully.
			 *
			 * @param int    $product_id Product ID being deactivated.
			 * @param string $product_key Subscription product key.
			 * @param array  $deactivation_response The response object from wp_safe_remote_request().
			 */
			do_action( 'woocommerce_helper_subscription_deactivate_success', $product_id, $product_key, $deactivation_response );
		} else {
			/**
			 * Fires when the Helper fails to activate a product.
			 *
			 * @param int    $product_id Product ID being deactivated.
			 * @param string $product_key Subscription product key.
			 * @param array  $deactivation_response The response object from wp_safe_remote_request().
			 */
			do_action( 'woocommerce_helper_subscription_deactivate_error', $product_id, $product_key, $deactivation_response );
		}
	}

	if ( $deactivated ) {
		self::log( sprintf( 'Auto-deactivated %d subscription(s) for %s', $deactivated, $filename ) );
		self::_flush_subscriptions_cache();
		self::_flush_updates_cache();
	}
}