WC_Helper_Updater::get_updates_count()
Get the number of products that have updates.
Method of the class: WC_Helper_Updater{}
No Hooks.
Return
Int
. The number of products with updates.
Usage
$result = WC_Helper_Updater::get_updates_count();
WC_Helper_Updater::get_updates_count() WC Helper Updater::get updates count code WC 9.6.0
public static function get_updates_count() { $cache_key = '_woocommerce_helper_updates_count'; $count = get_transient( $cache_key ); if ( false !== $count ) { return $count; } // Don't fetch any new data since this function in high-frequency. if ( ! get_transient( '_woocommerce_helper_subscriptions' ) ) { return 0; } if ( ! get_transient( '_woocommerce_helper_updates' ) ) { return 0; } $count = 0; $update_data = self::get_update_data(); if ( empty( $update_data ) ) { set_transient( $cache_key, $count, 12 * HOUR_IN_SECONDS ); return $count; } // Scan local plugins. foreach ( WC_Helper::get_local_woo_plugins() as $plugin ) { if ( empty( $update_data[ $plugin['_product_id'] ] ) ) { continue; } if ( version_compare( $plugin['Version'], $update_data[ $plugin['_product_id'] ]['version'], '<' ) ) { ++$count; } } // Scan local themes. foreach ( WC_Helper::get_local_woo_themes() as $theme ) { if ( empty( $update_data[ $theme['_product_id'] ] ) ) { continue; } if ( version_compare( $theme['Version'], $update_data[ $theme['_product_id'] ]['version'], '<' ) ) { ++$count; } } set_transient( $cache_key, $count, 12 * HOUR_IN_SECONDS ); return $count; }