Automattic\WooCommerce\Admin\API
Marketing::get_recommended_plugins()
Return installed marketing extensions data.
Метод класса: Marketing{}
Хуков нет.
Возвращает
\WP_Error|\WP_REST_Response
.
Использование
$Marketing = new Marketing(); $Marketing->get_recommended_plugins( $request );
- $request(\WP_REST_Request) (обязательный)
- Request data.
Код Marketing::get_recommended_plugins() Marketing::get recommended plugins WC 9.3.1
public function get_recommended_plugins( $request ) { // Default to marketing category (if no category set). $category = ( ! empty( $request->get_param( 'category' ) ) ) ? $request->get_param( 'category' ) : 'marketing'; $all_plugins = MarketingRecommendationsInit::get_recommended_plugins(); $valid_plugins = []; $per_page = $request->get_param( 'per_page' ); foreach ( $all_plugins as $plugin ) { // default to marketing if 'categories' is empty on the plugin object (support for legacy api while testing). $plugin_categories = ( ! empty( $plugin['categories'] ) ) ? $plugin['categories'] : [ 'marketing' ]; if ( ! PluginsHelper::is_plugin_installed( $plugin['plugin'] ) && in_array( $category, $plugin_categories, true ) ) { $valid_plugins[] = $plugin; } } return rest_ensure_response( array_slice( $valid_plugins, 0, $per_page ) ); }