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 / Membership / PlanIntegrationsMetabox.php
wp-user-avatar / src / Admin / SettingsPages / Membership Last commit date
CouponsPage 1 year ago CustomersPage 5 months ago DashboardPage 1 year ago DownloadLogsPage 1 year ago ExportPage 5 months ago GroupsPage 1 year ago OrdersPage 1 year ago PlansPage 2 months ago SubscriptionsPage 3 months ago TaxSettings 3 years ago views 1 month ago CheckListHeader.php 3 years ago CheckoutFieldsManager.php 1 year ago ContextualStateChangeHelper.php 3 years ago FileDownloads.php 3 years ago PaymentMethods.php 1 year ago PaymentSettings.php 1 month ago PlanIntegrationsMetabox.php 10 months ago SettingsFieldsParser.php 1 year ago index.php 3 years ago
PlanIntegrationsMetabox.php
338 lines
1 <?php
2
3 namespace ProfilePress\Core\Admin\SettingsPages\Membership;
4
5
6 class PlanIntegrationsMetabox
7 {
8 protected $args;
9 protected $saved_values;
10 protected $plan_id;
11
12 /**
13 * @param array $args
14 */
15 public function __construct($args, $saved_values)
16 {
17 $this->args = $args;
18 $this->saved_values = $saved_values;
19 }
20
21 private function saved_values_bucket($key)
22 {
23 return isset($this->saved_values[$key]) ? $this->saved_values[$key] : '';
24 }
25
26 public function text($name, $options)
27 {
28 $placeholder = isset($options['placeholder']) ? $options['placeholder'] : '';
29 printf(
30 '<input type="text" class="short" name="%1$s" id="%1$s" value="%3$s" placeholder="%2$s">',
31 esc_attr($name), esc_attr($placeholder), esc_attr($this->saved_values_bucket($name))
32 );
33 }
34
35 public function number($name, $options)
36 {
37 $placeholder = isset($options['placeholder']) ? $options['placeholder'] : '';
38 printf(
39 '<input type="number" class="short" name="%1$s" id="%1$s" value="%3$s" placeholder="%2$s">',
40 esc_attr($name), esc_attr($placeholder), esc_attr($this->saved_values_bucket($name))
41 );
42 }
43
44 public function upload($name, $options)
45 {
46 $placeholder = isset($options['placeholder']) ? $options['placeholder'] : '';
47 echo '<div class="pp_upload_field_container">';
48 printf(
49 '<input type="text" class="pp_upload_field short large-text" name="%1$s" id="%1$s" value="%3$s" placeholder="%2$s">',
50 esc_attr($name), esc_attr($placeholder), esc_attr($this->saved_values_bucket($name))
51 );
52 printf('<span class="pp_upload_file"><a href="#" class="pp_upload_button">%s</a></span>', esc_html__('Upload Image', 'wp-user-avatar'));
53 echo '</div>';
54 }
55
56 private function digital_files_row($name, $file_name = '', $file_url = '')
57 {
58 ?>
59 <tr>
60 <td class="sort"></td>
61 <td class="file_name">
62 <input type="text" class="input_text" placeholder="<?php esc_html_e('File name', 'wp-user-avatar') ?>" name="<?= esc_attr($name) ?>_names[]" value="<?= esc_attr($file_name) ?>">
63 </td>
64 <td class="file_url">
65 <input type="text" class="input_text" placeholder="https://" name="<?= esc_attr($name) ?>_urls[]" value="<?= esc_url($file_url) ?>">
66 </td>
67 <td class="file_url_choose">
68 <a href="#" class="button upload_file_button" data-choose="<?php esc_html_e('Choose file', 'wp-user-avatar') ?>" data-update="<?php esc_html_e('Insert file URL', 'wp-user-avatar') ?>"><?php esc_html_e('Choose file', 'wp-user-avatar') ?></a>
69 </td>
70 <td><a href="#" class="delete">x</a></td>
71 </tr>
72 <?php
73 }
74
75 public function digital_files($name, $options)
76 {
77 $url_field_id = sprintf('%s_urls', $name);
78 $name_field_id = sprintf('%s_names', $name);
79 ?>
80 <table class="widefat downloadable_files">
81 <thead>
82 <tr>
83 <th class="sort">&nbsp;</th>
84 <th><?php esc_html_e('Name', 'wp-user-avatar') ?></th>
85 <th colspan="2"><?php esc_html_e('File URL', 'wp-user-avatar') ?></span></th>
86 <th style="width:20px;">&nbsp;</th>
87 </tr>
88 </thead>
89 <tbody>
90 <?php if (isset($this->saved_values[$url_field_id]) && is_array($this->saved_values[$url_field_id]) && ! empty($this->saved_values[$url_field_id])) : ?>
91 <?php foreach ($this->saved_values[$url_field_id] as $index => $file_url) : ?>
92 <?php $file_name = isset($this->saved_values[$name_field_id]) && is_array($this->saved_values[$name_field_id]) ? $this->saved_values[$name_field_id][$index] : ''; ?>
93 <?php $this->digital_files_row($name, $file_name, $file_url); ?>
94 <?php endforeach; ?>
95 <?php else : ?>
96 <?php $this->digital_files_row($name); ?>
97 <?php endif; ?>
98 </tbody>
99 <tfoot>
100 <tr>
101 <th colspan="2">
102 <a href="#" class="button insert"><?php esc_html_e('Add File', 'wp-user-avatar') ?></a>
103 </th>
104 <th colspan="3">
105 </th>
106 </tr>
107 </tfoot>
108 </table>
109
110 <script type="text/html" id="tmpl-ppress-add-digital-file">
111 <?php $this->digital_files_row($name); ?>
112 </script>
113 <?php
114 }
115
116 public function textarea($name, $options)
117 {
118 $placeholder = $options['placeholder'] ?? '';
119 printf(
120 '<textarea class="short" name="%1$s" id="%1$s" placeholder="%2$s">%3$s</textarea>',
121 esc_attr($name), esc_attr($placeholder), esc_textarea($this->saved_values_bucket($name))
122 );
123 }
124
125 public function checkbox($name, $options)
126 {
127 $checkbox_label = $options['checkbox_label'] ?? '';
128
129 printf('<input type="hidden" style="display: none" name="%1$s" value="false">', esc_attr($name));
130
131 printf(
132 '<input type="checkbox" class="checkbox" name="%1$s" id="%1$s" value="true" %2$s>',
133 esc_attr($name), checked('true', $this->saved_values_bucket($name), false)
134 );
135
136 printf('<span class="description">%s</span>', $checkbox_label);
137 }
138
139 public function select($name, $options)
140 {
141 printf('<select id="%1$s" name="%1$s" class="select short">', esc_attr($name));
142
143 if (
144 isset($options['options']) &&
145 ($options['options'] instanceof \Generator || (is_array($options['options']) && ! empty($options['options'])))
146 ) {
147 foreach ($options['options'] as $id => $val) {
148 if (is_array($val)) {
149 echo "<optgroup label='$id'>";
150 foreach ($val as $id2 => $val2) {
151 printf('<option value="%1$s" %3$s>%2$s</option>', $id2, $val2, selected($id2, $this->saved_values_bucket($name), false));
152 }
153 echo "</optgroup>";
154 } else {
155 printf('<option value="%1$s" %3$s>%2$s</option>', $id, $val, selected($id, $this->saved_values_bucket($name), false));
156 }
157 }
158 }
159
160 echo '</select>';
161 }
162
163 public function custom($name, $options)
164 {
165 echo isset($options['content']) ? wp_kses_post($options['content']) : '';
166 }
167
168 private function select2_selected($id, $name)
169 {
170 $bucket = $this->saved_values_bucket($name);
171
172 return in_array($id, is_array($bucket) ? $bucket : []) ? 'selected="selected"' : '';
173 }
174
175 public function select2($name, $options)
176 {
177 printf('<input name="%1$s[]" type="hidden" value="">', esc_attr($name));
178 printf('<select data-placeholder="%2$s" id="%1$s" name="%1$s[]" class="select ppselect2 short" multiple>', esc_attr($name), esc_html__('Select...', 'wp-user-avatar'));
179
180 if (
181 isset($options['options']) &&
182 ($options['options'] instanceof \Generator || (is_array($options['options']) && ! empty($options['options'])))
183 ) {
184 foreach ($options['options'] as $id => $val) {
185 if (is_array($val)) {
186 echo "<optgroup label='$id'>";
187 foreach ($val as $id2 => $val2) {
188 printf('<option value="%1$s" %3$s>%2$s</option>', $id2, $val2, $this->select2_selected($id2, $name));
189 }
190 echo "</optgroup>";
191 } else {
192 printf('<option value="%1$s" %3$s>%2$s</option>', $id, $val, $this->select2_selected($id, $name));
193 }
194 }
195 }
196
197 echo '</select>';
198 }
199
200 public function build()
201 {
202 $tabs = [];
203 $tab_settings = [];
204 foreach ($this->args as $key => $value) {
205 $tabs[$key] = $value['tab_title'];
206 unset($value['tab_title']);
207 $tab_settings[$key] = wp_list_sort($value, ['priority' => 'ASC']);
208 }
209 ob_start();
210 ?>
211 <style>
212 #pp-form-builder-metabox .ppress-plan-integrations ul.pp-tabs li a::before {
213 font-family: none;
214 content: none;
215 }
216
217 #pp-form-builder-metabox .pp-form-builder_options_panel label {
218 width: 140px;
219 }
220
221 .ppview .postbox#pp-form-builder-metabox input:not([type=checkbox]) {
222 width: 100% !important;
223 max-width: 100% !important;
224 }
225
226 .ppview .postbox#pp-form-builder-metabox .downloadable_files input {
227 width: auto !important;
228 max-width: none !important;
229 }
230
231 .pp-form-builder_options_panel fieldset.form-field, .pp-form-builder_options_panel .form-field {
232 padding-right: 0 !important;
233 }
234
235 .pp-form-builder_options_panel .pp-field-row-content {
236 width: 98% !important;
237 }
238
239 .ppview .postbox#pp-form-builder-metabox .widefat th,
240 .ppview .postbox#pp-form-builder-metabox .widefat td {
241 padding-right: 0;
242 padding-left: 5px;
243 }
244
245 .ppview .postbox#pp-form-builder-metabox .widefat td input {
246 width: 100% !important;
247 }
248
249 .ppview .postbox#pp-form-builder-metabox .widefat th.sort {
250 width: 15px;
251 padding: 5px !important;
252 }
253
254 .ppview .postbox#pp-form-builder-metabox .widefat td.sort {
255 width: 17px;
256 cursor: move;
257 font-size: 15px;
258 text-align: center;
259 background: #f9f9f9;
260 padding-right: 7px !important;
261 }
262
263 .ppview .postbox#pp-form-builder-metabox .widefat td.sort::before {
264 content: "\f333";
265 font-family: Dashicons;
266 text-align: center;
267 line-height: 1;
268 color: #999;
269 display: block;
270 width: 17px;
271 float: left;
272 height: 100%;
273 }
274
275 .ppress-plan-integrations .pp-field-row-content .delete {
276 display: block;
277 text-indent: -9999px;
278 position: relative;
279 height: 1em;
280 width: 1em;
281 font-size: 1.2em;
282 }
283
284 .ppress-plan-integrations .pp-field-row-content .delete::before {
285 font-family: Dashicons;
286 speak: never;
287 font-weight: 400;
288 font-variant: normal;
289 text-transform: none;
290 line-height: 1;
291 -webkit-font-smoothing: antialiased;
292 margin: 0;
293 text-indent: 0;
294 position: absolute;
295 top: 5px;
296 left: 0;
297 width: 100%;
298 height: 100%;
299 text-align: center;
300 content: "\f153";
301 color: #999;
302 }
303
304 </style>
305 <?php echo ppress_minify_css(ob_get_clean()); ?>
306 <div class="panel-wrap pp-form-builder-mb-data">
307 <ul class="pp-form-builder-mb-data_tabs pp-tabs" style="width:22%">
308 <?php foreach ($tabs as $key => $value) : $key = esc_attr($key); ?>
309 <?php if (empty($tab_settings[$key])) continue; ?>
310 <li class="<?= $key ?>_options <?= $key ?>_tab">
311 <a href="#<?= $key ?>_data"><span><?= $value ?></span></a>
312 </li>
313 <?php endforeach; ?>
314 </ul>
315
316 <?php foreach ($tab_settings as $key => $fields) {
317 echo '<div id="' . esc_attr($key) . '_data" class="panel pp-form-builder_options_panel hidden" style="width: 78%">';
318
319 foreach ($fields as $options) {
320 $field_id = $options['id'] ?? '';
321
322 echo sprintf('<div class="form-field %s_wrap">', $field_id);
323 echo "<label for=\"$field_id\">" . wp_kses_post($options['label'] ?? '') . '</label>';
324 echo '<div class="pp-field-row-content">';
325 $this->{$options['type']}($field_id, $options);
326 echo '</div>';
327 if ( ! empty($options['description'])) {
328 printf('<p class="description">%s</p>', wp_kses_post($options['description']));
329 }
330 echo '</div>';
331 }
332 echo '</div>';
333 }
334 ?>
335 </div>
336 <?php
337 }
338 }