wc_prepare_attachment_for_js()
Prepare attachment for JavaScript.
Хуков нет.
Возвращает
Массив.
Использование
wc_prepare_attachment_for_js( $response );
- $response(массив) (обязательный)
- JS version of a attachment post object.
Код wc_prepare_attachment_for_js() wc prepare attachment for js WC 10.8.1
function wc_prepare_attachment_for_js( $response ) {
/*
* If the user can manage woocommerce, allow them to
* see the image content.
*/
if ( current_user_can( 'manage_woocommerce' ) ) {
return $response;
}
/*
* If the user does not have the right capabilities,
* filter out the image source and replace with placeholder
* image.
*/
if ( isset( $response['url'] ) && strstr( $response['url'], 'woocommerce_uploads/' ) ) {
$response['full']['url'] = wc_placeholder_img_src();
if ( isset( $response['sizes'] ) ) {
foreach ( $response['sizes'] as $size => $value ) {
$response['sizes'][ $size ]['url'] = wc_placeholder_img_src();
}
}
}
return $response;
}