WC_Helper::get_auto_update_data │ private static │ WC 11.2.0

Shared auto-update state for a plugin or a theme.

Method of the class: WC_Helper{}

No Hooks.

Returns

array{auto_update: bool, auto_update_manageable: bool}.

Usage

$result = WC_Helper::get_auto_update_data( $type, $item_key ): array;
$type('plugin'|'theme') (required)
The product type.
$item_key(string) (required)
Plugin file, or theme stylesheet.

Changelog

Since 11.2.0 Introduced.

WC_Helper::get_auto_update_data() code WC 11.2.1

private static function get_auto_update_data( string $type, string $item_key ): array {
	require_once ABSPATH . 'wp-admin/includes/update.php';

	$forced = wp_is_auto_update_forced_for_item( $type, null, self::get_auto_update_filter_payload( $type, $item_key ) );
	if ( ! is_null( $forced ) ) {
		return array(
			'auto_update'            => (bool) $forced,
			'auto_update_manageable' => false,
		);
	}

	$option     = 'theme' === $type ? 'auto_update_themes' : 'auto_update_plugins';
	$capability = 'theme' === $type ? 'update_themes' : 'update_plugins';

	return array(
		// The product's own setting. AUTOMATIC_UPDATER_DISABLED and the auto-update-enabled
		// filters switch the feature off for the whole site without changing it, which the
		// screen deliberately does not report per row.
		'auto_update'            => in_array( $item_key, (array) get_site_option( $option, array() ), true ),
		// These options are network options, and core only offers the toggle from network admin
		// on multisite. My Subscriptions is a site-level screen, so it reads only there.
		'auto_update_manageable' => wp_is_auto_update_enabled_for_type( $type )
			&& ! is_multisite()
			&& current_user_can( $capability ),
	);
}