-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunction.php
185 lines (161 loc) · 4.79 KB
/
function.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
<?php
namespace WeDevs\DokanPro\Modules\Elementor\Widgets;
use WeDevs\DokanPro\Modules\Elementor\Abstracts\DokanButton;
use Elementor\Controls_Manager;
use Elementor\Widget_Base;
class StoreFollowButton extends DokanButton {
protected $button_args = [];
/**
* Widget name
*
* @since 2.9.11
*
* @return string
*/
public function get_name() {
return 'dokan-store-follow-store-button';
}
/**
* Widget title
*
* @since 2.9.11
*
* @return string
*/
public function get_title() {
return __( 'Store Follow Button', 'dokan' );
}
/**
* Widget icon class
*
* @since 2.9.11
*
* @return string
*/
public function get_icon() {
return 'eicon-eye';
}
/**
* Widget keywords
*
* @since 2.9.11
*
* @return array
*/
public function get_keywords() {
return [ 'dokan', 'store', 'vendor', 'button', 'follow' ];
}
/**
* Register widget controls
*
* @since 2.9.11
*
* @return void
*/
protected function register_controls() {
parent::register_controls();
$this->update_control(
'text',
[
'dynamic' => [
'default' => dokan_elementor()->elementor()->dynamic_tags->tag_data_to_tag_text( null, 'dokan-store-follow-store-button-tag' ),
'active' => true,
],
'selectors' => [
'{{WRAPPER}} > .elementor-widget-container > .elementor-button-wrapper > .dokan-store-follow-store-btn' => 'width: auto; margin: 0;',
],
]
);
$this->update_control(
'link',
[
'type' => Controls_Manager::HIDDEN,
]
);
}
/**
* Button wrapper class
*
* @since 2.9.11
*
* @return string
*/
protected function get_button_wrapper_class() {
return parent::get_button_wrapper_class() . ' dokan-store-follow-store-btn-wrap';
}
/**
* Button class
*
* @since 2.9.11
*
* @return string
*/
protected function get_button_class() {
$classes = 'dokan-store-follow-store-btn dokan-follow-store-button dokan-follow-store-buttons-wrapper';
return $classes;
}
/**
* Render button
*
* @since 2.9.11
*
* @return void
*/
protected function render() {
if ( ! dokan_is_store_page() ) {
parent::render();
return;
}
if ( ! class_exists( \WeDevs\DokanPro\Modules\FollowStore\Module::class ) ) {
return;
}
$store_data = dokan_elementor()->get_store_data();
$vendor = dokan()->vendor->get( $store_data['id'] );
$this->button_args = dokan_follow_store_get_button_args( $vendor->data );
$this->add_render_attribute( 'button', 'data-vendor-id', $this->button_args['vendor_id'] );
$this->add_render_attribute( 'button', 'data-status', $this->button_args['status'] );
$this->add_render_attribute( 'button', 'data-is-logged-in', $this->button_args['is_logged_in'] );
parent::render();
}
/**
* Render button text.
*
* Render button widget text.
*
* @since 1.5.0
* @access protected
*/
protected function render_text( Widget_Base $instance = null ) {
if ( ! dokan_is_store_page() ) {
parent::render_text( $instance );
return;
}
$settings = $this->get_settings_for_display();
$this->add_render_attribute(
[
'content-wrapper' => [
'class' => 'elementor-button-content-wrapper',
],
'icon-align' => [
'class' => [
'elementor-button-icon',
'elementor-align-icon-' . $settings['icon_align'],
],
],
'text' => [
'class' => 'elementor-button-text',
],
]
);
$this->add_inline_editing_attributes( 'text', 'none' );
?>
<?php if ( ! empty( $settings['selected_icon']['value'] ) ) : ?>
<span <?php echo $this->get_render_attribute_string( 'icon-align' ); ?>>
<i class="<?php echo esc_attr( $settings['selected_icon']['value'] ); ?>" aria-hidden="true"></i>
</span>
<?php endif; ?>
<span class="dokan-follow-store-button-label-current elementor-button-text"><?php echo $this->button_args['label_current']; ?></span>
<span class="dokan-follow-store-button-label-unfollow elementor-button-text"><?php echo $this->button_args['label_unfollow']; ?></span>
<?php
}
}