@@ -2,26 +2,26 @@ discard block |
||
| 2 | 2 | |
| 3 | 3 | class FrmSettingsController { |
| 4 | 4 | |
| 5 | - public static function menu() { |
|
| 5 | + public static function menu() { |
|
| 6 | 6 | // Make sure admins can see the menu items |
| 7 | 7 | FrmAppHelper::force_capability( 'frm_change_settings' ); |
| 8 | 8 | |
| 9 | - add_submenu_page( 'formidable', 'Formidable | ' . __( 'Global Settings', 'formidable' ), __( 'Global Settings', 'formidable' ), 'frm_change_settings', 'formidable-settings', 'FrmSettingsController::route' ); |
|
| 10 | - } |
|
| 9 | + add_submenu_page( 'formidable', 'Formidable | ' . __( 'Global Settings', 'formidable' ), __( 'Global Settings', 'formidable' ), 'frm_change_settings', 'formidable-settings', 'FrmSettingsController::route' ); |
|
| 10 | + } |
|
| 11 | 11 | |
| 12 | - public static function license_box() { |
|
| 12 | + public static function license_box() { |
|
| 13 | 13 | $a = FrmAppHelper::simple_get( 't', 'sanitize_title', 'general_settings' ); |
| 14 | - include( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/license_box.php' ); |
|
| 15 | - } |
|
| 14 | + include( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/license_box.php' ); |
|
| 15 | + } |
|
| 16 | 16 | |
| 17 | - public static function display_form( $errors = array(), $message = '' ) { |
|
| 18 | - global $frm_vars; |
|
| 17 | + public static function display_form( $errors = array(), $message = '' ) { |
|
| 18 | + global $frm_vars; |
|
| 19 | 19 | |
| 20 | - $frm_settings = FrmAppHelper::get_settings(); |
|
| 21 | - $frm_roles = FrmAppHelper::frm_capabilities(); |
|
| 20 | + $frm_settings = FrmAppHelper::get_settings(); |
|
| 21 | + $frm_roles = FrmAppHelper::frm_capabilities(); |
|
| 22 | 22 | |
| 23 | - $uploads = wp_upload_dir(); |
|
| 24 | - $target_path = $uploads['basedir'] . '/formidable/css'; |
|
| 23 | + $uploads = wp_upload_dir(); |
|
| 24 | + $target_path = $uploads['basedir'] . '/formidable/css'; |
|
| 25 | 25 | |
| 26 | 26 | $sections = self::get_settings_tabs(); |
| 27 | 27 | |
@@ -64,47 +64,47 @@ discard block |
||
| 64 | 64 | wp_die(); |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | - public static function process_form( $stop_load = false ) { |
|
| 68 | - global $frm_vars; |
|
| 67 | + public static function process_form( $stop_load = false ) { |
|
| 68 | + global $frm_vars; |
|
| 69 | 69 | |
| 70 | - $frm_settings = FrmAppHelper::get_settings(); |
|
| 70 | + $frm_settings = FrmAppHelper::get_settings(); |
|
| 71 | 71 | |
| 72 | 72 | $process_form = FrmAppHelper::get_post_param( 'process_form', '', 'sanitize_text_field' ); |
| 73 | 73 | if ( ! wp_verify_nonce( $process_form, 'process_form_nonce' ) ) { |
| 74 | - wp_die( $frm_settings->admin_permission ); |
|
| 75 | - } |
|
| 74 | + wp_die( $frm_settings->admin_permission ); |
|
| 75 | + } |
|
| 76 | 76 | |
| 77 | - $errors = array(); |
|
| 78 | - $message = ''; |
|
| 77 | + $errors = array(); |
|
| 78 | + $message = ''; |
|
| 79 | 79 | |
| 80 | - if ( ! isset( $frm_vars['settings_routed'] ) || ! $frm_vars['settings_routed'] ) { |
|
| 81 | - $errors = $frm_settings->validate( $_POST, array() ); |
|
| 80 | + if ( ! isset( $frm_vars['settings_routed'] ) || ! $frm_vars['settings_routed'] ) { |
|
| 81 | + $errors = $frm_settings->validate( $_POST, array() ); |
|
| 82 | 82 | |
| 83 | - $frm_settings->update( stripslashes_deep( $_POST ) ); |
|
| 83 | + $frm_settings->update( stripslashes_deep( $_POST ) ); |
|
| 84 | 84 | |
| 85 | - if ( empty( $errors ) ) { |
|
| 86 | - $frm_settings->store(); |
|
| 87 | - $message = __( 'Settings Saved', 'formidable' ); |
|
| 88 | - } |
|
| 89 | - } else { |
|
| 90 | - $message = __( 'Settings Saved', 'formidable' ); |
|
| 91 | - } |
|
| 85 | + if ( empty( $errors ) ) { |
|
| 86 | + $frm_settings->store(); |
|
| 87 | + $message = __( 'Settings Saved', 'formidable' ); |
|
| 88 | + } |
|
| 89 | + } else { |
|
| 90 | + $message = __( 'Settings Saved', 'formidable' ); |
|
| 91 | + } |
|
| 92 | 92 | |
| 93 | 93 | if ( $stop_load == 'stop_load' ) { |
| 94 | - $frm_vars['settings_routed'] = true; |
|
| 95 | - return; |
|
| 96 | - } |
|
| 94 | + $frm_vars['settings_routed'] = true; |
|
| 95 | + return; |
|
| 96 | + } |
|
| 97 | 97 | |
| 98 | - self::display_form( $errors, $message ); |
|
| 99 | - } |
|
| 98 | + self::display_form( $errors, $message ); |
|
| 99 | + } |
|
| 100 | 100 | |
| 101 | - public static function route( $stop_load = false ) { |
|
| 102 | - $action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action'; |
|
| 101 | + public static function route( $stop_load = false ) { |
|
| 102 | + $action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action'; |
|
| 103 | 103 | $action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' ); |
| 104 | - if ( $action == 'process-form' ) { |
|
| 104 | + if ( $action == 'process-form' ) { |
|
| 105 | 105 | self::process_form( $stop_load ); |
| 106 | - } else if ( $stop_load != 'stop_load' ) { |
|
| 106 | + } else if ( $stop_load != 'stop_load' ) { |
|
| 107 | 107 | self::display_form(); |
| 108 | - } |
|
| 109 | - } |
|
| 108 | + } |
|
| 109 | + } |
|
| 110 | 110 | } |
@@ -45,16 +45,16 @@ |
||
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | public static function load_settings_tab() { |
| 48 | - FrmAppHelper::permission_check('frm_change_settings'); |
|
| 48 | + FrmAppHelper::permission_check( 'frm_change_settings' ); |
|
| 49 | 49 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 50 | 50 | |
| 51 | 51 | $section = FrmAppHelper::get_post_param( 'tab', '', 'sanitize_text_field' ); |
| 52 | 52 | $sections = self::get_settings_tabs(); |
| 53 | - if ( ! isset( $sections[ $section ] ) ) { |
|
| 53 | + if ( ! isset( $sections[$section] ) ) { |
|
| 54 | 54 | wp_die(); |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | - $section = $sections[ $section ]; |
|
| 57 | + $section = $sections[$section]; |
|
| 58 | 58 | |
| 59 | 59 | if ( isset( $section['class'] ) ) { |
| 60 | 60 | call_user_func( array( $section['class'], $section['function'] ) ); |
@@ -191,10 +191,10 @@ |
||
| 191 | 191 | } else { |
| 192 | 192 | call_user_func( ( isset( $section['function'] ) ? $section['function'] : $section ) ); |
| 193 | 193 | } |
| 194 | - } ?> |
|
| 194 | + } ?> |
|
| 195 | 195 | </div> |
| 196 | 196 | <?php |
| 197 | - } ?> |
|
| 197 | + } ?> |
|
| 198 | 198 | |
| 199 | 199 | <p class="alignright frm_uninstall"> |
| 200 | 200 | <a href="javascript:void(0)" id="frm_uninstall_now"><?php _e( 'Uninstall Formidable', 'formidable' ) ?></a> |
@@ -27,14 +27,14 @@ discard block |
||
| 27 | 27 | </ul> |
| 28 | 28 | </div> |
| 29 | 29 | |
| 30 | - <?php do_action('frm_before_settings'); ?> |
|
| 30 | + <?php do_action( 'frm_before_settings' ); ?> |
|
| 31 | 31 | |
| 32 | 32 | <form name="frm_settings_form" method="post" class="frm_settings_form" action="?page=formidable-settings<?php echo ( $a ? '&t=' . $a : '' ); ?>"> |
| 33 | 33 | <input type="hidden" name="frm_action" value="process-form" /> |
| 34 | 34 | <input type="hidden" name="action" value="process-form" /> |
| 35 | - <?php wp_nonce_field('process_form_nonce', 'process_form'); ?> |
|
| 35 | + <?php wp_nonce_field( 'process_form_nonce', 'process_form' ); ?> |
|
| 36 | 36 | |
| 37 | - <div class="general_settings tabs-panel <?php echo ($a == 'general_settings') ? 'frm_block' : 'frm_hidden'; ?>"> |
|
| 37 | + <div class="general_settings tabs-panel <?php echo ( $a == 'general_settings' ) ? 'frm_block' : 'frm_hidden'; ?>"> |
|
| 38 | 38 | <p class="submit"> |
| 39 | 39 | <input class="button-primary" type="submit" value="<?php esc_attr_e( 'Update Options', 'formidable' ) ?>" /> |
| 40 | 40 | </p> |
@@ -43,20 +43,20 @@ discard block |
||
| 43 | 43 | |
| 44 | 44 | <p><label class="frm_left_label"><?php _e( 'Load form styling', 'formidable' ) ?></label> |
| 45 | 45 | <select id="frm_load_style" name="frm_load_style"> |
| 46 | - <option value="all" <?php selected($frm_settings->load_style, 'all') ?>><?php _e( 'on every page of your site', 'formidable' ) ?></option> |
|
| 47 | - <option value="dynamic" <?php selected($frm_settings->load_style, 'dynamic') ?>><?php _e( 'only on applicable pages', 'formidable' ) ?></option> |
|
| 48 | - <option value="none" <?php selected($frm_settings->load_style, 'none') ?>><?php _e( 'Don\'t use form styling on any page', 'formidable' ) ?></option> |
|
| 46 | + <option value="all" <?php selected( $frm_settings->load_style, 'all' ) ?>><?php _e( 'on every page of your site', 'formidable' ) ?></option> |
|
| 47 | + <option value="dynamic" <?php selected( $frm_settings->load_style, 'dynamic' ) ?>><?php _e( 'only on applicable pages', 'formidable' ) ?></option> |
|
| 48 | + <option value="none" <?php selected( $frm_settings->load_style, 'none' ) ?>><?php _e( 'Don\'t use form styling on any page', 'formidable' ) ?></option> |
|
| 49 | 49 | </select> |
| 50 | 50 | </p> |
| 51 | 51 | |
| 52 | 52 | <p> |
| 53 | 53 | <label for="frm_use_html"> |
| 54 | - <input type="checkbox" id="frm_use_html" name="frm_use_html" value="1" <?php checked($frm_settings->use_html, 1) ?> > <?php _e( 'Use HTML5 in forms', 'formidable' ) ?> |
|
| 54 | + <input type="checkbox" id="frm_use_html" name="frm_use_html" value="1" <?php checked( $frm_settings->use_html, 1 ) ?> > <?php _e( 'Use HTML5 in forms', 'formidable' ) ?> |
|
| 55 | 55 | </label> |
| 56 | 56 | <span class="frm_help frm_icon_font frm_tooltip_icon" title="<?php esc_attr_e( 'We recommend using HTML 5 for your forms. It adds some nifty options like placeholders, patterns, and autocomplete.', 'formidable' ) ?>"></span> |
| 57 | 57 | </p> |
| 58 | 58 | |
| 59 | - <?php do_action('frm_style_general_settings', $frm_settings); ?> |
|
| 59 | + <?php do_action( 'frm_style_general_settings', $frm_settings ); ?> |
|
| 60 | 60 | |
| 61 | 61 | <h3><?php _e( 'User Permissions', 'formidable' ); ?> |
| 62 | 62 | <span class="frm_help frm_icon_font frm_tooltip_icon" title="<?php esc_attr_e( 'Select users that are allowed access to Formidable. Without access to View Forms, users will be unable to see the Formidable menu.', 'formidable' ) ?>"></span> |
@@ -80,10 +80,10 @@ discard block |
||
| 80 | 80 | </p> |
| 81 | 81 | |
| 82 | 82 | <p><label class="frm_left_label"><?php _e( 'Site Key', 'formidable' ) ?></label> |
| 83 | - <input type="text" name="frm_pubkey" id="frm_pubkey" size="42" value="<?php echo esc_attr($frm_settings->pubkey) ?>" placeholder="<?php esc_attr_e( 'Optional', 'formidable' ) ?>" /></p> |
|
| 83 | + <input type="text" name="frm_pubkey" id="frm_pubkey" size="42" value="<?php echo esc_attr( $frm_settings->pubkey ) ?>" placeholder="<?php esc_attr_e( 'Optional', 'formidable' ) ?>" /></p> |
|
| 84 | 84 | |
| 85 | 85 | <p><label class="frm_left_label"><?php _e( 'Secret Key', 'formidable' ) ?></label> |
| 86 | - <input type="text" name="frm_privkey" id="frm_privkey" size="42" value="<?php echo esc_attr($frm_settings->privkey) ?>" placeholder="<?php esc_attr_e( 'Optional', 'formidable' ) ?>" /></p> |
|
| 86 | + <input type="text" name="frm_privkey" id="frm_privkey" size="42" value="<?php echo esc_attr( $frm_settings->privkey ) ?>" placeholder="<?php esc_attr_e( 'Optional', 'formidable' ) ?>" /></p> |
|
| 87 | 87 | |
| 88 | 88 | <p><label class="frm_left_label"><?php _e( 'reCAPTCHA Type', 'formidable' ) ?></label> |
| 89 | 89 | <select name="frm_re_type" id="frm_re_type"> |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | <select name="frm_re_lang" id="frm_re_lang"> |
| 100 | 100 | <option value="" <?php selected( $frm_settings->re_lang, '' ) ?>><?php esc_html_e( 'Browser Default', 'formidable' ); ?></option> |
| 101 | 101 | <?php foreach ( $captcha_lang as $lang => $lang_name ) { ?> |
| 102 | - <option value="<?php echo esc_attr($lang) ?>" <?php selected($frm_settings->re_lang, $lang) ?>><?php echo esc_html( $lang_name ) ?></option> |
|
| 102 | + <option value="<?php echo esc_attr( $lang ) ?>" <?php selected( $frm_settings->re_lang, $lang ) ?>><?php echo esc_html( $lang_name ) ?></option> |
|
| 103 | 103 | <?php } ?> |
| 104 | 104 | </select></p> |
| 105 | 105 | |
@@ -152,7 +152,7 @@ discard block |
||
| 152 | 152 | <label class="frm_left_label"><?php _e( 'Success Message', 'formidable' ); ?> |
| 153 | 153 | <span class="frm_help frm_icon_font frm_tooltip_icon" title="<?php esc_attr_e( 'The default message seen after a form is submitted.', 'formidable' ) ?>" ></span> |
| 154 | 154 | </label> |
| 155 | - <input type="text" id="frm_success_msg" name="frm_success_msg" class="frm_with_left_label" value="<?php echo esc_attr($frm_settings->success_msg) ?>" /> |
|
| 155 | + <input type="text" id="frm_success_msg" name="frm_success_msg" class="frm_with_left_label" value="<?php echo esc_attr( $frm_settings->success_msg ) ?>" /> |
|
| 156 | 156 | </p> |
| 157 | 157 | |
| 158 | 158 | <p> |
@@ -160,7 +160,7 @@ discard block |
||
| 160 | 160 | <input type="text" value="<?php echo esc_attr( $frm_settings->submit_value ) ?>" id="frm_submit_value" name="frm_submit_value" class="frm_with_left_label" /> |
| 161 | 161 | </p> |
| 162 | 162 | |
| 163 | - <?php do_action('frm_settings_form', $frm_settings); ?> |
|
| 163 | + <?php do_action( 'frm_settings_form', $frm_settings ); ?> |
|
| 164 | 164 | |
| 165 | 165 | <?php if ( ! FrmAppHelper::pro_is_installed() ) { ?> |
| 166 | 166 | <div class="clear"></div> |
@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | <?php } ?> |
| 171 | 171 | |
| 172 | 172 | <p><label class="frm_left_label"><?php _e( 'Preview Page', 'formidable' ); ?></label> |
| 173 | - <?php FrmAppHelper::wp_pages_dropdown('frm-preview-page-id', $frm_settings->preview_page_id ) ?> |
|
| 173 | + <?php FrmAppHelper::wp_pages_dropdown( 'frm-preview-page-id', $frm_settings->preview_page_id ) ?> |
|
| 174 | 174 | </p> |
| 175 | 175 | |
| 176 | 176 | </div> |
@@ -2,70 +2,70 @@ discard block |
||
| 2 | 2 | |
| 3 | 3 | class FrmEntriesController { |
| 4 | 4 | |
| 5 | - public static function menu() { |
|
| 5 | + public static function menu() { |
|
| 6 | 6 | FrmAppHelper::force_capability( 'frm_view_entries' ); |
| 7 | 7 | |
| 8 | - add_submenu_page('formidable', 'Formidable | ' . __( 'Entries', 'formidable' ), __( 'Entries', 'formidable' ), 'frm_view_entries', 'formidable-entries', 'FrmEntriesController::route' ); |
|
| 8 | + add_submenu_page('formidable', 'Formidable | ' . __( 'Entries', 'formidable' ), __( 'Entries', 'formidable' ), 'frm_view_entries', 'formidable-entries', 'FrmEntriesController::route' ); |
|
| 9 | 9 | |
| 10 | 10 | if ( ! in_array( FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' ), array( 'edit', 'show' ) ) ) { |
| 11 | 11 | $menu_name = FrmAppHelper::get_menu_name(); |
| 12 | 12 | add_filter( 'manage_' . sanitize_title( $menu_name ) . '_page_formidable-entries_columns', 'FrmEntriesController::manage_columns' ); |
| 13 | 13 | add_filter( 'get_user_option_manage' . sanitize_title( $menu_name ) . '_page_formidable-entriescolumnshidden', 'FrmEntriesController::hidden_columns' ); |
| 14 | 14 | add_filter( 'manage_' . sanitize_title( $menu_name ) . '_page_formidable-entries_sortable_columns', 'FrmEntriesController::sortable_columns' ); |
| 15 | - } |
|
| 16 | - } |
|
| 15 | + } |
|
| 16 | + } |
|
| 17 | 17 | |
| 18 | - /* Display in Back End */ |
|
| 19 | - public static function route() { |
|
| 18 | + /* Display in Back End */ |
|
| 19 | + public static function route() { |
|
| 20 | 20 | $action = FrmAppHelper::get_param( 'frm_action', '', 'get', 'sanitize_title' ); |
| 21 | 21 | |
| 22 | - switch ( $action ) { |
|
| 23 | - case 'show': |
|
| 24 | - case 'destroy': |
|
| 25 | - case 'destroy_all': |
|
| 26 | - return self::$action(); |
|
| 22 | + switch ( $action ) { |
|
| 23 | + case 'show': |
|
| 24 | + case 'destroy': |
|
| 25 | + case 'destroy_all': |
|
| 26 | + return self::$action(); |
|
| 27 | 27 | |
| 28 | - default: |
|
| 29 | - do_action( 'frm_entry_action_route', $action ); |
|
| 30 | - if ( apply_filters( 'frm_entry_stop_action_route', false, $action ) ) { |
|
| 31 | - return; |
|
| 32 | - } |
|
| 28 | + default: |
|
| 29 | + do_action( 'frm_entry_action_route', $action ); |
|
| 30 | + if ( apply_filters( 'frm_entry_stop_action_route', false, $action ) ) { |
|
| 31 | + return; |
|
| 32 | + } |
|
| 33 | 33 | |
| 34 | - return self::display_list(); |
|
| 35 | - } |
|
| 36 | - } |
|
| 34 | + return self::display_list(); |
|
| 35 | + } |
|
| 36 | + } |
|
| 37 | 37 | |
| 38 | 38 | public static function contextual_help( $help, $screen_id, $screen ) { |
| 39 | - // Only add to certain screens. add_help_tab was introduced in WordPress 3.3 |
|
| 40 | - if ( ! method_exists( $screen, 'add_help_tab' ) ) { |
|
| 41 | - return $help; |
|
| 42 | - } |
|
| 39 | + // Only add to certain screens. add_help_tab was introduced in WordPress 3.3 |
|
| 40 | + if ( ! method_exists( $screen, 'add_help_tab' ) ) { |
|
| 41 | + return $help; |
|
| 42 | + } |
|
| 43 | 43 | |
| 44 | 44 | $action = FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' ); |
| 45 | 45 | $page = FrmAppHelper::simple_get( 'page', 'sanitize_title' ); |
| 46 | 46 | if ( $page != 'formidable-entries' || ( ! empty( $action ) && $action != 'list' ) ) { |
| 47 | - return $help; |
|
| 48 | - } |
|
| 47 | + return $help; |
|
| 48 | + } |
|
| 49 | 49 | |
| 50 | 50 | unset( $action, $page ); |
| 51 | 51 | |
| 52 | - $screen->add_help_tab( array( |
|
| 53 | - 'id' => 'formidable-entries-tab', |
|
| 54 | - 'title' => __( 'Overview', 'formidable' ), |
|
| 52 | + $screen->add_help_tab( array( |
|
| 53 | + 'id' => 'formidable-entries-tab', |
|
| 54 | + 'title' => __( 'Overview', 'formidable' ), |
|
| 55 | 55 | 'content' => '<p>' . esc_html__( 'This screen provides access to all of your entries. You can customize the display of this screen to suit your workflow.', 'formidable' ) . '</p> <p>' . esc_html__( 'Hovering over a row in the entries list will display action links that allow you to manage your entry.', 'formidable' ) . '</p>', |
| 56 | - )); |
|
| 56 | + )); |
|
| 57 | 57 | |
| 58 | - $screen->set_help_sidebar( |
|
| 58 | + $screen->set_help_sidebar( |
|
| 59 | 59 | '<p><strong>' . esc_html__( 'For more information:', 'formidable' ) . '</strong></p>' . |
| 60 | 60 | '<p><a href="' . esc_url( FrmAppHelper::make_affiliate_url( 'https://formidableforms.com/knowledgebase/manage-entries-from-the-back-end/' ) ) . '" target="_blank">' . esc_html__( 'Documentation on Entries', 'formidable' ) . '</a></p>' . |
| 61 | 61 | '<p><a href="' . esc_url( FrmAppHelper::make_affiliate_url( 'https://formidableforms.com/help-desk/' ) ) . '" target="_blank">' . esc_html__( 'Support', 'formidable' ) . '</a></p>' |
| 62 | - ); |
|
| 62 | + ); |
|
| 63 | 63 | |
| 64 | - return $help; |
|
| 65 | - } |
|
| 64 | + return $help; |
|
| 65 | + } |
|
| 66 | 66 | |
| 67 | 67 | public static function manage_columns( $columns ) { |
| 68 | - global $frm_vars; |
|
| 68 | + global $frm_vars; |
|
| 69 | 69 | $form_id = FrmForm::get_current_form_id(); |
| 70 | 70 | |
| 71 | 71 | $columns[ $form_id . '_id' ] = 'ID'; |
@@ -83,15 +83,15 @@ discard block |
||
| 83 | 83 | $columns[ $form_id . '_updated_at' ] = __( 'Entry update date', 'formidable' ); |
| 84 | 84 | $columns[ $form_id . '_ip' ] = 'IP'; |
| 85 | 85 | |
| 86 | - $frm_vars['cols'] = $columns; |
|
| 86 | + $frm_vars['cols'] = $columns; |
|
| 87 | 87 | |
| 88 | 88 | $action = FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' ); |
| 89 | 89 | if ( FrmAppHelper::is_admin_page( 'formidable-entries' ) && in_array( $action, array( '', 'list', 'destroy' ) ) ) { |
| 90 | 90 | add_screen_option( 'per_page', array( 'label' => __( 'Entries', 'formidable' ), 'default' => 20, 'option' => 'formidable_page_formidable_entries_per_page' ) ); |
| 91 | - } |
|
| 91 | + } |
|
| 92 | 92 | |
| 93 | - return $columns; |
|
| 94 | - } |
|
| 93 | + return $columns; |
|
| 94 | + } |
|
| 95 | 95 | |
| 96 | 96 | private static function get_columns_for_form( $form_id, &$columns ) { |
| 97 | 97 | $form_cols = FrmField::get_all_for_form( $form_id, '', 'include' ); |
@@ -135,76 +135,76 @@ discard block |
||
| 135 | 135 | $menu_name = FrmAppHelper::get_menu_name(); |
| 136 | 136 | $this_page_name = 'manage' . sanitize_title( $menu_name ) . '_page_formidable-entriescolumnshidden'; |
| 137 | 137 | if ( $meta_key != $this_page_name || $meta_value == $prev_value ) { |
| 138 | - return $check; |
|
| 139 | - } |
|
| 138 | + return $check; |
|
| 139 | + } |
|
| 140 | 140 | |
| 141 | 141 | if ( empty( $prev_value ) ) { |
| 142 | 142 | $prev_value = get_metadata( 'user', $object_id, $meta_key, true ); |
| 143 | 143 | } |
| 144 | 144 | |
| 145 | - global $frm_vars; |
|
| 146 | - //add a check so we don't create a loop |
|
| 147 | - $frm_vars['prev_hidden_cols'] = ( isset($frm_vars['prev_hidden_cols']) && $frm_vars['prev_hidden_cols'] ) ? false : $prev_value; |
|
| 145 | + global $frm_vars; |
|
| 146 | + //add a check so we don't create a loop |
|
| 147 | + $frm_vars['prev_hidden_cols'] = ( isset($frm_vars['prev_hidden_cols']) && $frm_vars['prev_hidden_cols'] ) ? false : $prev_value; |
|
| 148 | 148 | |
| 149 | - return $check; |
|
| 150 | - } |
|
| 149 | + return $check; |
|
| 150 | + } |
|
| 151 | 151 | |
| 152 | - //add hidden columns back from other forms |
|
| 152 | + //add hidden columns back from other forms |
|
| 153 | 153 | public static function update_hidden_cols( $meta_id, $object_id, $meta_key, $meta_value ) { |
| 154 | 154 | $menu_name = FrmAppHelper::get_menu_name(); |
| 155 | 155 | $sanitized = sanitize_title( $menu_name ); |
| 156 | 156 | $this_page_name = 'manage' . $sanitized . '_page_formidable-entriescolumnshidden'; |
| 157 | 157 | if ( $meta_key != $this_page_name ) { |
| 158 | - return; |
|
| 159 | - } |
|
| 160 | - |
|
| 161 | - global $frm_vars; |
|
| 162 | - if ( ! isset($frm_vars['prev_hidden_cols']) || ! $frm_vars['prev_hidden_cols'] ) { |
|
| 163 | - return; //don't continue if there's no previous value |
|
| 164 | - } |
|
| 165 | - |
|
| 166 | - foreach ( $meta_value as $mk => $mv ) { |
|
| 167 | - //remove blank values |
|
| 168 | - if ( empty( $mv ) ) { |
|
| 169 | - unset( $meta_value[ $mk ] ); |
|
| 170 | - } |
|
| 171 | - } |
|
| 172 | - |
|
| 173 | - $cur_form_prefix = reset($meta_value); |
|
| 174 | - $cur_form_prefix = explode('_', $cur_form_prefix); |
|
| 175 | - $cur_form_prefix = $cur_form_prefix[0]; |
|
| 176 | - $save = false; |
|
| 177 | - |
|
| 178 | - foreach ( (array) $frm_vars['prev_hidden_cols'] as $prev_hidden ) { |
|
| 158 | + return; |
|
| 159 | + } |
|
| 160 | + |
|
| 161 | + global $frm_vars; |
|
| 162 | + if ( ! isset($frm_vars['prev_hidden_cols']) || ! $frm_vars['prev_hidden_cols'] ) { |
|
| 163 | + return; //don't continue if there's no previous value |
|
| 164 | + } |
|
| 165 | + |
|
| 166 | + foreach ( $meta_value as $mk => $mv ) { |
|
| 167 | + //remove blank values |
|
| 168 | + if ( empty( $mv ) ) { |
|
| 169 | + unset( $meta_value[ $mk ] ); |
|
| 170 | + } |
|
| 171 | + } |
|
| 172 | + |
|
| 173 | + $cur_form_prefix = reset($meta_value); |
|
| 174 | + $cur_form_prefix = explode('_', $cur_form_prefix); |
|
| 175 | + $cur_form_prefix = $cur_form_prefix[0]; |
|
| 176 | + $save = false; |
|
| 177 | + |
|
| 178 | + foreach ( (array) $frm_vars['prev_hidden_cols'] as $prev_hidden ) { |
|
| 179 | 179 | if ( empty( $prev_hidden ) || in_array( $prev_hidden, $meta_value ) ) { |
| 180 | - //don't add blank cols or process included cols |
|
| 181 | - continue; |
|
| 182 | - } |
|
| 180 | + //don't add blank cols or process included cols |
|
| 181 | + continue; |
|
| 182 | + } |
|
| 183 | 183 | |
| 184 | 184 | $form_prefix = explode( '_', $prev_hidden ); |
| 185 | - $form_prefix = $form_prefix[0]; |
|
| 186 | - if ( $form_prefix == $cur_form_prefix ) { |
|
| 187 | - //don't add back columns that are meant to be hidden |
|
| 188 | - continue; |
|
| 189 | - } |
|
| 185 | + $form_prefix = $form_prefix[0]; |
|
| 186 | + if ( $form_prefix == $cur_form_prefix ) { |
|
| 187 | + //don't add back columns that are meant to be hidden |
|
| 188 | + continue; |
|
| 189 | + } |
|
| 190 | 190 | |
| 191 | - $meta_value[] = $prev_hidden; |
|
| 192 | - $save = true; |
|
| 193 | - unset($form_prefix); |
|
| 194 | - } |
|
| 191 | + $meta_value[] = $prev_hidden; |
|
| 192 | + $save = true; |
|
| 193 | + unset($form_prefix); |
|
| 194 | + } |
|
| 195 | 195 | |
| 196 | 196 | if ( $save ) { |
| 197 | - $user = wp_get_current_user(); |
|
| 197 | + $user = wp_get_current_user(); |
|
| 198 | 198 | update_user_option( $user->ID, $this_page_name, $meta_value, true ); |
| 199 | - } |
|
| 200 | - } |
|
| 199 | + } |
|
| 200 | + } |
|
| 201 | 201 | |
| 202 | 202 | public static function save_per_page( $save, $option, $value ) { |
| 203 | - if ( $option == 'formidable_page_formidable_entries_per_page' ) { |
|
| 204 | - $save = (int) $value; |
|
| 205 | - } |
|
| 206 | - return $save; |
|
| 207 | - } |
|
| 203 | + if ( $option == 'formidable_page_formidable_entries_per_page' ) { |
|
| 204 | + $save = (int) $value; |
|
| 205 | + } |
|
| 206 | + return $save; |
|
| 207 | + } |
|
| 208 | 208 | |
| 209 | 209 | public static function sortable_columns() { |
| 210 | 210 | $form_id = FrmForm::get_current_form_id(); |
@@ -230,46 +230,46 @@ discard block |
||
| 230 | 230 | } |
| 231 | 231 | |
| 232 | 232 | public static function hidden_columns( $result ) { |
| 233 | - global $frm_vars; |
|
| 233 | + global $frm_vars; |
|
| 234 | 234 | |
| 235 | 235 | $form_id = FrmForm::get_current_form_id(); |
| 236 | 236 | |
| 237 | - $return = false; |
|
| 238 | - foreach ( (array) $result as $r ) { |
|
| 239 | - if ( ! empty( $r ) ) { |
|
| 240 | - $form_prefix = explode( '_', $r ); |
|
| 241 | - $form_prefix = $form_prefix[0]; |
|
| 237 | + $return = false; |
|
| 238 | + foreach ( (array) $result as $r ) { |
|
| 239 | + if ( ! empty( $r ) ) { |
|
| 240 | + $form_prefix = explode( '_', $r ); |
|
| 241 | + $form_prefix = $form_prefix[0]; |
|
| 242 | 242 | |
| 243 | - if ( (int) $form_prefix == (int) $form_id ) { |
|
| 244 | - $return = true; |
|
| 245 | - break; |
|
| 246 | - } |
|
| 243 | + if ( (int) $form_prefix == (int) $form_id ) { |
|
| 244 | + $return = true; |
|
| 245 | + break; |
|
| 246 | + } |
|
| 247 | 247 | |
| 248 | - unset($form_prefix); |
|
| 249 | - } |
|
| 250 | - } |
|
| 248 | + unset($form_prefix); |
|
| 249 | + } |
|
| 250 | + } |
|
| 251 | 251 | |
| 252 | - if ( $return ) { |
|
| 252 | + if ( $return ) { |
|
| 253 | 253 | return $result; |
| 254 | 254 | } |
| 255 | 255 | |
| 256 | - $i = isset($frm_vars['cols']) ? count($frm_vars['cols']) : 0; |
|
| 257 | - $max_columns = 8; |
|
| 258 | - if ( $i <= $max_columns ) { |
|
| 256 | + $i = isset($frm_vars['cols']) ? count($frm_vars['cols']) : 0; |
|
| 257 | + $max_columns = 8; |
|
| 258 | + if ( $i <= $max_columns ) { |
|
| 259 | 259 | return $result; |
| 260 | 260 | } |
| 261 | 261 | |
| 262 | - global $frm_vars; |
|
| 263 | - if ( isset($frm_vars['current_form']) && $frm_vars['current_form'] ) { |
|
| 264 | - $frm_vars['current_form']->options = maybe_unserialize($frm_vars['current_form']->options); |
|
| 265 | - } |
|
| 262 | + global $frm_vars; |
|
| 263 | + if ( isset($frm_vars['current_form']) && $frm_vars['current_form'] ) { |
|
| 264 | + $frm_vars['current_form']->options = maybe_unserialize($frm_vars['current_form']->options); |
|
| 265 | + } |
|
| 266 | 266 | |
| 267 | 267 | $has_custom_hidden_columns = ( isset( $frm_vars['current_form'] ) && $frm_vars['current_form'] && isset( $frm_vars['current_form']->options['hidden_cols'] ) && ! empty( $frm_vars['current_form']->options['hidden_cols'] ) ); |
| 268 | 268 | if ( $has_custom_hidden_columns ) { |
| 269 | - $result = $frm_vars['current_form']->options['hidden_cols']; |
|
| 270 | - } else { |
|
| 271 | - $cols = $frm_vars['cols']; |
|
| 272 | - $cols = array_reverse($cols, true); |
|
| 269 | + $result = $frm_vars['current_form']->options['hidden_cols']; |
|
| 270 | + } else { |
|
| 271 | + $cols = $frm_vars['cols']; |
|
| 272 | + $cols = array_reverse($cols, true); |
|
| 273 | 273 | |
| 274 | 274 | if ( $form_id ) { |
| 275 | 275 | $result[] = $form_id . '_id'; |
@@ -277,59 +277,59 @@ discard block |
||
| 277 | 277 | } |
| 278 | 278 | |
| 279 | 279 | $result[] = $form_id . '_item_key'; |
| 280 | - $i--; |
|
| 280 | + $i--; |
|
| 281 | 281 | |
| 282 | 282 | foreach ( $cols as $col_key => $col ) { |
| 283 | - if ( $i > $max_columns ) { |
|
| 283 | + if ( $i > $max_columns ) { |
|
| 284 | 284 | $result[] = $col_key; |
| 285 | 285 | } |
| 286 | - //remove some columns by default |
|
| 287 | - $i--; |
|
| 288 | - unset($col_key, $col); |
|
| 289 | - } |
|
| 290 | - } |
|
| 286 | + //remove some columns by default |
|
| 287 | + $i--; |
|
| 288 | + unset($col_key, $col); |
|
| 289 | + } |
|
| 290 | + } |
|
| 291 | 291 | |
| 292 | - return $result; |
|
| 293 | - } |
|
| 292 | + return $result; |
|
| 293 | + } |
|
| 294 | 294 | |
| 295 | 295 | public static function display_list( $message = '', $errors = array() ) { |
| 296 | - global $wpdb, $frm_vars; |
|
| 296 | + global $wpdb, $frm_vars; |
|
| 297 | 297 | |
| 298 | 298 | $form = FrmForm::maybe_get_current_form(); |
| 299 | 299 | $params = FrmForm::get_admin_params( $form ); |
| 300 | 300 | |
| 301 | - if ( $form ) { |
|
| 302 | - $params['form'] = $form->id; |
|
| 303 | - $frm_vars['current_form'] = $form; |
|
| 301 | + if ( $form ) { |
|
| 302 | + $params['form'] = $form->id; |
|
| 303 | + $frm_vars['current_form'] = $form; |
|
| 304 | 304 | |
| 305 | 305 | self::get_delete_form_time( $form, $errors ); |
| 306 | 306 | } |
| 307 | 307 | |
| 308 | - $table_class = apply_filters( 'frm_entries_list_class', 'FrmEntriesListHelper' ); |
|
| 308 | + $table_class = apply_filters( 'frm_entries_list_class', 'FrmEntriesListHelper' ); |
|
| 309 | 309 | |
| 310 | - $wp_list_table = new $table_class( array( 'params' => $params ) ); |
|
| 310 | + $wp_list_table = new $table_class( array( 'params' => $params ) ); |
|
| 311 | 311 | |
| 312 | - $pagenum = $wp_list_table->get_pagenum(); |
|
| 312 | + $pagenum = $wp_list_table->get_pagenum(); |
|
| 313 | 313 | |
| 314 | - $wp_list_table->prepare_items(); |
|
| 314 | + $wp_list_table->prepare_items(); |
|
| 315 | 315 | |
| 316 | - $total_pages = $wp_list_table->get_pagination_arg( 'total_pages' ); |
|
| 317 | - if ( $pagenum > $total_pages && $total_pages > 0 ) { |
|
| 316 | + $total_pages = $wp_list_table->get_pagination_arg( 'total_pages' ); |
|
| 317 | + if ( $pagenum > $total_pages && $total_pages > 0 ) { |
|
| 318 | 318 | $url = add_query_arg( 'paged', $total_pages ); |
| 319 | - if ( headers_sent() ) { |
|
| 320 | - echo FrmAppHelper::js_redirect($url); |
|
| 321 | - } else { |
|
| 322 | - wp_redirect( esc_url_raw( $url ) ); |
|
| 323 | - } |
|
| 324 | - die(); |
|
| 325 | - } |
|
| 326 | - |
|
| 327 | - if ( empty($message) && isset($_GET['import-message']) ) { |
|
| 328 | - $message = __( 'Your import is complete', 'formidable' ); |
|
| 329 | - } |
|
| 319 | + if ( headers_sent() ) { |
|
| 320 | + echo FrmAppHelper::js_redirect($url); |
|
| 321 | + } else { |
|
| 322 | + wp_redirect( esc_url_raw( $url ) ); |
|
| 323 | + } |
|
| 324 | + die(); |
|
| 325 | + } |
|
| 326 | + |
|
| 327 | + if ( empty($message) && isset($_GET['import-message']) ) { |
|
| 328 | + $message = __( 'Your import is complete', 'formidable' ); |
|
| 329 | + } |
|
| 330 | 330 | |
| 331 | 331 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/list.php' ); |
| 332 | - } |
|
| 332 | + } |
|
| 333 | 333 | |
| 334 | 334 | private static function get_delete_form_time( $form, &$errors ) { |
| 335 | 335 | if ( 'trash' == $form->status ) { |
@@ -339,19 +339,19 @@ discard block |
||
| 339 | 339 | } |
| 340 | 340 | } |
| 341 | 341 | |
| 342 | - /* Back End CRUD */ |
|
| 342 | + /* Back End CRUD */ |
|
| 343 | 343 | public static function show( $id = 0 ) { |
| 344 | - FrmAppHelper::permission_check('frm_view_entries'); |
|
| 344 | + FrmAppHelper::permission_check('frm_view_entries'); |
|
| 345 | 345 | |
| 346 | - if ( ! $id ) { |
|
| 346 | + if ( ! $id ) { |
|
| 347 | 347 | $id = FrmAppHelper::get_param( 'id', 0, 'get', 'absint' ); |
| 348 | 348 | |
| 349 | - if ( ! $id ) { |
|
| 349 | + if ( ! $id ) { |
|
| 350 | 350 | $id = FrmAppHelper::get_param( 'item_id', 0, 'get', 'absint' ); |
| 351 | - } |
|
| 352 | - } |
|
| 351 | + } |
|
| 352 | + } |
|
| 353 | 353 | |
| 354 | - $entry = FrmEntry::getOne($id, true); |
|
| 354 | + $entry = FrmEntry::getOne($id, true); |
|
| 355 | 355 | if ( ! $entry ) { |
| 356 | 356 | echo '<div id="form_show_entry_page" class="wrap">' . |
| 357 | 357 | __( 'You are trying to view an entry that does not exist.', 'formidable' ) . |
@@ -359,110 +359,110 @@ discard block |
||
| 359 | 359 | return; |
| 360 | 360 | } |
| 361 | 361 | |
| 362 | - $data = maybe_unserialize($entry->description); |
|
| 362 | + $data = maybe_unserialize($entry->description); |
|
| 363 | 363 | if ( ! is_array( $data ) || ! isset( $data['referrer'] ) ) { |
| 364 | 364 | $data = array( 'referrer' => $data ); |
| 365 | 365 | } |
| 366 | 366 | |
| 367 | 367 | $fields = FrmField::get_all_for_form( $entry->form_id, '', 'include' ); |
| 368 | - $to_emails = array(); |
|
| 368 | + $to_emails = array(); |
|
| 369 | 369 | |
| 370 | 370 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/show.php' ); |
| 371 | - } |
|
| 371 | + } |
|
| 372 | 372 | |
| 373 | - public static function destroy() { |
|
| 374 | - FrmAppHelper::permission_check('frm_delete_entries'); |
|
| 373 | + public static function destroy() { |
|
| 374 | + FrmAppHelper::permission_check('frm_delete_entries'); |
|
| 375 | 375 | |
| 376 | 376 | $params = FrmForm::get_admin_params(); |
| 377 | 377 | |
| 378 | - if ( isset($params['keep_post']) && $params['keep_post'] ) { |
|
| 379 | - //unlink entry from post |
|
| 380 | - global $wpdb; |
|
| 378 | + if ( isset($params['keep_post']) && $params['keep_post'] ) { |
|
| 379 | + //unlink entry from post |
|
| 380 | + global $wpdb; |
|
| 381 | 381 | $wpdb->update( $wpdb->prefix . 'frm_items', array( 'post_id' => '' ), array( 'id' => $params['id'] ) ); |
| 382 | - } |
|
| 382 | + } |
|
| 383 | 383 | |
| 384 | - $message = ''; |
|
| 385 | - if ( FrmEntry::destroy( $params['id'] ) ) { |
|
| 386 | - $message = __( 'Entry was Successfully Destroyed', 'formidable' ); |
|
| 387 | - } |
|
| 384 | + $message = ''; |
|
| 385 | + if ( FrmEntry::destroy( $params['id'] ) ) { |
|
| 386 | + $message = __( 'Entry was Successfully Destroyed', 'formidable' ); |
|
| 387 | + } |
|
| 388 | 388 | |
| 389 | - self::display_list( $message ); |
|
| 390 | - } |
|
| 389 | + self::display_list( $message ); |
|
| 390 | + } |
|
| 391 | 391 | |
| 392 | - public static function destroy_all() { |
|
| 393 | - if ( ! current_user_can( 'frm_delete_entries' ) ) { |
|
| 394 | - $frm_settings = FrmAppHelper::get_settings(); |
|
| 395 | - wp_die( $frm_settings->admin_permission ); |
|
| 396 | - } |
|
| 392 | + public static function destroy_all() { |
|
| 393 | + if ( ! current_user_can( 'frm_delete_entries' ) ) { |
|
| 394 | + $frm_settings = FrmAppHelper::get_settings(); |
|
| 395 | + wp_die( $frm_settings->admin_permission ); |
|
| 396 | + } |
|
| 397 | 397 | |
| 398 | - global $wpdb; |
|
| 398 | + global $wpdb; |
|
| 399 | 399 | $params = FrmForm::get_admin_params(); |
| 400 | - $message = ''; |
|
| 401 | - $errors = array(); |
|
| 402 | - $form_id = (int) $params['form']; |
|
| 400 | + $message = ''; |
|
| 401 | + $errors = array(); |
|
| 402 | + $form_id = (int) $params['form']; |
|
| 403 | 403 | |
| 404 | - if ( $form_id ) { |
|
| 405 | - $entry_ids = FrmDb::get_col( 'frm_items', array( 'form_id' => $form_id ) ); |
|
| 404 | + if ( $form_id ) { |
|
| 405 | + $entry_ids = FrmDb::get_col( 'frm_items', array( 'form_id' => $form_id ) ); |
|
| 406 | 406 | $action = FrmFormAction::get_action_for_form( $form_id, 'wppost', 1 ); |
| 407 | 407 | |
| 408 | - if ( $action ) { |
|
| 409 | - // this action takes a while, so only trigger it if there are posts to delete |
|
| 410 | - foreach ( $entry_ids as $entry_id ) { |
|
| 411 | - do_action( 'frm_before_destroy_entry', $entry_id ); |
|
| 412 | - unset( $entry_id ); |
|
| 413 | - } |
|
| 414 | - } |
|
| 415 | - |
|
| 416 | - $wpdb->query( $wpdb->prepare( "DELETE em.* FROM {$wpdb->prefix}frm_item_metas as em INNER JOIN {$wpdb->prefix}frm_items as e on (em.item_id=e.id) and form_id=%d", $form_id ) ); |
|
| 417 | - $results = $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}frm_items WHERE form_id=%d", $form_id ) ); |
|
| 418 | - if ( $results ) { |
|
| 408 | + if ( $action ) { |
|
| 409 | + // this action takes a while, so only trigger it if there are posts to delete |
|
| 410 | + foreach ( $entry_ids as $entry_id ) { |
|
| 411 | + do_action( 'frm_before_destroy_entry', $entry_id ); |
|
| 412 | + unset( $entry_id ); |
|
| 413 | + } |
|
| 414 | + } |
|
| 415 | + |
|
| 416 | + $wpdb->query( $wpdb->prepare( "DELETE em.* FROM {$wpdb->prefix}frm_item_metas as em INNER JOIN {$wpdb->prefix}frm_items as e on (em.item_id=e.id) and form_id=%d", $form_id ) ); |
|
| 417 | + $results = $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}frm_items WHERE form_id=%d", $form_id ) ); |
|
| 418 | + if ( $results ) { |
|
| 419 | 419 | FrmEntry::clear_cache(); |
| 420 | - $message = __( 'Entries were Successfully Destroyed', 'formidable' ); |
|
| 421 | - } |
|
| 422 | - } else { |
|
| 423 | - $errors = __( 'No entries were specified', 'formidable' ); |
|
| 424 | - } |
|
| 425 | - |
|
| 426 | - self::display_list( $message, $errors ); |
|
| 427 | - } |
|
| 428 | - |
|
| 429 | - public static function show_form( $id = '', $key = '', $title = false, $description = false ) { |
|
| 430 | - _deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::show_form()' ); |
|
| 431 | - return FrmFormsController::show_form( $id, $key, $title, $description ); |
|
| 432 | - } |
|
| 433 | - |
|
| 434 | - public static function get_form( $filename, $form, $title, $description ) { |
|
| 435 | - _deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::get_form()' ); |
|
| 436 | - return FrmFormsController::get_form( $form, $title, $description ); |
|
| 437 | - } |
|
| 438 | - |
|
| 439 | - public static function process_entry( $errors = '', $ajax = false ) { |
|
| 420 | + $message = __( 'Entries were Successfully Destroyed', 'formidable' ); |
|
| 421 | + } |
|
| 422 | + } else { |
|
| 423 | + $errors = __( 'No entries were specified', 'formidable' ); |
|
| 424 | + } |
|
| 425 | + |
|
| 426 | + self::display_list( $message, $errors ); |
|
| 427 | + } |
|
| 428 | + |
|
| 429 | + public static function show_form( $id = '', $key = '', $title = false, $description = false ) { |
|
| 430 | + _deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::show_form()' ); |
|
| 431 | + return FrmFormsController::show_form( $id, $key, $title, $description ); |
|
| 432 | + } |
|
| 433 | + |
|
| 434 | + public static function get_form( $filename, $form, $title, $description ) { |
|
| 435 | + _deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::get_form()' ); |
|
| 436 | + return FrmFormsController::get_form( $form, $title, $description ); |
|
| 437 | + } |
|
| 438 | + |
|
| 439 | + public static function process_entry( $errors = '', $ajax = false ) { |
|
| 440 | 440 | $form_id = FrmAppHelper::get_post_param( 'form_id', '', 'absint' ); |
| 441 | 441 | if ( FrmAppHelper::is_admin() || empty( $_POST ) || empty( $form_id ) || ! isset( $_POST['item_key'] ) ) { |
| 442 | - return; |
|
| 443 | - } |
|
| 442 | + return; |
|
| 443 | + } |
|
| 444 | 444 | |
| 445 | - global $frm_vars; |
|
| 445 | + global $frm_vars; |
|
| 446 | 446 | |
| 447 | 447 | $form = FrmForm::getOne( $form_id ); |
| 448 | - if ( ! $form ) { |
|
| 449 | - return; |
|
| 450 | - } |
|
| 448 | + if ( ! $form ) { |
|
| 449 | + return; |
|
| 450 | + } |
|
| 451 | 451 | |
| 452 | 452 | $params = FrmForm::get_params( $form ); |
| 453 | 453 | |
| 454 | - if ( ! isset( $frm_vars['form_params'] ) ) { |
|
| 455 | - $frm_vars['form_params'] = array(); |
|
| 456 | - } |
|
| 454 | + if ( ! isset( $frm_vars['form_params'] ) ) { |
|
| 455 | + $frm_vars['form_params'] = array(); |
|
| 456 | + } |
|
| 457 | 457 | $frm_vars['form_params'][ $form->id ] = $params; |
| 458 | 458 | |
| 459 | 459 | if ( isset( $frm_vars['created_entries'][ $form_id ] ) ) { |
| 460 | - return; |
|
| 461 | - } |
|
| 460 | + return; |
|
| 461 | + } |
|
| 462 | 462 | |
| 463 | - if ( $errors == '' && ! $ajax ) { |
|
| 463 | + if ( $errors == '' && ! $ajax ) { |
|
| 464 | 464 | $errors = FrmEntryValidate::validate( $_POST ); |
| 465 | - } |
|
| 465 | + } |
|
| 466 | 466 | |
| 467 | 467 | /** |
| 468 | 468 | * Use this filter to add trigger actions and add errors after |
@@ -473,39 +473,39 @@ discard block |
||
| 473 | 473 | |
| 474 | 474 | $frm_vars['created_entries'][ $form_id ] = array( 'errors' => $errors ); |
| 475 | 475 | |
| 476 | - if ( empty( $errors ) ) { |
|
| 476 | + if ( empty( $errors ) ) { |
|
| 477 | 477 | $_POST['frm_skip_cookie'] = 1; |
| 478 | - if ( $params['action'] == 'create' ) { |
|
| 478 | + if ( $params['action'] == 'create' ) { |
|
| 479 | 479 | if ( apply_filters( 'frm_continue_to_create', true, $form_id ) && ! isset( $frm_vars['created_entries'][ $form_id ]['entry_id'] ) ) { |
| 480 | 480 | $frm_vars['created_entries'][ $form_id ]['entry_id'] = FrmEntry::create( $_POST ); |
| 481 | - } |
|
| 482 | - } |
|
| 481 | + } |
|
| 482 | + } |
|
| 483 | 483 | |
| 484 | - do_action( 'frm_process_entry', $params, $errors, $form, array( 'ajax' => $ajax ) ); |
|
| 484 | + do_action( 'frm_process_entry', $params, $errors, $form, array( 'ajax' => $ajax ) ); |
|
| 485 | 485 | unset( $_POST['frm_skip_cookie'] ); |
| 486 | - } |
|
| 487 | - } |
|
| 488 | - |
|
| 489 | - public static function delete_entry_before_redirect( $url, $form, $atts ) { |
|
| 490 | - self::_delete_entry( $atts['id'], $form ); |
|
| 491 | - return $url; |
|
| 492 | - } |
|
| 493 | - |
|
| 494 | - //Delete entry if not redirected |
|
| 495 | - public static function delete_entry_after_save( $atts ) { |
|
| 496 | - self::_delete_entry( $atts['entry_id'], $atts['form'] ); |
|
| 497 | - } |
|
| 498 | - |
|
| 499 | - private static function _delete_entry( $entry_id, $form ) { |
|
| 500 | - if ( ! $form ) { |
|
| 501 | - return; |
|
| 502 | - } |
|
| 503 | - |
|
| 504 | - $form->options = maybe_unserialize( $form->options ); |
|
| 505 | - if ( isset( $form->options['no_save'] ) && $form->options['no_save'] ) { |
|
| 506 | - FrmEntry::destroy( $entry_id ); |
|
| 507 | - } |
|
| 508 | - } |
|
| 486 | + } |
|
| 487 | + } |
|
| 488 | + |
|
| 489 | + public static function delete_entry_before_redirect( $url, $form, $atts ) { |
|
| 490 | + self::_delete_entry( $atts['id'], $form ); |
|
| 491 | + return $url; |
|
| 492 | + } |
|
| 493 | + |
|
| 494 | + //Delete entry if not redirected |
|
| 495 | + public static function delete_entry_after_save( $atts ) { |
|
| 496 | + self::_delete_entry( $atts['entry_id'], $atts['form'] ); |
|
| 497 | + } |
|
| 498 | + |
|
| 499 | + private static function _delete_entry( $entry_id, $form ) { |
|
| 500 | + if ( ! $form ) { |
|
| 501 | + return; |
|
| 502 | + } |
|
| 503 | + |
|
| 504 | + $form->options = maybe_unserialize( $form->options ); |
|
| 505 | + if ( isset( $form->options['no_save'] ) && $form->options['no_save'] ) { |
|
| 506 | + FrmEntry::destroy( $entry_id ); |
|
| 507 | + } |
|
| 508 | + } |
|
| 509 | 509 | |
| 510 | 510 | /** |
| 511 | 511 | * @param $atts |
@@ -560,15 +560,15 @@ discard block |
||
| 560 | 560 | } |
| 561 | 561 | |
| 562 | 562 | public static function entry_sidebar( $entry ) { |
| 563 | - $data = maybe_unserialize($entry->description); |
|
| 564 | - $date_format = get_option('date_format'); |
|
| 565 | - $time_format = get_option('time_format'); |
|
| 563 | + $data = maybe_unserialize($entry->description); |
|
| 564 | + $date_format = get_option('date_format'); |
|
| 565 | + $time_format = get_option('time_format'); |
|
| 566 | 566 | if ( isset( $data['browser'] ) ) { |
| 567 | 567 | $browser = FrmEntriesHelper::get_browser( $data['browser'] ); |
| 568 | 568 | } |
| 569 | 569 | |
| 570 | 570 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/sidebar-shared.php' ); |
| 571 | - } |
|
| 571 | + } |
|
| 572 | 572 | |
| 573 | 573 | /*********************************************************************** |
| 574 | 574 | * Deprecated Functions |
@@ -5,7 +5,7 @@ discard block |
||
| 5 | 5 | public static function menu() { |
| 6 | 6 | FrmAppHelper::force_capability( 'frm_view_entries' ); |
| 7 | 7 | |
| 8 | - add_submenu_page('formidable', 'Formidable | ' . __( 'Entries', 'formidable' ), __( 'Entries', 'formidable' ), 'frm_view_entries', 'formidable-entries', 'FrmEntriesController::route' ); |
|
| 8 | + add_submenu_page( 'formidable', 'Formidable | ' . __( 'Entries', 'formidable' ), __( 'Entries', 'formidable' ), 'frm_view_entries', 'formidable-entries', 'FrmEntriesController::route' ); |
|
| 9 | 9 | |
| 10 | 10 | if ( ! in_array( FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' ), array( 'edit', 'show' ) ) ) { |
| 11 | 11 | $menu_name = FrmAppHelper::get_menu_name(); |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | 'id' => 'formidable-entries-tab', |
| 54 | 54 | 'title' => __( 'Overview', 'formidable' ), |
| 55 | 55 | 'content' => '<p>' . esc_html__( 'This screen provides access to all of your entries. You can customize the display of this screen to suit your workflow.', 'formidable' ) . '</p> <p>' . esc_html__( 'Hovering over a row in the entries list will display action links that allow you to manage your entry.', 'formidable' ) . '</p>', |
| 56 | - )); |
|
| 56 | + ) ); |
|
| 57 | 57 | |
| 58 | 58 | $screen->set_help_sidebar( |
| 59 | 59 | '<p><strong>' . esc_html__( 'For more information:', 'formidable' ) . '</strong></p>' . |
@@ -68,20 +68,20 @@ discard block |
||
| 68 | 68 | global $frm_vars; |
| 69 | 69 | $form_id = FrmForm::get_current_form_id(); |
| 70 | 70 | |
| 71 | - $columns[ $form_id . '_id' ] = 'ID'; |
|
| 72 | - $columns[ $form_id . '_item_key' ] = esc_html__( 'Entry Key', 'formidable' ); |
|
| 71 | + $columns[$form_id . '_id'] = 'ID'; |
|
| 72 | + $columns[$form_id . '_item_key'] = esc_html__( 'Entry Key', 'formidable' ); |
|
| 73 | 73 | |
| 74 | 74 | if ( $form_id ) { |
| 75 | 75 | self::get_columns_for_form( $form_id, $columns ); |
| 76 | 76 | } else { |
| 77 | - $columns[ $form_id . '_form_id' ] = __( 'Form', 'formidable' ); |
|
| 78 | - $columns[ $form_id . '_name' ] = __( 'Entry Name', 'formidable' ); |
|
| 79 | - $columns[ $form_id . '_user_id' ] = __( 'Created By', 'formidable' ); |
|
| 77 | + $columns[$form_id . '_form_id'] = __( 'Form', 'formidable' ); |
|
| 78 | + $columns[$form_id . '_name'] = __( 'Entry Name', 'formidable' ); |
|
| 79 | + $columns[$form_id . '_user_id'] = __( 'Created By', 'formidable' ); |
|
| 80 | 80 | } |
| 81 | 81 | |
| 82 | - $columns[ $form_id . '_created_at' ] = __( 'Entry creation date', 'formidable' ); |
|
| 83 | - $columns[ $form_id . '_updated_at' ] = __( 'Entry update date', 'formidable' ); |
|
| 84 | - $columns[ $form_id . '_ip' ] = 'IP'; |
|
| 82 | + $columns[$form_id . '_created_at'] = __( 'Entry creation date', 'formidable' ); |
|
| 83 | + $columns[$form_id . '_updated_at'] = __( 'Entry update date', 'formidable' ); |
|
| 84 | + $columns[$form_id . '_ip'] = 'IP'; |
|
| 85 | 85 | |
| 86 | 86 | $frm_vars['cols'] = $columns; |
| 87 | 87 | |
@@ -107,14 +107,14 @@ discard block |
||
| 107 | 107 | if ( $sub_form_cols ) { |
| 108 | 108 | foreach ( $sub_form_cols as $k => $sub_form_col ) { |
| 109 | 109 | if ( FrmField::is_no_save_field( $sub_form_col->type ) ) { |
| 110 | - unset( $sub_form_cols[ $k ] ); |
|
| 110 | + unset( $sub_form_cols[$k] ); |
|
| 111 | 111 | continue; |
| 112 | 112 | } |
| 113 | - $columns[ $form_id . '_' . $sub_form_col->field_key . '-_-' . $form_col->id ] = FrmAppHelper::truncate( $sub_form_col->name, 35 ); |
|
| 114 | - unset($sub_form_col); |
|
| 113 | + $columns[$form_id . '_' . $sub_form_col->field_key . '-_-' . $form_col->id] = FrmAppHelper::truncate( $sub_form_col->name, 35 ); |
|
| 114 | + unset( $sub_form_col ); |
|
| 115 | 115 | } |
| 116 | 116 | } |
| 117 | - unset($sub_form_cols); |
|
| 117 | + unset( $sub_form_cols ); |
|
| 118 | 118 | } else { |
| 119 | 119 | $col_id = $form_col->field_key; |
| 120 | 120 | if ( $form_col->form_id != $form_id ) { |
@@ -124,9 +124,9 @@ discard block |
||
| 124 | 124 | $has_separate_value = ! FrmField::is_option_empty( $form_col, 'separate_value' ); |
| 125 | 125 | $is_post_status = FrmField::is_option_true( $form_col, 'post_field' ) && $form_col->field_options['post_field'] == 'post_status'; |
| 126 | 126 | if ( $has_separate_value && ! $is_post_status ) { |
| 127 | - $columns[ $form_id . '_frmsep_' . $col_id ] = FrmAppHelper::truncate( $form_col->name, 35 ); |
|
| 127 | + $columns[$form_id . '_frmsep_' . $col_id] = FrmAppHelper::truncate( $form_col->name, 35 ); |
|
| 128 | 128 | } |
| 129 | - $columns[ $form_id . '_' . $col_id ] = FrmAppHelper::truncate( $form_col->name, 35 ); |
|
| 129 | + $columns[$form_id . '_' . $col_id] = FrmAppHelper::truncate( $form_col->name, 35 ); |
|
| 130 | 130 | } |
| 131 | 131 | } |
| 132 | 132 | } |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | |
| 145 | 145 | global $frm_vars; |
| 146 | 146 | //add a check so we don't create a loop |
| 147 | - $frm_vars['prev_hidden_cols'] = ( isset($frm_vars['prev_hidden_cols']) && $frm_vars['prev_hidden_cols'] ) ? false : $prev_value; |
|
| 147 | + $frm_vars['prev_hidden_cols'] = ( isset( $frm_vars['prev_hidden_cols'] ) && $frm_vars['prev_hidden_cols'] ) ? false : $prev_value; |
|
| 148 | 148 | |
| 149 | 149 | return $check; |
| 150 | 150 | } |
@@ -159,19 +159,19 @@ discard block |
||
| 159 | 159 | } |
| 160 | 160 | |
| 161 | 161 | global $frm_vars; |
| 162 | - if ( ! isset($frm_vars['prev_hidden_cols']) || ! $frm_vars['prev_hidden_cols'] ) { |
|
| 162 | + if ( ! isset( $frm_vars['prev_hidden_cols'] ) || ! $frm_vars['prev_hidden_cols'] ) { |
|
| 163 | 163 | return; //don't continue if there's no previous value |
| 164 | 164 | } |
| 165 | 165 | |
| 166 | 166 | foreach ( $meta_value as $mk => $mv ) { |
| 167 | 167 | //remove blank values |
| 168 | 168 | if ( empty( $mv ) ) { |
| 169 | - unset( $meta_value[ $mk ] ); |
|
| 169 | + unset( $meta_value[$mk] ); |
|
| 170 | 170 | } |
| 171 | 171 | } |
| 172 | 172 | |
| 173 | - $cur_form_prefix = reset($meta_value); |
|
| 174 | - $cur_form_prefix = explode('_', $cur_form_prefix); |
|
| 173 | + $cur_form_prefix = reset( $meta_value ); |
|
| 174 | + $cur_form_prefix = explode( '_', $cur_form_prefix ); |
|
| 175 | 175 | $cur_form_prefix = $cur_form_prefix[0]; |
| 176 | 176 | $save = false; |
| 177 | 177 | |
@@ -190,7 +190,7 @@ discard block |
||
| 190 | 190 | |
| 191 | 191 | $meta_value[] = $prev_hidden; |
| 192 | 192 | $save = true; |
| 193 | - unset($form_prefix); |
|
| 193 | + unset( $form_prefix ); |
|
| 194 | 194 | } |
| 195 | 195 | |
| 196 | 196 | if ( $save ) { |
@@ -222,7 +222,7 @@ discard block |
||
| 222 | 222 | foreach ( $fields as $field ) { |
| 223 | 223 | if ( $field->type != 'checkbox' && ( ! isset( $field->field_options['post_field'] ) || $field->field_options['post_field'] == '' ) ) { |
| 224 | 224 | // Can't sort on checkboxes because they are stored serialized, or post fields |
| 225 | - $columns[ $form_id . '_' . $field->field_key ] = 'meta_' . $field->id; |
|
| 225 | + $columns[$form_id . '_' . $field->field_key] = 'meta_' . $field->id; |
|
| 226 | 226 | } |
| 227 | 227 | } |
| 228 | 228 | |
@@ -245,7 +245,7 @@ discard block |
||
| 245 | 245 | break; |
| 246 | 246 | } |
| 247 | 247 | |
| 248 | - unset($form_prefix); |
|
| 248 | + unset( $form_prefix ); |
|
| 249 | 249 | } |
| 250 | 250 | } |
| 251 | 251 | |
@@ -253,15 +253,15 @@ discard block |
||
| 253 | 253 | return $result; |
| 254 | 254 | } |
| 255 | 255 | |
| 256 | - $i = isset($frm_vars['cols']) ? count($frm_vars['cols']) : 0; |
|
| 256 | + $i = isset( $frm_vars['cols'] ) ? count( $frm_vars['cols'] ) : 0; |
|
| 257 | 257 | $max_columns = 8; |
| 258 | 258 | if ( $i <= $max_columns ) { |
| 259 | 259 | return $result; |
| 260 | 260 | } |
| 261 | 261 | |
| 262 | 262 | global $frm_vars; |
| 263 | - if ( isset($frm_vars['current_form']) && $frm_vars['current_form'] ) { |
|
| 264 | - $frm_vars['current_form']->options = maybe_unserialize($frm_vars['current_form']->options); |
|
| 263 | + if ( isset( $frm_vars['current_form'] ) && $frm_vars['current_form'] ) { |
|
| 264 | + $frm_vars['current_form']->options = maybe_unserialize( $frm_vars['current_form']->options ); |
|
| 265 | 265 | } |
| 266 | 266 | |
| 267 | 267 | $has_custom_hidden_columns = ( isset( $frm_vars['current_form'] ) && $frm_vars['current_form'] && isset( $frm_vars['current_form']->options['hidden_cols'] ) && ! empty( $frm_vars['current_form']->options['hidden_cols'] ) ); |
@@ -269,23 +269,23 @@ discard block |
||
| 269 | 269 | $result = $frm_vars['current_form']->options['hidden_cols']; |
| 270 | 270 | } else { |
| 271 | 271 | $cols = $frm_vars['cols']; |
| 272 | - $cols = array_reverse($cols, true); |
|
| 272 | + $cols = array_reverse( $cols, true ); |
|
| 273 | 273 | |
| 274 | 274 | if ( $form_id ) { |
| 275 | 275 | $result[] = $form_id . '_id'; |
| 276 | - $i--; |
|
| 276 | + $i --; |
|
| 277 | 277 | } |
| 278 | 278 | |
| 279 | 279 | $result[] = $form_id . '_item_key'; |
| 280 | - $i--; |
|
| 280 | + $i --; |
|
| 281 | 281 | |
| 282 | 282 | foreach ( $cols as $col_key => $col ) { |
| 283 | 283 | if ( $i > $max_columns ) { |
| 284 | 284 | $result[] = $col_key; |
| 285 | 285 | } |
| 286 | 286 | //remove some columns by default |
| 287 | - $i--; |
|
| 288 | - unset($col_key, $col); |
|
| 287 | + $i --; |
|
| 288 | + unset( $col_key, $col ); |
|
| 289 | 289 | } |
| 290 | 290 | } |
| 291 | 291 | |
@@ -317,14 +317,14 @@ discard block |
||
| 317 | 317 | if ( $pagenum > $total_pages && $total_pages > 0 ) { |
| 318 | 318 | $url = add_query_arg( 'paged', $total_pages ); |
| 319 | 319 | if ( headers_sent() ) { |
| 320 | - echo FrmAppHelper::js_redirect($url); |
|
| 320 | + echo FrmAppHelper::js_redirect( $url ); |
|
| 321 | 321 | } else { |
| 322 | 322 | wp_redirect( esc_url_raw( $url ) ); |
| 323 | 323 | } |
| 324 | 324 | die(); |
| 325 | 325 | } |
| 326 | 326 | |
| 327 | - if ( empty($message) && isset($_GET['import-message']) ) { |
|
| 327 | + if ( empty( $message ) && isset( $_GET['import-message'] ) ) { |
|
| 328 | 328 | $message = __( 'Your import is complete', 'formidable' ); |
| 329 | 329 | } |
| 330 | 330 | |
@@ -341,7 +341,7 @@ discard block |
||
| 341 | 341 | |
| 342 | 342 | /* Back End CRUD */ |
| 343 | 343 | public static function show( $id = 0 ) { |
| 344 | - FrmAppHelper::permission_check('frm_view_entries'); |
|
| 344 | + FrmAppHelper::permission_check( 'frm_view_entries' ); |
|
| 345 | 345 | |
| 346 | 346 | if ( ! $id ) { |
| 347 | 347 | $id = FrmAppHelper::get_param( 'id', 0, 'get', 'absint' ); |
@@ -351,7 +351,7 @@ discard block |
||
| 351 | 351 | } |
| 352 | 352 | } |
| 353 | 353 | |
| 354 | - $entry = FrmEntry::getOne($id, true); |
|
| 354 | + $entry = FrmEntry::getOne( $id, true ); |
|
| 355 | 355 | if ( ! $entry ) { |
| 356 | 356 | echo '<div id="form_show_entry_page" class="wrap">' . |
| 357 | 357 | __( 'You are trying to view an entry that does not exist.', 'formidable' ) . |
@@ -359,7 +359,7 @@ discard block |
||
| 359 | 359 | return; |
| 360 | 360 | } |
| 361 | 361 | |
| 362 | - $data = maybe_unserialize($entry->description); |
|
| 362 | + $data = maybe_unserialize( $entry->description ); |
|
| 363 | 363 | if ( ! is_array( $data ) || ! isset( $data['referrer'] ) ) { |
| 364 | 364 | $data = array( 'referrer' => $data ); |
| 365 | 365 | } |
@@ -371,11 +371,11 @@ discard block |
||
| 371 | 371 | } |
| 372 | 372 | |
| 373 | 373 | public static function destroy() { |
| 374 | - FrmAppHelper::permission_check('frm_delete_entries'); |
|
| 374 | + FrmAppHelper::permission_check( 'frm_delete_entries' ); |
|
| 375 | 375 | |
| 376 | 376 | $params = FrmForm::get_admin_params(); |
| 377 | 377 | |
| 378 | - if ( isset($params['keep_post']) && $params['keep_post'] ) { |
|
| 378 | + if ( isset( $params['keep_post'] ) && $params['keep_post'] ) { |
|
| 379 | 379 | //unlink entry from post |
| 380 | 380 | global $wpdb; |
| 381 | 381 | $wpdb->update( $wpdb->prefix . 'frm_items', array( 'post_id' => '' ), array( 'id' => $params['id'] ) ); |
@@ -454,9 +454,9 @@ discard block |
||
| 454 | 454 | if ( ! isset( $frm_vars['form_params'] ) ) { |
| 455 | 455 | $frm_vars['form_params'] = array(); |
| 456 | 456 | } |
| 457 | - $frm_vars['form_params'][ $form->id ] = $params; |
|
| 457 | + $frm_vars['form_params'][$form->id] = $params; |
|
| 458 | 458 | |
| 459 | - if ( isset( $frm_vars['created_entries'][ $form_id ] ) ) { |
|
| 459 | + if ( isset( $frm_vars['created_entries'][$form_id] ) ) { |
|
| 460 | 460 | return; |
| 461 | 461 | } |
| 462 | 462 | |
@@ -471,13 +471,13 @@ discard block |
||
| 471 | 471 | */ |
| 472 | 472 | $errors = apply_filters( 'frm_entries_before_create', $errors, $form ); |
| 473 | 473 | |
| 474 | - $frm_vars['created_entries'][ $form_id ] = array( 'errors' => $errors ); |
|
| 474 | + $frm_vars['created_entries'][$form_id] = array( 'errors' => $errors ); |
|
| 475 | 475 | |
| 476 | 476 | if ( empty( $errors ) ) { |
| 477 | 477 | $_POST['frm_skip_cookie'] = 1; |
| 478 | 478 | if ( $params['action'] == 'create' ) { |
| 479 | - if ( apply_filters( 'frm_continue_to_create', true, $form_id ) && ! isset( $frm_vars['created_entries'][ $form_id ]['entry_id'] ) ) { |
|
| 480 | - $frm_vars['created_entries'][ $form_id ]['entry_id'] = FrmEntry::create( $_POST ); |
|
| 479 | + if ( apply_filters( 'frm_continue_to_create', true, $form_id ) && ! isset( $frm_vars['created_entries'][$form_id]['entry_id'] ) ) { |
|
| 480 | + $frm_vars['created_entries'][$form_id]['entry_id'] = FrmEntry::create( $_POST ); |
|
| 481 | 481 | } |
| 482 | 482 | } |
| 483 | 483 | |
@@ -560,9 +560,9 @@ discard block |
||
| 560 | 560 | } |
| 561 | 561 | |
| 562 | 562 | public static function entry_sidebar( $entry ) { |
| 563 | - $data = maybe_unserialize($entry->description); |
|
| 564 | - $date_format = get_option('date_format'); |
|
| 565 | - $time_format = get_option('time_format'); |
|
| 563 | + $data = maybe_unserialize( $entry->description ); |
|
| 564 | + $date_format = get_option( 'date_format' ); |
|
| 565 | + $time_format = get_option( 'time_format' ); |
|
| 566 | 566 | if ( isset( $data['browser'] ) ) { |
| 567 | 567 | $browser = FrmEntriesHelper::get_browser( $data['browser'] ); |
| 568 | 568 | } |
@@ -350,10 +350,10 @@ discard block |
||
| 350 | 350 | if ( $this->include_field_in_content( $field_value ) ) { |
| 351 | 351 | |
| 352 | 352 | $displayed_value = $this->prepare_display_value_for_array( $field_value->get_displayed_value() ); |
| 353 | - $output[ $field_value->get_field_key() ] = $displayed_value; |
|
| 353 | + $output[$field_value->get_field_key()] = $displayed_value; |
|
| 354 | 354 | |
| 355 | 355 | if ( $displayed_value !== $field_value->get_saved_value() ) { |
| 356 | - $output[ $field_value->get_field_key() . '-value' ] = $field_value->get_saved_value(); |
|
| 356 | + $output[$field_value->get_field_key() . '-value'] = $field_value->get_saved_value(); |
|
| 357 | 357 | } |
| 358 | 358 | } |
| 359 | 359 | } |
@@ -608,7 +608,7 @@ discard block |
||
| 608 | 608 | |
| 609 | 609 | if ( is_array( $value ) ) { |
| 610 | 610 | foreach ( $value as $key => $single_value ) { |
| 611 | - $value[ $key ] = $this->strip_html( $single_value ); |
|
| 611 | + $value[$key] = $this->strip_html( $single_value ); |
|
| 612 | 612 | } |
| 613 | 613 | } else if ( $this->is_plain_text && ! is_array( $value ) ) { |
| 614 | 614 | if ( strpos( $value, '<img' ) !== false ) { |
@@ -329,7 +329,7 @@ discard block |
||
| 329 | 329 | * |
| 330 | 330 | * @since 2.04 |
| 331 | 331 | * |
| 332 | - * @param array $field_values |
|
| 332 | + * @param FrmFieldValue[] $field_values |
|
| 333 | 333 | * @param array $output |
| 334 | 334 | */ |
| 335 | 335 | protected function push_field_values_to_array( $field_values, &$output ) { |
@@ -551,7 +551,7 @@ discard block |
||
| 551 | 551 | * @param mixed $display_value |
| 552 | 552 | * @param string $field_type |
| 553 | 553 | * |
| 554 | - * @return mixed|string |
|
| 554 | + * @return string |
|
| 555 | 555 | */ |
| 556 | 556 | protected function prepare_display_value_for_html_table( $display_value, $field_type = '' ) { |
| 557 | 557 | $display_value = $this->flatten_array( $display_value ); |
@@ -154,12 +154,12 @@ discard block |
||
| 154 | 154 | * @return array |
| 155 | 155 | */ |
| 156 | 156 | private function prepare_array_property( $index, $atts ) { |
| 157 | - if ( isset( $atts[ $index ] ) && ! empty( $atts[ $index ] ) ) { |
|
| 157 | + if ( isset( $atts[$index] ) && ! empty( $atts[$index] ) ) { |
|
| 158 | 158 | |
| 159 | - if ( is_array( $atts[ $index ] ) ) { |
|
| 160 | - $property = $atts[ $index ]; |
|
| 159 | + if ( is_array( $atts[$index] ) ) { |
|
| 160 | + $property = $atts[$index]; |
|
| 161 | 161 | } else { |
| 162 | - $property = explode( ',', $atts[ $index ] ); |
|
| 162 | + $property = explode( ',', $atts[$index] ); |
|
| 163 | 163 | } |
| 164 | 164 | } else { |
| 165 | 165 | $property = array(); |
@@ -292,6 +292,6 @@ discard block |
||
| 292 | 292 | * @param stdClass $field |
| 293 | 293 | */ |
| 294 | 294 | protected function add_field_values( $field ) { |
| 295 | - $this->field_values[ $field->id ] = new FrmFieldValue( $field, $this->entry, array( 'source' => $this->source ) ); |
|
| 295 | + $this->field_values[$field->id] = new FrmFieldValue( $field, $this->entry, array( 'source' => $this->source ) ); |
|
| 296 | 296 | } |
| 297 | 297 | } |
| 298 | 298 | \ No newline at end of file |
@@ -151,6 +151,7 @@ |
||
| 151 | 151 | |
| 152 | 152 | /** |
| 153 | 153 | * @deprecated 2.04 |
| 154 | + * @param string $val |
|
| 154 | 155 | */ |
| 155 | 156 | private static function get_field_value( $atts, &$val ) { |
| 156 | 157 | _deprecated_function( __FUNCTION__, '2.04', 'instance of FrmEntryValues or FrmProEntryValues' ); |
@@ -98,15 +98,15 @@ discard block |
||
| 98 | 98 | self::prepare_field_output( $atts, $val ); |
| 99 | 99 | |
| 100 | 100 | if ( $atts['format'] != 'text' ) { |
| 101 | - $values[ $f->field_key ] = $val; |
|
| 101 | + $values[$f->field_key] = $val; |
|
| 102 | 102 | if ( $atts['entry'] && $f->type != 'textarea' ) { |
| 103 | - $prev_val = maybe_unserialize( $atts['entry']->metas[ $f->id ] ); |
|
| 103 | + $prev_val = maybe_unserialize( $atts['entry']->metas[$f->id] ); |
|
| 104 | 104 | if ( $prev_val != $val ) { |
| 105 | - $values[ $f->field_key . '-value' ] = $prev_val; |
|
| 105 | + $values[$f->field_key . '-value'] = $prev_val; |
|
| 106 | 106 | } |
| 107 | 107 | } |
| 108 | 108 | } else { |
| 109 | - $values[ $f->id ] = array( 'label' => $f->name, 'val' => $val, 'type' => $f->type ); |
|
| 109 | + $values[$f->id] = array( 'label' => $f->name, 'val' => $val, 'type' => $f->type ); |
|
| 110 | 110 | } |
| 111 | 111 | } |
| 112 | 112 | |
@@ -116,9 +116,9 @@ discard block |
||
| 116 | 116 | private static function fill_missing_fields( $atts, &$values ) { |
| 117 | 117 | _deprecated_function( __FUNCTION__, '2.04', 'instance of FrmEntryValues or FrmProEntryValues' ); |
| 118 | 118 | |
| 119 | - if ( $atts['entry'] && ! isset( $atts['entry']->metas[ $atts['field']->id ] ) ) { |
|
| 119 | + if ( $atts['entry'] && ! isset( $atts['entry']->metas[$atts['field']->id] ) ) { |
|
| 120 | 120 | // In case include_blank is set |
| 121 | - $atts['entry']->metas[ $atts['field']->id ] = ''; |
|
| 121 | + $atts['entry']->metas[$atts['field']->id] = ''; |
|
| 122 | 122 | $atts['entry'] = apply_filters( 'frm_prepare_entry_content', $atts['entry'], array( 'field' => $atts['field'] ) ); |
| 123 | 123 | self::fill_values_from_entry( $atts, $values ); |
| 124 | 124 | } |
@@ -146,7 +146,7 @@ discard block |
||
| 146 | 146 | 'type' => $f->type, |
| 147 | 147 | ); |
| 148 | 148 | |
| 149 | - $values[ $f->id ] = apply_filters( 'frm_field_shortcodes_for_default_html_email', $field_shortcodes, $f ); |
|
| 149 | + $values[$f->id] = apply_filters( 'frm_field_shortcodes_for_default_html_email', $field_shortcodes, $f ); |
|
| 150 | 150 | } |
| 151 | 151 | |
| 152 | 152 | /** |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | |
| 158 | 158 | $f = $atts['field']; |
| 159 | 159 | if ( $atts['entry'] ) { |
| 160 | - $prev_val = maybe_unserialize( $atts['entry']->metas[ $f->id ] ); |
|
| 160 | + $prev_val = maybe_unserialize( $atts['entry']->metas[$f->id] ); |
|
| 161 | 161 | $meta = array( 'item_id' => $atts['id'], 'field_id' => $f->id, 'meta_value' => $prev_val, 'field_type' => $f->type ); |
| 162 | 162 | |
| 163 | 163 | //This filter applies to the default-message shortcode and frm-show-entry shortcode only |
@@ -80,8 +80,8 @@ discard block |
||
| 80 | 80 | * @since 2.04 |
| 81 | 81 | */ |
| 82 | 82 | protected function init_saved_value() { |
| 83 | - if ( isset( $this->entry->metas[ $this->field->id ] ) ) { |
|
| 84 | - $this->saved_value = $this->entry->metas[ $this->field->id ]; |
|
| 83 | + if ( isset( $this->entry->metas[$this->field->id] ) ) { |
|
| 84 | + $this->saved_value = $this->entry->metas[$this->field->id]; |
|
| 85 | 85 | } else { |
| 86 | 86 | $this->saved_value = ''; |
| 87 | 87 | } |
@@ -154,7 +154,7 @@ discard block |
||
| 154 | 154 | |
| 155 | 155 | if ( $this->source === 'entry_formatter' ) { |
| 156 | 156 | // Deprecated frm_email_value hook |
| 157 | - $meta = array( |
|
| 157 | + $meta = array( |
|
| 158 | 158 | 'item_id' => $this->entry->id, |
| 159 | 159 | 'field_id' => $this->field->id, |
| 160 | 160 | 'meta_value' => $this->saved_value, |
@@ -1,10 +1,10 @@ discard block |
||
| 1 | 1 | <div class="field-group field-group-background clearfix frm-first-row"> |
| 2 | 2 | <label><?php _e( 'Color', 'formidable' ) ?></label> |
| 3 | - <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('label_color') ) ?>" id="frm_label_color" class="hex" value="<?php echo esc_attr( $style->post_content['label_color'] ) ?>" /> |
|
| 3 | + <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'label_color' ) ) ?>" id="frm_label_color" class="hex" value="<?php echo esc_attr( $style->post_content['label_color'] ) ?>" /> |
|
| 4 | 4 | </div> |
| 5 | 5 | <div class="field-group clearfix frm-first-row"> |
| 6 | 6 | <label><?php _e( 'Weight', 'formidable' ) ?></label> |
| 7 | - <select name="<?php echo esc_attr( $frm_style->get_field_name('weight') ) ?>" id="frm_weight"> |
|
| 7 | + <select name="<?php echo esc_attr( $frm_style->get_field_name( 'weight' ) ) ?>" id="frm_weight"> |
|
| 8 | 8 | <?php foreach ( FrmStyle::get_bold_options() as $value => $name ) { ?> |
| 9 | 9 | <option value="<?php echo esc_attr( $value ) ?>" <?php selected( $style->post_content['weight'], $value ) ?>><?php echo esc_html( $name ) ?></option> |
| 10 | 10 | <?php } ?> |
@@ -12,45 +12,45 @@ discard block |
||
| 12 | 12 | </div> |
| 13 | 13 | <div class="field-group clearfix frm-first-row"> |
| 14 | 14 | <label><?php _e( 'Size', 'formidable' ) ?></label> |
| 15 | - <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('font_size') ) ?>" id="frm_font_size" value="<?php echo esc_attr($style->post_content['font_size']) ?>" size="3" /> |
|
| 15 | + <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'font_size' ) ) ?>" id="frm_font_size" value="<?php echo esc_attr( $style->post_content['font_size'] ) ?>" size="3" /> |
|
| 16 | 16 | </div> |
| 17 | 17 | |
| 18 | 18 | <div class="field-group clearfix frm_clear"> |
| 19 | 19 | <label><?php _e( 'Position', 'formidable' ) ?></label> |
| 20 | - <select name="<?php echo esc_attr( $frm_style->get_field_name('position') ) ?>" id="frm_position"> |
|
| 20 | + <select name="<?php echo esc_attr( $frm_style->get_field_name( 'position' ) ) ?>" id="frm_position"> |
|
| 21 | 21 | <?php foreach ( FrmStylesHelper::get_css_label_positions() as $pos => $pos_label ) { ?> |
| 22 | - <option value="<?php echo esc_attr( $pos ) ?>" <?php selected($style->post_content['position'], $pos) ?>><?php echo esc_html( $pos_label ) ?></option> |
|
| 22 | + <option value="<?php echo esc_attr( $pos ) ?>" <?php selected( $style->post_content['position'], $pos ) ?>><?php echo esc_html( $pos_label ) ?></option> |
|
| 23 | 23 | <?php } ?> |
| 24 | 24 | </select> |
| 25 | 25 | </div> |
| 26 | 26 | |
| 27 | 27 | <div class="field-group clearfix"> |
| 28 | 28 | <label><?php _e( 'Align', 'formidable' ) ?></label> |
| 29 | - <select name="<?php echo esc_attr( $frm_style->get_field_name('align') ) ?>" id="frm_align"> |
|
| 30 | - <option value="left" <?php selected($style->post_content['align'], 'left') ?>><?php _e( 'left', 'formidable' ) ?></option> |
|
| 31 | - <option value="right" <?php selected($style->post_content['align'], 'right') ?>><?php _e( 'right', 'formidable' ) ?></option> |
|
| 29 | + <select name="<?php echo esc_attr( $frm_style->get_field_name( 'align' ) ) ?>" id="frm_align"> |
|
| 30 | + <option value="left" <?php selected( $style->post_content['align'], 'left' ) ?>><?php _e( 'left', 'formidable' ) ?></option> |
|
| 31 | + <option value="right" <?php selected( $style->post_content['align'], 'right' ) ?>><?php _e( 'right', 'formidable' ) ?></option> |
|
| 32 | 32 | </select> |
| 33 | 33 | </div> |
| 34 | 34 | |
| 35 | 35 | <div class="field-group clearfix"> |
| 36 | 36 | <label><?php _e( 'Width', 'formidable' ) ?></label> |
| 37 | - <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('width') ) ?>" id="frm_width" value="<?php echo esc_attr( $style->post_content['width'] ) ?>" /> |
|
| 37 | + <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'width' ) ) ?>" id="frm_width" value="<?php echo esc_attr( $style->post_content['width'] ) ?>" /> |
|
| 38 | 38 | </div> |
| 39 | 39 | |
| 40 | 40 | <div class="field-group clearfix frm_clear"> |
| 41 | 41 | <label><?php _e( 'Padding', 'formidable' ) ?></label> |
| 42 | - <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('label_padding') ) ?>" id="frm_label_padding" value="<?php echo esc_attr( $style->post_content['label_padding'] ) ?>" /> |
|
| 42 | + <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'label_padding' ) ) ?>" id="frm_label_padding" value="<?php echo esc_attr( $style->post_content['label_padding'] ) ?>" /> |
|
| 43 | 43 | </div> |
| 44 | 44 | |
| 45 | 45 | <div class="clear"></div> |
| 46 | 46 | <h3><?php _e( 'Required Indicator', 'formidable' ) ?></h3> |
| 47 | 47 | <div class="field-group field-group-border clearfix after-h3"> |
| 48 | 48 | <label class="background"><?php _e( 'Color', 'formidable' ) ?></label> |
| 49 | - <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('required_color') ) ?>" id="frm_required_color" class="hex" value="<?php echo esc_attr( $style->post_content['required_color'] ) ?>" /> |
|
| 49 | + <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'required_color' ) ) ?>" id="frm_required_color" class="hex" value="<?php echo esc_attr( $style->post_content['required_color'] ) ?>" /> |
|
| 50 | 50 | </div> |
| 51 | 51 | <div class="field-group clearfix after-h3"> |
| 52 | 52 | <label><?php _e( 'Weight', 'formidable' ) ?></label> |
| 53 | - <select name="<?php echo esc_attr( $frm_style->get_field_name('required_weight') ) ?>" id="frm_required_weight"> |
|
| 53 | + <select name="<?php echo esc_attr( $frm_style->get_field_name( 'required_weight' ) ) ?>" id="frm_required_weight"> |
|
| 54 | 54 | <?php foreach ( FrmStyle::get_bold_options() as $value => $name ) { ?> |
| 55 | 55 | <option value="<?php echo esc_attr( $value ) ?>" <?php selected( $style->post_content['required_weight'], $value ) ?>><?php echo esc_html( $name ) ?></option> |
| 56 | 56 | <?php } ?> |
@@ -2,129 +2,129 @@ discard block |
||
| 2 | 2 | |
| 3 | 3 | class FrmFieldsController { |
| 4 | 4 | |
| 5 | - public static function load_field() { |
|
| 5 | + public static function load_field() { |
|
| 6 | 6 | FrmAppHelper::permission_check('frm_edit_forms'); |
| 7 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 7 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 8 | 8 | |
| 9 | - $fields = $_POST['field']; |
|
| 10 | - if ( empty( $fields ) ) { |
|
| 11 | - wp_die(); |
|
| 12 | - } |
|
| 9 | + $fields = $_POST['field']; |
|
| 10 | + if ( empty( $fields ) ) { |
|
| 11 | + wp_die(); |
|
| 12 | + } |
|
| 13 | 13 | |
| 14 | - $_GET['page'] = 'formidable'; |
|
| 15 | - $fields = stripslashes_deep( $fields ); |
|
| 14 | + $_GET['page'] = 'formidable'; |
|
| 15 | + $fields = stripslashes_deep( $fields ); |
|
| 16 | 16 | |
| 17 | - $ajax = true; |
|
| 17 | + $ajax = true; |
|
| 18 | 18 | $values = array( 'id' => FrmAppHelper::get_post_param( 'form_id', '', 'absint' ) ); |
| 19 | - $path = FrmAppHelper::plugin_path(); |
|
| 20 | - $field_html = array(); |
|
| 21 | - |
|
| 22 | - foreach ( $fields as $field ) { |
|
| 23 | - $field = htmlspecialchars_decode( nl2br( $field ) ); |
|
| 24 | - $field = json_decode( $field, true ); |
|
| 25 | - if ( ! isset( $field['id'] ) ) { |
|
| 26 | - // this field may have already been loaded |
|
| 27 | - continue; |
|
| 28 | - } |
|
| 19 | + $path = FrmAppHelper::plugin_path(); |
|
| 20 | + $field_html = array(); |
|
| 21 | + |
|
| 22 | + foreach ( $fields as $field ) { |
|
| 23 | + $field = htmlspecialchars_decode( nl2br( $field ) ); |
|
| 24 | + $field = json_decode( $field, true ); |
|
| 25 | + if ( ! isset( $field['id'] ) ) { |
|
| 26 | + // this field may have already been loaded |
|
| 27 | + continue; |
|
| 28 | + } |
|
| 29 | 29 | |
| 30 | - $field_id = absint( $field['id'] ); |
|
| 30 | + $field_id = absint( $field['id'] ); |
|
| 31 | 31 | |
| 32 | - if ( ! isset( $field['value'] ) ) { |
|
| 33 | - $field['value'] = ''; |
|
| 34 | - } |
|
| 32 | + if ( ! isset( $field['value'] ) ) { |
|
| 33 | + $field['value'] = ''; |
|
| 34 | + } |
|
| 35 | 35 | |
| 36 | 36 | $field_name = 'item_meta[' . $field_id . ']'; |
| 37 | - $html_id = FrmFieldsHelper::get_html_id($field); |
|
| 37 | + $html_id = FrmFieldsHelper::get_html_id($field); |
|
| 38 | 38 | |
| 39 | - ob_start(); |
|
| 39 | + ob_start(); |
|
| 40 | 40 | include( $path . '/classes/views/frm-forms/add_field.php' ); |
| 41 | - $field_html[ $field_id ] = ob_get_contents(); |
|
| 42 | - ob_end_clean(); |
|
| 43 | - } |
|
| 41 | + $field_html[ $field_id ] = ob_get_contents(); |
|
| 42 | + ob_end_clean(); |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | - unset($path); |
|
| 45 | + unset($path); |
|
| 46 | 46 | |
| 47 | - echo json_encode($field_html); |
|
| 47 | + echo json_encode($field_html); |
|
| 48 | 48 | |
| 49 | - wp_die(); |
|
| 50 | - } |
|
| 49 | + wp_die(); |
|
| 50 | + } |
|
| 51 | 51 | |
| 52 | 52 | /** |
| 53 | 53 | * Create a new field with ajax |
| 54 | 54 | */ |
| 55 | - public static function create() { |
|
| 55 | + public static function create() { |
|
| 56 | 56 | FrmAppHelper::permission_check('frm_edit_forms'); |
| 57 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 57 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 58 | 58 | |
| 59 | 59 | $field_type = FrmAppHelper::get_post_param( 'field_type', '', 'sanitize_text_field' ); |
| 60 | 60 | $form_id = FrmAppHelper::get_post_param( 'form_id', 0, 'absint' ); |
| 61 | 61 | |
| 62 | 62 | $field = self::include_new_field( $field_type, $form_id ); |
| 63 | 63 | |
| 64 | - // this hook will allow for multiple fields to be added at once |
|
| 65 | - do_action('frm_after_field_created', $field, $form_id); |
|
| 64 | + // this hook will allow for multiple fields to be added at once |
|
| 65 | + do_action('frm_after_field_created', $field, $form_id); |
|
| 66 | 66 | |
| 67 | - wp_die(); |
|
| 68 | - } |
|
| 67 | + wp_die(); |
|
| 68 | + } |
|
| 69 | 69 | |
| 70 | - /** |
|
| 71 | - * Set up and create a new field |
|
| 72 | - * |
|
| 73 | - * @param string $field_type |
|
| 74 | - * @param integer $form_id |
|
| 75 | - * @return array|bool |
|
| 76 | - */ |
|
| 70 | + /** |
|
| 71 | + * Set up and create a new field |
|
| 72 | + * |
|
| 73 | + * @param string $field_type |
|
| 74 | + * @param integer $form_id |
|
| 75 | + * @return array|bool |
|
| 76 | + */ |
|
| 77 | 77 | public static function include_new_field( $field_type, $form_id ) { |
| 78 | - $values = array(); |
|
| 79 | - if ( FrmAppHelper::pro_is_installed() ) { |
|
| 80 | - $values['post_type'] = FrmProFormsHelper::post_type($form_id); |
|
| 81 | - } |
|
| 78 | + $values = array(); |
|
| 79 | + if ( FrmAppHelper::pro_is_installed() ) { |
|
| 80 | + $values['post_type'] = FrmProFormsHelper::post_type($form_id); |
|
| 81 | + } |
|
| 82 | 82 | |
| 83 | 83 | $field_values = FrmFieldsHelper::setup_new_vars( $field_type, $form_id ); |
| 84 | - $field_values = apply_filters( 'frm_before_field_created', $field_values ); |
|
| 84 | + $field_values = apply_filters( 'frm_before_field_created', $field_values ); |
|
| 85 | 85 | |
| 86 | - $field_id = FrmField::create( $field_values ); |
|
| 86 | + $field_id = FrmField::create( $field_values ); |
|
| 87 | 87 | |
| 88 | - if ( ! $field_id ) { |
|
| 89 | - return false; |
|
| 90 | - } |
|
| 88 | + if ( ! $field_id ) { |
|
| 89 | + return false; |
|
| 90 | + } |
|
| 91 | 91 | |
| 92 | - $field = self::include_single_field($field_id, $values, $form_id); |
|
| 92 | + $field = self::include_single_field($field_id, $values, $form_id); |
|
| 93 | 93 | |
| 94 | - return $field; |
|
| 95 | - } |
|
| 94 | + return $field; |
|
| 95 | + } |
|
| 96 | 96 | |
| 97 | 97 | public static function edit_name( $field = 'name', $id = '' ) { |
| 98 | 98 | FrmAppHelper::permission_check('frm_edit_forms'); |
| 99 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 99 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 100 | 100 | |
| 101 | - if ( empty($field) ) { |
|
| 102 | - $field = 'name'; |
|
| 103 | - } |
|
| 101 | + if ( empty($field) ) { |
|
| 102 | + $field = 'name'; |
|
| 103 | + } |
|
| 104 | 104 | |
| 105 | - if ( empty($id) ) { |
|
| 105 | + if ( empty($id) ) { |
|
| 106 | 106 | $id = FrmAppHelper::get_post_param( 'element_id', '', 'sanitize_title' ); |
| 107 | 107 | $id = str_replace( 'field_label_', '', $id ); |
| 108 | - } |
|
| 108 | + } |
|
| 109 | 109 | |
| 110 | 110 | $value = FrmAppHelper::get_post_param( 'update_value', '', 'wp_kses_post' ); |
| 111 | 111 | $value = trim( $value ); |
| 112 | - if ( trim(strip_tags($value)) == '' ) { |
|
| 113 | - // set blank value if there is no content |
|
| 114 | - $value = ''; |
|
| 115 | - } |
|
| 112 | + if ( trim(strip_tags($value)) == '' ) { |
|
| 113 | + // set blank value if there is no content |
|
| 114 | + $value = ''; |
|
| 115 | + } |
|
| 116 | 116 | |
| 117 | 117 | FrmField::update( $id, array( $field => $value ) ); |
| 118 | 118 | |
| 119 | 119 | do_action( 'frm_after_update_field_' . $field, compact( 'id', 'value' ) ); |
| 120 | 120 | |
| 121 | 121 | echo stripslashes( wp_kses_post( $value ) ); |
| 122 | - wp_die(); |
|
| 123 | - } |
|
| 122 | + wp_die(); |
|
| 123 | + } |
|
| 124 | 124 | |
| 125 | - public static function update_ajax_option() { |
|
| 125 | + public static function update_ajax_option() { |
|
| 126 | 126 | FrmAppHelper::permission_check('frm_edit_forms'); |
| 127 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 127 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 128 | 128 | |
| 129 | 129 | $field_id = FrmAppHelper::get_post_param( 'field', 0, 'absint' ); |
| 130 | 130 | if ( ! $field_id ) { |
@@ -139,26 +139,26 @@ discard block |
||
| 139 | 139 | unset($new_val); |
| 140 | 140 | } |
| 141 | 141 | |
| 142 | - FrmField::update( $field_id, array( |
|
| 143 | - 'field_options' => $field->field_options, |
|
| 142 | + FrmField::update( $field_id, array( |
|
| 143 | + 'field_options' => $field->field_options, |
|
| 144 | 144 | 'form_id' => $field->form_id, |
| 145 | - ) ); |
|
| 146 | - wp_die(); |
|
| 147 | - } |
|
| 145 | + ) ); |
|
| 146 | + wp_die(); |
|
| 147 | + } |
|
| 148 | 148 | |
| 149 | - public static function duplicate() { |
|
| 149 | + public static function duplicate() { |
|
| 150 | 150 | FrmAppHelper::permission_check('frm_edit_forms'); |
| 151 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 151 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 152 | 152 | |
| 153 | - global $wpdb; |
|
| 153 | + global $wpdb; |
|
| 154 | 154 | |
| 155 | 155 | $field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' ); |
| 156 | 156 | $form_id = FrmAppHelper::get_post_param( 'form_id', 0, 'absint' ); |
| 157 | 157 | |
| 158 | 158 | $copy_field = FrmField::getOne( $field_id ); |
| 159 | - if ( ! $copy_field ) { |
|
| 160 | - wp_die(); |
|
| 161 | - } |
|
| 159 | + if ( ! $copy_field ) { |
|
| 160 | + wp_die(); |
|
| 161 | + } |
|
| 162 | 162 | |
| 163 | 163 | do_action( 'frm_duplicate_field', $copy_field, $form_id ); |
| 164 | 164 | do_action( 'frm_duplicate_field_' . $copy_field->type, $copy_field, $form_id ); |
@@ -172,214 +172,214 @@ discard block |
||
| 172 | 172 | wp_die(); |
| 173 | 173 | } |
| 174 | 174 | |
| 175 | - self::include_single_field($field_id, $values); |
|
| 175 | + self::include_single_field($field_id, $values); |
|
| 176 | 176 | |
| 177 | - wp_die(); |
|
| 178 | - } |
|
| 177 | + wp_die(); |
|
| 178 | + } |
|
| 179 | 179 | |
| 180 | - /** |
|
| 181 | - * Load a single field in the form builder along with all needed variables |
|
| 182 | - */ |
|
| 183 | - public static function include_single_field( $field_id, $values, $form_id = 0 ) { |
|
| 184 | - $field = FrmFieldsHelper::setup_edit_vars(FrmField::getOne($field_id)); |
|
| 180 | + /** |
|
| 181 | + * Load a single field in the form builder along with all needed variables |
|
| 182 | + */ |
|
| 183 | + public static function include_single_field( $field_id, $values, $form_id = 0 ) { |
|
| 184 | + $field = FrmFieldsHelper::setup_edit_vars(FrmField::getOne($field_id)); |
|
| 185 | 185 | $field_name = 'item_meta[' . $field_id . ']'; |
| 186 | - $html_id = FrmFieldsHelper::get_html_id($field); |
|
| 187 | - $id = $form_id ? $form_id : $field['form_id']; |
|
| 188 | - if ( $field['type'] == 'html' ) { |
|
| 189 | - $field['stop_filter'] = true; |
|
| 190 | - } |
|
| 186 | + $html_id = FrmFieldsHelper::get_html_id($field); |
|
| 187 | + $id = $form_id ? $form_id : $field['form_id']; |
|
| 188 | + if ( $field['type'] == 'html' ) { |
|
| 189 | + $field['stop_filter'] = true; |
|
| 190 | + } |
|
| 191 | 191 | |
| 192 | 192 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/add_field.php' ); |
| 193 | 193 | |
| 194 | - return $field; |
|
| 195 | - } |
|
| 194 | + return $field; |
|
| 195 | + } |
|
| 196 | 196 | |
| 197 | - public static function destroy() { |
|
| 197 | + public static function destroy() { |
|
| 198 | 198 | FrmAppHelper::permission_check('frm_edit_forms'); |
| 199 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 199 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 200 | 200 | |
| 201 | 201 | $field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' ); |
| 202 | 202 | FrmField::destroy( $field_id ); |
| 203 | - wp_die(); |
|
| 204 | - } |
|
| 203 | + wp_die(); |
|
| 204 | + } |
|
| 205 | 205 | |
| 206 | - /* Field Options */ |
|
| 206 | + /* Field Options */ |
|
| 207 | 207 | |
| 208 | - //Add Single Option or Other Option |
|
| 209 | - public static function add_option() { |
|
| 208 | + //Add Single Option or Other Option |
|
| 209 | + public static function add_option() { |
|
| 210 | 210 | FrmAppHelper::permission_check('frm_edit_forms'); |
| 211 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 211 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 212 | 212 | |
| 213 | 213 | $id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' ); |
| 214 | 214 | $opt_type = FrmAppHelper::get_post_param( 'opt_type', '', 'sanitize_text_field' ); |
| 215 | 215 | $opt_key = FrmAppHelper::get_post_param( 'opt_key', 0, 'absint' ); |
| 216 | 216 | |
| 217 | - $field = FrmField::getOne($id); |
|
| 217 | + $field = FrmField::getOne($id); |
|
| 218 | 218 | |
| 219 | - if ( 'other' == $opt_type ) { |
|
| 219 | + if ( 'other' == $opt_type ) { |
|
| 220 | 220 | $opt = __( 'Other', 'formidable' ); |
| 221 | - $other_val = ''; |
|
| 222 | - $opt_key = 'other_' . $opt_key; |
|
| 223 | - } else { |
|
| 221 | + $other_val = ''; |
|
| 222 | + $opt_key = 'other_' . $opt_key; |
|
| 223 | + } else { |
|
| 224 | 224 | $opt = __( 'New Option', 'formidable' ); |
| 225 | - } |
|
| 226 | - $field_val = $opt; |
|
| 225 | + } |
|
| 226 | + $field_val = $opt; |
|
| 227 | 227 | |
| 228 | - $field_data = $field; |
|
| 228 | + $field_data = $field; |
|
| 229 | 229 | $field = (array) $field; |
| 230 | 230 | $field['separate_value'] = isset( $field_data->field_options['separate_value'] ) ? $field_data->field_options['separate_value'] : 0; |
| 231 | 231 | unset( $field_data ); |
| 232 | 232 | |
| 233 | 233 | $field_name = 'item_meta[' . $id . ']'; |
| 234 | 234 | $html_id = FrmFieldsHelper::get_html_id( $field ); |
| 235 | - $checked = ''; |
|
| 235 | + $checked = ''; |
|
| 236 | 236 | |
| 237 | - if ( 'other' == $opt_type ) { |
|
| 237 | + if ( 'other' == $opt_type ) { |
|
| 238 | 238 | include( FrmAppHelper::plugin_path() . '/pro/classes/views/frmpro-fields/other-option.php' ); |
| 239 | - } else { |
|
| 239 | + } else { |
|
| 240 | 240 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/single-option.php' ); |
| 241 | - } |
|
| 242 | - wp_die(); |
|
| 243 | - } |
|
| 241 | + } |
|
| 242 | + wp_die(); |
|
| 243 | + } |
|
| 244 | 244 | |
| 245 | - public static function edit_option() { |
|
| 245 | + public static function edit_option() { |
|
| 246 | 246 | _deprecated_function( __FUNCTION__, '2.3' ); |
| 247 | - } |
|
| 247 | + } |
|
| 248 | 248 | |
| 249 | - public static function delete_option() { |
|
| 249 | + public static function delete_option() { |
|
| 250 | 250 | _deprecated_function( __FUNCTION__, '2.3' ); |
| 251 | - } |
|
| 251 | + } |
|
| 252 | 252 | |
| 253 | - public static function import_choices() { |
|
| 254 | - FrmAppHelper::permission_check( 'frm_edit_forms', 'hide' ); |
|
| 253 | + public static function import_choices() { |
|
| 254 | + FrmAppHelper::permission_check( 'frm_edit_forms', 'hide' ); |
|
| 255 | 255 | |
| 256 | 256 | $field_id = absint( $_REQUEST['field_id'] ); |
| 257 | 257 | |
| 258 | - global $current_screen, $hook_suffix; |
|
| 258 | + global $current_screen, $hook_suffix; |
|
| 259 | 259 | |
| 260 | - // Catch plugins that include admin-header.php before admin.php completes. |
|
| 261 | - if ( empty( $current_screen ) && function_exists( 'set_current_screen' ) ) { |
|
| 262 | - $hook_suffix = ''; |
|
| 263 | - set_current_screen(); |
|
| 264 | - } |
|
| 260 | + // Catch plugins that include admin-header.php before admin.php completes. |
|
| 261 | + if ( empty( $current_screen ) && function_exists( 'set_current_screen' ) ) { |
|
| 262 | + $hook_suffix = ''; |
|
| 263 | + set_current_screen(); |
|
| 264 | + } |
|
| 265 | 265 | |
| 266 | - if ( function_exists( 'register_admin_color_schemes' ) ) { |
|
| 267 | - register_admin_color_schemes(); |
|
| 268 | - } |
|
| 266 | + if ( function_exists( 'register_admin_color_schemes' ) ) { |
|
| 267 | + register_admin_color_schemes(); |
|
| 268 | + } |
|
| 269 | 269 | |
| 270 | 270 | $hook_suffix = ''; |
| 271 | 271 | $admin_body_class = ''; |
| 272 | 272 | |
| 273 | - if ( get_user_setting( 'mfold' ) == 'f' ) { |
|
| 274 | - $admin_body_class .= ' folded'; |
|
| 275 | - } |
|
| 273 | + if ( get_user_setting( 'mfold' ) == 'f' ) { |
|
| 274 | + $admin_body_class .= ' folded'; |
|
| 275 | + } |
|
| 276 | 276 | |
| 277 | - if ( function_exists( 'is_admin_bar_showing' ) && is_admin_bar_showing() ) { |
|
| 278 | - $admin_body_class .= ' admin-bar'; |
|
| 279 | - } |
|
| 277 | + if ( function_exists( 'is_admin_bar_showing' ) && is_admin_bar_showing() ) { |
|
| 278 | + $admin_body_class .= ' admin-bar'; |
|
| 279 | + } |
|
| 280 | 280 | |
| 281 | - if ( is_rtl() ) { |
|
| 282 | - $admin_body_class .= ' rtl'; |
|
| 283 | - } |
|
| 281 | + if ( is_rtl() ) { |
|
| 282 | + $admin_body_class .= ' rtl'; |
|
| 283 | + } |
|
| 284 | 284 | |
| 285 | - $admin_body_class .= ' admin-color-' . sanitize_html_class( get_user_option( 'admin_color' ), 'fresh' ); |
|
| 286 | - $prepop = array(); |
|
| 287 | - FrmFieldsHelper::get_bulk_prefilled_opts($prepop); |
|
| 285 | + $admin_body_class .= ' admin-color-' . sanitize_html_class( get_user_option( 'admin_color' ), 'fresh' ); |
|
| 286 | + $prepop = array(); |
|
| 287 | + FrmFieldsHelper::get_bulk_prefilled_opts($prepop); |
|
| 288 | 288 | |
| 289 | - $field = FrmField::getOne($field_id); |
|
| 289 | + $field = FrmField::getOne($field_id); |
|
| 290 | 290 | |
| 291 | - wp_enqueue_script( 'utils' ); |
|
| 291 | + wp_enqueue_script( 'utils' ); |
|
| 292 | 292 | wp_enqueue_style( 'formidable-admin', FrmAppHelper::plugin_url() . '/css/frm_admin.css' ); |
| 293 | - FrmAppHelper::load_admin_wide_js(); |
|
| 293 | + FrmAppHelper::load_admin_wide_js(); |
|
| 294 | 294 | |
| 295 | 295 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/import_choices.php' ); |
| 296 | - wp_die(); |
|
| 297 | - } |
|
| 296 | + wp_die(); |
|
| 297 | + } |
|
| 298 | 298 | |
| 299 | - public static function import_options() { |
|
| 299 | + public static function import_options() { |
|
| 300 | 300 | FrmAppHelper::permission_check('frm_edit_forms'); |
| 301 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 301 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 302 | 302 | |
| 303 | - if ( ! is_admin() || ! current_user_can('frm_edit_forms') ) { |
|
| 304 | - return; |
|
| 305 | - } |
|
| 303 | + if ( ! is_admin() || ! current_user_can('frm_edit_forms') ) { |
|
| 304 | + return; |
|
| 305 | + } |
|
| 306 | 306 | |
| 307 | 307 | $field_id = absint( $_POST['field_id'] ); |
| 308 | - $field = FrmField::getOne($field_id); |
|
| 308 | + $field = FrmField::getOne($field_id); |
|
| 309 | 309 | |
| 310 | 310 | if ( ! in_array( $field->type, array( 'radio', 'checkbox', 'select' ) ) ) { |
| 311 | - return; |
|
| 312 | - } |
|
| 311 | + return; |
|
| 312 | + } |
|
| 313 | 313 | |
| 314 | - $field = FrmFieldsHelper::setup_edit_vars($field); |
|
| 314 | + $field = FrmFieldsHelper::setup_edit_vars($field); |
|
| 315 | 315 | $opts = FrmAppHelper::get_param( 'opts', '', 'post', 'wp_kses_post' ); |
| 316 | 316 | $opts = explode( "\n", rtrim( $opts, "\n" ) ); |
| 317 | 317 | $opts = array_map( 'trim', $opts ); |
| 318 | 318 | |
| 319 | - if ( $field['separate_value'] ) { |
|
| 320 | - foreach ( $opts as $opt_key => $opt ) { |
|
| 321 | - if ( strpos($opt, '|') !== false ) { |
|
| 322 | - $vals = explode('|', $opt); |
|
| 323 | - if ( $vals[0] != $vals[1] ) { |
|
| 324 | - $opts[ $opt_key ] = array( 'label' => trim( $vals[0] ), 'value' => trim( $vals[1] ) ); |
|
| 325 | - } |
|
| 326 | - unset($vals); |
|
| 327 | - } |
|
| 328 | - unset($opt_key, $opt); |
|
| 329 | - } |
|
| 330 | - } |
|
| 331 | - |
|
| 332 | - //Keep other options after bulk update |
|
| 333 | - if ( isset( $field['field_options']['other'] ) && $field['field_options']['other'] == true ) { |
|
| 334 | - $other_array = array(); |
|
| 335 | - foreach ( $field['options'] as $opt_key => $opt ) { |
|
| 319 | + if ( $field['separate_value'] ) { |
|
| 320 | + foreach ( $opts as $opt_key => $opt ) { |
|
| 321 | + if ( strpos($opt, '|') !== false ) { |
|
| 322 | + $vals = explode('|', $opt); |
|
| 323 | + if ( $vals[0] != $vals[1] ) { |
|
| 324 | + $opts[ $opt_key ] = array( 'label' => trim( $vals[0] ), 'value' => trim( $vals[1] ) ); |
|
| 325 | + } |
|
| 326 | + unset($vals); |
|
| 327 | + } |
|
| 328 | + unset($opt_key, $opt); |
|
| 329 | + } |
|
| 330 | + } |
|
| 331 | + |
|
| 332 | + //Keep other options after bulk update |
|
| 333 | + if ( isset( $field['field_options']['other'] ) && $field['field_options']['other'] == true ) { |
|
| 334 | + $other_array = array(); |
|
| 335 | + foreach ( $field['options'] as $opt_key => $opt ) { |
|
| 336 | 336 | if ( FrmFieldsHelper::is_other_opt( $opt_key ) ) { |
| 337 | 337 | $other_array[ $opt_key ] = $opt; |
| 338 | 338 | } |
| 339 | - unset($opt_key, $opt); |
|
| 340 | - } |
|
| 341 | - if ( ! empty($other_array) ) { |
|
| 342 | - $opts = array_merge( $opts, $other_array); |
|
| 343 | - } |
|
| 344 | - } |
|
| 339 | + unset($opt_key, $opt); |
|
| 340 | + } |
|
| 341 | + if ( ! empty($other_array) ) { |
|
| 342 | + $opts = array_merge( $opts, $other_array); |
|
| 343 | + } |
|
| 344 | + } |
|
| 345 | 345 | |
| 346 | - $field['options'] = $opts; |
|
| 346 | + $field['options'] = $opts; |
|
| 347 | 347 | |
| 348 | - if ( $field['type'] == 'radio' || $field['type'] == 'checkbox' ) { |
|
| 348 | + if ( $field['type'] == 'radio' || $field['type'] == 'checkbox' ) { |
|
| 349 | 349 | $field_name = 'item_meta[' . $field['id'] . ']'; |
| 350 | 350 | |
| 351 | 351 | // Get html_id which will be used in single-option.php |
| 352 | 352 | $html_id = FrmFieldsHelper::get_html_id( $field ); |
| 353 | 353 | |
| 354 | 354 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/radio.php' ); |
| 355 | - } else { |
|
| 356 | - FrmFieldsHelper::show_single_option($field); |
|
| 357 | - } |
|
| 355 | + } else { |
|
| 356 | + FrmFieldsHelper::show_single_option($field); |
|
| 357 | + } |
|
| 358 | 358 | |
| 359 | - wp_die(); |
|
| 360 | - } |
|
| 359 | + wp_die(); |
|
| 360 | + } |
|
| 361 | 361 | |
| 362 | - public static function update_order() { |
|
| 362 | + public static function update_order() { |
|
| 363 | 363 | FrmAppHelper::permission_check('frm_edit_forms'); |
| 364 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 364 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 365 | 365 | |
| 366 | 366 | $fields = FrmAppHelper::get_post_param( 'frm_field_id' ); |
| 367 | 367 | foreach ( (array) $fields as $position => $item ) { |
| 368 | 368 | FrmField::update( absint( $item ), array( 'field_order' => absint( $position ) ) ); |
| 369 | 369 | } |
| 370 | - wp_die(); |
|
| 371 | - } |
|
| 370 | + wp_die(); |
|
| 371 | + } |
|
| 372 | 372 | |
| 373 | 373 | public static function change_type( $type ) { |
| 374 | - $type_switch = array( |
|
| 375 | - 'scale' => 'radio', |
|
| 376 | - '10radio' => 'radio', |
|
| 377 | - 'rte' => 'textarea', |
|
| 378 | - 'website' => 'url', |
|
| 379 | - ); |
|
| 380 | - if ( isset( $type_switch[ $type ] ) ) { |
|
| 381 | - $type = $type_switch[ $type ]; |
|
| 382 | - } |
|
| 374 | + $type_switch = array( |
|
| 375 | + 'scale' => 'radio', |
|
| 376 | + '10radio' => 'radio', |
|
| 377 | + 'rte' => 'textarea', |
|
| 378 | + 'website' => 'url', |
|
| 379 | + ); |
|
| 380 | + if ( isset( $type_switch[ $type ] ) ) { |
|
| 381 | + $type = $type_switch[ $type ]; |
|
| 382 | + } |
|
| 383 | 383 | |
| 384 | 384 | $pro_fields = FrmField::pro_field_selection(); |
| 385 | 385 | $types = array_keys( $pro_fields ); |
@@ -387,137 +387,137 @@ discard block |
||
| 387 | 387 | $type = 'text'; |
| 388 | 388 | } |
| 389 | 389 | |
| 390 | - return $type; |
|
| 391 | - } |
|
| 390 | + return $type; |
|
| 391 | + } |
|
| 392 | 392 | |
| 393 | 393 | public static function display_field_options( $display ) { |
| 394 | 394 | switch ( $display['type'] ) { |
| 395 | - case 'captcha': |
|
| 396 | - $display['required'] = false; |
|
| 397 | - $display['invalid'] = true; |
|
| 398 | - $display['default_blank'] = false; |
|
| 395 | + case 'captcha': |
|
| 396 | + $display['required'] = false; |
|
| 397 | + $display['invalid'] = true; |
|
| 398 | + $display['default_blank'] = false; |
|
| 399 | 399 | $display['captcha_size'] = true; |
| 400 | - break; |
|
| 401 | - case 'radio': |
|
| 402 | - $display['default_blank'] = false; |
|
| 403 | - break; |
|
| 404 | - case 'text': |
|
| 405 | - case 'textarea': |
|
| 406 | - $display['size'] = true; |
|
| 407 | - $display['clear_on_focus'] = true; |
|
| 408 | - break; |
|
| 409 | - case 'select': |
|
| 410 | - $display['size'] = true; |
|
| 411 | - break; |
|
| 412 | - case 'url': |
|
| 413 | - case 'website': |
|
| 414 | - case 'email': |
|
| 415 | - $display['size'] = true; |
|
| 416 | - $display['clear_on_focus'] = true; |
|
| 417 | - $display['invalid'] = true; |
|
| 418 | - } |
|
| 419 | - |
|
| 420 | - return $display; |
|
| 421 | - } |
|
| 422 | - |
|
| 423 | - public static function input_html( $field, $echo = true ) { |
|
| 424 | - $class = array(); //$field['type']; |
|
| 425 | - self::add_input_classes($field, $class); |
|
| 426 | - |
|
| 427 | - $add_html = array(); |
|
| 428 | - self::add_html_size($field, $add_html); |
|
| 429 | - self::add_html_length($field, $add_html); |
|
| 430 | - self::add_html_placeholder($field, $add_html, $class); |
|
| 400 | + break; |
|
| 401 | + case 'radio': |
|
| 402 | + $display['default_blank'] = false; |
|
| 403 | + break; |
|
| 404 | + case 'text': |
|
| 405 | + case 'textarea': |
|
| 406 | + $display['size'] = true; |
|
| 407 | + $display['clear_on_focus'] = true; |
|
| 408 | + break; |
|
| 409 | + case 'select': |
|
| 410 | + $display['size'] = true; |
|
| 411 | + break; |
|
| 412 | + case 'url': |
|
| 413 | + case 'website': |
|
| 414 | + case 'email': |
|
| 415 | + $display['size'] = true; |
|
| 416 | + $display['clear_on_focus'] = true; |
|
| 417 | + $display['invalid'] = true; |
|
| 418 | + } |
|
| 419 | + |
|
| 420 | + return $display; |
|
| 421 | + } |
|
| 422 | + |
|
| 423 | + public static function input_html( $field, $echo = true ) { |
|
| 424 | + $class = array(); //$field['type']; |
|
| 425 | + self::add_input_classes($field, $class); |
|
| 426 | + |
|
| 427 | + $add_html = array(); |
|
| 428 | + self::add_html_size($field, $add_html); |
|
| 429 | + self::add_html_length($field, $add_html); |
|
| 430 | + self::add_html_placeholder($field, $add_html, $class); |
|
| 431 | 431 | self::add_validation_messages( $field, $add_html ); |
| 432 | 432 | |
| 433 | - $class = apply_filters('frm_field_classes', implode(' ', $class), $field); |
|
| 433 | + $class = apply_filters('frm_field_classes', implode(' ', $class), $field); |
|
| 434 | 434 | |
| 435 | 435 | FrmFormsHelper::add_html_attr( $class, 'class', $add_html ); |
| 436 | 436 | |
| 437 | - self::add_shortcodes_to_html($field, $add_html); |
|
| 437 | + self::add_shortcodes_to_html($field, $add_html); |
|
| 438 | 438 | |
| 439 | 439 | $add_html = apply_filters( 'frm_field_extra_html', $add_html, $field ); |
| 440 | 440 | $add_html = ' ' . implode( ' ', $add_html ) . ' '; |
| 441 | 441 | |
| 442 | - if ( $echo ) { |
|
| 443 | - echo $add_html; |
|
| 444 | - } |
|
| 442 | + if ( $echo ) { |
|
| 443 | + echo $add_html; |
|
| 444 | + } |
|
| 445 | 445 | |
| 446 | - return $add_html; |
|
| 447 | - } |
|
| 446 | + return $add_html; |
|
| 447 | + } |
|
| 448 | 448 | |
| 449 | 449 | private static function add_input_classes( $field, array &$class ) { |
| 450 | - if ( isset($field['input_class']) && ! empty($field['input_class']) ) { |
|
| 451 | - $class[] = $field['input_class']; |
|
| 452 | - } |
|
| 450 | + if ( isset($field['input_class']) && ! empty($field['input_class']) ) { |
|
| 451 | + $class[] = $field['input_class']; |
|
| 452 | + } |
|
| 453 | 453 | |
| 454 | - if ( $field['type'] == 'hidden' || $field['type'] == 'user_id' ) { |
|
| 455 | - return; |
|
| 456 | - } |
|
| 454 | + if ( $field['type'] == 'hidden' || $field['type'] == 'user_id' ) { |
|
| 455 | + return; |
|
| 456 | + } |
|
| 457 | 457 | |
| 458 | - if ( isset($field['size']) && $field['size'] > 0 ) { |
|
| 459 | - $class[] = 'auto_width'; |
|
| 460 | - } |
|
| 461 | - } |
|
| 458 | + if ( isset($field['size']) && $field['size'] > 0 ) { |
|
| 459 | + $class[] = 'auto_width'; |
|
| 460 | + } |
|
| 461 | + } |
|
| 462 | 462 | |
| 463 | 463 | private static function add_html_size( $field, array &$add_html ) { |
| 464 | 464 | if ( ! isset( $field['size'] ) || $field['size'] <= 0 || in_array( $field['type'], array( 'select', 'data', 'time', 'hidden', 'file', 'lookup' ) ) ) { |
| 465 | - return; |
|
| 466 | - } |
|
| 465 | + return; |
|
| 466 | + } |
|
| 467 | 467 | |
| 468 | - if ( FrmAppHelper::is_admin_page('formidable' ) ) { |
|
| 469 | - return; |
|
| 470 | - } |
|
| 468 | + if ( FrmAppHelper::is_admin_page('formidable' ) ) { |
|
| 469 | + return; |
|
| 470 | + } |
|
| 471 | 471 | |
| 472 | - if ( is_numeric($field['size']) ) { |
|
| 473 | - $field['size'] .= 'px'; |
|
| 474 | - } |
|
| 472 | + if ( is_numeric($field['size']) ) { |
|
| 473 | + $field['size'] .= 'px'; |
|
| 474 | + } |
|
| 475 | 475 | |
| 476 | - $important = apply_filters('frm_use_important_width', 1, $field); |
|
| 477 | - // Note: This inline styling must stay since we cannot realistically set a class for every possible field size |
|
| 476 | + $important = apply_filters('frm_use_important_width', 1, $field); |
|
| 477 | + // Note: This inline styling must stay since we cannot realistically set a class for every possible field size |
|
| 478 | 478 | $add_html['style'] = 'style="width:' . esc_attr( $field['size'] ) . ( $important ? ' !important' : '' ) . '"'; |
| 479 | 479 | |
| 480 | - self::add_html_cols($field, $add_html); |
|
| 481 | - } |
|
| 480 | + self::add_html_cols($field, $add_html); |
|
| 481 | + } |
|
| 482 | 482 | |
| 483 | 483 | private static function add_html_cols( $field, array &$add_html ) { |
| 484 | 484 | if ( ! in_array( $field['type'], array( 'textarea', 'rte' ) ) ) { |
| 485 | - return; |
|
| 486 | - } |
|
| 485 | + return; |
|
| 486 | + } |
|
| 487 | 487 | |
| 488 | - // convert to cols for textareas |
|
| 489 | - $calc = array( |
|
| 490 | - '' => 9, |
|
| 491 | - 'px' => 9, |
|
| 492 | - 'rem' => 0.444, |
|
| 493 | - 'em' => 0.544, |
|
| 494 | - ); |
|
| 488 | + // convert to cols for textareas |
|
| 489 | + $calc = array( |
|
| 490 | + '' => 9, |
|
| 491 | + 'px' => 9, |
|
| 492 | + 'rem' => 0.444, |
|
| 493 | + 'em' => 0.544, |
|
| 494 | + ); |
|
| 495 | 495 | |
| 496 | - // include "col" for valid html |
|
| 497 | - $unit = trim(preg_replace('/[0-9]+/', '', $field['size'])); |
|
| 496 | + // include "col" for valid html |
|
| 497 | + $unit = trim(preg_replace('/[0-9]+/', '', $field['size'])); |
|
| 498 | 498 | |
| 499 | - if ( ! isset( $calc[ $unit ] ) ) { |
|
| 500 | - return; |
|
| 501 | - } |
|
| 499 | + if ( ! isset( $calc[ $unit ] ) ) { |
|
| 500 | + return; |
|
| 501 | + } |
|
| 502 | 502 | |
| 503 | - $size = (float) str_replace( $unit, '', $field['size'] ) / $calc[ $unit ]; |
|
| 503 | + $size = (float) str_replace( $unit, '', $field['size'] ) / $calc[ $unit ]; |
|
| 504 | 504 | |
| 505 | 505 | $add_html['cols'] = 'cols="' . absint( $size ) . '"'; |
| 506 | - } |
|
| 506 | + } |
|
| 507 | 507 | |
| 508 | 508 | private static function add_html_length( $field, array &$add_html ) { |
| 509 | - // check for max setting and if this field accepts maxlength |
|
| 509 | + // check for max setting and if this field accepts maxlength |
|
| 510 | 510 | if ( FrmField::is_option_empty( $field, 'max' ) || in_array( $field['type'], array( 'textarea', 'rte', 'hidden', 'file' ) ) ) { |
| 511 | - return; |
|
| 512 | - } |
|
| 511 | + return; |
|
| 512 | + } |
|
| 513 | 513 | |
| 514 | - if ( FrmAppHelper::is_admin_page('formidable' ) ) { |
|
| 515 | - // don't load on form builder page |
|
| 516 | - return; |
|
| 517 | - } |
|
| 514 | + if ( FrmAppHelper::is_admin_page('formidable' ) ) { |
|
| 515 | + // don't load on form builder page |
|
| 516 | + return; |
|
| 517 | + } |
|
| 518 | 518 | |
| 519 | 519 | $add_html['maxlength'] = 'maxlength="' . esc_attr( $field['max'] ) . '"'; |
| 520 | - } |
|
| 520 | + } |
|
| 521 | 521 | |
| 522 | 522 | private static function add_html_placeholder( $field, array &$add_html, array &$class ) { |
| 523 | 523 | if ( FrmAppHelper::is_admin_page( 'formidable' ) ) { |
@@ -614,44 +614,44 @@ discard block |
||
| 614 | 614 | } |
| 615 | 615 | } |
| 616 | 616 | |
| 617 | - private static function add_shortcodes_to_html( $field, array &$add_html ) { |
|
| 618 | - if ( FrmField::is_option_empty( $field, 'shortcodes' ) ) { |
|
| 619 | - return; |
|
| 620 | - } |
|
| 617 | + private static function add_shortcodes_to_html( $field, array &$add_html ) { |
|
| 618 | + if ( FrmField::is_option_empty( $field, 'shortcodes' ) ) { |
|
| 619 | + return; |
|
| 620 | + } |
|
| 621 | 621 | |
| 622 | - foreach ( $field['shortcodes'] as $k => $v ) { |
|
| 623 | - if ( 'opt' === $k ) { |
|
| 624 | - continue; |
|
| 625 | - } |
|
| 622 | + foreach ( $field['shortcodes'] as $k => $v ) { |
|
| 623 | + if ( 'opt' === $k ) { |
|
| 624 | + continue; |
|
| 625 | + } |
|
| 626 | 626 | |
| 627 | - if ( is_numeric($k) && strpos($v, '=') ) { |
|
| 628 | - $add_html[] = $v; |
|
| 629 | - } else if ( ! empty( $k ) && isset( $add_html[ $k ] ) ) { |
|
| 627 | + if ( is_numeric($k) && strpos($v, '=') ) { |
|
| 628 | + $add_html[] = $v; |
|
| 629 | + } else if ( ! empty( $k ) && isset( $add_html[ $k ] ) ) { |
|
| 630 | 630 | $add_html[ $k ] = str_replace( $k . '="', $k . '="' . $v, $add_html[ $k ] ); |
| 631 | - } else { |
|
| 631 | + } else { |
|
| 632 | 632 | $add_html[ $k ] = $k . '="' . esc_attr( $v ) . '"'; |
| 633 | - } |
|
| 634 | - |
|
| 635 | - unset($k, $v); |
|
| 636 | - } |
|
| 637 | - } |
|
| 638 | - |
|
| 639 | - public static function check_value( $opt, $opt_key, $field ) { |
|
| 640 | - if ( is_array( $opt ) ) { |
|
| 641 | - if ( FrmField::is_option_true( $field, 'separate_value' ) ) { |
|
| 642 | - $opt = isset( $opt['value'] ) ? $opt['value'] : ( isset( $opt['label'] ) ? $opt['label'] : reset( $opt ) ); |
|
| 643 | - } else { |
|
| 644 | - $opt = isset( $opt['label'] ) ? $opt['label'] : reset( $opt ); |
|
| 645 | - } |
|
| 646 | - } |
|
| 647 | - return $opt; |
|
| 648 | - } |
|
| 633 | + } |
|
| 634 | + |
|
| 635 | + unset($k, $v); |
|
| 636 | + } |
|
| 637 | + } |
|
| 638 | + |
|
| 639 | + public static function check_value( $opt, $opt_key, $field ) { |
|
| 640 | + if ( is_array( $opt ) ) { |
|
| 641 | + if ( FrmField::is_option_true( $field, 'separate_value' ) ) { |
|
| 642 | + $opt = isset( $opt['value'] ) ? $opt['value'] : ( isset( $opt['label'] ) ? $opt['label'] : reset( $opt ) ); |
|
| 643 | + } else { |
|
| 644 | + $opt = isset( $opt['label'] ) ? $opt['label'] : reset( $opt ); |
|
| 645 | + } |
|
| 646 | + } |
|
| 647 | + return $opt; |
|
| 648 | + } |
|
| 649 | 649 | |
| 650 | 650 | public static function check_label( $opt ) { |
| 651 | - if ( is_array($opt) ) { |
|
| 652 | - $opt = (isset($opt['label']) ? $opt['label'] : reset($opt)); |
|
| 653 | - } |
|
| 651 | + if ( is_array($opt) ) { |
|
| 652 | + $opt = (isset($opt['label']) ? $opt['label'] : reset($opt)); |
|
| 653 | + } |
|
| 654 | 654 | |
| 655 | - return $opt; |
|
| 656 | - } |
|
| 655 | + return $opt; |
|
| 656 | + } |
|
| 657 | 657 | } |
@@ -3,7 +3,7 @@ discard block |
||
| 3 | 3 | class FrmFieldsController { |
| 4 | 4 | |
| 5 | 5 | public static function load_field() { |
| 6 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 6 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
| 7 | 7 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 8 | 8 | |
| 9 | 9 | $fields = $_POST['field']; |
@@ -34,17 +34,17 @@ discard block |
||
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | $field_name = 'item_meta[' . $field_id . ']'; |
| 37 | - $html_id = FrmFieldsHelper::get_html_id($field); |
|
| 37 | + $html_id = FrmFieldsHelper::get_html_id( $field ); |
|
| 38 | 38 | |
| 39 | 39 | ob_start(); |
| 40 | 40 | include( $path . '/classes/views/frm-forms/add_field.php' ); |
| 41 | - $field_html[ $field_id ] = ob_get_contents(); |
|
| 41 | + $field_html[$field_id] = ob_get_contents(); |
|
| 42 | 42 | ob_end_clean(); |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | - unset($path); |
|
| 45 | + unset( $path ); |
|
| 46 | 46 | |
| 47 | - echo json_encode($field_html); |
|
| 47 | + echo json_encode( $field_html ); |
|
| 48 | 48 | |
| 49 | 49 | wp_die(); |
| 50 | 50 | } |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | * Create a new field with ajax |
| 54 | 54 | */ |
| 55 | 55 | public static function create() { |
| 56 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 56 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
| 57 | 57 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 58 | 58 | |
| 59 | 59 | $field_type = FrmAppHelper::get_post_param( 'field_type', '', 'sanitize_text_field' ); |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | $field = self::include_new_field( $field_type, $form_id ); |
| 63 | 63 | |
| 64 | 64 | // this hook will allow for multiple fields to be added at once |
| 65 | - do_action('frm_after_field_created', $field, $form_id); |
|
| 65 | + do_action( 'frm_after_field_created', $field, $form_id ); |
|
| 66 | 66 | |
| 67 | 67 | wp_die(); |
| 68 | 68 | } |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | public static function include_new_field( $field_type, $form_id ) { |
| 78 | 78 | $values = array(); |
| 79 | 79 | if ( FrmAppHelper::pro_is_installed() ) { |
| 80 | - $values['post_type'] = FrmProFormsHelper::post_type($form_id); |
|
| 80 | + $values['post_type'] = FrmProFormsHelper::post_type( $form_id ); |
|
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | $field_values = FrmFieldsHelper::setup_new_vars( $field_type, $form_id ); |
@@ -89,27 +89,27 @@ discard block |
||
| 89 | 89 | return false; |
| 90 | 90 | } |
| 91 | 91 | |
| 92 | - $field = self::include_single_field($field_id, $values, $form_id); |
|
| 92 | + $field = self::include_single_field( $field_id, $values, $form_id ); |
|
| 93 | 93 | |
| 94 | 94 | return $field; |
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | public static function edit_name( $field = 'name', $id = '' ) { |
| 98 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 98 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
| 99 | 99 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 100 | 100 | |
| 101 | - if ( empty($field) ) { |
|
| 101 | + if ( empty( $field ) ) { |
|
| 102 | 102 | $field = 'name'; |
| 103 | 103 | } |
| 104 | 104 | |
| 105 | - if ( empty($id) ) { |
|
| 105 | + if ( empty( $id ) ) { |
|
| 106 | 106 | $id = FrmAppHelper::get_post_param( 'element_id', '', 'sanitize_title' ); |
| 107 | 107 | $id = str_replace( 'field_label_', '', $id ); |
| 108 | 108 | } |
| 109 | 109 | |
| 110 | 110 | $value = FrmAppHelper::get_post_param( 'update_value', '', 'wp_kses_post' ); |
| 111 | 111 | $value = trim( $value ); |
| 112 | - if ( trim(strip_tags($value)) == '' ) { |
|
| 112 | + if ( trim( strip_tags( $value ) ) == '' ) { |
|
| 113 | 113 | // set blank value if there is no content |
| 114 | 114 | $value = ''; |
| 115 | 115 | } |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | public static function update_ajax_option() { |
| 126 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 126 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
| 127 | 127 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 128 | 128 | |
| 129 | 129 | $field_id = FrmAppHelper::get_post_param( 'field', 0, 'absint' ); |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | if ( isset( $_POST['separate_value'] ) ) { |
| 137 | 137 | $new_val = FrmField::is_option_true( $field, 'separate_value' ) ? 0 : 1; |
| 138 | 138 | $field->field_options['separate_value'] = $new_val; |
| 139 | - unset($new_val); |
|
| 139 | + unset( $new_val ); |
|
| 140 | 140 | } |
| 141 | 141 | |
| 142 | 142 | FrmField::update( $field_id, array( |
@@ -147,7 +147,7 @@ discard block |
||
| 147 | 147 | } |
| 148 | 148 | |
| 149 | 149 | public static function duplicate() { |
| 150 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 150 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
| 151 | 151 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 152 | 152 | |
| 153 | 153 | global $wpdb; |
@@ -172,7 +172,7 @@ discard block |
||
| 172 | 172 | wp_die(); |
| 173 | 173 | } |
| 174 | 174 | |
| 175 | - self::include_single_field($field_id, $values); |
|
| 175 | + self::include_single_field( $field_id, $values ); |
|
| 176 | 176 | |
| 177 | 177 | wp_die(); |
| 178 | 178 | } |
@@ -181,9 +181,9 @@ discard block |
||
| 181 | 181 | * Load a single field in the form builder along with all needed variables |
| 182 | 182 | */ |
| 183 | 183 | public static function include_single_field( $field_id, $values, $form_id = 0 ) { |
| 184 | - $field = FrmFieldsHelper::setup_edit_vars(FrmField::getOne($field_id)); |
|
| 184 | + $field = FrmFieldsHelper::setup_edit_vars( FrmField::getOne( $field_id ) ); |
|
| 185 | 185 | $field_name = 'item_meta[' . $field_id . ']'; |
| 186 | - $html_id = FrmFieldsHelper::get_html_id($field); |
|
| 186 | + $html_id = FrmFieldsHelper::get_html_id( $field ); |
|
| 187 | 187 | $id = $form_id ? $form_id : $field['form_id']; |
| 188 | 188 | if ( $field['type'] == 'html' ) { |
| 189 | 189 | $field['stop_filter'] = true; |
@@ -195,7 +195,7 @@ discard block |
||
| 195 | 195 | } |
| 196 | 196 | |
| 197 | 197 | public static function destroy() { |
| 198 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 198 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
| 199 | 199 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 200 | 200 | |
| 201 | 201 | $field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' ); |
@@ -207,14 +207,14 @@ discard block |
||
| 207 | 207 | |
| 208 | 208 | //Add Single Option or Other Option |
| 209 | 209 | public static function add_option() { |
| 210 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 210 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
| 211 | 211 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 212 | 212 | |
| 213 | 213 | $id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' ); |
| 214 | 214 | $opt_type = FrmAppHelper::get_post_param( 'opt_type', '', 'sanitize_text_field' ); |
| 215 | 215 | $opt_key = FrmAppHelper::get_post_param( 'opt_key', 0, 'absint' ); |
| 216 | 216 | |
| 217 | - $field = FrmField::getOne($id); |
|
| 217 | + $field = FrmField::getOne( $id ); |
|
| 218 | 218 | |
| 219 | 219 | if ( 'other' == $opt_type ) { |
| 220 | 220 | $opt = __( 'Other', 'formidable' ); |
@@ -284,9 +284,9 @@ discard block |
||
| 284 | 284 | |
| 285 | 285 | $admin_body_class .= ' admin-color-' . sanitize_html_class( get_user_option( 'admin_color' ), 'fresh' ); |
| 286 | 286 | $prepop = array(); |
| 287 | - FrmFieldsHelper::get_bulk_prefilled_opts($prepop); |
|
| 287 | + FrmFieldsHelper::get_bulk_prefilled_opts( $prepop ); |
|
| 288 | 288 | |
| 289 | - $field = FrmField::getOne($field_id); |
|
| 289 | + $field = FrmField::getOne( $field_id ); |
|
| 290 | 290 | |
| 291 | 291 | wp_enqueue_script( 'utils' ); |
| 292 | 292 | wp_enqueue_style( 'formidable-admin', FrmAppHelper::plugin_url() . '/css/frm_admin.css' ); |
@@ -297,35 +297,35 @@ discard block |
||
| 297 | 297 | } |
| 298 | 298 | |
| 299 | 299 | public static function import_options() { |
| 300 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 300 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
| 301 | 301 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 302 | 302 | |
| 303 | - if ( ! is_admin() || ! current_user_can('frm_edit_forms') ) { |
|
| 303 | + if ( ! is_admin() || ! current_user_can( 'frm_edit_forms' ) ) { |
|
| 304 | 304 | return; |
| 305 | 305 | } |
| 306 | 306 | |
| 307 | 307 | $field_id = absint( $_POST['field_id'] ); |
| 308 | - $field = FrmField::getOne($field_id); |
|
| 308 | + $field = FrmField::getOne( $field_id ); |
|
| 309 | 309 | |
| 310 | 310 | if ( ! in_array( $field->type, array( 'radio', 'checkbox', 'select' ) ) ) { |
| 311 | 311 | return; |
| 312 | 312 | } |
| 313 | 313 | |
| 314 | - $field = FrmFieldsHelper::setup_edit_vars($field); |
|
| 314 | + $field = FrmFieldsHelper::setup_edit_vars( $field ); |
|
| 315 | 315 | $opts = FrmAppHelper::get_param( 'opts', '', 'post', 'wp_kses_post' ); |
| 316 | 316 | $opts = explode( "\n", rtrim( $opts, "\n" ) ); |
| 317 | 317 | $opts = array_map( 'trim', $opts ); |
| 318 | 318 | |
| 319 | 319 | if ( $field['separate_value'] ) { |
| 320 | 320 | foreach ( $opts as $opt_key => $opt ) { |
| 321 | - if ( strpos($opt, '|') !== false ) { |
|
| 322 | - $vals = explode('|', $opt); |
|
| 321 | + if ( strpos( $opt, '|' ) !== false ) { |
|
| 322 | + $vals = explode( '|', $opt ); |
|
| 323 | 323 | if ( $vals[0] != $vals[1] ) { |
| 324 | - $opts[ $opt_key ] = array( 'label' => trim( $vals[0] ), 'value' => trim( $vals[1] ) ); |
|
| 324 | + $opts[$opt_key] = array( 'label' => trim( $vals[0] ), 'value' => trim( $vals[1] ) ); |
|
| 325 | 325 | } |
| 326 | - unset($vals); |
|
| 326 | + unset( $vals ); |
|
| 327 | 327 | } |
| 328 | - unset($opt_key, $opt); |
|
| 328 | + unset( $opt_key, $opt ); |
|
| 329 | 329 | } |
| 330 | 330 | } |
| 331 | 331 | |
@@ -334,12 +334,12 @@ discard block |
||
| 334 | 334 | $other_array = array(); |
| 335 | 335 | foreach ( $field['options'] as $opt_key => $opt ) { |
| 336 | 336 | if ( FrmFieldsHelper::is_other_opt( $opt_key ) ) { |
| 337 | - $other_array[ $opt_key ] = $opt; |
|
| 337 | + $other_array[$opt_key] = $opt; |
|
| 338 | 338 | } |
| 339 | - unset($opt_key, $opt); |
|
| 339 | + unset( $opt_key, $opt ); |
|
| 340 | 340 | } |
| 341 | - if ( ! empty($other_array) ) { |
|
| 342 | - $opts = array_merge( $opts, $other_array); |
|
| 341 | + if ( ! empty( $other_array ) ) { |
|
| 342 | + $opts = array_merge( $opts, $other_array ); |
|
| 343 | 343 | } |
| 344 | 344 | } |
| 345 | 345 | |
@@ -353,14 +353,14 @@ discard block |
||
| 353 | 353 | |
| 354 | 354 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/radio.php' ); |
| 355 | 355 | } else { |
| 356 | - FrmFieldsHelper::show_single_option($field); |
|
| 356 | + FrmFieldsHelper::show_single_option( $field ); |
|
| 357 | 357 | } |
| 358 | 358 | |
| 359 | 359 | wp_die(); |
| 360 | 360 | } |
| 361 | 361 | |
| 362 | 362 | public static function update_order() { |
| 363 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 363 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
| 364 | 364 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 365 | 365 | |
| 366 | 366 | $fields = FrmAppHelper::get_post_param( 'frm_field_id' ); |
@@ -377,8 +377,8 @@ discard block |
||
| 377 | 377 | 'rte' => 'textarea', |
| 378 | 378 | 'website' => 'url', |
| 379 | 379 | ); |
| 380 | - if ( isset( $type_switch[ $type ] ) ) { |
|
| 381 | - $type = $type_switch[ $type ]; |
|
| 380 | + if ( isset( $type_switch[$type] ) ) { |
|
| 381 | + $type = $type_switch[$type]; |
|
| 382 | 382 | } |
| 383 | 383 | |
| 384 | 384 | $pro_fields = FrmField::pro_field_selection(); |
@@ -422,19 +422,19 @@ discard block |
||
| 422 | 422 | |
| 423 | 423 | public static function input_html( $field, $echo = true ) { |
| 424 | 424 | $class = array(); //$field['type']; |
| 425 | - self::add_input_classes($field, $class); |
|
| 425 | + self::add_input_classes( $field, $class ); |
|
| 426 | 426 | |
| 427 | 427 | $add_html = array(); |
| 428 | - self::add_html_size($field, $add_html); |
|
| 429 | - self::add_html_length($field, $add_html); |
|
| 430 | - self::add_html_placeholder($field, $add_html, $class); |
|
| 428 | + self::add_html_size( $field, $add_html ); |
|
| 429 | + self::add_html_length( $field, $add_html ); |
|
| 430 | + self::add_html_placeholder( $field, $add_html, $class ); |
|
| 431 | 431 | self::add_validation_messages( $field, $add_html ); |
| 432 | 432 | |
| 433 | - $class = apply_filters('frm_field_classes', implode(' ', $class), $field); |
|
| 433 | + $class = apply_filters( 'frm_field_classes', implode( ' ', $class ), $field ); |
|
| 434 | 434 | |
| 435 | 435 | FrmFormsHelper::add_html_attr( $class, 'class', $add_html ); |
| 436 | 436 | |
| 437 | - self::add_shortcodes_to_html($field, $add_html); |
|
| 437 | + self::add_shortcodes_to_html( $field, $add_html ); |
|
| 438 | 438 | |
| 439 | 439 | $add_html = apply_filters( 'frm_field_extra_html', $add_html, $field ); |
| 440 | 440 | $add_html = ' ' . implode( ' ', $add_html ) . ' '; |
@@ -447,7 +447,7 @@ discard block |
||
| 447 | 447 | } |
| 448 | 448 | |
| 449 | 449 | private static function add_input_classes( $field, array &$class ) { |
| 450 | - if ( isset($field['input_class']) && ! empty($field['input_class']) ) { |
|
| 450 | + if ( isset( $field['input_class'] ) && ! empty( $field['input_class'] ) ) { |
|
| 451 | 451 | $class[] = $field['input_class']; |
| 452 | 452 | } |
| 453 | 453 | |
@@ -455,7 +455,7 @@ discard block |
||
| 455 | 455 | return; |
| 456 | 456 | } |
| 457 | 457 | |
| 458 | - if ( isset($field['size']) && $field['size'] > 0 ) { |
|
| 458 | + if ( isset( $field['size'] ) && $field['size'] > 0 ) { |
|
| 459 | 459 | $class[] = 'auto_width'; |
| 460 | 460 | } |
| 461 | 461 | } |
@@ -465,19 +465,19 @@ discard block |
||
| 465 | 465 | return; |
| 466 | 466 | } |
| 467 | 467 | |
| 468 | - if ( FrmAppHelper::is_admin_page('formidable' ) ) { |
|
| 468 | + if ( FrmAppHelper::is_admin_page( 'formidable' ) ) { |
|
| 469 | 469 | return; |
| 470 | 470 | } |
| 471 | 471 | |
| 472 | - if ( is_numeric($field['size']) ) { |
|
| 472 | + if ( is_numeric( $field['size'] ) ) { |
|
| 473 | 473 | $field['size'] .= 'px'; |
| 474 | 474 | } |
| 475 | 475 | |
| 476 | - $important = apply_filters('frm_use_important_width', 1, $field); |
|
| 476 | + $important = apply_filters( 'frm_use_important_width', 1, $field ); |
|
| 477 | 477 | // Note: This inline styling must stay since we cannot realistically set a class for every possible field size |
| 478 | 478 | $add_html['style'] = 'style="width:' . esc_attr( $field['size'] ) . ( $important ? ' !important' : '' ) . '"'; |
| 479 | 479 | |
| 480 | - self::add_html_cols($field, $add_html); |
|
| 480 | + self::add_html_cols( $field, $add_html ); |
|
| 481 | 481 | } |
| 482 | 482 | |
| 483 | 483 | private static function add_html_cols( $field, array &$add_html ) { |
@@ -494,13 +494,13 @@ discard block |
||
| 494 | 494 | ); |
| 495 | 495 | |
| 496 | 496 | // include "col" for valid html |
| 497 | - $unit = trim(preg_replace('/[0-9]+/', '', $field['size'])); |
|
| 497 | + $unit = trim( preg_replace( '/[0-9]+/', '', $field['size'] ) ); |
|
| 498 | 498 | |
| 499 | - if ( ! isset( $calc[ $unit ] ) ) { |
|
| 499 | + if ( ! isset( $calc[$unit] ) ) { |
|
| 500 | 500 | return; |
| 501 | 501 | } |
| 502 | 502 | |
| 503 | - $size = (float) str_replace( $unit, '', $field['size'] ) / $calc[ $unit ]; |
|
| 503 | + $size = (float) str_replace( $unit, '', $field['size'] ) / $calc[$unit]; |
|
| 504 | 504 | |
| 505 | 505 | $add_html['cols'] = 'cols="' . absint( $size ) . '"'; |
| 506 | 506 | } |
@@ -511,7 +511,7 @@ discard block |
||
| 511 | 511 | return; |
| 512 | 512 | } |
| 513 | 513 | |
| 514 | - if ( FrmAppHelper::is_admin_page('formidable' ) ) { |
|
| 514 | + if ( FrmAppHelper::is_admin_page( 'formidable' ) ) { |
|
| 515 | 515 | // don't load on form builder page |
| 516 | 516 | return; |
| 517 | 517 | } |
@@ -591,7 +591,7 @@ discard block |
||
| 591 | 591 | private static function add_placeholder_to_input( $field, &$add_html ) { |
| 592 | 592 | if ( FrmFieldsHelper::is_placeholder_field_type( $field['type'] ) ) { |
| 593 | 593 | $add_html['placeholder'] = 'placeholder="' . esc_attr( $field['default_value'] ) . '"'; |
| 594 | - wp_enqueue_script('jquery-placeholder'); |
|
| 594 | + wp_enqueue_script( 'jquery-placeholder' ); |
|
| 595 | 595 | } |
| 596 | 596 | } |
| 597 | 597 | |
@@ -624,15 +624,15 @@ discard block |
||
| 624 | 624 | continue; |
| 625 | 625 | } |
| 626 | 626 | |
| 627 | - if ( is_numeric($k) && strpos($v, '=') ) { |
|
| 627 | + if ( is_numeric( $k ) && strpos( $v, '=' ) ) { |
|
| 628 | 628 | $add_html[] = $v; |
| 629 | - } else if ( ! empty( $k ) && isset( $add_html[ $k ] ) ) { |
|
| 630 | - $add_html[ $k ] = str_replace( $k . '="', $k . '="' . $v, $add_html[ $k ] ); |
|
| 629 | + } else if ( ! empty( $k ) && isset( $add_html[$k] ) ) { |
|
| 630 | + $add_html[$k] = str_replace( $k . '="', $k . '="' . $v, $add_html[$k] ); |
|
| 631 | 631 | } else { |
| 632 | - $add_html[ $k ] = $k . '="' . esc_attr( $v ) . '"'; |
|
| 632 | + $add_html[$k] = $k . '="' . esc_attr( $v ) . '"'; |
|
| 633 | 633 | } |
| 634 | 634 | |
| 635 | - unset($k, $v); |
|
| 635 | + unset( $k, $v ); |
|
| 636 | 636 | } |
| 637 | 637 | } |
| 638 | 638 | |
@@ -648,8 +648,8 @@ discard block |
||
| 648 | 648 | } |
| 649 | 649 | |
| 650 | 650 | public static function check_label( $opt ) { |
| 651 | - if ( is_array($opt) ) { |
|
| 652 | - $opt = (isset($opt['label']) ? $opt['label'] : reset($opt)); |
|
| 651 | + if ( is_array( $opt ) ) { |
|
| 652 | + $opt = ( isset( $opt['label'] ) ? $opt['label'] : reset( $opt ) ); |
|
| 653 | 653 | } |
| 654 | 654 | |
| 655 | 655 | return $opt; |