| 1 |
<?php |
| 2 |
|
| 3 |
defined( 'ABSPATH' ) || die(); |
| 4 |
|
| 5 |
class Sellkit_Elementor_Product_Title_Widget extends Sellkit_Elementor_Upsell_Base_Widget { |
| 6 |
|
| 7 |
public static function is_active() { |
| 8 |
return class_exists( 'woocommerce' ); |
| 9 |
} |
| 10 |
|
| 11 |
public function get_name() { |
| 12 |
return 'sellkit-product-title'; |
| 13 |
} |
| 14 |
|
| 15 |
public function get_title() { |
| 16 |
return __( 'Product Title', 'sellkit' ); |
| 17 |
} |
| 18 |
|
| 19 |
public function get_icon() { |
| 20 |
return 'sellkit-element-icon sellkit-product-title-icon'; |
| 21 |
} |
| 22 |
|
| 23 |
protected function register_controls() { |
| 24 |
$this->register_content_box_controls(); |
| 25 |
|
| 26 |
$this->start_controls_section( |
| 27 |
'style', |
| 28 |
[ |
| 29 |
'label' => __( 'Style', 'sellkit' ), |
| 30 |
'tab' => 'style', |
| 31 |
] |
| 32 |
); |
| 33 |
|
| 34 |
$this->add_control( |
| 35 |
'title_color', |
| 36 |
[ |
| 37 |
'label' => __( 'Title Color', 'sellkit' ), |
| 38 |
'type' => 'color', |
| 39 |
'selectors' => [ |
| 40 |
'{{WRAPPER}} .product_title-widget .entry-title' => 'color: {{VALUE}} !important;', |
| 41 |
], |
| 42 |
] |
| 43 |
); |
| 44 |
|
| 45 |
$this->add_group_control( |
| 46 |
'typography', |
| 47 |
[ |
| 48 |
'name' => 'input_typography', |
| 49 |
'scheme' => '3', |
| 50 |
'selector' => '{{WRAPPER}} .product_title-widget .entry-title', |
| 51 |
] |
| 52 |
); |
| 53 |
|
| 54 |
$this->add_group_control( |
| 55 |
'text-shadow', |
| 56 |
[ |
| 57 |
'name' => 'play_icon_shadow', |
| 58 |
'fields_options' => [ |
| 59 |
'text_shadow_type' => [ |
| 60 |
'label' => __( 'Text Shadow', 'sellkit' ), |
| 61 |
], |
| 62 |
], |
| 63 |
'selector' => '{{WRAPPER}} .product_title-widget .entry-title', |
| 64 |
] |
| 65 |
); |
| 66 |
|
| 67 |
$this->end_controls_section(); |
| 68 |
} |
| 69 |
|
| 70 |
/** |
| 71 |
* Content section controls. |
| 72 |
* |
| 73 |
* @since 1.1.0 |
| 74 |
*/ |
| 75 |
private function register_content_box_controls() { |
| 76 |
$this->start_controls_section( |
| 77 |
'content', |
| 78 |
[ |
| 79 |
'label' => __( 'Content', 'sellkit' ), |
| 80 |
'tab' => 'content', |
| 81 |
] |
| 82 |
); |
| 83 |
|
| 84 |
$this->add_control( |
| 85 |
'html_tag', |
| 86 |
[ |
| 87 |
'label' => __( 'HTML Tag', 'sellkit' ), |
| 88 |
'type' => 'select', |
| 89 |
'default' => 'h1', |
| 90 |
'options' => [ |
| 91 |
'h1' => 'H1', |
| 92 |
'h2' => 'H2', |
| 93 |
'h3' => 'H3', |
| 94 |
'h4' => 'H4', |
| 95 |
'h5' => 'H5', |
| 96 |
'p' => 'p', |
| 97 |
'span' => 'span', |
| 98 |
], |
| 99 |
] |
| 100 |
); |
| 101 |
|
| 102 |
$this->add_responsive_control( |
| 103 |
'content_align', |
| 104 |
[ |
| 105 |
'label' => __( 'Alignment', 'sellkit' ), |
| 106 |
'type' => 'choose', |
| 107 |
'default' => 'left', |
| 108 |
'options' => [ |
| 109 |
'left' => [ |
| 110 |
'title' => __( 'Left', 'sellkit' ), |
| 111 |
'icon' => 'fa fa-align-left', |
| 112 |
], |
| 113 |
'center' => [ |
| 114 |
'title' => __( 'Center', 'sellkit' ), |
| 115 |
'icon' => 'fa fa-align-center', |
| 116 |
], |
| 117 |
'right' => [ |
| 118 |
'title' => __( 'Right', 'sellkit' ), |
| 119 |
'icon' => 'fa fa-align-right', |
| 120 |
], |
| 121 |
], |
| 122 |
'selectors' => [ |
| 123 |
'{{WRAPPER}} .product_title-widget' => 'text-align: {{VALUE}};', |
| 124 |
], |
| 125 |
] |
| 126 |
); |
| 127 |
|
| 128 |
$this->end_controls_section(); |
| 129 |
} |
| 130 |
|
| 131 |
protected function render() { |
| 132 |
$settings = $this->get_settings_for_display(); |
| 133 |
$html_tag = $settings['html_tag']; |
| 134 |
$product = $this->get_product_object(); |
| 135 |
|
| 136 |
if ( empty( $product ) ) { |
| 137 |
return; |
| 138 |
} |
| 139 |
|
| 140 |
$product_id = $product->get_id(); |
| 141 |
?> |
| 142 |
<div class="product_title-widget"> |
| 143 |
<<?php echo esc_attr( $html_tag ); ?> class="entry-title"><?php echo esc_html( get_the_title( $product_id ) ); ?></<?php echo esc_attr( $html_tag ); ?>> |
| 144 |
</div> |
| 145 |
<?php |
| 146 |
} |
| 147 |
} |
| 148 |
|