PluginProbe
WP Directory Kit / 1.5.5
WP Directory Kit v1.5.5
1.5.9 1.5.7 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 All 37 releases
wpdirectorykit / elementor-extensions / wdk-listing-card-button.php

wdk-listing-card-button.php in WP Directory Kit 1.5.5, at elementor-extensions/wdk-listing-card-button.php

188 lines 5.1 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\Extensions;
4
5
6 use Wdk\Elementor\Widgets\WdkElementorBase;
7 use Elementor\Widget_Base;
8 use Elementor\Controls_Manager;
9 use Elementor\Utils;
10 use Elementor\Typography;
11 use Elementor\Editor;
12 use Elementor\Plugin;
13 use Elementor\Repeater;
14 use Elementor\Core\Schemes;
15 use Elementor\Icons_Manager;
16 use Elementor\Group_Control_Typography;
17 use Elementor\Group_Control_Border;
18 use Elementor\Group_Control_Box_Shadow;
19
20 if (!defined('ABSPATH'))
21 exit; // Exit if accessed directly
22
23 /**
24 * @since 1.1.0
25 */
26 class WdkListingCardButton extends \Wdk\Elementor\Widgets\WdkButton {
27 public $field_types = array();
28
29 public function __construct($data = array(), $args = null) {
30 parent::__construct($data, $args);
31 }
32
33 /**
34 * Retrieve the widget name.
35 *
36 * @since 1.1.0
37 *
38 * @access public
39 *
40 * @return string Widget name.
41 */
42 public function get_name() {
43 return 'wdk-listing-card-button';
44 }
45
46 /**
47 * Retrieve the widget title.
48 *
49 * @since 1.1.0
50 *
51 * @access public
52 *
53 * @return string Widget title.
54 */
55 public function get_title() {
56 return esc_html__('Wdk Listing Card Button', 'wpdirectorykit');
57 }
58
59 /**
60 * Register the widget controls.
61 *
62 * Adds different input fields to allow the user to change and customize the widget settings.
63 *
64 * @since 1.1.0
65 *
66 * @access protected
67 */
68 protected function register_controls() {
69 parent::register_controls();
70 }
71
72 /**
73 * Render the widget output on the frontend.
74 *
75 * Written in PHP and used to generate the final HTML.
76 *
77 * @since 1.1.0
78 *
79 * @access protected
80 */
81
82 protected function render() {
83
84 $this->data['id_element'] = $this->get_id();
85 $this->data['settings'] = $this->get_settings();
86
87 $enable = false;
88 if(wmvc_show_data('event_is_login_all', $this->data['settings'])) {
89 if(is_user_logged_in()){
90 $enable = true;
91 }
92 }
93
94 if(wmvc_show_data('event_is_not_login', $this->data['settings'])) {
95 if(!is_user_logged_in()){
96 $enable = true;
97 }
98 }
99
100 if(wmvc_show_data('event_is_login_custom_user_type', $this->data['settings'])) {
101 if(is_user_logged_in()){
102 foreach ($this->data['settings']['event_is_login_custom_user_type_list'] as $user_type) {
103 if(wmvc_user_in_role($user_type['role'])) {
104 $enable = true;
105 }
106 }
107 }
108 }
109
110 global $wdk_listing_id;
111 if(wdk_is_listing_page_enabled() && isset($wdk_listing_id)) {
112 $this->data['settings']['link_url'] = get_permalink($wdk_listing_id);
113 }
114
115 $this->data['is_edit_mode']= false;
116 if(Plugin::$instance->editor->is_edit_mode()){
117 $this->data['is_edit_mode']= true;
118 } else {
119 if(!$enable) {
120 return false;
121 }
122 }
123
124 echo $this->view('wdk-button', $this->data);
125
126 }
127
128 protected function generate_controls_conf() {
129
130 $this->start_controls_section(
131 'tab_conf_main_section',
132 [
133 'label' => esc_html__('Main', 'wpdirectorykit'),
134 'tab' => '1',
135 ]
136 );
137 $this->add_control(
138 'conf_pagination_enable',
139 [
140 'label' => __( 'Pagination', 'wpdirectorykit' ),
141 'type' => \Elementor\Controls_Manager::SWITCHER,
142 'label_on' => __( 'Show', 'wpdirectorykit' ),
143 'label_off' => __( 'Hide', 'wpdirectorykit' ),
144 'return_value' => 'yes',
145 'default' => 'yes',
146 ]
147 );
148
149 $this->add_control(
150 'per_page',
151 [
152 'label' => __( 'Limit Results (Per page)', 'wpdirectorykit' ),
153 'type' => \Elementor\Controls_Manager::NUMBER,
154 'min' => 1,
155 'max' => 50,
156 'step' => 1,
157 'default' => 10,
158 ]
159 );
160
161 $this->add_control(
162 'hide_profiles_with_no_listings',
163 [
164 'label' => __( 'Hide Profiles Without Listings', 'wpdirectorykit' ),
165 'type' => Controls_Manager::SWITCHER,
166 'label_on' => __( 'Hide', 'wpdirectorykit' ),
167 'label_off' => __( 'Show', 'wpdirectorykit' ),
168 'return_value' => 'yes',
169 'default' => '',
170 'separator' => 'before',
171 ]
172 );
173
174 $this->end_controls_section();
175 }
176 }
177
178 /* remove */
179 add_action(
180 'elementor/element/before_section_end',
181 function($section, $section_id, $args) {
182 if( $section->get_name() == 'wdk-membership-class-contact-form'/* && $section_id == 'section_style'*/ )
183 {
184 $section->remove_control('mail_data_to_email');
185 }
186 }, 10, 3
187 );
188