|
1
|
|
|
<?php |
|
2
|
|
|
if ( ! defined( 'ABSPATH' ) ) { |
|
3
|
|
|
die( 'You are not allowed to call this page directly.' ); |
|
4
|
|
|
} |
|
5
|
|
|
|
|
6
|
|
|
class FrmFormsController { |
|
7
|
|
|
|
|
8
|
|
|
public static function menu() { |
|
9
|
|
|
$menu_label = __( 'Forms', 'formidable' ); |
|
10
|
|
|
if ( ! FrmAppHelper::pro_is_installed() ) { |
|
11
|
|
|
$menu_label .= ' (Lite)'; |
|
12
|
|
|
} |
|
13
|
|
|
add_submenu_page( 'formidable', 'Formidable | ' . $menu_label, $menu_label, 'frm_view_forms', 'formidable', 'FrmFormsController::route' ); |
|
14
|
|
|
|
|
15
|
|
|
self::maybe_load_listing_hooks(); |
|
16
|
|
|
} |
|
17
|
|
|
|
|
18
|
|
|
public static function maybe_load_listing_hooks() { |
|
19
|
|
|
$action = FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' ); |
|
20
|
|
|
if ( ! empty( $action ) && ! in_array( $action, array( 'list', 'trash', 'untrash', 'destroy' ) ) ) { |
|
21
|
|
|
return; |
|
22
|
|
|
} |
|
23
|
|
|
|
|
24
|
|
|
add_filter( 'get_user_option_managetoplevel_page_formidablecolumnshidden', 'FrmFormsController::hidden_columns' ); |
|
25
|
|
|
|
|
26
|
|
|
add_filter( 'manage_toplevel_page_formidable_columns', 'FrmFormsController::get_columns', 0 ); |
|
27
|
|
|
add_filter( 'manage_toplevel_page_formidable_sortable_columns', 'FrmFormsController::get_sortable_columns' ); |
|
28
|
|
|
} |
|
29
|
|
|
|
|
30
|
|
|
public static function head() { |
|
31
|
|
|
if ( wp_is_mobile() ) { |
|
32
|
|
|
wp_enqueue_script( 'jquery-touch-punch' ); |
|
33
|
|
|
} |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
public static function register_widgets() { |
|
37
|
|
|
require_once( FrmAppHelper::plugin_path() . '/classes/widgets/FrmShowForm.php' ); |
|
38
|
|
|
register_widget( 'FrmShowForm' ); |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* Show a message about conditional logic |
|
43
|
|
|
* |
|
44
|
|
|
* @since 4.06.03 |
|
45
|
|
|
*/ |
|
46
|
|
|
public static function logic_tip() { |
|
47
|
|
|
echo '<a href="javascript:void(0)" class="frm_noallow frm_show_upgrade frm_add_logic_link" data-upgrade="' . esc_attr__( 'Conditional Logic options', 'formidable' ) . '" data-message="' . esc_attr__( 'Only show the fields you need and create branching forms. Upgrade to get conditional logic and question branching.', 'formidable' ) . esc_attr( ' <img src="https://cdn.formidableforms.com/wp-content/themes/fp2015git/images/survey/survey-logic.png" srcset="https://cdn.formidableforms.com/wp-content/themes/fp2015git/images/survey/[email protected] 2x" alt="Conditional Logic options"/>' ) . '" data-medium="builder" data-content="logic">'; |
|
48
|
|
|
FrmAppHelper::icon_by_class( 'frmfont frm_swap_icon' ); |
|
49
|
|
|
esc_html_e( 'Add Conditional Logic', 'formidable' ); |
|
50
|
|
|
echo '</a>'; |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
/** |
|
54
|
|
|
* By default, Divi processes form shortcodes on the edit post page. |
|
55
|
|
|
* Now that won't do. |
|
56
|
|
|
* |
|
57
|
|
|
* @since 3.01 |
|
58
|
|
|
*/ |
|
59
|
|
|
public static function prevent_divi_conflict( $shortcodes ) { |
|
60
|
|
|
$shortcodes[] = 'formidable'; |
|
61
|
|
|
|
|
62
|
|
|
return $shortcodes; |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
public static function list_form() { |
|
66
|
|
|
FrmAppHelper::permission_check( 'frm_view_forms' ); |
|
67
|
|
|
|
|
68
|
|
|
$message = ''; |
|
69
|
|
|
$params = FrmForm::list_page_params(); |
|
70
|
|
|
$errors = self::process_bulk_form_actions( array() ); |
|
71
|
|
|
if ( isset( $errors['message'] ) ) { |
|
72
|
|
|
$message = $errors['message']; |
|
73
|
|
|
unset( $errors['message'] ); |
|
74
|
|
|
} |
|
75
|
|
|
$errors = apply_filters( 'frm_admin_list_form_action', $errors ); |
|
76
|
|
|
|
|
77
|
|
|
return self::display_forms_list( $params, $message, $errors ); |
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
|
|
/** |
|
81
|
|
|
* Load the scripts before a modal can be triggered. |
|
82
|
|
|
* |
|
83
|
|
|
* @since 4.0 |
|
84
|
|
|
*/ |
|
85
|
|
|
private static function init_modal() { |
|
86
|
|
|
wp_enqueue_script( 'jquery-ui-dialog' ); |
|
87
|
|
|
wp_enqueue_style( 'jquery-ui-dialog' ); |
|
88
|
|
|
} |
|
89
|
|
|
|
|
90
|
|
|
/** |
|
91
|
|
|
* Create the default email action |
|
92
|
|
|
* |
|
93
|
|
|
* @since 2.02.11 |
|
94
|
|
|
* |
|
95
|
|
|
* @param object $form |
|
96
|
|
|
*/ |
|
97
|
|
|
private static function create_default_email_action( $form ) { |
|
98
|
|
|
FrmForm::maybe_get_form( $form ); |
|
99
|
|
|
$create_email = apply_filters( 'frm_create_default_email_action', true, $form ); |
|
100
|
|
|
|
|
101
|
|
|
if ( $create_email ) { |
|
102
|
|
|
$action_control = FrmFormActionsController::get_form_actions( 'email' ); |
|
103
|
|
|
$action_control->create( $form->id ); |
|
104
|
|
|
} |
|
105
|
|
|
} |
|
106
|
|
|
|
|
107
|
|
|
public static function edit( $values = false ) { |
|
108
|
|
|
FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
109
|
|
|
|
|
110
|
|
|
$id = isset( $values['id'] ) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' ); |
|
111
|
|
|
|
|
112
|
|
|
return self::get_edit_vars( $id ); |
|
113
|
|
|
} |
|
114
|
|
|
|
|
115
|
|
|
public static function settings( $id = false, $message = '' ) { |
|
116
|
|
|
FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
117
|
|
|
|
|
118
|
|
|
if ( ! $id || ! is_numeric( $id ) ) { |
|
119
|
|
|
$id = FrmAppHelper::get_param( 'id', '', 'get', 'absint' ); |
|
120
|
|
|
} |
|
121
|
|
|
|
|
122
|
|
|
return self::get_settings_vars( $id, array(), $message ); |
|
123
|
|
|
} |
|
124
|
|
|
|
|
125
|
|
|
public static function update_settings() { |
|
126
|
|
|
FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
127
|
|
|
|
|
128
|
|
|
$id = FrmAppHelper::get_param( 'id', '', 'get', 'absint' ); |
|
129
|
|
|
|
|
130
|
|
|
$errors = FrmForm::validate( $_POST ); |
|
131
|
|
|
$warnings = FrmFormsHelper::check_for_warnings( $_POST ); |
|
132
|
|
|
|
|
133
|
|
|
if ( count( $errors ) > 0 ) { |
|
134
|
|
|
return self::get_settings_vars( $id, $errors, compact( 'warnings' ) ); |
|
135
|
|
|
} |
|
136
|
|
|
|
|
137
|
|
|
do_action( 'frm_before_update_form_settings', $id ); |
|
138
|
|
|
|
|
139
|
|
|
FrmForm::update( $id, $_POST ); |
|
140
|
|
|
|
|
141
|
|
|
$message = __( 'Settings Successfully Updated', 'formidable' ); |
|
142
|
|
|
|
|
143
|
|
|
return self::get_settings_vars( $id, array(), compact( 'message', 'warnings' ) ); |
|
144
|
|
|
} |
|
145
|
|
|
|
|
146
|
|
|
public static function update( $values = array() ) { |
|
147
|
|
|
if ( empty( $values ) ) { |
|
148
|
|
|
$values = $_POST; |
|
149
|
|
|
} |
|
150
|
|
|
|
|
151
|
|
|
// Set radio button and checkbox meta equal to "other" value. |
|
152
|
|
|
if ( FrmAppHelper::pro_is_installed() ) { |
|
153
|
|
|
$values = FrmProEntry::mod_other_vals( $values, 'back' ); |
|
154
|
|
|
} |
|
155
|
|
|
|
|
156
|
|
|
$errors = FrmForm::validate( $values ); |
|
157
|
|
|
$permission_error = FrmAppHelper::permission_nonce_error( 'frm_edit_forms', 'frm_save_form', 'frm_save_form_nonce' ); |
|
158
|
|
|
if ( $permission_error !== false ) { |
|
159
|
|
|
$errors['form'] = $permission_error; |
|
160
|
|
|
} |
|
161
|
|
|
|
|
162
|
|
|
$id = isset( $values['id'] ) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' ); |
|
163
|
|
|
|
|
164
|
|
|
if ( count( $errors ) > 0 ) { |
|
165
|
|
|
return self::get_edit_vars( $id, $errors ); |
|
166
|
|
|
} else { |
|
167
|
|
|
FrmForm::update( $id, $values ); |
|
168
|
|
|
$message = __( 'Form was successfully updated.', 'formidable' ); |
|
169
|
|
|
|
|
170
|
|
|
if ( self::is_too_long( $values ) ) { |
|
171
|
|
|
$message .= '<br/> ' . sprintf( |
|
172
|
|
|
/* translators: %1$s: Start link HTML, %2$s: end link HTML */ |
|
173
|
|
|
__( 'However, your form is very long and may be %1$sreaching server limits%2$s.', 'formidable' ), |
|
174
|
|
|
'<a href="https://formidableforms.com/knowledgebase/i-have-a-long-form-why-did-the-options-at-the-end-of-the-form-stop-saving/?utm_source=WordPress&utm_medium=builder&utm_campaign=liteplugin" target="_blank" rel="noopener">', |
|
175
|
|
|
'</a>' |
|
176
|
|
|
); |
|
177
|
|
|
} |
|
178
|
|
|
|
|
179
|
|
|
if ( defined( 'DOING_AJAX' ) ) { |
|
180
|
|
|
wp_die( FrmAppHelper::kses( $message, array( 'a' ) ) ); // WPCS: XSS ok. |
|
181
|
|
|
} |
|
182
|
|
|
|
|
183
|
|
|
return self::get_edit_vars( $id, array(), $message ); |
|
184
|
|
|
} |
|
185
|
|
|
} |
|
186
|
|
|
|
|
187
|
|
|
/** |
|
188
|
|
|
* Check if the value at the end of the form was included. |
|
189
|
|
|
* If it's missing, it means other values at the end of the form |
|
190
|
|
|
* were likely not saved either. |
|
191
|
|
|
* |
|
192
|
|
|
* @since 3.06.01 |
|
193
|
|
|
*/ |
|
194
|
|
|
private static function is_too_long( $values ) { |
|
195
|
|
|
return ( ! isset( $values['frm_end'] ) ) || empty( $values['frm_end'] ); |
|
196
|
|
|
} |
|
197
|
|
|
|
|
198
|
|
|
/** |
|
199
|
|
|
* Redirect to the url for creating from a template |
|
200
|
|
|
* Also delete the current form |
|
201
|
|
|
* |
|
202
|
|
|
* @since 2.0 |
|
203
|
|
|
* @deprecated 3.06 |
|
204
|
|
|
*/ |
|
205
|
|
|
public static function _create_from_template() { |
|
206
|
|
|
_deprecated_function( __FUNCTION__, '3.06' ); |
|
207
|
|
|
|
|
208
|
|
|
FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
209
|
|
|
check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
210
|
|
|
|
|
211
|
|
|
$current_form = FrmAppHelper::get_param( 'this_form', '', 'get', 'absint' ); |
|
212
|
|
|
$template_id = FrmAppHelper::get_param( 'id', '', 'get', 'absint' ); |
|
213
|
|
|
|
|
214
|
|
|
if ( $current_form ) { |
|
215
|
|
|
FrmForm::destroy( $current_form ); |
|
216
|
|
|
} |
|
217
|
|
|
|
|
218
|
|
|
echo esc_url_raw( admin_url( 'admin.php?page=formidable&frm_action=duplicate&id=' . absint( $template_id ) ) ); |
|
219
|
|
|
wp_die(); |
|
220
|
|
|
} |
|
221
|
|
|
|
|
222
|
|
|
public static function duplicate() { |
|
223
|
|
|
FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
224
|
|
|
|
|
225
|
|
|
$params = FrmForm::list_page_params(); |
|
226
|
|
|
$form = FrmForm::duplicate( $params['id'], $params['template'], true ); |
|
227
|
|
|
$message = $params['template'] ? __( 'Form template was Successfully Created', 'formidable' ) : __( 'Form was Successfully Copied', 'formidable' ); |
|
228
|
|
|
if ( $form ) { |
|
229
|
|
|
return self::get_edit_vars( $form, array(), $message, true ); |
|
230
|
|
|
} else { |
|
231
|
|
|
return self::display_forms_list( $params, __( 'There was a problem creating the new template.', 'formidable' ) ); |
|
232
|
|
|
} |
|
233
|
|
|
} |
|
234
|
|
|
|
|
235
|
|
|
public static function page_preview() { |
|
236
|
|
|
$params = FrmForm::list_page_params(); |
|
237
|
|
|
if ( ! $params['form'] ) { |
|
238
|
|
|
return; |
|
239
|
|
|
} |
|
240
|
|
|
|
|
241
|
|
|
$form = FrmForm::getOne( $params['form'] ); |
|
242
|
|
|
if ( $form ) { |
|
243
|
|
|
return self::show_form( $form->id, '', true, true ); |
|
244
|
|
|
} |
|
245
|
|
|
} |
|
246
|
|
|
|
|
247
|
|
|
/** |
|
248
|
|
|
* @since 3.0 |
|
249
|
|
|
*/ |
|
250
|
|
|
public static function show_page_preview() { |
|
251
|
|
|
echo self::page_preview(); // WPCS: XSS ok. |
|
252
|
|
|
} |
|
253
|
|
|
|
|
254
|
|
|
public static function preview() { |
|
255
|
|
|
do_action( 'frm_wp' ); |
|
256
|
|
|
|
|
257
|
|
|
global $frm_vars; |
|
258
|
|
|
$frm_vars['preview'] = true; |
|
259
|
|
|
|
|
260
|
|
|
self::load_wp(); |
|
261
|
|
|
|
|
262
|
|
|
$include_theme = FrmAppHelper::get_param( 'theme', '', 'get', 'absint' ); |
|
263
|
|
|
if ( $include_theme ) { |
|
264
|
|
|
self::set_preview_query(); |
|
265
|
|
|
self::load_theme_preview(); |
|
266
|
|
|
} else { |
|
267
|
|
|
self::load_direct_preview(); |
|
268
|
|
|
} |
|
269
|
|
|
|
|
270
|
|
|
wp_die(); |
|
271
|
|
|
} |
|
272
|
|
|
|
|
273
|
|
|
/** |
|
274
|
|
|
* @since 3.0 |
|
275
|
|
|
*/ |
|
276
|
|
|
private static function load_wp() { |
|
277
|
|
|
if ( ! defined( 'ABSPATH' ) && ! defined( 'XMLRPC_REQUEST' ) ) { |
|
278
|
|
|
global $wp; |
|
279
|
|
|
$root = dirname( dirname( dirname( dirname( __FILE__ ) ) ) ); |
|
280
|
|
|
include_once( $root . '/wp-config.php' ); |
|
281
|
|
|
$wp->init(); |
|
282
|
|
|
$wp->register_globals(); |
|
283
|
|
|
} |
|
284
|
|
|
} |
|
285
|
|
|
|
|
286
|
|
|
private static function set_preview_query() { |
|
287
|
|
|
$random_page = get_posts( |
|
288
|
|
|
array( |
|
289
|
|
|
'numberposts' => 1, |
|
290
|
|
|
'orderby' => 'date', |
|
291
|
|
|
'order' => 'ASC', |
|
292
|
|
|
'post_type' => 'page', |
|
293
|
|
|
) |
|
294
|
|
|
); |
|
295
|
|
|
|
|
296
|
|
|
if ( ! empty( $random_page ) ) { |
|
297
|
|
|
$random_page = reset( $random_page ); |
|
298
|
|
|
query_posts( |
|
299
|
|
|
array( |
|
300
|
|
|
'post_type' => 'page', |
|
301
|
|
|
'page_id' => $random_page->ID, |
|
302
|
|
|
) |
|
303
|
|
|
); |
|
304
|
|
|
} |
|
305
|
|
|
} |
|
306
|
|
|
|
|
307
|
|
|
/** |
|
308
|
|
|
* @since 3.0 |
|
309
|
|
|
*/ |
|
310
|
|
|
private static function load_theme_preview() { |
|
311
|
|
|
add_filter( 'wp_title', 'FrmFormsController::preview_title', 9999 ); |
|
312
|
|
|
add_filter( 'the_title', 'FrmFormsController::preview_page_title', 9999 ); |
|
313
|
|
|
add_filter( 'the_content', 'FrmFormsController::preview_content', 9999 ); |
|
314
|
|
|
add_action( 'loop_no_results', 'FrmFormsController::show_page_preview' ); |
|
315
|
|
|
add_filter( 'is_active_sidebar', '__return_false' ); |
|
316
|
|
|
FrmStylesController::enqueue_css( 'enqueue', true ); |
|
317
|
|
|
get_template_part( 'page' ); |
|
318
|
|
|
} |
|
319
|
|
|
|
|
320
|
|
|
/** |
|
321
|
|
|
* Set the page title for the theme preview page |
|
322
|
|
|
* |
|
323
|
|
|
* @since 3.0 |
|
324
|
|
|
*/ |
|
325
|
|
|
public static function preview_page_title( $title ) { |
|
326
|
|
|
if ( in_the_loop() ) { |
|
327
|
|
|
$title = self::preview_title( $title ); |
|
328
|
|
|
} |
|
329
|
|
|
|
|
330
|
|
|
return $title; |
|
331
|
|
|
} |
|
332
|
|
|
|
|
333
|
|
|
/** |
|
334
|
|
|
* Set the page title for the theme preview page |
|
335
|
|
|
* |
|
336
|
|
|
* @since 3.0 |
|
337
|
|
|
*/ |
|
338
|
|
|
public static function preview_title( $title ) { |
|
339
|
|
|
return __( 'Form Preview', 'formidable' ); |
|
340
|
|
|
} |
|
341
|
|
|
|
|
342
|
|
|
/** |
|
343
|
|
|
* Set the page content for the theme preview page |
|
344
|
|
|
* |
|
345
|
|
|
* @since 3.0 |
|
346
|
|
|
*/ |
|
347
|
|
|
public static function preview_content( $content ) { |
|
348
|
|
|
if ( in_the_loop() ) { |
|
349
|
|
|
$content = self::show_page_preview(); |
|
|
|
|
|
|
350
|
|
|
} |
|
351
|
|
|
|
|
352
|
|
|
return $content; |
|
353
|
|
|
} |
|
354
|
|
|
|
|
355
|
|
|
/** |
|
356
|
|
|
* @since 3.0 |
|
357
|
|
|
*/ |
|
358
|
|
|
private static function load_direct_preview() { |
|
359
|
|
|
header( 'Content-Type: text/html; charset=' . get_option( 'blog_charset' ) ); |
|
360
|
|
|
|
|
361
|
|
|
$key = FrmAppHelper::simple_get( 'form', 'sanitize_title' ); |
|
362
|
|
|
if ( $key == '' ) { |
|
363
|
|
|
$key = FrmAppHelper::get_post_param( 'form', '', 'sanitize_title' ); |
|
364
|
|
|
} |
|
365
|
|
|
|
|
366
|
|
|
$form = FrmForm::getAll( array( 'form_key' => $key ), '', 1 ); |
|
367
|
|
|
if ( empty( $form ) ) { |
|
368
|
|
|
$form = FrmForm::getAll( array(), '', 1 ); |
|
369
|
|
|
} |
|
370
|
|
|
|
|
371
|
|
|
require( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/direct.php' ); |
|
372
|
|
|
} |
|
373
|
|
|
|
|
374
|
|
|
public static function untrash() { |
|
375
|
|
|
self::change_form_status( 'untrash' ); |
|
376
|
|
|
} |
|
377
|
|
|
|
|
378
|
|
|
public static function bulk_untrash( $ids ) { |
|
379
|
|
|
FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
380
|
|
|
|
|
381
|
|
|
$count = FrmForm::set_status( $ids, 'published' ); |
|
382
|
|
|
|
|
383
|
|
|
/* translators: %1$s: Number of forms */ |
|
384
|
|
|
$message = sprintf( _n( '%1$s form restored from the Trash.', '%1$s forms restored from the Trash.', $count, 'formidable' ), 1 ); |
|
385
|
|
|
|
|
386
|
|
|
return $message; |
|
387
|
|
|
} |
|
388
|
|
|
|
|
389
|
|
|
/** |
|
390
|
|
|
* @since 3.06 |
|
391
|
|
|
*/ |
|
392
|
|
|
public static function ajax_trash() { |
|
393
|
|
|
FrmAppHelper::permission_check( 'frm_delete_forms' ); |
|
394
|
|
|
check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
395
|
|
|
$form_id = FrmAppHelper::get_param( 'id', '', 'post', 'absint' ); |
|
396
|
|
|
FrmForm::set_status( $form_id, 'trash' ); |
|
397
|
|
|
wp_die(); |
|
398
|
|
|
} |
|
399
|
|
|
|
|
400
|
|
|
public static function trash() { |
|
401
|
|
|
self::change_form_status( 'trash' ); |
|
402
|
|
|
} |
|
403
|
|
|
|
|
404
|
|
|
/** |
|
405
|
|
|
* @param string $status |
|
406
|
|
|
* |
|
407
|
|
|
* @return int The number of forms changed |
|
408
|
|
|
*/ |
|
409
|
|
|
public static function change_form_status( $status ) { |
|
410
|
|
|
$available_status = array( |
|
411
|
|
|
'untrash' => array( |
|
412
|
|
|
'permission' => 'frm_edit_forms', |
|
413
|
|
|
'new_status' => 'published', |
|
414
|
|
|
), |
|
415
|
|
|
'trash' => array( |
|
416
|
|
|
'permission' => 'frm_delete_forms', |
|
417
|
|
|
'new_status' => 'trash', |
|
418
|
|
|
), |
|
419
|
|
|
); |
|
420
|
|
|
|
|
421
|
|
|
if ( ! isset( $available_status[ $status ] ) ) { |
|
422
|
|
|
return; |
|
423
|
|
|
} |
|
424
|
|
|
|
|
425
|
|
|
FrmAppHelper::permission_check( $available_status[ $status ]['permission'] ); |
|
426
|
|
|
|
|
427
|
|
|
$params = FrmForm::list_page_params(); |
|
428
|
|
|
|
|
429
|
|
|
//check nonce url |
|
430
|
|
|
check_admin_referer( $status . '_form_' . $params['id'] ); |
|
431
|
|
|
|
|
432
|
|
|
$count = 0; |
|
433
|
|
|
if ( FrmForm::set_status( $params['id'], $available_status[ $status ]['new_status'] ) ) { |
|
434
|
|
|
$count ++; |
|
435
|
|
|
} |
|
436
|
|
|
|
|
437
|
|
|
$form_type = FrmAppHelper::get_simple_request( |
|
438
|
|
|
array( |
|
439
|
|
|
'param' => 'form_type', |
|
440
|
|
|
'type' => 'request', |
|
441
|
|
|
) |
|
442
|
|
|
); |
|
443
|
|
|
|
|
444
|
|
|
/* translators: %1$s: Number of forms */ |
|
445
|
|
|
$available_status['untrash']['message'] = sprintf( _n( '%1$s form restored from the Trash.', '%1$s forms restored from the Trash.', $count, 'formidable' ), $count ); |
|
446
|
|
|
|
|
447
|
|
|
/* translators: %1$s: Number of forms, %2$s: Start link HTML, %3$s: End link HTML */ |
|
448
|
|
|
$available_status['trash']['message'] = sprintf( _n( '%1$s form moved to the Trash. %2$sUndo%3$s', '%1$s forms moved to the Trash. %2$sUndo%3$s', $count, 'formidable' ), $count, '<a href="' . esc_url( wp_nonce_url( '?page=formidable&frm_action=untrash&form_type=' . $form_type . '&id=' . $params['id'], 'untrash_form_' . $params['id'] ) ) . '">', '</a>' ); |
|
449
|
|
|
|
|
450
|
|
|
$message = $available_status[ $status ]['message']; |
|
451
|
|
|
|
|
452
|
|
|
self::display_forms_list( $params, $message ); |
|
453
|
|
|
} |
|
454
|
|
|
|
|
455
|
|
|
public static function bulk_trash( $ids ) { |
|
456
|
|
|
FrmAppHelper::permission_check( 'frm_delete_forms' ); |
|
457
|
|
|
|
|
458
|
|
|
$count = 0; |
|
459
|
|
|
foreach ( $ids as $id ) { |
|
460
|
|
|
if ( FrmForm::trash( $id ) ) { |
|
461
|
|
|
$count ++; |
|
462
|
|
|
} |
|
463
|
|
|
} |
|
464
|
|
|
|
|
465
|
|
|
$current_page = FrmAppHelper::get_simple_request( |
|
466
|
|
|
array( |
|
467
|
|
|
'param' => 'form_type', |
|
468
|
|
|
'type' => 'request', |
|
469
|
|
|
) |
|
470
|
|
|
); |
|
471
|
|
|
$message = sprintf( |
|
472
|
|
|
/* translators: %1$s: Number of forms, %2$s: Start link HTML, %3$s: End link HTML */ |
|
473
|
|
|
_n( '%1$s form moved to the Trash. %2$sUndo%3$s', '%1$s forms moved to the Trash. %2$sUndo%3$s', $count, 'formidable' ), |
|
474
|
|
|
$count, |
|
475
|
|
|
'<a href="' . esc_url( wp_nonce_url( '?page=formidable&frm_action=list&action=bulk_untrash&form_type=' . $current_page . '&item-action=' . implode( ',', $ids ), 'bulk-toplevel_page_formidable' ) ) . '">', |
|
476
|
|
|
'</a>' |
|
477
|
|
|
); |
|
478
|
|
|
|
|
479
|
|
|
return $message; |
|
480
|
|
|
} |
|
481
|
|
|
|
|
482
|
|
|
public static function destroy() { |
|
483
|
|
|
FrmAppHelper::permission_check( 'frm_delete_forms' ); |
|
484
|
|
|
|
|
485
|
|
|
$params = FrmForm::list_page_params(); |
|
486
|
|
|
|
|
487
|
|
|
// Check nonce url. |
|
488
|
|
|
check_admin_referer( 'destroy_form_' . $params['id'] ); |
|
489
|
|
|
|
|
490
|
|
|
$count = 0; |
|
491
|
|
|
if ( FrmForm::destroy( $params['id'] ) ) { |
|
492
|
|
|
$count ++; |
|
493
|
|
|
} |
|
494
|
|
|
|
|
495
|
|
|
/* translators: %1$s: Number of forms */ |
|
496
|
|
|
$message = sprintf( _n( '%1$s Form Permanently Deleted', '%1$s Forms Permanently Deleted', $count, 'formidable' ), $count ); |
|
497
|
|
|
|
|
498
|
|
|
self::display_forms_list( $params, $message ); |
|
499
|
|
|
} |
|
500
|
|
|
|
|
501
|
|
|
public static function bulk_destroy( $ids ) { |
|
502
|
|
|
FrmAppHelper::permission_check( 'frm_delete_forms' ); |
|
503
|
|
|
|
|
504
|
|
|
$count = 0; |
|
505
|
|
|
foreach ( $ids as $id ) { |
|
506
|
|
|
$d = FrmForm::destroy( $id ); |
|
507
|
|
|
if ( $d ) { |
|
508
|
|
|
$count ++; |
|
509
|
|
|
} |
|
510
|
|
|
} |
|
511
|
|
|
|
|
512
|
|
|
/* translators: %1$s: Number of forms */ |
|
513
|
|
|
$message = sprintf( _n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count ); |
|
514
|
|
|
|
|
515
|
|
|
return $message; |
|
516
|
|
|
} |
|
517
|
|
|
|
|
518
|
|
|
private static function delete_all() { |
|
519
|
|
|
// Check nonce url. |
|
520
|
|
|
$permission_error = FrmAppHelper::permission_nonce_error( 'frm_delete_forms', '_wpnonce', 'bulk-toplevel_page_formidable' ); |
|
521
|
|
|
if ( $permission_error !== false ) { |
|
522
|
|
|
self::display_forms_list( array(), '', array( $permission_error ) ); |
|
523
|
|
|
|
|
524
|
|
|
return; |
|
525
|
|
|
} |
|
526
|
|
|
|
|
527
|
|
|
$count = FrmForm::scheduled_delete( time() ); |
|
528
|
|
|
|
|
529
|
|
|
/* translators: %1$s: Number of forms */ |
|
530
|
|
|
$message = sprintf( _n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count ); |
|
531
|
|
|
|
|
532
|
|
|
self::display_forms_list( array(), $message ); |
|
533
|
|
|
} |
|
534
|
|
|
|
|
535
|
|
|
/** |
|
536
|
|
|
* Create a new form from the modal. |
|
537
|
|
|
* |
|
538
|
|
|
* @since 4.0 |
|
539
|
|
|
*/ |
|
540
|
|
|
public static function build_new_form() { |
|
541
|
|
|
global $wpdb; |
|
542
|
|
|
|
|
543
|
|
|
FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
544
|
|
|
check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
545
|
|
|
|
|
546
|
|
|
$new_values = self::get_modal_values(); |
|
547
|
|
|
$new_values['form_key'] = $new_values['name']; |
|
548
|
|
|
|
|
549
|
|
|
$form_id = FrmForm::create( $new_values ); |
|
550
|
|
|
|
|
551
|
|
|
self::create_default_email_action( $form_id ); |
|
552
|
|
|
|
|
553
|
|
|
$response = array( |
|
554
|
|
|
'redirect' => FrmForm::get_edit_link( $form_id ), |
|
|
|
|
|
|
555
|
|
|
); |
|
556
|
|
|
|
|
557
|
|
|
echo wp_json_encode( $response ); |
|
558
|
|
|
wp_die(); |
|
559
|
|
|
} |
|
560
|
|
|
|
|
561
|
|
|
/** |
|
562
|
|
|
* Create a custom template from a form |
|
563
|
|
|
* |
|
564
|
|
|
* @since 3.06 |
|
565
|
|
|
*/ |
|
566
|
|
|
public static function build_template() { |
|
567
|
|
|
global $wpdb; |
|
568
|
|
|
|
|
569
|
|
|
FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
570
|
|
|
check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
571
|
|
|
|
|
572
|
|
|
$form_id = FrmAppHelper::get_param( 'xml', '', 'post', 'absint' ); |
|
573
|
|
|
$new_form_id = FrmForm::duplicate( $form_id, 1, true ); |
|
574
|
|
|
if ( ! $new_form_id ) { |
|
575
|
|
|
$response = array( |
|
576
|
|
|
'message' => __( 'There was an error creating a template.', 'formidable' ), |
|
577
|
|
|
); |
|
578
|
|
|
} else { |
|
579
|
|
|
$new_values = self::get_modal_values(); |
|
580
|
|
|
$query_results = $wpdb->update( $wpdb->prefix . 'frm_forms', $new_values, array( 'id' => $new_form_id ) ); |
|
581
|
|
|
if ( $query_results ) { |
|
582
|
|
|
FrmForm::clear_form_cache(); |
|
583
|
|
|
} |
|
584
|
|
|
|
|
585
|
|
|
$response = array( |
|
586
|
|
|
'redirect' => admin_url( 'admin.php?page=formidable&frm_action=duplicate&id=' . $new_form_id ), |
|
587
|
|
|
); |
|
588
|
|
|
} |
|
589
|
|
|
|
|
590
|
|
|
echo wp_json_encode( $response ); |
|
591
|
|
|
wp_die(); |
|
592
|
|
|
} |
|
593
|
|
|
|
|
594
|
|
|
/** |
|
595
|
|
|
* Before creating a new form, get the name and description from the modal. |
|
596
|
|
|
* |
|
597
|
|
|
* @since 4.0 |
|
598
|
|
|
*/ |
|
599
|
|
|
private static function get_modal_values() { |
|
600
|
|
|
$name = FrmAppHelper::get_param( 'name', '', 'post', 'sanitize_text_field' ); |
|
601
|
|
|
$desc = FrmAppHelper::get_param( 'desc', '', 'post', 'sanitize_textarea_field' ); |
|
602
|
|
|
|
|
603
|
|
|
return array( |
|
604
|
|
|
'name' => $name, |
|
605
|
|
|
'description' => $desc, |
|
606
|
|
|
); |
|
607
|
|
|
} |
|
608
|
|
|
|
|
609
|
|
|
/** |
|
610
|
|
|
* Inserts Formidable button |
|
611
|
|
|
* Hook exists since 2.5.0 |
|
612
|
|
|
* |
|
613
|
|
|
* @since 2.0.15 |
|
614
|
|
|
*/ |
|
615
|
|
|
public static function insert_form_button() { |
|
616
|
|
|
if ( current_user_can( 'frm_view_forms' ) ) { |
|
617
|
|
|
FrmAppHelper::load_admin_wide_js(); |
|
618
|
|
|
$menu_name = FrmAppHelper::get_menu_name(); |
|
619
|
|
|
$icon = apply_filters( 'frm_media_icon', FrmAppHelper::svg_logo() ); |
|
620
|
|
|
echo '<a href="#TB_inline?width=50&height=50&inlineId=frm_insert_form" class="thickbox button add_media frm_insert_form" title="' . esc_attr__( 'Add forms and content', 'formidable' ) . '">' . |
|
621
|
|
|
FrmAppHelper::kses( $icon, 'all' ) . |
|
622
|
|
|
' ' . esc_html( $menu_name ) . '</a>'; // WPCS: XSS ok. |
|
623
|
|
|
} |
|
624
|
|
|
} |
|
625
|
|
|
|
|
626
|
|
|
public static function insert_form_popup() { |
|
627
|
|
|
$page = basename( FrmAppHelper::get_server_value( 'PHP_SELF' ) ); |
|
628
|
|
|
if ( ! in_array( $page, array( 'post.php', 'page.php', 'page-new.php', 'post-new.php' ) ) ) { |
|
629
|
|
|
return; |
|
630
|
|
|
} |
|
631
|
|
|
|
|
632
|
|
|
FrmAppHelper::load_admin_wide_js(); |
|
633
|
|
|
|
|
634
|
|
|
$shortcodes = array( |
|
635
|
|
|
'formidable' => array( |
|
636
|
|
|
'name' => __( 'Form', 'formidable' ), |
|
637
|
|
|
'label' => __( 'Insert a Form', 'formidable' ), |
|
638
|
|
|
), |
|
639
|
|
|
); |
|
640
|
|
|
|
|
641
|
|
|
$shortcodes = apply_filters( 'frm_popup_shortcodes', $shortcodes ); |
|
642
|
|
|
|
|
643
|
|
|
include( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/insert_form_popup.php' ); |
|
644
|
|
|
} |
|
645
|
|
|
|
|
646
|
|
|
public static function get_shortcode_opts() { |
|
647
|
|
|
FrmAppHelper::permission_check( 'frm_view_forms' ); |
|
648
|
|
|
check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
649
|
|
|
|
|
650
|
|
|
$shortcode = FrmAppHelper::get_post_param( 'shortcode', '', 'sanitize_text_field' ); |
|
651
|
|
|
if ( empty( $shortcode ) ) { |
|
652
|
|
|
wp_die(); |
|
653
|
|
|
} |
|
654
|
|
|
|
|
655
|
|
|
echo '<div id="sc-opts-' . esc_attr( $shortcode ) . '" class="frm_shortcode_option">'; |
|
656
|
|
|
echo '<input type="radio" name="frmsc" value="' . esc_attr( $shortcode ) . '" id="sc-' . esc_attr( $shortcode ) . '" class="frm_hidden" />'; |
|
657
|
|
|
|
|
658
|
|
|
$form_id = ''; |
|
659
|
|
|
$opts = array(); |
|
660
|
|
|
switch ( $shortcode ) { |
|
661
|
|
|
case 'formidable': |
|
662
|
|
|
$opts = array( |
|
663
|
|
|
'form_id' => 'id', |
|
664
|
|
|
'title' => array( |
|
665
|
|
|
'val' => 1, |
|
666
|
|
|
'label' => __( 'Display form title', 'formidable' ), |
|
667
|
|
|
), |
|
668
|
|
|
'description' => array( |
|
669
|
|
|
'val' => 1, |
|
670
|
|
|
'label' => __( 'Display form description', 'formidable' ), |
|
671
|
|
|
), |
|
672
|
|
|
'minimize' => array( |
|
673
|
|
|
'val' => 1, |
|
674
|
|
|
'label' => __( 'Minimize form HTML', 'formidable' ), |
|
675
|
|
|
), |
|
676
|
|
|
); |
|
677
|
|
|
} |
|
678
|
|
|
$opts = apply_filters( 'frm_sc_popup_opts', $opts, $shortcode ); |
|
679
|
|
|
|
|
680
|
|
|
if ( isset( $opts['form_id'] ) && is_string( $opts['form_id'] ) ) { |
|
681
|
|
|
// allow other shortcodes to use the required form id option |
|
682
|
|
|
$form_id = $opts['form_id']; |
|
683
|
|
|
unset( $opts['form_id'] ); |
|
684
|
|
|
} |
|
685
|
|
|
|
|
686
|
|
|
include( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/shortcode_opts.php' ); |
|
687
|
|
|
|
|
688
|
|
|
echo '</div>'; |
|
689
|
|
|
|
|
690
|
|
|
wp_die(); |
|
691
|
|
|
} |
|
692
|
|
|
|
|
693
|
|
|
public static function display_forms_list( $params = array(), $message = '', $errors = array() ) { |
|
694
|
|
|
FrmAppHelper::permission_check( 'frm_view_forms' ); |
|
695
|
|
|
|
|
696
|
|
|
global $wpdb, $frm_vars; |
|
697
|
|
|
|
|
698
|
|
|
if ( empty( $params ) ) { |
|
699
|
|
|
$params = FrmForm::list_page_params(); |
|
700
|
|
|
} |
|
701
|
|
|
|
|
702
|
|
|
$wp_list_table = new FrmFormsListHelper( compact( 'params' ) ); |
|
703
|
|
|
|
|
704
|
|
|
$pagenum = $wp_list_table->get_pagenum(); |
|
705
|
|
|
|
|
706
|
|
|
$wp_list_table->prepare_items(); |
|
707
|
|
|
|
|
708
|
|
|
$total_pages = $wp_list_table->get_pagination_arg( 'total_pages' ); |
|
709
|
|
|
if ( $pagenum > $total_pages && $total_pages > 0 ) { |
|
710
|
|
|
wp_redirect( esc_url_raw( add_query_arg( 'paged', $total_pages ) ) ); |
|
711
|
|
|
die(); |
|
712
|
|
|
} |
|
713
|
|
|
|
|
714
|
|
|
require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/list.php' ); |
|
715
|
|
|
} |
|
716
|
|
|
|
|
717
|
|
|
public static function get_columns( $columns ) { |
|
718
|
|
|
$columns['cb'] = '<input type="checkbox" />'; |
|
719
|
|
|
$columns['id'] = 'ID'; |
|
720
|
|
|
|
|
721
|
|
|
$type = FrmAppHelper::get_simple_request( |
|
722
|
|
|
array( |
|
723
|
|
|
'param' => 'form_type', |
|
724
|
|
|
'type' => 'request', |
|
725
|
|
|
'default' => 'published', |
|
726
|
|
|
) |
|
727
|
|
|
); |
|
728
|
|
|
|
|
729
|
|
|
if ( 'template' == $type ) { |
|
730
|
|
|
$columns['name'] = __( 'Template Name', 'formidable' ); |
|
731
|
|
|
$columns['type'] = __( 'Type', 'formidable' ); |
|
732
|
|
|
$columns['form_key'] = __( 'Key', 'formidable' ); |
|
733
|
|
|
} else { |
|
734
|
|
|
$columns['name'] = __( 'Form Title', 'formidable' ); |
|
735
|
|
|
$columns['entries'] = __( 'Entries', 'formidable' ); |
|
736
|
|
|
$columns['form_key'] = __( 'Key', 'formidable' ); |
|
737
|
|
|
$columns['shortcode'] = __( 'Shortcodes', 'formidable' ); |
|
738
|
|
|
} |
|
739
|
|
|
|
|
740
|
|
|
$columns['created_at'] = __( 'Date', 'formidable' ); |
|
741
|
|
|
|
|
742
|
|
|
add_screen_option( |
|
743
|
|
|
'per_page', |
|
744
|
|
|
array( |
|
745
|
|
|
'label' => __( 'Forms', 'formidable' ), |
|
746
|
|
|
'default' => 20, |
|
747
|
|
|
'option' => 'formidable_page_formidable_per_page', |
|
748
|
|
|
) |
|
749
|
|
|
); |
|
750
|
|
|
|
|
751
|
|
|
return $columns; |
|
752
|
|
|
} |
|
753
|
|
|
|
|
754
|
|
|
public static function get_sortable_columns() { |
|
755
|
|
|
return array( |
|
756
|
|
|
'id' => 'id', |
|
757
|
|
|
'name' => 'name', |
|
758
|
|
|
'description' => 'description', |
|
759
|
|
|
'form_key' => 'form_key', |
|
760
|
|
|
'created_at' => 'created_at', |
|
761
|
|
|
); |
|
762
|
|
|
} |
|
763
|
|
|
|
|
764
|
|
|
public static function hidden_columns( $hidden_columns ) { |
|
765
|
|
|
$type = FrmAppHelper::get_simple_request( |
|
766
|
|
|
array( |
|
767
|
|
|
'param' => 'form_type', |
|
768
|
|
|
'type' => 'request', |
|
769
|
|
|
) |
|
770
|
|
|
); |
|
771
|
|
|
|
|
772
|
|
|
if ( $type === 'template' ) { |
|
773
|
|
|
$hidden_columns[] = 'id'; |
|
774
|
|
|
$hidden_columns[] = 'form_key'; |
|
775
|
|
|
} |
|
776
|
|
|
|
|
777
|
|
|
return $hidden_columns; |
|
778
|
|
|
} |
|
779
|
|
|
|
|
780
|
|
|
public static function save_per_page( $save, $option, $value ) { |
|
781
|
|
|
if ( $option == 'formidable_page_formidable_per_page' ) { |
|
782
|
|
|
$save = (int) $value; |
|
783
|
|
|
} |
|
784
|
|
|
|
|
785
|
|
|
return $save; |
|
786
|
|
|
} |
|
787
|
|
|
|
|
788
|
|
|
/** |
|
789
|
|
|
* @return bool |
|
790
|
|
|
*/ |
|
791
|
|
|
public static function expired() { |
|
792
|
|
|
global $frm_expired; |
|
793
|
|
|
return $frm_expired; |
|
794
|
|
|
} |
|
795
|
|
|
|
|
796
|
|
|
/** |
|
797
|
|
|
* Get data from api before rendering it so that we can flag the modal as expired |
|
798
|
|
|
*/ |
|
799
|
|
|
public static function before_list_templates() { |
|
800
|
|
|
global $frm_templates; |
|
801
|
|
|
global $frm_expired; |
|
802
|
|
|
global $frm_license_type; |
|
803
|
|
|
|
|
804
|
|
|
$api = new FrmFormTemplateApi(); |
|
805
|
|
|
$frm_templates = $api->get_api_info(); |
|
806
|
|
|
$expired = false; |
|
807
|
|
|
$license_type = ''; |
|
808
|
|
|
if ( isset( $frm_templates['error'] ) ) { |
|
809
|
|
|
$error = $frm_templates['error']['message']; |
|
810
|
|
|
$error = str_replace( 'utm_medium=addons', 'utm_medium=form-templates', $error ); |
|
|
|
|
|
|
811
|
|
|
$expired = 'expired' === $frm_templates['error']['code']; |
|
812
|
|
|
$license_type = isset( $frm_templates['error']['type'] ) ? $frm_templates['error']['type'] : ''; |
|
813
|
|
|
unset( $frm_templates['error'] ); |
|
814
|
|
|
} |
|
815
|
|
|
|
|
816
|
|
|
$frm_expired = $expired; |
|
817
|
|
|
$frm_license_type = $license_type; |
|
818
|
|
|
} |
|
819
|
|
|
|
|
820
|
|
|
public static function list_templates() { |
|
821
|
|
|
global $frm_templates; |
|
822
|
|
|
global $frm_expired; |
|
823
|
|
|
global $frm_license_type; |
|
824
|
|
|
|
|
825
|
|
|
$templates = $frm_templates; |
|
826
|
|
|
$custom_templates = array(); |
|
827
|
|
|
$templates_by_category = array(); |
|
828
|
|
|
|
|
829
|
|
|
self::add_user_templates( $custom_templates ); |
|
830
|
|
|
|
|
831
|
|
|
foreach ( $templates as $template ) { |
|
832
|
|
|
if ( ! isset( $template['categories'] ) ) { |
|
833
|
|
|
continue; |
|
834
|
|
|
} |
|
835
|
|
|
|
|
836
|
|
|
foreach ( $template['categories'] as $category ) { |
|
837
|
|
|
if ( ! isset( $templates_by_category[ $category ] ) ) { |
|
838
|
|
|
$templates_by_category[ $category ] = array(); |
|
839
|
|
|
} |
|
840
|
|
|
|
|
841
|
|
|
$templates_by_category[ $category ][] = $template; |
|
842
|
|
|
} |
|
843
|
|
|
} |
|
844
|
|
|
unset( $template ); |
|
845
|
|
|
|
|
846
|
|
|
// Subcategories that are included elsewhere. |
|
847
|
|
|
$redundant_cats = array( 'PayPal', 'Stripe', 'Twilio' ); |
|
848
|
|
|
|
|
849
|
|
|
$categories = array_keys( $templates_by_category ); |
|
850
|
|
|
$categories = array_diff( $categories, FrmFormsHelper::ignore_template_categories() ); |
|
851
|
|
|
$categories = array_diff( $categories, $redundant_cats ); |
|
852
|
|
|
sort( $categories ); |
|
853
|
|
|
|
|
854
|
|
|
array_walk( |
|
855
|
|
|
$custom_templates, |
|
856
|
|
|
function( &$template ) { |
|
857
|
|
|
$template['custom'] = true; |
|
858
|
|
|
} |
|
859
|
|
|
); |
|
860
|
|
|
|
|
861
|
|
|
$my_templates_translation = __( 'My Templates', 'formidable' ); |
|
862
|
|
|
$categories = array_merge( array( $my_templates_translation ), $categories ); |
|
863
|
|
|
$pricing = FrmAppHelper::admin_upgrade_link( 'form-templates' ); |
|
864
|
|
|
$expired = $frm_expired; |
|
865
|
|
|
$license_type = $frm_license_type; |
|
866
|
|
|
$args = compact( 'pricing', 'license_type' ); |
|
867
|
|
|
$where = apply_filters( 'frm_forms_dropdown', array(), '' ); |
|
868
|
|
|
$forms = FrmForm::get_published_forms( $where ); |
|
869
|
|
|
$view_path = FrmAppHelper::plugin_path() . '/classes/views/frm-forms/'; |
|
870
|
|
|
|
|
871
|
|
|
$templates_by_category[ $my_templates_translation ] = $custom_templates; |
|
872
|
|
|
|
|
873
|
|
|
unset( $pricing, $license_type, $where ); |
|
874
|
|
|
wp_enqueue_script( 'accordion' ); // register accordion for template groups |
|
875
|
|
|
require $view_path . 'list-templates.php'; |
|
876
|
|
|
} |
|
877
|
|
|
|
|
878
|
|
|
/** |
|
879
|
|
|
* @since 4.03.01 |
|
880
|
|
|
*/ |
|
881
|
|
|
private static function get_template_categories( $templates ) { |
|
882
|
|
|
$categories = array(); |
|
883
|
|
|
foreach ( $templates as $template ) { |
|
884
|
|
|
if ( isset( $template['categories'] ) ) { |
|
885
|
|
|
$categories = array_merge( $categories, $template['categories'] ); |
|
886
|
|
|
} |
|
887
|
|
|
} |
|
888
|
|
|
$exclude_cats = FrmFormsHelper::ignore_template_categories(); |
|
889
|
|
|
$categories = array_unique( $categories ); |
|
890
|
|
|
$categories = array_diff( $categories, $exclude_cats ); |
|
891
|
|
|
sort( $categories ); |
|
892
|
|
|
return $categories; |
|
893
|
|
|
} |
|
894
|
|
|
|
|
895
|
|
|
private static function add_user_templates( &$templates ) { |
|
896
|
|
|
$user_templates = array( |
|
897
|
|
|
'is_template' => 1, |
|
898
|
|
|
'default_template' => 0, |
|
899
|
|
|
); |
|
900
|
|
|
$user_templates = FrmForm::getAll( $user_templates, 'name' ); |
|
901
|
|
|
foreach ( $user_templates as $template ) { |
|
902
|
|
|
$template = array( |
|
903
|
|
|
'id' => $template->id, |
|
904
|
|
|
'name' => $template->name, |
|
905
|
|
|
'key' => $template->form_key, |
|
906
|
|
|
'description' => $template->description, |
|
907
|
|
|
'url' => admin_url( 'admin.php?page=formidable&frm_action=duplicate&id=' . absint( $template->id ) ), |
|
908
|
|
|
'released' => $template->created_at, |
|
909
|
|
|
'installed' => 1, |
|
910
|
|
|
); |
|
911
|
|
|
array_unshift( $templates, $template ); |
|
912
|
|
|
unset( $template ); |
|
913
|
|
|
} |
|
914
|
|
|
} |
|
915
|
|
|
|
|
916
|
|
|
private static function get_edit_vars( $id, $errors = array(), $message = '', $create_link = false ) { |
|
917
|
|
|
global $frm_vars; |
|
918
|
|
|
|
|
919
|
|
|
$form = FrmForm::getOne( $id ); |
|
920
|
|
|
if ( ! $form ) { |
|
921
|
|
|
wp_die( esc_html__( 'You are trying to edit a form that does not exist.', 'formidable' ) ); |
|
922
|
|
|
} |
|
923
|
|
|
|
|
924
|
|
|
if ( $form->parent_form_id ) { |
|
925
|
|
|
/* translators: %1$s: Start link HTML, %2$s: End link HTML */ |
|
926
|
|
|
wp_die( sprintf( esc_html__( 'You are trying to edit a child form. Please edit from %1$shere%2$s', 'formidable' ), '<a href="' . esc_url( FrmForm::get_edit_link( $form->parent_form_id ) ) . '">', '</a>' ) ); |
|
927
|
|
|
} |
|
928
|
|
|
|
|
929
|
|
|
$frm_field_selection = FrmField::field_selection(); |
|
930
|
|
|
|
|
931
|
|
|
$fields = FrmField::get_all_for_form( $form->id ); |
|
932
|
|
|
|
|
933
|
|
|
// Automatically add end section fields if they don't exist (2.0 migration). |
|
934
|
|
|
$reset_fields = false; |
|
935
|
|
|
FrmFormsHelper::auto_add_end_section_fields( $form, $fields, $reset_fields ); |
|
936
|
|
|
|
|
937
|
|
|
if ( $reset_fields ) { |
|
938
|
|
|
$fields = FrmField::get_all_for_form( $form->id, '', 'exclude' ); |
|
939
|
|
|
} |
|
940
|
|
|
|
|
941
|
|
|
unset( $end_section_values, $last_order, $open, $reset_fields ); |
|
942
|
|
|
|
|
943
|
|
|
$args = array( 'parent_form_id' => $form->id ); |
|
944
|
|
|
$values = FrmAppHelper::setup_edit_vars( $form, 'forms', '', true, array(), $args ); |
|
945
|
|
|
$values['fields'] = $fields; |
|
946
|
|
|
|
|
947
|
|
|
$edit_message = __( 'Form was successfully updated.', 'formidable' ); |
|
948
|
|
|
if ( $form->is_template && $message == $edit_message ) { |
|
949
|
|
|
$message = __( 'Template was successfully updated.', 'formidable' ); |
|
950
|
|
|
} |
|
951
|
|
|
|
|
952
|
|
|
$all_templates = FrmForm::getAll( array( 'is_template' => 1 ), 'name' ); |
|
953
|
|
|
$has_fields = isset( $values['fields'] ) && ! empty( $values['fields'] ); |
|
954
|
|
|
|
|
955
|
|
|
if ( defined( 'DOING_AJAX' ) ) { |
|
956
|
|
|
wp_die(); |
|
957
|
|
|
} else { |
|
958
|
|
|
require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/edit.php' ); |
|
959
|
|
|
} |
|
960
|
|
|
} |
|
961
|
|
|
|
|
962
|
|
|
public static function get_settings_vars( $id, $errors = array(), $args = array() ) { |
|
963
|
|
|
FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
964
|
|
|
|
|
965
|
|
|
global $frm_vars; |
|
966
|
|
|
|
|
967
|
|
|
if ( ! is_array( $args ) ) { |
|
968
|
|
|
// For reverse compatibility. |
|
969
|
|
|
$args = array( |
|
970
|
|
|
'message' => $args, |
|
971
|
|
|
); |
|
972
|
|
|
} |
|
973
|
|
|
|
|
974
|
|
|
$defaults = array( |
|
975
|
|
|
'message' => '', |
|
976
|
|
|
'warnings' => array(), |
|
977
|
|
|
); |
|
978
|
|
|
$args = array_merge( $defaults, $args ); |
|
979
|
|
|
$message = $args['message']; |
|
980
|
|
|
$warnings = $args['warnings']; |
|
981
|
|
|
|
|
982
|
|
|
$form = FrmForm::getOne( $id ); |
|
983
|
|
|
$fields = FrmField::get_all_for_form( $id ); |
|
984
|
|
|
$values = FrmAppHelper::setup_edit_vars( $form, 'forms', $fields, true ); |
|
985
|
|
|
|
|
986
|
|
|
self::clean_submit_html( $values ); |
|
987
|
|
|
|
|
988
|
|
|
$sections = self::get_settings_tabs( $values ); |
|
|
|
|
|
|
989
|
|
|
$current = FrmAppHelper::simple_get( 't', 'sanitize_title', 'advanced_settings' ); |
|
990
|
|
|
|
|
991
|
|
|
require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/settings.php' ); |
|
992
|
|
|
} |
|
993
|
|
|
|
|
994
|
|
|
/** |
|
995
|
|
|
* @since 4.0 |
|
996
|
|
|
*/ |
|
997
|
|
|
public static function form_publish_button( $atts ) { |
|
998
|
|
|
$values = $atts['values']; |
|
999
|
|
|
include( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/_publish_box.php' ); |
|
1000
|
|
|
} |
|
1001
|
|
|
|
|
1002
|
|
|
/** |
|
1003
|
|
|
* Get a list of all the settings tabs for the form settings page. |
|
1004
|
|
|
* |
|
1005
|
|
|
* @since 4.0 |
|
1006
|
|
|
* |
|
1007
|
|
|
* @param array $values |
|
1008
|
|
|
* @return array |
|
1009
|
|
|
*/ |
|
1010
|
|
|
private static function get_settings_tabs( $values ) { |
|
1011
|
|
|
$sections = array( |
|
1012
|
|
|
'advanced' => array( |
|
1013
|
|
|
'name' => __( 'General', 'formidable' ), |
|
1014
|
|
|
'title' => __( 'General Form Settings', 'formidable' ), |
|
1015
|
|
|
'function' => array( __CLASS__, 'advanced_settings' ), |
|
1016
|
|
|
'icon' => 'frm_icon_font frm_settings_icon', |
|
1017
|
|
|
), |
|
1018
|
|
|
'email' => array( |
|
1019
|
|
|
'name' => __( 'Actions & Notifications', 'formidable' ), |
|
1020
|
|
|
'function' => array( 'FrmFormActionsController', 'email_settings' ), |
|
1021
|
|
|
'id' => 'frm_notification_settings', |
|
1022
|
|
|
'icon' => 'frm_icon_font frm_mail_bulk_icon', |
|
1023
|
|
|
), |
|
1024
|
|
|
'permissions' => array( |
|
1025
|
|
|
'name' => __( 'Form Permissions', 'formidable' ), |
|
1026
|
|
|
'icon' => 'frm_icon_font frm_lock_icon', |
|
1027
|
|
|
'html_class' => 'frm_show_upgrade frm_noallow', |
|
1028
|
|
|
'data' => array( |
|
1029
|
|
|
'medium' => 'permissions', |
|
1030
|
|
|
'upgrade' => __( 'Form Permissions', 'formidable' ), |
|
1031
|
|
|
'message' => __( 'Allow editing, protect forms and files, limit entries, and save drafts. Upgrade to get form and entry permissions.', 'formidable' ), |
|
1032
|
|
|
), |
|
1033
|
|
|
), |
|
1034
|
|
|
'scheduling' => array( |
|
1035
|
|
|
'name' => __( 'Form Scheduling', 'formidable' ), |
|
1036
|
|
|
'icon' => 'frm_icon_font frm_calendar_icon', |
|
1037
|
|
|
'html_class' => 'frm_show_upgrade frm_noallow', |
|
1038
|
|
|
'data' => array( |
|
1039
|
|
|
'medium' => 'scheduling', |
|
1040
|
|
|
'upgrade' => __( 'Form scheduling settings', 'formidable' ), |
|
1041
|
|
|
), |
|
1042
|
|
|
), |
|
1043
|
|
|
'buttons' => array( |
|
1044
|
|
|
'name' => __( 'Styling & Buttons', 'formidable' ), |
|
1045
|
|
|
'class' => __CLASS__, |
|
1046
|
|
|
'function' => 'buttons_settings', |
|
1047
|
|
|
'icon' => 'frm_icon_font frm_pallet_icon', |
|
1048
|
|
|
), |
|
1049
|
|
|
'html' => array( |
|
1050
|
|
|
'name' => __( 'Customize HTML', 'formidable' ), |
|
1051
|
|
|
'class' => __CLASS__, |
|
1052
|
|
|
'function' => 'html_settings', |
|
1053
|
|
|
'icon' => 'frm_icon_font frm_code_icon', |
|
1054
|
|
|
), |
|
1055
|
|
|
); |
|
1056
|
|
|
|
|
1057
|
|
|
$sections = apply_filters( 'frm_add_form_settings_section', $sections, $values ); |
|
1058
|
|
|
|
|
1059
|
|
|
if ( FrmAppHelper::pro_is_installed() && ! FrmAppHelper::meets_min_pro_version( '4.0' ) ) { |
|
1060
|
|
|
// Prevent settings from showing in 2 spots. |
|
1061
|
|
|
unset( $sections['permissions'], $sections['scheduling'] ); |
|
1062
|
|
|
} |
|
1063
|
|
|
|
|
1064
|
|
|
foreach ( $sections as $key => $section ) { |
|
1065
|
|
|
$defaults = array( |
|
1066
|
|
|
'html_class' => '', |
|
1067
|
|
|
'name' => ucfirst( $key ), |
|
1068
|
|
|
'icon' => 'frm_icon_font frm_settings_icon', |
|
1069
|
|
|
); |
|
1070
|
|
|
|
|
1071
|
|
|
$section = array_merge( $defaults, $section ); |
|
1072
|
|
|
|
|
1073
|
|
|
if ( ! isset( $section['anchor'] ) ) { |
|
1074
|
|
|
$section['anchor'] = $key; |
|
1075
|
|
|
} |
|
1076
|
|
|
$section['anchor'] .= '_settings'; |
|
1077
|
|
|
|
|
1078
|
|
|
if ( ! isset( $section['title'] ) ) { |
|
1079
|
|
|
$section['title'] = $section['name']; |
|
1080
|
|
|
} |
|
1081
|
|
|
|
|
1082
|
|
|
if ( ! isset( $section['id'] ) ) { |
|
1083
|
|
|
$section['id'] = $section['anchor']; |
|
1084
|
|
|
} |
|
1085
|
|
|
|
|
1086
|
|
|
$sections[ $key ] = $section; |
|
1087
|
|
|
} |
|
1088
|
|
|
|
|
1089
|
|
|
return $sections; |
|
1090
|
|
|
} |
|
1091
|
|
|
|
|
1092
|
|
|
/** |
|
1093
|
|
|
* @since 4.0 |
|
1094
|
|
|
* |
|
1095
|
|
|
* @param array $values |
|
1096
|
|
|
*/ |
|
1097
|
|
|
public static function advanced_settings( $values ) { |
|
1098
|
|
|
$first_h3 = 'frm_first_h3'; |
|
1099
|
|
|
|
|
1100
|
|
|
include( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/settings-advanced.php' ); |
|
1101
|
|
|
} |
|
1102
|
|
|
|
|
1103
|
|
|
/** |
|
1104
|
|
|
* @since 4.0 |
|
1105
|
|
|
* |
|
1106
|
|
|
* @param array $values |
|
1107
|
|
|
*/ |
|
1108
|
|
|
public static function buttons_settings( $values ) { |
|
1109
|
|
|
$styles = apply_filters( 'frm_get_style_opts', array() ); |
|
1110
|
|
|
|
|
1111
|
|
|
$frm_settings = FrmAppHelper::get_settings(); |
|
1112
|
|
|
$no_global_style = $frm_settings->load_style === 'none'; |
|
1113
|
|
|
|
|
1114
|
|
|
include( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/settings-buttons.php' ); |
|
1115
|
|
|
} |
|
1116
|
|
|
|
|
1117
|
|
|
/** |
|
1118
|
|
|
* @since 4.0 |
|
1119
|
|
|
* |
|
1120
|
|
|
* @param array $values |
|
1121
|
|
|
*/ |
|
1122
|
|
|
public static function html_settings( $values ) { |
|
1123
|
|
|
include( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/settings-html.php' ); |
|
1124
|
|
|
} |
|
1125
|
|
|
|
|
1126
|
|
|
/** |
|
1127
|
|
|
* Replace old Submit Button href with new href to avoid errors in Chrome |
|
1128
|
|
|
* |
|
1129
|
|
|
* @since 2.03.08 |
|
1130
|
|
|
* |
|
1131
|
|
|
* @param array|boolean $values |
|
1132
|
|
|
*/ |
|
1133
|
|
|
private static function clean_submit_html( &$values ) { |
|
1134
|
|
|
if ( is_array( $values ) && isset( $values['submit_html'] ) ) { |
|
1135
|
|
|
$values['submit_html'] = str_replace( 'javascript:void(0)', '#', $values['submit_html'] ); |
|
1136
|
|
|
} |
|
1137
|
|
|
} |
|
1138
|
|
|
|
|
1139
|
|
|
public static function mb_tags_box( $form_id, $class = '' ) { |
|
1140
|
|
|
$fields = FrmField::get_all_for_form( $form_id, '', 'include' ); |
|
1141
|
|
|
$linked_forms = array(); |
|
1142
|
|
|
$col = 'one'; |
|
1143
|
|
|
$settings_tab = FrmAppHelper::is_admin_page( 'formidable' ) ? true : false; |
|
1144
|
|
|
|
|
1145
|
|
|
$cond_shortcodes = apply_filters( 'frm_conditional_shortcodes', array() ); |
|
1146
|
|
|
$entry_shortcodes = self::get_shortcode_helpers( $settings_tab ); |
|
1147
|
|
|
|
|
1148
|
|
|
$advanced_helpers = self::advanced_helpers( compact( 'fields', 'form_id' ) ); |
|
1149
|
|
|
|
|
1150
|
|
|
include( FrmAppHelper::plugin_path() . '/classes/views/shared/mb_adv_info.php' ); |
|
1151
|
|
|
} |
|
1152
|
|
|
|
|
1153
|
|
|
/** |
|
1154
|
|
|
* @since 3.04.01 |
|
1155
|
|
|
*/ |
|
1156
|
|
|
private static function advanced_helpers( $atts ) { |
|
1157
|
|
|
$advanced_helpers = array( |
|
1158
|
|
|
'default' => array( |
|
1159
|
|
|
'heading' => __( 'Customize field values with the following parameters.', 'formidable' ), |
|
1160
|
|
|
'codes' => self::get_advanced_shortcodes(), |
|
1161
|
|
|
), |
|
1162
|
|
|
); |
|
1163
|
|
|
|
|
1164
|
|
|
$user_fields = self::user_shortcodes(); |
|
1165
|
|
|
if ( ! empty( $user_fields ) ) { |
|
1166
|
|
|
$user_helpers = array(); |
|
1167
|
|
|
foreach ( $user_fields as $uk => $uf ) { |
|
1168
|
|
|
$user_helpers[ '|user_id| show="' . $uk . '"' ] = $uf; |
|
1169
|
|
|
unset( $uk, $uf ); |
|
1170
|
|
|
} |
|
1171
|
|
|
|
|
1172
|
|
|
$advanced_helpers['user_id'] = array( |
|
1173
|
|
|
'codes' => $user_helpers, |
|
1174
|
|
|
); |
|
1175
|
|
|
} |
|
1176
|
|
|
|
|
1177
|
|
|
/** |
|
1178
|
|
|
* Add extra helper shortcodes on the Advanced tab in form settings and views |
|
1179
|
|
|
* |
|
1180
|
|
|
* @since 3.04.01 |
|
1181
|
|
|
* |
|
1182
|
|
|
* @param array $atts - Includes fields and form_id |
|
1183
|
|
|
*/ |
|
1184
|
|
|
return apply_filters( 'frm_advanced_helpers', $advanced_helpers, $atts ); |
|
1185
|
|
|
} |
|
1186
|
|
|
|
|
1187
|
|
|
/** |
|
1188
|
|
|
* Get an array of the options to display in the advanced tab |
|
1189
|
|
|
* of the customization panel |
|
1190
|
|
|
* |
|
1191
|
|
|
* @since 2.0.6 |
|
1192
|
|
|
*/ |
|
1193
|
|
|
private static function get_advanced_shortcodes() { |
|
1194
|
|
|
$adv_shortcodes = array( |
|
1195
|
|
|
'x sep=", "' => array( |
|
1196
|
|
|
'label' => __( 'Separator', 'formidable' ), |
|
1197
|
|
|
'title' => __( 'Use a different separator for checkbox fields', 'formidable' ), |
|
1198
|
|
|
), |
|
1199
|
|
|
'x format="d-m-Y"' => array( |
|
1200
|
|
|
'label' => __( 'Date Format', 'formidable' ), |
|
1201
|
|
|
), |
|
1202
|
|
|
'x show="field_label"' => array( |
|
1203
|
|
|
'label' => __( 'Field Label', 'formidable' ), |
|
1204
|
|
|
), |
|
1205
|
|
|
'x wpautop=0' => array( |
|
1206
|
|
|
'label' => __( 'No Auto P', 'formidable' ), |
|
1207
|
|
|
'title' => __( 'Do not automatically add any paragraphs or line breaks', 'formidable' ), |
|
1208
|
|
|
), |
|
1209
|
|
|
); |
|
1210
|
|
|
$adv_shortcodes = apply_filters( 'frm_advanced_shortcodes', $adv_shortcodes ); |
|
1211
|
|
|
|
|
1212
|
|
|
// __( 'Leave blank instead of defaulting to User Login', 'formidable' ) : blank=1 |
|
1213
|
|
|
|
|
1214
|
|
|
return $adv_shortcodes; |
|
1215
|
|
|
} |
|
1216
|
|
|
|
|
1217
|
|
|
/** |
|
1218
|
|
|
* @since 3.04.01 |
|
1219
|
|
|
*/ |
|
1220
|
|
|
private static function user_shortcodes() { |
|
1221
|
|
|
$options = array( |
|
1222
|
|
|
'ID' => __( 'User ID', 'formidable' ), |
|
1223
|
|
|
'first_name' => __( 'First Name', 'formidable' ), |
|
1224
|
|
|
'last_name' => __( 'Last Name', 'formidable' ), |
|
1225
|
|
|
'display_name' => __( 'Display Name', 'formidable' ), |
|
1226
|
|
|
'user_login' => __( 'User Login', 'formidable' ), |
|
1227
|
|
|
'user_email' => __( 'Email', 'formidable' ), |
|
1228
|
|
|
'avatar' => __( 'Avatar', 'formidable' ), |
|
1229
|
|
|
'author_link' => __( 'Author Link', 'formidable' ), |
|
1230
|
|
|
); |
|
1231
|
|
|
|
|
1232
|
|
|
return apply_filters( 'frm_user_shortcodes', $options ); |
|
1233
|
|
|
} |
|
1234
|
|
|
|
|
1235
|
|
|
/** |
|
1236
|
|
|
* Get an array of the helper shortcodes to display in the customization panel |
|
1237
|
|
|
* |
|
1238
|
|
|
* @since 2.0.6 |
|
1239
|
|
|
*/ |
|
1240
|
|
|
private static function get_shortcode_helpers( $settings_tab ) { |
|
1241
|
|
|
$entry_shortcodes = array( |
|
1242
|
|
|
'id' => __( 'Entry ID', 'formidable' ), |
|
1243
|
|
|
'key' => __( 'Entry Key', 'formidable' ), |
|
1244
|
|
|
'post_id' => __( 'Post ID', 'formidable' ), |
|
1245
|
|
|
'ip' => __( 'User IP', 'formidable' ), |
|
1246
|
|
|
'created-at' => __( 'Entry created', 'formidable' ), |
|
1247
|
|
|
'updated-at' => __( 'Entry updated', 'formidable' ), |
|
1248
|
|
|
'' => '', |
|
1249
|
|
|
'siteurl' => __( 'Site URL', 'formidable' ), |
|
1250
|
|
|
'sitename' => __( 'Site Name', 'formidable' ), |
|
1251
|
|
|
); |
|
1252
|
|
|
|
|
1253
|
|
|
if ( ! FrmAppHelper::pro_is_installed() ) { |
|
1254
|
|
|
unset( $entry_shortcodes['post_id'] ); |
|
1255
|
|
|
} |
|
1256
|
|
|
|
|
1257
|
|
|
if ( $settings_tab ) { |
|
1258
|
|
|
$entry_shortcodes['default-message'] = __( 'Default Msg', 'formidable' ); |
|
1259
|
|
|
$entry_shortcodes['default-html'] = __( 'Default HTML', 'formidable' ); |
|
1260
|
|
|
$entry_shortcodes['default-plain'] = __( 'Default Plain', 'formidable' ); |
|
1261
|
|
|
} |
|
1262
|
|
|
|
|
1263
|
|
|
/** |
|
1264
|
|
|
* Use this hook to add or remove buttons in the helpers section |
|
1265
|
|
|
* in the customization panel |
|
1266
|
|
|
* |
|
1267
|
|
|
* @since 2.0.6 |
|
1268
|
|
|
*/ |
|
1269
|
|
|
$entry_shortcodes = apply_filters( 'frm_helper_shortcodes', $entry_shortcodes, $settings_tab ); |
|
1270
|
|
|
|
|
1271
|
|
|
return $entry_shortcodes; |
|
1272
|
|
|
} |
|
1273
|
|
|
|
|
1274
|
|
|
/** |
|
1275
|
|
|
* Insert the form class setting into the form |
|
1276
|
|
|
*/ |
|
1277
|
|
|
public static function form_classes( $form ) { |
|
1278
|
|
|
if ( isset( $form->options['form_class'] ) ) { |
|
1279
|
|
|
echo esc_attr( sanitize_text_field( $form->options['form_class'] ) ); |
|
1280
|
|
|
} |
|
1281
|
|
|
|
|
1282
|
|
|
if ( isset( $form->options['js_validate'] ) && $form->options['js_validate'] ) { |
|
1283
|
|
|
echo ' frm_js_validate '; |
|
1284
|
|
|
} |
|
1285
|
|
|
} |
|
1286
|
|
|
|
|
1287
|
|
|
public static function get_email_html() { |
|
1288
|
|
|
FrmAppHelper::permission_check( 'frm_view_forms' ); |
|
1289
|
|
|
check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
1290
|
|
|
|
|
1291
|
|
|
echo FrmEntriesController::show_entry_shortcode( // WPCS: XSS ok. |
|
1292
|
|
|
array( |
|
1293
|
|
|
'form_id' => FrmAppHelper::get_post_param( 'form_id', '', 'absint' ), |
|
1294
|
|
|
'default_email' => true, |
|
1295
|
|
|
'plain_text' => FrmAppHelper::get_post_param( 'plain_text', '', 'absint' ), |
|
1296
|
|
|
) |
|
1297
|
|
|
); |
|
1298
|
|
|
wp_die(); |
|
1299
|
|
|
} |
|
1300
|
|
|
|
|
1301
|
|
|
public static function filter_content( $content, $form, $entry = false ) { |
|
1302
|
|
|
self::get_entry_by_param( $entry ); |
|
1303
|
|
|
if ( ! $entry ) { |
|
1304
|
|
|
return $content; |
|
1305
|
|
|
} |
|
1306
|
|
|
|
|
1307
|
|
|
if ( is_object( $form ) ) { |
|
1308
|
|
|
$form = $form->id; |
|
1309
|
|
|
} |
|
1310
|
|
|
|
|
1311
|
|
|
$shortcodes = FrmFieldsHelper::get_shortcodes( $content, $form ); |
|
1312
|
|
|
$content = apply_filters( 'frm_replace_content_shortcodes', $content, $entry, $shortcodes ); |
|
1313
|
|
|
|
|
1314
|
|
|
return $content; |
|
1315
|
|
|
} |
|
1316
|
|
|
|
|
1317
|
|
|
private static function get_entry_by_param( &$entry ) { |
|
1318
|
|
|
if ( ! $entry || ! is_object( $entry ) ) { |
|
1319
|
|
|
if ( ! $entry || ! is_numeric( $entry ) ) { |
|
1320
|
|
|
$entry = FrmAppHelper::get_post_param( 'id', false, 'sanitize_title' ); |
|
1321
|
|
|
} |
|
1322
|
|
|
|
|
1323
|
|
|
FrmEntry::maybe_get_entry( $entry ); |
|
1324
|
|
|
} |
|
1325
|
|
|
} |
|
1326
|
|
|
|
|
1327
|
|
|
public static function replace_content_shortcodes( $content, $entry, $shortcodes ) { |
|
1328
|
|
|
return FrmFieldsHelper::replace_content_shortcodes( $content, $entry, $shortcodes ); |
|
1329
|
|
|
} |
|
1330
|
|
|
|
|
1331
|
|
|
public static function process_bulk_form_actions( $errors ) { |
|
1332
|
|
|
if ( ! $_REQUEST ) { |
|
1333
|
|
|
return $errors; |
|
1334
|
|
|
} |
|
1335
|
|
|
|
|
1336
|
|
|
$bulkaction = FrmAppHelper::get_param( 'action', '', 'get', 'sanitize_text_field' ); |
|
1337
|
|
|
if ( $bulkaction == - 1 ) { |
|
1338
|
|
|
$bulkaction = FrmAppHelper::get_param( 'action2', '', 'get', 'sanitize_title' ); |
|
1339
|
|
|
} |
|
1340
|
|
|
|
|
1341
|
|
|
if ( ! empty( $bulkaction ) && strpos( $bulkaction, 'bulk_' ) === 0 ) { |
|
1342
|
|
|
FrmAppHelper::remove_get_action(); |
|
1343
|
|
|
|
|
1344
|
|
|
$bulkaction = str_replace( 'bulk_', '', $bulkaction ); |
|
1345
|
|
|
} |
|
1346
|
|
|
|
|
1347
|
|
|
$ids = FrmAppHelper::get_param( 'item-action', '', 'get', 'sanitize_text_field' ); |
|
1348
|
|
|
if ( empty( $ids ) ) { |
|
1349
|
|
|
$errors[] = __( 'No forms were specified', 'formidable' ); |
|
1350
|
|
|
|
|
1351
|
|
|
return $errors; |
|
1352
|
|
|
} |
|
1353
|
|
|
|
|
1354
|
|
|
$permission_error = FrmAppHelper::permission_nonce_error( '', '_wpnonce', 'bulk-toplevel_page_formidable' ); |
|
1355
|
|
|
if ( $permission_error !== false ) { |
|
1356
|
|
|
$errors[] = $permission_error; |
|
1357
|
|
|
|
|
1358
|
|
|
return $errors; |
|
1359
|
|
|
} |
|
1360
|
|
|
|
|
1361
|
|
|
if ( ! is_array( $ids ) ) { |
|
1362
|
|
|
$ids = explode( ',', $ids ); |
|
1363
|
|
|
} |
|
1364
|
|
|
|
|
1365
|
|
|
switch ( $bulkaction ) { |
|
1366
|
|
|
case 'delete': |
|
1367
|
|
|
$message = self::bulk_destroy( $ids ); |
|
1368
|
|
|
break; |
|
1369
|
|
|
case 'trash': |
|
1370
|
|
|
$message = self::bulk_trash( $ids ); |
|
1371
|
|
|
break; |
|
1372
|
|
|
case 'untrash': |
|
1373
|
|
|
$message = self::bulk_untrash( $ids ); |
|
1374
|
|
|
} |
|
1375
|
|
|
|
|
1376
|
|
|
if ( isset( $message ) && ! empty( $message ) ) { |
|
1377
|
|
|
$errors['message'] = $message; |
|
1378
|
|
|
} |
|
1379
|
|
|
|
|
1380
|
|
|
return $errors; |
|
1381
|
|
|
} |
|
1382
|
|
|
|
|
1383
|
|
|
public static function route() { |
|
1384
|
|
|
$action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action'; |
|
1385
|
|
|
$vars = array(); |
|
1386
|
|
|
FrmAppHelper::include_svg(); |
|
1387
|
|
|
|
|
1388
|
|
|
if ( isset( $_POST['frm_compact_fields'] ) ) { |
|
1389
|
|
|
FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
1390
|
|
|
|
|
1391
|
|
|
// Javascript needs to be allowed in some field settings. |
|
1392
|
|
|
// phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized |
|
1393
|
|
|
$json_vars = htmlspecialchars_decode( nl2br( str_replace( '"', '"', wp_unslash( $_POST['frm_compact_fields'] ) ) ) ); |
|
1394
|
|
|
$json_vars = json_decode( $json_vars, true ); |
|
1395
|
|
|
if ( empty( $json_vars ) ) { |
|
1396
|
|
|
// json decoding failed so we should return an error message. |
|
1397
|
|
|
$action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' ); |
|
1398
|
|
|
if ( 'edit' == $action ) { |
|
1399
|
|
|
$action = 'update'; |
|
1400
|
|
|
} |
|
1401
|
|
|
|
|
1402
|
|
|
add_filter( 'frm_validate_form', 'FrmFormsController::json_error' ); |
|
1403
|
|
|
} else { |
|
1404
|
|
|
$vars = FrmAppHelper::json_to_array( $json_vars ); |
|
1405
|
|
|
$action = $vars[ $action ]; |
|
1406
|
|
|
unset( $_REQUEST['frm_compact_fields'], $_POST['frm_compact_fields'] ); |
|
1407
|
|
|
$_REQUEST = array_merge( $_REQUEST, $vars ); |
|
1408
|
|
|
$_POST = array_merge( $_POST, $_REQUEST ); |
|
1409
|
|
|
} |
|
1410
|
|
|
} else { |
|
1411
|
|
|
$action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' ); |
|
1412
|
|
|
if ( isset( $_REQUEST['delete_all'] ) ) { |
|
1413
|
|
|
// Override the action for this page. |
|
1414
|
|
|
$action = 'delete_all'; |
|
1415
|
|
|
} |
|
1416
|
|
|
} |
|
1417
|
|
|
|
|
1418
|
|
|
add_action( 'frm_load_form_hooks', 'FrmHooksController::trigger_load_form_hooks' ); |
|
1419
|
|
|
FrmAppHelper::trigger_hook_load( 'form' ); |
|
1420
|
|
|
|
|
1421
|
|
|
switch ( $action ) { |
|
1422
|
|
|
case 'new': |
|
1423
|
|
|
return self::new_form( $vars ); |
|
|
|
|
|
|
1424
|
|
|
case 'create': |
|
1425
|
|
|
case 'edit': |
|
1426
|
|
|
case 'update': |
|
1427
|
|
|
case 'duplicate': |
|
1428
|
|
|
case 'trash': |
|
1429
|
|
|
case 'untrash': |
|
1430
|
|
|
case 'destroy': |
|
1431
|
|
|
case 'delete_all': |
|
1432
|
|
|
case 'settings': |
|
1433
|
|
|
case 'update_settings': |
|
1434
|
|
|
return self::$action( $vars ); |
|
1435
|
|
|
case 'lite-reports': |
|
1436
|
|
|
return self::no_reports( $vars ); |
|
1437
|
|
|
case 'views': |
|
1438
|
|
|
return self::no_views( $vars ); |
|
1439
|
|
|
default: |
|
1440
|
|
|
do_action( 'frm_form_action_' . $action ); |
|
1441
|
|
|
if ( apply_filters( 'frm_form_stop_action_' . $action, false ) ) { |
|
1442
|
|
|
return; |
|
1443
|
|
|
} |
|
1444
|
|
|
|
|
1445
|
|
|
$action = FrmAppHelper::get_param( 'action', '', 'get', 'sanitize_text_field' ); |
|
1446
|
|
|
if ( $action == - 1 ) { |
|
1447
|
|
|
$action = FrmAppHelper::get_param( 'action2', '', 'get', 'sanitize_title' ); |
|
1448
|
|
|
} |
|
1449
|
|
|
|
|
1450
|
|
|
if ( strpos( $action, 'bulk_' ) === 0 ) { |
|
1451
|
|
|
FrmAppHelper::remove_get_action(); |
|
1452
|
|
|
|
|
1453
|
|
|
return self::list_form(); |
|
1454
|
|
|
} |
|
1455
|
|
|
|
|
1456
|
|
|
return self::display_forms_list(); |
|
1457
|
|
|
} |
|
1458
|
|
|
} |
|
1459
|
|
|
|
|
1460
|
|
|
public static function json_error( $errors ) { |
|
1461
|
|
|
$errors['json'] = __( 'Abnormal HTML characters prevented your form from saving correctly', 'formidable' ); |
|
1462
|
|
|
|
|
1463
|
|
|
return $errors; |
|
1464
|
|
|
} |
|
1465
|
|
|
|
|
1466
|
|
|
/** |
|
1467
|
|
|
* Education for premium features. |
|
1468
|
|
|
* |
|
1469
|
|
|
* @since 4.05 |
|
1470
|
|
|
*/ |
|
1471
|
|
|
public static function add_form_style_tab_options() { |
|
1472
|
|
|
include( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/add_form_style_options.php' ); |
|
1473
|
|
|
} |
|
1474
|
|
|
|
|
1475
|
|
|
/** |
|
1476
|
|
|
* Add education about views. |
|
1477
|
|
|
* |
|
1478
|
|
|
* @since 4.07 |
|
1479
|
|
|
*/ |
|
1480
|
|
|
public static function no_views( $values = array() ) { |
|
1481
|
|
|
FrmAppHelper::include_svg(); |
|
1482
|
|
|
$id = FrmAppHelper::get_param( 'form', '', 'get', 'absint' ); |
|
1483
|
|
|
$form = $id ? FrmForm::getOne( $id ) : false; |
|
1484
|
|
|
|
|
1485
|
|
|
include FrmAppHelper::plugin_path() . '/classes/views/shared/views-info.php'; |
|
1486
|
|
|
} |
|
1487
|
|
|
|
|
1488
|
|
|
/** |
|
1489
|
|
|
* Add education about reports. |
|
1490
|
|
|
* |
|
1491
|
|
|
* @since 4.07 |
|
1492
|
|
|
*/ |
|
1493
|
|
|
public static function no_reports( $values = array() ) { |
|
1494
|
|
|
$id = FrmAppHelper::get_param( 'form', '', 'get', 'absint' ); |
|
1495
|
|
|
$form = $id ? FrmForm::getOne( $id ) : false; |
|
1496
|
|
|
|
|
1497
|
|
|
include FrmAppHelper::plugin_path() . '/classes/views/shared/reports-info.php'; |
|
1498
|
|
|
} |
|
1499
|
|
|
|
|
1500
|
|
|
/* FRONT-END FORMS */ |
|
1501
|
|
|
public static function admin_bar_css() { |
|
1502
|
|
|
if ( is_admin() || ! current_user_can( 'frm_edit_forms' ) ) { |
|
1503
|
|
|
return; |
|
1504
|
|
|
} |
|
1505
|
|
|
|
|
1506
|
|
|
self::move_menu_to_footer(); |
|
1507
|
|
|
|
|
1508
|
|
|
add_action( 'wp_before_admin_bar_render', 'FrmFormsController::admin_bar_configure' ); |
|
1509
|
|
|
FrmAppHelper::load_font_style(); |
|
1510
|
|
|
} |
|
1511
|
|
|
|
|
1512
|
|
|
/** |
|
1513
|
|
|
* @since 4.05.02 |
|
1514
|
|
|
*/ |
|
1515
|
|
|
private static function move_menu_to_footer() { |
|
1516
|
|
|
$settings = FrmAppHelper::get_settings(); |
|
1517
|
|
|
if ( empty( $settings->admin_bar ) ) { |
|
1518
|
|
|
remove_action( 'wp_body_open', 'wp_admin_bar_render', 0 ); |
|
1519
|
|
|
} |
|
1520
|
|
|
} |
|
1521
|
|
|
|
|
1522
|
|
|
public static function admin_bar_configure() { |
|
1523
|
|
|
global $frm_vars; |
|
1524
|
|
|
if ( empty( $frm_vars['forms_loaded'] ) ) { |
|
1525
|
|
|
return; |
|
1526
|
|
|
} |
|
1527
|
|
|
|
|
1528
|
|
|
$actions = array(); |
|
1529
|
|
|
foreach ( $frm_vars['forms_loaded'] as $form ) { |
|
1530
|
|
|
if ( is_object( $form ) ) { |
|
1531
|
|
|
$actions[ $form->id ] = $form->name; |
|
1532
|
|
|
} |
|
1533
|
|
|
unset( $form ); |
|
1534
|
|
|
} |
|
1535
|
|
|
|
|
1536
|
|
|
if ( empty( $actions ) ) { |
|
1537
|
|
|
return; |
|
1538
|
|
|
} |
|
1539
|
|
|
|
|
1540
|
|
|
self::add_menu_to_admin_bar(); |
|
1541
|
|
|
self::add_forms_to_admin_bar( $actions ); |
|
1542
|
|
|
} |
|
1543
|
|
|
|
|
1544
|
|
|
/** |
|
1545
|
|
|
* @since 2.05.07 |
|
1546
|
|
|
*/ |
|
1547
|
|
|
public static function add_menu_to_admin_bar() { |
|
1548
|
|
|
global $wp_admin_bar; |
|
1549
|
|
|
|
|
1550
|
|
|
$wp_admin_bar->add_node( |
|
1551
|
|
|
array( |
|
1552
|
|
|
'id' => 'frm-forms', |
|
1553
|
|
|
'title' => '<span class="ab-icon"></span><span class="ab-label">' . FrmAppHelper::get_menu_name() . '</span>', |
|
1554
|
|
|
'href' => admin_url( 'admin.php?page=formidable' ), |
|
1555
|
|
|
'meta' => array( |
|
1556
|
|
|
'title' => FrmAppHelper::get_menu_name(), |
|
1557
|
|
|
), |
|
1558
|
|
|
) |
|
1559
|
|
|
); |
|
1560
|
|
|
} |
|
1561
|
|
|
|
|
1562
|
|
|
/** |
|
1563
|
|
|
* @since 2.05.07 |
|
1564
|
|
|
*/ |
|
1565
|
|
|
private static function add_forms_to_admin_bar( $actions ) { |
|
1566
|
|
|
global $wp_admin_bar; |
|
1567
|
|
|
|
|
1568
|
|
|
asort( $actions ); |
|
1569
|
|
|
|
|
1570
|
|
|
foreach ( $actions as $form_id => $name ) { |
|
1571
|
|
|
|
|
1572
|
|
|
$wp_admin_bar->add_node( |
|
1573
|
|
|
array( |
|
1574
|
|
|
'parent' => 'frm-forms', |
|
1575
|
|
|
'id' => 'edit_form_' . $form_id, |
|
1576
|
|
|
'title' => empty( $name ) ? __( '(no title)', 'formidable' ) : $name, |
|
1577
|
|
|
'href' => FrmForm::get_edit_link( $form_id ), |
|
1578
|
|
|
) |
|
1579
|
|
|
); |
|
1580
|
|
|
} |
|
1581
|
|
|
} |
|
1582
|
|
|
|
|
1583
|
|
|
/** |
|
1584
|
|
|
* The formidable shortcode |
|
1585
|
|
|
* |
|
1586
|
|
|
* @param array $atts The params from the shortcode. |
|
1587
|
|
|
*/ |
|
1588
|
|
|
public static function get_form_shortcode( $atts ) { |
|
1589
|
|
|
global $frm_vars; |
|
1590
|
|
|
if ( isset( $frm_vars['skip_shortcode'] ) && $frm_vars['skip_shortcode'] ) { |
|
1591
|
|
|
$sc = '[formidable'; |
|
1592
|
|
|
$sc .= FrmAppHelper::array_to_html_params( $atts ); |
|
1593
|
|
|
return $sc . ']'; |
|
1594
|
|
|
} |
|
1595
|
|
|
|
|
1596
|
|
|
$shortcode_atts = shortcode_atts( |
|
1597
|
|
|
array( |
|
1598
|
|
|
'id' => '', |
|
1599
|
|
|
'key' => '', |
|
1600
|
|
|
'title' => false, |
|
1601
|
|
|
'description' => false, |
|
1602
|
|
|
'readonly' => false, |
|
1603
|
|
|
'entry_id' => false, |
|
1604
|
|
|
'fields' => array(), |
|
1605
|
|
|
'exclude_fields' => array(), |
|
1606
|
|
|
'minimize' => false, |
|
1607
|
|
|
), |
|
1608
|
|
|
$atts |
|
1609
|
|
|
); |
|
1610
|
|
|
do_action( 'formidable_shortcode_atts', $shortcode_atts, $atts ); |
|
1611
|
|
|
|
|
1612
|
|
|
return self::show_form( $shortcode_atts['id'], $shortcode_atts['key'], $shortcode_atts['title'], $shortcode_atts['description'], $atts ); |
|
1613
|
|
|
} |
|
1614
|
|
|
|
|
1615
|
|
|
public static function show_form( $id = '', $key = '', $title = false, $description = false, $atts = array() ) { |
|
1616
|
|
|
if ( empty( $id ) ) { |
|
1617
|
|
|
$id = $key; |
|
1618
|
|
|
} |
|
1619
|
|
|
|
|
1620
|
|
|
$form = self::maybe_get_form_to_show( $id ); |
|
1621
|
|
|
if ( ! $form ) { |
|
1622
|
|
|
return __( 'Please select a valid form', 'formidable' ); |
|
1623
|
|
|
} |
|
1624
|
|
|
|
|
1625
|
|
|
FrmAppController::maybe_update_styles(); |
|
1626
|
|
|
|
|
1627
|
|
|
add_action( 'frm_load_form_hooks', 'FrmHooksController::trigger_load_form_hooks' ); |
|
1628
|
|
|
FrmAppHelper::trigger_hook_load( 'form', $form ); |
|
1629
|
|
|
|
|
1630
|
|
|
$form = apply_filters( 'frm_pre_display_form', $form ); |
|
1631
|
|
|
|
|
1632
|
|
|
$frm_settings = FrmAppHelper::get_settings( array( 'current_form' => $form->id ) ); |
|
1633
|
|
|
|
|
1634
|
|
|
if ( self::is_viewable_draft_form( $form ) ) { |
|
1635
|
|
|
// don't show a draft form on a page |
|
1636
|
|
|
$form = __( 'Please select a valid form', 'formidable' ); |
|
1637
|
|
|
} elseif ( ! FrmForm::is_visible_to_user( $form ) ) { |
|
1638
|
|
|
$form = do_shortcode( $frm_settings->login_msg ); |
|
1639
|
|
|
} else { |
|
1640
|
|
|
do_action( 'frm_pre_get_form', $form ); |
|
1641
|
|
|
$form = self::get_form( $form, $title, $description, $atts ); |
|
1642
|
|
|
|
|
1643
|
|
|
/** |
|
1644
|
|
|
* Use this shortcode to check for external shortcodes that may span |
|
1645
|
|
|
* across multiple fields in the customizable HTML |
|
1646
|
|
|
* |
|
1647
|
|
|
* @since 2.0.8 |
|
1648
|
|
|
*/ |
|
1649
|
|
|
$form = apply_filters( 'frm_filter_final_form', $form ); |
|
1650
|
|
|
} |
|
1651
|
|
|
|
|
1652
|
|
|
return $form; |
|
1653
|
|
|
} |
|
1654
|
|
|
|
|
1655
|
|
|
private static function maybe_get_form_to_show( $id ) { |
|
1656
|
|
|
$form = false; |
|
1657
|
|
|
|
|
1658
|
|
|
if ( ! empty( $id ) ) { // no form id or key set |
|
1659
|
|
|
$form = FrmForm::getOne( $id ); |
|
1660
|
|
|
if ( ! $form || $form->parent_form_id || $form->status == 'trash' ) { |
|
1661
|
|
|
$form = false; |
|
1662
|
|
|
} |
|
1663
|
|
|
} |
|
1664
|
|
|
|
|
1665
|
|
|
return $form; |
|
1666
|
|
|
} |
|
1667
|
|
|
|
|
1668
|
|
|
private static function is_viewable_draft_form( $form ) { |
|
1669
|
|
|
return $form->status == 'draft' && current_user_can( 'frm_edit_forms' ) && ! FrmAppHelper::is_preview_page(); |
|
1670
|
|
|
} |
|
1671
|
|
|
|
|
1672
|
|
|
public static function get_form( $form, $title, $description, $atts = array() ) { |
|
1673
|
|
|
ob_start(); |
|
1674
|
|
|
|
|
1675
|
|
|
do_action( 'frm_before_get_form', $atts ); |
|
1676
|
|
|
|
|
1677
|
|
|
self::get_form_contents( $form, $title, $description, $atts ); |
|
1678
|
|
|
self::enqueue_scripts( FrmForm::get_params( $form ) ); |
|
1679
|
|
|
|
|
1680
|
|
|
$contents = ob_get_contents(); |
|
1681
|
|
|
ob_end_clean(); |
|
1682
|
|
|
|
|
1683
|
|
|
self::maybe_minimize_form( $atts, $contents ); |
|
1684
|
|
|
|
|
1685
|
|
|
return $contents; |
|
1686
|
|
|
} |
|
1687
|
|
|
|
|
1688
|
|
|
public static function enqueue_scripts( $params ) { |
|
1689
|
|
|
do_action( 'frm_enqueue_form_scripts', $params ); |
|
1690
|
|
|
} |
|
1691
|
|
|
|
|
1692
|
|
|
public static function get_form_contents( $form, $title, $description, $atts ) { |
|
1693
|
|
|
$params = FrmForm::get_params( $form ); |
|
1694
|
|
|
$errors = self::get_saved_errors( $form, $params ); |
|
1695
|
|
|
$fields = FrmFieldsHelper::get_form_fields( $form->id, $errors ); |
|
1696
|
|
|
$reset = false; |
|
1697
|
|
|
$pass_args = compact( 'form', 'fields', 'errors', 'title', 'description', 'reset' ); |
|
1698
|
|
|
|
|
1699
|
|
|
$handle_process_here = $params['action'] == 'create' && $params['posted_form_id'] == $form->id && $_POST; |
|
1700
|
|
|
|
|
1701
|
|
|
if ( ! $handle_process_here ) { |
|
1702
|
|
|
do_action( 'frm_display_form_action', $params, $fields, $form, $title, $description ); |
|
1703
|
|
|
if ( apply_filters( 'frm_continue_to_new', true, $form->id, $params['action'] ) ) { |
|
1704
|
|
|
self::show_form_after_submit( $pass_args ); |
|
1705
|
|
|
} |
|
1706
|
|
|
} elseif ( ! empty( $errors ) ) { |
|
1707
|
|
|
self::show_form_after_submit( $pass_args ); |
|
1708
|
|
|
|
|
1709
|
|
|
} else { |
|
1710
|
|
|
|
|
1711
|
|
|
do_action( 'frm_validate_form_creation', $params, $fields, $form, $title, $description ); |
|
1712
|
|
|
|
|
1713
|
|
|
if ( apply_filters( 'frm_continue_to_create', true, $form->id ) ) { |
|
1714
|
|
|
$entry_id = self::just_created_entry( $form->id ); |
|
1715
|
|
|
$pass_args['entry_id'] = $entry_id; |
|
1716
|
|
|
$pass_args['reset'] = true; |
|
1717
|
|
|
$pass_args['conf_method'] = self::get_confirmation_method( compact( 'form', 'entry_id' ) ); |
|
1718
|
|
|
|
|
1719
|
|
|
self::run_success_action( $pass_args ); |
|
1720
|
|
|
|
|
1721
|
|
|
do_action( |
|
1722
|
|
|
'frm_after_entry_processed', |
|
1723
|
|
|
array( |
|
1724
|
|
|
'entry_id' => $entry_id, |
|
1725
|
|
|
'form' => $form, |
|
1726
|
|
|
) |
|
1727
|
|
|
); |
|
1728
|
|
|
} |
|
1729
|
|
|
} |
|
1730
|
|
|
} |
|
1731
|
|
|
|
|
1732
|
|
|
/** |
|
1733
|
|
|
* If the form was processed earlier (init), get the generated errors |
|
1734
|
|
|
* |
|
1735
|
|
|
* @since 2.05 |
|
1736
|
|
|
*/ |
|
1737
|
|
|
private static function get_saved_errors( $form, $params ) { |
|
1738
|
|
|
global $frm_vars; |
|
1739
|
|
|
|
|
1740
|
|
|
if ( $params['posted_form_id'] == $form->id && $_POST && isset( $frm_vars['created_entries'][ $form->id ] ) ) { |
|
1741
|
|
|
$errors = $frm_vars['created_entries'][ $form->id ]['errors']; |
|
1742
|
|
|
} else { |
|
1743
|
|
|
$errors = array(); |
|
1744
|
|
|
} |
|
1745
|
|
|
|
|
1746
|
|
|
return $errors; |
|
1747
|
|
|
} |
|
1748
|
|
|
|
|
1749
|
|
|
/** |
|
1750
|
|
|
* @since 2.2.7 |
|
1751
|
|
|
*/ |
|
1752
|
|
|
public static function just_created_entry( $form_id ) { |
|
1753
|
|
|
global $frm_vars; |
|
1754
|
|
|
|
|
1755
|
|
|
return ( isset( $frm_vars['created_entries'] ) && isset( $frm_vars['created_entries'][ $form_id ] ) && isset( $frm_vars['created_entries'][ $form_id ]['entry_id'] ) ) ? $frm_vars['created_entries'][ $form_id ]['entry_id'] : 0; |
|
1756
|
|
|
} |
|
1757
|
|
|
|
|
1758
|
|
|
/** |
|
1759
|
|
|
* @since 3.0 |
|
1760
|
|
|
*/ |
|
1761
|
|
|
private static function get_confirmation_method( $atts ) { |
|
1762
|
|
|
$opt = 'success_action'; |
|
1763
|
|
|
$method = ( isset( $atts['form']->options[ $opt ] ) && ! empty( $atts['form']->options[ $opt ] ) ) ? $atts['form']->options[ $opt ] : 'message'; |
|
1764
|
|
|
$method = apply_filters( 'frm_success_filter', $method, $atts['form'], 'create' ); |
|
1765
|
|
|
|
|
1766
|
|
|
if ( $method != 'message' && ( ! $atts['entry_id'] || ! is_numeric( $atts['entry_id'] ) ) ) { |
|
1767
|
|
|
$method = 'message'; |
|
1768
|
|
|
} |
|
1769
|
|
|
|
|
1770
|
|
|
return $method; |
|
1771
|
|
|
} |
|
1772
|
|
|
|
|
1773
|
|
|
public static function maybe_trigger_redirect( $form, $params, $args ) { |
|
1774
|
|
|
if ( ! isset( $params['id'] ) ) { |
|
1775
|
|
|
global $frm_vars; |
|
1776
|
|
|
$params['id'] = $frm_vars['created_entries'][ $form->id ]['entry_id']; |
|
1777
|
|
|
} |
|
1778
|
|
|
|
|
1779
|
|
|
$conf_method = self::get_confirmation_method( |
|
1780
|
|
|
array( |
|
1781
|
|
|
'form' => $form, |
|
1782
|
|
|
'entry_id' => $params['id'], |
|
1783
|
|
|
) |
|
1784
|
|
|
); |
|
1785
|
|
|
|
|
1786
|
|
|
if ( 'redirect' === $conf_method ) { |
|
1787
|
|
|
self::trigger_redirect( $form, $params, $args ); |
|
1788
|
|
|
} |
|
1789
|
|
|
} |
|
1790
|
|
|
|
|
1791
|
|
|
public static function trigger_redirect( $form, $params, $args ) { |
|
1792
|
|
|
$success_args = array( |
|
1793
|
|
|
'action' => $params['action'], |
|
1794
|
|
|
'conf_method' => 'redirect', |
|
1795
|
|
|
'form' => $form, |
|
1796
|
|
|
'entry_id' => $params['id'], |
|
1797
|
|
|
); |
|
1798
|
|
|
|
|
1799
|
|
|
if ( isset( $args['ajax'] ) ) { |
|
1800
|
|
|
$success_args['ajax'] = $args['ajax']; |
|
1801
|
|
|
} |
|
1802
|
|
|
|
|
1803
|
|
|
self::run_success_action( $success_args ); |
|
1804
|
|
|
} |
|
1805
|
|
|
|
|
1806
|
|
|
/** |
|
1807
|
|
|
* Used when the success action is not 'message' |
|
1808
|
|
|
* |
|
1809
|
|
|
* @since 2.05 |
|
1810
|
|
|
*/ |
|
1811
|
|
|
public static function run_success_action( $args ) { |
|
1812
|
|
|
$extra_args = $args; |
|
1813
|
|
|
unset( $extra_args['form'] ); |
|
1814
|
|
|
|
|
1815
|
|
|
do_action( 'frm_success_action', $args['conf_method'], $args['form'], $args['form']->options, $args['entry_id'], $extra_args ); |
|
1816
|
|
|
|
|
1817
|
|
|
$opt = ( ! isset( $args['action'] ) || $args['action'] == 'create' ) ? 'success' : 'edit'; |
|
1818
|
|
|
|
|
1819
|
|
|
$args['success_opt'] = $opt; |
|
1820
|
|
|
if ( $args['conf_method'] == 'page' && is_numeric( $args['form']->options[ $opt . '_page_id' ] ) ) { |
|
1821
|
|
|
self::load_page_after_submit( $args ); |
|
1822
|
|
|
} elseif ( $args['conf_method'] == 'redirect' ) { |
|
1823
|
|
|
self::redirect_after_submit( $args ); |
|
1824
|
|
|
} else { |
|
1825
|
|
|
self::show_message_after_save( $args ); |
|
1826
|
|
|
} |
|
1827
|
|
|
} |
|
1828
|
|
|
|
|
1829
|
|
|
/** |
|
1830
|
|
|
* @since 3.0 |
|
1831
|
|
|
*/ |
|
1832
|
|
|
private static function load_page_after_submit( $args ) { |
|
1833
|
|
|
global $post; |
|
1834
|
|
|
$opt = $args['success_opt']; |
|
1835
|
|
|
if ( ! $post || $args['form']->options[ $opt . '_page_id' ] != $post->ID ) { |
|
1836
|
|
|
$page = get_post( $args['form']->options[ $opt . '_page_id' ] ); |
|
1837
|
|
|
$old_post = $post; |
|
1838
|
|
|
$post = $page; |
|
1839
|
|
|
$content = apply_filters( 'frm_content', $page->post_content, $args['form'], $args['entry_id'] ); |
|
1840
|
|
|
echo apply_filters( 'the_content', $content ); // WPCS: XSS ok. |
|
1841
|
|
|
$post = $old_post; |
|
1842
|
|
|
} |
|
1843
|
|
|
} |
|
1844
|
|
|
|
|
1845
|
|
|
/** |
|
1846
|
|
|
* @since 3.0 |
|
1847
|
|
|
*/ |
|
1848
|
|
|
private static function redirect_after_submit( $args ) { |
|
1849
|
|
|
global $frm_vars; |
|
1850
|
|
|
|
|
1851
|
|
|
add_filter( 'frm_use_wpautop', '__return_false' ); |
|
1852
|
|
|
|
|
1853
|
|
|
$opt = $args['success_opt']; |
|
1854
|
|
|
$success_url = trim( $args['form']->options[ $opt . '_url' ] ); |
|
1855
|
|
|
$success_url = apply_filters( 'frm_content', $success_url, $args['form'], $args['entry_id'] ); |
|
1856
|
|
|
$success_url = do_shortcode( $success_url ); |
|
1857
|
|
|
|
|
1858
|
|
|
$success_msg = isset( $args['form']->options[ $opt . '_msg' ] ) ? $args['form']->options[ $opt . '_msg' ] : __( 'Please wait while you are redirected.', 'formidable' ); |
|
1859
|
|
|
|
|
1860
|
|
|
$redirect_msg = self::get_redirect_message( $success_url, $success_msg, $args ); |
|
1861
|
|
|
|
|
1862
|
|
|
$args['id'] = $args['entry_id']; |
|
1863
|
|
|
FrmEntriesController::delete_entry_before_redirect( $success_url, $args['form'], $args ); |
|
1864
|
|
|
|
|
1865
|
|
|
add_filter( 'frm_redirect_url', 'FrmEntriesController::prepare_redirect_url' ); |
|
1866
|
|
|
$success_url = apply_filters( 'frm_redirect_url', $success_url, $args['form'], $args ); |
|
1867
|
|
|
|
|
1868
|
|
|
$doing_ajax = FrmAppHelper::doing_ajax(); |
|
1869
|
|
|
|
|
1870
|
|
|
if ( isset( $args['ajax'] ) && $args['ajax'] && $doing_ajax ) { |
|
1871
|
|
|
echo json_encode( array( 'redirect' => $success_url ) ); |
|
1872
|
|
|
wp_die(); |
|
1873
|
|
|
} elseif ( ! headers_sent() ) { |
|
1874
|
|
|
wp_redirect( esc_url_raw( $success_url ) ); |
|
1875
|
|
|
die(); // do not use wp_die or redirect fails |
|
1876
|
|
|
} else { |
|
1877
|
|
|
add_filter( 'frm_use_wpautop', '__return_true' ); |
|
1878
|
|
|
|
|
1879
|
|
|
echo $redirect_msg; // WPCS: XSS ok. |
|
1880
|
|
|
echo "<script type='text/javascript'>window.onload = function(){setTimeout(window.location='" . esc_url_raw( $success_url ) . "', 8000);}</script>"; |
|
1881
|
|
|
} |
|
1882
|
|
|
} |
|
1883
|
|
|
|
|
1884
|
|
|
/** |
|
1885
|
|
|
* @since 3.0 |
|
1886
|
|
|
* |
|
1887
|
|
|
* @param string $success_url |
|
1888
|
|
|
* @param string $success_msg |
|
1889
|
|
|
* @param array $args |
|
1890
|
|
|
*/ |
|
1891
|
|
|
private static function get_redirect_message( $success_url, $success_msg, $args ) { |
|
1892
|
|
|
$redirect_msg = '<div class="' . esc_attr( FrmFormsHelper::get_form_style_class( $args['form'] ) ) . '"><div class="frm-redirect-msg frm_message" role="status">' . $success_msg . '<br/>' . |
|
1893
|
|
|
/* translators: %1$s: Start link HTML, %2$s: End link HTML */ |
|
1894
|
|
|
sprintf( __( '%1$sClick here%2$s if you are not automatically redirected.', 'formidable' ), '<a href="' . esc_url( $success_url ) . '">', '</a>' ) . |
|
1895
|
|
|
'</div></div>'; |
|
1896
|
|
|
|
|
1897
|
|
|
$redirect_args = array( |
|
1898
|
|
|
'entry_id' => $args['entry_id'], |
|
1899
|
|
|
'form_id' => $args['form']->id, |
|
1900
|
|
|
'form' => $args['form'], |
|
1901
|
|
|
); |
|
1902
|
|
|
|
|
1903
|
|
|
return apply_filters( 'frm_redirect_msg', $redirect_msg, $redirect_args ); |
|
1904
|
|
|
} |
|
1905
|
|
|
|
|
1906
|
|
|
/** |
|
1907
|
|
|
* Prepare to show the success message and empty form after submit |
|
1908
|
|
|
* |
|
1909
|
|
|
* @since 2.05 |
|
1910
|
|
|
*/ |
|
1911
|
|
|
public static function show_message_after_save( $atts ) { |
|
1912
|
|
|
$atts['message'] = self::prepare_submit_message( $atts['form'], $atts['entry_id'] ); |
|
1913
|
|
|
|
|
1914
|
|
|
if ( ! isset( $atts['form']->options['show_form'] ) || $atts['form']->options['show_form'] ) { |
|
1915
|
|
|
self::show_form_after_submit( $atts ); |
|
1916
|
|
|
} else { |
|
1917
|
|
|
self::show_lone_success_messsage( $atts ); |
|
1918
|
|
|
} |
|
1919
|
|
|
} |
|
1920
|
|
|
|
|
1921
|
|
|
/** |
|
1922
|
|
|
* Show an empty form |
|
1923
|
|
|
* |
|
1924
|
|
|
* @since 2.05 |
|
1925
|
|
|
*/ |
|
1926
|
|
|
private static function show_form_after_submit( $args ) { |
|
1927
|
|
|
self::fill_atts_for_form_display( $args ); |
|
1928
|
|
|
|
|
1929
|
|
|
$errors = $args['errors']; |
|
1930
|
|
|
$message = $args['message']; |
|
1931
|
|
|
$form = $args['form']; |
|
1932
|
|
|
$title = $args['title']; |
|
1933
|
|
|
$description = $args['description']; |
|
1934
|
|
|
|
|
1935
|
|
|
if ( empty( $args['fields'] ) ) { |
|
1936
|
|
|
$values = array(); |
|
1937
|
|
|
} else { |
|
1938
|
|
|
$values = FrmEntriesHelper::setup_new_vars( $args['fields'], $form, $args['reset'] ); |
|
1939
|
|
|
} |
|
1940
|
|
|
unset( $args ); |
|
1941
|
|
|
|
|
1942
|
|
|
$include_form_tag = apply_filters( 'frm_include_form_tag', true, $form ); |
|
1943
|
|
|
|
|
1944
|
|
|
$frm_settings = FrmAppHelper::get_settings(); |
|
1945
|
|
|
$submit = isset( $form->options['submit_value'] ) ? $form->options['submit_value'] : $frm_settings->submit_value; |
|
1946
|
|
|
|
|
1947
|
|
|
global $frm_vars; |
|
1948
|
|
|
self::maybe_load_css( $form, $values['custom_style'], $frm_vars['load_css'] ); |
|
1949
|
|
|
|
|
1950
|
|
|
$message_placement = self::message_placement( $form, $message ); |
|
1951
|
|
|
|
|
1952
|
|
|
include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/new.php' ); |
|
1953
|
|
|
} |
|
1954
|
|
|
|
|
1955
|
|
|
/** |
|
1956
|
|
|
* @return string - 'before', 'after', or 'submit' |
|
1957
|
|
|
* |
|
1958
|
|
|
* @since 4.05.02 |
|
1959
|
|
|
*/ |
|
1960
|
|
|
private static function message_placement( $form, $message ) { |
|
1961
|
|
|
$place = 'before'; |
|
1962
|
|
|
|
|
1963
|
|
|
if ( $message && isset( $form->options['form_class'] ) ) { |
|
1964
|
|
|
if ( strpos( $form->options['form_class'], 'frm_below_success' ) !== false ) { |
|
1965
|
|
|
$place = 'after'; |
|
1966
|
|
|
} elseif ( strpos( $form->options['form_class'], 'frm_inline_success' ) !== false ) { |
|
1967
|
|
|
$place = 'submit'; |
|
1968
|
|
|
} |
|
1969
|
|
|
} |
|
1970
|
|
|
|
|
1971
|
|
|
/** |
|
1972
|
|
|
* @return string - 'before' or 'after' |
|
1973
|
|
|
* |
|
1974
|
|
|
* @since 4.05.02 |
|
1975
|
|
|
*/ |
|
1976
|
|
|
return apply_filters( 'frm_message_placement', $place, compact( 'form', 'message' ) ); |
|
1977
|
|
|
} |
|
1978
|
|
|
|
|
1979
|
|
|
/** |
|
1980
|
|
|
* Get all the values needed on the new.php entry page |
|
1981
|
|
|
* |
|
1982
|
|
|
* @since 2.05 |
|
1983
|
|
|
*/ |
|
1984
|
|
|
private static function fill_atts_for_form_display( &$args ) { |
|
1985
|
|
|
$defaults = array( |
|
1986
|
|
|
'errors' => array(), |
|
1987
|
|
|
'message' => '', |
|
1988
|
|
|
'fields' => array(), |
|
1989
|
|
|
'form' => array(), |
|
1990
|
|
|
'title' => true, |
|
1991
|
|
|
'description' => false, |
|
1992
|
|
|
'reset' => false, |
|
1993
|
|
|
); |
|
1994
|
|
|
$args = wp_parse_args( $args, $defaults ); |
|
1995
|
|
|
} |
|
1996
|
|
|
|
|
1997
|
|
|
/** |
|
1998
|
|
|
* Show the success message without the form |
|
1999
|
|
|
* |
|
2000
|
|
|
* @since 2.05 |
|
2001
|
|
|
*/ |
|
2002
|
|
|
private static function show_lone_success_messsage( $atts ) { |
|
2003
|
|
|
global $frm_vars; |
|
2004
|
|
|
$values = FrmEntriesHelper::setup_new_vars( $atts['fields'], $atts['form'], true ); |
|
2005
|
|
|
self::maybe_load_css( $atts['form'], $values['custom_style'], $frm_vars['load_css'] ); |
|
2006
|
|
|
|
|
2007
|
|
|
$include_extra_container = 'frm_forms' . FrmFormsHelper::get_form_style_class( $values ); |
|
2008
|
|
|
|
|
2009
|
|
|
$errors = array(); |
|
2010
|
|
|
$form = $atts['form']; |
|
2011
|
|
|
$message = $atts['message']; |
|
2012
|
|
|
|
|
2013
|
|
|
include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/errors.php' ); |
|
2014
|
|
|
} |
|
2015
|
|
|
|
|
2016
|
|
|
/** |
|
2017
|
|
|
* Prepare the success message before it's shown |
|
2018
|
|
|
* |
|
2019
|
|
|
* @since 2.05 |
|
2020
|
|
|
*/ |
|
2021
|
|
|
private static function prepare_submit_message( $form, $entry_id ) { |
|
2022
|
|
|
$frm_settings = FrmAppHelper::get_settings( array( 'current_form' => $form->id ) ); |
|
2023
|
|
|
|
|
2024
|
|
|
if ( $entry_id && is_numeric( $entry_id ) ) { |
|
2025
|
|
|
$message = isset( $form->options['success_msg'] ) ? $form->options['success_msg'] : $frm_settings->success_msg; |
|
2026
|
|
|
$class = 'frm_message'; |
|
2027
|
|
|
} else { |
|
2028
|
|
|
$message = $frm_settings->failed_msg; |
|
2029
|
|
|
$class = FrmFormsHelper::form_error_class(); |
|
2030
|
|
|
} |
|
2031
|
|
|
|
|
2032
|
|
|
$message = FrmFormsHelper::get_success_message( compact( 'message', 'form', 'entry_id', 'class' ) ); |
|
2033
|
|
|
|
|
2034
|
|
|
return apply_filters( 'frm_main_feedback', $message, $form, $entry_id ); |
|
2035
|
|
|
} |
|
2036
|
|
|
|
|
2037
|
|
|
public static function front_head() { |
|
2038
|
|
|
$version = FrmAppHelper::plugin_version(); |
|
2039
|
|
|
$suffix = FrmAppHelper::js_suffix(); |
|
2040
|
|
|
|
|
2041
|
|
|
if ( ! empty( $suffix ) && self::has_combo_js_file() ) { |
|
2042
|
|
|
wp_register_script( 'formidable', FrmAppHelper::plugin_url() . '/js/frm.min.js', array( 'jquery' ), $version, true ); |
|
2043
|
|
|
} else { |
|
2044
|
|
|
wp_register_script( 'formidable', FrmAppHelper::plugin_url() . "/js/formidable{$suffix}.js", array( 'jquery' ), $version, true ); |
|
2045
|
|
|
} |
|
2046
|
|
|
|
|
2047
|
|
|
add_filter( 'script_loader_tag', 'FrmFormsController::defer_script_loading', 10, 2 ); |
|
2048
|
|
|
|
|
2049
|
|
|
if ( FrmAppHelper::is_admin() ) { |
|
2050
|
|
|
// don't load this in back-end |
|
2051
|
|
|
return; |
|
2052
|
|
|
} |
|
2053
|
|
|
|
|
2054
|
|
|
FrmAppHelper::localize_script( 'front' ); |
|
2055
|
|
|
FrmStylesController::enqueue_css( 'register' ); |
|
2056
|
|
|
} |
|
2057
|
|
|
|
|
2058
|
|
|
/** |
|
2059
|
|
|
* @since 3.0 |
|
2060
|
|
|
*/ |
|
2061
|
|
|
public static function has_combo_js_file() { |
|
2062
|
|
|
return is_readable( FrmAppHelper::plugin_path() . '/js/frm.min.js' ); |
|
2063
|
|
|
} |
|
2064
|
|
|
|
|
2065
|
|
|
public static function maybe_load_css( $form, $this_load, $global_load ) { |
|
2066
|
|
|
$load_css = FrmForm::is_form_loaded( $form, $this_load, $global_load ); |
|
2067
|
|
|
|
|
2068
|
|
|
if ( ! $load_css ) { |
|
2069
|
|
|
return; |
|
2070
|
|
|
} |
|
2071
|
|
|
|
|
2072
|
|
|
global $frm_vars; |
|
2073
|
|
|
self::footer_js( 'header' ); |
|
2074
|
|
|
$frm_vars['css_loaded'] = true; |
|
2075
|
|
|
|
|
2076
|
|
|
self::load_late_css(); |
|
2077
|
|
|
} |
|
2078
|
|
|
|
|
2079
|
|
|
/** |
|
2080
|
|
|
* If css is loaded only on applicable pages, include it before the form loads |
|
2081
|
|
|
* to prevent a flash of unstyled form. |
|
2082
|
|
|
* |
|
2083
|
|
|
* @since 4.01 |
|
2084
|
|
|
*/ |
|
2085
|
|
|
private static function load_late_css() { |
|
2086
|
|
|
$frm_settings = FrmAppHelper::get_settings(); |
|
2087
|
|
|
$late_css = $frm_settings->load_style === 'dynamic'; |
|
2088
|
|
|
if ( ! $late_css ) { |
|
2089
|
|
|
return; |
|
2090
|
|
|
} |
|
2091
|
|
|
|
|
2092
|
|
|
global $wp_styles; |
|
2093
|
|
|
if ( is_array( $wp_styles->queue ) && in_array( 'formidable', $wp_styles->queue ) ) { |
|
2094
|
|
|
wp_print_styles( 'formidable' ); |
|
2095
|
|
|
} |
|
2096
|
|
|
} |
|
2097
|
|
|
|
|
2098
|
|
|
public static function defer_script_loading( $tag, $handle ) { |
|
2099
|
|
|
if ( 'recaptcha-api' == $handle && ! strpos( $tag, 'defer' ) ) { |
|
2100
|
|
|
$tag = str_replace( ' src', ' defer="defer" async="async" src', $tag ); |
|
2101
|
|
|
} |
|
2102
|
|
|
|
|
2103
|
|
|
return $tag; |
|
2104
|
|
|
} |
|
2105
|
|
|
|
|
2106
|
|
|
public static function footer_js( $location = 'footer' ) { |
|
2107
|
|
|
global $frm_vars; |
|
2108
|
|
|
|
|
2109
|
|
|
FrmStylesController::enqueue_css(); |
|
2110
|
|
|
|
|
2111
|
|
|
if ( ! FrmAppHelper::is_admin() && $location != 'header' && ! empty( $frm_vars['forms_loaded'] ) ) { |
|
2112
|
|
|
// load formidable js |
|
2113
|
|
|
wp_enqueue_script( 'formidable' ); |
|
2114
|
|
|
} |
|
2115
|
|
|
} |
|
2116
|
|
|
|
|
2117
|
|
|
/** |
|
2118
|
|
|
* @since 2.0.8 |
|
2119
|
|
|
*/ |
|
2120
|
|
|
private static function maybe_minimize_form( $atts, &$content ) { |
|
2121
|
|
|
// check if minimizing is turned on |
|
2122
|
|
|
if ( self::is_minification_on( $atts ) ) { |
|
2123
|
|
|
$content = str_replace( array( "\r\n", "\r", "\n", "\t", ' ' ), '', $content ); |
|
2124
|
|
|
} |
|
2125
|
|
|
} |
|
2126
|
|
|
|
|
2127
|
|
|
/** |
|
2128
|
|
|
* @since 2.0.8 |
|
2129
|
|
|
* @return boolean |
|
2130
|
|
|
*/ |
|
2131
|
|
|
private static function is_minification_on( $atts ) { |
|
2132
|
|
|
return isset( $atts['minimize'] ) && ! empty( $atts['minimize'] ); |
|
2133
|
|
|
} |
|
2134
|
|
|
|
|
2135
|
|
|
/** |
|
2136
|
|
|
* @deprecated 4.0 |
|
2137
|
|
|
*/ |
|
2138
|
|
|
public static function new_form( $values = array() ) { |
|
2139
|
|
|
FrmDeprecated::new_form( $values ); |
|
2140
|
|
|
} |
|
2141
|
|
|
|
|
2142
|
|
|
/** |
|
2143
|
|
|
* @deprecated 4.0 |
|
2144
|
|
|
*/ |
|
2145
|
|
|
public static function create( $values = array() ) { |
|
2146
|
|
|
_deprecated_function( __METHOD__, '4.0', 'FrmFormsController::update' ); |
|
2147
|
|
|
self::update( $values ); |
|
2148
|
|
|
} |
|
2149
|
|
|
|
|
2150
|
|
|
/** |
|
2151
|
|
|
* @deprecated 1.07.05 |
|
2152
|
|
|
* @codeCoverageIgnore |
|
2153
|
|
|
*/ |
|
2154
|
|
|
public static function add_default_templates( $path, $default = true, $template = true ) { |
|
2155
|
|
|
FrmDeprecated::add_default_templates( $path, $default, $template ); |
|
2156
|
|
|
} |
|
2157
|
|
|
|
|
2158
|
|
|
/** |
|
2159
|
|
|
* @deprecated 3.0 |
|
2160
|
|
|
* @codeCoverageIgnore |
|
2161
|
|
|
*/ |
|
2162
|
|
|
public static function bulk_create_template( $ids ) { |
|
2163
|
|
|
return FrmDeprecated::bulk_create_template( $ids ); |
|
2164
|
|
|
} |
|
2165
|
|
|
|
|
2166
|
|
|
/** |
|
2167
|
|
|
* @deprecated 2.03 |
|
2168
|
|
|
* @codeCoverageIgnore |
|
2169
|
|
|
*/ |
|
2170
|
|
|
public static function register_pro_scripts() { |
|
2171
|
|
|
FrmDeprecated::register_pro_scripts(); |
|
2172
|
|
|
} |
|
2173
|
|
|
|
|
2174
|
|
|
/** |
|
2175
|
|
|
* @deprecated 3.0 |
|
2176
|
|
|
* @codeCoverageIgnore |
|
2177
|
|
|
*/ |
|
2178
|
|
|
public static function edit_key() { |
|
2179
|
|
|
FrmDeprecated::edit_key(); |
|
2180
|
|
|
} |
|
2181
|
|
|
|
|
2182
|
|
|
/** |
|
2183
|
|
|
* @deprecated 3.0 |
|
2184
|
|
|
* @codeCoverageIgnore |
|
2185
|
|
|
*/ |
|
2186
|
|
|
public static function edit_description() { |
|
2187
|
|
|
FrmDeprecated::edit_description(); |
|
2188
|
|
|
} |
|
2189
|
|
|
|
|
2190
|
|
|
/** |
|
2191
|
|
|
* @deprecated 4.08 |
|
2192
|
|
|
* @since 3.06 |
|
2193
|
|
|
*/ |
|
2194
|
|
|
public static function add_new() { |
|
2195
|
|
|
_deprecated_function( __FUNCTION__, '4.08' ); |
|
2196
|
|
|
} |
|
2197
|
|
|
} |
|
2198
|
|
|
|
This check looks for function or method calls that always return null and whose return value is assigned to a variable.
The method
getObject()can return nothing but null, so it makes no sense to assign that value to a variable.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.