PluginProbe
WP Directory Kit / 1.3.3
WP Directory Kit v1.3.3
1.5.6 1.5.5 1.5.4 1.5.3 trunk 1.1.0 1.1.6 1.1.8 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.8 1.4.0 1.4.1 All 35 releases
wpdirectorykit / elementor-elements / classes / wdk-button-addlisting.php

wdk-button-addlisting.php in WP Directory Kit 1.3.3, at elementor-elements/classes/wdk-button-addlisting.php

315 lines 9.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Wdk\Elementor\Widgets;
4
5 use Wdk\Elementor\Widgets\WdkElementorBase;
6 use Elementor\Widget_Base;
7 use Elementor\Controls_Manager;
8 use Elementor\Utils;
9 use Elementor\Typography;
10 use Elementor\Editor;
11 use Elementor\Plugin;
12 use Elementor\Repeater;
13 use Elementor\Core\Schemes;
14 use Elementor\Icons_Manager;
15 use Elementor\Group_Control_Typography;
16 use Elementor\Group_Control_Border;
17 use Elementor\Group_Control_Box_Shadow;
18
19 if (!defined('ABSPATH'))
20 exit; // Exit if accessed directly
21
22 /**
23 * @since 1.1.0
24 */
25 class WdkButtonAddlisting extends WdkElementorBase {
26
27 public $field_id = NULL;
28 public $fields_list = array();
29
30 public function __construct($data = array(), $args = null) {
31
32 \Elementor\Controls_Manager::add_tab(
33 'tab_conf',
34 esc_html__('Settings', 'wpdirectorykit')
35 );
36
37 \Elementor\Controls_Manager::add_tab(
38 'tab_layout',
39 esc_html__('Layout', 'wpdirectorykit')
40 );
41
42 \Elementor\Controls_Manager::add_tab(
43 'tab_content',
44 esc_html__('Main', 'wpdirectorykit')
45 );
46
47
48 if ($this->is_edit_mode_load()) {
49 $this->enqueue_styles_scripts();
50 }
51
52 parent::__construct($data, $args);
53
54 }
55
56
57 /**
58 * Retrieve the widget name.
59 *
60 * @since 1.1.0
61 *
62 * @access public
63 *
64 * @return string Widget name.
65 */
66 public function get_name() {
67 return 'wdk-button-addlisting';
68 }
69
70 /**
71 * Retrieve the widget title.
72 *
73 * @since 1.1.0
74 *
75 * @access public
76 *
77 * @return string Widget title.
78 */
79 public function get_title() {
80 return esc_html__('Wdk Button Add Listing', 'wpdirectorykit');
81 }
82
83 /**
84 * Retrieve the widget icon.
85 *
86 * @since 1.1.0
87 *
88 * @access public
89 *
90 * @return string Widget icon.
91 */
92 public function get_icon() {
93 return 'eicon-dual-button';
94 }
95
96 /**
97 * Register the widget controls.
98 *
99 * Adds different input fields to allow the user to change and customize the widget settings.
100 *
101 * @since 1.1.0
102 *
103 * @access protected
104 */
105 protected function register_controls() {
106 $this->generate_controls_conf();
107 $this->generate_controls_layout();
108 $this->generate_controls_styles();
109 $this->generate_controls_content();
110
111 $this->insert_pro_message('1');
112 parent::register_controls();
113 }
114
115 /**
116 * Render the widget output on the frontend.
117 *
118 * Written in PHP and used to generate the final HTML.
119 *
120 * @since 1.1.0
121 *
122 * @access protected
123 */
124 protected function render() {
125 parent::render();
126
127 $this->data['id_element'] = $this->get_id();
128 $this->data['settings'] = $this->get_settings();
129
130 $this->data['settings']['link_url'] = get_admin_url() . "admin.php?page=wdk_listing";
131 if(is_user_logged_in()) {
132
133 if(function_exists('wdk_dash_url') && wdk_dash_url('dash_page=listings&function=edit')){
134 if(current_user_can('edit_own_listings') || wmvc_user_in_role('administrator')){
135 $this->data['settings']['link_url'] = wdk_dash_url('dash_page=listings&function=edit');
136 } else {
137 $this->data['settings']['link_text'] = esc_html__('My Profile', 'wpdirectorykit');
138 $this->data['settings']['link_url'] = wdk_dash_url('dash_page=profile');
139 $this->data['settings']['link_icon'] = '';
140 }
141 } else {
142 $this->data['settings']['link_url'] = get_admin_url() . "admin.php?page=wdk_listing";
143 }
144
145 } else {
146 $redirect = get_admin_url() . "admin.php?page=wdk_listing";
147 if(function_exists('wdk_dash_url') && wdk_get_option('wdk_membership_login_page')){
148 $redirect = wdk_dash_url('dash_page=listings&function=edit');
149 }
150
151 $this->data['settings']['link_url'] = wp_login_url($redirect);
152 if(wdk_get_option('wdk_membership_login_page')){
153 $this->data['settings']['link_url'] = wdk_url_suffix(get_permalink(wdk_get_option('wdk_membership_login_page')), 'redirect_to='.urlencode($redirect));
154 }
155 }
156
157
158 if(!empty($this->data['settings']['custom_link']['url'])) {
159 $this->add_link_attributes( 'custom_link', $this->data['settings']['custom_link'] );
160 }
161
162 $this->data['is_edit_mode']= false;
163 if(Plugin::$instance->editor->is_edit_mode()){
164 $this->data['is_edit_mode']= true;
165 } else {
166 }
167
168 echo $this->view('wdk-button-addlisting', $this->data);
169 }
170
171 private function generate_controls_conf() {
172 $this->start_controls_section(
173 'tab_conf_main_section',
174 [
175 'label' => esc_html__('Main', 'wpdirectorykit'),
176 'tab' => '1',
177 ]
178 );
179
180 $this->add_control(
181 'link_text',
182 [
183 'label' => __('Text Button', 'wpdirectorykit'),
184 'type' => \Elementor\Controls_Manager::TEXT,
185 'default' => __('Add Listing', 'wpdirectorykit'),
186 'separator' => 'before',
187 ]
188 );
189
190 $this->add_control(
191 'link_id',
192 [
193 'label' => __('Secial attr id for link', 'wpdirectorykit'),
194 'type' => \Elementor\Controls_Manager::TEXT,
195 'default' => '',
196 ]
197 );
198
199 $this->add_control(
200 'link_icon',
201 [
202 'label' => esc_html__('Icon', 'wpdirectorykit'),
203 'type' => Controls_Manager::ICONS,
204 'label_block' => true,
205 'default' => [
206 'value' => 'fa fa-plus',
207 'library' => 'solid',
208 ],
209 ]
210 );
211
212 $this->add_control(
213 'link_icon_position',
214 [
215 'label' => esc_html__('icon Position', 'wpdirectorykit'),
216 'type' => Controls_Manager::SELECT,
217 'options' => [
218 'left' => esc_html__('Left', 'wpdirectorykit'),
219 'right' => esc_html__('Right', 'wpdirectorykit'),
220 ],
221 'default' => 'left',
222 ]
223 );
224
225 $this->add_control(
226 'custom_link',
227 [
228 'label' => esc_html__( 'Link', 'wpdirectorykit' ),
229 'desciption' => esc_html__( 'use this url instead default', 'wpdirectorykit' ),
230 'type' => \Elementor\Controls_Manager::URL,
231 'placeholder' => esc_html__( 'https://your-link.com', 'wpdirectorykit' ),
232 'options' => [ 'url', 'is_external', 'nofollow' ],
233 'default' => [
234 'url' => '',
235 'is_external' => true,
236 'nofollow' => true,
237 // 'custom_attributes' => '',
238 ],
239 'label_block' => true,
240 ]
241 );
242
243 $this->end_controls_section();
244 }
245
246 private function generate_controls_layout() {
247
248 }
249
250 private function generate_controls_styles() {
251 $items = [
252 [
253 'key'=>'btn',
254 'label'=> esc_html__('Button', 'wpdirectorykit'),
255 'options'=>['margin','typo','color','background','border','border_radius','padding','shadow','transition'],
256 ]
257 ];
258
259 foreach ($items as $item) {
260 $this->start_controls_section(
261 $item['key'].'_section',
262 [
263 'label' => $item['label'],
264 'tab' => 'tab_layout'
265 ]
266 );
267
268 $selectors = array(
269 'normal' => '{{WRAPPER}} .wdk-element .wdk-element-button',
270 'hover'=>'{{WRAPPER}} .wdk-element .wdk-element-button%1$s'
271 );
272 $this->generate_renders_tabs($selectors, $item['key'].'_dynamic', $item['options']);
273
274 $this->end_controls_section();
275 /* END special for some elements */
276 }
277
278 $items = [
279 [
280 'key'=>'icon',
281 'label'=> esc_html__('Icon', 'wpdirectorykit'),
282 'options'=>['margin','font-size','color','background','border','border_radius','padding'],
283 ]
284 ];
285
286 foreach ($items as $item) {
287 $this->start_controls_section(
288 $item['key'].'_section',
289 [
290 'label' => $item['label'],
291 'tab' => 'tab_layout'
292 ]
293 );
294
295 $selectors = array(
296 'normal' => '{{WRAPPER}} .wdk-element .wdk-element-button i,{{WRAPPER}} .wdk-element .wdk-element-button svg',
297 'hover'=>'{{WRAPPER}} .wdk-element .wdk-element-button%1$s i,{{WRAPPER}} .wdk-element .wdk-element-button%1$s svg'
298 );
299 $this->generate_renders_tabs($selectors, $item['key'].'_dynamic', $item['options']);
300
301 $this->end_controls_section();
302 /* END special for some elements */
303 }
304 }
305
306
307 private function generate_controls_content() {
308
309 }
310
311 public function enqueue_styles_scripts() {
312 wp_enqueue_style('wdk-element-button');
313 }
314 }
315