WC_Helper_Plugin_Info::plugins_api() public WC 1.0
Plugin information callback for Woo extensions.
{} Это метод класса: WC_Helper_Plugin_Info{}
Хуков нет.
Возвращает
Объект. An updated $response.
Использование
$result = WC_Helper_Plugin_Info::plugins_api( $response, $action, $args );
- $response(объект) (обязательный)
- The response core needs to display the modal.
- $action(строка) (обязательный)
- The requested plugins_api() action.
- $args(объект) (обязательный)
- Arguments passed to plugins_api().
Код WC_Helper_Plugin_Info::plugins_api() WC Helper Plugin Info::plugins api WC 5.0.0
public static function plugins_api( $response, $action, $args ) {
if ( 'plugin_information' !== $action ) {
return $response;
}
if ( empty( $args->slug ) ) {
return $response;
}
// Only for slugs that start with woo-
if ( 0 !== strpos( $args->slug, 'woocommerce-com-' ) ) {
return $response;
}
$clean_slug = str_replace( 'woocommerce-com-', '', $args->slug );
// Look through update data by slug.
$update_data = WC_Helper_Updater::get_update_data();
$products = wp_list_filter( $update_data, array( 'slug' => $clean_slug ) );
if ( empty( $products ) ) {
return $response;
}
$product_id = array_keys( $products );
$product_id = array_shift( $product_id );
// Fetch the product information from the Helper API.
$request = WC_Helper_API::get(
add_query_arg(
array(
'product_id' => absint( $product_id ),
),
'info'
),
array( 'authenticated' => true )
);
$results = json_decode( wp_remote_retrieve_body( $request ), true );
if ( ! empty( $results ) ) {
$response = (object) $results;
}
return $response;
}