PluginProbe
StoreEngine — Complete eCommerce Solution with Memberships, Licensing, Affiliates & More / 2.2.0
StoreEngine — Complete eCommerce Solution with Memberships, Licensing, Affiliates & More v2.2.0
2.3.0 2.2.0 2.1.1 2.1.0 2.0.0 1.10.0 1.9.1 1.9.0 1.2.1 1.2.2 1.3.0 1.3.1 1.3.2 1.3.3 1.4.0 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.6.0 All 59 releases
storeengine / includes / shortcode / product-description.php

product-description.php in StoreEngine — Complete eCommerce Solution with Memberships, Licensing, Affiliates & More 2.2.0, at includes/shortcode/product-description.php

44 lines 923 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace StoreEngine\Shortcode;
4
5 use StoreEngine\Utils\Helper;
6 use StoreEngine\Utils\Template;
7
8 if ( ! defined( 'ABSPATH' ) ) {
9 exit;
10 }
11
12 class ProductDescription {
13
14 public function __construct() {
15 add_shortcode( 'storeengine_product_description', [ $this, 'render' ] );
16 }
17
18 public function render( array $attrs ) {
19 $attrs = shortcode_atts( [
20 'label' => __( 'Description', 'storeengine' ),
21 'product_id' => null,
22 ], $attrs );
23
24 if ( empty( $attrs['product_id'] ) ) {
25 return __( 'Product ID is required', 'storeengine' );
26 }
27
28 $product_id = (int) $attrs['product_id'];
29 $product = Helper::get_product( $product_id );
30 if ( ! $product ) {
31 return __( 'Product not found', 'storeengine' );
32 }
33
34 ob_start();
35 Template::get_template( 'shortcode/product-description.php', [
36 'label' => $attrs['label'],
37 'content' => $product->get_content(),
38 ] );
39
40 return ob_get_clean();
41 }
42
43 }
44