PluginProbe
User Submitted Posts – Enable Users to Submit Posts from the Front End / 20260916
User Submitted Posts – Enable Users to Submit Posts from the Front End v20260916
20260916 20260810 20260608 20230806 20230809 20230811 20230901 20230902 20230914 20231102 20240319 20240516 20240703 20241026 20250327 20250329 20251121 20251210 20260110 20260113 20260207 20260217 20260407 20260422 trunk All 59 releases
← All changes | library/form-functions.php +127 -25 2023091420260916 View file →
@@ -1,22 +1,45 @@
1 1 <?php // User Submitted Posts - Form helper functions
2 2
3 3 if (!defined('ABSPATH')) die();
4 4
5 +function usp_display_turnstile() {
6 +
7 + global $usp_options;
8 +
9 + $site_key = isset($usp_options['turnstile_site_key']) ? $usp_options['turnstile_site_key'] : false;
10 + $secret = isset($usp_options['turnstile_secret_key']) ? $usp_options['turnstile_secret_key'] : false;
11 + $display = isset($usp_options['usp_turnstile']) ? $usp_options['usp_turnstile'] : false;
12 +
13 + $output = '';
14 +
15 + if (!empty($site_key) && !empty($secret) && $display) {
16 +
17 + $output = '<div class="cf-turnstile" data-sitekey="'. esc_attr($site_key) .'"></div>';
18 +
19 + }
20 +
21 + return $output;
22 +
23 +}
24 +
5 25 function usp_display_custom_checkbox() {
6 26
7 27 global $usp_options;
8 28
9 - $enable = (isset($usp_options['custom_checkbox']) && !empty($usp_options['custom_checkbox'])) ? true : false;
10 - $required = (isset($usp_options['disable_required']) && !empty($usp_options['disable_required'])) ? false : true;
29 + $enable = (isset($usp_options['custom_checkbox']) && !empty($usp_options['custom_checkbox'])) ? true : false;
11 30
12 - $name = isset($usp_options['custom_checkbox_name']) ? $usp_options['custom_checkbox_name'] : null;
13 - $text = isset($usp_options['custom_checkbox_text']) ? $usp_options['custom_checkbox_text'] : '';
31 + $required = (isset($usp_options['custom_checkbox_req']) && !empty($usp_options['custom_checkbox_req'])) ? true : false;
14 32
33 + $name = isset($usp_options['custom_checkbox_name']) ? $usp_options['custom_checkbox_name'] : null;
34 +
35 + $text = isset($usp_options['custom_checkbox_text']) ? $usp_options['custom_checkbox_text'] : '';
36 +
15 37 $output = '';
16 38
17 39 if ($enable && $name) {
18 40
41 + $text = str_replace('script', '', $text);
19 42 $text = str_replace("{", "<", $text);
20 43 $text = str_replace("}", ">", $text);
21 44
22 45 $required_markup = $required ? ' data-required="true" required' : '';
@@ -22,9 +45,9 @@
22 45 $required_markup = $required ? ' data-required="true" required' : '';
23 46
24 47 $output .= '<fieldset class="usp-checkbox">';
25 48 $output .= '<input id="user-submitted-checkbox" name="'. esc_attr($name) .'" type="checkbox" value=""'. $required_markup .'> ';
26 - $output .= '<label for="user-submitted-checkbox">'. $text .'</label>';
49 + $output .= '<label for="user-submitted-checkbox">'. wp_kses($text, usp_allowed_post_tags()) .'</label>';
27 50 $output .= '</fieldset>';
28 51
29 52 }
30 53
@@ -31,8 +54,80 @@
31 54 return $output;
32 55
33 56 }
34 57
58 +function usp_allowed_post_tags() {
59 +
60 + global $allowedposttags;
61 +
62 + $allowed_atts = array(
63 +
64 + 'align' => array(),
65 + 'class' => array(),
66 + 'type' => array(),
67 + 'id' => array(),
68 + 'dir' => array(),
69 + 'lang' => array(),
70 + 'style' => array(),
71 + 'xml:lang' => array(),
72 + 'src' => array(),
73 + 'alt' => array(),
74 + 'href' => array(),
75 + 'rel' => array(),
76 + 'rev' => array(),
77 + 'target' => array(),
78 + 'novalidate' => array(),
79 + 'type' => array(),
80 + 'value' => array(),
81 + 'name' => array(),
82 + 'tabindex' => array(),
83 + 'action' => array(),
84 + 'method' => array(),
85 + 'for' => array(),
86 + 'width' => array(),
87 + 'height' => array(),
88 + 'data' => array(),
89 + 'title' => array()
90 +
91 + );
92 +
93 + $allowedposttags['form'] = $allowed_atts;
94 + $allowedposttags['label'] = $allowed_atts;
95 + $allowedposttags['input'] = $allowed_atts;
96 + $allowedposttags['textarea'] = $allowed_atts;
97 + $allowedposttags['style'] = $allowed_atts;
98 + $allowedposttags['strong'] = $allowed_atts;
99 + $allowedposttags['small'] = $allowed_atts;
100 + $allowedposttags['table'] = $allowed_atts;
101 + $allowedposttags['span'] = $allowed_atts;
102 + $allowedposttags['abbr'] = $allowed_atts;
103 + $allowedposttags['code'] = $allowed_atts;
104 + $allowedposttags['pre'] = $allowed_atts;
105 + $allowedposttags['div'] = $allowed_atts;
106 + $allowedposttags['img'] = $allowed_atts;
107 + $allowedposttags['h1'] = $allowed_atts;
108 + $allowedposttags['h2'] = $allowed_atts;
109 + $allowedposttags['h3'] = $allowed_atts;
110 + $allowedposttags['h4'] = $allowed_atts;
111 + $allowedposttags['h5'] = $allowed_atts;
112 + $allowedposttags['h6'] = $allowed_atts;
113 + $allowedposttags['ol'] = $allowed_atts;
114 + $allowedposttags['ul'] = $allowed_atts;
115 + $allowedposttags['li'] = $allowed_atts;
116 + $allowedposttags['em'] = $allowed_atts;
117 + $allowedposttags['hr'] = $allowed_atts;
118 + $allowedposttags['br'] = $allowed_atts;
119 + $allowedposttags['tr'] = $allowed_atts;
120 + $allowedposttags['td'] = $allowed_atts;
121 + $allowedposttags['p'] = $allowed_atts;
122 + $allowedposttags['a'] = $allowed_atts;
123 + $allowedposttags['b'] = $allowed_atts;
124 + $allowedposttags['i'] = $allowed_atts;
125 +
126 + return apply_filters('usp_allowed_post_tags', $allowedposttags);
127 +
128 +}
129 +
35 130 function usp_get_form_vars() {
36 131
37 132 global $usp_options;
38 133
@@ -78,8 +173,12 @@
78 173 $usp_recaptcha_display = isset($usp_options['usp_recaptcha']) ? $usp_options['usp_recaptcha'] : '';
79 174
80 175 $usp_data_sitekey = isset($usp_options['recaptcha_public']) ? $usp_options['recaptcha_public'] : '';
81 176
177 + $usp_turnstile_site_key = isset($usp_options['turnstile_site_key']) ? $usp_options['turnstile_site_key'] : '';
178 + $usp_turnstile_secret_key = isset($usp_options['turnstile_secret_key']) ? $usp_options['turnstile_secret_key'] : '';
179 + $usp_turnstile_display = isset($usp_options['usp_turnstile']) ? $usp_options['usp_turnstile'] : '';
180 +
82 181 $usp_custom_name = isset($usp_options['custom_name']) ? $usp_options['custom_name'] : '';
83 182 $usp_custom_label = isset($usp_options['custom_label']) ? $usp_options['custom_label'] : '';
84 183
85 184 $usp_custom_name_2 = isset($usp_options['custom_name_2']) ? $usp_options['custom_name_2'] : '';
@@ -85,28 +184,31 @@
85 184 $usp_custom_name_2 = isset($usp_options['custom_name_2']) ? $usp_options['custom_name_2'] : '';
86 185 $usp_custom_label_2 = isset($usp_options['custom_label_2']) ? $usp_options['custom_label_2'] : '';
87 186
88 187 $options = array(
89 - 'usp_user_name' => $usp_user_name,
90 - 'usp_user_email' => $usp_user_email,
91 - 'usp_user_url' => $usp_user_url,
92 - 'usp_required' => $usp_required,
93 - 'usp_captcha' => $usp_captcha,
94 - 'multiple_cats' => $multiple_cats,
95 - 'category_class' => $category_class,
96 - 'usp_display_name' => $usp_display_name,
97 - 'usp_display_email' => $usp_display_email,
98 - 'usp_display_url' => $usp_display_url,
99 - 'usp_existing_tags' => $usp_existing_tags,
100 - 'usp_recaptcha_public' => $usp_recaptcha_public,
101 - 'usp_recaptcha_private' => $usp_recaptcha_private,
102 - 'usp_recaptcha_version' => $usp_recaptcha_version,
103 - 'usp_recaptcha_display' => $usp_recaptcha_display,
104 - 'usp_data_sitekey' => $usp_data_sitekey,
105 - 'usp_custom_name' => $usp_custom_name,
106 - 'usp_custom_label' => $usp_custom_label,
107 - 'usp_custom_name_2' => $usp_custom_name_2,
108 - 'usp_custom_label_2' => $usp_custom_label_2,
188 + 'usp_user_name' => $usp_user_name,
189 + 'usp_user_email' => $usp_user_email,
190 + 'usp_user_url' => $usp_user_url,
191 + 'usp_required' => $usp_required,
192 + 'usp_captcha' => $usp_captcha,
193 + 'multiple_cats' => $multiple_cats,
194 + 'category_class' => $category_class,
195 + 'usp_display_name' => $usp_display_name,
196 + 'usp_display_email' => $usp_display_email,
197 + 'usp_display_url' => $usp_display_url,
198 + 'usp_existing_tags' => $usp_existing_tags,
199 + 'usp_recaptcha_public' => $usp_recaptcha_public,
200 + 'usp_recaptcha_private' => $usp_recaptcha_private,
201 + 'usp_recaptcha_version' => $usp_recaptcha_version,
202 + 'usp_recaptcha_display' => $usp_recaptcha_display,
203 + 'usp_turnstile_site_key' => $usp_turnstile_site_key,
204 + 'usp_turnstile_secret_key' => $usp_turnstile_secret_key,
205 + 'usp_turnstile_display' => $usp_turnstile_display,
206 + 'usp_data_sitekey' => $usp_data_sitekey,
207 + 'usp_custom_name' => $usp_custom_name,
208 + 'usp_custom_label' => $usp_custom_label,
209 + 'usp_custom_name_2' => $usp_custom_name_2,
210 + 'usp_custom_label_2' => $usp_custom_label_2,
109 211 );
110 212
111 213 return $options;
112 214