WC_Helper::get_subscription_local_data
Add local data to a subscription.
Method of the class: WC_Helper{}
No Hooks.
Returns
Array. The subscription data with local data added.
Usage
$result = WC_Helper::get_subscription_local_data( $subscription );
- $subscription(array) (required)
- The subscription data.
WC_Helper::get_subscription_local_data() WC Helper::get subscription local data code WC 10.5.0
public static function get_subscription_local_data( array $subscription ) {
$local_plugins = self::get_local_plugins();
$local_themes = self::get_local_themes();
$installed_product = wp_list_filter(
array_merge( $local_plugins, $local_themes ),
array( 'slug' => $subscription['zip_slug'] )
);
$installed_product = array_shift( $installed_product );
if ( empty( $installed_product ) ) {
return array(
'installed' => false,
'active' => false,
'version' => null,
'type' => null,
'slug' => null,
'path' => null,
);
}
$local_data = array(
'installed' => true,
'active' => false,
'version' => $installed_product['Version'],
'type' => $installed_product['_type'],
'slug' => null,
'path' => $installed_product['_filename'],
);
if ( 'plugin' === $installed_product['_type'] ) {
$local_data['slug'] = $installed_product['slug'];
if ( is_plugin_active( $installed_product['_filename'] ) ) {
$local_data['active'] = true;
} elseif ( is_multisite() && is_plugin_active_for_network( $installed_product['_filename'] ) ) {
$local_data['active'] = true;
}
} elseif ( 'theme' === $installed_product['_type'] ) {
$local_data['slug'] = $installed_product['_stylesheet'];
if ( in_array( $installed_product['_stylesheet'], array( get_stylesheet(), get_template() ), true ) ) {
$local_data['active'] = true;
}
}
return $local_data;
}