| 1 |
<?php |
| 2 |
/** |
| 3 |
* Main ProductDescription class. |
| 4 |
* |
| 5 |
* @package RadiusTheme\SB |
| 6 |
*/ |
| 7 |
|
| 8 |
namespace RadiusTheme\SB\Elementor\Widgets\General; |
| 9 |
|
| 10 |
use RadiusTheme\SB\Helpers\Fns; |
| 11 |
use RadiusTheme\SB\Abstracts\ElementorWidgetBase; |
| 12 |
use RadiusTheme\SB\Elementor\Widgets\Controls\NoticeSettings; |
| 13 |
use RadiusTheme\SB\Helpers\BuilderFns; |
| 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 Description class |
| 22 |
*/ |
| 23 |
class Notice 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__( 'Notice', 'shopbuilder' ); |
| 32 |
$this->rtsb_base = 'rtsb-wc-notice'; |
| 33 |
parent::__construct( $data, $args ); |
| 34 |
$this->rtsb_category = 'rtsb-shopbuilder-general'; |
| 35 |
} |
| 36 |
/** |
| 37 |
* Widget Field |
| 38 |
* |
| 39 |
* @return array |
| 40 |
*/ |
| 41 |
public function widget_fields() { |
| 42 |
return NoticeSettings::widget_fields( $this ); |
| 43 |
} |
| 44 |
/** |
| 45 |
* Set Widget Keyword. |
| 46 |
* |
| 47 |
* @return array |
| 48 |
*/ |
| 49 |
public function get_keywords() { |
| 50 |
return [ 'Notice' ] + parent::get_keywords(); |
| 51 |
} |
| 52 |
|
| 53 |
/** |
| 54 |
* @return void |
| 55 |
*/ |
| 56 |
public function apply_the_hooks() { |
| 57 |
|
| 58 |
} |
| 59 |
|
| 60 |
/** |
| 61 |
* Render Function |
| 62 |
* |
| 63 |
* @return void |
| 64 |
*/ |
| 65 |
protected function render() { |
| 66 |
$this->apply_the_hooks(); |
| 67 |
$this->theme_support(); |
| 68 |
|
| 69 |
if ( $this->is_edit_mode() ) { |
| 70 |
$all_notices = [ |
| 71 |
'success' => [ |
| 72 |
[ |
| 73 |
'notice' => esc_html__( 'This is demo preview for success notice.', 'shopbuilder' ) . '<a href="#" tabindex="1" class="button wc-forward">' . esc_html__( 'Demo Button', 'shopbuilder' ) . '</a>', |
| 74 |
'data' => [], |
| 75 |
], |
| 76 |
], |
| 77 |
'error' => [ |
| 78 |
[ |
| 79 |
'notice' => esc_html__( 'This is demo preview for error notice.', 'shopbuilder' ), |
| 80 |
'data' => [], |
| 81 |
], |
| 82 |
], |
| 83 |
'notice' => [ |
| 84 |
[ |
| 85 |
'notice' => esc_html__( 'This is demo preview for info notice.', 'shopbuilder' ), |
| 86 |
'data' => [], |
| 87 |
], |
| 88 |
], |
| 89 |
]; |
| 90 |
|
| 91 |
$notice_types = [ 'success', 'error', 'notice' ]; |
| 92 |
|
| 93 |
echo '<div class="rtsb-notice-widget"><div class="rtsb-notice"><div class="woocommerce-notices-wrapper">'; |
| 94 |
|
| 95 |
foreach ( $notice_types as $notice_type ) { |
| 96 |
$messages = []; |
| 97 |
|
| 98 |
foreach ( $all_notices[ $notice_type ] as $notice ) { |
| 99 |
$messages[] = $notice['notice'] ?? $notice; |
| 100 |
} |
| 101 |
|
| 102 |
wc_get_template( |
| 103 |
"notices/{$notice_type}.php", |
| 104 |
[ |
| 105 |
'messages' => $messages, |
| 106 |
'notices' => $all_notices[ $notice_type ], |
| 107 |
] |
| 108 |
); |
| 109 |
} |
| 110 |
echo '</div></div>'; |
| 111 |
} else { |
| 112 |
echo '<div class="rtsb-notice-widget">'; |
| 113 |
Fns::woocommerce_output_all_notices(); |
| 114 |
echo '</div>'; |
| 115 |
} |
| 116 |
|
| 117 |
$this->theme_support( 'render_reset' ); |
| 118 |
} |
| 119 |
} |
| 120 |
|