Version Description
Download this release
Release Info
Developer | sswells |
Plugin | Formidable Forms – Form Builder for WordPress |
Version | 2.0.09b |
Comparing to | |
See all releases |
Code changes from version 2.0.08 to 2.0.09b
- classes/controllers/FrmAppController.php +27 -147
- classes/controllers/FrmEntriesController.php +23 -150
- classes/controllers/FrmFieldsController.php +15 -13
- classes/controllers/FrmFormActionsController.php +4 -4
- classes/controllers/FrmFormsController.php +112 -72
- classes/controllers/FrmHooksController.php +13 -6
- classes/controllers/FrmStylesController.php +71 -0
- classes/helpers/FrmAppHelper.php +87 -17
- classes/helpers/FrmEntriesHelper.php +56 -340
- classes/helpers/FrmEntriesListHelper.php +25 -2
- classes/helpers/FrmFieldsHelper.php +69 -134
- classes/helpers/FrmFormActionsHelper.php +14 -105
- classes/helpers/FrmFormsHelper.php +16 -76
- classes/helpers/FrmFormsListHelper.php +10 -0
- classes/helpers/FrmListHelper.php +4 -0
- classes/helpers/FrmXMLHelper.php +48 -17
- classes/models/FrmDb.php +6 -3
- classes/models/FrmEntry.php +53 -282
- classes/models/FrmEntryFormat.php +324 -0
- classes/models/FrmEntryMeta.php +3 -3
- classes/models/FrmEntryValidate.php +279 -0
- classes/models/FrmField.php +172 -2
- classes/models/FrmForm.php +169 -1
- classes/models/FrmFormAction.php +114 -13
- classes/models/FrmNotification.php +1 -1
- classes/views/frm-entries/form.php +1 -6
- classes/views/frm-entries/sidebar-shared.php +2 -4
- classes/views/frm-fields/import_choices.php +1 -1
- classes/views/frm-fields/input.php +4 -4
- classes/views/frm-fields/show-build.php +5 -5
- classes/views/frm-form-actions/default_actions.php +7 -14
- classes/views/frm-forms/add_field.php +12 -6
- classes/views/frm-forms/add_field_links.php +1 -1
- classes/views/shared/mb_adv_info.php +4 -4
- css/_single_theme.css.php +9 -0
- css/custom_theme.css.php +64 -11
- css/frm_admin.css +4 -1
- js/formidable.min.js +59 -57
classes/controllers/FrmAppController.php
CHANGED
@@ -3,25 +3,24 @@
|
|
3 |
class FrmAppController {
|
4 |
|
5 |
public static function menu() {
|
6 |
-
add_filter( 'plugin_action_links_' . FrmAppHelper::plugin_folder() . '/formidable.php', 'FrmAppController::settings_link' );
|
7 |
-
add_filter( 'admin_body_class', 'FrmAppController::wp_admin_body_class' );
|
8 |
-
|
9 |
FrmAppHelper::maybe_add_permissions();
|
10 |
-
|
11 |
if ( ! current_user_can( 'frm_view_forms' ) ) {
|
12 |
return;
|
13 |
}
|
14 |
|
15 |
-
$count = count( get_post_types( array( 'show_ui' => true, '_builtin' => false, 'show_in_menu' => true ) ) );
|
16 |
-
$pos = ( (int) $count > 0 ) ? '22.7' : '29.3';
|
17 |
-
$pos = apply_filters( 'frm_menu_position', $pos );
|
18 |
-
|
19 |
$frm_settings = FrmAppHelper::get_settings();
|
20 |
-
add_menu_page( 'Formidable', $frm_settings->menu, 'frm_view_forms', 'formidable', 'FrmFormsController::route', FrmAppHelper::plugin_url() . '/images/form_16.png',
|
21 |
}
|
22 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
public static function load_wp_admin_style() {
|
24 |
-
|
25 |
}
|
26 |
|
27 |
public static function get_form_nav( $form, $show_nav = '', $title = 'show' ) {
|
@@ -32,10 +31,10 @@ class FrmAppController {
|
|
32 |
return;
|
33 |
}
|
34 |
|
35 |
-
$current_page = isset( $_GET['page'] ) ? FrmAppHelper::simple_get( 'page', 'sanitize_title' ) :
|
36 |
|
37 |
if ( $form ) {
|
38 |
-
|
39 |
|
40 |
if ( is_object( $form ) ) {
|
41 |
$id = $form->id;
|
@@ -149,7 +148,7 @@ class FrmAppController {
|
|
149 |
wp_enqueue_style( 'widgets' );
|
150 |
wp_enqueue_script( 'formidable' );
|
151 |
wp_enqueue_script( 'formidable_admin' );
|
152 |
-
|
153 |
|
154 |
wp_enqueue_style( 'formidable-admin' );
|
155 |
add_thickbox();
|
@@ -173,7 +172,7 @@ class FrmAppController {
|
|
173 |
wp_enqueue_script( 'jquery-ui-draggable' );
|
174 |
wp_enqueue_script( 'formidable_admin' );
|
175 |
wp_enqueue_style( 'formidable-admin' );
|
176 |
-
|
177 |
}
|
178 |
} else if ( $pagenow == 'widgets.php' ) {
|
179 |
FrmAppHelper::load_admin_wide_js();
|
@@ -216,145 +215,27 @@ class FrmAppController {
|
|
216 |
self::install( $old_db_version );
|
217 |
}
|
218 |
}
|
219 |
-
|
220 |
-
$version = FrmAppHelper::plugin_version();
|
221 |
-
wp_register_script( 'formidable', FrmAppHelper::plugin_url() . '/js/formidable.min.js', array( 'jquery' ), $version, true );
|
222 |
-
wp_register_script( 'jquery-placeholder', FrmAppHelper::plugin_url() . '/js/jquery/jquery.placeholder.js', array( 'jquery' ), '2.0.7', true );
|
223 |
-
|
224 |
-
if ( FrmAppHelper::is_admin() ) {
|
225 |
-
// don't load this in back-end
|
226 |
-
return;
|
227 |
-
}
|
228 |
-
|
229 |
-
self::localize_script( 'front' );
|
230 |
-
|
231 |
-
$frm_settings = FrmAppHelper::get_settings();
|
232 |
-
|
233 |
-
$style = apply_filters( 'get_frm_stylesheet', self::custom_stylesheet() );
|
234 |
-
if ( $style ) {
|
235 |
-
foreach ( (array) $style as $k => $file ) {
|
236 |
-
wp_register_style( $k, $file, array(), $version );
|
237 |
-
if ( 'all' == $frm_settings->load_style ) {
|
238 |
-
wp_enqueue_style( $k );
|
239 |
-
}
|
240 |
-
unset( $k, $file );
|
241 |
-
}
|
242 |
-
}
|
243 |
-
unset( $style );
|
244 |
-
|
245 |
-
if ( $frm_settings->load_style == 'all' ) {
|
246 |
-
global $frm_vars;
|
247 |
-
$frm_vars['css_loaded'] = true;
|
248 |
-
}
|
249 |
-
}
|
250 |
-
|
251 |
-
/**
|
252 |
-
* @param string $location
|
253 |
-
*/
|
254 |
-
public static function localize_script( $location ) {
|
255 |
-
wp_localize_script( 'formidable', 'frm_js', array(
|
256 |
-
'ajax_url' => admin_url( 'admin-ajax.php' ),
|
257 |
-
'images_url' => FrmAppHelper::plugin_url() . '/images',
|
258 |
-
'loading' => __( 'Loading…' ),
|
259 |
-
'remove' => __( 'Remove', 'formidable' ),
|
260 |
-
'offset' => apply_filters( 'frm_scroll_offset', 4 ),
|
261 |
-
'nonce' => wp_create_nonce( 'frm_ajax' ),
|
262 |
-
'id' => __( 'ID', 'formidable' ),
|
263 |
-
) );
|
264 |
-
|
265 |
-
if ( $location == 'admin' ) {
|
266 |
-
$frm_settings = FrmAppHelper::get_settings();
|
267 |
-
wp_localize_script( 'formidable_admin', 'frm_admin_js', array(
|
268 |
-
'confirm_uninstall' => __( 'Are you sure you want to do this? Clicking OK will delete all forms, form data, and all other Formidable data. There is no Undo.', 'formidable' ),
|
269 |
-
'desc' => __( '(Click to add description)', 'formidable' ),
|
270 |
-
'blank' => __( '(blank)', 'formidable' ),
|
271 |
-
'no_label' => __( '(no label)', 'formidable' ),
|
272 |
-
'saving' => esc_attr( __( 'Saving', 'formidable' ) ),
|
273 |
-
'saved' => esc_attr( __( 'Saved', 'formidable' ) ),
|
274 |
-
'ok' => __( 'OK' ),
|
275 |
-
'cancel' => __( 'Cancel', 'formidable' ),
|
276 |
-
'default' => __( 'Default', 'formidable' ),
|
277 |
-
'clear_default' => __( 'Clear default value when typing', 'formidable' ),
|
278 |
-
'no_clear_default' => __( 'Do not clear default value when typing', 'formidable' ),
|
279 |
-
'valid_default' => __( 'Default value will pass form validation', 'formidable' ),
|
280 |
-
'no_valid_default' => __( 'Default value will NOT pass form validation', 'formidable' ),
|
281 |
-
'confirm' => __( 'Are you sure?', 'formidable' ),
|
282 |
-
'conf_delete' => __( 'Are you sure you want to delete this field and all data associated with it?', 'formidable' ),
|
283 |
-
'conf_delete_sec' => __( 'WARNING: This will delete all fields inside of the section as well.', 'formidable' ),
|
284 |
-
'conf_no_repeat' => __( 'Warning: If you have entries with multiple rows, all but the first row will be lost.', 'formidable' ),
|
285 |
-
'default_unique' => $frm_settings->unique_msg,
|
286 |
-
'default_conf' => __( 'The entered values do not match', 'formidable' ),
|
287 |
-
'enter_email' => __( 'Enter Email', 'formidable' ),
|
288 |
-
'confirm_email' => __( 'Confirm Email', 'formidable' ),
|
289 |
-
'enter_password' => __( 'Enter Password', 'formidable' ),
|
290 |
-
'confirm_password' => __( 'Confirm Password', 'formidable' ),
|
291 |
-
'import_complete' => __( 'Import Complete', 'formidable' ),
|
292 |
-
'updating' => __( 'Please wait while your site updates.', 'formidable' ),
|
293 |
-
'no_save_warning' => __( 'Warning: There is no way to retrieve unsaved entries.', 'formidable' ),
|
294 |
-
'jquery_ui_url' => FrmAppHelper::jquery_ui_base_url(),
|
295 |
-
) );
|
296 |
-
}
|
297 |
}
|
298 |
|
299 |
-
|
300 |
-
|
301 |
-
$
|
302 |
-
self::maybe_enqueue_jquery_css();
|
303 |
-
|
304 |
-
if ( ! isset( $frm_vars['css_loaded'] ) || ! $frm_vars['css_loaded'] ) {
|
305 |
-
//include css in head
|
306 |
-
self::get_url_to_custom_style( $stylesheet_urls );
|
307 |
-
}
|
308 |
-
|
309 |
-
return $stylesheet_urls;
|
310 |
-
}
|
311 |
-
|
312 |
-
private static function get_url_to_custom_style( &$stylesheet_urls ) {
|
313 |
-
$uploads = FrmStylesHelper::get_upload_base();
|
314 |
-
$saved_css_path = '/formidable/css/formidablepro.css';
|
315 |
-
if ( is_readable( $uploads['basedir'] . $saved_css_path ) ) {
|
316 |
-
$url = $uploads['baseurl'] . $saved_css_path;
|
317 |
-
} else {
|
318 |
-
$url = admin_url( 'admin-ajax.php' ) . '?action=frmpro_css';
|
319 |
-
}
|
320 |
-
$stylesheet_urls['formidable'] = $url;
|
321 |
}
|
322 |
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
FrmStylesHelper::enqueue_jquery_css();
|
327 |
-
}
|
328 |
}
|
329 |
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
wp_die();
|
335 |
-
}
|
336 |
-
|
337 |
-
public static function footer_js( $location = 'footer' ) {
|
338 |
-
global $frm_vars;
|
339 |
-
|
340 |
-
$frm_settings = FrmAppHelper::get_settings();
|
341 |
-
if ( $frm_vars['load_css'] && ! FrmAppHelper::is_admin() && $frm_settings->load_style != 'none' ) {
|
342 |
-
$css = apply_filters( 'get_frm_stylesheet', self::custom_stylesheet() );
|
343 |
-
|
344 |
-
if ( ! empty( $css ) ) {
|
345 |
-
foreach ( (array) $css as $css_key => $file ) {
|
346 |
-
wp_enqueue_style( $css_key );
|
347 |
-
unset( $css_key, $file );
|
348 |
-
}
|
349 |
-
}
|
350 |
-
unset( $css );
|
351 |
-
}
|
352 |
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
}
|
358 |
|
359 |
/**
|
360 |
* Run silent upgrade on each site in the network during a network upgrade.
|
@@ -458,7 +339,6 @@ class FrmAppController {
|
|
458 |
wp_die();
|
459 |
}
|
460 |
|
461 |
-
//formidable shortcode
|
462 |
public static function get_form_shortcode( $atts ) {
|
463 |
_deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::get_form_shortcode()' );
|
464 |
return FrmFormsController::get_form_shortcode( $atts );
|
3 |
class FrmAppController {
|
4 |
|
5 |
public static function menu() {
|
|
|
|
|
|
|
6 |
FrmAppHelper::maybe_add_permissions();
|
|
|
7 |
if ( ! current_user_can( 'frm_view_forms' ) ) {
|
8 |
return;
|
9 |
}
|
10 |
|
|
|
|
|
|
|
|
|
11 |
$frm_settings = FrmAppHelper::get_settings();
|
12 |
+
add_menu_page( 'Formidable', $frm_settings->menu, 'frm_view_forms', 'formidable', 'FrmFormsController::route', FrmAppHelper::plugin_url() . '/images/form_16.png', self::get_menu_position() );
|
13 |
}
|
14 |
|
15 |
+
private static function get_menu_position() {
|
16 |
+
$count = count( get_post_types( array( 'show_ui' => true, '_builtin' => false, 'show_in_menu' => true ) ) );
|
17 |
+
$pos = $count ? '22.7' : '29.3';
|
18 |
+
$pos = apply_filters( 'frm_menu_position', $pos );
|
19 |
+
return $pos;
|
20 |
+
}
|
21 |
+
|
22 |
public static function load_wp_admin_style() {
|
23 |
+
FrmAppHelper::load_font_style();
|
24 |
}
|
25 |
|
26 |
public static function get_form_nav( $form, $show_nav = '', $title = 'show' ) {
|
31 |
return;
|
32 |
}
|
33 |
|
34 |
+
$current_page = isset( $_GET['page'] ) ? FrmAppHelper::simple_get( 'page', 'sanitize_title' ) : FrmAppHelper::simple_get( 'post_type', 'sanitize_title', 'None' );
|
35 |
|
36 |
if ( $form ) {
|
37 |
+
FrmForm::maybe_get_form( $form );
|
38 |
|
39 |
if ( is_object( $form ) ) {
|
40 |
$id = $form->id;
|
148 |
wp_enqueue_style( 'widgets' );
|
149 |
wp_enqueue_script( 'formidable' );
|
150 |
wp_enqueue_script( 'formidable_admin' );
|
151 |
+
FrmAppHelper::localize_script( 'admin' );
|
152 |
|
153 |
wp_enqueue_style( 'formidable-admin' );
|
154 |
add_thickbox();
|
172 |
wp_enqueue_script( 'jquery-ui-draggable' );
|
173 |
wp_enqueue_script( 'formidable_admin' );
|
174 |
wp_enqueue_style( 'formidable-admin' );
|
175 |
+
FrmAppHelper::localize_script( 'admin' );
|
176 |
}
|
177 |
} else if ( $pagenow == 'widgets.php' ) {
|
178 |
FrmAppHelper::load_admin_wide_js();
|
215 |
self::install( $old_db_version );
|
216 |
}
|
217 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
218 |
}
|
219 |
|
220 |
+
public static function localize_script( $location ) {
|
221 |
+
_deprecated_function( __FUNCTION__, '2.0.9', 'FrmAppHelper::localize_script' );
|
222 |
+
return FrmAppHelper::localize_script( $location );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
223 |
}
|
224 |
|
225 |
+
public static function custom_stylesheet() {
|
226 |
+
_deprecated_function( __FUNCTION__, '2.0.9', 'FrmStylesController::custom_stylesheet' );
|
227 |
+
return FrmStylesController::custom_stylesheet();
|
|
|
|
|
228 |
}
|
229 |
|
230 |
+
public static function load_css() {
|
231 |
+
_deprecated_function( __FUNCTION__, '2.0.9', 'FrmStylesController::load_saved_css' );
|
232 |
+
return FrmStylesController::load_saved_css();
|
233 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
234 |
|
235 |
+
public static function footer_js( $location = 'footer' ) {
|
236 |
+
_deprecated_function( __FUNCTION__, '2.0', 'FrmAppHelper::widget_text_filter_callback' );
|
237 |
+
return FrmFormsController::footer_js( $location );
|
238 |
+
}
|
|
|
239 |
|
240 |
/**
|
241 |
* Run silent upgrade on each site in the network during a network upgrade.
|
339 |
wp_die();
|
340 |
}
|
341 |
|
|
|
342 |
public static function get_form_shortcode( $atts ) {
|
343 |
_deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::get_form_shortcode()' );
|
344 |
return FrmFormsController::get_form_shortcode( $atts );
|
classes/controllers/FrmEntriesController.php
CHANGED
@@ -10,7 +10,6 @@ class FrmEntriesController {
|
|
10 |
if ( ! in_array( FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' ), array( 'edit', 'show' ) ) ) {
|
11 |
$frm_settings = FrmAppHelper::get_settings();
|
12 |
add_filter( 'manage_' . sanitize_title( $frm_settings->menu ) . '_page_formidable-entries_columns', 'FrmEntriesController::manage_columns' );
|
13 |
-
add_filter( 'manage_' . sanitize_title( $frm_settings->menu ) . '_page_formidable-entries_sortable_columns', 'FrmEntriesController::sortable_columns' );
|
14 |
add_filter( 'get_user_option_manage' . sanitize_title( $frm_settings->menu ) . '_page_formidable-entriescolumnshidden', 'FrmEntriesController::hidden_columns' );
|
15 |
}
|
16 |
}
|
@@ -63,9 +62,9 @@ class FrmEntriesController {
|
|
63 |
return $help;
|
64 |
}
|
65 |
|
66 |
-
|
67 |
global $frm_vars, $wpdb;
|
68 |
-
|
69 |
|
70 |
$columns[ $form_id .'_id' ] = 'ID';
|
71 |
$columns[ $form_id . '_item_key' ] = esc_html__( 'Entry Key', 'formidable' );
|
@@ -77,7 +76,7 @@ class FrmEntriesController {
|
|
77 |
$form_cols = FrmField::get_all_for_form($form_id, '', 'include');
|
78 |
|
79 |
foreach ( $form_cols as $form_col ) {
|
80 |
-
if (
|
81 |
continue;
|
82 |
}
|
83 |
|
@@ -86,7 +85,7 @@ class FrmEntriesController {
|
|
86 |
|
87 |
if ( $sub_form_cols ) {
|
88 |
foreach ( $sub_form_cols as $k => $sub_form_col ) {
|
89 |
-
|
90 |
unset( $sub_form_cols[ $k ] );
|
91 |
continue;
|
92 |
}
|
@@ -196,34 +195,10 @@ class FrmEntriesController {
|
|
196 |
return $save;
|
197 |
}
|
198 |
|
199 |
-
public static function sortable_columns() {
|
200 |
-
$form_id = FrmEntriesHelper::get_current_form_id();
|
201 |
-
|
202 |
-
$fields = FrmField::get_all_for_form( $form_id );
|
203 |
-
|
204 |
-
$columns = array(
|
205 |
-
$form_id .'_id' => 'id',
|
206 |
-
$form_id .'_created_at' => 'created_at',
|
207 |
-
$form_id .'_updated_at' => 'updated_at',
|
208 |
-
$form_id .'_ip' => 'ip',
|
209 |
-
$form_id .'_item_key' => 'item_key',
|
210 |
-
$form_id .'_is_draft' => 'is_draft',
|
211 |
-
);
|
212 |
-
|
213 |
-
foreach ( $fields as $field ) {
|
214 |
-
if ( $field->type != 'checkbox' && ( ! isset($field->field_options['post_field']) || $field->field_options['post_field'] == '' ) ) {
|
215 |
-
// Can't sort on checkboxes because they are stored serialized, or post fields
|
216 |
-
$columns[ $form_id .'_'. $field->field_key ] = 'meta_'. $field->id;
|
217 |
-
}
|
218 |
-
}
|
219 |
-
|
220 |
-
return $columns;
|
221 |
-
}
|
222 |
-
|
223 |
public static function hidden_columns($result) {
|
224 |
global $frm_vars;
|
225 |
|
226 |
-
|
227 |
|
228 |
$return = false;
|
229 |
foreach ( (array) $result as $r ) {
|
@@ -283,8 +258,8 @@ class FrmEntriesController {
|
|
283 |
public static function display_list( $message = '', $errors = array() ) {
|
284 |
global $wpdb, $frm_vars;
|
285 |
|
286 |
-
|
287 |
-
|
288 |
|
289 |
if ( $form ) {
|
290 |
$params['form'] = $form->id;
|
@@ -352,7 +327,7 @@ class FrmEntriesController {
|
|
352 |
public static function destroy() {
|
353 |
FrmAppHelper::permission_check('frm_delete_entries');
|
354 |
|
355 |
-
|
356 |
|
357 |
if ( isset($params['keep_post']) && $params['keep_post'] ) {
|
358 |
//unlink entry from post
|
@@ -375,14 +350,14 @@ class FrmEntriesController {
|
|
375 |
}
|
376 |
|
377 |
global $wpdb;
|
378 |
-
|
379 |
$message = '';
|
380 |
$errors = array();
|
381 |
$form_id = (int) $params['form'];
|
382 |
|
383 |
if ( $form_id ) {
|
384 |
$entry_ids = FrmDb::get_col( 'frm_items', array( 'form_id' => $form_id ) );
|
385 |
-
|
386 |
|
387 |
if ( $action ) {
|
388 |
// this action takes a while, so only trigger it if there are posts to delete
|
@@ -427,7 +402,7 @@ class FrmEntriesController {
|
|
427 |
return;
|
428 |
}
|
429 |
|
430 |
-
|
431 |
|
432 |
if ( ! isset( $frm_vars['form_params'] ) ) {
|
433 |
$frm_vars['form_params'] = array();
|
@@ -439,7 +414,7 @@ class FrmEntriesController {
|
|
439 |
}
|
440 |
|
441 |
if ( $errors == '' ) {
|
442 |
-
|
443 |
}
|
444 |
|
445 |
/**
|
@@ -485,68 +460,9 @@ class FrmEntriesController {
|
|
485 |
}
|
486 |
}
|
487 |
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
'user_info' => false, 'include_blank' => false, 'default_email' => false,
|
492 |
-
'form_id' => false, 'format' => 'text', 'direction' => 'ltr',
|
493 |
-
'font_size' => '', 'text_color' => '',
|
494 |
-
'border_width' => '', 'border_color' => '',
|
495 |
-
'bg_color' => '', 'alt_bg_color' => '',
|
496 |
-
), $atts );
|
497 |
-
|
498 |
-
if ( $atts['format'] != 'text' ) {
|
499 |
-
//format options are text, array, or json
|
500 |
-
$atts['plain_text'] = true;
|
501 |
-
}
|
502 |
-
|
503 |
-
if ( is_object( $atts['entry'] ) && ! isset( $atts['entry']->metas ) ) {
|
504 |
-
// if the entry does not include metas, force it again
|
505 |
-
$atts['entry'] = false;
|
506 |
-
}
|
507 |
-
|
508 |
-
if ( ! $atts['entry'] || ! is_object( $atts['entry'] ) ) {
|
509 |
-
if ( ! $atts['id'] && ! $atts['default_email'] ) {
|
510 |
-
return;
|
511 |
-
}
|
512 |
-
|
513 |
-
if ( $atts['id'] ) {
|
514 |
-
$atts['entry'] = FrmEntry::getOne( $atts['id'], true );
|
515 |
-
}
|
516 |
-
}
|
517 |
-
|
518 |
-
if ( $atts['entry'] ) {
|
519 |
-
$atts['form_id'] = $atts['entry']->form_id;
|
520 |
-
$atts['id'] = $atts['entry']->id;
|
521 |
-
}
|
522 |
-
|
523 |
-
if ( ! $atts['fields'] || ! is_array($atts['fields']) ) {
|
524 |
-
$atts['fields'] = FrmField::get_all_for_form( $atts['form_id'], '', 'include' );
|
525 |
-
}
|
526 |
-
|
527 |
-
$values = array();
|
528 |
-
foreach ( $atts['fields'] as $f ) {
|
529 |
-
FrmEntriesHelper::fill_entry_values($atts, $f, $values);
|
530 |
-
unset($f);
|
531 |
-
}
|
532 |
-
|
533 |
-
FrmEntriesHelper::fill_entry_user_info($atts, $values);
|
534 |
-
|
535 |
-
if ( $atts['format'] == 'json' ) {
|
536 |
-
return json_encode($values);
|
537 |
-
} else if ( $atts['format'] == 'array' ) {
|
538 |
-
return $values;
|
539 |
-
}
|
540 |
-
|
541 |
-
$content = array();
|
542 |
-
FrmEntriesHelper::convert_entry_to_content($values, $atts, $content);
|
543 |
-
|
544 |
-
if ( 'text' == $atts['format'] ) {
|
545 |
-
$content = implode('', $content);
|
546 |
-
}
|
547 |
-
|
548 |
-
return $content;
|
549 |
-
}
|
550 |
|
551 |
public static function &filter_email_value( $value, $meta, $entry, $atts = array() ) {
|
552 |
$field = FrmField::getOne($meta->field_id);
|
@@ -560,7 +476,7 @@ class FrmEntriesController {
|
|
560 |
|
561 |
public static function &filter_shortcode_value($value, $tag, $atts, $field) {
|
562 |
$plain_text = add_filter('frm_plain_text_email', true);
|
563 |
-
|
564 |
|
565 |
if ( isset($atts['show']) && $atts['show'] == 'value' ) {
|
566 |
return $value;
|
@@ -571,7 +487,7 @@ class FrmEntriesController {
|
|
571 |
|
572 |
public static function &filter_display_value( $value, $field, $atts = array() ) {
|
573 |
$saved_value = ( isset($atts['saved_value']) && $atts['saved_value'] ) ? true : false;
|
574 |
-
|
575 |
return $value;
|
576 |
}
|
577 |
|
@@ -608,60 +524,17 @@ class FrmEntriesController {
|
|
608 |
}
|
609 |
|
610 |
public static function get_params( $form = null ) {
|
611 |
-
|
612 |
-
|
613 |
-
|
614 |
-
$form = FrmForm::getAll( array(), 'name', 1 );
|
615 |
-
} else {
|
616 |
-
FrmFormsHelper::maybe_get_form( $form );
|
617 |
-
}
|
618 |
-
|
619 |
-
if ( isset( $frm_vars['form_params'] ) && is_array( $frm_vars['form_params'] ) && isset( $frm_vars['form_params'][ $form->id ] ) ) {
|
620 |
-
return $frm_vars['form_params'][ $form->id ];
|
621 |
-
}
|
622 |
-
|
623 |
-
$action_var = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action';
|
624 |
-
$action = apply_filters( 'frm_show_new_entry_page', FrmAppHelper::get_param( $action_var, 'new', 'get', 'sanitize_title' ), $form );
|
625 |
-
|
626 |
-
$default_values = array(
|
627 |
-
'id' => '', 'form_name' => '', 'paged' => 1, 'form' => $form->id, 'form_id' => $form->id,
|
628 |
-
'field_id' => '', 'search' => '', 'sort' => '', 'sdir' => '', 'action' => $action,
|
629 |
-
);
|
630 |
-
|
631 |
-
$values = array();
|
632 |
-
$values['posted_form_id'] = FrmAppHelper::get_param( 'form_id', '', 'get', 'absint' );
|
633 |
-
if ( ! $values['posted_form_id'] ) {
|
634 |
-
$values['posted_form_id'] = FrmAppHelper::get_param( 'form', '', 'get', 'absint' );
|
635 |
-
}
|
636 |
-
|
637 |
-
if ( $form->id == $values['posted_form_id'] ) {
|
638 |
-
//if there are two forms on the same page, make sure not to submit both
|
639 |
-
foreach ( $default_values as $var => $default ) {
|
640 |
-
if ( $var == 'action' ) {
|
641 |
-
$values[ $var ] = FrmAppHelper::get_param( $action_var, $default, 'get', 'sanitize_title' );
|
642 |
-
} else {
|
643 |
-
$values[ $var ] = FrmAppHelper::get_param( $var, $default );
|
644 |
-
}
|
645 |
-
unset( $var, $default );
|
646 |
-
}
|
647 |
-
} else {
|
648 |
-
foreach ( $default_values as $var => $default ) {
|
649 |
-
$values[ $var ] = $default;
|
650 |
-
unset( $var, $default );
|
651 |
-
}
|
652 |
-
}
|
653 |
-
|
654 |
-
if ( in_array( $values['action'], array( 'create', 'update' ) ) && ( ! $_POST || ( ! isset( $_POST['action'] ) && ! isset( $_POST['frm_action'] ) ) ) ) {
|
655 |
-
$values['action'] = 'new';
|
656 |
-
}
|
657 |
-
|
658 |
-
return $values;
|
659 |
-
}
|
660 |
|
661 |
public static function entry_sidebar($entry) {
|
662 |
$data = maybe_unserialize($entry->description);
|
663 |
$date_format = get_option('date_format');
|
664 |
$time_format = get_option('time_format');
|
|
|
|
|
|
|
665 |
|
666 |
include(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/sidebar-shared.php');
|
667 |
}
|
10 |
if ( ! in_array( FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' ), array( 'edit', 'show' ) ) ) {
|
11 |
$frm_settings = FrmAppHelper::get_settings();
|
12 |
add_filter( 'manage_' . sanitize_title( $frm_settings->menu ) . '_page_formidable-entries_columns', 'FrmEntriesController::manage_columns' );
|
|
|
13 |
add_filter( 'get_user_option_manage' . sanitize_title( $frm_settings->menu ) . '_page_formidable-entriescolumnshidden', 'FrmEntriesController::hidden_columns' );
|
14 |
}
|
15 |
}
|
62 |
return $help;
|
63 |
}
|
64 |
|
65 |
+
public static function manage_columns( $columns ) {
|
66 |
global $frm_vars, $wpdb;
|
67 |
+
$form_id = FrmForm::get_current_form_id();
|
68 |
|
69 |
$columns[ $form_id .'_id' ] = 'ID';
|
70 |
$columns[ $form_id . '_item_key' ] = esc_html__( 'Entry Key', 'formidable' );
|
76 |
$form_cols = FrmField::get_all_for_form($form_id, '', 'include');
|
77 |
|
78 |
foreach ( $form_cols as $form_col ) {
|
79 |
+
if ( FrmField::is_no_save_field( $form_col->type ) ) {
|
80 |
continue;
|
81 |
}
|
82 |
|
85 |
|
86 |
if ( $sub_form_cols ) {
|
87 |
foreach ( $sub_form_cols as $k => $sub_form_col ) {
|
88 |
+
if ( FrmField::is_no_save_field( $sub_form_col->type ) ) {
|
89 |
unset( $sub_form_cols[ $k ] );
|
90 |
continue;
|
91 |
}
|
195 |
return $save;
|
196 |
}
|
197 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
198 |
public static function hidden_columns($result) {
|
199 |
global $frm_vars;
|
200 |
|
201 |
+
$form_id = FrmForm::get_current_form_id();
|
202 |
|
203 |
$return = false;
|
204 |
foreach ( (array) $result as $r ) {
|
258 |
public static function display_list( $message = '', $errors = array() ) {
|
259 |
global $wpdb, $frm_vars;
|
260 |
|
261 |
+
$form = FrmForm::get_current_form();
|
262 |
+
$params = FrmForm::get_admin_params( $form );
|
263 |
|
264 |
if ( $form ) {
|
265 |
$params['form'] = $form->id;
|
327 |
public static function destroy() {
|
328 |
FrmAppHelper::permission_check('frm_delete_entries');
|
329 |
|
330 |
+
$params = FrmForm::get_admin_params();
|
331 |
|
332 |
if ( isset($params['keep_post']) && $params['keep_post'] ) {
|
333 |
//unlink entry from post
|
350 |
}
|
351 |
|
352 |
global $wpdb;
|
353 |
+
$params = FrmForm::get_admin_params();
|
354 |
$message = '';
|
355 |
$errors = array();
|
356 |
$form_id = (int) $params['form'];
|
357 |
|
358 |
if ( $form_id ) {
|
359 |
$entry_ids = FrmDb::get_col( 'frm_items', array( 'form_id' => $form_id ) );
|
360 |
+
$action = FrmFormAction::get_action_for_form( $form_id, 'wppost', 1 );
|
361 |
|
362 |
if ( $action ) {
|
363 |
// this action takes a while, so only trigger it if there are posts to delete
|
402 |
return;
|
403 |
}
|
404 |
|
405 |
+
$params = FrmForm::get_params( $form );
|
406 |
|
407 |
if ( ! isset( $frm_vars['form_params'] ) ) {
|
408 |
$frm_vars['form_params'] = array();
|
414 |
}
|
415 |
|
416 |
if ( $errors == '' ) {
|
417 |
+
$errors = FrmEntryValidate::validate( $_POST );
|
418 |
}
|
419 |
|
420 |
/**
|
460 |
}
|
461 |
}
|
462 |
|
463 |
+
public static function show_entry_shortcode( $atts ) {
|
464 |
+
return FrmEntryFormat::show_entry( $atts );
|
465 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
466 |
|
467 |
public static function &filter_email_value( $value, $meta, $entry, $atts = array() ) {
|
468 |
$field = FrmField::getOne($meta->field_id);
|
476 |
|
477 |
public static function &filter_shortcode_value($value, $tag, $atts, $field) {
|
478 |
$plain_text = add_filter('frm_plain_text_email', true);
|
479 |
+
FrmEntryFormat::textarea_display_value( $field->type, $plain_text, $value );
|
480 |
|
481 |
if ( isset($atts['show']) && $atts['show'] == 'value' ) {
|
482 |
return $value;
|
487 |
|
488 |
public static function &filter_display_value( $value, $field, $atts = array() ) {
|
489 |
$saved_value = ( isset($atts['saved_value']) && $atts['saved_value'] ) ? true : false;
|
490 |
+
if ( ! in_array( $field->type, array( 'radio', 'checkbox', 'radio', 'select' ) ) || ! FrmField::is_option_true( $field, 'separate_value' ) || $saved_value ) {
|
491 |
return $value;
|
492 |
}
|
493 |
|
524 |
}
|
525 |
|
526 |
public static function get_params( $form = null ) {
|
527 |
+
_deprecated_function( __FUNCTION__, '2.0.9', 'FrmForm::get_params' );
|
528 |
+
return FrmForm::get_params( $form );
|
529 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
530 |
|
531 |
public static function entry_sidebar($entry) {
|
532 |
$data = maybe_unserialize($entry->description);
|
533 |
$date_format = get_option('date_format');
|
534 |
$time_format = get_option('time_format');
|
535 |
+
if ( isset( $data['browser'] ) ) {
|
536 |
+
$browser = FrmEntryFormat::get_browser( $data['browser'] );
|
537 |
+
}
|
538 |
|
539 |
include(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/sidebar-shared.php');
|
540 |
}
|
classes/controllers/FrmFieldsController.php
CHANGED
@@ -139,7 +139,7 @@ class FrmFieldsController {
|
|
139 |
$new_val = FrmAppHelper::get_post_param( $val, 0, 'absint' );
|
140 |
|
141 |
if ( $val == 'separate_value' ) {
|
142 |
-
|
143 |
}
|
144 |
|
145 |
$field->field_options[ $val ] = $new_val;
|
@@ -284,7 +284,7 @@ class FrmFieldsController {
|
|
284 |
$ids = explode( '-', $element_id );
|
285 |
$id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' );
|
286 |
|
287 |
-
$orig_update_value = $update_value = trim( FrmAppHelper::get_post_param( 'update_value'
|
288 |
if ( strpos( $element_id, 'key_' ) ) {
|
289 |
$new_value = $update_value;
|
290 |
} else {
|
@@ -292,7 +292,7 @@ class FrmFieldsController {
|
|
292 |
}
|
293 |
|
294 |
$field = FrmField::getOne($id);
|
295 |
-
$separate_values = (
|
296 |
|
297 |
$this_opt_id = end($ids);
|
298 |
$this_opt = (array) $field->options[ $this_opt_id ];
|
@@ -490,7 +490,7 @@ class FrmFieldsController {
|
|
490 |
$type = $type_switch[ $type ];
|
491 |
}
|
492 |
|
493 |
-
|
494 |
$types = array_keys($frm_field_selection);
|
495 |
if ( ! in_array($type, $types) && $type != 'captcha' ) {
|
496 |
$type = 'text';
|
@@ -618,7 +618,7 @@ class FrmFieldsController {
|
|
618 |
|
619 |
private static function add_html_length($field, array &$add_html) {
|
620 |
// check for max setting and if this field accepts maxlength
|
621 |
-
if (
|
622 |
return;
|
623 |
}
|
624 |
|
@@ -631,13 +631,15 @@ class FrmFieldsController {
|
|
631 |
}
|
632 |
|
633 |
private static function add_html_placeholder($field, array &$add_html, array &$class) {
|
634 |
-
|
635 |
-
|
636 |
-
|
637 |
-
}
|
638 |
|
639 |
-
|
640 |
-
|
|
|
|
|
|
|
641 |
return;
|
642 |
}
|
643 |
|
@@ -659,7 +661,7 @@ class FrmFieldsController {
|
|
659 |
}
|
660 |
|
661 |
private static function add_shortcodes_to_html( $field, array &$add_html ) {
|
662 |
-
if (
|
663 |
return;
|
664 |
}
|
665 |
|
@@ -682,7 +684,7 @@ class FrmFieldsController {
|
|
682 |
|
683 |
public static function check_value( $opt, $opt_key, $field ) {
|
684 |
if ( is_array( $opt ) ) {
|
685 |
-
if (
|
686 |
$opt = isset( $opt['value'] ) ? $opt['value'] : ( isset( $opt['label'] ) ? $opt['label'] : reset( $opt ) );
|
687 |
} else {
|
688 |
$opt = isset( $opt['label'] ) ? $opt['label'] : reset( $opt );
|
139 |
$new_val = FrmAppHelper::get_post_param( $val, 0, 'absint' );
|
140 |
|
141 |
if ( $val == 'separate_value' ) {
|
142 |
+
$new_val = FrmField::is_option_true( $field, $val ) ? 0 : 1;
|
143 |
}
|
144 |
|
145 |
$field->field_options[ $val ] = $new_val;
|
284 |
$ids = explode( '-', $element_id );
|
285 |
$id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' );
|
286 |
|
287 |
+
$orig_update_value = $update_value = trim( FrmAppHelper::get_post_param( 'update_value' ) );
|
288 |
if ( strpos( $element_id, 'key_' ) ) {
|
289 |
$new_value = $update_value;
|
290 |
} else {
|
292 |
}
|
293 |
|
294 |
$field = FrmField::getOne($id);
|
295 |
+
$separate_values = FrmField::is_option_true( $field, 'separate_value' );
|
296 |
|
297 |
$this_opt_id = end($ids);
|
298 |
$this_opt = (array) $field->options[ $this_opt_id ];
|
490 |
$type = $type_switch[ $type ];
|
491 |
}
|
492 |
|
493 |
+
$frm_field_selection = FrmField::field_selection();
|
494 |
$types = array_keys($frm_field_selection);
|
495 |
if ( ! in_array($type, $types) && $type != 'captcha' ) {
|
496 |
$type = 'text';
|
618 |
|
619 |
private static function add_html_length($field, array &$add_html) {
|
620 |
// check for max setting and if this field accepts maxlength
|
621 |
+
if ( FrmField::is_option_empty( $field, 'max' ) || in_array( $field['type'], array( 'textarea', 'rte', 'hidden' ) ) ) {
|
622 |
return;
|
623 |
}
|
624 |
|
631 |
}
|
632 |
|
633 |
private static function add_html_placeholder($field, array &$add_html, array &$class) {
|
634 |
+
if ( empty( $field['default_value'] ) || FrmAppHelper::is_admin_page( 'formidable' ) ) {
|
635 |
+
return;
|
636 |
+
}
|
|
|
637 |
|
638 |
+
if ( ! FrmField::is_option_true( $field, 'clear_on_focus' ) ) {
|
639 |
+
if ( is_array( $field['default_value'] ) ) {
|
640 |
+
$field['default_value'] = json_encode( $field['default_value'] );
|
641 |
+
}
|
642 |
+
$add_html['data-frmval'] = 'data-frmval="' . esc_attr( $field['default_value'] ) . '"';
|
643 |
return;
|
644 |
}
|
645 |
|
661 |
}
|
662 |
|
663 |
private static function add_shortcodes_to_html( $field, array &$add_html ) {
|
664 |
+
if ( FrmField::is_option_empty( $field, 'shortcodes' ) ) {
|
665 |
return;
|
666 |
}
|
667 |
|
684 |
|
685 |
public static function check_value( $opt, $opt_key, $field ) {
|
686 |
if ( is_array( $opt ) ) {
|
687 |
+
if ( FrmField::is_option_true( $field, 'separate_value' ) ) {
|
688 |
$opt = isset( $opt['value'] ) ? $opt['value'] : ( isset( $opt['label'] ) ? $opt['label'] : reset( $opt ) );
|
689 |
} else {
|
690 |
$opt = isset( $opt['label'] ) ? $opt['label'] : reset( $opt );
|
classes/controllers/FrmFormActionsController.php
CHANGED
@@ -111,7 +111,7 @@ class FrmFormActionsController {
|
|
111 |
*/
|
112 |
do_action( 'frm_before_list_actions', $form );
|
113 |
|
114 |
-
$form_actions =
|
115 |
|
116 |
$action_controls = self::get_form_actions();
|
117 |
|
@@ -239,13 +239,13 @@ class FrmFormActionsController {
|
|
239 |
* @param string $event
|
240 |
*/
|
241 |
public static function trigger_actions( $event, $form, $entry, $type = 'all', $args = array() ) {
|
242 |
-
|
243 |
|
244 |
if ( empty( $form_actions ) ) {
|
245 |
return;
|
246 |
}
|
247 |
|
248 |
-
|
249 |
|
250 |
$link_settings = self::get_form_actions( $type );
|
251 |
if ( 'all' != $type ) {
|
@@ -276,7 +276,7 @@ class FrmFormActionsController {
|
|
276 |
}
|
277 |
|
278 |
// check conditional logic
|
279 |
-
|
280 |
if ( $stop ) {
|
281 |
continue;
|
282 |
}
|
111 |
*/
|
112 |
do_action( 'frm_before_list_actions', $form );
|
113 |
|
114 |
+
$form_actions = FrmFormAction::get_action_for_form( $form->id );
|
115 |
|
116 |
$action_controls = self::get_form_actions();
|
117 |
|
239 |
* @param string $event
|
240 |
*/
|
241 |
public static function trigger_actions( $event, $form, $entry, $type = 'all', $args = array() ) {
|
242 |
+
$form_actions = FrmFormAction::get_action_for_form( ( is_object( $form ) ? $form->id : $form ), $type );
|
243 |
|
244 |
if ( empty( $form_actions ) ) {
|
245 |
return;
|
246 |
}
|
247 |
|
248 |
+
FrmForm::maybe_get_form( $form );
|
249 |
|
250 |
$link_settings = self::get_form_actions( $type );
|
251 |
if ( 'all' != $type ) {
|
276 |
}
|
277 |
|
278 |
// check conditional logic
|
279 |
+
$stop = FrmFormAction::action_conditions_met( $action, $entry );
|
280 |
if ( $stop ) {
|
281 |
continue;
|
282 |
}
|
classes/controllers/FrmFormsController.php
CHANGED
@@ -2,17 +2,12 @@
|
|
2 |
|
3 |
class FrmFormsController {
|
4 |
|
5 |
-
public static function trigger_load_form_hooks() {
|
6 |
-
FrmHooksController::trigger_load_hook( 'load_form_hooks' );
|
7 |
-
}
|
8 |
-
|
9 |
public static function menu() {
|
10 |
add_submenu_page('formidable', 'Formidable | '. __( 'Forms', 'formidable' ), __( 'Forms', 'formidable' ), 'frm_view_forms', 'formidable', 'FrmFormsController::route' );
|
11 |
|
12 |
add_filter('get_user_option_managetoplevel_page_formidablecolumnshidden', 'FrmFormsController::hidden_columns' );
|
13 |
|
14 |
add_filter('manage_toplevel_page_formidable_columns', 'FrmFormsController::get_columns', 0 );
|
15 |
-
add_filter('manage_toplevel_page_formidable_sortable_columns', 'FrmFormsController::get_sortable_columns' );
|
16 |
}
|
17 |
|
18 |
public static function head() {
|
@@ -31,7 +26,7 @@ class FrmFormsController {
|
|
31 |
public static function list_form() {
|
32 |
FrmAppHelper::permission_check('frm_view_forms');
|
33 |
|
34 |
-
|
35 |
$errors = self::process_bulk_form_actions( array());
|
36 |
$errors = apply_filters('frm_admin_list_form_action', $errors);
|
37 |
|
@@ -49,7 +44,7 @@ class FrmFormsController {
|
|
49 |
if ( $action == 'create' ) {
|
50 |
return self::create($values);
|
51 |
} else if ( $action == 'new' ) {
|
52 |
-
|
53 |
$values = FrmFormsHelper::setup_new_vars($values);
|
54 |
$id = FrmForm::create( $values );
|
55 |
$form = FrmForm::getOne($id);
|
@@ -89,7 +84,7 @@ class FrmFormsController {
|
|
89 |
|
90 |
if ( count($errors) > 0 ) {
|
91 |
$hide_preview = true;
|
92 |
-
|
93 |
$form = FrmForm::getOne( $id );
|
94 |
$fields = FrmField::get_all_for_form($id);
|
95 |
|
@@ -227,7 +222,7 @@ class FrmFormsController {
|
|
227 |
public static function duplicate() {
|
228 |
FrmAppHelper::permission_check('frm_edit_forms');
|
229 |
|
230 |
-
|
231 |
$form = FrmForm::duplicate( $params['id'], $params['template'], true );
|
232 |
$message = ($params['template']) ? __( 'Form template was Successfully Created', 'formidable' ) : __( 'Form was Successfully Copied', 'formidable' );
|
233 |
if ( $form ) {
|
@@ -238,7 +233,7 @@ class FrmFormsController {
|
|
238 |
}
|
239 |
|
240 |
public static function page_preview() {
|
241 |
-
|
242 |
if ( ! $params['form'] ) {
|
243 |
return;
|
244 |
}
|
@@ -264,9 +259,7 @@ class FrmFormsController {
|
|
264 |
$wp->register_globals();
|
265 |
}
|
266 |
|
267 |
-
|
268 |
-
FrmProEntriesController::register_scripts();
|
269 |
-
}
|
270 |
|
271 |
header( 'Content-Type: text/html; charset='. get_option( 'blog_charset' ) );
|
272 |
|
@@ -284,8 +277,16 @@ class FrmFormsController {
|
|
284 |
wp_die();
|
285 |
}
|
286 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
287 |
public static function untrash() {
|
288 |
-
|
289 |
}
|
290 |
|
291 |
public static function bulk_untrash($ids) {
|
@@ -298,9 +299,44 @@ class FrmFormsController {
|
|
298 |
}
|
299 |
|
300 |
public static function trash() {
|
301 |
-
|
302 |
}
|
303 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
304 |
public static function bulk_trash($ids) {
|
305 |
FrmAppHelper::permission_check('frm_delete_forms');
|
306 |
|
@@ -320,7 +356,7 @@ class FrmFormsController {
|
|
320 |
public static function destroy() {
|
321 |
FrmAppHelper::permission_check('frm_delete_forms');
|
322 |
|
323 |
-
|
324 |
|
325 |
//check nonce url
|
326 |
check_admin_referer('destroy_form_' . $params['id']);
|
@@ -359,41 +395,16 @@ class FrmFormsController {
|
|
359 |
return;
|
360 |
}
|
361 |
|
362 |
-
|
363 |
$message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count);
|
364 |
|
365 |
self::display_forms_list( array(), $message );
|
366 |
}
|
367 |
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
public static function scheduled_delete($delete_timestamp = '') {
|
373 |
-
global $wpdb;
|
374 |
-
|
375 |
-
$trash_forms = FrmDb::get_results( $wpdb->prefix . 'frm_forms', array( 'status' => 'trash' ), 'id, options' );
|
376 |
-
|
377 |
-
if ( ! $trash_forms ) {
|
378 |
-
return;
|
379 |
-
}
|
380 |
-
|
381 |
-
if ( empty($delete_timestamp) ) {
|
382 |
-
$delete_timestamp = time() - ( DAY_IN_SECONDS * EMPTY_TRASH_DAYS );
|
383 |
-
}
|
384 |
-
|
385 |
-
$count = 0;
|
386 |
-
foreach ( $trash_forms as $form ) {
|
387 |
-
$form->options = maybe_unserialize($form->options);
|
388 |
-
if ( ! isset( $form->options['trash_time'] ) || $form->options['trash_time'] < $delete_timestamp ) {
|
389 |
-
FrmForm::destroy($form->id);
|
390 |
-
$count++;
|
391 |
-
}
|
392 |
-
|
393 |
-
unset($form);
|
394 |
-
}
|
395 |
-
return $count;
|
396 |
-
}
|
397 |
|
398 |
public static function insert_form_button($content) {
|
399 |
if ( current_user_can('frm_view_forms') ) {
|
@@ -469,7 +480,7 @@ class FrmFormsController {
|
|
469 |
global $wpdb, $frm_vars;
|
470 |
|
471 |
if ( empty( $params ) ) {
|
472 |
-
|
473 |
}
|
474 |
|
475 |
$wp_list_table = new FrmFormsListHelper( compact( 'params' ) );
|
@@ -506,21 +517,11 @@ class FrmFormsController {
|
|
506 |
|
507 |
$columns['created_at'] = __( 'Date', 'formidable' );
|
508 |
|
509 |
-
|
510 |
|
511 |
return $columns;
|
512 |
}
|
513 |
|
514 |
-
public static function get_sortable_columns() {
|
515 |
-
return array(
|
516 |
-
'id' => 'id',
|
517 |
-
'name' => 'name',
|
518 |
-
'description' => 'description',
|
519 |
-
'form_key' => 'form_key',
|
520 |
-
'created_at' => 'created_at',
|
521 |
-
);
|
522 |
-
}
|
523 |
-
|
524 |
public static function hidden_columns( $result ) {
|
525 |
$return = false;
|
526 |
foreach ( (array) $result as $r ) {
|
@@ -564,7 +565,7 @@ class FrmFormsController {
|
|
564 |
wp_die( sprintf(__( 'You are trying to edit a child form. Please edit from %1$shere%2$s', 'formidable' ), '<a href="'. esc_url(admin_url('admin.php') .'?page=formidable&frm_action=edit&id='. $form->parent_form_id) .'">', '</a>' ));
|
565 |
}
|
566 |
|
567 |
-
|
568 |
$fields = FrmField::get_all_for_form($form->id);
|
569 |
|
570 |
// Automatically add end section fields if they don't exist (2.0 migration)
|
@@ -710,7 +711,7 @@ class FrmFormsController {
|
|
710 |
|
711 |
public static function get_email_html() {
|
712 |
check_ajax_referer( 'frm_ajax', 'nonce' );
|
713 |
-
|
714 |
'form_id' => FrmAppHelper::get_post_param( 'form_id', '', 'absint' ),
|
715 |
'default_email' => true,
|
716 |
'plain_text' => FrmAppHelper::get_post_param( 'plain_text', '', 'absint' ),
|
@@ -740,7 +741,7 @@ class FrmFormsController {
|
|
740 |
$entry = FrmAppHelper::get_post_param( 'id', false, 'sanitize_title' );
|
741 |
}
|
742 |
|
743 |
-
|
744 |
}
|
745 |
}
|
746 |
|
@@ -874,7 +875,7 @@ class FrmFormsController {
|
|
874 |
}
|
875 |
}
|
876 |
|
877 |
-
|
878 |
FrmAppHelper::trigger_hook_load( 'form' );
|
879 |
|
880 |
switch ( $action ) {
|
@@ -919,7 +920,7 @@ class FrmFormsController {
|
|
919 |
|
920 |
/* FRONT-END FORMS */
|
921 |
public static function admin_bar_css() {
|
922 |
-
|
923 |
}
|
924 |
|
925 |
public static function admin_bar_configure() {
|
@@ -981,9 +982,11 @@ class FrmFormsController {
|
|
981 |
global $frm_vars;
|
982 |
if ( isset($frm_vars['skip_shortcode']) && $frm_vars['skip_shortcode'] ) {
|
983 |
$sc = '[formidable';
|
984 |
-
|
985 |
-
|
986 |
-
|
|
|
|
|
987 |
return $sc .']';
|
988 |
}
|
989 |
|
@@ -1015,7 +1018,7 @@ class FrmFormsController {
|
|
1015 |
return __( 'Please select a valid form', 'formidable' );
|
1016 |
}
|
1017 |
|
1018 |
-
|
1019 |
FrmAppHelper::trigger_hook_load( 'form', $form );
|
1020 |
|
1021 |
$form = apply_filters( 'frm_pre_display_form', $form );
|
@@ -1061,7 +1064,7 @@ class FrmFormsController {
|
|
1061 |
ob_start();
|
1062 |
|
1063 |
self::get_form_contents( $form, $title, $description, $atts );
|
1064 |
-
|
1065 |
|
1066 |
$contents = ob_get_contents();
|
1067 |
ob_end_clean();
|
@@ -1071,6 +1074,10 @@ class FrmFormsController {
|
|
1071 |
return $contents;
|
1072 |
}
|
1073 |
|
|
|
|
|
|
|
|
|
1074 |
public static function get_form_contents($form, $title, $description, $atts) {
|
1075 |
global $frm_vars;
|
1076 |
|
@@ -1079,9 +1086,7 @@ class FrmFormsController {
|
|
1079 |
$submit = isset($form->options['submit_value']) ? $form->options['submit_value'] : $frm_settings->submit_value;
|
1080 |
|
1081 |
$user_ID = get_current_user_id();
|
1082 |
-
|
1083 |
-
$params = FrmEntriesController::get_params($form);
|
1084 |
-
|
1085 |
$message = $errors = '';
|
1086 |
|
1087 |
if ( $params['posted_form_id'] == $form->id && $_POST ) {
|
@@ -1135,7 +1140,7 @@ class FrmFormsController {
|
|
1135 |
require(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/new.php');
|
1136 |
} else {
|
1137 |
global $frm_vars;
|
1138 |
-
|
1139 |
|
1140 |
$include_extra_container = 'frm_forms'. FrmFormsHelper::get_form_style_class($values);
|
1141 |
include(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/errors.php');
|
@@ -1144,6 +1149,41 @@ class FrmFormsController {
|
|
1144 |
do_action( 'frm_after_entry_processed', array( 'entry_id' => $created, 'form' => $form ) );
|
1145 |
}
|
1146 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1147 |
/**
|
1148 |
* @since 2.0.8
|
1149 |
*/
|
2 |
|
3 |
class FrmFormsController {
|
4 |
|
|
|
|
|
|
|
|
|
5 |
public static function menu() {
|
6 |
add_submenu_page('formidable', 'Formidable | '. __( 'Forms', 'formidable' ), __( 'Forms', 'formidable' ), 'frm_view_forms', 'formidable', 'FrmFormsController::route' );
|
7 |
|
8 |
add_filter('get_user_option_managetoplevel_page_formidablecolumnshidden', 'FrmFormsController::hidden_columns' );
|
9 |
|
10 |
add_filter('manage_toplevel_page_formidable_columns', 'FrmFormsController::get_columns', 0 );
|
|
|
11 |
}
|
12 |
|
13 |
public static function head() {
|
26 |
public static function list_form() {
|
27 |
FrmAppHelper::permission_check('frm_view_forms');
|
28 |
|
29 |
+
$params = FrmForm::list_page_params();
|
30 |
$errors = self::process_bulk_form_actions( array());
|
31 |
$errors = apply_filters('frm_admin_list_form_action', $errors);
|
32 |
|
44 |
if ( $action == 'create' ) {
|
45 |
return self::create($values);
|
46 |
} else if ( $action == 'new' ) {
|
47 |
+
$frm_field_selection = FrmField::field_selection();
|
48 |
$values = FrmFormsHelper::setup_new_vars($values);
|
49 |
$id = FrmForm::create( $values );
|
50 |
$form = FrmForm::getOne($id);
|
84 |
|
85 |
if ( count($errors) > 0 ) {
|
86 |
$hide_preview = true;
|
87 |
+
$frm_field_selection = FrmField::field_selection();
|
88 |
$form = FrmForm::getOne( $id );
|
89 |
$fields = FrmField::get_all_for_form($id);
|
90 |
|
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 ) {
|
233 |
}
|
234 |
|
235 |
public static function page_preview() {
|
236 |
+
$params = FrmForm::list_page_params();
|
237 |
if ( ! $params['form'] ) {
|
238 |
return;
|
239 |
}
|
259 |
$wp->register_globals();
|
260 |
}
|
261 |
|
262 |
+
self::register_pro_scripts();
|
|
|
|
|
263 |
|
264 |
header( 'Content-Type: text/html; charset='. get_option( 'blog_charset' ) );
|
265 |
|
277 |
wp_die();
|
278 |
}
|
279 |
|
280 |
+
public static function register_pro_scripts() {
|
281 |
+
if ( FrmAppHelper::pro_is_installed() ) {
|
282 |
+
wp_register_script( 'jquery-frm-rating', FrmAppHelper::plugin_url() . '/pro/js/jquery.rating.min.js', array( 'jquery' ), '4.11', true );
|
283 |
+
wp_register_script( 'jquery-maskedinput', FrmAppHelper::plugin_url() . '/pro/js/jquery.maskedinput.min.js', array( 'jquery' ), '1.4', true );
|
284 |
+
wp_register_script( 'jquery-chosen', FrmAppHelper::plugin_url() .'/pro/js/chosen.jquery.min.js', array( 'jquery' ), '1.2.0', true );
|
285 |
+
}
|
286 |
+
}
|
287 |
+
|
288 |
public static function untrash() {
|
289 |
+
self::change_form_status( 'untrash' );
|
290 |
}
|
291 |
|
292 |
public static function bulk_untrash($ids) {
|
299 |
}
|
300 |
|
301 |
public static function trash() {
|
302 |
+
self::change_form_status( 'trash' );
|
303 |
}
|
304 |
|
305 |
+
/**
|
306 |
+
* @param string $status
|
307 |
+
*
|
308 |
+
* @return int The number of forms changed
|
309 |
+
*/
|
310 |
+
public static function change_form_status( $status ) {
|
311 |
+
$available_status = array(
|
312 |
+
'untrash' => array( 'permission' => 'frm_edit_forms', 'new_status' => 'published' ),
|
313 |
+
'trash' => array( 'permission' => 'frm_delete_forms', 'new_status' => 'trash' ),
|
314 |
+
);
|
315 |
+
|
316 |
+
if ( ! isset( $available_status[ $status ] ) ) {
|
317 |
+
return;
|
318 |
+
}
|
319 |
+
|
320 |
+
FrmAppHelper::permission_check( $available_status[ $status ]['permission'] );
|
321 |
+
|
322 |
+
$params = FrmForm::list_page_params();
|
323 |
+
|
324 |
+
//check nonce url
|
325 |
+
check_admin_referer($status .'_form_' . $params['id']);
|
326 |
+
|
327 |
+
$count = 0;
|
328 |
+
if ( FrmForm::set_status( $params['id'], $available_status[ $status ]['new_status'] ) ) {
|
329 |
+
$count++;
|
330 |
+
}
|
331 |
+
|
332 |
+
$available_status['untrash']['message'] = sprintf(_n( '%1$s form restored from the Trash.', '%1$s forms restored from the Trash.', $count, 'formidable' ), $count );
|
333 |
+
$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='. ( isset( $_REQUEST['form_type'] ) ? sanitize_title( $_REQUEST['form_type'] ) : '' ) . '&id=' . $params['id'], 'untrash_form_' . $params['id'] ) ) . '">', '</a>' );
|
334 |
+
|
335 |
+
$message = $available_status[ $status ]['message'];
|
336 |
+
|
337 |
+
self::display_forms_list( $params, $message );
|
338 |
+
}
|
339 |
+
|
340 |
public static function bulk_trash($ids) {
|
341 |
FrmAppHelper::permission_check('frm_delete_forms');
|
342 |
|
356 |
public static function destroy() {
|
357 |
FrmAppHelper::permission_check('frm_delete_forms');
|
358 |
|
359 |
+
$params = FrmForm::list_page_params();
|
360 |
|
361 |
//check nonce url
|
362 |
check_admin_referer('destroy_form_' . $params['id']);
|
395 |
return;
|
396 |
}
|
397 |
|
398 |
+
$count = FrmForm::scheduled_delete( time() );
|
399 |
$message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count);
|
400 |
|
401 |
self::display_forms_list( array(), $message );
|
402 |
}
|
403 |
|
404 |
+
public static function scheduled_delete( $delete_timestamp = '' ) {
|
405 |
+
_deprecated_function( __FUNCTION__, '2.0.9', 'FrmForm::scheduled_delete' );
|
406 |
+
return FrmForm::scheduled_delete( $delete_timestamp );
|
407 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
408 |
|
409 |
public static function insert_form_button($content) {
|
410 |
if ( current_user_can('frm_view_forms') ) {
|
480 |
global $wpdb, $frm_vars;
|
481 |
|
482 |
if ( empty( $params ) ) {
|
483 |
+
$params = FrmForm::list_page_params();
|
484 |
}
|
485 |
|
486 |
$wp_list_table = new FrmFormsListHelper( compact( 'params' ) );
|
517 |
|
518 |
$columns['created_at'] = __( 'Date', 'formidable' );
|
519 |
|
520 |
+
add_screen_option( 'per_page', array( 'label' => __( 'Forms', 'formidable' ), 'default' => 20, 'option' => 'formidable_page_formidable_per_page' ) );
|
521 |
|
522 |
return $columns;
|
523 |
}
|
524 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
525 |
public static function hidden_columns( $result ) {
|
526 |
$return = false;
|
527 |
foreach ( (array) $result as $r ) {
|
565 |
wp_die( sprintf(__( 'You are trying to edit a child form. Please edit from %1$shere%2$s', 'formidable' ), '<a href="'. esc_url(admin_url('admin.php') .'?page=formidable&frm_action=edit&id='. $form->parent_form_id) .'">', '</a>' ));
|
566 |
}
|
567 |
|
568 |
+
$frm_field_selection = FrmField::field_selection();
|
569 |
$fields = FrmField::get_all_for_form($form->id);
|
570 |
|
571 |
// Automatically add end section fields if they don't exist (2.0 migration)
|
711 |
|
712 |
public static function get_email_html() {
|
713 |
check_ajax_referer( 'frm_ajax', 'nonce' );
|
714 |
+
echo FrmEntryFormat::show_entry( array(
|
715 |
'form_id' => FrmAppHelper::get_post_param( 'form_id', '', 'absint' ),
|
716 |
'default_email' => true,
|
717 |
'plain_text' => FrmAppHelper::get_post_param( 'plain_text', '', 'absint' ),
|
741 |
$entry = FrmAppHelper::get_post_param( 'id', false, 'sanitize_title' );
|
742 |
}
|
743 |
|
744 |
+
FrmEntry::maybe_get_entry( $entry );
|
745 |
}
|
746 |
}
|
747 |
|
875 |
}
|
876 |
}
|
877 |
|
878 |
+
add_action( 'frm_load_form_hooks', 'FrmHooksController::trigger_load_form_hooks' );
|
879 |
FrmAppHelper::trigger_hook_load( 'form' );
|
880 |
|
881 |
switch ( $action ) {
|
920 |
|
921 |
/* FRONT-END FORMS */
|
922 |
public static function admin_bar_css() {
|
923 |
+
FrmAppHelper::load_font_style();
|
924 |
}
|
925 |
|
926 |
public static function admin_bar_configure() {
|
982 |
global $frm_vars;
|
983 |
if ( isset($frm_vars['skip_shortcode']) && $frm_vars['skip_shortcode'] ) {
|
984 |
$sc = '[formidable';
|
985 |
+
if ( ! empty( $atts ) ) {
|
986 |
+
foreach ( $atts as $k => $v ) {
|
987 |
+
$sc .= ' ' . $k . '="' . esc_attr( $v ) . '"';
|
988 |
+
}
|
989 |
+
}
|
990 |
return $sc .']';
|
991 |
}
|
992 |
|
1018 |
return __( 'Please select a valid form', 'formidable' );
|
1019 |
}
|
1020 |
|
1021 |
+
add_action( 'frm_load_form_hooks', 'FrmHooksController::trigger_load_form_hooks' );
|
1022 |
FrmAppHelper::trigger_hook_load( 'form', $form );
|
1023 |
|
1024 |
$form = apply_filters( 'frm_pre_display_form', $form );
|
1064 |
ob_start();
|
1065 |
|
1066 |
self::get_form_contents( $form, $title, $description, $atts );
|
1067 |
+
self::enqueue_scripts( FrmForm::get_params( $form ) );
|
1068 |
|
1069 |
$contents = ob_get_contents();
|
1070 |
ob_end_clean();
|
1074 |
return $contents;
|
1075 |
}
|
1076 |
|
1077 |
+
public static function enqueue_scripts( $params ) {
|
1078 |
+
do_action( 'frm_enqueue_form_scripts', $params );
|
1079 |
+
}
|
1080 |
+
|
1081 |
public static function get_form_contents($form, $title, $description, $atts) {
|
1082 |
global $frm_vars;
|
1083 |
|
1086 |
$submit = isset($form->options['submit_value']) ? $form->options['submit_value'] : $frm_settings->submit_value;
|
1087 |
|
1088 |
$user_ID = get_current_user_id();
|
1089 |
+
$params = FrmForm::get_params( $form );
|
|
|
|
|
1090 |
$message = $errors = '';
|
1091 |
|
1092 |
if ( $params['posted_form_id'] == $form->id && $_POST ) {
|
1140 |
require(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/new.php');
|
1141 |
} else {
|
1142 |
global $frm_vars;
|
1143 |
+
self::maybe_load_css( $form, $values['custom_style'], $frm_vars['load_css'] );
|
1144 |
|
1145 |
$include_extra_container = 'frm_forms'. FrmFormsHelper::get_form_style_class($values);
|
1146 |
include(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/errors.php');
|
1149 |
do_action( 'frm_after_entry_processed', array( 'entry_id' => $created, 'form' => $form ) );
|
1150 |
}
|
1151 |
|
1152 |
+
public static function front_head() {
|
1153 |
+
$version = FrmAppHelper::plugin_version();
|
1154 |
+
wp_register_script( 'formidable', FrmAppHelper::plugin_url() . '/js/formidable.min.js', array( 'jquery' ), $version, true );
|
1155 |
+
wp_register_script( 'jquery-placeholder', FrmAppHelper::plugin_url() . '/js/jquery/jquery.placeholder.js', array( 'jquery' ), '2.0.7', true );
|
1156 |
+
|
1157 |
+
if ( FrmAppHelper::is_admin() ) {
|
1158 |
+
// don't load this in back-end
|
1159 |
+
return;
|
1160 |
+
}
|
1161 |
+
|
1162 |
+
FrmAppHelper::localize_script( 'front' );
|
1163 |
+
FrmStylesController::enqueue_css( 'register' );
|
1164 |
+
}
|
1165 |
+
|
1166 |
+
public static function maybe_load_css( $form, $this_load, $global_load ) {
|
1167 |
+
$load_css = FrmForm::is_form_loaded( $form, $this_load, $global_load );
|
1168 |
+
|
1169 |
+
if ( $load_css ) {
|
1170 |
+
global $frm_vars;
|
1171 |
+
self::footer_js( 'header' );
|
1172 |
+
$frm_vars['css_loaded'] = true;
|
1173 |
+
}
|
1174 |
+
}
|
1175 |
+
|
1176 |
+
public static function footer_js( $location = 'footer' ) {
|
1177 |
+
global $frm_vars;
|
1178 |
+
|
1179 |
+
FrmStylesController::enqueue_css();
|
1180 |
+
|
1181 |
+
if ( ! FrmAppHelper::is_admin() && $location != 'header' && ! empty( $frm_vars['forms_loaded'] ) ) {
|
1182 |
+
//load formidable js
|
1183 |
+
wp_enqueue_script( 'formidable' );
|
1184 |
+
}
|
1185 |
+
}
|
1186 |
+
|
1187 |
/**
|
1188 |
* @since 2.0.8
|
1189 |
*/
|
classes/controllers/FrmHooksController.php
CHANGED
@@ -39,15 +39,17 @@ class FrmHooksController {
|
|
39 |
|
40 |
}
|
41 |
|
|
|
|
|
|
|
|
|
42 |
public static function load_hooks() {
|
43 |
if ( ! is_admin() ) {
|
44 |
add_filter( 'the_content', 'FrmAppController::page_route', 10 );
|
45 |
}
|
46 |
|
47 |
add_action( 'plugins_loaded', 'FrmAppController::load_lang' );
|
48 |
-
add_action( 'init', 'FrmAppController::front_head' );
|
49 |
add_filter( 'widget_text', 'FrmAppController::widget_text_filter', 8 );
|
50 |
-
add_action( 'wp_footer', 'FrmAppController::footer_js', 1, 0 );
|
51 |
|
52 |
// Entries controller
|
53 |
add_action( 'wp', 'FrmEntriesController::process_entry', 10, 0 );
|
@@ -63,11 +65,14 @@ class FrmHooksController {
|
|
63 |
|
64 |
// Forms Controller
|
65 |
add_action( 'widgets_init', 'FrmFormsController::register_widgets' );
|
|
|
66 |
add_filter( 'frm_content', 'FrmFormsController::filter_content', 10, 3 );
|
67 |
add_filter( 'frm_replace_content_shortcodes', 'FrmFormsController::replace_content_shortcodes', 20, 3 );
|
68 |
add_action( 'admin_bar_init', 'FrmFormsController::admin_bar_css' );
|
69 |
add_action( 'wp_before_admin_bar_render', 'FrmFormsController::admin_bar_configure' );
|
70 |
-
|
|
|
|
|
71 |
|
72 |
// Form Shortcodes
|
73 |
add_shortcode( 'formidable', 'FrmFormsController::get_form_shortcode' );
|
@@ -84,6 +89,8 @@ class FrmHooksController {
|
|
84 |
add_action( 'admin_enqueue_scripts', 'FrmAppController::load_wp_admin_style' );
|
85 |
add_action( 'admin_notices', 'FrmAppController::pro_get_started_headline' );
|
86 |
add_action( 'admin_init', 'FrmAppController::admin_init', 11 );
|
|
|
|
|
87 |
register_activation_hook( FrmAppHelper::plugin_path() . '/formidable.php', 'FrmAppController::activation_install' );
|
88 |
|
89 |
// Entries Controller
|
@@ -137,9 +144,6 @@ class FrmHooksController {
|
|
137 |
add_action( 'wp_ajax_frm_uninstall', 'FrmAppController::uninstall' );
|
138 |
add_action( 'wp_ajax_frm_deauthorize', 'FrmAppController::deauthorize' );
|
139 |
|
140 |
-
add_action( 'wp_ajax_frmpro_css', 'FrmAppController::load_css' );
|
141 |
-
add_action( 'wp_ajax_nopriv_frmpro_css', 'FrmAppController::load_css' );
|
142 |
-
|
143 |
// Fields Controller
|
144 |
add_action( 'wp_ajax_frm_load_field', 'FrmFieldsController::load_field' );
|
145 |
add_action( 'wp_ajax_frm_insert_field', 'FrmFieldsController::create' );
|
@@ -174,6 +178,8 @@ class FrmHooksController {
|
|
174 |
add_action( 'wp_ajax_frm_change_styling', 'FrmStylesController::change_styling' );
|
175 |
add_action( 'wp_ajax_frmpro_load_css', 'FrmStylesController::load_css' );
|
176 |
add_action( 'wp_ajax_nopriv_frmpro_load_css', 'FrmStylesController::load_css' );
|
|
|
|
|
177 |
|
178 |
// XML Controller
|
179 |
add_action( 'wp_ajax_frm_export_xml', 'FrmXMLController::export_xml' );
|
@@ -198,6 +204,7 @@ class FrmHooksController {
|
|
198 |
}
|
199 |
|
200 |
public static function load_multisite_hooks() {
|
|
|
201 |
add_action( 'wpmu_upgrade_site', 'FrmAppController::network_upgrade_site' );
|
202 |
|
203 |
// drop tables when mu site is deleted
|
39 |
|
40 |
}
|
41 |
|
42 |
+
public static function trigger_load_form_hooks() {
|
43 |
+
self::trigger_load_hook( 'load_form_hooks' );
|
44 |
+
}
|
45 |
+
|
46 |
public static function load_hooks() {
|
47 |
if ( ! is_admin() ) {
|
48 |
add_filter( 'the_content', 'FrmAppController::page_route', 10 );
|
49 |
}
|
50 |
|
51 |
add_action( 'plugins_loaded', 'FrmAppController::load_lang' );
|
|
|
52 |
add_filter( 'widget_text', 'FrmAppController::widget_text_filter', 8 );
|
|
|
53 |
|
54 |
// Entries controller
|
55 |
add_action( 'wp', 'FrmEntriesController::process_entry', 10, 0 );
|
65 |
|
66 |
// Forms Controller
|
67 |
add_action( 'widgets_init', 'FrmFormsController::register_widgets' );
|
68 |
+
add_action( 'init', 'FrmFormsController::front_head' );
|
69 |
add_filter( 'frm_content', 'FrmFormsController::filter_content', 10, 3 );
|
70 |
add_filter( 'frm_replace_content_shortcodes', 'FrmFormsController::replace_content_shortcodes', 20, 3 );
|
71 |
add_action( 'admin_bar_init', 'FrmFormsController::admin_bar_css' );
|
72 |
add_action( 'wp_before_admin_bar_render', 'FrmFormsController::admin_bar_configure' );
|
73 |
+
add_action( 'wp_footer', 'FrmFormsController::footer_js', 1, 0 );
|
74 |
+
|
75 |
+
add_action( 'wp_scheduled_delete', 'FrmForm::scheduled_delete' );
|
76 |
|
77 |
// Form Shortcodes
|
78 |
add_shortcode( 'formidable', 'FrmFormsController::get_form_shortcode' );
|
89 |
add_action( 'admin_enqueue_scripts', 'FrmAppController::load_wp_admin_style' );
|
90 |
add_action( 'admin_notices', 'FrmAppController::pro_get_started_headline' );
|
91 |
add_action( 'admin_init', 'FrmAppController::admin_init', 11 );
|
92 |
+
add_filter( 'admin_body_class', 'FrmAppController::wp_admin_body_class' );
|
93 |
+
add_filter( 'plugin_action_links_' . FrmAppHelper::plugin_folder() . '/formidable.php', 'FrmAppController::settings_link' );
|
94 |
register_activation_hook( FrmAppHelper::plugin_path() . '/formidable.php', 'FrmAppController::activation_install' );
|
95 |
|
96 |
// Entries Controller
|
144 |
add_action( 'wp_ajax_frm_uninstall', 'FrmAppController::uninstall' );
|
145 |
add_action( 'wp_ajax_frm_deauthorize', 'FrmAppController::deauthorize' );
|
146 |
|
|
|
|
|
|
|
147 |
// Fields Controller
|
148 |
add_action( 'wp_ajax_frm_load_field', 'FrmFieldsController::load_field' );
|
149 |
add_action( 'wp_ajax_frm_insert_field', 'FrmFieldsController::create' );
|
178 |
add_action( 'wp_ajax_frm_change_styling', 'FrmStylesController::change_styling' );
|
179 |
add_action( 'wp_ajax_frmpro_load_css', 'FrmStylesController::load_css' );
|
180 |
add_action( 'wp_ajax_nopriv_frmpro_load_css', 'FrmStylesController::load_css' );
|
181 |
+
add_action( 'wp_ajax_frmpro_css', 'FrmStylesController::load_saved_css' );
|
182 |
+
add_action( 'wp_ajax_nopriv_frmpro_css', 'FrmStylesController::load_saved_css' );
|
183 |
|
184 |
// XML Controller
|
185 |
add_action( 'wp_ajax_frm_export_xml', 'FrmXMLController::export_xml' );
|
204 |
}
|
205 |
|
206 |
public static function load_multisite_hooks() {
|
207 |
+
add_action( 'init', 'FrmAppController::front_head' );
|
208 |
add_action( 'wpmu_upgrade_site', 'FrmAppController::network_upgrade_site' );
|
209 |
|
210 |
// drop tables when mu site is deleted
|
classes/controllers/FrmStylesController.php
CHANGED
@@ -64,6 +64,70 @@ class FrmStylesController {
|
|
64 |
}
|
65 |
}
|
66 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
67 |
public static function new_style($return = '') {
|
68 |
FrmAppHelper::update_message( __( 'create multiple styling templates', 'formidable' ), 'wrap' );
|
69 |
self::load_styler('default');
|
@@ -284,6 +348,13 @@ class FrmStylesController {
|
|
284 |
wp_die();
|
285 |
}
|
286 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
287 |
/**
|
288 |
* Check if the Formidable styling should be loaded,
|
289 |
* then enqueue it for the footer
|
64 |
}
|
65 |
}
|
66 |
|
67 |
+
public static function enqueue_css( $register = 'enqueue' ) {
|
68 |
+
global $frm_vars;
|
69 |
+
$register_css = ( $register == 'register' );
|
70 |
+
if ( ( $frm_vars['load_css'] || $register_css ) && ! FrmAppHelper::is_admin() ) {
|
71 |
+
$frm_settings = FrmAppHelper::get_settings();
|
72 |
+
if ( $frm_settings->load_style == 'none' ) {
|
73 |
+
return;
|
74 |
+
}
|
75 |
+
|
76 |
+
$css = apply_filters( 'get_frm_stylesheet', self::custom_stylesheet() );
|
77 |
+
|
78 |
+
if ( ! empty( $css ) ) {
|
79 |
+
$version = FrmAppHelper::plugin_version();
|
80 |
+
|
81 |
+
foreach ( (array) $css as $css_key => $file ) {
|
82 |
+
if ( $register == 'register' ) {
|
83 |
+
wp_register_style( $css_key, $file, array(), $version );
|
84 |
+
}
|
85 |
+
|
86 |
+
if ( 'all' == $frm_settings->load_style || $register != 'register' ) {
|
87 |
+
wp_enqueue_style( $css_key );
|
88 |
+
}
|
89 |
+
unset( $css_key, $file );
|
90 |
+
}
|
91 |
+
|
92 |
+
if ( $frm_settings->load_style == 'all' ) {
|
93 |
+
$frm_vars['css_loaded'] = true;
|
94 |
+
}
|
95 |
+
}
|
96 |
+
unset( $css );
|
97 |
+
}
|
98 |
+
}
|
99 |
+
|
100 |
+
public static function custom_stylesheet() {
|
101 |
+
global $frm_vars;
|
102 |
+
$stylesheet_urls = array();
|
103 |
+
self::maybe_enqueue_jquery_css();
|
104 |
+
|
105 |
+
if ( ! isset( $frm_vars['css_loaded'] ) || ! $frm_vars['css_loaded'] ) {
|
106 |
+
//include css in head
|
107 |
+
self::get_url_to_custom_style( $stylesheet_urls );
|
108 |
+
}
|
109 |
+
|
110 |
+
return $stylesheet_urls;
|
111 |
+
}
|
112 |
+
|
113 |
+
private static function get_url_to_custom_style( &$stylesheet_urls ) {
|
114 |
+
$uploads = FrmStylesHelper::get_upload_base();
|
115 |
+
$saved_css_path = '/formidable/css/formidablepro.css';
|
116 |
+
if ( is_readable( $uploads['basedir'] . $saved_css_path ) ) {
|
117 |
+
$url = $uploads['baseurl'] . $saved_css_path;
|
118 |
+
} else {
|
119 |
+
$url = admin_url( 'admin-ajax.php' ) . '?action=frmpro_css';
|
120 |
+
}
|
121 |
+
$stylesheet_urls['formidable'] = $url;
|
122 |
+
}
|
123 |
+
|
124 |
+
private static function maybe_enqueue_jquery_css() {
|
125 |
+
global $frm_vars;
|
126 |
+
if ( isset( $frm_vars['datepicker_loaded'] ) && ! empty( $frm_vars['datepicker_loaded'] ) ) {
|
127 |
+
FrmStylesHelper::enqueue_jquery_css();
|
128 |
+
}
|
129 |
+
}
|
130 |
+
|
131 |
public static function new_style($return = '') {
|
132 |
FrmAppHelper::update_message( __( 'create multiple styling templates', 'formidable' ), 'wrap' );
|
133 |
self::load_styler('default');
|
348 |
wp_die();
|
349 |
}
|
350 |
|
351 |
+
public static function load_saved_css() {
|
352 |
+
$css = get_transient( 'frmpro_css' );
|
353 |
+
|
354 |
+
include( FrmAppHelper::plugin_path() . '/css/custom_theme.css.php' );
|
355 |
+
wp_die();
|
356 |
+
}
|
357 |
+
|
358 |
/**
|
359 |
* Check if the Formidable styling should be loaded,
|
360 |
* then enqueue it for the footer
|
classes/helpers/FrmAppHelper.php
CHANGED
@@ -5,7 +5,7 @@ if ( ! defined('ABSPATH') ) {
|
|
5 |
|
6 |
class FrmAppHelper {
|
7 |
public static $db_version = 26; //version of the database we are moving to
|
8 |
-
public static $pro_db_version =
|
9 |
|
10 |
/**
|
11 |
* @since 2.0
|
@@ -43,6 +43,11 @@ class FrmAppHelper {
|
|
43 |
return $url;
|
44 |
}
|
45 |
|
|
|
|
|
|
|
|
|
|
|
46 |
/**
|
47 |
* @return string Site URL
|
48 |
*/
|
@@ -169,6 +174,10 @@ class FrmAppHelper {
|
|
169 |
return ( is_array( $value ) && empty( $value ) ) || $value == $empty;
|
170 |
}
|
171 |
|
|
|
|
|
|
|
|
|
172 |
/**
|
173 |
* Get any value from the $_SERVER
|
174 |
*
|
@@ -324,6 +333,13 @@ class FrmAppHelper {
|
|
324 |
}
|
325 |
}
|
326 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
327 |
/**
|
328 |
* Sanitize the value, and allow some HTML
|
329 |
* @since 2.0
|
@@ -564,21 +580,6 @@ class FrmAppHelper {
|
|
564 |
}
|
565 |
}
|
566 |
|
567 |
-
/**
|
568 |
-
* Make sure admins have permission to see the menu items
|
569 |
-
* @since 2.0.6
|
570 |
-
*/
|
571 |
-
public static function force_capability( $cap = 'frm_change_settings' ) {
|
572 |
-
// Make sure admins can see the menu items
|
573 |
-
if ( current_user_can( 'administrator' ) && ! current_user_can( $cap ) ) {
|
574 |
-
$role = get_role( 'administrator' );
|
575 |
-
$frm_roles = self::frm_capabilities();
|
576 |
-
foreach ( $frm_roles as $frm_role => $frm_role_description ) {
|
577 |
-
$role->add_cap( $frm_role );
|
578 |
-
}
|
579 |
-
}
|
580 |
-
}
|
581 |
-
|
582 |
public static function frm_capabilities($type = 'auto') {
|
583 |
$cap = array(
|
584 |
'frm_view_forms' => __( 'View Forms and Templates', 'formidable' ),
|
@@ -644,6 +645,20 @@ class FrmAppHelper {
|
|
644 |
}
|
645 |
}
|
646 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
647 |
/**
|
648 |
* Check if the user has permision for action.
|
649 |
* Return permission message and stop the action if no permission
|
@@ -1030,7 +1045,7 @@ class FrmAppHelper {
|
|
1030 |
private static function fill_form_opts($record, $table, $post_values, array &$values) {
|
1031 |
if ( $table == 'entries' ) {
|
1032 |
$form = $record->form_id;
|
1033 |
-
|
1034 |
} else {
|
1035 |
$form = $record;
|
1036 |
}
|
@@ -1661,6 +1676,61 @@ class FrmAppHelper {
|
|
1661 |
}
|
1662 |
}
|
1663 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1664 |
/**
|
1665 |
* @since 1.07.10
|
1666 |
*
|
5 |
|
6 |
class FrmAppHelper {
|
7 |
public static $db_version = 26; //version of the database we are moving to
|
8 |
+
public static $pro_db_version = 28;
|
9 |
|
10 |
/**
|
11 |
* @since 2.0
|
43 |
return $url;
|
44 |
}
|
45 |
|
46 |
+
public static function relative_plugin_url( $url = '' ) {
|
47 |
+
$url = self::plugin_url( $url );
|
48 |
+
return str_replace( array( 'https:', 'http:' ), '', $url );
|
49 |
+
}
|
50 |
+
|
51 |
/**
|
52 |
* @return string Site URL
|
53 |
*/
|
174 |
return ( is_array( $value ) && empty( $value ) ) || $value == $empty;
|
175 |
}
|
176 |
|
177 |
+
public static function is_not_empty_value( $value, $empty = '' ) {
|
178 |
+
return ! self::is_empty_value( $value, $empty );
|
179 |
+
}
|
180 |
+
|
181 |
/**
|
182 |
* Get any value from the $_SERVER
|
183 |
*
|
333 |
}
|
334 |
}
|
335 |
|
336 |
+
public static function sanitize_array( &$values ) {
|
337 |
+
$temp_values = $values;
|
338 |
+
foreach ( $temp_values as $k => $val ) {
|
339 |
+
$values[ $k ] = wp_kses_post( $val );
|
340 |
+
}
|
341 |
+
}
|
342 |
+
|
343 |
/**
|
344 |
* Sanitize the value, and allow some HTML
|
345 |
* @since 2.0
|
580 |
}
|
581 |
}
|
582 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
583 |
public static function frm_capabilities($type = 'auto') {
|
584 |
$cap = array(
|
585 |
'frm_view_forms' => __( 'View Forms and Templates', 'formidable' ),
|
645 |
}
|
646 |
}
|
647 |
|
648 |
+
/**
|
649 |
+
* Make sure admins have permission to see the menu items
|
650 |
+
* @since 2.0.6
|
651 |
+
*/
|
652 |
+
public static function force_capability( $cap = 'frm_change_settings' ) {
|
653 |
+
if ( current_user_can( 'administrator' ) && ! current_user_can( $cap ) ) {
|
654 |
+
$role = get_role( 'administrator' );
|
655 |
+
$frm_roles = self::frm_capabilities();
|
656 |
+
foreach ( $frm_roles as $frm_role => $frm_role_description ) {
|
657 |
+
$role->add_cap( $frm_role );
|
658 |
+
}
|
659 |
+
}
|
660 |
+
}
|
661 |
+
|
662 |
/**
|
663 |
* Check if the user has permision for action.
|
664 |
* Return permission message and stop the action if no permission
|
1045 |
private static function fill_form_opts($record, $table, $post_values, array &$values) {
|
1046 |
if ( $table == 'entries' ) {
|
1047 |
$form = $record->form_id;
|
1048 |
+
FrmForm::maybe_get_form( $form );
|
1049 |
} else {
|
1050 |
$form = $record;
|
1051 |
}
|
1676 |
}
|
1677 |
}
|
1678 |
|
1679 |
+
/**
|
1680 |
+
* @since 2.0.9
|
1681 |
+
*/
|
1682 |
+
public static function load_font_style() {
|
1683 |
+
wp_enqueue_style( 'frm_fonts', self::plugin_url() . '/css/frm_fonts.css', array(), self::plugin_version() );
|
1684 |
+
}
|
1685 |
+
|
1686 |
+
/**
|
1687 |
+
* @param string $location
|
1688 |
+
*/
|
1689 |
+
public static function localize_script( $location ) {
|
1690 |
+
wp_localize_script( 'formidable', 'frm_js', array(
|
1691 |
+
'ajax_url' => admin_url( 'admin-ajax.php' ),
|
1692 |
+
'images_url' => self::plugin_url() . '/images',
|
1693 |
+
'loading' => __( 'Loading…' ),
|
1694 |
+
'remove' => __( 'Remove', 'formidable' ),
|
1695 |
+
'offset' => apply_filters( 'frm_scroll_offset', 4 ),
|
1696 |
+
'nonce' => wp_create_nonce( 'frm_ajax' ),
|
1697 |
+
'id' => __( 'ID', 'formidable' ),
|
1698 |
+
) );
|
1699 |
+
|
1700 |
+
if ( $location == 'admin' ) {
|
1701 |
+
$frm_settings = self::get_settings();
|
1702 |
+
wp_localize_script( 'formidable_admin', 'frm_admin_js', array(
|
1703 |
+
'confirm_uninstall' => __( 'Are you sure you want to do this? Clicking OK will delete all forms, form data, and all other Formidable data. There is no Undo.', 'formidable' ),
|
1704 |
+
'desc' => __( '(Click to add description)', 'formidable' ),
|
1705 |
+
'blank' => __( '(blank)', 'formidable' ),
|
1706 |
+
'no_label' => __( '(no label)', 'formidable' ),
|
1707 |
+
'saving' => esc_attr( __( 'Saving', 'formidable' ) ),
|
1708 |
+
'saved' => esc_attr( __( 'Saved', 'formidable' ) ),
|
1709 |
+
'ok' => __( 'OK' ),
|
1710 |
+
'cancel' => __( 'Cancel', 'formidable' ),
|
1711 |
+
'default' => __( 'Default', 'formidable' ),
|
1712 |
+
'clear_default' => __( 'Clear default value when typing', 'formidable' ),
|
1713 |
+
'no_clear_default' => __( 'Do not clear default value when typing', 'formidable' ),
|
1714 |
+
'valid_default' => __( 'Default value will pass form validation', 'formidable' ),
|
1715 |
+
'no_valid_default' => __( 'Default value will NOT pass form validation', 'formidable' ),
|
1716 |
+
'confirm' => __( 'Are you sure?', 'formidable' ),
|
1717 |
+
'conf_delete' => __( 'Are you sure you want to delete this field and all data associated with it?', 'formidable' ),
|
1718 |
+
'conf_delete_sec' => __( 'WARNING: This will delete all fields inside of the section as well.', 'formidable' ),
|
1719 |
+
'conf_no_repeat' => __( 'Warning: If you have entries with multiple rows, all but the first row will be lost.', 'formidable' ),
|
1720 |
+
'default_unique' => $frm_settings->unique_msg,
|
1721 |
+
'default_conf' => __( 'The entered values do not match', 'formidable' ),
|
1722 |
+
'enter_email' => __( 'Enter Email', 'formidable' ),
|
1723 |
+
'confirm_email' => __( 'Confirm Email', 'formidable' ),
|
1724 |
+
'enter_password' => __( 'Enter Password', 'formidable' ),
|
1725 |
+
'confirm_password' => __( 'Confirm Password', 'formidable' ),
|
1726 |
+
'import_complete' => __( 'Import Complete', 'formidable' ),
|
1727 |
+
'updating' => __( 'Please wait while your site updates.', 'formidable' ),
|
1728 |
+
'no_save_warning' => __( 'Warning: There is no way to retrieve unsaved entries.', 'formidable' ),
|
1729 |
+
'jquery_ui_url' => self::jquery_ui_base_url(),
|
1730 |
+
) );
|
1731 |
+
}
|
1732 |
+
}
|
1733 |
+
|
1734 |
/**
|
1735 |
* @since 1.07.10
|
1736 |
*
|
classes/helpers/FrmEntriesHelper.php
CHANGED
@@ -25,14 +25,14 @@ class FrmEntriesHelper {
|
|
25 |
if ( ! $reset && $_POST && isset( $_POST['item_meta'][ $field->id ] ) && $_POST['item_meta'][ $field->id ] != '' ) {
|
26 |
$new_value = stripslashes_deep( $_POST['item_meta'][ $field->id ] );
|
27 |
$posted_val = true;
|
28 |
-
} else if (
|
29 |
$new_value = '';
|
30 |
}
|
31 |
|
32 |
$is_default = ($new_value == $default) ? true : false;
|
33 |
|
34 |
//If checkbox, multi-select dropdown, or checkbox data from entries field, set return array to true
|
35 |
-
|
36 |
|
37 |
$field->default_value = apply_filters('frm_get_default_value', $field->default_value, $field, true, $return_array);
|
38 |
|
@@ -113,282 +113,28 @@ class FrmEntriesHelper {
|
|
113 |
}
|
114 |
|
115 |
public static function get_admin_params( $form = null ) {
|
116 |
-
|
117 |
-
|
118 |
-
$form_id = self::get_current_form_id();
|
119 |
-
} else if ( $form && is_object($form) ) {
|
120 |
-
$form_id = $form->id;
|
121 |
-
}
|
122 |
-
|
123 |
-
$values = array();
|
124 |
-
foreach ( array(
|
125 |
-
'id' => '', 'form_name' => '', 'paged' => 1, 'form' => $form_id,
|
126 |
-
'field_id' => '', 'search' => '', 'sort' => '', 'sdir' => '', 'fid' => '',
|
127 |
-
'keep_post' => '',
|
128 |
-
) as $var => $default ) {
|
129 |
-
$values[ $var ] = FrmAppHelper::get_param( $var, $default );
|
130 |
-
}
|
131 |
-
|
132 |
-
return $values;
|
133 |
-
}
|
134 |
-
|
135 |
-
public static function set_current_form($form_id) {
|
136 |
-
global $frm_vars;
|
137 |
-
|
138 |
-
$query = array();
|
139 |
-
if ( $form_id ) {
|
140 |
-
$query['id'] = $form_id;
|
141 |
-
}
|
142 |
-
|
143 |
-
$frm_vars['current_form'] = FrmForm::get_published_forms( $query, 1 );
|
144 |
-
|
145 |
-
return $frm_vars['current_form'];
|
146 |
}
|
147 |
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
return $frm_vars['current_form'];
|
153 |
-
}
|
154 |
|
155 |
-
|
156 |
-
|
157 |
-
|
|
|
158 |
|
159 |
public static function get_current_form_id() {
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
return $form_id;
|
164 |
}
|
165 |
|
166 |
-
/**
|
167 |
-
* If $entry is numeric, get the entry object
|
168 |
-
* @param int|object $entry by reference
|
169 |
-
*
|
170 |
-
*/
|
171 |
public static function maybe_get_entry( &$entry ) {
|
172 |
-
|
173 |
-
|
174 |
-
}
|
175 |
-
}
|
176 |
-
|
177 |
-
public static function fill_entry_values($atts, $f, array &$values) {
|
178 |
-
if ( FrmFieldsHelper::is_no_save_field( $f->type ) ) {
|
179 |
-
return;
|
180 |
-
}
|
181 |
-
|
182 |
-
if ( $atts['default_email'] ) {
|
183 |
-
$values[ $f->id ] = array( 'label' => '['. $f->id .' show=field_label]', 'val' => '['. $f->id .']' );
|
184 |
-
return;
|
185 |
-
}
|
186 |
-
|
187 |
-
//Remove signature from default-message shortcode
|
188 |
-
if ( $f->type == 'signature' ) {
|
189 |
-
return;
|
190 |
-
}
|
191 |
-
|
192 |
-
if ( $atts['entry'] && ! isset( $atts['entry']->metas[ $f->id ] ) ) {
|
193 |
-
// In case include_blank is set
|
194 |
-
$atts['entry']->metas[ $f->id ] = '';
|
195 |
-
|
196 |
-
if ( FrmAppHelper::pro_is_installed() ) {
|
197 |
-
// If field is a post field
|
198 |
-
if ( $atts['entry']->post_id && ( $f->type == 'tag' || (isset($f->field_options['post_field']) && $f->field_options['post_field'])) ) {
|
199 |
-
$p_val = FrmProEntryMetaHelper::get_post_value($atts['entry']->post_id, $f->field_options['post_field'], $f->field_options['custom_field'], array(
|
200 |
-
'truncate' => (($f->field_options['post_field'] == 'post_category') ? true : false),
|
201 |
-
'form_id' => $atts['entry']->form_id, 'field' => $f, 'type' => $f->type,
|
202 |
-
'exclude_cat' => ( isset( $f->field_options['exclude_cat'] ) ? $f->field_options['exclude_cat'] : 0 ),
|
203 |
-
));
|
204 |
-
if ( $p_val != '' ) {
|
205 |
-
$atts['entry']->metas[ $f->id ] = $p_val;
|
206 |
-
}
|
207 |
-
}
|
208 |
-
|
209 |
-
// If field is in a repeating section
|
210 |
-
if ( $atts['entry']->form_id != $f->form_id ) {
|
211 |
-
// get entry ids linked through repeat field or embeded form
|
212 |
-
$child_entries = FrmProEntry::get_sub_entries($atts['entry']->id, true);
|
213 |
-
$val = FrmProEntryMetaHelper::get_sub_meta_values($child_entries, $f);
|
214 |
-
if ( ! empty( $val ) ) {
|
215 |
-
//Flatten multi-dimensional array for multi-file upload field
|
216 |
-
self::flatten_multi_file_upload( $val, $f );
|
217 |
-
$atts['entry']->metas[ $f->id ] = $val;
|
218 |
-
}
|
219 |
-
} else {
|
220 |
-
$val = '';
|
221 |
-
FrmProEntriesHelper::get_dynamic_list_values( $f, $atts['entry'], $val );
|
222 |
-
$atts['entry']->metas[ $f->id ] = $val;
|
223 |
-
}
|
224 |
-
}
|
225 |
-
}
|
226 |
-
|
227 |
-
$val = '';
|
228 |
-
if ( $atts['entry'] ) {
|
229 |
-
$prev_val = maybe_unserialize( $atts['entry']->metas[ $f->id ] );
|
230 |
-
$meta = array( 'item_id' => $atts['id'], 'field_id' => $f->id, 'meta_value' => $prev_val, 'field_type' => $f->type );
|
231 |
-
|
232 |
-
//This filter applies to the default-message shortcode and frm-show-entry shortcode only
|
233 |
-
if ( isset($atts['filter']) && $atts['filter'] == false ) {
|
234 |
-
$val = $prev_val;
|
235 |
-
} else {
|
236 |
-
$val = apply_filters('frm_email_value', $prev_val, (object) $meta, $atts['entry']);
|
237 |
-
}
|
238 |
-
}
|
239 |
-
|
240 |
-
// Don't include blank values
|
241 |
-
if ( ! $atts['include_blank'] && FrmAppHelper::is_empty_value( $val ) ) {
|
242 |
-
return;
|
243 |
-
}
|
244 |
-
|
245 |
-
self::textarea_display_value( $val, $f->type, $atts['plain_text'] );
|
246 |
-
|
247 |
-
if ( is_array($val) && $atts['format'] == 'text' ) {
|
248 |
-
$val = implode(', ', $val);
|
249 |
-
}
|
250 |
-
|
251 |
-
if ( $atts['format'] != 'text' ) {
|
252 |
-
$values[ $f->field_key ] = $val;
|
253 |
-
} else {
|
254 |
-
$values[ $f->id ] = array( 'label' => $f->name, 'val' => $val );
|
255 |
-
}
|
256 |
-
}
|
257 |
-
|
258 |
-
/**
|
259 |
-
* Flatten multi-dimensional array for multi-file upload fields
|
260 |
-
* @since 2.0
|
261 |
-
*/
|
262 |
-
public static function flatten_multi_file_upload( &$val, $field ) {
|
263 |
-
if ( $field->type == 'file' && isset( $field->field_options['multiple'] ) && $field->field_options['multiple'] ) {
|
264 |
-
$val = FrmAppHelper::array_flatten( $val );
|
265 |
-
}
|
266 |
-
}
|
267 |
-
|
268 |
-
/**
|
269 |
-
* Replace returns with HTML line breaks for display
|
270 |
-
* @since 2.0
|
271 |
-
*/
|
272 |
-
public static function textarea_display_value( &$value, $type, $plain_text ) {
|
273 |
-
if ( $type == 'textarea' && ! $plain_text ) {
|
274 |
-
$value = str_replace( array( "\r\n", "\r", "\n" ), ' <br/>', $value );
|
275 |
-
}
|
276 |
-
}
|
277 |
-
|
278 |
-
public static function fill_entry_user_info($atts, array &$values) {
|
279 |
-
if ( ! $atts['user_info'] ) {
|
280 |
-
return;
|
281 |
-
}
|
282 |
-
|
283 |
-
$data = self::get_entry_description_data( $atts );
|
284 |
-
|
285 |
-
if ( $atts['default_email'] ) {
|
286 |
-
$atts['entry']->ip = '[ip]';
|
287 |
-
}
|
288 |
-
|
289 |
-
if ( $atts['format'] != 'text' ) {
|
290 |
-
$values['ip'] = $atts['entry']->ip;
|
291 |
-
$values['browser'] = self::get_browser($data['browser']);
|
292 |
-
$values['referrer'] = $data['referrer'];
|
293 |
-
} else {
|
294 |
-
$values['ip'] = array( 'label' => __( 'IP Address', 'formidable' ), 'val' => $atts['entry']->ip );
|
295 |
-
$values['browser'] = array(
|
296 |
-
'label' => __( 'User-Agent (Browser/OS)', 'formidable' ),
|
297 |
-
'val' => self::get_browser($data['browser']),
|
298 |
-
);
|
299 |
-
$values['referrer'] = array( 'label' => __( 'Referrer', 'formidable' ), 'val' => $data['referrer'] );
|
300 |
-
}
|
301 |
-
}
|
302 |
-
|
303 |
-
/**
|
304 |
-
* @param array $atts - include (object) entry, (boolean) default_email
|
305 |
-
* @since 2.0.8
|
306 |
-
*/
|
307 |
-
public static function get_entry_description_data( $atts ) {
|
308 |
-
$default_data = array(
|
309 |
-
'browser' => '',
|
310 |
-
'referrer' => '',
|
311 |
-
);
|
312 |
-
$data = $default_data;
|
313 |
-
|
314 |
-
if ( isset( $atts['entry']->description ) ) {
|
315 |
-
$data = maybe_unserialize( $atts['entry']->description );
|
316 |
-
} else if ( $atts['default_email'] ) {
|
317 |
-
$data = array(
|
318 |
-
'browser' => '[browser]',
|
319 |
-
'referrer' => '[referrer]',
|
320 |
-
);
|
321 |
-
}
|
322 |
-
|
323 |
-
return array_merge( $default_data, $data );
|
324 |
-
}
|
325 |
-
|
326 |
-
public static function convert_entry_to_content($values, $atts, array &$content) {
|
327 |
-
|
328 |
-
if ( $atts['plain_text'] ) {
|
329 |
-
$bg_color_alt = $row_style = '';
|
330 |
-
} else {
|
331 |
-
$default_settings = apply_filters('frm_show_entry_styles', array(
|
332 |
-
'border_color' => 'dddddd',
|
333 |
-
'bg_color' => 'f7f7f7',
|
334 |
-
'text_color' => '444444',
|
335 |
-
'font_size' => '12px',
|
336 |
-
'border_width' => '1px',
|
337 |
-
'alt_bg_color' => 'ffffff',
|
338 |
-
) );
|
339 |
-
|
340 |
-
// merge defaults, global settings, and shortcode options
|
341 |
-
foreach ( $default_settings as $key => $setting ) {
|
342 |
-
if ( $atts[ $key ] != '' ) {
|
343 |
-
continue;
|
344 |
-
}
|
345 |
-
|
346 |
-
$atts[ $key ] = $setting;
|
347 |
-
unset($key, $setting);
|
348 |
-
}
|
349 |
-
|
350 |
-
unset($default_settings);
|
351 |
-
|
352 |
-
$content[] = '<table cellspacing="0" style="font-size:'. $atts['font_size'] .';line-height:135%; border-bottom:'. $atts['border_width'] .' solid #'. $atts['border_color'] .';"><tbody>'."\r\n";
|
353 |
-
$atts['bg_color'] = ' style="background-color:#'. $atts['bg_color'] .';"';
|
354 |
-
$bg_color_alt = ' style="background-color:#'. $atts['alt_bg_color'] .';"';
|
355 |
-
$row_style = 'style="text-align:'. ( $atts['direction'] == 'rtl' ? 'right' : 'left' ) .';color:#'. $atts['text_color'] .';padding:7px 9px;border-top:'. $atts['border_width'] .' solid #'. $atts['border_color'] .'"';
|
356 |
-
}
|
357 |
-
|
358 |
-
$odd = true;
|
359 |
-
foreach ( $values as $id => $value ) {
|
360 |
-
if ( $atts['plain_text'] ) {
|
361 |
-
if ( 'rtl' == $atts['direction'] ) {
|
362 |
-
$content[] = $value['val'] . ' :'. $value['label'] ."\r\n";
|
363 |
-
} else {
|
364 |
-
$content[] = $value['label'] . ': '. $value['val'] ."\r\n";
|
365 |
-
}
|
366 |
-
continue;
|
367 |
-
}
|
368 |
-
|
369 |
-
if ( $atts['default_email'] && is_numeric($id) ) {
|
370 |
-
$content[] = '[if '. $id .']<tr style="[frm-alt-color]">';
|
371 |
-
} else {
|
372 |
-
$content[] = '<tr'. ( $odd ? $atts['bg_color'] : $bg_color_alt ) .'>';
|
373 |
-
}
|
374 |
-
|
375 |
-
$value['val'] = str_replace( "\r\n", '<br/>', $value['val'] );
|
376 |
-
if ( 'rtl' == $atts['direction'] ) {
|
377 |
-
$content[] = '<td '. $row_style .'>'. $value['val'] .'</td><th '. $row_style .'>'. $value['label'] . '</th>';
|
378 |
-
} else {
|
379 |
-
$content[] = '<th '. $row_style .'>'. $value['label'] .'</th><td '. $row_style .'>'. $value['val'] .'</td>';
|
380 |
-
}
|
381 |
-
$content[] = '</tr>'. "\r\n";
|
382 |
-
|
383 |
-
if ( $atts['default_email'] && is_numeric($id) ) {
|
384 |
-
$content[] = '[/if '. $id .']';
|
385 |
-
}
|
386 |
-
$odd = $odd ? false : true;
|
387 |
-
}
|
388 |
-
|
389 |
-
if ( ! $atts['plain_text'] ) {
|
390 |
-
$content[] = '</tbody></table>';
|
391 |
-
}
|
392 |
}
|
393 |
|
394 |
public static function replace_default_message($message, $atts) {
|
@@ -412,7 +158,7 @@ class FrmEntriesHelper {
|
|
412 |
$this_atts = $atts;
|
413 |
}
|
414 |
|
415 |
-
|
416 |
|
417 |
// Add the default message
|
418 |
$message = str_replace( $shortcodes[0][ $short_key ], $default, $message );
|
@@ -585,7 +331,7 @@ class FrmEntriesHelper {
|
|
585 |
self::set_other_repeating_vals( $field, $value, $args );
|
586 |
|
587 |
// Check if there are any posted "Other" values
|
588 |
-
|
589 |
|
590 |
// Save original value
|
591 |
$args['temp_value'] = $value;
|
@@ -612,7 +358,7 @@ class FrmEntriesHelper {
|
|
612 |
}
|
613 |
|
614 |
// Check if there are any other posted "other" values for this field
|
615 |
-
|
616 |
// Save original value
|
617 |
$args['temp_value'] = $value;
|
618 |
$args['other'] = true;
|
@@ -675,13 +421,10 @@ class FrmEntriesHelper {
|
|
675 |
}
|
676 |
}
|
677 |
|
678 |
-
|
679 |
-
|
680 |
-
|
681 |
-
|
682 |
-
public static function enqueue_scripts($params) {
|
683 |
-
do_action('frm_enqueue_form_scripts', $params);
|
684 |
-
}
|
685 |
|
686 |
// Add submitted values to a string for spam checking
|
687 |
public static function entry_array_to_string($values) {
|
@@ -701,69 +444,42 @@ class FrmEntriesHelper {
|
|
701 |
return $content;
|
702 |
}
|
703 |
|
704 |
-
|
705 |
-
|
706 |
-
|
707 |
-
|
708 |
-
|
709 |
-
// Get the operating system
|
710 |
-
if ( preg_match('/windows|win32/i', $u_agent) ) {
|
711 |
-
$platform = 'Windows';
|
712 |
-
} else if ( preg_match('/android/i', $u_agent) ) {
|
713 |
-
$platform = 'Android';
|
714 |
-
} else if ( preg_match('/linux/i', $u_agent) ) {
|
715 |
-
$platform = 'Linux';
|
716 |
-
} else if ( preg_match('/macintosh|mac os x/i', $u_agent) ) {
|
717 |
-
$platform = 'OS X';
|
718 |
-
}
|
719 |
|
720 |
-
|
721 |
-
|
722 |
-
|
723 |
-
|
724 |
-
'Netscape' => 'Netscape',
|
725 |
-
'Firefox' => 'Mozilla Firefox',
|
726 |
-
);
|
727 |
-
|
728 |
-
// Next get the name of the useragent yes seperately and for good reason
|
729 |
-
if ( strpos( $u_agent, 'MSIE' ) !== false && strpos( $u_agent, 'Opera' ) === false ) {
|
730 |
-
$bname = 'Internet Explorer';
|
731 |
-
$ub = 'MSIE';
|
732 |
-
} else {
|
733 |
-
foreach ( $agent_options as $agent_key => $agent_name ) {
|
734 |
-
if ( strpos( $u_agent, $agent_key ) !== false ) {
|
735 |
-
$bname = $agent_name;
|
736 |
-
$ub = $agent_key;
|
737 |
-
break;
|
738 |
-
}
|
739 |
-
}
|
740 |
-
}
|
741 |
|
742 |
-
|
743 |
-
|
744 |
-
|
745 |
-
|
746 |
-
|
747 |
-
// see how many we have
|
748 |
-
$i = count($matches['browser']);
|
749 |
-
if ( $i != 1 ) {
|
750 |
-
//we will have two since we are not using 'other' argument yet
|
751 |
-
//see if version is before or after the name
|
752 |
-
if ( strripos( $u_agent, 'Version' ) < strripos( $u_agent, $ub ) ) {
|
753 |
-
$version = $matches['version'][0];
|
754 |
-
} else {
|
755 |
-
$version = $matches['version'][1];
|
756 |
-
}
|
757 |
-
} else {
|
758 |
-
$version = $matches['version'][0];
|
759 |
-
}
|
760 |
|
761 |
-
|
762 |
-
|
763 |
-
|
764 |
-
|
765 |
|
766 |
-
|
767 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
768 |
|
|
|
|
|
|
|
769 |
}
|
25 |
if ( ! $reset && $_POST && isset( $_POST['item_meta'][ $field->id ] ) && $_POST['item_meta'][ $field->id ] != '' ) {
|
26 |
$new_value = stripslashes_deep( $_POST['item_meta'][ $field->id ] );
|
27 |
$posted_val = true;
|
28 |
+
} else if ( FrmField::is_option_true( $field, 'clear_on_focus' ) ) {
|
29 |
$new_value = '';
|
30 |
}
|
31 |
|
32 |
$is_default = ($new_value == $default) ? true : false;
|
33 |
|
34 |
//If checkbox, multi-select dropdown, or checkbox data from entries field, set return array to true
|
35 |
+
$return_array = FrmField::is_field_with_multiple_values( $field );
|
36 |
|
37 |
$field->default_value = apply_filters('frm_get_default_value', $field->default_value, $field, true, $return_array);
|
38 |
|
113 |
}
|
114 |
|
115 |
public static function get_admin_params( $form = null ) {
|
116 |
+
_deprecated_function( __FUNCTION__, '2.0.9', 'FrmForm::get_admin_params' );
|
117 |
+
return FrmForm::set_current_form( $form );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
118 |
}
|
119 |
|
120 |
+
public static function set_current_form( $form_id ) {
|
121 |
+
_deprecated_function( __FUNCTION__, '2.0.9', 'FrmForm::set_current_form' );
|
122 |
+
return FrmForm::set_current_form( $form_id );
|
123 |
+
}
|
|
|
|
|
124 |
|
125 |
+
public static function get_current_form( $form_id = 0 ) {
|
126 |
+
_deprecated_function( __FUNCTION__, '2.0.9', 'FrmForm::get_current_form' );
|
127 |
+
return FrmForm::get_current_form( $form_id );
|
128 |
+
}
|
129 |
|
130 |
public static function get_current_form_id() {
|
131 |
+
_deprecated_function( __FUNCTION__, '2.0.9', 'FrmForm::get_current_form_id' );
|
132 |
+
return FrmForm::get_current_form_id();
|
|
|
|
|
133 |
}
|
134 |
|
|
|
|
|
|
|
|
|
|
|
135 |
public static function maybe_get_entry( &$entry ) {
|
136 |
+
_deprecated_function( __FUNCTION__, '2.0.9', 'FrmEntry::maybe_get_entry' );
|
137 |
+
FrmEntry::maybe_get_entry( $entry );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
138 |
}
|
139 |
|
140 |
public static function replace_default_message($message, $atts) {
|
158 |
$this_atts = $atts;
|
159 |
}
|
160 |
|
161 |
+
$default = FrmEntryFormat::show_entry( $this_atts );
|
162 |
|
163 |
// Add the default message
|
164 |
$message = str_replace( $shortcodes[0][ $short_key ], $default, $message );
|
331 |
self::set_other_repeating_vals( $field, $value, $args );
|
332 |
|
333 |
// Check if there are any posted "Other" values
|
334 |
+
if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta']['other'][ $field->id ] ) ) {
|
335 |
|
336 |
// Save original value
|
337 |
$args['temp_value'] = $value;
|
358 |
}
|
359 |
|
360 |
// Check if there are any other posted "other" values for this field
|
361 |
+
if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ] ) ) {
|
362 |
// Save original value
|
363 |
$args['temp_value'] = $value;
|
364 |
$args['other'] = true;
|
421 |
}
|
422 |
}
|
423 |
|
424 |
+
public static function enqueue_scripts( $params ) {
|
425 |
+
_deprecated_function( __FUNCTION__, '2.0.9', 'FrmFormsController::enqueue_scripts' );
|
426 |
+
return FrmFormsController::enqueue_scripts( $params );
|
427 |
+
}
|
|
|
|
|
|
|
428 |
|
429 |
// Add submitted values to a string for spam checking
|
430 |
public static function entry_array_to_string($values) {
|
444 |
return $content;
|
445 |
}
|
446 |
|
447 |
+
public static function fill_entry_values( $atts, $f, array &$values ) {
|
448 |
+
_deprecated_function( __FUNCTION__, '2.0.9', 'FrmEntryFormat::fill_entry_values' );
|
449 |
+
FrmEntryFormat::fill_entry_values( $atts, $f, $values );
|
450 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
451 |
|
452 |
+
public static function flatten_multi_file_upload( &$val, $field ) {
|
453 |
+
_deprecated_function( __FUNCTION__, '2.0.9', 'FrmEntryFormat::flatten_multi_file_upload' );
|
454 |
+
FrmEntryFormat::flatten_multi_file_upload( $field, $val );
|
455 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
456 |
|
457 |
+
public static function textarea_display_value( &$value, $type, $plain_text ) {
|
458 |
+
_deprecated_function( __FUNCTION__, '2.0.9', 'FrmEntryFormat::textarea_display_value' );
|
459 |
+
FrmEntryFormat::textarea_display_value( $type, $plain_text, $value );
|
460 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
461 |
|
462 |
+
public static function fill_entry_user_info($atts, array &$values) {
|
463 |
+
_deprecated_function( __FUNCTION__, '2.0.9', 'FrmEntryFormat::fill_entry_user_info' );
|
464 |
+
FrmEntryFormat::fill_entry_user_info( $atts, $values );
|
465 |
+
}
|
466 |
|
467 |
+
public static function get_entry_description_data( $atts ) {
|
468 |
+
_deprecated_function( __FUNCTION__, '2.0.9', 'FrmEntryFormat::get_entry_description_data' );
|
469 |
+
return FrmEntryFormat::get_entry_description_data( $atts );
|
470 |
+
}
|
471 |
+
|
472 |
+
public static function convert_entry_to_content( $values, $atts, array &$content ) {
|
473 |
+
_deprecated_function( __FUNCTION__, '2.0.9', 'FrmEntryFormat::convert_entry_to_content' );
|
474 |
+
return FrmEntryFormat::convert_entry_to_content( $values, $atts, $content );
|
475 |
+
}
|
476 |
+
|
477 |
+
public static function get_browser( $u_agent ) {
|
478 |
+
_deprecated_function( __FUNCTION__, '2.0.9', 'FrmEntryFormat::get_browser' );
|
479 |
+
return FrmEntryFormat::get_browser( $u_agent );
|
480 |
+
}
|
481 |
|
482 |
+
public static function entries_dropdown() {
|
483 |
+
_deprecated_function( __FUNCTION__, '1.07.09');
|
484 |
+
}
|
485 |
}
|
classes/helpers/FrmEntriesListHelper.php
CHANGED
@@ -8,7 +8,7 @@ class FrmEntriesListHelper extends FrmListHelper {
|
|
8 |
public function prepare_items() {
|
9 |
global $wpdb, $per_page;
|
10 |
|
11 |
-
|
12 |
|
13 |
$form_id = $this->params['form'];
|
14 |
if ( ! $form_id ) {
|
@@ -28,7 +28,7 @@ class FrmEntriesListHelper extends FrmListHelper {
|
|
28 |
$s = isset( $_REQUEST['s'] ) ? stripslashes($_REQUEST['s']) : '';
|
29 |
|
30 |
if ( $s != '' && FrmAppHelper::pro_is_installed() ) {
|
31 |
-
$fid = isset( $_REQUEST['fid'] ) ?
|
32 |
$s_query = FrmProEntriesHelper::get_search_str( $s_query, $s, $form_id, $fid);
|
33 |
}
|
34 |
|
@@ -73,6 +73,29 @@ class FrmEntriesListHelper extends FrmListHelper {
|
|
73 |
// Searching is a pro feature
|
74 |
}
|
75 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
76 |
public function single_row( $item, $style = '' ) {
|
77 |
// Set up the hover actions for this user
|
78 |
$actions = array();
|
8 |
public function prepare_items() {
|
9 |
global $wpdb, $per_page;
|
10 |
|
11 |
+
$per_page = $this->get_items_per_page( 'formidable_page_formidable_entries_per_page' );
|
12 |
|
13 |
$form_id = $this->params['form'];
|
14 |
if ( ! $form_id ) {
|
28 |
$s = isset( $_REQUEST['s'] ) ? stripslashes($_REQUEST['s']) : '';
|
29 |
|
30 |
if ( $s != '' && FrmAppHelper::pro_is_installed() ) {
|
31 |
+
$fid = isset( $_REQUEST['fid'] ) ? sanitize_title( $_REQUEST['fid'] ) : '';
|
32 |
$s_query = FrmProEntriesHelper::get_search_str( $s_query, $s, $form_id, $fid);
|
33 |
}
|
34 |
|
73 |
// Searching is a pro feature
|
74 |
}
|
75 |
|
76 |
+
protected function get_sortable_columns() {
|
77 |
+
$form_id = FrmForm::get_current_form_id();
|
78 |
+
$fields = FrmField::get_all_for_form( $form_id );
|
79 |
+
|
80 |
+
$columns = array(
|
81 |
+
$form_id . '_id' => 'id',
|
82 |
+
$form_id . '_created_at' => 'created_at',
|
83 |
+
$form_id . '_updated_at' => 'updated_at',
|
84 |
+
$form_id . '_ip' => 'ip',
|
85 |
+
$form_id . '_item_key' => 'item_key',
|
86 |
+
$form_id . '_is_draft' => 'is_draft',
|
87 |
+
);
|
88 |
+
|
89 |
+
foreach ( $fields as $field ) {
|
90 |
+
if ( $field->type != 'checkbox' && ( ! isset( $field->field_options['post_field'] ) || $field->field_options['post_field'] == '' ) ) {
|
91 |
+
// Can't sort on checkboxes because they are stored serialized, or post fields
|
92 |
+
$columns[ $form_id . '_' . $field->field_key ] = 'meta_' . $field->id;
|
93 |
+
}
|
94 |
+
}
|
95 |
+
|
96 |
+
return $columns;
|
97 |
+
}
|
98 |
+
|
99 |
public function single_row( $item, $style = '' ) {
|
100 |
// Set up the hover actions for this user
|
101 |
$actions = array();
|
classes/helpers/FrmFieldsHelper.php
CHANGED
@@ -5,111 +5,6 @@ if ( ! defined('ABSPATH') ) {
|
|
5 |
|
6 |
class FrmFieldsHelper {
|
7 |
|
8 |
-
public static function field_selection() {
|
9 |
-
$fields = apply_filters('frm_available_fields', array(
|
10 |
-
'text' => __( 'Single Line Text', 'formidable' ),
|
11 |
-
'textarea' => __( 'Paragraph Text', 'formidable' ),
|
12 |
-
'checkbox' => __( 'Checkboxes', 'formidable' ),
|
13 |
-
'radio' => __( 'Radio Buttons', 'formidable' ),
|
14 |
-
'select' => __( 'Dropdown', 'formidable' ),
|
15 |
-
'email' => __( 'Email Address', 'formidable' ),
|
16 |
-
'url' => __( 'Website/URL', 'formidable' ),
|
17 |
-
'captcha' => __( 'reCAPTCHA', 'formidable' ),
|
18 |
-
));
|
19 |
-
|
20 |
-
return $fields;
|
21 |
-
}
|
22 |
-
|
23 |
-
public static function pro_field_selection() {
|
24 |
-
return apply_filters('frm_pro_available_fields', array(
|
25 |
-
'end_divider' => array(
|
26 |
-
'name' => __( 'End Section', 'formidable' ),
|
27 |
-
'switch_from' => 'divider',
|
28 |
-
),
|
29 |
-
'divider' => __( 'Section', 'formidable' ),
|
30 |
-
'break' => __( 'Page Break', 'formidable' ),
|
31 |
-
'file' => __( 'File Upload', 'formidable' ),
|
32 |
-
'rte' => __( 'Rich Text', 'formidable' ),
|
33 |
-
'number' => __( 'Number', 'formidable' ),
|
34 |
-
'phone' => __( 'Phone Number', 'formidable' ),
|
35 |
-
'date' => __( 'Date', 'formidable' ),
|
36 |
-
'time' => __( 'Time', 'formidable' ),
|
37 |
-
'image' => __( 'Image URL', 'formidable' ),
|
38 |
-
'scale' => __( 'Scale', 'formidable' ),
|
39 |
-
'data' => __( 'Dynamic Field', 'formidable' ),
|
40 |
-
'form' => __( 'Embed Form', 'formidable' ),
|
41 |
-
'hidden' => __( 'Hidden Field', 'formidable' ),
|
42 |
-
'user_id' => __( 'User ID (hidden)', 'formidable' ),
|
43 |
-
'password' => __( 'Password', 'formidable' ),
|
44 |
-
'html' => __( 'HTML', 'formidable' ),
|
45 |
-
'tag' => __( 'Tags', 'formidable' ),
|
46 |
-
//'address' => 'Address' //Address line 1, Address line 2, City, State/Providence, Postal Code, Select Country
|
47 |
-
//'city_selector' => 'US State/County/City selector',
|
48 |
-
//'full_name' => 'First and Last Name',
|
49 |
-
//'quiz' => 'Question and Answer' // for captcha alternative
|
50 |
-
));
|
51 |
-
}
|
52 |
-
|
53 |
-
public static function is_no_save_field($type) {
|
54 |
-
return in_array($type, self::no_save_fields());
|
55 |
-
}
|
56 |
-
|
57 |
-
public static function no_save_fields() {
|
58 |
-
return array( 'divider', 'end_divider', 'captcha', 'break', 'html' );
|
59 |
-
}
|
60 |
-
|
61 |
-
/**
|
62 |
-
* Check if this is a multiselect dropdown field
|
63 |
-
*
|
64 |
-
* @since 2.0
|
65 |
-
* @return boolean
|
66 |
-
*/
|
67 |
-
public static function is_multiple_select($field) {
|
68 |
-
if ( is_array($field) ) {
|
69 |
-
return isset($field['multiple']) && $field['multiple'] && ( ( $field['type'] == 'select' || ( $field['type'] == 'data' && isset($field['data_type']) && $field['data_type'] == 'select') ) );
|
70 |
-
} else {
|
71 |
-
return isset($field->field_options['multiple']) && $field->field_options['multiple'] && ( ( $field->type == 'select' || ( $field->type == 'data' && isset($field->field_options['data_type']) && $field->field_options['data_type'] == 'select') ) );
|
72 |
-
}
|
73 |
-
}
|
74 |
-
|
75 |
-
/**
|
76 |
-
* Check if this field can hold an array of values
|
77 |
-
*
|
78 |
-
* @since 2.0
|
79 |
-
*
|
80 |
-
* @param array|object $field
|
81 |
-
* @return boolean
|
82 |
-
*/
|
83 |
-
public static function is_field_with_multiple_values( $field ) {
|
84 |
-
if ( ! $field ) {
|
85 |
-
return false;
|
86 |
-
}
|
87 |
-
|
88 |
-
if ( is_array( $field ) ) {
|
89 |
-
// For field array
|
90 |
-
return $field['type'] == 'checkbox' || ( $field['type'] == 'data' && isset($field['data_type']) && $field['data_type'] == 'checkbox' ) || self::is_multiple_select( $field );
|
91 |
-
} else {
|
92 |
-
// For field object
|
93 |
-
return $field->type == 'checkbox' || ( $field->type == 'data' && isset( $field->field_options['data_type'] ) && $field->field_options['data_type'] == 'checkbox' ) || self::is_multiple_select($field);
|
94 |
-
}
|
95 |
-
}
|
96 |
-
|
97 |
-
/**
|
98 |
-
* @since 2.0.6
|
99 |
-
*/
|
100 |
-
public static function is_required_field( $field ) {
|
101 |
-
return $field['required'] != '0';
|
102 |
-
}
|
103 |
-
|
104 |
-
/**
|
105 |
-
* If $field is numeric, get the field object
|
106 |
-
*/
|
107 |
-
public static function maybe_get_field( &$field ) {
|
108 |
-
if ( ! is_object($field) ) {
|
109 |
-
$field = FrmField::getOne($field);
|
110 |
-
}
|
111 |
-
}
|
112 |
-
|
113 |
public static function setup_new_vars($type = '', $form_id = '') {
|
114 |
|
115 |
if ( strpos($type, '|') ) {
|
@@ -160,8 +55,8 @@ class FrmFieldsHelper {
|
|
160 |
$values['name'] = __( 'Website', 'formidable' );
|
161 |
}
|
162 |
|
163 |
-
|
164 |
-
$fields = array_merge($fields,
|
165 |
|
166 |
if ( isset( $fields[ $type ] ) ) {
|
167 |
$values['name'] = is_array( $fields[ $type ] ) ? $fields[ $type ]['name'] : $fields[ $type ];
|
@@ -178,15 +73,18 @@ class FrmFieldsHelper {
|
|
178 |
|
179 |
public static function setup_edit_vars( $record, $doing_ajax = false ) {
|
180 |
$values = array( 'id' => $record->id, 'form_id' => $record->form_id );
|
181 |
-
$defaults = array(
|
182 |
-
|
183 |
-
|
184 |
-
'
|
185 |
-
|
186 |
-
|
|
|
|
|
|
|
187 |
|
188 |
if ( $doing_ajax ) {
|
189 |
-
$values = $values + $defaults
|
190 |
$values['form_name'] = '';
|
191 |
} else {
|
192 |
foreach ( $defaults as $var => $default ) {
|
@@ -194,15 +92,10 @@ class FrmFieldsHelper {
|
|
194 |
unset($var, $default);
|
195 |
}
|
196 |
|
197 |
-
|
198 |
-
$values[ $var ] = FrmAppHelper::get_param( $var, $default );
|
199 |
-
unset($var, $default);
|
200 |
-
}
|
201 |
-
|
202 |
-
$values['form_name'] = ($record->form_id) ? FrmForm::getName( $record->form_id ) : '';
|
203 |
}
|
204 |
|
205 |
-
|
206 |
|
207 |
$values['options'] = $record->options;
|
208 |
$values['field_options'] = $record->field_options;
|
@@ -329,7 +222,7 @@ DEFAULT_HTML;
|
|
329 |
$field_id = $args['field_id'];
|
330 |
$html_id = self::get_html_id($field, $args['field_plus_id']);
|
331 |
|
332 |
-
if (
|
333 |
$field_name .= '[]';
|
334 |
}
|
335 |
|
@@ -348,7 +241,7 @@ DEFAULT_HTML;
|
|
348 |
$html = str_replace('[key]', $field['field_key'], $html);
|
349 |
|
350 |
//replace [description] and [required_label] and [error]
|
351 |
-
$required =
|
352 |
if ( ! is_array( $errors ) ) {
|
353 |
$errors = array();
|
354 |
}
|
@@ -356,7 +249,7 @@ DEFAULT_HTML;
|
|
356 |
|
357 |
//If field type is section heading, add class so a bottom margin can be added to either the h3 or description
|
358 |
if ( $field['type'] == 'divider' ) {
|
359 |
-
if (
|
360 |
$html = str_replace( 'frm_description', 'frm_description frm_section_spacing', $html );
|
361 |
} else {
|
362 |
$html = str_replace('[label_position]', '[label_position] frm_section_spacing', $html);
|
@@ -368,7 +261,7 @@ DEFAULT_HTML;
|
|
368 |
}
|
369 |
|
370 |
//replace [required_class]
|
371 |
-
|
372 |
$html = str_replace('[required_class]', $required_class, $html);
|
373 |
|
374 |
//replace [label_position]
|
@@ -450,7 +343,9 @@ DEFAULT_HTML;
|
|
450 |
|
451 |
self::remove_collapse_shortcode( $html );
|
452 |
|
453 |
-
|
|
|
|
|
454 |
|
455 |
return $html;
|
456 |
}
|
@@ -773,7 +668,7 @@ DEFAULT_HTML;
|
|
773 |
return FrmProDisplaysHelper::get_shortcodes($content, $form_id);
|
774 |
}
|
775 |
|
776 |
-
$fields = FrmField::getAll( array( 'fi.form_id' => (int) $form_id, 'fi.type not' =>
|
777 |
|
778 |
$tagregexp = self::allowed_shortcodes($fields);
|
779 |
|
@@ -828,7 +723,7 @@ DEFAULT_HTML;
|
|
828 |
case 'user_agent':
|
829 |
case 'user-agent':
|
830 |
$entry->description = maybe_unserialize($entry->description);
|
831 |
-
|
832 |
break;
|
833 |
|
834 |
case 'created_at':
|
@@ -999,7 +894,7 @@ DEFAULT_HTML;
|
|
999 |
$multiple_input = array( 'radio', 'checkbox', 'select', 'scale' );
|
1000 |
$other_type = array( 'divider', 'html', 'break' );
|
1001 |
|
1002 |
-
|
1003 |
|
1004 |
$field_types = array();
|
1005 |
if ( in_array($type, $single_input) ) {
|
@@ -1056,7 +951,7 @@ DEFAULT_HTML;
|
|
1056 |
|
1057 |
// If option is an "other" option and there is a value set for this field,
|
1058 |
// check if the value belongs in the current "Other" option text field
|
1059 |
-
if ( ! FrmFieldsHelper::is_other_opt( $opt_key ) || !
|
1060 |
return $other_val;
|
1061 |
}
|
1062 |
|
@@ -1064,7 +959,7 @@ DEFAULT_HTML;
|
|
1064 |
|
1065 |
// For fields inside repeating sections - note, don't check if $pointer is true because it will often be zero
|
1066 |
if ( $parent && isset( $_POST['item_meta'][ $parent ][ $pointer ]['other'][ $field['id'] ] ) ) {
|
1067 |
-
if (
|
1068 |
$other_val = isset( $_POST['item_meta'][ $parent ][ $pointer ]['other'][ $field['id'] ][ $opt_key ] ) ? sanitize_text_field( $_POST['item_meta'][ $parent ][ $pointer ]['other'][ $field['id'] ][ $opt_key ] ) : '';
|
1069 |
} else {
|
1070 |
$other_val = sanitize_text_field( $_POST['item_meta'][ $parent ][ $pointer ]['other'][ $field['id'] ] );
|
@@ -1074,7 +969,7 @@ DEFAULT_HTML;
|
|
1074 |
} else if ( isset( $field['id'] ) && isset( $_POST['item_meta']['other'][ $field['id'] ] ) ) {
|
1075 |
// For normal fields
|
1076 |
|
1077 |
-
if (
|
1078 |
$other_val = isset( $_POST['item_meta']['other'][ $field['id'] ][ $opt_key ] ) ? sanitize_text_field( $_POST['item_meta']['other'][ $field['id'] ][ $opt_key ] ) : '';
|
1079 |
} else {
|
1080 |
$other_val = sanitize_text_field( $_POST['item_meta']['other'][ $field['id'] ] );
|
@@ -1162,7 +1057,7 @@ DEFAULT_HTML;
|
|
1162 |
|
1163 |
//Converts item_meta[field_id] => item_meta[other][field_id] and
|
1164 |
//item_meta[parent][0][field_id] => item_meta[parent][0][other][field_id]
|
1165 |
-
if (
|
1166 |
$other_args['name'] .= '[' . $args['opt_key'] . ']';
|
1167 |
}
|
1168 |
}
|
@@ -1227,7 +1122,7 @@ DEFAULT_HTML;
|
|
1227 |
* @param string|boolean $opt_key
|
1228 |
* @return string $other_id
|
1229 |
*/
|
1230 |
-
public static function get_other_field_html_id( $type, $html_id, $opt_key = false ){
|
1231 |
$other_id = $html_id;
|
1232 |
|
1233 |
// If hidden radio field, add an opt key of 0
|
@@ -1429,4 +1324,44 @@ DEFAULT_HTML;
|
|
1429 |
|
1430 |
$prepop = apply_filters( 'frm_bulk_field_choices', $prepop );
|
1431 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1432 |
}
|
5 |
|
6 |
class FrmFieldsHelper {
|
7 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
public static function setup_new_vars($type = '', $form_id = '') {
|
9 |
|
10 |
if ( strpos($type, '|') ) {
|
55 |
$values['name'] = __( 'Website', 'formidable' );
|
56 |
}
|
57 |
|
58 |
+
$fields = FrmField::field_selection();
|
59 |
+
$fields = array_merge($fields, FrmField::pro_field_selection());
|
60 |
|
61 |
if ( isset( $fields[ $type ] ) ) {
|
62 |
$values['name'] = is_array( $fields[ $type ] ) ? $fields[ $type ]['name'] : $fields[ $type ];
|
73 |
|
74 |
public static function setup_edit_vars( $record, $doing_ajax = false ) {
|
75 |
$values = array( 'id' => $record->id, 'form_id' => $record->form_id );
|
76 |
+
$defaults = array(
|
77 |
+
'name' => $record->name,
|
78 |
+
'description' => $record->description,
|
79 |
+
'field_key' => $record->field_key,
|
80 |
+
'type' => $record->type,
|
81 |
+
'default_value' => $record->default_value,
|
82 |
+
'field_order' => $record->field_order,
|
83 |
+
'required' => $record->required,
|
84 |
+
);
|
85 |
|
86 |
if ( $doing_ajax ) {
|
87 |
+
$values = $values + $defaults;
|
88 |
$values['form_name'] = '';
|
89 |
} else {
|
90 |
foreach ( $defaults as $var => $default ) {
|
92 |
unset($var, $default);
|
93 |
}
|
94 |
|
95 |
+
$values['form_name'] = $record->form_id ? FrmForm::getName( $record->form_id ) : '';
|
|
|
|
|
|
|
|
|
|
|
96 |
}
|
97 |
|
98 |
+
unset( $defaults );
|
99 |
|
100 |
$values['options'] = $record->options;
|
101 |
$values['field_options'] = $record->field_options;
|
222 |
$field_id = $args['field_id'];
|
223 |
$html_id = self::get_html_id($field, $args['field_plus_id']);
|
224 |
|
225 |
+
if ( FrmField::is_multiple_select($field) ) {
|
226 |
$field_name .= '[]';
|
227 |
}
|
228 |
|
241 |
$html = str_replace('[key]', $field['field_key'], $html);
|
242 |
|
243 |
//replace [description] and [required_label] and [error]
|
244 |
+
$required = FrmField::is_required( $field ) ? $field['required_indicator'] : '';
|
245 |
if ( ! is_array( $errors ) ) {
|
246 |
$errors = array();
|
247 |
}
|
249 |
|
250 |
//If field type is section heading, add class so a bottom margin can be added to either the h3 or description
|
251 |
if ( $field['type'] == 'divider' ) {
|
252 |
+
if ( FrmField::is_option_true( $field, 'description' ) ) {
|
253 |
$html = str_replace( 'frm_description', 'frm_description frm_section_spacing', $html );
|
254 |
} else {
|
255 |
$html = str_replace('[label_position]', '[label_position] frm_section_spacing', $html);
|
261 |
}
|
262 |
|
263 |
//replace [required_class]
|
264 |
+
$required_class = FrmField::is_required( $field ) ? ' frm_required_field' : '';
|
265 |
$html = str_replace('[required_class]', $required_class, $html);
|
266 |
|
267 |
//replace [label_position]
|
343 |
|
344 |
self::remove_collapse_shortcode( $html );
|
345 |
|
346 |
+
if ( apply_filters( 'frm_do_html_shortcodes', true ) ) {
|
347 |
+
$html = do_shortcode( $html );
|
348 |
+
}
|
349 |
|
350 |
return $html;
|
351 |
}
|
668 |
return FrmProDisplaysHelper::get_shortcodes($content, $form_id);
|
669 |
}
|
670 |
|
671 |
+
$fields = FrmField::getAll( array( 'fi.form_id' => (int) $form_id, 'fi.type not' => FrmField::no_save_fields() ) );
|
672 |
|
673 |
$tagregexp = self::allowed_shortcodes($fields);
|
674 |
|
723 |
case 'user_agent':
|
724 |
case 'user-agent':
|
725 |
$entry->description = maybe_unserialize($entry->description);
|
726 |
+
$replace_with = FrmEntryFormat::get_browser( $entry->description['browser'] );
|
727 |
break;
|
728 |
|
729 |
case 'created_at':
|
894 |
$multiple_input = array( 'radio', 'checkbox', 'select', 'scale' );
|
895 |
$other_type = array( 'divider', 'html', 'break' );
|
896 |
|
897 |
+
$field_selection = array_merge( FrmField::pro_field_selection(), FrmField::field_selection() );
|
898 |
|
899 |
$field_types = array();
|
900 |
if ( in_array($type, $single_input) ) {
|
951 |
|
952 |
// If option is an "other" option and there is a value set for this field,
|
953 |
// check if the value belongs in the current "Other" option text field
|
954 |
+
if ( ! FrmFieldsHelper::is_other_opt( $opt_key ) || ! FrmField::is_option_true( $field, 'value' ) ) {
|
955 |
return $other_val;
|
956 |
}
|
957 |
|
959 |
|
960 |
// For fields inside repeating sections - note, don't check if $pointer is true because it will often be zero
|
961 |
if ( $parent && isset( $_POST['item_meta'][ $parent ][ $pointer ]['other'][ $field['id'] ] ) ) {
|
962 |
+
if ( FrmField::is_field_with_multiple_values( $field ) ) {
|
963 |
$other_val = isset( $_POST['item_meta'][ $parent ][ $pointer ]['other'][ $field['id'] ][ $opt_key ] ) ? sanitize_text_field( $_POST['item_meta'][ $parent ][ $pointer ]['other'][ $field['id'] ][ $opt_key ] ) : '';
|
964 |
} else {
|
965 |
$other_val = sanitize_text_field( $_POST['item_meta'][ $parent ][ $pointer ]['other'][ $field['id'] ] );
|
969 |
} else if ( isset( $field['id'] ) && isset( $_POST['item_meta']['other'][ $field['id'] ] ) ) {
|
970 |
// For normal fields
|
971 |
|
972 |
+
if ( FrmField::is_field_with_multiple_values( $field ) ) {
|
973 |
$other_val = isset( $_POST['item_meta']['other'][ $field['id'] ][ $opt_key ] ) ? sanitize_text_field( $_POST['item_meta']['other'][ $field['id'] ][ $opt_key ] ) : '';
|
974 |
} else {
|
975 |
$other_val = sanitize_text_field( $_POST['item_meta']['other'][ $field['id'] ] );
|
1057 |
|
1058 |
//Converts item_meta[field_id] => item_meta[other][field_id] and
|
1059 |
//item_meta[parent][0][field_id] => item_meta[parent][0][other][field_id]
|
1060 |
+
if ( FrmField::is_field_with_multiple_values( $args['field'] ) ) {
|
1061 |
$other_args['name'] .= '[' . $args['opt_key'] . ']';
|
1062 |
}
|
1063 |
}
|
1122 |
* @param string|boolean $opt_key
|
1123 |
* @return string $other_id
|
1124 |
*/
|
1125 |
+
public static function get_other_field_html_id( $type, $html_id, $opt_key = false ) {
|
1126 |
$other_id = $html_id;
|
1127 |
|
1128 |
// If hidden radio field, add an opt key of 0
|
1324 |
|
1325 |
$prepop = apply_filters( 'frm_bulk_field_choices', $prepop );
|
1326 |
}
|
1327 |
+
|
1328 |
+
public static function field_selection() {
|
1329 |
+
_deprecated_function( __FUNCTION__, '2.0.9', 'FrmField::field_selection' );
|
1330 |
+
return FrmField::field_selection();
|
1331 |
+
}
|
1332 |
+
|
1333 |
+
public static function pro_field_selection() {
|
1334 |
+
_deprecated_function( __FUNCTION__, '2.0.9', 'FrmField::pro_field_selection' );
|
1335 |
+
return FrmField::pro_field_selection();
|
1336 |
+
}
|
1337 |
+
|
1338 |
+
public static function is_no_save_field( $type ) {
|
1339 |
+
_deprecated_function( __FUNCTION__, '2.0.9', 'FrmField::is_no_save_field' );
|
1340 |
+
return FrmField::is_no_save_field( $type );
|
1341 |
+
}
|
1342 |
+
|
1343 |
+
public static function no_save_fields() {
|
1344 |
+
_deprecated_function( __FUNCTION__, '2.0.9', 'FrmField::no_save_fields' );
|
1345 |
+
return FrmField::no_save_fields();
|
1346 |
+
}
|
1347 |
+
|
1348 |
+
public static function is_multiple_select( $field ) {
|
1349 |
+
_deprecated_function( __FUNCTION__, '2.0.9', 'FrmField::is_multiple_select' );
|
1350 |
+
return FrmField::is_multiple_select( $field );
|
1351 |
+
}
|
1352 |
+
|
1353 |
+
public static function is_field_with_multiple_values( $field ) {
|
1354 |
+
_deprecated_function( __FUNCTION__, '2.0.9', 'FrmField::is_field_with_multiple_values' );
|
1355 |
+
return FrmField::is_field_with_multiple_values( $field );
|
1356 |
+
}
|
1357 |
+
|
1358 |
+
public static function is_required_field( $field ) {
|
1359 |
+
_deprecated_function( __FUNCTION__, '2.0.9', 'FrmField::is_required' );
|
1360 |
+
return FrmField::is_required( $field );
|
1361 |
+
}
|
1362 |
+
|
1363 |
+
public static function maybe_get_field( &$field ) {
|
1364 |
+
_deprecated_function( __FUNCTION__, '2.0.9', 'FrmField::maybe_get_field' );
|
1365 |
+
FrmField::maybe_get_field( $field );
|
1366 |
+
}
|
1367 |
}
|
classes/helpers/FrmFormActionsHelper.php
CHANGED
@@ -5,114 +5,23 @@ if ( ! defined('ABSPATH') ) {
|
|
5 |
|
6 |
class FrmFormActionsHelper {
|
7 |
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
return array();
|
13 |
-
}
|
14 |
-
|
15 |
-
if ( 'all' != $type ) {
|
16 |
-
return $action_controls->get_all( $form_id, $limit );
|
17 |
-
}
|
18 |
-
|
19 |
-
$args = self::action_args( $form_id, $limit );
|
20 |
-
$actions = FrmAppHelper::check_cache( serialize( $args ), 'frm_actions', $args, 'get_posts' );
|
21 |
-
|
22 |
-
if ( ! $actions ) {
|
23 |
-
return array();
|
24 |
-
}
|
25 |
-
|
26 |
-
$settings = array();
|
27 |
-
foreach ( $actions as $action ) {
|
28 |
-
// some plugins/themes are formatting the post_excerpt
|
29 |
-
$action->post_excerpt = sanitize_title( $action->post_excerpt );
|
30 |
-
|
31 |
-
if ( ! isset( $action_controls[ $action->post_excerpt ] ) ) {
|
32 |
-
continue;
|
33 |
-
}
|
34 |
-
|
35 |
-
$action = $action_controls[ $action->post_excerpt ]->prepare_action( $action );
|
36 |
-
$settings[ $action->ID ] = $action;
|
37 |
-
|
38 |
-
if ( count( $settings ) >= $limit ) {
|
39 |
-
break;
|
40 |
-
}
|
41 |
-
}
|
42 |
-
|
43 |
-
if ( 1 === $limit ) {
|
44 |
-
$settings = reset($settings);
|
45 |
-
}
|
46 |
-
|
47 |
-
return $settings;
|
48 |
-
}
|
49 |
|
50 |
public static function action_args( $form_id = 0, $limit = 99 ) {
|
51 |
-
|
52 |
-
|
53 |
-
'post_status' => 'publish',
|
54 |
-
'numberposts' => $limit,
|
55 |
-
'orderby' => 'title',
|
56 |
-
'order' => 'ASC',
|
57 |
-
);
|
58 |
-
|
59 |
-
if ( $form_id ) {
|
60 |
-
$args['menu_order'] = $form_id;
|
61 |
-
}
|
62 |
-
|
63 |
-
return $args;
|
64 |
}
|
65 |
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
if ( ! isset( $notification['conditions'] ) || empty( $notification['conditions'] ) ) {
|
72 |
-
return $stop;
|
73 |
-
}
|
74 |
-
|
75 |
-
foreach ( $notification['conditions'] as $k => $condition ) {
|
76 |
-
if ( ! is_numeric( $k ) ) {
|
77 |
-
continue;
|
78 |
-
}
|
79 |
-
|
80 |
-
if ( $stop && 'any' == $notification['conditions']['any_all'] && 'stop' == $notification['conditions']['send_stop'] ) {
|
81 |
-
continue;
|
82 |
-
}
|
83 |
-
|
84 |
-
if ( is_array($condition['hide_opt']) ) {
|
85 |
-
$condition['hide_opt'] = reset($condition['hide_opt']);
|
86 |
-
}
|
87 |
-
|
88 |
-
$observed_value = isset( $entry->metas[ $condition['hide_field'] ] ) ? $entry->metas[ $condition['hide_field'] ] : '';
|
89 |
-
if ( $condition['hide_opt'] == 'current_user' ) {
|
90 |
-
$condition['hide_opt'] = get_current_user_id();
|
91 |
-
}
|
92 |
-
|
93 |
-
$stop = FrmFieldsHelper::value_meets_condition($observed_value, $condition['hide_field_cond'], $condition['hide_opt']);
|
94 |
-
|
95 |
-
if ( $notification['conditions']['send_stop'] == 'send' ) {
|
96 |
-
$stop = $stop ? false : true;
|
97 |
-
}
|
98 |
-
|
99 |
-
$met[ $stop ] = $stop;
|
100 |
-
}
|
101 |
-
|
102 |
-
if ( $notification['conditions']['any_all'] == 'all' && ! empty( $met ) && isset( $met[0] ) && isset( $met[1] ) ) {
|
103 |
-
$stop = ($notification['conditions']['send_stop'] == 'send') ? true : false;
|
104 |
-
} else if ( $notification['conditions']['any_all'] == 'any' && $notification['conditions']['send_stop'] == 'send' && isset($met[0]) ) {
|
105 |
-
$stop = false;
|
106 |
-
}
|
107 |
-
|
108 |
-
return $stop;
|
109 |
-
}
|
110 |
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
'limit' => 0,
|
116 |
-
);
|
117 |
-
}
|
118 |
}
|
5 |
|
6 |
class FrmFormActionsHelper {
|
7 |
|
8 |
+
public static function get_action_for_form( $form_id, $type = 'all', $limit = 99 ) {
|
9 |
+
//_deprecated_function( __FUNCTION__, '2.0.9', 'FrmFormAction::get_action_for_form' );
|
10 |
+
return FrmFormAction::get_action_for_form( $form_id, $type, $limit );
|
11 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
|
13 |
public static function action_args( $form_id = 0, $limit = 99 ) {
|
14 |
+
_deprecated_function( __FUNCTION__, '2.0.9', 'FrmFormAction::action_args' );
|
15 |
+
return FrmFormAction::action_args( $form_id, $limit );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
}
|
17 |
|
18 |
+
public static function action_conditions_met( $action, $entry ) {
|
19 |
+
_deprecated_function( __FUNCTION__, '2.0.9', 'FrmFormAction::action_conditions_met' );
|
20 |
+
return FrmFormAction::action_conditions_met( $action, $entry );
|
21 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
|
23 |
+
public static function default_action_opts( $class = '' ) {
|
24 |
+
//_deprecated_function( __FUNCTION__, '2.0.9', 'FrmFormAction::default_action_opts' );
|
25 |
+
return FrmFormAction::default_action_opts( $class );
|
26 |
+
}
|
|
|
|
|
|
|
27 |
}
|
classes/helpers/FrmFormsHelper.php
CHANGED
@@ -4,15 +4,11 @@ if ( ! defined('ABSPATH') ) {
|
|
4 |
}
|
5 |
|
6 |
class FrmFormsHelper {
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
if ( ! is_object( $form ) && ! is_array( $form ) && ! empty( $form ) ) {
|
13 |
-
$form = FrmForm::getOne($form);
|
14 |
-
}
|
15 |
-
}
|
16 |
|
17 |
public static function get_direct_link($key, $form = false ) {
|
18 |
$target_url = esc_url(admin_url('admin-ajax.php') . '?action=frm_forms_preview&form='. $key);
|
@@ -409,7 +405,9 @@ BEFORE_HTML;
|
|
409 |
$html = preg_replace( '/(\[if\s+save_draft\])(.*?)(\[\/if\s+save_draft\])/mis', '', $html );
|
410 |
}
|
411 |
|
412 |
-
|
|
|
|
|
413 |
|
414 |
return $html;
|
415 |
}
|
@@ -480,26 +478,6 @@ BEFORE_HTML;
|
|
480 |
return $style;
|
481 |
}
|
482 |
|
483 |
-
public static function form_loaded($form, $this_load, $global_load) {
|
484 |
-
global $frm_vars;
|
485 |
-
$small_form = new stdClass();
|
486 |
-
foreach ( array( 'id', 'form_key', 'name' ) as $var ) {
|
487 |
-
$small_form->{$var} = $form->{$var};
|
488 |
-
unset($var);
|
489 |
-
}
|
490 |
-
|
491 |
-
$frm_vars['forms_loaded'][] = $small_form;
|
492 |
-
|
493 |
-
if ( $this_load && empty($global_load) ) {
|
494 |
-
$global_load = $frm_vars['load_css'] = true;
|
495 |
-
}
|
496 |
-
|
497 |
-
if ( ( ! isset($frm_vars['css_loaded']) || ! $frm_vars['css_loaded'] ) && $global_load ) {
|
498 |
-
echo FrmAppController::footer_js('header');
|
499 |
-
$frm_vars['css_loaded'] = true;
|
500 |
-
}
|
501 |
-
}
|
502 |
-
|
503 |
/**
|
504 |
* Display the validation error messages when an entry is submitted
|
505 |
*
|
@@ -620,51 +598,13 @@ BEFORE_HTML;
|
|
620 |
return $name;
|
621 |
}
|
622 |
|
623 |
-
|
624 |
-
|
625 |
-
|
626 |
-
|
627 |
-
}
|
628 |
-
|
629 |
-
return $values;
|
630 |
-
}
|
631 |
-
|
632 |
-
/**
|
633 |
-
* @param string $status
|
634 |
-
*
|
635 |
-
* @return int The number of forms changed
|
636 |
-
*/
|
637 |
-
public static function change_form_status( $status ) {
|
638 |
-
$available_status = array(
|
639 |
-
'untrash' => array(
|
640 |
-
'permission' => 'frm_edit_forms', 'new_status' => 'published',
|
641 |
-
),
|
642 |
-
'trash' => array(
|
643 |
-
'permission' => 'frm_delete_forms', 'new_status' => 'trash',
|
644 |
-
),
|
645 |
-
);
|
646 |
-
|
647 |
-
if ( ! isset( $available_status[ $status ] ) ) {
|
648 |
-
return;
|
649 |
-
}
|
650 |
-
|
651 |
-
FrmAppHelper::permission_check( $available_status[ $status ]['permission'] );
|
652 |
-
|
653 |
-
$params = self::get_params();
|
654 |
-
|
655 |
-
//check nonce url
|
656 |
-
check_admin_referer($status .'_form_' . $params['id']);
|
657 |
-
|
658 |
-
$count = 0;
|
659 |
-
if ( FrmForm::set_status( $params['id'], $available_status[ $status ]['new_status'] ) ) {
|
660 |
-
$count++;
|
661 |
-
}
|
662 |
-
|
663 |
-
$available_status['untrash']['message'] = sprintf(_n( '%1$s form restored from the Trash.', '%1$s forms restored from the Trash.', $count, 'formidable' ), $count );
|
664 |
-
$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='. ( isset( $_REQUEST['form_type'] ) ? sanitize_title( $_REQUEST['form_type'] ) : '' ) . '&id=' . $params['id'], 'untrash_form_' . $params['id'] ) ) . '">', '</a>' );
|
665 |
-
|
666 |
-
$message = $available_status[ $status ]['message'];
|
667 |
|
668 |
-
|
669 |
-
|
|
|
|
|
670 |
}
|
4 |
}
|
5 |
|
6 |
class FrmFormsHelper {
|
7 |
+
|
8 |
+
public static function maybe_get_form( &$form ) {
|
9 |
+
_deprecated_function( __FUNCTION__, '2.0.9', 'FrmForm::maybe_get_form' );
|
10 |
+
FrmForm::maybe_get_form( $form );
|
11 |
+
}
|
|
|
|
|
|
|
|
|
12 |
|
13 |
public static function get_direct_link($key, $form = false ) {
|
14 |
$target_url = esc_url(admin_url('admin-ajax.php') . '?action=frm_forms_preview&form='. $key);
|
405 |
$html = preg_replace( '/(\[if\s+save_draft\])(.*?)(\[\/if\s+save_draft\])/mis', '', $html );
|
406 |
}
|
407 |
|
408 |
+
if ( apply_filters( 'frm_do_html_shortcodes', true ) ) {
|
409 |
+
$html = do_shortcode( $html );
|
410 |
+
}
|
411 |
|
412 |
return $html;
|
413 |
}
|
478 |
return $style;
|
479 |
}
|
480 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
481 |
/**
|
482 |
* Display the validation error messages when an entry is submitted
|
483 |
*
|
598 |
return $name;
|
599 |
}
|
600 |
|
601 |
+
public static function get_params() {
|
602 |
+
_deprecated_function( __FUNCTION__, '2.0.9', 'FrmForm::list_page_params' );
|
603 |
+
return FrmForm::list_page_params();
|
604 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
605 |
|
606 |
+
public static function form_loaded( $form, $this_load, $global_load ) {
|
607 |
+
_deprecated_function( __FUNCTION__, '2.0.9', 'FrmFormsController::maybe_load_css' );
|
608 |
+
FrmFormsController::maybe_load_css( $form, $this_load, $global_load );
|
609 |
+
}
|
610 |
}
|
classes/helpers/FrmFormsListHelper.php
CHANGED
@@ -158,6 +158,16 @@ class FrmFormsListHelper extends FrmListHelper {
|
|
158 |
<?php
|
159 |
}
|
160 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
161 |
public function get_views() {
|
162 |
|
163 |
$statuses = array(
|
158 |
<?php
|
159 |
}
|
160 |
|
161 |
+
protected function get_sortable_columns() {
|
162 |
+
return array(
|
163 |
+
'id' => 'id',
|
164 |
+
'name' => 'name',
|
165 |
+
'description' => 'description',
|
166 |
+
'form_key' => 'form_key',
|
167 |
+
'created_at' => 'created_at',
|
168 |
+
);
|
169 |
+
}
|
170 |
+
|
171 |
public function get_views() {
|
172 |
|
173 |
$statuses = array(
|
classes/helpers/FrmListHelper.php
CHANGED
@@ -20,6 +20,10 @@ class FrmListHelper extends WP_List_Table {
|
|
20 |
return current_user_can( 'administrator' );
|
21 |
}
|
22 |
|
|
|
|
|
|
|
|
|
23 |
public function display_rows() {
|
24 |
$style = '';
|
25 |
foreach ( $this->items as $item ) {
|
20 |
return current_user_can( 'administrator' );
|
21 |
}
|
22 |
|
23 |
+
public function get_columns() {
|
24 |
+
return array();
|
25 |
+
}
|
26 |
+
|
27 |
public function display_rows() {
|
28 |
$style = '';
|
29 |
foreach ( $this->items as $item ) {
|
classes/helpers/FrmXMLHelper.php
CHANGED
@@ -118,7 +118,6 @@ class FrmXMLHelper {
|
|
118 |
}
|
119 |
|
120 |
public static function import_xml_forms($forms, $imported) {
|
121 |
-
|
122 |
// Keep track of repeating sections that are created
|
123 |
$repeat_fields = array();
|
124 |
|
@@ -180,17 +179,6 @@ class FrmXMLHelper {
|
|
180 |
$imported['imported']['forms']++;
|
181 |
// Keep track of whether this specific form was updated or not
|
182 |
$imported['form_status'][ $form_id ] = 'imported';
|
183 |
-
|
184 |
-
// Check if any repeating sections form_select need to be updated
|
185 |
-
if ( isset( $repeat_fields[ $form['id'] ] ) ) {
|
186 |
-
// Get section field
|
187 |
-
$section_field = FrmField::getOne( $repeat_fields[ $form['id'] ] );
|
188 |
-
$field_opts = maybe_unserialize( $section_field->field_options );
|
189 |
-
$field_opts['form_select'] = $form_id;
|
190 |
-
|
191 |
-
// update form_select now
|
192 |
-
FrmField::update( $repeat_fields[ $form['id'] ], array( 'field_options' => maybe_serialize( $field_opts ) ) );
|
193 |
-
}
|
194 |
}
|
195 |
}
|
196 |
|
@@ -249,6 +237,7 @@ class FrmXMLHelper {
|
|
249 |
if ( $new_id == false ) {
|
250 |
continue;
|
251 |
}
|
|
|
252 |
|
253 |
// if no matching field id or key in this form, create the field
|
254 |
$imported['imported']['fields']++;
|
@@ -258,14 +247,11 @@ class FrmXMLHelper {
|
|
258 |
if ( $new_id == false ) {
|
259 |
continue;
|
260 |
}
|
|
|
|
|
261 |
$imported['imported']['fields']++;
|
262 |
}
|
263 |
|
264 |
-
// Check if a repeating section was just created
|
265 |
-
if ( isset( $new_id ) && $f['type'] == 'divider' && isset( $f['field_options']['repeat'] ) && $f['field_options']['repeat'] ) {
|
266 |
-
$repeat_fields[ $f['field_options']['form_select'] ] = $new_id;
|
267 |
-
}
|
268 |
-
|
269 |
unset($field, $new_id);
|
270 |
}
|
271 |
|
@@ -290,10 +276,55 @@ class FrmXMLHelper {
|
|
290 |
|
291 |
unset($form, $item);
|
292 |
}
|
|
|
293 |
|
294 |
return $imported;
|
295 |
}
|
296 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
297 |
public static function import_xml_views($views, $imported) {
|
298 |
$imported['posts'] = array();
|
299 |
$form_action_type = FrmFormActionsController::$action_post_type;
|
118 |
}
|
119 |
|
120 |
public static function import_xml_forms($forms, $imported) {
|
|
|
121 |
// Keep track of repeating sections that are created
|
122 |
$repeat_fields = array();
|
123 |
|
179 |
$imported['imported']['forms']++;
|
180 |
// Keep track of whether this specific form was updated or not
|
181 |
$imported['form_status'][ $form_id ] = 'imported';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
182 |
}
|
183 |
}
|
184 |
|
237 |
if ( $new_id == false ) {
|
238 |
continue;
|
239 |
}
|
240 |
+
self::track_repeating_fields( $f, $new_id, $repeat_fields );
|
241 |
|
242 |
// if no matching field id or key in this form, create the field
|
243 |
$imported['imported']['fields']++;
|
247 |
if ( $new_id == false ) {
|
248 |
continue;
|
249 |
}
|
250 |
+
|
251 |
+
self::track_repeating_fields( $f, $new_id, $repeat_fields );
|
252 |
$imported['imported']['fields']++;
|
253 |
}
|
254 |
|
|
|
|
|
|
|
|
|
|
|
255 |
unset($field, $new_id);
|
256 |
}
|
257 |
|
276 |
|
277 |
unset($form, $item);
|
278 |
}
|
279 |
+
self::update_repeat_field_options( $repeat_fields, $imported['forms'] );
|
280 |
|
281 |
return $imported;
|
282 |
}
|
283 |
|
284 |
+
/**
|
285 |
+
* Update form_select for all imported repeating sections and embedded forms
|
286 |
+
*
|
287 |
+
* @since 2.0.09
|
288 |
+
* @param array $repeat_fields - old form ID as keys and section field IDs as items
|
289 |
+
* @param array $imported_forms
|
290 |
+
*/
|
291 |
+
private static function update_repeat_field_options( $repeat_fields, $imported_forms ) {
|
292 |
+
foreach ( $repeat_fields as $old_form_id => $new_repeat_fields ) {
|
293 |
+
foreach ( $new_repeat_fields as $repeat_field_id ) {
|
294 |
+
// Get section/embed form field
|
295 |
+
$repeat_field = FrmField::getOne( $repeat_field_id );
|
296 |
+
$field_opts = maybe_unserialize( $repeat_field->field_options );
|
297 |
+
|
298 |
+
if ( ! $imported_forms[ $old_form_id ] ) {
|
299 |
+
return;
|
300 |
+
}
|
301 |
+
$field_opts['form_select'] = $imported_forms[ $old_form_id ];
|
302 |
+
|
303 |
+
// update form_select now
|
304 |
+
FrmField::update( $repeat_field_id, array( 'field_options' => maybe_serialize( $field_opts ) ) );
|
305 |
+
}
|
306 |
+
}
|
307 |
+
}
|
308 |
+
|
309 |
+
/**
|
310 |
+
* Keep track of imported repeating fields and embedded forms
|
311 |
+
*
|
312 |
+
* @since 2.0.09
|
313 |
+
* @param array $f - field array
|
314 |
+
* @param int $repeat_field_id
|
315 |
+
* @param array $repeat_fields - pass by reference
|
316 |
+
*/
|
317 |
+
private static function track_repeating_fields( $f, $repeat_field_id, &$repeat_fields ) {
|
318 |
+
if ( FrmField::is_repeating_field( $f ) || $f['type'] == 'form' ) {
|
319 |
+
$old_form_id = $f['field_options']['form_select'];
|
320 |
+
if ( ! isset( $repeat_fields[ $old_form_id ] ) ) {
|
321 |
+
$repeat_fields[ $old_form_id ] = array();
|
322 |
+
}
|
323 |
+
|
324 |
+
$repeat_fields[ $old_form_id ][] = $repeat_field_id;
|
325 |
+
}
|
326 |
+
}
|
327 |
+
|
328 |
public static function import_xml_views($views, $imported) {
|
329 |
$imported['posts'] = array();
|
330 |
$form_action_type = FrmFormActionsController::$action_post_type;
|
classes/models/FrmDb.php
CHANGED
@@ -223,6 +223,8 @@ class FrmDb {
|
|
223 |
* @param string $where
|
224 |
*/
|
225 |
private static function interpret_array_to_sql( $key, $value, &$where, &$values ) {
|
|
|
|
|
226 |
if ( strpos( $key, 'created_at' ) !== false || strpos( $key, 'updated_at' ) !== false ) {
|
227 |
$k = explode(' ', $key);
|
228 |
$where .= ' DATE_FORMAT(' . reset( $k ) . ', %s) ' . str_replace( reset( $k ), '', $key );
|
@@ -233,6 +235,7 @@ class FrmDb {
|
|
233 |
|
234 |
$lowercase_key = explode( ' ', strtolower( $key ) );
|
235 |
$lowercase_key = end( $lowercase_key );
|
|
|
236 |
if ( is_array( $value ) ) {
|
237 |
// translate array of values to "in"
|
238 |
if ( strpos( $lowercase_key, 'like' ) !== false ) {
|
@@ -248,7 +251,7 @@ class FrmDb {
|
|
248 |
$values[] = '%' . FrmAppHelper::esc_like( $v ) . '%';
|
249 |
}
|
250 |
$where .= ')';
|
251 |
-
} else {
|
252 |
$where .= ' in ('. FrmAppHelper::prepare_array_values( $value, '%s' ) .')';
|
253 |
$values = array_merge( $values, $value );
|
254 |
}
|
@@ -676,7 +679,7 @@ DEFAULT_HTML;
|
|
676 |
private function migrate_to_6() {
|
677 |
global $wpdb;
|
678 |
|
679 |
-
|
680 |
$fields = FrmDb::get_results( $this->fields, array( 'type NOT' => $no_save ), 'id, field_options' );
|
681 |
|
682 |
$default_html = <<<DEFAULT_HTML
|
@@ -702,7 +705,7 @@ DEFAULT_HTML;
|
|
702 |
$new_default_html = FrmFieldsHelper::get_default_html('text');
|
703 |
foreach ( $fields as $field ) {
|
704 |
$field->field_options = maybe_unserialize($field->field_options);
|
705 |
-
|
706 |
$field->field_options['custom_html'] = $new_default_html;
|
707 |
$wpdb->update( $this->fields, array( 'field_options' => maybe_serialize( $field->field_options ) ), array( 'id' => $field->id ) );
|
708 |
}
|
223 |
* @param string $where
|
224 |
*/
|
225 |
private static function interpret_array_to_sql( $key, $value, &$where, &$values ) {
|
226 |
+
$key = trim( $key );
|
227 |
+
|
228 |
if ( strpos( $key, 'created_at' ) !== false || strpos( $key, 'updated_at' ) !== false ) {
|
229 |
$k = explode(' ', $key);
|
230 |
$where .= ' DATE_FORMAT(' . reset( $k ) . ', %s) ' . str_replace( reset( $k ), '', $key );
|
235 |
|
236 |
$lowercase_key = explode( ' ', strtolower( $key ) );
|
237 |
$lowercase_key = end( $lowercase_key );
|
238 |
+
|
239 |
if ( is_array( $value ) ) {
|
240 |
// translate array of values to "in"
|
241 |
if ( strpos( $lowercase_key, 'like' ) !== false ) {
|
251 |
$values[] = '%' . FrmAppHelper::esc_like( $v ) . '%';
|
252 |
}
|
253 |
$where .= ')';
|
254 |
+
} else if ( ! empty( $value ) ) {
|
255 |
$where .= ' in ('. FrmAppHelper::prepare_array_values( $value, '%s' ) .')';
|
256 |
$values = array_merge( $values, $value );
|
257 |
}
|
679 |
private function migrate_to_6() {
|
680 |
global $wpdb;
|
681 |
|
682 |
+
$no_save = array_merge( FrmField::no_save_fields(), array( 'form', 'hidden', 'user_id' ) );
|
683 |
$fields = FrmDb::get_results( $this->fields, array( 'type NOT' => $no_save ), 'id, field_options' );
|
684 |
|
685 |
$default_html = <<<DEFAULT_HTML
|
705 |
$new_default_html = FrmFieldsHelper::get_default_html('text');
|
706 |
foreach ( $fields as $field ) {
|
707 |
$field->field_options = maybe_unserialize($field->field_options);
|
708 |
+
if ( ! FrmField::is_option_empty( $field, 'custom_html' ) || $field->field_options['custom_html'] == $default_html || $field->field_options['custom_html'] == $old_default_html ) {
|
709 |
$field->field_options['custom_html'] = $new_default_html;
|
710 |
$wpdb->update( $this->fields, array( 'field_options' => maybe_serialize( $field->field_options ) ), array( 'id' => $field->id ) );
|
711 |
}
|
classes/models/FrmEntry.php
CHANGED
@@ -22,8 +22,8 @@ class FrmEntry {
|
|
22 |
'ip' => FrmAppHelper::get_ip_address(),
|
23 |
'is_draft' => ( ( isset($values['frm_saving_draft']) && $values['frm_saving_draft'] == 1 ) || ( isset($values['is_draft']) && $values['is_draft'] == 1) ) ? 1 : 0,
|
24 |
'form_id' => isset($values['form_id']) ? (int) $values['form_id']: null,
|
25 |
-
|
26 |
-
|
27 |
'created_at' => isset($values['created_at']) ? $values['created_at'] : current_time('mysql', 1),
|
28 |
'updated_at' => isset($values['updated_at']) ? $values['updated_at'] : ( isset($values['created_at']) ? $values['created_at'] : current_time('mysql', 1) ),
|
29 |
);
|
@@ -35,11 +35,9 @@ class FrmEntry {
|
|
35 |
if ( isset($values['description']) && ! empty($values['description']) ) {
|
36 |
$new_values['description'] = maybe_serialize($values['description']);
|
37 |
} else {
|
38 |
-
$referrerinfo = FrmAppHelper::get_server_value('HTTP_REFERER');
|
39 |
-
|
40 |
$new_values['description'] = serialize( array(
|
41 |
-
|
42 |
-
|
43 |
) );
|
44 |
}
|
45 |
|
@@ -94,22 +92,21 @@ class FrmEntry {
|
|
94 |
* @return boolean
|
95 |
*/
|
96 |
public static function is_duplicate($new_values, $values) {
|
97 |
-
|
98 |
return false;
|
99 |
}
|
100 |
|
101 |
$check_val = $new_values;
|
102 |
$check_val['created_at >'] = date( 'Y-m-d H:i:s', ( strtotime( $new_values['created_at'] ) - 60 ) );
|
103 |
|
104 |
-
|
105 |
-
|
106 |
|
107 |
if ( $new_values['item_key'] == $new_values['name'] ) {
|
108 |
unset($check_val['name']);
|
109 |
}
|
110 |
|
111 |
global $wpdb;
|
112 |
-
|
113 |
$entry_exists = FrmDb::get_col( $wpdb->prefix . 'frm_items', $check_val, 'id', array( 'order_by' => 'created_at DESC' ) );
|
114 |
|
115 |
if ( ! $entry_exists || empty($entry_exists) || ! isset($values['item_meta']) ) {
|
@@ -142,7 +139,7 @@ class FrmEntry {
|
|
142 |
}
|
143 |
|
144 |
if ( $is_duplicate ) {
|
145 |
-
|
146 |
}
|
147 |
}
|
148 |
|
@@ -280,6 +277,17 @@ class FrmEntry {
|
|
280 |
FrmAppHelper::cache_delete_group( 'frm_item_meta' );
|
281 |
}
|
282 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
283 |
public static function getOne( $id, $meta = false) {
|
284 |
global $wpdb;
|
285 |
|
@@ -477,51 +485,6 @@ class FrmEntry {
|
|
477 |
}
|
478 |
}
|
479 |
|
480 |
-
public static function validate( $values, $exclude = false ) {
|
481 |
-
global $wpdb;
|
482 |
-
|
483 |
-
self::sanitize_entry_post( $values );
|
484 |
-
$errors = array();
|
485 |
-
|
486 |
-
if ( ! isset($values['form_id']) || ! isset($values['item_meta']) ) {
|
487 |
-
$errors['form'] = __( 'There was a problem with your submission. Please try again.', 'formidable' );
|
488 |
-
return $errors;
|
489 |
-
}
|
490 |
-
|
491 |
-
if ( FrmAppHelper::is_admin() && is_user_logged_in() && ( ! isset( $values[ 'frm_submit_entry_' . $values['form_id'] ] ) || ! wp_verify_nonce( $values[ 'frm_submit_entry_' . $values['form_id'] ], 'frm_submit_entry_nonce' ) ) ) {
|
492 |
-
$errors['form'] = __( 'You do not have permission to do that', 'formidable' );
|
493 |
-
}
|
494 |
-
|
495 |
-
if ( ! isset($values['item_key']) || $values['item_key'] == '' ) {
|
496 |
-
$_POST['item_key'] = $values['item_key'] = FrmAppHelper::get_unique_key('', $wpdb->prefix .'frm_items', 'item_key');
|
497 |
-
}
|
498 |
-
|
499 |
-
$where = apply_filters('frm_posted_field_ids', array( 'fi.form_id' => $values['form_id'] ) );
|
500 |
-
// Don't get subfields
|
501 |
-
$where['fr.parent_form_id'] = array( null, 0 );
|
502 |
-
// Don't get excluded fields (like file upload fields in the ajax validation)
|
503 |
-
if ( ! empty( $exclude ) ) {
|
504 |
-
$where['fi.type not'] = $exclude;
|
505 |
-
}
|
506 |
-
|
507 |
-
$posted_fields = FrmField::getAll($where, 'field_order');
|
508 |
-
|
509 |
-
// Pass exclude value to validate_field function so it can be used for repeating sections
|
510 |
-
$args = array( 'exclude' => $exclude );
|
511 |
-
|
512 |
-
foreach ( $posted_fields as $posted_field ) {
|
513 |
-
self::validate_field($posted_field, $errors, $values, $args);
|
514 |
-
unset($posted_field);
|
515 |
-
}
|
516 |
-
|
517 |
-
// check for spam
|
518 |
-
self::spam_check($exclude, $values, $errors);
|
519 |
-
|
520 |
-
$errors = apply_filters('frm_validate_entry', $errors, $values, compact('exclude'));
|
521 |
-
|
522 |
-
return $errors;
|
523 |
-
}
|
524 |
-
|
525 |
/**
|
526 |
* Sanitize the POST values before we use them
|
527 |
*
|
@@ -539,243 +502,51 @@ class FrmEntry {
|
|
539 |
'is_draft' => 'absint',
|
540 |
'post_id' => 'absint',
|
541 |
'parent_item_id' => 'absint',
|
542 |
-
'created_at' => '
|
543 |
-
'updated_at' => '
|
544 |
);
|
545 |
|
546 |
FrmAppHelper::sanitize_request( $sanitize_method, $values );
|
547 |
}
|
548 |
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
'key_pointer' => '', // the pointer in the posted array
|
554 |
-
'exclude' => array(), // exclude these field types from validation
|
555 |
-
);
|
556 |
-
$args = wp_parse_args( $args, $defaults );
|
557 |
-
|
558 |
-
if ( empty($args['parent_field_id']) ) {
|
559 |
-
$value = isset( $values['item_meta'][ $args['id'] ] ) ? $values['item_meta'][ $args['id'] ] : '';
|
560 |
-
} else {
|
561 |
-
// value is from a nested form
|
562 |
-
$value = $values;
|
563 |
-
}
|
564 |
-
|
565 |
-
// Check for values in "Other" fields
|
566 |
-
FrmEntriesHelper::maybe_set_other_validation( $posted_field, $value, $args );
|
567 |
-
|
568 |
-
if ( isset($posted_field->field_options['default_blank']) && $posted_field->field_options['default_blank'] && $value == $posted_field->default_value ) {
|
569 |
-
$value = '';
|
570 |
-
}
|
571 |
-
|
572 |
-
// Check for an array with only one value
|
573 |
-
// Don't reset values in "Other" fields because array keys need to be preserved
|
574 |
-
if ( is_array($value) && count( $value ) == 1 && $args['other'] !== true ) {
|
575 |
-
$value = reset($value);
|
576 |
-
}
|
577 |
-
|
578 |
-
if ( $posted_field->required == '1' && ! is_array( $value ) && trim( $value ) == '' ) {
|
579 |
-
$frm_settings = FrmAppHelper::get_settings();
|
580 |
-
$errors[ 'field' . $args['id'] ] = ( ! isset( $posted_field->field_options['blank'] ) || $posted_field->field_options['blank'] == '' ) ? $frm_settings->blank_msg : $posted_field->field_options['blank'];
|
581 |
-
} else if ( $posted_field->type == 'text' && ! isset( $_POST['name'] ) ) {
|
582 |
-
$_POST['name'] = $value;
|
583 |
-
}
|
584 |
-
|
585 |
-
self::validate_url_field($errors, $posted_field, $value, $args);
|
586 |
-
self::validate_email_field($errors, $posted_field, $value, $args);
|
587 |
-
|
588 |
-
FrmEntriesHelper::set_posted_value($posted_field, $value, $args);
|
589 |
-
|
590 |
-
self::validate_recaptcha($errors, $posted_field, $args);
|
591 |
-
|
592 |
-
$errors = apply_filters('frm_validate_field_entry', $errors, $posted_field, $value, $args);
|
593 |
-
}
|
594 |
-
|
595 |
-
public static function validate_url_field(&$errors, $field, &$value, $args) {
|
596 |
-
if ( $value == '' || ! in_array( $field->type, array( 'website', 'url', 'image' ) ) ) {
|
597 |
-
return;
|
598 |
-
}
|
599 |
-
|
600 |
-
if ( trim($value) == 'http://' ) {
|
601 |
-
$value = '';
|
602 |
-
} else {
|
603 |
-
$value = esc_url_raw( $value );
|
604 |
-
$value = preg_match('/^(https?|ftps?|mailto|news|feed|telnet):/is', $value) ? $value : 'http://'. $value;
|
605 |
-
}
|
606 |
-
|
607 |
-
//validate the url format
|
608 |
-
if ( ! preg_match('/^http(s)?:\/\/([\da-z\.-]+)\.([\da-z\.-]+)/i', $value) ) {
|
609 |
-
$errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $field, 'invalid' );
|
610 |
-
}
|
611 |
-
}
|
612 |
-
|
613 |
-
public static function validate_email_field(&$errors, $field, $value, $args) {
|
614 |
-
if ( $value == '' || $field->type != 'email' ) {
|
615 |
-
return;
|
616 |
-
}
|
617 |
-
|
618 |
-
//validate the email format
|
619 |
-
if ( ! is_email($value) ) {
|
620 |
-
$errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $field, 'invalid' );
|
621 |
-
}
|
622 |
-
}
|
623 |
-
|
624 |
-
public static function validate_recaptcha(&$errors, $field, $args) {
|
625 |
-
if ( $field->type != 'captcha' || FrmAppHelper::is_admin() ) {
|
626 |
-
return;
|
627 |
-
}
|
628 |
-
|
629 |
-
$frm_settings = FrmAppHelper::get_settings();
|
630 |
-
if ( empty( $frm_settings->pubkey ) ) {
|
631 |
-
// don't require the captcha if it shouldn't be shown
|
632 |
-
return;
|
633 |
-
}
|
634 |
-
|
635 |
-
if ( ! isset($_POST['g-recaptcha-response']) ) {
|
636 |
-
// If captcha is missing, check if it was already verified
|
637 |
-
if ( ! isset( $_POST['recaptcha_checked'] ) || ! wp_verify_nonce( $_POST['recaptcha_checked'], 'frm_ajax' ) ) {
|
638 |
-
// There was no captcha submitted
|
639 |
-
$errors[ 'field' . $args['id'] ] = __( 'The captcha is missing from this form', 'formidable' );
|
640 |
-
}
|
641 |
-
return;
|
642 |
-
}
|
643 |
-
|
644 |
-
$arg_array = array(
|
645 |
-
'body' => array(
|
646 |
-
'secret' => $frm_settings->privkey,
|
647 |
-
'response' => $_POST['g-recaptcha-response'],
|
648 |
-
'remoteip' => FrmAppHelper::get_ip_address(),
|
649 |
-
),
|
650 |
-
);
|
651 |
-
$resp = wp_remote_post( 'https://www.google.com/recaptcha/api/siteverify', $arg_array );
|
652 |
-
$response = json_decode(wp_remote_retrieve_body( $resp ), true);
|
653 |
-
|
654 |
-
if ( isset( $response['success'] ) && ! $response['success'] ) {
|
655 |
-
// What happens when the CAPTCHA was entered incorrectly
|
656 |
-
$errors[ 'field' . $args['id'] ] = ( ! isset( $field->field_options['invalid'] ) || $field->field_options['invalid'] == '' ) ? $frm_settings->re_msg : $field->field_options['invalid'];
|
657 |
-
}
|
658 |
-
}
|
659 |
-
|
660 |
-
/**
|
661 |
-
* check for spam
|
662 |
-
* @param boolean $exclude
|
663 |
-
* @param array $values
|
664 |
-
* @param array $errors by reference
|
665 |
-
*/
|
666 |
-
public static function spam_check($exclude, $values, &$errors) {
|
667 |
-
if ( ! empty($exclude) || ! isset($values['item_meta']) || empty($values['item_meta']) || ! empty($errors) ) {
|
668 |
-
// only check spam if there are no other errors
|
669 |
-
return;
|
670 |
-
}
|
671 |
-
|
672 |
-
global $wpcom_api_key;
|
673 |
-
if ( ( function_exists( 'akismet_http_post' ) || is_callable('Akismet::http_post') ) && ( get_option('wordpress_api_key') || $wpcom_api_key ) && self::akismet($values) ) {
|
674 |
-
$form = FrmForm::getOne($values['form_id']);
|
675 |
-
|
676 |
-
if ( isset($form->options['akismet']) && ! empty($form->options['akismet']) && ( $form->options['akismet'] != 'logged' || ! is_user_logged_in() ) ) {
|
677 |
-
$errors['spam'] = __( 'Your entry appears to be spam!', 'formidable' );
|
678 |
-
}
|
679 |
-
}
|
680 |
-
|
681 |
-
// check for blacklist keys
|
682 |
-
if ( self::blacklist_check($values) ) {
|
683 |
-
$errors['spam'] = __( 'Your entry appears to be spam!', 'formidable' );
|
684 |
-
}
|
685 |
-
}
|
686 |
-
|
687 |
-
// check the blacklisted words
|
688 |
-
public static function blacklist_check( $values ) {
|
689 |
-
if ( ! apply_filters('frm_check_blacklist', true, $values) ) {
|
690 |
-
return false;
|
691 |
-
}
|
692 |
-
|
693 |
-
$mod_keys = trim( get_option( 'blacklist_keys' ) );
|
694 |
-
|
695 |
-
if ( empty( $mod_keys ) ) {
|
696 |
-
return false;
|
697 |
-
}
|
698 |
-
|
699 |
-
$content = FrmEntriesHelper::entry_array_to_string($values);
|
700 |
-
|
701 |
-
if ( empty($content) ) {
|
702 |
-
return false;
|
703 |
-
}
|
704 |
-
|
705 |
-
$words = explode( "\n", $mod_keys );
|
706 |
-
|
707 |
-
foreach ( (array) $words as $word ) {
|
708 |
-
$word = trim( $word );
|
709 |
-
|
710 |
-
if ( empty($word) ) {
|
711 |
-
continue;
|
712 |
-
}
|
713 |
-
|
714 |
-
if ( preg_match('#' . preg_quote( $word, '#' ) . '#', $content) ) {
|
715 |
-
return true;
|
716 |
-
}
|
717 |
-
}
|
718 |
-
|
719 |
-
return false;
|
720 |
-
}
|
721 |
|
722 |
-
|
723 |
-
|
724 |
-
|
725 |
-
|
726 |
-
*/
|
727 |
-
public static function akismet($values) {
|
728 |
-
$content = FrmEntriesHelper::entry_array_to_string($values);
|
729 |
|
730 |
-
|
731 |
-
|
732 |
-
|
|
|
733 |
|
734 |
-
|
735 |
-
|
|
|
|
|
736 |
|
737 |
-
|
738 |
-
|
739 |
-
|
740 |
-
|
741 |
-
}
|
742 |
|
743 |
-
|
744 |
-
|
745 |
-
|
746 |
-
|
747 |
-
$response = akismet_http_post( $query_string, $akismet_api_host, '/1.1/comment-check', $akismet_api_port );
|
748 |
-
}
|
749 |
|
750 |
-
|
751 |
-
|
|
|
|
|
752 |
|
753 |
-
|
754 |
-
|
755 |
-
|
756 |
-
|
757 |
-
* @param string $content
|
758 |
-
*/
|
759 |
-
private static function parse_akismet_array( &$datas, $content ) {
|
760 |
-
$datas['blog'] = FrmAppHelper::site_url();
|
761 |
-
$datas['user_ip'] = preg_replace( '/[^0-9., ]/', '', FrmAppHelper::get_ip_address() );
|
762 |
-
$datas['user_agent'] = FrmAppHelper::get_server_value( 'HTTP_USER_AGENT' );
|
763 |
-
$datas['referrer'] = isset( $_SERVER['HTTP_REFERER'] ) ? FrmAppHelper::get_server_value( 'HTTP_REFERER' ) : false;
|
764 |
-
$datas['comment_type'] = 'formidable';
|
765 |
-
$datas['comment_content'] = $content;
|
766 |
-
|
767 |
-
if ( $permalink = get_permalink() ) {
|
768 |
-
$datas['permalink'] = $permalink;
|
769 |
-
}
|
770 |
-
|
771 |
-
foreach ( $_SERVER as $key => $value ) {
|
772 |
-
if ( ! in_array( $key, array( 'HTTP_COOKIE', 'HTTP_COOKIE2', 'PHP_AUTH_PW' ) ) && is_string( $value ) ) {
|
773 |
-
$datas[ $key ] = wp_strip_all_tags( $value );
|
774 |
-
} else {
|
775 |
-
$datas[ $key ] = '';
|
776 |
-
}
|
777 |
|
778 |
-
unset($key, $value);
|
779 |
-
}
|
780 |
-
}
|
781 |
}
|
22 |
'ip' => FrmAppHelper::get_ip_address(),
|
23 |
'is_draft' => ( ( isset($values['frm_saving_draft']) && $values['frm_saving_draft'] == 1 ) || ( isset($values['is_draft']) && $values['is_draft'] == 1) ) ? 1 : 0,
|
24 |
'form_id' => isset($values['form_id']) ? (int) $values['form_id']: null,
|
25 |
+
'post_id' => isset( $values['post_id'] ) ? (int) $values['post_id']: 0,
|
26 |
+
'parent_item_id' => isset( $values['parent_item_id'] ) ? (int) $values['parent_item_id']: 0,
|
27 |
'created_at' => isset($values['created_at']) ? $values['created_at'] : current_time('mysql', 1),
|
28 |
'updated_at' => isset($values['updated_at']) ? $values['updated_at'] : ( isset($values['created_at']) ? $values['created_at'] : current_time('mysql', 1) ),
|
29 |
);
|
35 |
if ( isset($values['description']) && ! empty($values['description']) ) {
|
36 |
$new_values['description'] = maybe_serialize($values['description']);
|
37 |
} else {
|
|
|
|
|
38 |
$new_values['description'] = serialize( array(
|
39 |
+
'browser' => FrmAppHelper::get_server_value( 'HTTP_USER_AGENT' ),
|
40 |
+
'referrer' => FrmAppHelper::get_server_value( 'HTTP_REFERER' ),
|
41 |
) );
|
42 |
}
|
43 |
|
92 |
* @return boolean
|
93 |
*/
|
94 |
public static function is_duplicate($new_values, $values) {
|
95 |
+
if ( defined('WP_IMPORTING') && WP_IMPORTING ) {
|
96 |
return false;
|
97 |
}
|
98 |
|
99 |
$check_val = $new_values;
|
100 |
$check_val['created_at >'] = date( 'Y-m-d H:i:s', ( strtotime( $new_values['created_at'] ) - 60 ) );
|
101 |
|
102 |
+
unset( $check_val['created_at'], $check_val['updated_at'] );
|
103 |
+
unset( $check_val['is_draft'], $check_val['id'], $check_val['item_key'] );
|
104 |
|
105 |
if ( $new_values['item_key'] == $new_values['name'] ) {
|
106 |
unset($check_val['name']);
|
107 |
}
|
108 |
|
109 |
global $wpdb;
|
|
|
110 |
$entry_exists = FrmDb::get_col( $wpdb->prefix . 'frm_items', $check_val, 'id', array( 'order_by' => 'created_at DESC' ) );
|
111 |
|
112 |
if ( ! $entry_exists || empty($entry_exists) || ! isset($values['item_meta']) ) {
|
139 |
}
|
140 |
|
141 |
if ( $is_duplicate ) {
|
142 |
+
break;
|
143 |
}
|
144 |
}
|
145 |
|
277 |
FrmAppHelper::cache_delete_group( 'frm_item_meta' );
|
278 |
}
|
279 |
|
280 |
+
/**
|
281 |
+
* If $entry is numeric, get the entry object
|
282 |
+
* @param int|object $entry by reference
|
283 |
+
* @since 2.0.9
|
284 |
+
*/
|
285 |
+
public static function maybe_get_entry( &$entry ) {
|
286 |
+
if ( $entry && is_numeric( $entry ) ) {
|
287 |
+
$entry = self::getOne( $entry );
|
288 |
+
}
|
289 |
+
}
|
290 |
+
|
291 |
public static function getOne( $id, $meta = false) {
|
292 |
global $wpdb;
|
293 |
|
485 |
}
|
486 |
}
|
487 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
488 |
/**
|
489 |
* Sanitize the POST values before we use them
|
490 |
*
|
502 |
'is_draft' => 'absint',
|
503 |
'post_id' => 'absint',
|
504 |
'parent_item_id' => 'absint',
|
505 |
+
'created_at' => 'sanitize_text_field',
|
506 |
+
'updated_at' => 'sanitize_text_field',
|
507 |
);
|
508 |
|
509 |
FrmAppHelper::sanitize_request( $sanitize_method, $values );
|
510 |
}
|
511 |
|
512 |
+
public static function validate( $values, $exclude = false ) {
|
513 |
+
_deprecated_function( __FUNCTION__, '2.0.9', 'FrmEntryValidate::validate' );
|
514 |
+
return FrmEntryValidate::validate( $values, $exclude );
|
515 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
516 |
|
517 |
+
public static function validate_field( $posted_field, &$errors, $values, $args = array() ) {
|
518 |
+
_deprecated_function( __FUNCTION__, '2.0.9', 'FrmEntryValidate::validate_field' );
|
519 |
+
FrmEntryValidate::validate_field( $posted_field, $errors, $values, $args );
|
520 |
+
}
|
|
|
|
|
|
|
521 |
|
522 |
+
public static function validate_url_field( &$errors, $field, &$value, $args ) {
|
523 |
+
_deprecated_function( __FUNCTION__, '2.0.9', 'FrmEntryValidate::validate_url_field' );
|
524 |
+
FrmEntryValidate::validate_url_field( $errors, $field, $value, $args );
|
525 |
+
}
|
526 |
|
527 |
+
public static function validate_email_field( &$errors, $field, $value, $args ) {
|
528 |
+
_deprecated_function( __FUNCTION__, '2.0.9', 'FrmEntryValidate::validate_email_field' );
|
529 |
+
FrmEntryValidate::validate_email_field( $errors, $field, $value, $args );
|
530 |
+
}
|
531 |
|
532 |
+
public static function validate_recaptcha( &$errors, $field, $args ) {
|
533 |
+
_deprecated_function( __FUNCTION__, '2.0.9', 'FrmEntryValidate::validate_recaptcha' );
|
534 |
+
FrmEntryValidate::validate_recaptcha( $errors, $field, $args );
|
535 |
+
}
|
|
|
536 |
|
537 |
+
public static function spam_check( $exclude, $values, &$errors ) {
|
538 |
+
_deprecated_function( __FUNCTION__, '2.0.9', 'FrmEntryValidate::spam_check' );
|
539 |
+
FrmEntryValidate::spam_check( $exclude, $values, $errors );
|
540 |
+
}
|
|
|
|
|
541 |
|
542 |
+
public static function blacklist_check( $values ) {
|
543 |
+
_deprecated_function( __FUNCTION__, '2.0.9', 'FrmEntryValidate::blacklist_check' );
|
544 |
+
return FrmEntryValidate::blacklist_check( $values );
|
545 |
+
}
|
546 |
|
547 |
+
public static function akismet( $values ) {
|
548 |
+
_deprecated_function( __FUNCTION__, '2.0.9', 'FrmEntryValidate::akismet' );
|
549 |
+
return FrmEntryValidate::akismet( $values );
|
550 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
551 |
|
|
|
|
|
|
|
552 |
}
|
classes/models/FrmEntryFormat.php
ADDED
@@ -0,0 +1,324 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class FrmEntryFormat {
|
4 |
+
public static function show_entry( $atts ) {
|
5 |
+
$atts = shortcode_atts( array(
|
6 |
+
'id' => false, 'entry' => false, 'fields' => false, 'plain_text' => false,
|
7 |
+
'user_info' => false, 'include_blank' => false, 'default_email' => false,
|
8 |
+
'form_id' => false, 'format' => 'text', 'direction' => 'ltr',
|
9 |
+
'font_size' => '', 'text_color' => '',
|
10 |
+
'border_width' => '', 'border_color' => '',
|
11 |
+
'bg_color' => '', 'alt_bg_color' => '',
|
12 |
+
), $atts );
|
13 |
+
|
14 |
+
if ( $atts['format'] != 'text' ) {
|
15 |
+
//format options are text, array, or json
|
16 |
+
$atts['plain_text'] = true;
|
17 |
+
}
|
18 |
+
|
19 |
+
if ( is_object( $atts['entry'] ) && ! isset( $atts['entry']->metas ) ) {
|
20 |
+
// if the entry does not include metas, force it again
|
21 |
+
$atts['entry'] = false;
|
22 |
+
}
|
23 |
+
|
24 |
+
if ( ! $atts['entry'] || ! is_object( $atts['entry'] ) ) {
|
25 |
+
if ( ! $atts['id'] && ! $atts['default_email'] ) {
|
26 |
+
return;
|
27 |
+
}
|
28 |
+
|
29 |
+
if ( $atts['id'] ) {
|
30 |
+
$atts['entry'] = FrmEntry::getOne( $atts['id'], true );
|
31 |
+
}
|
32 |
+
}
|
33 |
+
|
34 |
+
if ( $atts['entry'] ) {
|
35 |
+
$atts['form_id'] = $atts['entry']->form_id;
|
36 |
+
$atts['id'] = $atts['entry']->id;
|
37 |
+
}
|
38 |
+
|
39 |
+
if ( ! $atts['fields'] || ! is_array($atts['fields']) ) {
|
40 |
+
$atts['fields'] = FrmField::get_all_for_form( $atts['form_id'], '', 'include' );
|
41 |
+
}
|
42 |
+
|
43 |
+
$values = array();
|
44 |
+
foreach ( $atts['fields'] as $f ) {
|
45 |
+
self::fill_entry_values( $atts, $f, $values );
|
46 |
+
unset($f);
|
47 |
+
}
|
48 |
+
|
49 |
+
self::fill_entry_user_info( $atts, $values );
|
50 |
+
|
51 |
+
if ( $atts['format'] == 'json' ) {
|
52 |
+
return json_encode($values);
|
53 |
+
} else if ( $atts['format'] == 'array' ) {
|
54 |
+
return $values;
|
55 |
+
}
|
56 |
+
|
57 |
+
$content = array();
|
58 |
+
self::convert_entry_to_content( $values, $atts, $content );
|
59 |
+
|
60 |
+
if ( 'text' == $atts['format'] ) {
|
61 |
+
$content = implode('', $content);
|
62 |
+
}
|
63 |
+
|
64 |
+
return $content;
|
65 |
+
}
|
66 |
+
|
67 |
+
public static function fill_entry_values( $atts, $f, array &$values ) {
|
68 |
+
if ( FrmField::is_no_save_field( $f->type ) ) {
|
69 |
+
return;
|
70 |
+
}
|
71 |
+
|
72 |
+
if ( $atts['default_email'] ) {
|
73 |
+
$values[ $f->id ] = array( 'label' => '[' . $f->id . ' show=field_label]', 'val' => '[' . $f->id . ']' );
|
74 |
+
return;
|
75 |
+
}
|
76 |
+
|
77 |
+
//Remove signature from default-message shortcode
|
78 |
+
if ( $f->type == 'signature' ) {
|
79 |
+
return;
|
80 |
+
}
|
81 |
+
|
82 |
+
if ( $atts['entry'] && ! isset( $atts['entry']->metas[ $f->id ] ) ) {
|
83 |
+
// In case include_blank is set
|
84 |
+
$atts['entry']->metas[ $f->id ] = '';
|
85 |
+
|
86 |
+
if ( FrmAppHelper::pro_is_installed() ) {
|
87 |
+
FrmProEntryMeta::add_post_value_to_entry( $f, $atts['entry'] );
|
88 |
+
FrmProEntryMeta::add_repeating_value_to_entry( $f, $atts['entry'] );
|
89 |
+
}
|
90 |
+
}
|
91 |
+
|
92 |
+
$val = '';
|
93 |
+
if ( $atts['entry'] ) {
|
94 |
+
$prev_val = maybe_unserialize( $atts['entry']->metas[ $f->id ] );
|
95 |
+
$meta = array( 'item_id' => $atts['id'], 'field_id' => $f->id, 'meta_value' => $prev_val, 'field_type' => $f->type );
|
96 |
+
|
97 |
+
//This filter applies to the default-message shortcode and frm-show-entry shortcode only
|
98 |
+
if ( isset( $atts['filter'] ) && $atts['filter'] == false ) {
|
99 |
+
$val = $prev_val;
|
100 |
+
} else {
|
101 |
+
$val = apply_filters( 'frm_email_value', $prev_val, (object) $meta, $atts['entry'] );
|
102 |
+
}
|
103 |
+
}
|
104 |
+
|
105 |
+
// Don't include blank values
|
106 |
+
if ( ! $atts['include_blank'] && FrmAppHelper::is_empty_value( $val ) ) {
|
107 |
+
return;
|
108 |
+
}
|
109 |
+
|
110 |
+
self::textarea_display_value( $f->type, $atts['plain_text'], $val );
|
111 |
+
|
112 |
+
if ( is_array( $val ) && $atts['format'] == 'text' ) {
|
113 |
+
$val = implode( ', ', $val );
|
114 |
+
}
|
115 |
+
|
116 |
+
if ( $atts['format'] != 'text' ) {
|
117 |
+
$values[ $f->field_key ] = $val;
|
118 |
+
} else {
|
119 |
+
$values[ $f->id ] = array( 'label' => $f->name, 'val' => $val );
|
120 |
+
}
|
121 |
+
}
|
122 |
+
|
123 |
+
/**
|
124 |
+
* Flatten multi-dimensional array for multi-file upload fields
|
125 |
+
* @since 2.0.9
|
126 |
+
*/
|
127 |
+
public static function flatten_multi_file_upload( $field, &$val ) {
|
128 |
+
if ( $field->type == 'file' && FrmField::is_option_true( $field, 'multiple' ) ) {
|
129 |
+
$val = FrmAppHelper::array_flatten( $val );
|
130 |
+
}
|
131 |
+
}
|
132 |
+
|
133 |
+
/**
|
134 |
+
* Replace returns with HTML line breaks for display
|
135 |
+
* @since 2.0.9
|
136 |
+
*/
|
137 |
+
public static function textarea_display_value( $type, $plain_text, &$value ) {
|
138 |
+
if ( $type == 'textarea' && ! $plain_text ) {
|
139 |
+
$value = str_replace( array( "\r\n", "\r", "\n" ), ' <br/>', $value );
|
140 |
+
}
|
141 |
+
}
|
142 |
+
|
143 |
+
public static function fill_entry_user_info( $atts, array &$values ) {
|
144 |
+
if ( ! $atts['user_info'] ) {
|
145 |
+
return;
|
146 |
+
}
|
147 |
+
|
148 |
+
$data = self::get_entry_description_data( $atts );
|
149 |
+
|
150 |
+
if ( $atts['default_email'] ) {
|
151 |
+
$atts['entry']->ip = '[ip]';
|
152 |
+
}
|
153 |
+
|
154 |
+
if ( $atts['format'] != 'text' ) {
|
155 |
+
$values['ip'] = $atts['entry']->ip;
|
156 |
+
$values['browser'] = self::get_browser( $data['browser'] );
|
157 |
+
$values['referrer'] = $data['referrer'];
|
158 |
+
} else {
|
159 |
+
$values['ip'] = array( 'label' => __( 'IP Address', 'formidable' ), 'val' => $atts['entry']->ip );
|
160 |
+
$values['browser'] = array(
|
161 |
+
'label' => __( 'User-Agent (Browser/OS)', 'formidable' ),
|
162 |
+
'val' => self::get_browser( $data['browser'] ),
|
163 |
+
);
|
164 |
+
$values['referrer'] = array( 'label' => __( 'Referrer', 'formidable' ), 'val' => $data['referrer'] );
|
165 |
+
}
|
166 |
+
}
|
167 |
+
|
168 |
+
/**
|
169 |
+
* @param array $atts - include (object) entry, (boolean) default_email
|
170 |
+
* @since 2.0.9
|
171 |
+
*/
|
172 |
+
public static function get_entry_description_data( $atts ) {
|
173 |
+
$default_data = array(
|
174 |
+
'browser' => '',
|
175 |
+
'referrer' => '',
|
176 |
+
);
|
177 |
+
$data = $default_data;
|
178 |
+
|
179 |
+
if ( isset( $atts['entry']->description ) ) {
|
180 |
+
$data = maybe_unserialize( $atts['entry']->description );
|
181 |
+
} else if ( $atts['default_email'] ) {
|
182 |
+
$data = array(
|
183 |
+
'browser' => '[browser]',
|
184 |
+
'referrer' => '[referrer]',
|
185 |
+
);
|
186 |
+
}
|
187 |
+
|
188 |
+
return array_merge( $default_data, $data );
|
189 |
+
}
|
190 |
+
|
191 |
+
public static function get_browser( $u_agent ) {
|
192 |
+
$bname = __( 'Unknown', 'formidable' );
|
193 |
+
$platform = __( 'Unknown', 'formidable' );
|
194 |
+
$ub = '';
|
195 |
+
|
196 |
+
// Get the operating system
|
197 |
+
if ( preg_match( '/windows|win32/i', $u_agent ) ) {
|
198 |
+
$platform = 'Windows';
|
199 |
+
} else if ( preg_match( '/android/i', $u_agent ) ) {
|
200 |
+
$platform = 'Android';
|
201 |
+
} else if ( preg_match( '/linux/i', $u_agent ) ) {
|
202 |
+
$platform = 'Linux';
|
203 |
+
} else if ( preg_match( '/macintosh|mac os x/i', $u_agent ) ) {
|
204 |
+
$platform = 'OS X';
|
205 |
+
}
|
206 |
+
|
207 |
+
$agent_options = array(
|
208 |
+
'Chrome' => 'Google Chrome',
|
209 |
+
'Safari' => 'Apple Safari',
|
210 |
+
'Opera' => 'Opera',
|
211 |
+
'Netscape' => 'Netscape',
|
212 |
+
'Firefox' => 'Mozilla Firefox',
|
213 |
+
);
|
214 |
+
|
215 |
+
// Next get the name of the useragent yes seperately and for good reason
|
216 |
+
if ( strpos( $u_agent, 'MSIE' ) !== false && strpos( $u_agent, 'Opera' ) === false ) {
|
217 |
+
$bname = 'Internet Explorer';
|
218 |
+
$ub = 'MSIE';
|
219 |
+
} else {
|
220 |
+
foreach ( $agent_options as $agent_key => $agent_name ) {
|
221 |
+
if ( strpos( $u_agent, $agent_key ) !== false ) {
|
222 |
+
$bname = $agent_name;
|
223 |
+
$ub = $agent_key;
|
224 |
+
break;
|
225 |
+
}
|
226 |
+
}
|
227 |
+
}
|
228 |
+
|
229 |
+
// finally get the correct version number
|
230 |
+
$known = array( 'Version', $ub, 'other' );
|
231 |
+
$pattern = '#(?<browser>' . join( '|', $known ) . ')[/ ]+(?<version>[0-9.|a-zA-Z.]*)#';
|
232 |
+
preg_match_all( $pattern, $u_agent, $matches ); // get the matching numbers
|
233 |
+
|
234 |
+
// see how many we have
|
235 |
+
$i = count($matches['browser']);
|
236 |
+
if ( $i != 1 ) {
|
237 |
+
//we will have two since we are not using 'other' argument yet
|
238 |
+
//see if version is before or after the name
|
239 |
+
if ( strripos( $u_agent, 'Version' ) < strripos( $u_agent, $ub ) ) {
|
240 |
+
$version = $matches['version'][0];
|
241 |
+
} else {
|
242 |
+
$version = $matches['version'][1];
|
243 |
+
}
|
244 |
+
} else {
|
245 |
+
$version = $matches['version'][0];
|
246 |
+
}
|
247 |
+
|
248 |
+
// check if we have a number
|
249 |
+
if ( $version == '' ) {
|
250 |
+
$version = '?';
|
251 |
+
}
|
252 |
+
|
253 |
+
return $bname .' '. $version .' / '. $platform;
|
254 |
+
}
|
255 |
+
|
256 |
+
public static function convert_entry_to_content( $values, $atts, array &$content ) {
|
257 |
+
|
258 |
+
if ( $atts['plain_text'] ) {
|
259 |
+
$bg_color_alt = $row_style = '';
|
260 |
+
} else {
|
261 |
+
$default_settings = apply_filters( 'frm_show_entry_styles', array(
|
262 |
+
'border_color' => 'dddddd',
|
263 |
+
'bg_color' => 'f7f7f7',
|
264 |
+
'text_color' => '444444',
|
265 |
+
'font_size' => '12px',
|
266 |
+
'border_width' => '1px',
|
267 |
+
'alt_bg_color' => 'ffffff',
|
268 |
+
) );
|
269 |
+
|
270 |
+
// merge defaults, global settings, and shortcode options
|
271 |
+
foreach ( $default_settings as $key => $setting ) {
|
272 |
+
if ( $atts[ $key ] != '' ) {
|
273 |
+
continue;
|
274 |
+
}
|
275 |
+
|
276 |
+
$atts[ $key ] = $setting;
|
277 |
+
unset( $key, $setting );
|
278 |
+
}
|
279 |
+
|
280 |
+
unset($default_settings);
|
281 |
+
|
282 |
+
$content[] = '<table cellspacing="0" style="font-size:'. $atts['font_size'] .';line-height:135%; border-bottom:'. $atts['border_width'] . ' solid #' . $atts['border_color'] . ';"><tbody>' . "\r\n";
|
283 |
+
$atts['bg_color'] = ' style="background-color:#'. $atts['bg_color'] .';"';
|
284 |
+
$bg_color_alt = ' style="background-color:#'. $atts['alt_bg_color'] .';"';
|
285 |
+
$row_style = 'style="text-align:' . ( $atts['direction'] == 'rtl' ? 'right' : 'left' ) .';color:#'. $atts['text_color'] . ';padding:7px 9px;border-top:' . $atts['border_width'] .' solid #' . $atts['border_color'] . '"';
|
286 |
+
}
|
287 |
+
|
288 |
+
$odd = true;
|
289 |
+
foreach ( $values as $id => $value ) {
|
290 |
+
if ( $atts['plain_text'] ) {
|
291 |
+
if ( 'rtl' == $atts['direction'] ) {
|
292 |
+
$content[] = $value['val'] . ' :'. $value['label'] ."\r\n";
|
293 |
+
} else {
|
294 |
+
$content[] = $value['label'] . ': '. $value['val'] ."\r\n";
|
295 |
+
}
|
296 |
+
continue;
|
297 |
+
}
|
298 |
+
|
299 |
+
if ( $atts['default_email'] && is_numeric($id) ) {
|
300 |
+
$content[] = '[if ' . $id . ']<tr style="[frm-alt-color]">';
|
301 |
+
} else {
|
302 |
+
$content[] = '<tr' . ( $odd ? $atts['bg_color'] : $bg_color_alt ) . '>';
|
303 |
+
}
|
304 |
+
|
305 |
+
$value['val'] = str_replace( "\r\n", '<br/>', $value['val'] );
|
306 |
+
if ( 'rtl' == $atts['direction'] ) {
|
307 |
+
$content[] = '<td ' . $row_style . '>' . $value['val'] . '</td><th ' . $row_style . '>' . $value['label'] . '</th>';
|
308 |
+
} else {
|
309 |
+
$content[] = '<th ' . $row_style . '>' . $value['label'] . '</th><td '. $row_style . '>' . $value['val'] . '</td>';
|
310 |
+
}
|
311 |
+
$content[] = '</tr>' . "\r\n";
|
312 |
+
|
313 |
+
if ( $atts['default_email'] && is_numeric( $id ) ) {
|
314 |
+
$content[] = '[/if ' . $id . ']';
|
315 |
+
}
|
316 |
+
$odd = $odd ? false : true;
|
317 |
+
}
|
318 |
+
|
319 |
+
if ( ! $atts['plain_text'] ) {
|
320 |
+
$content[] = '</tbody></table>';
|
321 |
+
}
|
322 |
+
}
|
323 |
+
|
324 |
+
}
|
classes/models/FrmEntryMeta.php
CHANGED
@@ -11,13 +11,13 @@ class FrmEntryMeta {
|
|
11 |
public static function add_entry_meta($entry_id, $field_id, $meta_key = null, $meta_value) {
|
12 |
global $wpdb;
|
13 |
|
14 |
-
if ( (
|
15 |
// don't save blank fields
|
16 |
return;
|
17 |
}
|
18 |
|
19 |
$new_values = array(
|
20 |
-
|
21 |
'item_id' => $entry_id,
|
22 |
'field_id' => $field_id,
|
23 |
'created_at' => current_time('mysql', 1),
|
@@ -51,7 +51,7 @@ class FrmEntryMeta {
|
|
51 |
$values['meta_value'] = $meta_value;
|
52 |
$values = apply_filters('frm_update_entry_meta', $values);
|
53 |
if ( is_array($values['meta_value']) ) {
|
54 |
-
$values['meta_value'] = array_filter($values['meta_value']);
|
55 |
}
|
56 |
$meta_value = maybe_serialize($values['meta_value']);
|
57 |
|
11 |
public static function add_entry_meta($entry_id, $field_id, $meta_key = null, $meta_value) {
|
12 |
global $wpdb;
|
13 |
|
14 |
+
if ( FrmAppHelper::is_empty_value( $meta_value ) ) {
|
15 |
// don't save blank fields
|
16 |
return;
|
17 |
}
|
18 |
|
19 |
$new_values = array(
|
20 |
+
'meta_value' => is_array( $meta_value ) ? serialize( array_filter( $meta_value, 'FrmAppHelper::is_not_empty_value' ) ) : trim( $meta_value ),
|
21 |
'item_id' => $entry_id,
|
22 |
'field_id' => $field_id,
|
23 |
'created_at' => current_time('mysql', 1),
|
51 |
$values['meta_value'] = $meta_value;
|
52 |
$values = apply_filters('frm_update_entry_meta', $values);
|
53 |
if ( is_array($values['meta_value']) ) {
|
54 |
+
$values['meta_value'] = array_filter( $values['meta_value'], 'FrmAppHelper::is_not_empty_value' );
|
55 |
}
|
56 |
$meta_value = maybe_serialize($values['meta_value']);
|
57 |
|
classes/models/FrmEntryValidate.php
ADDED
@@ -0,0 +1,279 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class FrmEntryValidate {
|
4 |
+
public static function validate( $values, $exclude = false ) {
|
5 |
+
global $wpdb;
|
6 |
+
|
7 |
+
FrmEntry::sanitize_entry_post( $values );
|
8 |
+
$errors = array();
|
9 |
+
|
10 |
+
if ( ! isset($values['form_id']) || ! isset($values['item_meta']) ) {
|
11 |
+
$errors['form'] = __( 'There was a problem with your submission. Please try again.', 'formidable' );
|
12 |
+
return $errors;
|
13 |
+
}
|
14 |
+
|
15 |
+
if ( FrmAppHelper::is_admin() && is_user_logged_in() && ( ! isset( $values[ 'frm_submit_entry_' . $values['form_id'] ] ) || ! wp_verify_nonce( $values[ 'frm_submit_entry_' . $values['form_id'] ], 'frm_submit_entry_nonce' ) ) ) {
|
16 |
+
$errors['form'] = __( 'You do not have permission to do that', 'formidable' );
|
17 |
+
}
|
18 |
+
|
19 |
+
if ( ! isset($values['item_key']) || $values['item_key'] == '' ) {
|
20 |
+
$_POST['item_key'] = $values['item_key'] = FrmAppHelper::get_unique_key('', $wpdb->prefix .'frm_items', 'item_key');
|
21 |
+
}
|
22 |
+
|
23 |
+
$where = apply_filters('frm_posted_field_ids', array( 'fi.form_id' => $values['form_id'] ) );
|
24 |
+
// Don't get subfields
|
25 |
+
$where['fr.parent_form_id'] = array( null, 0 );
|
26 |
+
// Don't get excluded fields (like file upload fields in the ajax validation)
|
27 |
+
if ( ! empty( $exclude ) ) {
|
28 |
+
$where['fi.type not'] = $exclude;
|
29 |
+
}
|
30 |
+
|
31 |
+
$posted_fields = FrmField::getAll($where, 'field_order');
|
32 |
+
|
33 |
+
// Pass exclude value to validate_field function so it can be used for repeating sections
|
34 |
+
$args = array( 'exclude' => $exclude );
|
35 |
+
|
36 |
+
foreach ( $posted_fields as $posted_field ) {
|
37 |
+
self::validate_field($posted_field, $errors, $values, $args);
|
38 |
+
unset($posted_field);
|
39 |
+
}
|
40 |
+
|
41 |
+
// check for spam
|
42 |
+
self::spam_check( $exclude, $values, $errors );
|
43 |
+
|
44 |
+
$errors = apply_filters( 'frm_validate_entry', $errors, $values, compact('exclude') );
|
45 |
+
|
46 |
+
return $errors;
|
47 |
+
}
|
48 |
+
|
49 |
+
public static function validate_field( $posted_field, &$errors, $values, $args = array() ) {
|
50 |
+
$defaults = array(
|
51 |
+
'id' => $posted_field->id,
|
52 |
+
'parent_field_id' => '', // the id of the repeat or embed form
|
53 |
+
'key_pointer' => '', // the pointer in the posted array
|
54 |
+
'exclude' => array(), // exclude these field types from validation
|
55 |
+
);
|
56 |
+
$args = wp_parse_args( $args, $defaults );
|
57 |
+
|
58 |
+
if ( empty($args['parent_field_id']) ) {
|
59 |
+
$value = isset( $values['item_meta'][ $args['id'] ] ) ? $values['item_meta'][ $args['id'] ] : '';
|
60 |
+
} else {
|
61 |
+
// value is from a nested form
|
62 |
+
$value = $values;
|
63 |
+
}
|
64 |
+
|
65 |
+
// Check for values in "Other" fields
|
66 |
+
FrmEntriesHelper::maybe_set_other_validation( $posted_field, $value, $args );
|
67 |
+
|
68 |
+
if ( isset($posted_field->field_options['default_blank']) && $posted_field->field_options['default_blank'] && $value == $posted_field->default_value ) {
|
69 |
+
$value = '';
|
70 |
+
}
|
71 |
+
|
72 |
+
// Check for an array with only one value
|
73 |
+
// Don't reset values in "Other" fields because array keys need to be preserved
|
74 |
+
if ( is_array($value) && count( $value ) == 1 && $args['other'] !== true ) {
|
75 |
+
$value = reset($value);
|
76 |
+
}
|
77 |
+
|
78 |
+
if ( $posted_field->required == '1' && ! is_array( $value ) && trim( $value ) == '' ) {
|
79 |
+
$frm_settings = FrmAppHelper::get_settings();
|
80 |
+
$errors[ 'field' . $args['id'] ] = ( ! isset( $posted_field->field_options['blank'] ) || $posted_field->field_options['blank'] == '' ) ? $frm_settings->blank_msg : $posted_field->field_options['blank'];
|
81 |
+
} else if ( $posted_field->type == 'text' && ! isset( $_POST['name'] ) ) {
|
82 |
+
$_POST['name'] = $value;
|
83 |
+
}
|
84 |
+
|
85 |
+
self::validate_url_field($errors, $posted_field, $value, $args);
|
86 |
+
self::validate_email_field($errors, $posted_field, $value, $args);
|
87 |
+
|
88 |
+
FrmEntriesHelper::set_posted_value($posted_field, $value, $args);
|
89 |
+
|
90 |
+
self::validate_recaptcha($errors, $posted_field, $args);
|
91 |
+
|
92 |
+
$errors = apply_filters('frm_validate_field_entry', $errors, $posted_field, $value, $args);
|
93 |
+
}
|
94 |
+
|
95 |
+
public static function validate_url_field(&$errors, $field, &$value, $args) {
|
96 |
+
if ( $value == '' || ! in_array( $field->type, array( 'website', 'url', 'image' ) ) ) {
|
97 |
+
return;
|
98 |
+
}
|
99 |
+
|
100 |
+
if ( trim($value) == 'http://' ) {
|
101 |
+
$value = '';
|
102 |
+
} else {
|
103 |
+
$value = esc_url_raw( $value );
|
104 |
+
$value = preg_match('/^(https?|ftps?|mailto|news|feed|telnet):/is', $value) ? $value : 'http://'. $value;
|
105 |
+
}
|
106 |
+
|
107 |
+
//validate the url format
|
108 |
+
if ( ! preg_match('/^http(s)?:\/\/([\da-z\.-]+)\.([\da-z\.-]+)/i', $value) ) {
|
109 |
+
$errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $field, 'invalid' );
|
110 |
+
}
|
111 |
+
}
|
112 |
+
|
113 |
+
public static function validate_email_field(&$errors, $field, $value, $args) {
|
114 |
+
if ( $value == '' || $field->type != 'email' ) {
|
115 |
+
return;
|
116 |
+
}
|
117 |
+
|
118 |
+
//validate the email format
|
119 |
+
if ( ! is_email($value) ) {
|
120 |
+
$errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $field, 'invalid' );
|
121 |
+
}
|
122 |
+
}
|
123 |
+
|
124 |
+
public static function validate_recaptcha(&$errors, $field, $args) {
|
125 |
+
if ( $field->type != 'captcha' || FrmAppHelper::is_admin() ) {
|
126 |
+
return;
|
127 |
+
}
|
128 |
+
|
129 |
+
$frm_settings = FrmAppHelper::get_settings();
|
130 |
+
if ( empty( $frm_settings->pubkey ) ) {
|
131 |
+
// don't require the captcha if it shouldn't be shown
|
132 |
+
return;
|
133 |
+
}
|
134 |
+
|
135 |
+
if ( ! isset($_POST['g-recaptcha-response']) ) {
|
136 |
+
// If captcha is missing, check if it was already verified
|
137 |
+
if ( ! isset( $_POST['recaptcha_checked'] ) || ! wp_verify_nonce( $_POST['recaptcha_checked'], 'frm_ajax' ) ) {
|
138 |
+
// There was no captcha submitted
|
139 |
+
$errors[ 'field' . $args['id'] ] = __( 'The captcha is missing from this form', 'formidable' );
|
140 |
+
}
|
141 |
+
return;
|
142 |
+
}
|
143 |
+
|
144 |
+
$arg_array = array(
|
145 |
+
'body' => array(
|
146 |
+
'secret' => $frm_settings->privkey,
|
147 |
+
'response' => $_POST['g-recaptcha-response'],
|
148 |
+
'remoteip' => FrmAppHelper::get_ip_address(),
|
149 |
+
),
|
150 |
+
);
|
151 |
+
$resp = wp_remote_post( 'https://www.google.com/recaptcha/api/siteverify', $arg_array );
|
152 |
+
$response = json_decode(wp_remote_retrieve_body( $resp ), true);
|
153 |
+
|
154 |
+
if ( isset( $response['success'] ) && ! $response['success'] ) {
|
155 |
+
// What happens when the CAPTCHA was entered incorrectly
|
156 |
+
$errors[ 'field' . $args['id'] ] = ( ! isset( $field->field_options['invalid'] ) || $field->field_options['invalid'] == '' ) ? $frm_settings->re_msg : $field->field_options['invalid'];
|
157 |
+
}
|
158 |
+
}
|
159 |
+
|
160 |
+
/**
|
161 |
+
* check for spam
|
162 |
+
* @param boolean $exclude
|
163 |
+
* @param array $values
|
164 |
+
* @param array $errors by reference
|
165 |
+
*/
|
166 |
+
public static function spam_check( $exclude, $values, &$errors ) {
|
167 |
+
if ( ! empty( $exclude ) || ! isset( $values['item_meta'] ) || empty( $values['item_meta'] ) || ! empty( $errors ) ) {
|
168 |
+
// only check spam if there are no other errors
|
169 |
+
return;
|
170 |
+
}
|
171 |
+
|
172 |
+
if ( self::is_akismet_spam( $values ) ) {
|
173 |
+
if ( self::is_akismet_enabled_for_user( $values['form_id'] ) ) {
|
174 |
+
$errors['spam'] = __( 'Your entry appears to be spam!', 'formidable' );
|
175 |
+
}
|
176 |
+
}
|
177 |
+
|
178 |
+
if ( self::blacklist_check( $values ) ) {
|
179 |
+
$errors['spam'] = __( 'Your entry appears to be spam!', 'formidable' );
|
180 |
+
}
|
181 |
+
}
|
182 |
+
|
183 |
+
private static function is_akismet_spam( $values ) {
|
184 |
+
global $wpcom_api_key;
|
185 |
+
return ( ( function_exists( 'akismet_http_post' ) || is_callable('Akismet::http_post') ) && ( get_option('wordpress_api_key') || $wpcom_api_key ) && self::akismet( $values ) );
|
186 |
+
}
|
187 |
+
|
188 |
+
private static function is_akismet_enabled_for_user( $form_id ) {
|
189 |
+
$form = FrmForm::getOne( $form_id );
|
190 |
+
return ( isset( $form->options['akismet'] ) && ! empty( $form->options['akismet'] ) && ( $form->options['akismet'] != 'logged' || ! is_user_logged_in() ) );
|
191 |
+
}
|
192 |
+
|
193 |
+
public static function blacklist_check( $values ) {
|
194 |
+
if ( ! apply_filters('frm_check_blacklist', true, $values) ) {
|
195 |
+
return false;
|
196 |
+
}
|
197 |
+
|
198 |
+
$mod_keys = trim( get_option( 'blacklist_keys' ) );
|
199 |
+
|
200 |
+
if ( empty( $mod_keys ) ) {
|
201 |
+
return false;
|
202 |
+
}
|
203 |
+
|
204 |
+
$content = FrmEntriesHelper::entry_array_to_string($values);
|
205 |
+
|
206 |
+
if ( empty($content) ) {
|
207 |
+
return false;
|
208 |
+
}
|
209 |
+
|
210 |
+
$words = explode( "\n", $mod_keys );
|
211 |
+
|
212 |
+
foreach ( (array) $words as $word ) {
|
213 |
+
$word = trim( $word );
|
214 |
+
|
215 |
+
if ( empty($word) ) {
|
216 |
+
continue;
|
217 |
+
}
|
218 |
+
|
219 |
+
if ( preg_match('#' . preg_quote( $word, '#' ) . '#', $content) ) {
|
220 |
+
return true;
|
221 |
+
}
|
222 |
+
}
|
223 |
+
|
224 |
+
return false;
|
225 |
+
}
|
226 |
+
|
227 |
+
/**
|
228 |
+
* Check entries for spam
|
229 |
+
*
|
230 |
+
* @return boolean true if is spam
|
231 |
+
*/
|
232 |
+
public static function akismet( $values ) {
|
233 |
+
$content = FrmEntriesHelper::entry_array_to_string( $values );
|
234 |
+
|
235 |
+
if ( empty( $content ) ) {
|
236 |
+
return false;
|
237 |
+
}
|
238 |
+
|
239 |
+
$datas = array();
|
240 |
+
self::parse_akismet_array( $datas, $content );
|
241 |
+
|
242 |
+
$query_string = '';
|
243 |
+
foreach ( $datas as $key => $data ) {
|
244 |
+
$query_string .= $key . '=' . urlencode( stripslashes( $data ) ) . '&';
|
245 |
+
unset( $key, $data );
|
246 |
+
}
|
247 |
+
|
248 |
+
$response = Akismet::http_post($query_string, 'comment-check');
|
249 |
+
|
250 |
+
return ( is_array( $response ) && $response[1] == 'true' );
|
251 |
+
}
|
252 |
+
|
253 |
+
/**
|
254 |
+
* @since 2.0
|
255 |
+
* @param string $content
|
256 |
+
*/
|
257 |
+
private static function parse_akismet_array( &$datas, $content ) {
|
258 |
+
$datas['blog'] = FrmAppHelper::site_url();
|
259 |
+
$datas['user_ip'] = preg_replace( '/[^0-9., ]/', '', FrmAppHelper::get_ip_address() );
|
260 |
+
$datas['user_agent'] = FrmAppHelper::get_server_value( 'HTTP_USER_AGENT' );
|
261 |
+
$datas['referrer'] = isset( $_SERVER['HTTP_REFERER'] ) ? FrmAppHelper::get_server_value( 'HTTP_REFERER' ) : false;
|
262 |
+
$datas['comment_type'] = 'formidable';
|
263 |
+
$datas['comment_content'] = $content;
|
264 |
+
|
265 |
+
if ( $permalink = get_permalink() ) {
|
266 |
+
$datas['permalink'] = $permalink;
|
267 |
+
}
|
268 |
+
|
269 |
+
foreach ( $_SERVER as $key => $value ) {
|
270 |
+
if ( ! in_array( $key, array( 'HTTP_COOKIE', 'HTTP_COOKIE2', 'PHP_AUTH_PW' ) ) && is_string( $value ) ) {
|
271 |
+
$datas[ $key ] = wp_strip_all_tags( $value );
|
272 |
+
} else {
|
273 |
+
$datas[ $key ] = '';
|
274 |
+
}
|
275 |
+
|
276 |
+
unset($key, $value);
|
277 |
+
}
|
278 |
+
}
|
279 |
+
}
|
classes/models/FrmField.php
CHANGED
@@ -7,6 +7,51 @@ class FrmField {
|
|
7 |
static $use_cache = true;
|
8 |
static $transient_size = 200;
|
9 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
public static function create( $values, $return = true ) {
|
11 |
global $wpdb, $frm_duplicate_ids;
|
12 |
|
@@ -75,7 +120,7 @@ class FrmField {
|
|
75 |
FrmFieldsHelper::fill_field( $values, $field, $form_id, $new_key );
|
76 |
|
77 |
// If this is a repeating section, create new form
|
78 |
-
if ( $field->type == 'divider' &&
|
79 |
// create the repeatable form
|
80 |
$repeat_form_values = FrmFormsHelper::setup_new_vars( array( 'parent_form_id' => $form_id ) );
|
81 |
$new_repeat_form_id = FrmForm::create( $repeat_form_values );
|
@@ -195,6 +240,15 @@ class FrmField {
|
|
195 |
}
|
196 |
}
|
197 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
198 |
public static function getOne( $id ) {
|
199 |
if ( empty( $id ) ) {
|
200 |
return;
|
@@ -320,6 +374,7 @@ class FrmField {
|
|
320 |
}
|
321 |
|
322 |
$form_fields = $results;
|
|
|
323 |
foreach ( $form_fields as $k => $field ) {
|
324 |
if ( 'form' != $field->type || ! isset($field->field_options['form_select']) ) {
|
325 |
continue;
|
@@ -332,7 +387,9 @@ class FrmField {
|
|
332 |
}
|
333 |
|
334 |
if ( ! empty($sub_fields) ) {
|
335 |
-
|
|
|
|
|
336 |
}
|
337 |
unset($field, $sub_fields);
|
338 |
}
|
@@ -505,4 +562,117 @@ class FrmField {
|
|
505 |
return $results;
|
506 |
}
|
507 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
508 |
}
|
7 |
static $use_cache = true;
|
8 |
static $transient_size = 200;
|
9 |
|
10 |
+
public static function field_selection() {
|
11 |
+
$fields = apply_filters('frm_available_fields', array(
|
12 |
+
'text' => __( 'Single Line Text', 'formidable' ),
|
13 |
+
'textarea' => __( 'Paragraph Text', 'formidable' ),
|
14 |
+
'checkbox' => __( 'Checkboxes', 'formidable' ),
|
15 |
+
'radio' => __( 'Radio Buttons', 'formidable' ),
|
16 |
+
'select' => __( 'Dropdown', 'formidable' ),
|
17 |
+
'email' => __( 'Email Address', 'formidable' ),
|
18 |
+
'url' => __( 'Website/URL', 'formidable' ),
|
19 |
+
'captcha' => __( 'reCAPTCHA', 'formidable' ),
|
20 |
+
));
|
21 |
+
|
22 |
+
return $fields;
|
23 |
+
}
|
24 |
+
|
25 |
+
public static function pro_field_selection() {
|
26 |
+
return apply_filters('frm_pro_available_fields', array(
|
27 |
+
'end_divider' => array(
|
28 |
+
'name' => __( 'End Section', 'formidable' ),
|
29 |
+
'switch_from' => 'divider',
|
30 |
+
),
|
31 |
+
'divider' => __( 'Section', 'formidable' ),
|
32 |
+
'break' => __( 'Page Break', 'formidable' ),
|
33 |
+
'file' => __( 'File Upload', 'formidable' ),
|
34 |
+
'rte' => __( 'Rich Text', 'formidable' ),
|
35 |
+
'number' => __( 'Number', 'formidable' ),
|
36 |
+
'phone' => __( 'Phone Number', 'formidable' ),
|
37 |
+
'date' => __( 'Date', 'formidable' ),
|
38 |
+
'time' => __( 'Time', 'formidable' ),
|
39 |
+
'image' => __( 'Image URL', 'formidable' ),
|
40 |
+
'scale' => __( 'Scale', 'formidable' ),
|
41 |
+
'data' => __( 'Dynamic Field', 'formidable' ),
|
42 |
+
'form' => __( 'Embed Form', 'formidable' ),
|
43 |
+
'hidden' => __( 'Hidden Field', 'formidable' ),
|
44 |
+
'user_id' => __( 'User ID (hidden)', 'formidable' ),
|
45 |
+
'password' => __( 'Password', 'formidable' ),
|
46 |
+
'html' => __( 'HTML', 'formidable' ),
|
47 |
+
'tag' => __( 'Tags', 'formidable' ),
|
48 |
+
//'address' => 'Address' //Address line 1, Address line 2, City, State/Providence, Postal Code, Select Country
|
49 |
+
//'city_selector' => 'US State/County/City selector',
|
50 |
+
//'full_name' => 'First and Last Name',
|
51 |
+
//'quiz' => 'Question and Answer' // for captcha alternative
|
52 |
+
));
|
53 |
+
}
|
54 |
+
|
55 |
public static function create( $values, $return = true ) {
|
56 |
global $wpdb, $frm_duplicate_ids;
|
57 |
|
120 |
FrmFieldsHelper::fill_field( $values, $field, $form_id, $new_key );
|
121 |
|
122 |
// If this is a repeating section, create new form
|
123 |
+
if ( $field->type == 'divider' && self::is_option_true( $field, 'repeat' ) ) {
|
124 |
// create the repeatable form
|
125 |
$repeat_form_values = FrmFormsHelper::setup_new_vars( array( 'parent_form_id' => $form_id ) );
|
126 |
$new_repeat_form_id = FrmForm::create( $repeat_form_values );
|
240 |
}
|
241 |
}
|
242 |
|
243 |
+
/**
|
244 |
+
* If $field is numeric, get the field object
|
245 |
+
*/
|
246 |
+
public static function maybe_get_field( &$field ) {
|
247 |
+
if ( ! is_object( $field ) ) {
|
248 |
+
$field = self::getOne( $field );
|
249 |
+
}
|
250 |
+
}
|
251 |
+
|
252 |
public static function getOne( $id ) {
|
253 |
if ( empty( $id ) ) {
|
254 |
return;
|
374 |
}
|
375 |
|
376 |
$form_fields = $results;
|
377 |
+
$index_offset = 1;
|
378 |
foreach ( $form_fields as $k => $field ) {
|
379 |
if ( 'form' != $field->type || ! isset($field->field_options['form_select']) ) {
|
380 |
continue;
|
387 |
}
|
388 |
|
389 |
if ( ! empty($sub_fields) ) {
|
390 |
+
$index = $k + $index_offset;
|
391 |
+
$index_offset += count( $sub_fields );
|
392 |
+
array_splice($results, $index, 0, $sub_fields);
|
393 |
}
|
394 |
unset($field, $sub_fields);
|
395 |
}
|
562 |
return $results;
|
563 |
}
|
564 |
|
565 |
+
public static function is_no_save_field( $type ) {
|
566 |
+
return in_array( $type, self::no_save_fields() );
|
567 |
+
}
|
568 |
+
|
569 |
+
public static function no_save_fields() {
|
570 |
+
return array( 'divider', 'end_divider', 'captcha', 'break', 'html', 'form' );
|
571 |
+
}
|
572 |
+
|
573 |
+
/**
|
574 |
+
* Check if this field can hold an array of values
|
575 |
+
*
|
576 |
+
* @since 2.0.9
|
577 |
+
*
|
578 |
+
* @param array|object $field
|
579 |
+
* @return boolean
|
580 |
+
*/
|
581 |
+
public static function is_field_with_multiple_values( $field ) {
|
582 |
+
if ( ! $field ) {
|
583 |
+
return false;
|
584 |
+
}
|
585 |
+
|
586 |
+
if ( is_array( $field ) ) {
|
587 |
+
return $field['type'] == 'checkbox' || ( $field['type'] == 'data' && isset($field['data_type']) && $field['data_type'] == 'checkbox' ) || self::is_multiple_select( $field );
|
588 |
+
} else {
|
589 |
+
return $field->type == 'checkbox' || ( $field->type == 'data' && isset( $field->field_options['data_type'] ) && $field->field_options['data_type'] == 'checkbox' ) || self::is_multiple_select($field);
|
590 |
+
}
|
591 |
+
}
|
592 |
+
|
593 |
+
/**
|
594 |
+
* Check if this is a multiselect dropdown field
|
595 |
+
*
|
596 |
+
* @since 2.0.9
|
597 |
+
* @return boolean
|
598 |
+
*/
|
599 |
+
public static function is_multiple_select( $field ) {
|
600 |
+
if ( is_array( $field ) ) {
|
601 |
+
return self::is_option_true( $field, 'multiple' ) && ( ( $field['type'] == 'select' || ( $field['type'] == 'data' && isset( $field['data_type'] ) && $field['data_type'] == 'select') ) );
|
602 |
+
} else {
|
603 |
+
return self::is_option_true( $field, 'multiple' ) && ( ( $field->type == 'select' || ( $field->type == 'data' && isset($field->field_options['data_type'] ) && $field->field_options['data_type'] == 'select') ) );
|
604 |
+
}
|
605 |
+
}
|
606 |
+
|
607 |
+
/**
|
608 |
+
* Check if a field is read only. Read only can be set in the field options,
|
609 |
+
* but disabled with the shortcode options
|
610 |
+
*
|
611 |
+
* @since 2.0.9
|
612 |
+
*/
|
613 |
+
public static function is_read_only( $field ) {
|
614 |
+
global $frm_vars;
|
615 |
+
return ( self::is_option_true( $field, 'read_only' ) && ( ! isset( $frm_vars['readonly'] ) || $frm_vars['readonly'] != 'disabled' ) );
|
616 |
+
}
|
617 |
+
|
618 |
+
/**
|
619 |
+
* @since 2.0.9
|
620 |
+
*/
|
621 |
+
public static function is_required( $field ) {
|
622 |
+
return $field['required'] != '0';
|
623 |
+
}
|
624 |
+
|
625 |
+
/**
|
626 |
+
* @since 2.0.9
|
627 |
+
*/
|
628 |
+
public static function is_option_true( $field, $option ) {
|
629 |
+
if ( is_array( $field ) ) {
|
630 |
+
return self::is_option_true_in_array( $field, $option );
|
631 |
+
} else {
|
632 |
+
return self::is_option_true_in_object( $field, $option );
|
633 |
+
}
|
634 |
+
}
|
635 |
+
|
636 |
+
/**
|
637 |
+
* @since 2.0.9
|
638 |
+
*/
|
639 |
+
public static function is_option_empty( $field, $option ) {
|
640 |
+
if ( is_array( $field ) ) {
|
641 |
+
return self::is_option_empty_in_array( $field, $option );
|
642 |
+
} else {
|
643 |
+
return self::is_option_empty_in_object( $field, $option );
|
644 |
+
}
|
645 |
+
}
|
646 |
+
|
647 |
+
public static function is_option_true_in_array( $field, $option ) {
|
648 |
+
return isset( $field[ $option ] ) && $field[ $option ];
|
649 |
+
}
|
650 |
+
|
651 |
+
public static function is_option_true_in_object( $field, $option ) {
|
652 |
+
return isset( $field->field_options[ $option ] ) && $field->field_options[ $option ];
|
653 |
+
}
|
654 |
+
|
655 |
+
public static function is_option_empty_in_array( $field, $option ) {
|
656 |
+
return ! isset( $field[ $option ] ) || empty( $field[ $option ] );
|
657 |
+
}
|
658 |
+
|
659 |
+
public static function is_option_empty_in_object( $field, $option ) {
|
660 |
+
return ! isset( $field->field_options[ $option ] ) || empty( $field->field_options[ $option ] );
|
661 |
+
}
|
662 |
+
|
663 |
+
public static function is_option_value_in_object( $field, $option ) {
|
664 |
+
return isset( $field->field_options[ $option ] ) && $field->field_options[ $option ] != '';
|
665 |
+
}
|
666 |
+
|
667 |
+
/**
|
668 |
+
* @since 2.0.09
|
669 |
+
*/
|
670 |
+
public static function is_repeating_field( $field ) {
|
671 |
+
if ( is_array( $field ) ) {
|
672 |
+
$is_repeating_field = ( 'divider' == $field['type'] );
|
673 |
+
} else {
|
674 |
+
$is_repeating_field = ( 'divider' == $field->type );
|
675 |
+
}
|
676 |
+
return ( $is_repeating_field && self::is_option_true( $field, 'repeat' ) );
|
677 |
+
}
|
678 |
}
|
classes/models/FrmForm.php
CHANGED
@@ -123,7 +123,7 @@ class FrmForm {
|
|
123 |
public static function update( $id, $values, $create_link = false ) {
|
124 |
global $wpdb;
|
125 |
|
126 |
-
if ( $create_link || isset($values['options']) || isset($values['item_meta']) || isset($values['field_options']) ) {
|
127 |
$values['status'] = 'published';
|
128 |
}
|
129 |
|
@@ -372,6 +372,36 @@ class FrmForm {
|
|
372 |
return $query_results;
|
373 |
}
|
374 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
375 |
/**
|
376 |
* @return string form name
|
377 |
*/
|
@@ -416,6 +446,17 @@ class FrmForm {
|
|
416 |
return $key;
|
417 |
}
|
418 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
419 |
/**
|
420 |
* @return object form
|
421 |
*/
|
@@ -560,4 +601,131 @@ class FrmForm {
|
|
560 |
return apply_filters('frm_validate_form', $errors, $values);
|
561 |
}
|
562 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
563 |
}
|
123 |
public static function update( $id, $values, $create_link = false ) {
|
124 |
global $wpdb;
|
125 |
|
126 |
+
if ( ! isset( $values['status'] ) && ( $create_link || isset( $values['options'] ) || isset( $values['item_meta'] ) || isset( $values['field_options'] ) ) ) {
|
127 |
$values['status'] = 'published';
|
128 |
}
|
129 |
|
372 |
return $query_results;
|
373 |
}
|
374 |
|
375 |
+
/**
|
376 |
+
* Delete trashed forms based on how long they have been trashed
|
377 |
+
* @return int The number of forms deleted
|
378 |
+
*/
|
379 |
+
public static function scheduled_delete( $delete_timestamp = '' ) {
|
380 |
+
global $wpdb;
|
381 |
+
|
382 |
+
$trash_forms = FrmDb::get_results( $wpdb->prefix . 'frm_forms', array( 'status' => 'trash' ), 'id, options' );
|
383 |
+
|
384 |
+
if ( ! $trash_forms ) {
|
385 |
+
return;
|
386 |
+
}
|
387 |
+
|
388 |
+
if ( empty( $delete_timestamp ) ) {
|
389 |
+
$delete_timestamp = time() - ( DAY_IN_SECONDS * EMPTY_TRASH_DAYS );
|
390 |
+
}
|
391 |
+
|
392 |
+
$count = 0;
|
393 |
+
foreach ( $trash_forms as $form ) {
|
394 |
+
$form->options = maybe_unserialize( $form->options );
|
395 |
+
if ( ! isset( $form->options['trash_time'] ) || $form->options['trash_time'] < $delete_timestamp ) {
|
396 |
+
self::destroy( $form->id );
|
397 |
+
$count++;
|
398 |
+
}
|
399 |
+
|
400 |
+
unset( $form );
|
401 |
+
}
|
402 |
+
return $count;
|
403 |
+
}
|
404 |
+
|
405 |
/**
|
406 |
* @return string form name
|
407 |
*/
|
446 |
return $key;
|
447 |
}
|
448 |
|
449 |
+
/**
|
450 |
+
* If $form is numeric, get the form object
|
451 |
+
* @param object|int $form
|
452 |
+
* @since 2.0.9
|
453 |
+
*/
|
454 |
+
public static function maybe_get_form( &$form ) {
|
455 |
+
if ( ! is_object( $form ) && ! is_array( $form ) && ! empty( $form ) ) {
|
456 |
+
$form = self::getOne( $form );
|
457 |
+
}
|
458 |
+
}
|
459 |
+
|
460 |
/**
|
461 |
* @return object form
|
462 |
*/
|
601 |
return apply_filters('frm_validate_form', $errors, $values);
|
602 |
}
|
603 |
|
604 |
+
public static function get_params( $form = null ) {
|
605 |
+
global $frm_vars;
|
606 |
+
|
607 |
+
if ( ! $form ) {
|
608 |
+
$form = self::getAll( array(), 'name', 1 );
|
609 |
+
} else {
|
610 |
+
self::maybe_get_form( $form );
|
611 |
+
}
|
612 |
+
|
613 |
+
if ( isset( $frm_vars['form_params'] ) && is_array( $frm_vars['form_params'] ) && isset( $frm_vars['form_params'][ $form->id ] ) ) {
|
614 |
+
return $frm_vars['form_params'][ $form->id ];
|
615 |
+
}
|
616 |
+
|
617 |
+
$action_var = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action';
|
618 |
+
$action = apply_filters( 'frm_show_new_entry_page', FrmAppHelper::get_param( $action_var, 'new', 'get', 'sanitize_title' ), $form );
|
619 |
+
|
620 |
+
$default_values = array(
|
621 |
+
'id' => '', 'form_name' => '', 'paged' => 1, 'form' => $form->id, 'form_id' => $form->id,
|
622 |
+
'field_id' => '', 'search' => '', 'sort' => '', 'sdir' => '', 'action' => $action,
|
623 |
+
);
|
624 |
+
|
625 |
+
$values = array();
|
626 |
+
$values['posted_form_id'] = FrmAppHelper::get_param( 'form_id', '', 'get', 'absint' );
|
627 |
+
if ( ! $values['posted_form_id'] ) {
|
628 |
+
$values['posted_form_id'] = FrmAppHelper::get_param( 'form', '', 'get', 'absint' );
|
629 |
+
}
|
630 |
+
|
631 |
+
if ( $form->id == $values['posted_form_id'] ) {
|
632 |
+
//if there are two forms on the same page, make sure not to submit both
|
633 |
+
foreach ( $default_values as $var => $default ) {
|
634 |
+
if ( $var == 'action' ) {
|
635 |
+
$values[ $var ] = FrmAppHelper::get_param( $action_var, $default, 'get', 'sanitize_title' );
|
636 |
+
} else {
|
637 |
+
$values[ $var ] = FrmAppHelper::get_param( $var, $default );
|
638 |
+
}
|
639 |
+
unset( $var, $default );
|
640 |
+
}
|
641 |
+
} else {
|
642 |
+
foreach ( $default_values as $var => $default ) {
|
643 |
+
$values[ $var ] = $default;
|
644 |
+
unset( $var, $default );
|
645 |
+
}
|
646 |
+
}
|
647 |
+
|
648 |
+
if ( in_array( $values['action'], array( 'create', 'update' ) ) && ( ! $_POST || ( ! isset( $_POST['action'] ) && ! isset( $_POST['frm_action'] ) ) ) ) {
|
649 |
+
$values['action'] = 'new';
|
650 |
+
}
|
651 |
+
|
652 |
+
return $values;
|
653 |
+
}
|
654 |
+
|
655 |
+
public static function list_page_params() {
|
656 |
+
$values = array();
|
657 |
+
foreach ( array( 'template' => 0, 'id' => '', 'paged' => 1, 'form' => '', 'search' => '', 'sort' => '', 'sdir' => '' ) as $var => $default ) {
|
658 |
+
$values[ $var ] = FrmAppHelper::get_param( $var, $default );
|
659 |
+
}
|
660 |
+
|
661 |
+
return $values;
|
662 |
+
}
|
663 |
+
|
664 |
+
public static function get_admin_params( $form = null ) {
|
665 |
+
$form_id = $form;
|
666 |
+
if ( $form === null ) {
|
667 |
+
$form_id = FrmForm::get_current_form_id();
|
668 |
+
} else if ( $form && is_object( $form ) ) {
|
669 |
+
$form_id = $form->id;
|
670 |
+
}
|
671 |
+
|
672 |
+
$values = array();
|
673 |
+
foreach ( array(
|
674 |
+
'id' => '', 'form_name' => '', 'paged' => 1, 'form' => $form_id,
|
675 |
+
'field_id' => '', 'search' => '', 'sort' => '', 'sdir' => '', 'fid' => '',
|
676 |
+
'keep_post' => '',
|
677 |
+
) as $var => $default ) {
|
678 |
+
$values[ $var ] = FrmAppHelper::get_param( $var, $default );
|
679 |
+
}
|
680 |
+
|
681 |
+
return $values;
|
682 |
+
}
|
683 |
+
|
684 |
+
public static function get_current_form_id() {
|
685 |
+
$form = self::get_current_form();
|
686 |
+
$form_id = $form ? $form->id : 0;
|
687 |
+
|
688 |
+
return $form_id;
|
689 |
+
}
|
690 |
+
|
691 |
+
public static function get_current_form( $form_id = 0 ) {
|
692 |
+
global $frm_vars, $wpdb;
|
693 |
+
|
694 |
+
if ( isset( $frm_vars['current_form'] ) && $frm_vars['current_form'] && ( ! $form_id || $form_id == $frm_vars['current_form']->id ) ) {
|
695 |
+
return $frm_vars['current_form'];
|
696 |
+
}
|
697 |
+
|
698 |
+
$form_id = FrmAppHelper::get_param( 'form', $form_id, 'get', 'absint' );
|
699 |
+
return self::set_current_form( $form_id );
|
700 |
+
}
|
701 |
+
|
702 |
+
public static function set_current_form( $form_id ) {
|
703 |
+
global $frm_vars;
|
704 |
+
|
705 |
+
$query = array();
|
706 |
+
if ( $form_id ) {
|
707 |
+
$query['id'] = $form_id;
|
708 |
+
}
|
709 |
+
|
710 |
+
$frm_vars['current_form'] = self::get_published_forms( $query, 1 );
|
711 |
+
|
712 |
+
return $frm_vars['current_form'];
|
713 |
+
}
|
714 |
+
|
715 |
+
public static function is_form_loaded( $form, $this_load, $global_load ) {
|
716 |
+
global $frm_vars;
|
717 |
+
$small_form = new stdClass();
|
718 |
+
foreach ( array( 'id', 'form_key', 'name' ) as $var ) {
|
719 |
+
$small_form->{$var} = $form->{$var};
|
720 |
+
unset($var);
|
721 |
+
}
|
722 |
+
|
723 |
+
$frm_vars['forms_loaded'][] = $small_form;
|
724 |
+
|
725 |
+
if ( $this_load && empty($global_load) ) {
|
726 |
+
$global_load = $frm_vars['load_css'] = true;
|
727 |
+
}
|
728 |
+
|
729 |
+
return ( ( ! isset($frm_vars['css_loaded']) || ! $frm_vars['css_loaded'] ) && $global_load );
|
730 |
+
}
|
731 |
}
|
classes/models/FrmFormAction.php
CHANGED
@@ -347,6 +347,48 @@ class FrmFormAction {
|
|
347 |
return $this->get_all($form_id, 1);
|
348 |
}
|
349 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
350 |
public function get_all( $form_id = false, $limit = 99 ) {
|
351 |
if ( $form_id ) {
|
352 |
$this->form_id = $form_id;
|
@@ -358,18 +400,9 @@ class FrmFormAction {
|
|
358 |
$frm_vars['action_type'] = $type;
|
359 |
|
360 |
add_filter( 'posts_where' , 'FrmFormActionsController::limit_by_type' );
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
'numberposts' => 99,
|
365 |
-
'order' => 'ASC',
|
366 |
-
'suppress_filters' => false,
|
367 |
-
);
|
368 |
-
|
369 |
-
if ( $form_id != 'all' ) {
|
370 |
-
// allow actions for all forms
|
371 |
-
$query['menu_order'] = $this->form_id;
|
372 |
-
}
|
373 |
|
374 |
$actions = FrmAppHelper::check_cache( serialize( $query ) . '_type_' . $type, 'frm_actions', $query, 'get_posts' );
|
375 |
unset($query);
|
@@ -398,6 +431,22 @@ class FrmFormAction {
|
|
398 |
return $settings;
|
399 |
}
|
400 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
401 |
public function prepare_action($action) {
|
402 |
$action->post_content = FrmAppHelper::maybe_json_decode($action->post_content);
|
403 |
$action->post_excerpt = sanitize_title( $action->post_excerpt );
|
@@ -454,7 +503,7 @@ class FrmFormAction {
|
|
454 |
}
|
455 |
|
456 |
public function get_settings() {
|
457 |
-
|
458 |
}
|
459 |
|
460 |
public function get_global_defaults() {
|
@@ -522,4 +571,56 @@ class FrmFormAction {
|
|
522 |
return $post_id;
|
523 |
}
|
524 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
525 |
}
|
347 |
return $this->get_all($form_id, 1);
|
348 |
}
|
349 |
|
350 |
+
public static function get_action_for_form( $form_id, $type = 'all', $limit = 99 ) {
|
351 |
+
$action_controls = FrmFormActionsController::get_form_actions( $type );
|
352 |
+
if ( empty($action_controls) ) {
|
353 |
+
// don't continue if there are no available actions
|
354 |
+
return array();
|
355 |
+
}
|
356 |
+
|
357 |
+
if ( 'all' != $type ) {
|
358 |
+
return $action_controls->get_all( $form_id, $limit );
|
359 |
+
}
|
360 |
+
|
361 |
+
$args = self::action_args( $form_id, $limit );
|
362 |
+
$actions = FrmAppHelper::check_cache( serialize( $args ), 'frm_actions', $args, 'get_posts' );
|
363 |
+
|
364 |
+
if ( ! $actions ) {
|
365 |
+
return array();
|
366 |
+
}
|
367 |
+
|
368 |
+
$settings = array();
|
369 |
+
foreach ( $actions as $action ) {
|
370 |
+
// some plugins/themes are formatting the post_excerpt
|
371 |
+
$action->post_excerpt = sanitize_title( $action->post_excerpt );
|
372 |
+
|
373 |
+
if ( ! isset( $action_controls[ $action->post_excerpt ] ) ) {
|
374 |
+
continue;
|
375 |
+
}
|
376 |
+
|
377 |
+
$action = $action_controls[ $action->post_excerpt ]->prepare_action( $action );
|
378 |
+
$settings[ $action->ID ] = $action;
|
379 |
+
|
380 |
+
if ( count( $settings ) >= $limit ) {
|
381 |
+
break;
|
382 |
+
}
|
383 |
+
}
|
384 |
+
|
385 |
+
if ( 1 === $limit ) {
|
386 |
+
$settings = reset($settings);
|
387 |
+
}
|
388 |
+
|
389 |
+
return $settings;
|
390 |
+
}
|
391 |
+
|
392 |
public function get_all( $form_id = false, $limit = 99 ) {
|
393 |
if ( $form_id ) {
|
394 |
$this->form_id = $form_id;
|
400 |
$frm_vars['action_type'] = $type;
|
401 |
|
402 |
add_filter( 'posts_where' , 'FrmFormActionsController::limit_by_type' );
|
403 |
+
$query = self::action_args( $form_id, $limit );
|
404 |
+
$query['post_status'] = 'any';
|
405 |
+
$query['suppress_filters'] = false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
406 |
|
407 |
$actions = FrmAppHelper::check_cache( serialize( $query ) . '_type_' . $type, 'frm_actions', $query, 'get_posts' );
|
408 |
unset($query);
|
431 |
return $settings;
|
432 |
}
|
433 |
|
434 |
+
public static function action_args( $form_id = 0, $limit = 99 ) {
|
435 |
+
$args = array(
|
436 |
+
'post_type' => FrmFormActionsController::$action_post_type,
|
437 |
+
'post_status' => 'publish',
|
438 |
+
'numberposts' => $limit,
|
439 |
+
'orderby' => 'title',
|
440 |
+
'order' => 'ASC',
|
441 |
+
);
|
442 |
+
|
443 |
+
if ( $form_id && $form_id != 'all' ) {
|
444 |
+
$args['menu_order'] = $form_id;
|
445 |
+
}
|
446 |
+
|
447 |
+
return $args;
|
448 |
+
}
|
449 |
+
|
450 |
public function prepare_action($action) {
|
451 |
$action->post_content = FrmAppHelper::maybe_json_decode($action->post_content);
|
452 |
$action->post_excerpt = sanitize_title( $action->post_excerpt );
|
503 |
}
|
504 |
|
505 |
public function get_settings() {
|
506 |
+
return self::get_action_for_form( $this->form_id, $this->id_base );
|
507 |
}
|
508 |
|
509 |
public function get_global_defaults() {
|
571 |
return $post_id;
|
572 |
}
|
573 |
|
574 |
+
public static function action_conditions_met( $action, $entry ) {
|
575 |
+
$notification = $action->post_content;
|
576 |
+
$stop = false;
|
577 |
+
$met = array();
|
578 |
+
|
579 |
+
if ( ! isset( $notification['conditions'] ) || empty( $notification['conditions'] ) ) {
|
580 |
+
return $stop;
|
581 |
+
}
|
582 |
+
|
583 |
+
foreach ( $notification['conditions'] as $k => $condition ) {
|
584 |
+
if ( ! is_numeric( $k ) ) {
|
585 |
+
continue;
|
586 |
+
}
|
587 |
+
|
588 |
+
if ( $stop && 'any' == $notification['conditions']['any_all'] && 'stop' == $notification['conditions']['send_stop'] ) {
|
589 |
+
continue;
|
590 |
+
}
|
591 |
+
|
592 |
+
if ( is_array($condition['hide_opt']) ) {
|
593 |
+
$condition['hide_opt'] = reset($condition['hide_opt']);
|
594 |
+
}
|
595 |
+
|
596 |
+
$observed_value = isset( $entry->metas[ $condition['hide_field'] ] ) ? $entry->metas[ $condition['hide_field'] ] : '';
|
597 |
+
if ( $condition['hide_opt'] == 'current_user' ) {
|
598 |
+
$condition['hide_opt'] = get_current_user_id();
|
599 |
+
}
|
600 |
+
|
601 |
+
$stop = FrmFieldsHelper::value_meets_condition($observed_value, $condition['hide_field_cond'], $condition['hide_opt']);
|
602 |
+
|
603 |
+
if ( $notification['conditions']['send_stop'] == 'send' ) {
|
604 |
+
$stop = $stop ? false : true;
|
605 |
+
}
|
606 |
+
|
607 |
+
$met[ $stop ] = $stop;
|
608 |
+
}
|
609 |
+
|
610 |
+
if ( $notification['conditions']['any_all'] == 'all' && ! empty( $met ) && isset( $met[0] ) && isset( $met[1] ) ) {
|
611 |
+
$stop = ($notification['conditions']['send_stop'] == 'send');
|
612 |
+
} else if ( $notification['conditions']['any_all'] == 'any' && $notification['conditions']['send_stop'] == 'send' && isset($met[0]) ) {
|
613 |
+
$stop = false;
|
614 |
+
}
|
615 |
+
|
616 |
+
return $stop;
|
617 |
+
}
|
618 |
+
|
619 |
+
public static function default_action_opts( $class = '' ) {
|
620 |
+
return array(
|
621 |
+
'classes' => 'frm_icon_font ' . $class,
|
622 |
+
'active' => false,
|
623 |
+
'limit' => 0,
|
624 |
+
);
|
625 |
+
}
|
626 |
}
|
classes/models/FrmNotification.php
CHANGED
@@ -93,7 +93,7 @@ class FrmNotification {
|
|
93 |
$data = maybe_unserialize($entry->description);
|
94 |
$mail_body .= "\r\n\r\n" . __( 'User Information', 'formidable' ) ."\r\n";
|
95 |
$mail_body .= __( 'IP Address', 'formidable' ) . ': '. $entry->ip ."\r\n";
|
96 |
-
|
97 |
$mail_body .= __( 'Referrer', 'formidable' ) . ': '. $data['referrer']."\r\n";
|
98 |
}
|
99 |
unset($prev_mail_body);
|
93 |
$data = maybe_unserialize($entry->description);
|
94 |
$mail_body .= "\r\n\r\n" . __( 'User Information', 'formidable' ) ."\r\n";
|
95 |
$mail_body .= __( 'IP Address', 'formidable' ) . ': '. $entry->ip ."\r\n";
|
96 |
+
$mail_body .= __( 'User-Agent (Browser/OS)', 'formidable' ) . ': ' . FrmEntryFormat::get_browser( $data['browser'] ) . "\r\n";
|
97 |
$mail_body .= __( 'Referrer', 'formidable' ) . ': '. $data['referrer']."\r\n";
|
98 |
}
|
99 |
unset($prev_mail_body);
|
classes/views/frm-entries/form.php
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
global $frm_vars;
|
3 |
-
|
4 |
?>
|
5 |
<div class="frm_form_fields <?php echo esc_attr( apply_filters( 'frm_form_fields_class', '', $values ) ); ?>">
|
6 |
<fieldset>
|
@@ -38,11 +38,6 @@ if ( FrmAppHelper::is_admin() && ! $frm_settings->lock_keys ) { ?>
|
|
38 |
do_action('frm_entry_form', $form, $form_action, $errors);
|
39 |
|
40 |
global $frm_vars;
|
41 |
-
// close open section div
|
42 |
-
if ( isset($frm_vars['div']) && $frm_vars['div'] ) {
|
43 |
-
echo "</div>\n";
|
44 |
-
unset($frm_vars['div']);
|
45 |
-
}
|
46 |
// close open collapsible toggle div
|
47 |
if ( isset($frm_vars['collapse_div']) && $frm_vars['collapse_div'] ) {
|
48 |
echo "</div>\n";
|
1 |
<?php
|
2 |
global $frm_vars;
|
3 |
+
FrmFormsController::maybe_load_css( $form, $values['custom_style'], $frm_vars['load_css'] );
|
4 |
?>
|
5 |
<div class="frm_form_fields <?php echo esc_attr( apply_filters( 'frm_form_fields_class', '', $values ) ); ?>">
|
6 |
<fieldset>
|
38 |
do_action('frm_entry_form', $form, $form_action, $errors);
|
39 |
|
40 |
global $frm_vars;
|
|
|
|
|
|
|
|
|
|
|
41 |
// close open collapsible toggle div
|
42 |
if ( isset($frm_vars['collapse_div']) && $frm_vars['collapse_div'] ) {
|
43 |
echo "</div>\n";
|
classes/views/frm-entries/sidebar-shared.php
CHANGED
@@ -43,8 +43,6 @@
|
|
43 |
</div>
|
44 |
</div>
|
45 |
|
46 |
-
|
47 |
-
|
48 |
<div class="postbox">
|
49 |
<h3 class="hndle"><span><?php _e( 'User Information', 'formidable' ) ?></span></h3>
|
50 |
<div class="inside">
|
@@ -53,10 +51,10 @@
|
|
53 |
<b><?php echo sanitize_text_field( $entry->ip ); ?></b>
|
54 |
</div>
|
55 |
|
56 |
-
<?php if ( isset($
|
57 |
<div class="misc-pub-section">
|
58 |
<b><?php _e( 'Browser/OS', 'formidable' ) ?></b>:<br/>
|
59 |
-
|
60 |
</div>
|
61 |
<?php } ?>
|
62 |
|
43 |
</div>
|
44 |
</div>
|
45 |
|
|
|
|
|
46 |
<div class="postbox">
|
47 |
<h3 class="hndle"><span><?php _e( 'User Information', 'formidable' ) ?></span></h3>
|
48 |
<div class="inside">
|
51 |
<b><?php echo sanitize_text_field( $entry->ip ); ?></b>
|
52 |
</div>
|
53 |
|
54 |
+
<?php if ( isset( $browser ) ) { ?>
|
55 |
<div class="misc-pub-section">
|
56 |
<b><?php _e( 'Browser/OS', 'formidable' ) ?></b>:<br/>
|
57 |
+
<?php echo wp_kses_post( $browser ); ?>
|
58 |
</div>
|
59 |
<?php } ?>
|
60 |
|
classes/views/frm-fields/import_choices.php
CHANGED
@@ -36,7 +36,7 @@ foreach ( $field->options as $fkey => $fopt ) {
|
|
36 |
if ( is_array( $fopt ) ) {
|
37 |
$label = (isset($fopt['label'])) ? $fopt['label'] : reset($fopt);
|
38 |
$value = (isset($fopt['value'])) ? $fopt['value'] : $label;
|
39 |
-
|
40 |
echo "$label|$value\n";
|
41 |
} else {
|
42 |
echo $label ."\n";
|
36 |
if ( is_array( $fopt ) ) {
|
37 |
$label = (isset($fopt['label'])) ? $fopt['label'] : reset($fopt);
|
38 |
$value = (isset($fopt['value'])) ? $fopt['value'] : $label;
|
39 |
+
if ( $label != $value && FrmField::is_option_true( $field, 'separate_value' ) ) {
|
40 |
echo "$label|$value\n";
|
41 |
} else {
|
42 |
echo $label ."\n";
|
classes/views/frm-fields/input.php
CHANGED
@@ -11,7 +11,7 @@ do_action('frm_field_input_html', $field);
|
|
11 |
|
12 |
} else if ( $field['type'] == 'radio' ) {
|
13 |
$read_only = false;
|
14 |
-
|
15 |
$read_only = true; ?>
|
16 |
<input type="hidden" value="<?php echo esc_attr( $field['value'] ) ?>" name="<?php echo esc_attr( $field_name ) ?>" />
|
17 |
<?php
|
@@ -63,7 +63,7 @@ do_action('frm_field_input_html', $field);
|
|
63 |
if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) {
|
64 |
echo FrmFieldsHelper::dropdown_categories( array( 'name' => $field_name, 'field' => $field ) );
|
65 |
} else {
|
66 |
-
|
67 |
$read_only = true; ?>
|
68 |
<input type="hidden" value="<?php echo esc_attr($field['value']) ?>" name="<?php echo esc_attr( $field_name ) ?>" id="<?php echo esc_attr( $html_id ) ?>" />
|
69 |
<select disabled="disabled" <?php do_action('frm_field_input_html', $field) ?>>
|
@@ -99,11 +99,11 @@ do_action('frm_field_input_html', $field);
|
|
99 |
$checked_values = $field['value'];
|
100 |
$read_only = false;
|
101 |
|
102 |
-
|
103 |
$read_only = true;
|
104 |
if ( $checked_values ) {
|
105 |
foreach ( (array) $checked_values as $checked_value ) { ?>
|
106 |
-
<input type="hidden" value="<?php echo esc_attr( $checked_value ) ?>"
|
107 |
<?php
|
108 |
}
|
109 |
} else { ?>
|
11 |
|
12 |
} else if ( $field['type'] == 'radio' ) {
|
13 |
$read_only = false;
|
14 |
+
if ( FrmField::is_read_only( $field ) && ! FrmAppHelper::is_admin() ) {
|
15 |
$read_only = true; ?>
|
16 |
<input type="hidden" value="<?php echo esc_attr( $field['value'] ) ?>" name="<?php echo esc_attr( $field_name ) ?>" />
|
17 |
<?php
|
63 |
if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) {
|
64 |
echo FrmFieldsHelper::dropdown_categories( array( 'name' => $field_name, 'field' => $field ) );
|
65 |
} else {
|
66 |
+
if ( FrmField::is_read_only( $field ) && ! FrmAppHelper::is_admin() ) {
|
67 |
$read_only = true; ?>
|
68 |
<input type="hidden" value="<?php echo esc_attr($field['value']) ?>" name="<?php echo esc_attr( $field_name ) ?>" id="<?php echo esc_attr( $html_id ) ?>" />
|
69 |
<select disabled="disabled" <?php do_action('frm_field_input_html', $field) ?>>
|
99 |
$checked_values = $field['value'];
|
100 |
$read_only = false;
|
101 |
|
102 |
+
if ( FrmField::is_read_only( $field ) && ! FrmAppHelper::is_admin() ) {
|
103 |
$read_only = true;
|
104 |
if ( $checked_values ) {
|
105 |
foreach ( (array) $checked_values as $checked_value ) { ?>
|
106 |
+
<input type="hidden" value="<?php echo esc_attr( $checked_value ) ?>" name="<?php echo esc_attr( $field_name ) ?>[]" />
|
107 |
<?php
|
108 |
}
|
109 |
} else { ?>
|
classes/views/frm-fields/show-build.php
CHANGED
@@ -1,8 +1,8 @@
|
|
1 |
<?php if ( in_array( $display['type'], array( 'text', 'website', 'email', 'url' ) ) ) { ?>
|
2 |
-
<input type="text" name="<?php echo esc_attr( $field_name ) ?>" id="<?php echo esc_attr( $html_id ) ?>" value="<?php echo esc_attr( $field['default_value'] ); ?>" <?php echo (
|
3 |
<?php } else if ( $field['type'] == 'textarea' ) { ?>
|
4 |
<textarea name="<?php echo esc_attr( $field_name ) ?>" <?php
|
5 |
-
echo (
|
6 |
?> rows="<?php echo esc_attr( $field['max'] ); ?>" id="<?php echo esc_attr( $html_id ) ?>" class="dyn_default_value"><?php echo FrmAppHelper::esc_textarea(force_balance_tags($field['default_value'])); ?></textarea>
|
7 |
|
8 |
<?php
|
@@ -22,9 +22,9 @@
|
|
22 |
if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) {
|
23 |
echo FrmFieldsHelper::dropdown_categories( array( 'name' => $field_name, 'field' => $field ) );
|
24 |
} else { ?>
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
<?php foreach ( $field['options'] as $opt_key => $opt ) {
|
29 |
$field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field);
|
30 |
$opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field);
|
1 |
<?php if ( in_array( $display['type'], array( 'text', 'website', 'email', 'url' ) ) ) { ?>
|
2 |
+
<input type="text" name="<?php echo esc_attr( $field_name ) ?>" id="<?php echo esc_attr( $html_id ) ?>" value="<?php echo esc_attr( $field['default_value'] ); ?>" <?php echo ( FrmField::is_option_true( $field, 'size' ) ) ? esc_attr( 'style="width:'. $field['size'] . ( is_numeric($field['size']) ? 'px' : '') .';"' ) : ''; ?> class="dyn_default_value" />
|
3 |
<?php } else if ( $field['type'] == 'textarea' ) { ?>
|
4 |
<textarea name="<?php echo esc_attr( $field_name ) ?>" <?php
|
5 |
+
echo ( FrmField::is_option_true( $field, 'size' ) ) ? esc_attr( 'style="width:'. $field['size'] . ( is_numeric($field['size']) ? 'px' : '') .';"' ) : '';
|
6 |
?> rows="<?php echo esc_attr( $field['max'] ); ?>" id="<?php echo esc_attr( $html_id ) ?>" class="dyn_default_value"><?php echo FrmAppHelper::esc_textarea(force_balance_tags($field['default_value'])); ?></textarea>
|
7 |
|
8 |
<?php
|
22 |
if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) {
|
23 |
echo FrmFieldsHelper::dropdown_categories( array( 'name' => $field_name, 'field' => $field ) );
|
24 |
} else { ?>
|
25 |
+
<select name="<?php echo esc_attr( $field_name ) . ( FrmField::is_option_true( $field, 'multiple' ) ? '[]' : '' ); ?>" <?php
|
26 |
+
echo FrmField::is_option_true( $field, 'size' ) ? 'class="auto_width"' : '';
|
27 |
+
echo FrmField::is_option_true( $field, 'multiple' ) ? ' multiple="multiple"' : ''; ?> >
|
28 |
<?php foreach ( $field['options'] as $opt_key => $opt ) {
|
29 |
$field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field);
|
30 |
$opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field);
|
classes/views/frm-form-actions/default_actions.php
CHANGED
@@ -2,19 +2,17 @@
|
|
2 |
// add post action
|
3 |
class FrmDefPostAction extends FrmFormAction {
|
4 |
public function __construct() {
|
5 |
-
|
6 |
$action_ops['classes'] = 'ab-icon frm_dashicon_font dashicons-before';
|
7 |
|
8 |
$this->FrmFormAction('wppost', __( 'Create Post', 'formidable' ), $action_ops);
|
9 |
}
|
10 |
}
|
11 |
|
12 |
-
|
13 |
// add register action
|
14 |
class FrmDefRegAction extends FrmFormAction {
|
15 |
public function __construct() {
|
16 |
-
|
17 |
-
|
18 |
$this->FrmFormAction('register', __( 'Register User', 'formidable' ), $action_ops);
|
19 |
}
|
20 |
}
|
@@ -22,8 +20,7 @@ class FrmDefRegAction extends FrmFormAction {
|
|
22 |
// add paypal action
|
23 |
class FrmDefPayPalAction extends FrmFormAction {
|
24 |
public function __construct() {
|
25 |
-
|
26 |
-
|
27 |
$this->FrmFormAction('paypal', __( 'Collect Payment', 'formidable' ), $action_ops);
|
28 |
}
|
29 |
}
|
@@ -31,8 +28,7 @@ class FrmDefPayPalAction extends FrmFormAction {
|
|
31 |
// add aweber action
|
32 |
class FrmDefAweberAction extends FrmFormAction {
|
33 |
public function __construct() {
|
34 |
-
|
35 |
-
|
36 |
$this->FrmFormAction('aweber', __( 'Aweber', 'formidable' ), $action_ops);
|
37 |
}
|
38 |
}
|
@@ -40,8 +36,7 @@ class FrmDefAweberAction extends FrmFormAction {
|
|
40 |
// add mailchimp action
|
41 |
class FrmDefMlcmpAction extends FrmFormAction {
|
42 |
public function __construct() {
|
43 |
-
|
44 |
-
|
45 |
$this->FrmFormAction('mailchimp', __( 'MailChimp', 'formidable' ), $action_ops);
|
46 |
}
|
47 |
}
|
@@ -49,8 +44,7 @@ class FrmDefMlcmpAction extends FrmFormAction {
|
|
49 |
// add twilio action
|
50 |
class FrmDefTwilioAction extends FrmFormAction {
|
51 |
public function __construct() {
|
52 |
-
|
53 |
-
|
54 |
$this->FrmFormAction('twilio', __( 'Twilio', 'formidable' ), $action_ops);
|
55 |
}
|
56 |
}
|
@@ -58,8 +52,7 @@ class FrmDefTwilioAction extends FrmFormAction {
|
|
58 |
// add highrise action
|
59 |
class FrmDefHrsAction extends FrmFormAction {
|
60 |
public function __construct() {
|
61 |
-
|
62 |
-
|
63 |
$this->FrmFormAction('highrise', __( 'Highrise', 'formidable' ), $action_ops);
|
64 |
}
|
65 |
}
|
2 |
// add post action
|
3 |
class FrmDefPostAction extends FrmFormAction {
|
4 |
public function __construct() {
|
5 |
+
$action_ops = FrmFormAction::default_action_opts();
|
6 |
$action_ops['classes'] = 'ab-icon frm_dashicon_font dashicons-before';
|
7 |
|
8 |
$this->FrmFormAction('wppost', __( 'Create Post', 'formidable' ), $action_ops);
|
9 |
}
|
10 |
}
|
11 |
|
|
|
12 |
// add register action
|
13 |
class FrmDefRegAction extends FrmFormAction {
|
14 |
public function __construct() {
|
15 |
+
$action_ops = FrmFormAction::default_action_opts('frm_register_icon');
|
|
|
16 |
$this->FrmFormAction('register', __( 'Register User', 'formidable' ), $action_ops);
|
17 |
}
|
18 |
}
|
20 |
// add paypal action
|
21 |
class FrmDefPayPalAction extends FrmFormAction {
|
22 |
public function __construct() {
|
23 |
+
$action_ops = FrmFormAction::default_action_opts('frm_paypal_icon');
|
|
|
24 |
$this->FrmFormAction('paypal', __( 'Collect Payment', 'formidable' ), $action_ops);
|
25 |
}
|
26 |
}
|
28 |
// add aweber action
|
29 |
class FrmDefAweberAction extends FrmFormAction {
|
30 |
public function __construct() {
|
31 |
+
$action_ops = FrmFormAction::default_action_opts('frm_aweber_icon');
|
|
|
32 |
$this->FrmFormAction('aweber', __( 'Aweber', 'formidable' ), $action_ops);
|
33 |
}
|
34 |
}
|
36 |
// add mailchimp action
|
37 |
class FrmDefMlcmpAction extends FrmFormAction {
|
38 |
public function __construct() {
|
39 |
+
$action_ops = FrmFormAction::default_action_opts('frm_mailchimp_icon');
|
|
|
40 |
$this->FrmFormAction('mailchimp', __( 'MailChimp', 'formidable' ), $action_ops);
|
41 |
}
|
42 |
}
|
44 |
// add twilio action
|
45 |
class FrmDefTwilioAction extends FrmFormAction {
|
46 |
public function __construct() {
|
47 |
+
$action_ops = FrmFormAction::default_action_opts('frm_sms_icon');
|
|
|
48 |
$this->FrmFormAction('twilio', __( 'Twilio', 'formidable' ), $action_ops);
|
49 |
}
|
50 |
}
|
52 |
// add highrise action
|
53 |
class FrmDefHrsAction extends FrmFormAction {
|
54 |
public function __construct() {
|
55 |
+
$action_ops = FrmFormAction::default_action_opts('frm_highrise_icon');
|
|
|
56 |
$this->FrmFormAction('highrise', __( 'Highrise', 'formidable' ), $action_ops);
|
57 |
}
|
58 |
}
|
classes/views/frm-forms/add_field.php
CHANGED
@@ -6,6 +6,7 @@ $display = apply_filters('frm_display_field_options', array(
|
|
6 |
'description' => true, 'options' => true, 'label_position' => true,
|
7 |
'invalid' => false, 'size' => false, 'clear_on_focus' => false,
|
8 |
'default_blank' => true, 'css' => true, 'conf_field' => false,
|
|
|
9 |
));
|
10 |
|
11 |
$li_classes = 'form-field edit_form_item frm_field_box frm_top_container frm_not_divider edit_field_type_'. $display['type'];
|
@@ -27,8 +28,8 @@ if ( ! isset( $frm_all_field_selection ) ) {
|
|
27 |
if ( isset($frm_field_selection) && isset($pro_field_selection) ) {
|
28 |
$frm_all_field_selection = array_merge($frm_field_selection, $pro_field_selection);
|
29 |
} else {
|
30 |
-
|
31 |
-
|
32 |
}
|
33 |
}
|
34 |
|
@@ -54,7 +55,7 @@ if ( $field['type'] == 'divider' ) { ?>
|
|
54 |
<?php do_action('frm_extra_field_actions', $field['id']); ?>
|
55 |
<?php if ( $display['required'] ) { ?>
|
56 |
<span id="require_field_<?php echo esc_attr( $field['id'] ); ?>">
|
57 |
-
<a href="javascript:void(0);" class="frm_req_field frm_action_icon frm_required_icon frm_icon_font alignleft frm_required<?php echo (int) $field['required'] ?>" id="req_field_<?php echo esc_attr( $field['id'] ); ?>" title="Click to Mark as <?php echo
|
58 |
</span>
|
59 |
<?php }
|
60 |
|
@@ -243,14 +244,18 @@ if ( $display['options'] ) { ?>
|
|
243 |
<?php
|
244 |
if ( in_array( $field['type'], array( 'select', 'time', 'data' ) ) ) {
|
245 |
if ( ! isset( $values['custom_style'] ) || $values['custom_style'] ) { ?>
|
246 |
-
|
|
|
|
|
|
|
247 |
<?php
|
248 |
}
|
249 |
} else { ?>
|
250 |
<input type="text" name="field_options[size_<?php echo esc_attr( $field['id'] ) ?>]" value="<?php echo esc_attr( $field['size'] ); ?>" size="5" /> <span class="howto"><?php _e( 'pixels wide', 'formidable' ) ?></span>
|
251 |
|
|
|
252 |
<input type="text" name="field_options[max_<?php echo esc_attr( $field['id'] ) ?>]" value="<?php echo esc_attr( $field['max'] ); ?>" size="5" /> <span class="howto"><?php echo ( $field['type'] == 'textarea' || $field['type'] == 'rte' ) ? __( 'rows high', 'formidable' ) : __( 'characters maximum', 'formidable' ) ?></span>
|
253 |
-
<?php
|
254 |
} ?>
|
255 |
</td>
|
256 |
</tr>
|
@@ -258,7 +263,8 @@ if ( $display['options'] ) { ?>
|
|
258 |
<?php do_action('frm_field_options_form', $field, $display, $values);
|
259 |
|
260 |
if ( $display['required'] || $display['invalid'] || $display['unique'] || $display['conf_field'] ) { ?>
|
261 |
-
|
|
|
262 |
<div class="menu-settings">
|
263 |
<h3 class="frm_no_bg"><?php _e( 'Validation', 'formidable' ) ?></h3>
|
264 |
|
6 |
'description' => true, 'options' => true, 'label_position' => true,
|
7 |
'invalid' => false, 'size' => false, 'clear_on_focus' => false,
|
8 |
'default_blank' => true, 'css' => true, 'conf_field' => false,
|
9 |
+
'max' => true,
|
10 |
));
|
11 |
|
12 |
$li_classes = 'form-field edit_form_item frm_field_box frm_top_container frm_not_divider edit_field_type_'. $display['type'];
|
28 |
if ( isset($frm_field_selection) && isset($pro_field_selection) ) {
|
29 |
$frm_all_field_selection = array_merge($frm_field_selection, $pro_field_selection);
|
30 |
} else {
|
31 |
+
$pro_field_selection = FrmField::pro_field_selection();
|
32 |
+
$frm_all_field_selection = array_merge( FrmField::field_selection(), $pro_field_selection );
|
33 |
}
|
34 |
}
|
35 |
|
55 |
<?php do_action('frm_extra_field_actions', $field['id']); ?>
|
56 |
<?php if ( $display['required'] ) { ?>
|
57 |
<span id="require_field_<?php echo esc_attr( $field['id'] ); ?>">
|
58 |
+
<a href="javascript:void(0);" class="frm_req_field frm_action_icon frm_required_icon frm_icon_font alignleft frm_required<?php echo (int) $field['required'] ?>" id="req_field_<?php echo esc_attr( $field['id'] ); ?>" title="Click to Mark as <?php echo FrmField::is_required( $field ) ? 'not ' : ''; ?>Required"></a>
|
59 |
</span>
|
60 |
<?php }
|
61 |
|
244 |
<?php
|
245 |
if ( in_array( $field['type'], array( 'select', 'time', 'data' ) ) ) {
|
246 |
if ( ! isset( $values['custom_style'] ) || $values['custom_style'] ) { ?>
|
247 |
+
<label for="size_<?php echo esc_attr( $field['id'] ) ?>">
|
248 |
+
<input type="checkbox" name="field_options[size_<?php echo esc_attr( $field['id'] ) ?>]" id="size_<?php echo esc_attr( $field['id'] ) ?>" value="1" <?php echo FrmField::is_option_true( $field, 'size' ) ? 'checked="checked"' : ''; ?> />
|
249 |
+
<?php _e( 'automatic width', 'formidable' ) ?>
|
250 |
+
</label>
|
251 |
<?php
|
252 |
}
|
253 |
} else { ?>
|
254 |
<input type="text" name="field_options[size_<?php echo esc_attr( $field['id'] ) ?>]" value="<?php echo esc_attr( $field['size'] ); ?>" size="5" /> <span class="howto"><?php _e( 'pixels wide', 'formidable' ) ?></span>
|
255 |
|
256 |
+
<?php if ( $display['max'] ) { ?>
|
257 |
<input type="text" name="field_options[max_<?php echo esc_attr( $field['id'] ) ?>]" value="<?php echo esc_attr( $field['max'] ); ?>" size="5" /> <span class="howto"><?php echo ( $field['type'] == 'textarea' || $field['type'] == 'rte' ) ? __( 'rows high', 'formidable' ) : __( 'characters maximum', 'formidable' ) ?></span>
|
258 |
+
<?php }
|
259 |
} ?>
|
260 |
</td>
|
261 |
</tr>
|
263 |
<?php do_action('frm_field_options_form', $field, $display, $values);
|
264 |
|
265 |
if ( $display['required'] || $display['invalid'] || $display['unique'] || $display['conf_field'] ) { ?>
|
266 |
+
<tr class="frm_validation_msg <?php echo ($display['invalid'] || $field['required'] || FrmField::is_option_true( $field, 'unique' ) || FrmField::is_option_true( $field, 'conf_field' ) ) ? '' : 'frm_hidden'; ?>">
|
267 |
+
<td colspan="2">
|
268 |
<div class="menu-settings">
|
269 |
<h3 class="frm_no_bg"><?php _e( 'Validation', 'formidable' ) ?></h3>
|
270 |
|
classes/views/frm-forms/add_field_links.php
CHANGED
@@ -37,7 +37,7 @@ foreach ( $frm_field_selection as $field_key => $field_type ) { ?>
|
|
37 |
<?php
|
38 |
$col_class = 'frm_col_one';
|
39 |
$no_allow_class = apply_filters( 'frm_noallow_class', 'frm_noallow' );
|
40 |
-
foreach (
|
41 |
|
42 |
if ( is_array( $field_type ) ) {
|
43 |
$field_label = $field_type['name'];
|
37 |
<?php
|
38 |
$col_class = 'frm_col_one';
|
39 |
$no_allow_class = apply_filters( 'frm_noallow_class', 'frm_noallow' );
|
40 |
+
foreach ( FrmField::pro_field_selection() as $field_key => $field_type ) {
|
41 |
|
42 |
if ( is_array( $field_type ) ) {
|
43 |
$field_label = $field_type['name'];
|
classes/views/shared/mb_adv_info.php
CHANGED
@@ -21,11 +21,11 @@
|
|
21 |
$linked_forms[] = array();
|
22 |
|
23 |
foreach ( $fields as $f ) {
|
24 |
-
if (
|
25 |
$repeat_field = $f->id;
|
26 |
}
|
27 |
|
28 |
-
if (
|
29 |
continue;
|
30 |
}
|
31 |
|
@@ -44,7 +44,7 @@
|
|
44 |
$linked_form = FrmDb::get_var( $wpdb->prefix .'frm_fields', array( 'id' => $f->field_options['form_select'] ), 'form_id' );
|
45 |
if ( ! in_array( $linked_form, $linked_forms ) ) {
|
46 |
$linked_forms[] = $linked_form;
|
47 |
-
$linked_fields = FrmField::getAll( array( 'fi.type not' =>
|
48 |
$ldfe = '';
|
49 |
if ( $linked_fields ) {
|
50 |
foreach ( $linked_fields as $linked_field ) {
|
@@ -98,7 +98,7 @@
|
|
98 |
<ul class="frm_code_list frm_full_width">
|
99 |
<?php if ( ! empty( $fields ) ) {
|
100 |
foreach ( $fields as $f ) {
|
101 |
-
|
102 |
continue;
|
103 |
}
|
104 |
?>
|
21 |
$linked_forms[] = array();
|
22 |
|
23 |
foreach ( $fields as $f ) {
|
24 |
+
if ( FrmField::is_repeating_field( $f ) ) {
|
25 |
$repeat_field = $f->id;
|
26 |
}
|
27 |
|
28 |
+
if ( FrmField::is_no_save_field( $f->type ) ) {
|
29 |
continue;
|
30 |
}
|
31 |
|
44 |
$linked_form = FrmDb::get_var( $wpdb->prefix .'frm_fields', array( 'id' => $f->field_options['form_select'] ), 'form_id' );
|
45 |
if ( ! in_array( $linked_form, $linked_forms ) ) {
|
46 |
$linked_forms[] = $linked_form;
|
47 |
+
$linked_fields = FrmField::getAll( array( 'fi.type not' => FrmField::no_save_fields(), 'fi.form_id' => $linked_form ) );
|
48 |
$ldfe = '';
|
49 |
if ( $linked_fields ) {
|
50 |
foreach ( $linked_fields as $linked_field ) {
|
98 |
<ul class="frm_code_list frm_full_width">
|
99 |
<?php if ( ! empty( $fields ) ) {
|
100 |
foreach ( $fields as $f ) {
|
101 |
+
if ( FrmField::is_no_save_field( $f->type ) || ( $f->type == 'data' && ( ! isset( $f->field_options['data_type'] ) || $f->field_options['data_type'] == 'data' || $f->field_options['data_type'] == '' ) ) ) {
|
102 |
continue;
|
103 |
}
|
104 |
?>
|
css/_single_theme.css.php
CHANGED
@@ -893,6 +893,15 @@ if ( ! $submit_style ) { ?>
|
|
893 |
width:100%<?php echo $important ?>;
|
894 |
}
|
895 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
896 |
.<?php echo $style_class ?> .frm_form_field.frm_first_half.frm_right_container div.frm_description,
|
897 |
.<?php echo $style_class ?> .frm_form_field.frm_first_half.frm_right_container .frm_error,
|
898 |
.<?php echo $style_class ?> .frm_form_field.frm_first_half .frm_right_container div.frm_description,
|
893 |
width:100%<?php echo $important ?>;
|
894 |
}
|
895 |
|
896 |
+
.<?php echo $style_class ?> .frm_form_field.frm_last.frm_repeat_buttons label.frm_primary_label{
|
897 |
+
display:none;
|
898 |
+
}
|
899 |
+
|
900 |
+
.<?php echo $style_class ?> .frm_repeat_inline,
|
901 |
+
.<?php echo $style_class ?> .frm_repeat_grid{
|
902 |
+
margin: 20px 0;
|
903 |
+
}
|
904 |
+
|
905 |
.<?php echo $style_class ?> .frm_form_field.frm_first_half.frm_right_container div.frm_description,
|
906 |
.<?php echo $style_class ?> .frm_form_field.frm_first_half.frm_right_container .frm_error,
|
907 |
.<?php echo $style_class ?> .frm_form_field.frm_first_half .frm_right_container div.frm_description,
|
css/custom_theme.css.php
CHANGED
@@ -141,7 +141,7 @@ legend.frm_hidden{
|
|
141 |
text-decoration:none;
|
142 |
border:1px solid #eee;
|
143 |
padding:5px;
|
144 |
-
display:inline
|
145 |
}
|
146 |
|
147 |
.with_frm_style .frm_submit{
|
@@ -562,7 +562,7 @@ table.frmcal-calendar .frmcal-today .frmcal_date{
|
|
562 |
/* End Calendar Styling */
|
563 |
|
564 |
.frm-loading-img{
|
565 |
-
background:url(<?php echo FrmAppHelper::
|
566 |
padding:6px 12px;
|
567 |
}
|
568 |
|
@@ -1123,6 +1123,7 @@ table.frmcal-calendar .frmcal-today .frmcal_date{
|
|
1123 |
|
1124 |
.frm_form_field .frm_repeat_sec .frm_add_form_row{
|
1125 |
opacity:0;
|
|
|
1126 |
*visibility:visible;
|
1127 |
-moz-transition: opacity .15s ease-in-out;
|
1128 |
-webkit-transition: opacity .15s ease-in-out;
|
@@ -1132,6 +1133,7 @@ table.frmcal-calendar .frmcal-today .frmcal_date{
|
|
1132 |
|
1133 |
.frm_section_heading div.frm_repeat_sec:last-child .frm_add_form_row{
|
1134 |
opacity:100;
|
|
|
1135 |
pointer-events:auto;
|
1136 |
}
|
1137 |
|
@@ -1280,6 +1282,53 @@ html[xmlns] .frm_clearfix{
|
|
1280 |
height:1%;
|
1281 |
}
|
1282 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1283 |
/* Start Chosen */
|
1284 |
.with_frm_style .chosen-container{
|
1285 |
font-size:<?php echo $defaults['field_font_size'] ?>;
|
@@ -1354,7 +1403,7 @@ html[xmlns] .frm_clearfix{
|
|
1354 |
width:12px;
|
1355 |
height:12px;
|
1356 |
font-size:1px;
|
1357 |
-
background:url('<?php echo FrmAppHelper::
|
1358 |
}
|
1359 |
|
1360 |
.with_frm_style .chosen-container-single .chosen-single abbr:hover{
|
@@ -1375,7 +1424,7 @@ html[xmlns] .frm_clearfix{
|
|
1375 |
}
|
1376 |
|
1377 |
.with_frm_style .chosen-container-single .chosen-single div b{
|
1378 |
-
background:url('<?php echo FrmAppHelper::
|
1379 |
display:block;
|
1380 |
width:100%;
|
1381 |
height:100%;
|
@@ -1395,8 +1444,8 @@ html[xmlns] .frm_clearfix{
|
|
1395 |
box-sizing:border-box;
|
1396 |
width:100%;
|
1397 |
height:auto;
|
1398 |
-
background:white url('<?php echo FrmAppHelper::
|
1399 |
-
background:url('<?php echo FrmAppHelper::
|
1400 |
font-size:1em;
|
1401 |
font-family:sans-serif;
|
1402 |
line-height:normal;
|
@@ -1426,6 +1475,10 @@ html[xmlns] .frm_clearfix{
|
|
1426 |
-webkit-overflow-scrolling:touch;
|
1427 |
}
|
1428 |
|
|
|
|
|
|
|
|
|
1429 |
.with_frm_style .chosen-container .chosen-results li{
|
1430 |
display:none;
|
1431 |
margin:0;
|
@@ -1535,7 +1588,7 @@ html[xmlns] .frm_clearfix{
|
|
1535 |
display:block;
|
1536 |
width:12px;
|
1537 |
height:12px;
|
1538 |
-
background:url('<?php echo FrmAppHelper::
|
1539 |
font-size:1px;
|
1540 |
}
|
1541 |
|
@@ -1675,7 +1728,7 @@ html[xmlns] .frm_clearfix{
|
|
1675 |
|
1676 |
.with_frm_style .chosen-rtl .chosen-search input[type="text"]{
|
1677 |
padding:4px 5px 4px 20px;
|
1678 |
-
background:white url('<?php echo FrmAppHelper::
|
1679 |
direction:rtl;
|
1680 |
}
|
1681 |
|
@@ -1691,8 +1744,8 @@ html[xmlns] .frm_clearfix{
|
|
1691 |
/* Fonts */
|
1692 |
@font-face {
|
1693 |
font-family:'s11-fp';
|
1694 |
-
src:url('<?php echo FrmAppHelper::
|
1695 |
-
src:local('☺'), url('<?php echo FrmAppHelper::
|
1696 |
font-weight:normal;
|
1697 |
font-style:normal;
|
1698 |
}
|
@@ -1708,7 +1761,7 @@ html[xmlns] .frm_clearfix{
|
|
1708 |
.with_frm_style .chosen-container-multi .chosen-choices .search-choice .search-choice-close,
|
1709 |
.with_frm_style .chosen-container .chosen-results-scroll-down span,
|
1710 |
.with_frm_style .chosen-container .chosen-results-scroll-up span{
|
1711 |
-
background-image:url('<?php echo FrmAppHelper::
|
1712 |
background-size:52px 37px !important;
|
1713 |
background-repeat:no-repeat !important;
|
1714 |
}
|
141 |
text-decoration:none;
|
142 |
border:1px solid #eee;
|
143 |
padding:5px;
|
144 |
+
display:inline;
|
145 |
}
|
146 |
|
147 |
.with_frm_style .frm_submit{
|
562 |
/* End Calendar Styling */
|
563 |
|
564 |
.frm-loading-img{
|
565 |
+
background:url(<?php echo FrmAppHelper::relative_plugin_url() ?>/images/ajax_loader.gif) no-repeat center center;
|
566 |
padding:6px 12px;
|
567 |
}
|
568 |
|
1123 |
|
1124 |
.frm_form_field .frm_repeat_sec .frm_add_form_row{
|
1125 |
opacity:0;
|
1126 |
+
display:none;
|
1127 |
*visibility:visible;
|
1128 |
-moz-transition: opacity .15s ease-in-out;
|
1129 |
-webkit-transition: opacity .15s ease-in-out;
|
1133 |
|
1134 |
.frm_section_heading div.frm_repeat_sec:last-child .frm_add_form_row{
|
1135 |
opacity:100;
|
1136 |
+
display:inline;
|
1137 |
pointer-events:auto;
|
1138 |
}
|
1139 |
|
1282 |
height:1%;
|
1283 |
}
|
1284 |
|
1285 |
+
/* Login form */
|
1286 |
+
.with_frm_style.frm_login_form.frm_inline_login .login-remember input{
|
1287 |
+
vertical-align:baseline;
|
1288 |
+
}
|
1289 |
+
|
1290 |
+
.with_frm_style.frm_login_form.frm_inline_login label{
|
1291 |
+
display:inline;
|
1292 |
+
}
|
1293 |
+
|
1294 |
+
.with_frm_style.frm_login_form.frm_inline_login .login-username,
|
1295 |
+
.with_frm_style.frm_login_form.frm_inline_login .login-password,
|
1296 |
+
.with_frm_style.frm_login_form.frm_inline_login .login-remember{
|
1297 |
+
float:left;
|
1298 |
+
margin-right:5px;
|
1299 |
+
}
|
1300 |
+
|
1301 |
+
.with_frm_style.frm_login_form.frm_inline_login form{
|
1302 |
+
position:relative;
|
1303 |
+
}
|
1304 |
+
|
1305 |
+
.with_frm_style.frm_login_form.frm_inline_login .login-remember{
|
1306 |
+
position:absolute;
|
1307 |
+
top:35px;
|
1308 |
+
}
|
1309 |
+
|
1310 |
+
.with_frm_style.frm_login_form.frm_inline_login input[type=submit]{
|
1311 |
+
margin:0 !important;
|
1312 |
+
}
|
1313 |
+
|
1314 |
+
.with_frm_style.frm_login_form.frm_inline_login.frm_no_labels .login-username label,
|
1315 |
+
.with_frm_style.frm_login_form.frm_inline_login.frm_no_labels .login-password label{
|
1316 |
+
display:none;
|
1317 |
+
}
|
1318 |
+
|
1319 |
+
.with_frm_style .frm-open-login{
|
1320 |
+
float:left;
|
1321 |
+
margin-right:15px;
|
1322 |
+
}
|
1323 |
+
|
1324 |
+
.with_frm_style .frm-open-login a{
|
1325 |
+
text-decoration:none;
|
1326 |
+
}
|
1327 |
+
|
1328 |
+
.with_frm_style.frm_slide.frm_login_form form{
|
1329 |
+
display:none;
|
1330 |
+
}
|
1331 |
+
|
1332 |
/* Start Chosen */
|
1333 |
.with_frm_style .chosen-container{
|
1334 |
font-size:<?php echo $defaults['field_font_size'] ?>;
|
1403 |
width:12px;
|
1404 |
height:12px;
|
1405 |
font-size:1px;
|
1406 |
+
background:url('<?php echo FrmAppHelper::relative_plugin_url() ?>/pro/images/chosen-sprite.png') -42px 1px no-repeat;
|
1407 |
}
|
1408 |
|
1409 |
.with_frm_style .chosen-container-single .chosen-single abbr:hover{
|
1424 |
}
|
1425 |
|
1426 |
.with_frm_style .chosen-container-single .chosen-single div b{
|
1427 |
+
background:url('<?php echo FrmAppHelper::relative_plugin_url() ?>/pro/images/chosen-sprite.png') no-repeat 0px 2px;
|
1428 |
display:block;
|
1429 |
width:100%;
|
1430 |
height:100%;
|
1444 |
box-sizing:border-box;
|
1445 |
width:100%;
|
1446 |
height:auto;
|
1447 |
+
background:white url('<?php echo FrmAppHelper::relative_plugin_url() ?>/pro/images/chosen-sprite.png') no-repeat 100% -20px;
|
1448 |
+
background:url('<?php echo FrmAppHelper::relative_plugin_url() ?>/pro/images/chosen-sprite.png') no-repeat 100% -20px;
|
1449 |
font-size:1em;
|
1450 |
font-family:sans-serif;
|
1451 |
line-height:normal;
|
1475 |
-webkit-overflow-scrolling:touch;
|
1476 |
}
|
1477 |
|
1478 |
+
.with_frm_style .chosen-container .chosen-results li:before{
|
1479 |
+
background:none;
|
1480 |
+
}
|
1481 |
+
|
1482 |
.with_frm_style .chosen-container .chosen-results li{
|
1483 |
display:none;
|
1484 |
margin:0;
|
1588 |
display:block;
|
1589 |
width:12px;
|
1590 |
height:12px;
|
1591 |
+
background:url('<?php echo FrmAppHelper::relative_plugin_url() ?>/pro/images/chosen-sprite.png') -42px 1px no-repeat;
|
1592 |
font-size:1px;
|
1593 |
}
|
1594 |
|
1728 |
|
1729 |
.with_frm_style .chosen-rtl .chosen-search input[type="text"]{
|
1730 |
padding:4px 5px 4px 20px;
|
1731 |
+
background:white url('<?php echo FrmAppHelper::relative_plugin_url() ?>/pro/images/chosen-sprite.png') no-repeat -30px -20px;background:url('<?php echo FrmAppHelper::relative_plugin_url() ?>/pro/images/chosen-sprite.png') no-repeat -30px -20px;
|
1732 |
direction:rtl;
|
1733 |
}
|
1734 |
|
1744 |
/* Fonts */
|
1745 |
@font-face {
|
1746 |
font-family:'s11-fp';
|
1747 |
+
src:url('<?php echo FrmAppHelper::relative_plugin_url() ?>/fonts/s11-fp.eot');
|
1748 |
+
src:local('☺'), url('<?php echo FrmAppHelper::relative_plugin_url() ?>/fonts/s11-fp.woff') format('woff'), url('<?php echo FrmAppHelper::relative_plugin_url() ?>/fonts/s11-fp.ttf') format('truetype'), url('<?php echo FrmAppHelper::relative_plugin_url() ?>/fonts/s11-fp.svg') format('svg');
|
1749 |
font-weight:normal;
|
1750 |
font-style:normal;
|
1751 |
}
|
1761 |
.with_frm_style .chosen-container-multi .chosen-choices .search-choice .search-choice-close,
|
1762 |
.with_frm_style .chosen-container .chosen-results-scroll-down span,
|
1763 |
.with_frm_style .chosen-container .chosen-results-scroll-up span{
|
1764 |
+
background-image:url('<?php echo FrmAppHelper::relative_plugin_url() ?>/pro/images/chosen-sprite2x.png') !important;
|
1765 |
background-size:52px 37px !important;
|
1766 |
background-repeat:no-repeat !important;
|
1767 |
}
|
css/frm_admin.css
CHANGED
@@ -1226,7 +1226,10 @@ a.frm_action_icon:hover {text-decoration:none;}
|
|
1226 |
.frm_action_icon.frm_required_icon:before{content: '\e612'; font-size:7px; vertical-align:top; line-height: 2.1em; margin-right:3px;}
|
1227 |
.frm_38_trigger .frm_action_icon.frm_required_icon:before{font-size:8px;}
|
1228 |
.frm_action_icon.frm_required_icon {color:#000;margin-top:0;}
|
1229 |
-
.frm_inactive_icon.frm_action_icon.frm_required_icon,
|
|
|
|
|
|
|
1230 |
|
1231 |
.frm-hover-icon{padding-left:5px;}
|
1232 |
.frm-move.frm-hover-icon{padding-left:3px;}
|
1226 |
.frm_action_icon.frm_required_icon:before{content: '\e612'; font-size:7px; vertical-align:top; line-height: 2.1em; margin-right:3px;}
|
1227 |
.frm_38_trigger .frm_action_icon.frm_required_icon:before{font-size:8px;}
|
1228 |
.frm_action_icon.frm_required_icon {color:#000;margin-top:0;}
|
1229 |
+
a.frm_inactive_icon.frm_action_icon.frm_required_icon,
|
1230 |
+
a.frm_action_icon.frm_required0{
|
1231 |
+
color:#ababab;
|
1232 |
+
}
|
1233 |
|
1234 |
.frm-hover-icon{padding-left:5px;}
|
1235 |
.frm-move.frm-hover-icon{padding-left:3px;}
|
js/formidable.min.js
CHANGED
@@ -1,57 +1,59 @@
|
|
1 |
-
function frmFrontFormJS(){function
|
2 |
-
jQuery(this).toggleClass("active").children(".ui-icon-triangle-1-e, .ui-icon-triangle-1-s").toggleClass("ui-icon-triangle-1-s ui-icon-triangle-1-e")}function
|
3 |
-
|
4 |
-
"checkbox"===
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
f.val();"undefined"
|
10 |
-
|
11 |
-
|
12 |
-
a,
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
if(
|
19 |
-
var
|
20 |
-
g
|
21 |
-
|
22 |
-
"
|
23 |
-
|
24 |
-
"
|
25 |
-
"
|
26 |
-
|
27 |
-
|
28 |
-
jQuery(
|
29 |
-
|
30 |
-
"
|
31 |
-
|
32 |
-
|
33 |
-
b
|
34 |
-
a
|
35 |
-
"
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
jQuery.
|
40 |
-
|
41 |
-
g
|
42 |
-
a.
|
43 |
-
|
44 |
-
jQuery(
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
"
|
51 |
-
|
52 |
-
g
|
53 |
-
function
|
54 |
-
|
55 |
-
function
|
56 |
-
function
|
57 |
-
function
|
|
|
|
1 |
+
function frmFrontFormJS(){function l(a){var b=jQuery(this),c=b.attr("type");"submit"!==c&&a.preventDefault();a=b.parents("form:first");var d=b="",e=this.name;if("frm_prev_page"===e||-1!==this.className.indexOf("frm_prev_page"))b=jQuery(a).find(".frm_next_page").attr("id").replace("frm_next_p_","");else if("frm_save_draft"===e||-1!==this.className.indexOf("frm_save_draft"))d=1;jQuery(".frm_next_page").val(b);jQuery(".frm_saving_draft").val(d);"submit"!==c&&a.trigger("submit")}function n(){jQuery(this).parent().children(".frm_toggle_container").slideToggle("fast");
|
2 |
+
jQuery(this).toggleClass("active").children(".ui-icon-triangle-1-e, .ui-icon-triangle-1-s").toggleClass("ui-icon-triangle-1-s ui-icon-triangle-1-e")}function q(){this.className=this.className.replace("frm_transparent","");this.parentNode.getElementsByTagName("a")[0].className.indexOf("frm_clear_file_link")}function v(){var a=this.type,b=!1,c=!1;if("select-one"===a)c=!0,"frm_other_trigger"===this.options[this.selectedIndex].className&&(b=!0);else if("select-multiple"===a)for(var c=!0,d=this.options,
|
3 |
+
b=!1,e=0;e<d.length;e++)if("frm_other_trigger"===d[e].className&&d[e].selected){b=!0;break}c?(a=jQuery(this).parent().children(".frm_other_input"),b?a[0].className=a[0].className.replace("frm_pos_none",""):(1>a[0].className.indexOf("frm_pos_none")&&(a[0].className+=" frm_pos_none"),a[0].value="")):"radio"===a?jQuery(this).is(":checked")&&(jQuery(this).closest(".frm_radio").children(".frm_other_input").removeClass("frm_pos_none"),jQuery(this).closest(".frm_radio").siblings().children(".frm_other_input").addClass("frm_pos_none").val("")):
|
4 |
+
"checkbox"===a&&(this.checked?jQuery(this).closest(".frm_checkbox").children(".frm_other_input").removeClass("frm_pos_none"):jQuery(this).closest(".frm_checkbox").children(".frm_other_input").addClass("frm_pos_none").val(""))}function x(a){var b;b=this.name.replace("item_meta[","").split("]");var c=b[0],d=!1;jQuery('input[name="item_meta['+c+'][form]"]').length&&(c=b[2].replace("[",""),d=!0);"other"===c&&(c=d?b[3].replace("[",""):b[1].replace("[",""));if((b=c)&&"undefined"!==typeof b){c="reset";if(a.frmTriggered){if(a.frmTriggered==
|
5 |
+
b)return;c="persist"}p("und",b,null,jQuery(this),c);E(b)}}function p(a,b,c,d,e){var f;if("undefined"===typeof __FRMRULES||"undefined"===typeof __FRMRULES[b])f=void 0;else{f=__FRMRULES[b];for(var g=[],h=0,k=f.length;h<k;h++){var l=f[h];if("undefined"!==typeof l)for(var F=0,n=l.Conditions.length;F<n;F++){var C=l.Conditions[F];C.HideField=l.Setting.FieldName;C.MatchType=l.MatchType;C.Show=l.Show;g.push(C)}}f=g}if("undefined"!==typeof f){if("undefined"===typeof c||null===c)c="go";"persist"!==e&&(m=[],
|
6 |
+
A=[]);e=d;g=!1;""===y&&"undefined"!==typeof e&&null!==e&&(1<e.length&&(e=e.eq(0)),g=e.closest(".frm_repeat_sec, .frm_repeat_inline, .frm_repeat_grid"),"undefined"!==typeof g?(y=g.attr("id"),g=!0):g=!1);e=g;g=f.length;for(h=0;h<g;h++)f[h].FieldName===b?r(h,f[h],b,a,c,d):r(h,f[h],b,a,c),h===g-1&&(R(c),e&&(y=""))}}function r(a,b,c,d,e,f){"undefined"===typeof m[b.HideField]&&(m[b.HideField]=[]);b.inputName="item_meta["+b.FieldName+"]";b.hiddenName="item_meta["+b.HideField+"]";b.containerID="frm_field_"+
|
7 |
+
b.FieldName+"_container";b.hideContainerID="frm_field_"+b.HideField+"_container";b.hideBy="#";var g=!1;if("undefined"!==typeof f&&null!==f){1<f.length&&(f=f.eq(0));if("undefined"===typeof f.attr("name"))return;b.inputName=f.attr("name").replace("[other]","").replace("[]","");var h=f.closest(".frm_repeat_sec, .frm_repeat_inline, .frm_repeat_grid");h.length&&(h=h.find(".frm_field_"+b.FieldName+"_container"),b.containerID=h.attr("id"),b.hideContainerID=b.containerID.replace(b.FieldName,b.HideField),
|
8 |
+
b.hiddenName=b.inputName.replace("["+b.FieldName+"]","["+b.HideField+"]"))}else{g=!0;f=jQuery('input[name^="'+b.inputName+'"], textarea[name^="'+b.inputName+'"], select[name^="'+b.inputName+'"]');if(1>f.length&&(h="."+b.containerID,""!==y&&(h="#"+y+" "+h),h=jQuery(h),h.length)){f=h.find("input, textarea, select");f.length?r(a,b,c,d,e,f):(m[b.HideField][a]=!1,B(a,b,e));return}1<f.length&&(f=f.eq(0))}null===document.getElementById(b.hideContainerID)&&(b.hideBy=".");if(b.FieldName!==c||"undefined"===
|
9 |
+
typeof d||"und"===d)if(("radio"===b.Type||"data-radio"===b.Type)&&"radio"===f.attr("type"))d=jQuery('input[name="'+b.inputName+'"]:checked').val(),"undefined"===typeof d&&(d="");else if("select"===b.Type||"time"===b.Type||"data-select"===b.Type||"checkbox"!==b.Type&&"data-checkbox"!==b.Type)d=f.val();"undefined"===typeof d&&(d=f.val());if("undefined"===typeof d){if(!0===g&&(c=jQuery("."+b.containerID+" input, ."+b.containerID+" select, ."+b.containerID+" textarea"),c.length)){c.each(function(){r(a,
|
10 |
+
b,b.FieldName,d,e,jQuery(this))});return}d=""}c=[];if("checkbox"===b.Type||"data-checkbox"===b.Type)c=S(b.containerID,b.inputName),d=c.length?c:"";m[b.HideField][a]=""===d||1>d.length?!1:{funcName:"getDataOpts",f:b,sel:d};if("checkbox"===b.Type||"data-checkbox"===b.Type&&"undefined"===typeof b.LinkedField)if(c=m[b.HideField][a]=!1,""!==d)for("!="===b.Condition&&(m[b.HideField][a]=!0),f=0;f<d.length;f++)c=z(b.Condition,b.Value,d[f]),"!="===b.Condition?!0===m[b.HideField][a]&&!1===c&&(m[b.HideField][a]=
|
11 |
+
!1):!1===m[b.HideField][a]&&c&&(m[b.HideField][a]=!0);else c=z(b.Condition,b.Value,""),!1===m[b.HideField][a]&&c&&(m[b.HideField][a]=!0);else if("undefined"!==typeof b.LinkedField&&0===b.Type.indexOf("data-")){if("undefined"===typeof b.DataType||"data"===b.DataType)""===d?u(b.hideContainerID,b.hideBy,b.HideField):"data-radio"===b.Type?m[b.HideField][a]="undefined"===typeof b.DataType?z(b.Condition,b.Value,d):{funcName:"getData",f:b,sel:d}:"data-checkbox"===b.Type||"data-select"===b.Type&&jQuery.isArray(d)?
|
12 |
+
(u(b.hideContainerID,b.hideBy,b.HideField),m[b.HideField][a]=!0,K(b,d,1)):"data-select"===b.Type&&(m[b.HideField][a]={funcName:"getData",f:b,sel:d})}else"undefined"===typeof b.Value&&0===b.Type.indexOf("data")?(b.Value=""===d?"1":d,m[b.HideField][a]=z(b.Condition,b.Value,d),b.Value=void 0):m[b.HideField][a]=z(b.Condition,b.Value,d);B(a,b,e)}function u(a,b,c){-1===jQuery.inArray(a,A)&&(A[c]=a,a="."===b?jQuery("."+a):jQuery(document.getElementById(a)),a.fadeOut("slow"),a.find(".frm_data_field_container").empty())}
|
13 |
+
function w(a,b){a.hide();if(-1===jQuery.inArray(a.attr("id"),A)){A[b.HideField]=a.attr("id");var c=a.find('select[name^="item_meta"]:not([readonly]), textarea[name^="item_meta"]:not([readonly]), input[name^="item_meta"]:not([type=hidden]):not([readonly])');if(c.length){c.prop("checked",!1).prop("selectedIndex",0);c.not(":checkbox, :radio, select").val("");var d=!1;c.each(function(){"SELECT"==this.tagName&&null!==document.getElementById(this.id+"_chosen")&&jQuery(this).trigger("chosen:updated");var a=
|
14 |
+
jQuery(this),b=a.data("frmval");"undefined"!==typeof b&&(a.is(":checkbox, :radio")?(a.val()==b||jQuery.isArray(b)&&-1!==jQuery.inArray(a.val(),b))&&a.prop("checked",!0):a.val(b));!1===d&&jQuery(this).trigger({type:"change",frmTriggered:"dependent",selfTriggered:!0});d=!0})}}}function B(a,b,c){if("all"===b.MatchType||!1===m[b.HideField][a])G.push({result:m[b.HideField][a],show:b.Show,match:b.MatchType,FieldName:b.FieldName,HideField:b.HideField,hideContainerID:b.hideContainerID,hideBy:b.hideBy});else{var d=
|
15 |
+
"none";if("show"===b.Show){if(!0!==m[b.HideField][a]){L(m[b.HideField][a],b.FieldName,c);return}d=""}"."===b.hideBy?(a=jQuery("."+b.hideContainerID),a.length&&("none"===d?w(a,b):a.show())):(a=document.getElementById(b.hideContainerID),null!==a&&("none"===d?w(jQuery(a),b):("undefined"!==typeof __FRMCALC&&(c=__FRMCALC,b=c.fieldsWithCalc[b.HideField],"undefined"!==typeof b&&M(c,b,[])),a.style.display=d)))}}function R(a){jQuery.each(G,function(b,c){if("undefined"!==typeof c&&"undefined"!==typeof c.result){var d=
|
16 |
+
jQuery(c.hideBy+c.hideContainerID),e=c.show;if(d.length){if("any"===c.match&&-1===jQuery.inArray(!0,m[c.HideField])||"all"===c.match&&-1<jQuery.inArray(!1,m[c.HideField]))e="show"===c.show?"hide":"show";"show"===e?d.show():w(d,c);!1!==typeof c.result&&!0!==typeof c.result&&L(c.result,c.FieldName,a)}delete G[b]}})}function z(a,b,c){"undefined"===typeof c&&(c="");jQuery.isArray(c)&&-1<jQuery.inArray(b,c)&&(c=b);-1!==String(b).search(/^\s*(\+|-)?((\d+(\.\d+)?)|(\.\d+))\s*$/)&&(b=parseFloat(b),c=parseFloat(c));
|
17 |
+
return"-1"!=String(b).indexOf(""")&&z(a,b.replace(""",'"'),c)?!0:{"==":function(a,b){return a==b},"!=":function(a,b){return a!=b},"<":function(a,b){return a>b},">":function(a,b){return a<b},LIKE:function(a,b){return b?-1!=b.indexOf(a):0},"not LIKE":function(a,b){return b?-1==b.indexOf(a):1}}[a](b,c)}function L(a,b,c){"getDataOpts"==a.funcName?T(a.f,a.sel,b,c):"getData"==a.funcName&&K(a.f,a.sel,0)}function K(a,b,c){var d=document.getElementById(a.hideContainerID),e=jQuery(d).find(".frm_data_field_container");
|
18 |
+
if(0===e.length)return!0;c||e.html('<span class="frm-loading-img"></span>');jQuery.ajax({type:"POST",url:frm_js.ajax_url,data:{action:"frm_fields_ajax_get_data",entry_id:b,field_id:a.LinkedField,current_field:a.HideField,hide_id:a.hideContainerID,nonce:frm_js.nonce},success:function(f){""!==f&&(d.style.display="");if(c)e.append(f);else{e.html(f);var g=e.children("input"),h=g.val();if(""===f||""===h)d.style.display="none";p(b,a.HideField,null,g)}return!0}})}function T(a,b,c,d){if(!("stop"==d&&-1<jQuery.inArray(a.HideField,
|
19 |
+
H)&&a.parentField&&"hidden"==a.parentField.attr("type"))){var e=jQuery('input[name^="'+a.hiddenName+'"], select[name^="'+a.hiddenName+'"]:not(":disabled"), textarea[name^="'+a.hiddenName+'"]'),f=[];e.each(function(){"radio"===this.type||"checkbox"===this.type?!0===this.checked&&f.push(jQuery(this).val()):f.push(jQuery(this).val())});if("select"!=a.DataType||"stop"!=d&&!jQuery("#"+a.hideContainerID+" .frm-loading-img").length||!(-1<jQuery.inArray(a.HideField,H))){0===f.length&&(f="");H.push(a.HideField);
|
20 |
+
var g=document.getElementById(a.hideContainerID),h=jQuery(g).find(".frm_data_field_container");if(0===h.length&&e.length)return p(f,a.HideField,"stop",e),!1;if(""!==a.Value&&!z(a.Condition,a.Value,b))return g.style.display="none",h.html(""),p("",a.HideField,"stop",e),!1;h.html('<span class="frm-loading-img" style="visibility:visible;display:inline;"></span>');var k=a.DataType;jQuery.ajax({type:"POST",url:frm_js.ajax_url,data:{action:"frm_fields_ajax_data_options",hide_field:c,entry_id:b,selected_field_id:a.LinkedField,
|
21 |
+
field_id:a.HideField,hide_id:a.hideContainerID,nonce:frm_js.nonce},success:function(b){""===b?(g.style.display="none",f=""):"all"!=a.MatchType&&(g.style.display="");h.html(b);var c=h.find("select, input, textarea");""!==b&&""!==f&&(jQuery.isArray(f)||(b=[],b.push(f),f=b),jQuery.each(f,function(a,b){if("undefined"!==typeof b&&""!==b)if("checkbox"==k||"radio"==k)1<c.length?c.filter('[value="'+b+'"]').attr("checked","checked"):c.val()==b&&c.attr("checked","checked");else if("select"==k){var d=c.children('option[value="'+
|
22 |
+
b+'"]');d.length?d.prop("selected",!0):f.splice(a,1)}else c.val(b)}));c.hasClass("frm_chzn")&&jQuery().chosen&&jQuery(".frm_chzn").chosen({allow_single_deselect:!0});c.length?p(f,a.HideField,"stop",c):p(f,a.HideField,"stop")}})}}}function E(a){if("undefined"!==typeof __FRMCALC){var b=__FRMCALC;a=b.fields[a];if("undefined"!==typeof a){a=a.total;for(var c=[],d=0,e=a.length;d<e;d++)b.calc[a[d]].field_id in A||M(b,a[d],c)}}}function M(a,b,c){var d=a.calc[b],e=d.calc,e=U(d,e,a,c);a=d.calc_dec;e.indexOf(").toFixed(")&&
|
23 |
+
(c=e.split(").toFixed("),N(c[1])&&(a=c[1],e=e.replace(").toFixed("+a,"")));e=parseFloat(eval(e));N(a)&&(e=e.toFixed(a));"undefined"===typeof e&&(e=0);jQuery(document.getElementById("field_"+b)).val(e).trigger({type:"change",frmTriggered:b,selfTriggered:!0})}function U(a,b,c,d){for(var e=0,f=a.fields.length;e<f;e++){var g=a.fields[e],h=c.fields[g],k="input"+c.fieldKeys[g];"checkbox"==h.type||"select"==h.type?k=k+":checked,select"+c.fieldKeys[g]+" option:selected,"+k+"[type=hidden]":"radio"==h.type||
|
24 |
+
"scale"==h.type?k=k+":checked,"+k+"[type=hidden]":"textarea"==h.type&&(k=k+",textarea"+c.fieldKeys[g]);d[g]=V(k,g,h,c,d);if("undefined"===typeof d[g]||isNaN(d[g]))d[g]=0;h="["+g+"]";h=h.replace(/([.*+?^=!:${}()|\[\]\/\\])/g,"\\$1");b=b.replace(new RegExp(h,"g"),d[g])}return b}function V(a,b,c,d,e){if("undefined"!==typeof e[b]&&0!==e[b])return e[b];jQuery(a).each(function(){"undefined"===typeof e[b]&&(e[b]=0);var a;a=!1;if("hidden"==this.type)""!==I(this)&&(a=!0);else if("select"==c.type){var g=this.className;
|
25 |
+
g&&-1<g.indexOf("frm_other_trigger")&&(a=!0)}else("checkbox"==c.type||"radio"==c.type)&&-1<this.id.indexOf("-other_")&&0>this.id.indexOf("-otext")&&(a=!0);a?(a=0,"select"==c.type?"hidden"==this.type?(g=!1,2<this.name.split("[").length&&(g=!0),g||(a=I(this))):a=jQuery(this).closest(".frm_other_container").find(".frm_other_input").val():"checkbox"!=c.type&&"radio"!=c.type||"hidden"==this.type||(a=I(this))):a=jQuery(this).val();"date"==c.type&&(g=jQuery.datepicker.parseDate(d.date,a),null!==g&&(e[b]=
|
26 |
+
Math.ceil(g/864E5)));""!==a&&0!==a&&(a=a.trim(),a=parseFloat(a.replace(/,/g,"").match(/-?[\d\.]+$/)));if("undefined"===typeof a||isNaN(a)||""===a)a=0;e[b]+=a});return e[b]}function I(a){var b="";a=document.getElementById(a.id+"-otext");null!==a&&""!==a.value&&(b=a.value);return b}function O(a,b){jQuery(a).find('input[type="submit"], input[type="button"]').attr("disabled","disabled");jQuery(a).find(".frm_ajax_loading").addClass("frm_loading_now");"undefined"==typeof b&&jQuery(a).find('input[name="frm_action"]').val();
|
27 |
+
jQuery.ajax({type:"POST",url:frm_js.ajax_url,data:jQuery(a).serialize()+"&action=frm_entries_"+b+"&nonce="+frm_js.nonce,success:function(b){b=b.replace(/^\s+|\s+$/g,"");0===b.indexOf("{")&&(b=jQuery.parseJSON(b));if(""===b||!b||"0"===b||"object"!=typeof b&&0===b.indexOf("<!DOCTYPE")){var d=document.getElementById("frm_loading");null!==d&&(b=jQuery(a).find("input[type=file]").val(),"undefined"!=typeof b&&""!==b&&setTimeout(function(){jQuery(d).fadeIn("slow")},2E3));b=jQuery(a).find(".g-recaptcha");
|
28 |
+
b.length&&(1>jQuery(a).find(".frm_next_page").length||1>jQuery(a).find(".frm_next_page").val())&&b.closest(".frm_form_field").replaceWith('<input type="hidden" name="recaptcha_checked" value="'+frm_js.nonce+'">');a.submit()}else if("object"!=typeof b){jQuery(a).find(".frm_ajax_loading").removeClass("frm_loading_now");var e=jQuery(a).find('input[name="form_id"]').val();jQuery(a).closest("#frm_form_"+e+"_container").replaceWith(b);frmFrontForm.scrollMsg(e);if("function"==typeof frmThemeOverride_frmAfterSubmit){var e=
|
29 |
+
jQuery('input[name="frm_page_order_'+e+'"]').val(),f=jQuery(b).find('input[name="form_id"]').val();frmThemeOverride_frmAfterSubmit(f,e,b,a)}b=jQuery(a).find('input[name="id"]');b.length&&jQuery(document.getElementById("frm_edit_"+b.val())).find("a").addClass("frm_ajax_edited").click()}else{jQuery(a).find('input[type="submit"], input[type="button"]').removeAttr("disabled");jQuery(a).find(".frm_ajax_loading").removeClass("frm_loading_now");e=!0;jQuery(".form-field").removeClass("frm_blank_field");jQuery(".form-field .frm_error").replaceWith("");
|
30 |
+
var f="",g=!1,h=null,k;for(k in b)if(h=jQuery(a).find(jQuery(document.getElementById("frm_field_"+k+"_container"))),h.length){if(!h.is(":visible")){var l=h.closest(".frm_toggle_container");l.length&&l.prev(".frm_trigger").click()}h.is(":visible")&&(e=!1,""===f&&(frmFrontForm.scrollMsg(k,a,!0),f="#frm_field_"+k+"_container"),jQuery(a).find("#frm_field_"+k+"_container .g-recaptcha").length&&(g=!0,grecaptcha.reset()),h.addClass("frm_blank_field"),"function"==typeof frmThemeOverride_frmPlaceError?frmThemeOverride_frmPlaceError(k,
|
31 |
+
b):h.append('<div class="frm_error">'+b[k]+"</div>"))}else if("redirect"==k){window.location=b[k];return}!0!==g&&jQuery(a).find(".g-recaptcha").closest(".frm_form_field").replaceWith('<input type="hidden" name="recaptcha_checked" value="'+frm_js.nonce+'">');e&&a.submit()}},error:function(){jQuery(a).find('input[type="submit"], input[type="button"]').removeAttr("disabled");a.submit()}})}function W(){P(jQuery(this),"clear")}function X(){P(jQuery(this),"replace")}function P(a,b){var c=a.data("frmval").replace(/(\n|\r\n)/g,
|
32 |
+
"\r");if(""===c||"undefined"==typeof c)return!1;var d=a.val().replace(/(\n|\r\n)/g,"\r");"replace"==b?""===d&&a.addClass("frm_default").val(c):d==c&&a.removeClass("frm_default").val("")}function Y(){var a=jQuery(this),b=a.data("eid"),c=a.data("fid");a.append('<span class="spinner" style="display:inline"></span>');jQuery.ajax({type:"POST",url:frm_js.ajax_url,data:{action:"frm_entries_send_email",entry_id:b,form_id:c,nonce:frm_js.nonce},success:function(b){a.replaceWith(b)}});return!1}function Z(a,
|
33 |
+
b){google.load("visualization","1.0",{packages:[b],callback:function(){if("table"==b){var c=new google.visualization.DataTable,d=!1;-1!==jQuery.inArray("id",a.options.fields)&&(d=!0,c.addColumn("number",frm_js.id));for(var e=a.fields.length,f="string",g=0,h=e;g<h;g++){var k=a.fields[g],f=Q(k);c.addColumn(f,k.name)}g=!1;a.options.edit_link&&(g=!0,c.addColumn("string",a.options.edit_link));h=!1;a.options.delete_link&&(h=!0,c.addColumn("string",a.options.delete_link));k=0;if(null!==a.entries){var l=
|
34 |
+
a.entries.length;c.addRows(l);for(var m=0,n=0;n<l;n++){var k=0,p=a.entries[n];d&&(c.setCell(m,k,p.id),k++);for(var q=0,r=e;q<r;q++){var t=a.fields[q],f=Q(t),t=p.metas[t.id];"number"!=f||null!==t&&""!==t?"boolean"==f&&(t=null===t||"false"==t||!1===t?!1:!0):t=0;c.setCell(m,k,t);k++}g&&("undefined"!==typeof p.editLink?c.setCell(m,k,'<a href="'+p.editLink+'">'+a.options.edit_link+"</a>"):c.setCell(m,k,""),k++);h&&("undefined"!==typeof p.deleteLink?c.setCell(m,k,'<a href="'+p.deleteLink+'" class="frm_delete_link" onclick="return confirm('+
|
35 |
+
a.options.confirm+')">'+a.options.delete_link+"</a>"):c.setCell(m,k,""));m++}}else for(c.addRows(1),g=k=0,h=e;g<h;g++)0<k?c.setCell(0,k,""):c.setCell(0,k,a.options.no_entries),k++;(new google.visualization.Table(document.getElementById("frm_google_table_"+a.options.form_id))).draw(c,a.graphOpts)}else aa(a)}})}function Q(a){var b="string";if("number"==a.type)b="number";else if("checkbox"==a.type||"select"==a.type){var c=a.options.length;"select"==a.type&&""===a.options[0]&&(c="post_status"==a.field_options.post_field?
|
36 |
+
3:c-1);1==c&&(b="boolean")}return b}function aa(a){var b=new google.visualization.DataTable,c=!1,d=!1,e=a.rows.length;if(0<e)if("table"==a.type){c=!0;b.addRows(a.rows[e-1][0]+1);for(var f=0;f<e;f++)b.setCell(a.rows[f])}else if("undefined"!=typeof a.rows[0].tooltip)for(var d=c=!0,g=0;g<e;g++){f=a.rows[g].tooltip;delete a.rows[g].tooltip;var h=Object.keys(a.rows[g]).map(function(b){return a.rows[g][b]});a.rows[g]=h;a.rows[g].push(f)}e=a.cols.length;if(c){if(0<e)for(c=0;c<e;c++)f=a.cols[c],b.addColumn(f.type,
|
37 |
+
f.name);d&&(b.addColumn({type:"string",role:"tooltip"}),b.addRows(a.rows))}else{b=[[]];for(d=0;d<e;d++)b[0].push(a.cols[d].name);b=b.concat(a.rows);b=google.visualization.arrayToDataTable(b)}d=a.type.charAt(0).toUpperCase()+a.type.slice(1)+"Chart";(new google.visualization[d](document.getElementById("chart_"+a.graph_id))).draw(b,a.options)}function ba(){var a=jQuery(this),b=a.data("fid");a.wrap('<div class="frm_file_names frm_uploaded_files">');for(var c=a.get(0).files,d=0;d<c.length;d++)0===d?a.after(c[d].name+
|
38 |
+
' <a href="#" class="frm_clear_file_link">'+frm_js.remove+"</a>"):a.after(c[d].name+"<br/>");a.hide();c=a.attr("name");c!="item_meta["+b+"][]"&&c.replace("item_meta[","").replace("[]","").split("][");a.closest(".frm_form_field").find(".frm_uploaded_files:last").after('<input name="'+c+'" data-fid="'+b+'"class="frm_transparent frm_multiple_file" multiple="multiple" type="file" />')}function ca(){da(jQuery(this).parent(".frm_uploaded_files"))}function ea(){jQuery(this).parent(".frm_file_names").replaceWith("");
|
39 |
+
return!1}function fa(){var a="frm_section_"+jQuery(this).data("parent")+"-"+jQuery(this).data("key"),b=jQuery(document.getElementById(a)),c=b.find("input, select, textarea");b.fadeOut("slow",function(){b.remove();c.each(function(){if("file"!=this.type){var a=this.name.replace("item_meta[","").split("]")[2].replace("[","");E(a)}})});return!1}function ga(){var a=jQuery(this).data("parent"),b=0;0<jQuery(".frm_repeat_"+a).length&&(b=1+parseInt(jQuery(".frm_repeat_"+a+":last").attr("id").replace("frm_section_"+
|
40 |
+
a+"-","")),"undefined"==typeof b&&(b=1));jQuery.ajax({type:"POST",url:frm_js.ajax_url,dataType:"json",data:{action:"frm_add_form_row",field_id:a,i:b,nonce:frm_js.nonce},success:function(b){var d=b.html,e=jQuery(d).hide().fadeIn("slow");jQuery(".frm_repeat_"+a+":last").after(e);var f=["other"],g,h="reset";y=e.attr("id");jQuery(d).find("input, select, textarea").each(function(){"file"!=this.type&&(g=this.name.replace("item_meta[","").split("]")[2].replace("[",""),-1==jQuery.inArray(g,f)&&(f.push(g),
|
41 |
+
p("und",g,null,jQuery(this),h),E(g),h="persist"))});y="";for(var e=0,k=b.logic.check.length;e<k;e++)-1==jQuery.inArray(b.logic.check[e],f)&&1>jQuery(d).find(".frm_field_"+b.logic.check[e]+"_container").length&&(p("und",b.logic.check[e],null,null,h),h="persist");0<jQuery(d).find(".star").length&&jQuery(".star").rating();0<jQuery(d).find(".frm_chzn").length&&jQuery().chosen&&jQuery(".frm_chzn").chosen({allow_single_deselect:!0});"function"==typeof frmThemeOverride_frmAddRow&&frmThemeOverride_frmAddRow(a,
|
42 |
+
b)}});return!1}function da(a){a.fadeOut("slow",function(){a.remove()})}function ha(){var a=jQuery(this).data("frmtoggle");jQuery(a).is(":visible")?jQuery(a).slideUp("fast"):jQuery(a).slideDown("fast");return!1}function N(a){return!jQuery.isArray(a)&&0<=a-parseFloat(a)+1}function S(a,b){var c=[];if("undefined"==typeof document.querySelector)jQuery("#"+a+' input[type=checkbox]:checked, input[type=hidden][name^="'+b+'"]').each(function(){c.push(this.value)});else for(var d=document.querySelectorAll("#"+
|
43 |
+
a+' input[type=checkbox], input[type=hidden][name^="'+b+'"]'),e=0;e<d.length;e++)("checkbox"==d[e].type&&d[e].checked||"hidden"==d[e].type)&&c.push(d[e].value);return c}var m=[],G=[],A=[],H=[],y="",J="",D=[];return{init:function(){jQuery(document).on("click",".frm_trigger",n);var a=jQuery(".frm_blank_field");a.length&&a.closest(".frm_toggle_container").prev(".frm_trigger").click();jQuery.isFunction(jQuery.fn.placeholder)?jQuery(".frm-show-form input, .frm-show-form textarea").placeholder():jQuery(".frm-show-form input[onblur], .frm-show-form textarea[onblur]").each(function(){""===
|
44 |
+
jQuery(this).val()&&jQuery(this).blur()});jQuery(document).on("focus",".frm_toggle_default",W);jQuery(document).on("blur",".frm_toggle_default",X);jQuery(".frm_toggle_default").blur();jQuery(document.getElementById("frm_resend_email")).click(Y);jQuery(document).on("change",".frm_multiple_file",ba);jQuery(document).on("click",".frm_clear_file_link",ea);jQuery(document).on("click",".frm_remove_link",ca);jQuery(document).on("focusin","input[data-frmmask]",function(){jQuery(this).mask(jQuery(this).data("frmmask").toString())});
|
45 |
+
jQuery(document).on("change",'.frm-show-form input[name^="item_meta"], .frm-show-form select[name^="item_meta"], .frm-show-form textarea[name^="item_meta"]',x);jQuery(document).on("click",'.frm-show-form input[type="submit"], .frm-show-form input[name="frm_prev_page"], .frm-show-form .frm_save_draft',l);jQuery(document).on("change",'.frm_other_container input[type="checkbox"], .frm_other_container input[type="radio"], .frm_other_container select',v);jQuery(document).on("change","input[type=file].frm_transparent",
|
46 |
+
q);jQuery(document).on("click",".frm_remove_form_row",fa);jQuery(document).on("click",".frm_add_form_row",ga);jQuery("a[data-frmtoggle]").click(ha);jQuery(".frm_month_heading, .frm_year_heading").click(function(){var b=jQuery(this).children(".ui-icon-triangle-1-e, .ui-icon-triangle-1-s");b.hasClass("ui-icon-triangle-1-e")?(b.addClass("ui-icon-triangle-1-s").removeClass("ui-icon-triangle-1-e"),jQuery(this).next(".frm_toggle_container").fadeIn("slow")):(b.addClass("ui-icon-triangle-1-e").removeClass("ui-icon-triangle-1-s"),
|
47 |
+
jQuery(this).next(".frm_toggle_container").hide())})},submitForm:function(a){a.preventDefault();jQuery(this).find(".wp-editor-wrap").length&&"undefined"!=typeof tinyMCE&&tinyMCE.triggerSave();J=jQuery(this).find('input[name="frm_action"]').val();D=[];"function"==typeof frmThemeOverride_jsErrors&&(D=frmThemeOverride_jsErrors(J,this));if(0===D.length)O(this,J);else for(var b in D)$fieldCont=jQuery(this).find(jQuery(document.getElementById("frm_field_"+b+"_container"))),$fieldCont.length&&$fieldCont.is(":visible")&&
|
48 |
+
($fieldCont.addClass("frm_blank_field"),"function"==typeof frmThemeOverride_frmPlaceError?frmThemeOverride_frmPlaceError(b,errObj):$fieldCont.append('<div class="frm_error">'+errObj[b]+"</div>"))},checkFormErrors:function(a,b){O(a,b)},scrollToID:function(a){a=jQuery(document.getElementById(a).offset());window.scrollTo(a.left,a.top)},scrollMsg:function(a,b,c){var d="";if(d="undefined"==typeof b?jQuery(document.getElementById("frm_form_"+a+"_container")).offset().top:jQuery(b).find(document.getElementById("frm_field_"+
|
49 |
+
a+"_container")).offset().top){d-=frm_js.offset;a=jQuery("html").css("margin-top");b=jQuery("body").css("margin-top");if(a||b)d=d-parseInt(a)-parseInt(b);if(d&&window.innerHeight&&(a=document.documentElement.scrollTop||document.body.scrollTop,d>a+window.innerHeight||d<a))return"undefined"===typeof c?jQuery(window).scrollTop(d):jQuery("html,body").animate({scrollTop:d},500),!1}},hideCondFields:function(a){a=JSON.parse(a);for(var b=0,c=a.length;b<c;b++){var d=document.getElementById("frm_field_"+a[b]+
|
50 |
+
"_container");null!==d?d.style.display="none":jQuery(".frm_field_"+a[b]+"_container").hide()}},checkDependent:function(a){a=JSON.parse(a);for(var b="reset",c=0,d=a.length;c<d;c++)p("und",a[c],null,null,b),b="persist"},loadGoogle:function(){if("undefined"!==typeof google&&google&&google.load){console.log("load");for(var a=__FRMTABLES,b=Object.keys(a),c=0;c<b.length;c++)for(var d=a[b[c]],e=b[c],f=0;f<d.length;f++)Z(d[f],e)}else console.log("timeout"),setTimeout(frmFrontForm.loadGoogle,30)},removeUsedTimes:function(a,
|
51 |
+
b){var c=jQuery(a).parents("form:first").find('input[name="id"]');jQuery.ajax({type:"POST",url:frm_js.ajax_url,dataType:"json",data:{action:"frm_fields_ajax_time_options",time_field:b,date_field:a.id,entry_id:c?c.val():"",date:jQuery(a).val(),nonce:frm_js.nonce},success:function(a){var c=jQuery(document.getElementById(b));c.find("option").removeAttr("disabled");if(a&&""!==a)for(var f in a)c.find('option[value="'+f+'"]').attr("disabled","disabled")}})},escapeHtml:function(a){return a.replace(/&/g,
|
52 |
+
"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")},invisible:function(a){jQuery(a).css("visibility","hidden")},visible:function(a){jQuery(a).css("visibility","visible")}}}var frmFrontForm=frmFrontFormJS();jQuery(document).ready(function(l){frmFrontForm.init()});
|
53 |
+
function frmEditEntry(l,n,q,v,x,p){var r=jQuery(document.getElementById("frm_edit_"+l)),u=r.html(),w=jQuery(document.getElementById(n+l)),B=w.html();w.html('<span class="frm-loading-img" id="'+n+l+'"></span><div class="frm_orig_content" style="display:none">'+B+"</div>");jQuery.ajax({type:"POST",url:frm_js.ajax_url,dataType:"html",data:{action:"frm_entries_edit_entry_ajax",post_id:q,entry_id:l,id:v,nonce:frm_js.nonce},success:function(B){w.children(".frm-loading-img").replaceWith(B);r.replaceWith('<span id="frm_edit_'+
|
54 |
+
l+'"><a onclick="frmCancelEdit('+l+",'"+n+"','"+frmFrontForm.escapeHtml(u)+"',"+q+","+v+",'"+p+'\')" class="'+p+'">'+x+"</a></span>")}})}
|
55 |
+
function frmCancelEdit(l,n,q,v,x,p){var r=jQuery(document.getElementById("frm_edit_"+l)),u=r.find("a"),w=u.html();u.hasClass("frm_ajax_edited")||(u=jQuery(document.getElementById(n+l)),u.children(".frm_forms").replaceWith(""),u.children(".frm_orig_content").fadeIn("slow").removeClass("frm_orig_content"));r.replaceWith('<a id="frm_edit_'+l+'" class="frm_edit_link '+p+'" href="javascript:frmEditEntry('+l+",'"+n+"',"+v+","+x+",'"+frmFrontForm.escapeHtml(w)+"','"+p+"')\">"+q+"</a>")}
|
56 |
+
function frmUpdateField(l,n,q,v,x){jQuery(document.getElementById("frm_update_field_"+l+"_"+n)).html('<span class="frm-loading-img"></span>');jQuery.ajax({type:"POST",url:frm_js.ajax_url,data:{action:"frm_entries_update_field_ajax",entry_id:l,field_id:n,value:q,nonce:frm_js.nonce},success:function(){""===v.replace(/^\s+|\s+$/g,"")?jQuery(document.getElementById("frm_update_field_"+l+"_"+n+"_"+x)).fadeOut("slow"):jQuery(document.getElementById("frm_update_field_"+l+"_"+n+"_"+x)).replaceWith(v)}})}
|
57 |
+
function frmDeleteEntry(l,n){jQuery(document.getElementById("frm_delete_"+l)).replaceWith('<span class="frm-loading-img" id="frm_delete_'+l+'"></span>');jQuery.ajax({type:"POST",url:frm_js.ajax_url,data:{action:"frm_entries_destroy",entry:l,nonce:frm_js.nonce},success:function(q){"success"==q.replace(/^\s+|\s+$/g,"")?jQuery(document.getElementById(n+l)).fadeOut("slow"):jQuery(document.getElementById("frm_delete_"+l)).replaceWith(q)}})}
|
58 |
+
function frmOnSubmit(l){console.warn("DEPRECATED: function frmOnSubmit in v2.0 use frmFrontForm.submitForm");frmFrontForm.submitForm(l,this)}
|
59 |
+
function frm_resend_email(l,n){console.warn("DEPRECATED: function frm_resend_email in v2.0");$link=jQuery(document.getElementById("frm_resend_email"));$link.append('<span class="spinner" style="display:inline"></span>');jQuery.ajax({type:"POST",url:frm_js.ajax_url,data:{action:"frm_entries_send_email",entry_id:l,form_id:n,nonce:frm_js.nonce},success:function(l){$link.replaceWith(l)}})};
|