PluginProbe ʕ •ᴥ•ʔ
Paid Membership Plugin, Ecommerce, User Registration Form, Login Form, User Profile & Restrict Content – ProfilePress / trunk
Paid Membership Plugin, Ecommerce, User Registration Form, Login Form, User Profile & Restrict Content – ProfilePress vtrunk
4.16.18 4.16.17 4.16.16 trunk 1.0 1.0.1 1.0.2 1.1 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.5a 1.1.6 1.1.7 1.2 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.3 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.4 1.4.1 1.4.2 1.5 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.6 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6 1.6.7 1.6.8 1.7 1.7.1 1.7.2 1.8 1.8.1 1.8.10 1.8.2 1.8.3 1.8.4 1.8.5 1.8.6 1.8.7 1.8.8 1.8.9 1.9 1.9.1 1.9.10 1.9.11 1.9.12 1.9.13 1.9.2 1.9.3 1.9.4 1.9.5 1.9.6 1.9.7 1.9.8 1.9.9 2.1.9 2.2.10 2.2.11 2.2.12 2.2.13 2.2.14 2.2.15 2.2.16 2.2.2 2.2.5 2.2.6 2.2.7 2.2.8 2.2.9 3.0 3.1 3.1.1 3.1.10 3.1.11 3.1.12 3.1.13 3.1.14 3.1.15 3.1.16 3.1.17 3.1.18 3.1.19 3.1.2 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7 3.1.8 3.1.9 3.2.0 3.2.1 3.2.10 3.2.11 3.2.12 3.2.13 3.2.14 3.2.15 3.2.16 3.2.2 3.2.3 3.2.4 3.2.5 3.2.6 3.2.7 3.2.8 3.2.9 4.0.0 4.0.1 4.0.2 4.0.3 4.1.0 4.1.1 4.1.2 4.1.3 4.1.4 4.10.0 4.10.1 4.10.2 4.10.3 4.11.0 4.12.0 4.13.0 4.13.1 4.13.2 4.13.3 4.13.4 4.14.0 4.14.1 4.14.2 4.14.3 4.14.4 4.15.0 4.15.1 4.15.10 4.15.11 4.15.12 4.15.13 4.15.14 4.15.15 4.15.16 4.15.17 4.15.18 4.15.19 4.15.2 4.15.20 4.15.20.1 4.15.21 4.15.22 4.15.23 4.15.24 4.15.25 4.15.3 4.15.4 4.15.5 4.15.6 4.15.7 4.15.8 4.15.9 4.16.0 4.16.1 4.16.10 4.16.11 4.16.12 4.16.13 4.16.14 4.16.15 4.16.2 4.16.3 4.16.4 4.16.5 4.16.6 4.16.7 4.16.8 4.16.9 4.2.0 4.3.0 4.3.1 4.3.2 4.4.0 4.4.1 4.5.0 4.5.1 4.5.2 4.5.3 4.5.4 4.5.5 4.6.0 4.7.0 4.8.0 4.9.0
wp-user-avatar / src / Admin / SettingsPages / DragDropBuilder / FieldBase.php
wp-user-avatar / src / Admin / SettingsPages / DragDropBuilder Last commit date
Controls 1 year ago Fields 1 month ago DragDropBuilder.php 1 year ago FieldBase.php 3 months ago FieldInterface.php 5 years ago Metabox.php 1 year ago google-web-fonts.txt 5 years ago
FieldBase.php
250 lines
1 <?php
2
3 namespace ProfilePress\Core\Admin\SettingsPages\DragDropBuilder;
4
5 use ProfilePress\Core\Admin\SettingsPages\DragDropBuilder\Controls\IconPicker;
6 use ProfilePress\Core\Admin\SettingsPages\DragDropBuilder\Controls\Input;
7 use ProfilePress\Core\Admin\SettingsPages\DragDropBuilder\Controls\Select;
8 use ProfilePress\Core\Admin\SettingsPages\DragDropBuilder\Controls\Textarea;
9 use ProfilePress\Core\Admin\SettingsPages\DragDropBuilder\Controls\WPEditor;
10 use ProfilePress\Core\Classes\FormRepository;
11
12 abstract class FieldBase implements FieldInterface
13 {
14 const STANDARD_CATEGORY = 'standard';
15 const EXTRA_CATEGORY = 'extra';
16
17 const INPUT_FIELD = 'input';
18 const WPEDITOR_FIELD = 'wpeditor';
19 const SELECT_FIELD = 'select';
20 const TEXTAREA_FIELD = 'textarea';
21 const ICON_PICKER_FIELD = 'icon_picker';
22
23 const GENERAL_TAB = 'pp_tab_general';
24 const SETTINGS_TAB = 'pp_tab_settings';
25 const STYLE_TAB = 'pp_style_settings';
26 const COLUMN_SETTINGS = 'pp_column_settings';
27 const COLUMN_2_SETTINGS = 'pp_column_2_settings';
28
29 public $tag_name;
30
31 public $form_id;
32 public $form_type;
33 public $form_class;
34
35 public function __construct()
36 {
37 $this->form_id = isset($_GET['id']) ? absint($_GET['id']) : 0;
38 $this->form_type = sanitize_text_field($_GET['form-type']);
39 $this->form_class = FormRepository::get_form_meta($this->form_id, $this->form_type, FormRepository::FORM_CLASS);
40
41 $this->register_field();
42
43 $this->tag_name = $this->form_type == FormRepository::REGISTRATION_TYPE ? 'reg' : 'edit-profile';
44
45 add_action('admin_footer', [$this, 'print_template']);
46 }
47
48 public function field_bar_title()
49 {
50 return $this->field_title();
51 }
52
53 public function category()
54 {
55 return self::STANDARD_CATEGORY;
56 }
57
58 public function register_field()
59 {
60 $defaults = [];
61 $theme_class_instance = FormRepository::forge_class($this->form_id, $this->form_class, $this->form_type);
62 if ($theme_class_instance) {
63 $defaults = call_user_func([FormRepository::forge_class($this->form_id, $this->form_class, $this->form_type), 'default_fields_settings']);
64 }
65
66 $filter = 'ppress_form_builder_' . $this->category() . '_fields';
67
68 add_filter($filter, function ($fields) use ($defaults) {
69 $fields[$this->field_type()] = [
70 'fieldType' => $this->field_type(),
71 'fieldTitle' => $this->field_title(),
72 'fieldBarTitle' => $this->field_bar_title(),
73 'fieldIcon' => $this->field_icon()
74 ];
75
76 if (isset($defaults[$this->field_type()])) {
77 $fields[$this->field_type()] = wp_parse_args($fields[$this->field_type()], $defaults[$this->field_type()]);
78 }
79
80 return $fields;
81 });
82 }
83
84 public function field_settings_tabs()
85 {
86 return [
87 self::GENERAL_TAB => esc_html__('General', 'wp-user-avatar'),
88 self::STYLE_TAB => esc_html__('Style', 'wp-user-avatar'),
89 self::SETTINGS_TAB => esc_html__('Settings', 'wp-user-avatar'),
90 ];
91 }
92
93 public function print_template()
94 {
95 if ( ! ppress_is_admin_page() || $_GET['view'] != 'drag-drop-builder') return;
96
97 $this->field_settings_modal_tmpl();
98
99 $this->field_bar_tmpl();
100 }
101
102 public function field_settings_modal_tmpl()
103 {
104 $tabs = $this->field_settings_tabs();
105 $field_settings = apply_filters('ppress_form_builder_field_settings', $this->field_settings(), $this);
106
107 ?>
108 <script type="text/html" id="tmpl-pp-form-builder-popup-settings-<?= $this->field_type() ?>">
109 <div class="pp-form-buider-settings-popup-content">
110 <div class="pp-form-buider-settings-popup-header">
111 <h3><?php _e('Edit Field', 'wp-user-avatar'); ?></h3>
112 <div class="pp-actions-left">
113 <span class="pp-form-buider-settings-field-type">{{ data.fieldTitle }}</span>
114 </div>
115
116 <div class="pp-actions-right">
117 <span class="pp-form-buider-settings-field-close-btn pp-form-cancel-btn">&times;</span>
118 </div>
119 </div>
120 <div class="pp-form-buider-settings-popup-body">
121 <div class="pp-form-buider-settings-popup-tabs">
122 <?php foreach ($tabs as $tab_id => $tab_title) {
123 if ( ! empty($field_settings[$tab_id])) {
124 ?>
125 <a href="#<?= $tab_id ?>" class="pp-form-buider-settings-popup-tab-menu"><?= esc_html($tab_title) ?></a>
126 <?php
127 }
128 }
129 ?>
130 </div>
131
132 <?php
133 // we are re-arranging this because it is necessary for the modal field settings tab menu to work.
134 $ordered_field_settings = [];
135 if (isset($field_settings[self::GENERAL_TAB])) {
136 $ordered_field_settings[self::GENERAL_TAB] = $field_settings[self::GENERAL_TAB];
137 }
138 if (isset($field_settings[self::STYLE_TAB])) {
139 $ordered_field_settings[self::STYLE_TAB] = $field_settings[self::STYLE_TAB];
140 }
141 if (isset($field_settings[self::SETTINGS_TAB])) {
142 $ordered_field_settings[self::SETTINGS_TAB] = $field_settings[self::SETTINGS_TAB];
143 }
144
145 foreach ($ordered_field_settings as $tab_id => $fields) {
146 printf('<div id="%s" class="pp-form-buider-settings-popup-tab-content">', $tab_id);
147 foreach ($fields as $field_id => $settings) {
148
149 if (in_array($field_id, [self::COLUMN_SETTINGS, self::COLUMN_2_SETTINGS])) { ?>
150 <div class="pp-form-row">
151 <?php foreach ($settings as $key => $settingz) : ?>
152 <div class="pp-form-column">
153 <div class="pp-form-builder-settings-field">
154 <?php
155 $settingz['name'] = $key;
156 if (isset($settingz['field'])) {
157 switch ($settingz['field']) {
158 case self::INPUT_FIELD :
159 (new Input($settingz))->render();
160 break;
161 case self::WPEDITOR_FIELD :
162 (new WPEditor($settingz))->render();
163 break;
164 case self::TEXTAREA_FIELD :
165 (new Textarea($settingz))->render();
166 break;
167 case self::SELECT_FIELD :
168 (new Select($settingz))->render();
169 break;
170 case self::ICON_PICKER_FIELD :
171 (new IconPicker($settingz))->render();
172 break;
173 }
174 } ?>
175 </div>
176 </div>
177 <?php endforeach; ?>
178 </div>
179 <?php } else { ?>
180 <div class="pp-form-row">
181 <div class="pp-form-column">
182 <div class="pp-form-builder-settings-field">
183 <?php $settings['name'] = $field_id;
184 switch ($settings['field']) {
185 case self::INPUT_FIELD :
186 (new Input($settings))->render();
187 break;
188 case self::WPEDITOR_FIELD :
189 (new WPEditor($settings))->render();
190 break;
191 case self::TEXTAREA_FIELD :
192 (new Textarea($settings))->render();
193 break;
194 case self::SELECT_FIELD :
195 (new Select($settings))->render();
196 break;
197 case self::ICON_PICKER_FIELD :
198 (new IconPicker($settings))->render();
199 break;
200 } ?>
201 </div>
202 </div>
203 </div>
204 <?php }
205 }
206 echo '</div>';
207 } ?>
208 </div>
209 <div class="pp-form-buider-settings-popup-footer">
210 <a href="#" class="pp-form-cancel-btn button"><?= esc_html__('Cancel', 'wp-user-avatar') ?></a>
211
212 <div class="pp-actions-right">
213 <a href="#" class="pp-form-save-btn button-primary"><?= esc_html__('Apply Changes', 'wp-user-avatar') ?></a>
214 </div>
215 </div>
216 </div>
217 </script>
218 <?php
219 }
220
221 public function field_bar_tmpl()
222 {
223 static $flag = null;
224
225 if(is_null($flag)) {
226 $flag = true;
227 ?>
228 <script type="text/html" id="tmpl-pp-form-builder-field-bar">
229 <# var fieldBarTitle = typeof data.fieldBarTitle !== 'undefined' && data.fieldBarTitle != '' ? data.fieldBarTitle : data.fieldTitle; #>
230 <div class="pp-builder-element-header">
231 <# if( typeof data.fieldIcon !== 'undefined' ) { #>
232 <span class="pp-builder-element-icon">{{{ data.fieldIcon }}}</span>
233 <# } #>
234 <span class="pp-builder-element-header-title">{{fieldBarTitle}}</span>
235 <span class="pp-form-buider-settings-field-type field-bar-title">{{{ data.fieldTitle }}}</span>
236 <a href="#" class="pp-builder-element-expand-button pp-settings" title="<?php _e('Settings', 'wp-user-avatar'); ?>">
237 <span class="dashicons dashicons-admin-generic"></span>
238 </a>
239 <a href="#" class="pp-builder-element-expand-button pp-delete expand-btn-hide" title="<?php _e('Delete', 'wp-user-avatar'); ?>">
240 <span class="dashicons dashicons-trash"></span>
241 </a>
242 <a href="#" class="pp-builder-element-expand-button pp-clone expand-btn-hide" title="<?php _e('Clone', 'wp-user-avatar'); ?>">
243 <span class="dashicons dashicons-admin-page"></span>
244 </a>
245 </div>
246 </script>
247 <?php
248 }
249 }
250 }