Automattic\WooCommerce\Internal\Admin\Marketing
MarketingSpecs::get_recommended_plugins()
Load recommended plugins from WooCommerce.com
Метод класса: MarketingSpecs{}
Хуков нет.
Возвращает
Массив
.
Использование
$MarketingSpecs = new MarketingSpecs(); $MarketingSpecs->get_recommended_plugins(): array;
Код MarketingSpecs::get_recommended_plugins() MarketingSpecs::get recommended plugins WC 8.1.1
public function get_recommended_plugins(): array { $plugins = get_transient( self::RECOMMENDED_PLUGINS_TRANSIENT ); if ( false === $plugins ) { $request = wp_remote_get( 'https://woocommerce.com/wp-json/wccom/marketing-tab/1.3/recommendations.json', array( 'user-agent' => 'WooCommerce/' . WC()->version . '; ' . get_bloginfo( 'url' ), ) ); $plugins = []; if ( ! is_wp_error( $request ) && 200 === $request['response']['code'] ) { $plugins = json_decode( $request['body'], true ); } set_transient( self::RECOMMENDED_PLUGINS_TRANSIENT, $plugins, // Expire transient in 15 minutes if remote get failed. // Cache an empty result to avoid repeated failed requests. empty( $plugins ) ? 900 : 3 * DAY_IN_SECONDS ); } return array_values( $plugins ); }