Automattic\WooCommerce\Blocks\BlockTypes
ProductSummary::get_source
Get product description depends on config.
Метод класса: ProductSummary{}
Хуков нет.
Возвращает
Строку.
Использование
// private - только в коде основоного (родительского) класса $result = $this->get_source( $product, $show_description_if_empty );
- $product(WC_Product) (обязательный)
- Product object.
- $show_description_if_empty(true|false) (обязательный)
- Defines if fallback to full description.
Код ProductSummary::get_source() ProductSummary::get source WC 10.5.0
private function get_source( $product, $show_description_if_empty ) {
$short_description = $product->get_short_description();
if ( $short_description ) {
// Logic copied from https://github.com/woocommerce/woocommerce/blob/637dde283057ed6667ff81c73ed08774552f631d/plugins/woocommerce/includes/wc-core-functions.php#L53-L62.
$short_description = wp_kses_post( $short_description );
$short_description = $GLOBALS['wp_embed']->run_shortcode( $short_description );
$short_description = shortcode_unautop( $short_description );
$short_description = do_shortcode( $short_description );
return $short_description;
}
$description = $product->get_description();
if ( $show_description_if_empty && $description ) {
// Logic copied from https://github.com/woocommerce/woocommerce/blob/637dde283057ed6667ff81c73ed08774552f631d/plugins/woocommerce/includes/wc-core-functions.php#L53-L62.
$description = wp_kses_post( $description );
$description = $GLOBALS['wp_embed']->run_shortcode( $description );
$description = shortcode_unautop( $description );
$description = do_shortcode( $description );
return $description;
}
return '';
}