| 1 |
<?php |
| 2 |
/** |
| 3 |
* Main ProductMeta class. |
| 4 |
* |
| 5 |
* @package RadiusTheme\SB |
| 6 |
*/ |
| 7 |
|
| 8 |
namespace RadiusTheme\SB\Elementor\Widgets\Single; |
| 9 |
|
| 10 |
use Elementor\Controls_Manager; |
| 11 |
use RadiusTheme\SB\Helpers\Fns; |
| 12 |
use RadiusTheme\SB\Abstracts\ElementorWidgetBase; |
| 13 |
use RadiusTheme\SB\Elementor\Widgets\Controls\MetaSettings; |
| 14 |
use RadiusTheme\SB\Elementor\Widgets\Controls\ProductTaxSettings; |
| 15 |
|
| 16 |
// Do not allow directly accessing this file. |
| 17 |
if ( ! defined( 'ABSPATH' ) ) { |
| 18 |
exit( 'This script cannot be accessed directly.' ); |
| 19 |
} |
| 20 |
|
| 21 |
/** |
| 22 |
* Product Meta class |
| 23 |
*/ |
| 24 |
class ProductMeta extends ElementorWidgetBase { |
| 25 |
/** |
| 26 |
* Construct function |
| 27 |
* |
| 28 |
* @param array $data default array. |
| 29 |
* @param mixed $args default arg. |
| 30 |
*/ |
| 31 |
public function __construct( $data = [], $args = null ) { |
| 32 |
$this->rtsb_name = esc_html__( 'Product Meta', 'shopbuilder' ); |
| 33 |
$this->rtsb_base = 'rtsb-product-meta'; |
| 34 |
parent::__construct( $data, $args ); |
| 35 |
} |
| 36 |
/** |
| 37 |
* Widget Field |
| 38 |
* |
| 39 |
* @return array |
| 40 |
*/ |
| 41 |
public function widget_fields() { |
| 42 |
$fields = MetaSettings::widget_fields( $this ); |
| 43 |
$tax_settings = ProductTaxSettings::widget_fields( $this ); |
| 44 |
$tax_settings['meta_content']['tab'] = 'style'; |
| 45 |
$fields = $fields + $tax_settings; |
| 46 |
unset( $fields['show_label'] ); |
| 47 |
unset( $fields['meta_label_heading']['condition'] ); |
| 48 |
unset( $fields['label_typo']['condition'] ); |
| 49 |
unset( $fields['meta_label_color']['condition'] ); |
| 50 |
return $fields; |
| 51 |
} |
| 52 |
/** |
| 53 |
* Set Widget Keyword. |
| 54 |
* |
| 55 |
* @return array |
| 56 |
*/ |
| 57 |
public function get_keywords() { |
| 58 |
return [ 'SKU', 'Category', 'Tag' ] + parent::get_keywords(); |
| 59 |
} |
| 60 |
/** |
| 61 |
* Render Function |
| 62 |
* |
| 63 |
* @return void |
| 64 |
*/ |
| 65 |
protected function render() { |
| 66 |
global $product; |
| 67 |
$_product = $product; |
| 68 |
$product = Fns::get_product(); |
| 69 |
$controllers = $this->get_settings_for_display(); |
| 70 |
$this->theme_support(); |
| 71 |
// show_sku. |
| 72 |
$classes = ''; |
| 73 |
if ( ! empty( $controllers['show_sku'] ) ) { |
| 74 |
$classes .= 'rtsb-show-sku '; |
| 75 |
} |
| 76 |
if ( ! empty( $controllers['show_cat'] ) ) { |
| 77 |
$classes .= 'rtsb-show-cat '; |
| 78 |
} |
| 79 |
if ( ! empty( $controllers['show_tag'] ) ) { |
| 80 |
$classes .= 'rtsb-show-tag '; |
| 81 |
} |
| 82 |
$data = [ |
| 83 |
'template' => 'elementor/single-product/meta', |
| 84 |
'controllers' => $controllers, |
| 85 |
'classes' => $classes, |
| 86 |
]; |
| 87 |
Fns::load_template( $data['template'], $data ); |
| 88 |
$this->theme_support( 'render_reset' ); |
| 89 |
$product = $_product; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited |
| 90 |
} |
| 91 |
|
| 92 |
} |
| 93 |
|