PluginProbe
WP Directory Kit / trunk
WP Directory Kit vtrunk
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-implode-shortcode.php

wdk-implode-shortcode.php in WP Directory Kit trunk, at elementor-elements/classes/wdk-implode-shortcode.php

175 lines 4.6 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 WdkImplodeShortcode 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 add_action( 'elementor/editor/after_enqueue_styles', function()
48 {
49 wp_add_inline_style( 'elementor-editor', '.elementor-control-content select option[value*="section"]{color:#fff;background:#000}');
50 } );
51
52 if ($this->is_edit_mode_load()) {
53 $this->enqueue_styles_scripts();
54 }
55
56 parent::__construct($data, $args);
57
58 }
59
60 /**
61 * Retrieve the widget name.
62 *
63 * @since 1.1.0
64 *
65 * @access public
66 *
67 * @return string Widget name.
68 */
69 public function get_name() {
70 return 'wdk-implode-shortcode';
71 }
72
73 /**
74 * Retrieve the widget title.
75 *
76 * @since 1.1.0
77 *
78 * @access public
79 *
80 * @return string Widget title.
81 */
82 public function get_title() {
83 return esc_html__('Wdk Implode Shortcode', 'wpdirectorykit');
84 }
85
86 /**
87 * Retrieve the widget icon.
88 *
89 * @since 1.1.0
90 *
91 * @access public
92 *
93 * @return string Widget icon.
94 */
95 public function get_icon() {
96 return 'eicon-post-title';
97 }
98
99 /**
100 * Register the widget controls.
101 *
102 * Adds different input fields to allow the user to change and customize the widget settings.
103 *
104 * @since 1.1.0
105 *
106 * @access protected
107 */
108 protected function register_controls() {
109 $this->generate_controls_conf();
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 $shortcode = $this->data['settings']['shortcode'];
131 $profile_id = wdk_get_profile_page_id();
132 if(stripos($shortcode, '{profile_id}') !== false && $profile_id){
133 $shortcode= str_replace('{profile_id}', $profile_id, $shortcode);
134 }
135
136 global $wdk_listing_id;
137 if(stripos($shortcode, '{listing_id}') !== false && isset($wdk_listing_id)){
138 $shortcode= str_replace('{listing_id}', $wdk_listing_id, $shortcode);
139 }
140
141 $this->data['is_edit_mode']= false;
142 if(Plugin::$instance->editor->is_edit_mode()){
143 echo $shortcode;
144 } else {
145 return do_shortcode($shortcode);
146 }
147
148 }
149
150
151 private function generate_controls_conf() {
152 $this->start_controls_section(
153 'tab_conf_main_section',
154 [
155 'label' => esc_html__('Main', 'wpdirectorykit'),
156 'tab' => '1',
157 ]
158 );
159
160 $this->add_control(
161 'shortcode',
162 [
163 'label' => __( 'Shortcode', 'wpdirectorykit' ),
164 'type' => \Elementor\Controls_Manager::TEXTAREA,
165 'description' => '<span style="word-break: break-all;">'.__( 'Special vars:', 'wpdirectorykit' ).
166 '<br> {profile_id} - replaced on profile id'.
167 '<br> {listing_id} - replaced on listing id'.
168 '</span>',
169 ]
170 );
171
172 $this->end_controls_section();
173 }
174 }
175