| 1 |
<?php |
| 2 |
/** |
| 3 |
* Main ProductTitle class. |
| 4 |
* |
| 5 |
* @package RadiusTheme\SB |
| 6 |
*/ |
| 7 |
|
| 8 |
namespace RadiusTheme\SB\Elementor\Widgets\Single; |
| 9 |
|
| 10 |
use RadiusTheme\SB\Helpers\Fns; |
| 11 |
use RadiusTheme\SB\Abstracts\ElementorWidgetBase; |
| 12 |
use RadiusTheme\SB\Elementor\Widgets\Controls\TitleSettings; |
| 13 |
use RadiusTheme\SB\Elementor\Helper\ControlHelper; |
| 14 |
|
| 15 |
// Do not allow directly accessing this file. |
| 16 |
if ( ! defined( 'ABSPATH' ) ) { |
| 17 |
exit( 'This script cannot be accessed directly.' ); |
| 18 |
} |
| 19 |
|
| 20 |
/** |
| 21 |
* Product Title class |
| 22 |
*/ |
| 23 |
class ProductTitle extends ElementorWidgetBase { |
| 24 |
/** |
| 25 |
* Construct function |
| 26 |
* |
| 27 |
* @param array $data default array. |
| 28 |
* @param mixed $args default arg. |
| 29 |
*/ |
| 30 |
public function __construct( $data = [], $args = null ) { |
| 31 |
$this->rtsb_name = esc_html__( 'Product Title', 'shopbuilder' ); |
| 32 |
$this->rtsb_base = 'rtsb-product-title'; |
| 33 |
parent::__construct( $data, $args ); |
| 34 |
} |
| 35 |
/** |
| 36 |
* Widget Field |
| 37 |
* |
| 38 |
* @return array |
| 39 |
*/ |
| 40 |
public function widget_fields() { |
| 41 |
$fields = self::general_settings() + TitleSettings::title_settings( $this ); |
| 42 |
unset( |
| 43 |
$fields['title_style_start']['condition'], |
| 44 |
); |
| 45 |
return $fields; |
| 46 |
} |
| 47 |
/** |
| 48 |
* Set Widget Keyword. |
| 49 |
* |
| 50 |
* @return array |
| 51 |
*/ |
| 52 |
public function general_settings() { |
| 53 |
$fields = TitleSettings::general_settings(); |
| 54 |
$fields['general_style']['label'] = esc_html__( 'Options', 'shopbuilder' ); |
| 55 |
unset( $fields['show_title'] ); |
| 56 |
$new_fields = [ |
| 57 |
'product_title_html_tag' => [ |
| 58 |
'label' => esc_html__( 'Title HTML Tag', 'shopbuilder' ), |
| 59 |
'type' => 'select', |
| 60 |
'options' => ControlHelper::heading_tags(), |
| 61 |
'default' => 'h2', |
| 62 |
'separator' => 'default', |
| 63 |
], |
| 64 |
]; |
| 65 |
$fields = Fns::insert_controls( 'general_style', $fields, $new_fields, true ); |
| 66 |
return $fields; |
| 67 |
} |
| 68 |
/** |
| 69 |
* Set Widget Keyword. |
| 70 |
* |
| 71 |
* @return array |
| 72 |
*/ |
| 73 |
public function get_keywords() { |
| 74 |
return [ 'Heading', 'Name' ] + parent::get_keywords(); |
| 75 |
} |
| 76 |
/** |
| 77 |
* Render Function |
| 78 |
* |
| 79 |
* @return void |
| 80 |
*/ |
| 81 |
protected function render() { |
| 82 |
global $post; |
| 83 |
$_post = $post; |
| 84 |
$controllers = $this->get_settings_for_display(); |
| 85 |
$this->theme_support(); |
| 86 |
if ( $this->is_builder_mode() ) { |
| 87 |
// Overriding Global. |
| 88 |
$post = get_post( Fns::get_prepared_product_id() ); // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited |
| 89 |
} |
| 90 |
$data = [ |
| 91 |
'template' => 'elementor/single-product/title', |
| 92 |
'controllers' => $controllers, |
| 93 |
]; |
| 94 |
Fns::load_template( $data['template'], $data ); |
| 95 |
$this->theme_support( 'render_reset' ); |
| 96 |
$post = $_post; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited |
| 97 |
} |
| 98 |
|
| 99 |
} |
| 100 |
|