@@ -1,67 +1,67 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | class FrmStylesHelper { |
| 3 | 3 | |
| 4 | - public static function jquery_themes() { |
|
| 5 | - $themes = array( |
|
| 6 | - 'ui-lightness' => 'UI Lightness', |
|
| 7 | - 'ui-darkness' => 'UI Darkness', |
|
| 8 | - 'smoothness' => 'Smoothness', |
|
| 9 | - 'start' => 'Start', |
|
| 10 | - 'redmond' => 'Redmond', |
|
| 11 | - 'sunny' => 'Sunny', |
|
| 12 | - 'overcast' => 'Overcast', |
|
| 13 | - 'le-frog' => 'Le Frog', |
|
| 14 | - 'flick' => 'Flick', |
|
| 4 | + public static function jquery_themes() { |
|
| 5 | + $themes = array( |
|
| 6 | + 'ui-lightness' => 'UI Lightness', |
|
| 7 | + 'ui-darkness' => 'UI Darkness', |
|
| 8 | + 'smoothness' => 'Smoothness', |
|
| 9 | + 'start' => 'Start', |
|
| 10 | + 'redmond' => 'Redmond', |
|
| 11 | + 'sunny' => 'Sunny', |
|
| 12 | + 'overcast' => 'Overcast', |
|
| 13 | + 'le-frog' => 'Le Frog', |
|
| 14 | + 'flick' => 'Flick', |
|
| 15 | 15 | 'pepper-grinder' => 'Pepper Grinder', |
| 16 | - 'eggplant' => 'Eggplant', |
|
| 17 | - 'dark-hive' => 'Dark Hive', |
|
| 18 | - 'cupertino' => 'Cupertino', |
|
| 19 | - 'south-street' => 'South Street', |
|
| 20 | - 'blitzer' => 'Blitzer', |
|
| 21 | - 'humanity' => 'Humanity', |
|
| 22 | - 'hot-sneaks' => 'Hot Sneaks', |
|
| 23 | - 'excite-bike' => 'Excite Bike', |
|
| 24 | - 'vader' => 'Vader', |
|
| 25 | - 'dot-luv' => 'Dot Luv', |
|
| 26 | - 'mint-choc' => 'Mint Choc', |
|
| 27 | - 'black-tie' => 'Black Tie', |
|
| 28 | - 'trontastic' => 'Trontastic', |
|
| 29 | - 'swanky-purse' => 'Swanky Purse', |
|
| 30 | - ); |
|
| 31 | - |
|
| 32 | - $themes = apply_filters('frm_jquery_themes', $themes); |
|
| 33 | - return $themes; |
|
| 34 | - } |
|
| 16 | + 'eggplant' => 'Eggplant', |
|
| 17 | + 'dark-hive' => 'Dark Hive', |
|
| 18 | + 'cupertino' => 'Cupertino', |
|
| 19 | + 'south-street' => 'South Street', |
|
| 20 | + 'blitzer' => 'Blitzer', |
|
| 21 | + 'humanity' => 'Humanity', |
|
| 22 | + 'hot-sneaks' => 'Hot Sneaks', |
|
| 23 | + 'excite-bike' => 'Excite Bike', |
|
| 24 | + 'vader' => 'Vader', |
|
| 25 | + 'dot-luv' => 'Dot Luv', |
|
| 26 | + 'mint-choc' => 'Mint Choc', |
|
| 27 | + 'black-tie' => 'Black Tie', |
|
| 28 | + 'trontastic' => 'Trontastic', |
|
| 29 | + 'swanky-purse' => 'Swanky Purse', |
|
| 30 | + ); |
|
| 31 | + |
|
| 32 | + $themes = apply_filters('frm_jquery_themes', $themes); |
|
| 33 | + return $themes; |
|
| 34 | + } |
|
| 35 | 35 | |
| 36 | 36 | public static function jquery_css_url( $theme_css ) { |
| 37 | - if ( $theme_css == -1 ) { |
|
| 38 | - return; |
|
| 39 | - } |
|
| 40 | - |
|
| 41 | - if ( ! $theme_css || $theme_css == '' || $theme_css == 'ui-lightness' ) { |
|
| 42 | - $css_file = FrmAppHelper::plugin_url() . '/css/ui-lightness/jquery-ui.css'; |
|
| 43 | - } else if ( preg_match('/^http.?:\/\/.*\..*$/', $theme_css) ) { |
|
| 44 | - $css_file = $theme_css; |
|
| 45 | - } else { |
|
| 46 | - $uploads = self::get_upload_base(); |
|
| 37 | + if ( $theme_css == -1 ) { |
|
| 38 | + return; |
|
| 39 | + } |
|
| 40 | + |
|
| 41 | + if ( ! $theme_css || $theme_css == '' || $theme_css == 'ui-lightness' ) { |
|
| 42 | + $css_file = FrmAppHelper::plugin_url() . '/css/ui-lightness/jquery-ui.css'; |
|
| 43 | + } else if ( preg_match('/^http.?:\/\/.*\..*$/', $theme_css) ) { |
|
| 44 | + $css_file = $theme_css; |
|
| 45 | + } else { |
|
| 46 | + $uploads = self::get_upload_base(); |
|
| 47 | 47 | $file_path = '/formidable/css/' . $theme_css . '/jquery-ui.css'; |
| 48 | - if ( file_exists($uploads['basedir'] . $file_path) ) { |
|
| 49 | - $css_file = $uploads['baseurl'] . $file_path; |
|
| 50 | - } else { |
|
| 48 | + if ( file_exists($uploads['basedir'] . $file_path) ) { |
|
| 49 | + $css_file = $uploads['baseurl'] . $file_path; |
|
| 50 | + } else { |
|
| 51 | 51 | $css_file = FrmAppHelper::jquery_ui_base_url() . '/themes/' . $theme_css . '/jquery-ui.min.css'; |
| 52 | - } |
|
| 53 | - } |
|
| 52 | + } |
|
| 53 | + } |
|
| 54 | 54 | |
| 55 | - return $css_file; |
|
| 56 | - } |
|
| 55 | + return $css_file; |
|
| 56 | + } |
|
| 57 | 57 | |
| 58 | - public static function enqueue_jquery_css() { |
|
| 58 | + public static function enqueue_jquery_css() { |
|
| 59 | 59 | $form = self::get_form_for_page(); |
| 60 | 60 | $theme_css = FrmStylesController::get_style_val( 'theme_css', $form ); |
| 61 | - if ( $theme_css != -1 ) { |
|
| 62 | - wp_enqueue_style('jquery-theme', self::jquery_css_url($theme_css), array(), FrmAppHelper::plugin_version()); |
|
| 63 | - } |
|
| 64 | - } |
|
| 61 | + if ( $theme_css != -1 ) { |
|
| 62 | + wp_enqueue_style('jquery-theme', self::jquery_css_url($theme_css), array(), FrmAppHelper::plugin_version()); |
|
| 63 | + } |
|
| 64 | + } |
|
| 65 | 65 | |
| 66 | 66 | public static function get_form_for_page() { |
| 67 | 67 | global $frm_vars; |
@@ -77,14 +77,14 @@ discard block |
||
| 77 | 77 | return $form_id; |
| 78 | 78 | } |
| 79 | 79 | |
| 80 | - public static function get_upload_base() { |
|
| 81 | - $uploads = wp_upload_dir(); |
|
| 82 | - if ( is_ssl() && ! preg_match('/^https:\/\/.*\..*$/', $uploads['baseurl']) ) { |
|
| 83 | - $uploads['baseurl'] = str_replace('http://', 'https://', $uploads['baseurl']); |
|
| 84 | - } |
|
| 80 | + public static function get_upload_base() { |
|
| 81 | + $uploads = wp_upload_dir(); |
|
| 82 | + if ( is_ssl() && ! preg_match('/^https:\/\/.*\..*$/', $uploads['baseurl']) ) { |
|
| 83 | + $uploads['baseurl'] = str_replace('http://', 'https://', $uploads['baseurl']); |
|
| 84 | + } |
|
| 85 | 85 | |
| 86 | - return $uploads; |
|
| 87 | - } |
|
| 86 | + return $uploads; |
|
| 87 | + } |
|
| 88 | 88 | |
| 89 | 89 | public static function style_menu( $active = '' ) { |
| 90 | 90 | ?> |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | <a href="<?php echo esc_url( admin_url('admin.php?page=formidable-styles&frm_action=custom_css' ) ) ?>" class="nav-tab <?php echo ( 'custom_css' == $active ) ? 'nav-tab-active' : '' ?>"><?php _e( 'Custom CSS', 'formidable' ) ?></a> |
| 95 | 95 | </h2> |
| 96 | 96 | <?php |
| 97 | - } |
|
| 97 | + } |
|
| 98 | 98 | |
| 99 | 99 | /** |
| 100 | 100 | * @since 2.04.02 |
@@ -121,20 +121,20 @@ discard block |
||
| 121 | 121 | ); |
| 122 | 122 | } |
| 123 | 123 | |
| 124 | - public static function minus_icons() { |
|
| 125 | - return array( |
|
| 124 | + public static function minus_icons() { |
|
| 125 | + return array( |
|
| 126 | 126 | 0 => array( '-' => '62e', '+' => '62f' ), |
| 127 | 127 | 1 => array( '-' => '600', '+' => '602' ), |
| 128 | 128 | 2 => array( '-' => '604', '+' => '603' ), |
| 129 | 129 | 3 => array( '-' => '633', '+' => '632' ), |
| 130 | 130 | 4 => array( '-' => '613', '+' => '60f' ), |
| 131 | - ); |
|
| 132 | - } |
|
| 131 | + ); |
|
| 132 | + } |
|
| 133 | 133 | |
| 134 | - public static function arrow_icons() { |
|
| 135 | - $minus_icons = self::minus_icons(); |
|
| 134 | + public static function arrow_icons() { |
|
| 135 | + $minus_icons = self::minus_icons(); |
|
| 136 | 136 | |
| 137 | - return array( |
|
| 137 | + return array( |
|
| 138 | 138 | 6 => array( '-' => '62d', '+' => '62a' ), |
| 139 | 139 | 0 => array( '-' => '60d', '+' => '609' ), |
| 140 | 140 | 1 => array( '-' => '60e', '+' => '60c' ), |
@@ -142,44 +142,44 @@ discard block |
||
| 142 | 142 | 3 => array( '-' => '62b', '+' => '628' ), |
| 143 | 143 | 4 => array( '-' => '62c', '+' => '629' ), |
| 144 | 144 | 5 => array( '-' => '635', '+' => '634' ), |
| 145 | - 'p0' => $minus_icons[0], |
|
| 146 | - 'p1' => $minus_icons[1], |
|
| 147 | - 'p2' => $minus_icons[2], |
|
| 148 | - 'p3' => $minus_icons[3], |
|
| 149 | - 'p4' => $minus_icons[4], |
|
| 150 | - ); |
|
| 151 | - } |
|
| 152 | - |
|
| 153 | - /** |
|
| 154 | - * @since 2.0 |
|
| 155 | - * @return The class for this icon |
|
| 156 | - */ |
|
| 145 | + 'p0' => $minus_icons[0], |
|
| 146 | + 'p1' => $minus_icons[1], |
|
| 147 | + 'p2' => $minus_icons[2], |
|
| 148 | + 'p3' => $minus_icons[3], |
|
| 149 | + 'p4' => $minus_icons[4], |
|
| 150 | + ); |
|
| 151 | + } |
|
| 152 | + |
|
| 153 | + /** |
|
| 154 | + * @since 2.0 |
|
| 155 | + * @return The class for this icon |
|
| 156 | + */ |
|
| 157 | 157 | public static function icon_key_to_class( $key, $icon = '+', $type = 'arrow' ) { |
| 158 | - if ( 'arrow' == $type && is_numeric($key) ) { |
|
| 159 | - //frm_arrowup6_icon |
|
| 158 | + if ( 'arrow' == $type && is_numeric($key) ) { |
|
| 159 | + //frm_arrowup6_icon |
|
| 160 | 160 | $arrow = array( '-' => 'down', '+' => 'up' ); |
| 161 | 161 | $class = 'frm_arrow' . $arrow[ $icon ]; |
| 162 | - } else { |
|
| 163 | - //frm_minus1_icon |
|
| 164 | - $key = str_replace('p', '', $key); |
|
| 162 | + } else { |
|
| 163 | + //frm_minus1_icon |
|
| 164 | + $key = str_replace('p', '', $key); |
|
| 165 | 165 | $plus = array( '-' => 'minus', '+' => 'plus' ); |
| 166 | 166 | $class = 'frm_' . $plus[ $icon ]; |
| 167 | - } |
|
| 167 | + } |
|
| 168 | 168 | |
| 169 | - if ( $key ) { |
|
| 170 | - $class .= $key; |
|
| 171 | - } |
|
| 172 | - $class .= '_icon'; |
|
| 169 | + if ( $key ) { |
|
| 170 | + $class .= $key; |
|
| 171 | + } |
|
| 172 | + $class .= '_icon'; |
|
| 173 | 173 | |
| 174 | - return $class; |
|
| 175 | - } |
|
| 174 | + return $class; |
|
| 175 | + } |
|
| 176 | 176 | |
| 177 | 177 | public static function bs_icon_select( $style, $frm_style, $type = 'arrow' ) { |
| 178 | 178 | $function_name = $type . '_icons'; |
| 179 | 179 | $icons = self::$function_name(); |
| 180 | 180 | unset( $function_name ); |
| 181 | 181 | |
| 182 | - $name = ( 'arrow' == $type ) ? 'collapse_icon' : 'repeat_icon'; |
|
| 182 | + $name = ( 'arrow' == $type ) ? 'collapse_icon' : 'repeat_icon'; |
|
| 183 | 183 | ?> |
| 184 | 184 | <select name="<?php echo esc_attr( $frm_style->get_field_name($name) ) ?>" id="frm_<?php echo esc_attr( $name ) ?>" class="frm_icon_font frm_multiselect hide-if-js"> |
| 185 | 185 | <?php foreach ( $icons as $key => $icon ) { ?> |
@@ -212,24 +212,24 @@ discard block |
||
| 212 | 212 | </ul> |
| 213 | 213 | </div> |
| 214 | 214 | <?php |
| 215 | - } |
|
| 215 | + } |
|
| 216 | 216 | |
| 217 | 217 | public static function hex2rgb( $hex ) { |
| 218 | - $hex = str_replace('#', '', $hex); |
|
| 218 | + $hex = str_replace('#', '', $hex); |
|
| 219 | 219 | |
| 220 | - if ( strlen($hex) == 3 ) { |
|
| 220 | + if ( strlen($hex) == 3 ) { |
|
| 221 | 221 | $r = hexdec( substr( $hex, 0, 1 ) . substr( $hex, 0, 1 ) ); |
| 222 | 222 | $g = hexdec( substr( $hex, 1, 1 ) . substr( $hex, 1, 1 ) ); |
| 223 | 223 | $b = hexdec( substr( $hex, 2, 1 ) . substr( $hex, 2, 1 ) ); |
| 224 | - } else { |
|
| 224 | + } else { |
|
| 225 | 225 | $r = hexdec( substr( $hex, 0, 2 ) ); |
| 226 | 226 | $g = hexdec( substr( $hex, 2, 2 ) ); |
| 227 | 227 | $b = hexdec( substr( $hex, 4, 2 ) ); |
| 228 | - } |
|
| 228 | + } |
|
| 229 | 229 | $rgb = array( $r, $g, $b ); |
| 230 | - return implode(',', $rgb); // returns the rgb values separated by commas |
|
| 231 | - //return $rgb; // returns an array with the rgb values |
|
| 232 | - } |
|
| 230 | + return implode(',', $rgb); // returns the rgb values separated by commas |
|
| 231 | + //return $rgb; // returns an array with the rgb values |
|
| 232 | + } |
|
| 233 | 233 | |
| 234 | 234 | /** |
| 235 | 235 | * @param $hex string - The original color in hex format #ffffff |
@@ -7,72 +7,72 @@ discard block |
||
| 7 | 7 | |
| 8 | 8 | public static function setup_new_vars( $type = '', $form_id = '' ) { |
| 9 | 9 | |
| 10 | - if ( strpos($type, '|') ) { |
|
| 11 | - list($type, $setting) = explode('|', $type); |
|
| 12 | - } |
|
| 13 | - |
|
| 14 | - $defaults = self::get_default_field_opts($type, $form_id); |
|
| 15 | - $defaults['field_options']['custom_html'] = self::get_default_html($type); |
|
| 16 | - |
|
| 17 | - $values = array(); |
|
| 18 | - |
|
| 19 | - foreach ( $defaults as $var => $default ) { |
|
| 20 | - if ( $var == 'field_options' ) { |
|
| 21 | - $values['field_options'] = array(); |
|
| 22 | - foreach ( $default as $opt_var => $opt_default ) { |
|
| 23 | - $values['field_options'][ $opt_var ] = $opt_default; |
|
| 24 | - unset($opt_var, $opt_default); |
|
| 25 | - } |
|
| 26 | - } else { |
|
| 27 | - $values[ $var ] = $default; |
|
| 28 | - } |
|
| 29 | - unset($var, $default); |
|
| 30 | - } |
|
| 31 | - |
|
| 32 | - if ( isset( $setting ) && ! empty( $setting ) ) { |
|
| 33 | - if ( in_array( $type, array( 'data', 'lookup' ) ) ) { |
|
| 34 | - $values['field_options']['data_type'] = $setting; |
|
| 35 | - } else { |
|
| 36 | - $values['field_options'][ $setting ] = 1; |
|
| 37 | - } |
|
| 38 | - } |
|
| 39 | - |
|
| 40 | - if ( $type == 'radio' || $type == 'checkbox' ) { |
|
| 41 | - $values['options'] = serialize( array( |
|
| 42 | - __( 'Option 1', 'formidable' ), |
|
| 43 | - __( 'Option 2', 'formidable' ), |
|
| 44 | - ) ); |
|
| 45 | - } else if ( $type == 'select' ) { |
|
| 46 | - $values['options'] = serialize( array( |
|
| 47 | - '', __( 'Option 1', 'formidable' ), |
|
| 48 | - ) ); |
|
| 49 | - } else if ( $type == 'textarea' ) { |
|
| 50 | - $values['field_options']['max'] = '5'; |
|
| 51 | - } else if ( $type == 'captcha' ) { |
|
| 52 | - $frm_settings = FrmAppHelper::get_settings(); |
|
| 53 | - $values['invalid'] = $frm_settings->re_msg; |
|
| 10 | + if ( strpos($type, '|') ) { |
|
| 11 | + list($type, $setting) = explode('|', $type); |
|
| 12 | + } |
|
| 13 | + |
|
| 14 | + $defaults = self::get_default_field_opts($type, $form_id); |
|
| 15 | + $defaults['field_options']['custom_html'] = self::get_default_html($type); |
|
| 16 | + |
|
| 17 | + $values = array(); |
|
| 18 | + |
|
| 19 | + foreach ( $defaults as $var => $default ) { |
|
| 20 | + if ( $var == 'field_options' ) { |
|
| 21 | + $values['field_options'] = array(); |
|
| 22 | + foreach ( $default as $opt_var => $opt_default ) { |
|
| 23 | + $values['field_options'][ $opt_var ] = $opt_default; |
|
| 24 | + unset($opt_var, $opt_default); |
|
| 25 | + } |
|
| 26 | + } else { |
|
| 27 | + $values[ $var ] = $default; |
|
| 28 | + } |
|
| 29 | + unset($var, $default); |
|
| 30 | + } |
|
| 31 | + |
|
| 32 | + if ( isset( $setting ) && ! empty( $setting ) ) { |
|
| 33 | + if ( in_array( $type, array( 'data', 'lookup' ) ) ) { |
|
| 34 | + $values['field_options']['data_type'] = $setting; |
|
| 35 | + } else { |
|
| 36 | + $values['field_options'][ $setting ] = 1; |
|
| 37 | + } |
|
| 38 | + } |
|
| 39 | + |
|
| 40 | + if ( $type == 'radio' || $type == 'checkbox' ) { |
|
| 41 | + $values['options'] = serialize( array( |
|
| 42 | + __( 'Option 1', 'formidable' ), |
|
| 43 | + __( 'Option 2', 'formidable' ), |
|
| 44 | + ) ); |
|
| 45 | + } else if ( $type == 'select' ) { |
|
| 46 | + $values['options'] = serialize( array( |
|
| 47 | + '', __( 'Option 1', 'formidable' ), |
|
| 48 | + ) ); |
|
| 49 | + } else if ( $type == 'textarea' ) { |
|
| 50 | + $values['field_options']['max'] = '5'; |
|
| 51 | + } else if ( $type == 'captcha' ) { |
|
| 52 | + $frm_settings = FrmAppHelper::get_settings(); |
|
| 53 | + $values['invalid'] = $frm_settings->re_msg; |
|
| 54 | 54 | $values['field_options']['label'] = 'none'; |
| 55 | - } else if ( 'url' == $type ) { |
|
| 56 | - $values['name'] = __( 'Website', 'formidable' ); |
|
| 57 | - } |
|
| 55 | + } else if ( 'url' == $type ) { |
|
| 56 | + $values['name'] = __( 'Website', 'formidable' ); |
|
| 57 | + } |
|
| 58 | 58 | |
| 59 | 59 | $fields = FrmField::field_selection(); |
| 60 | - $fields = array_merge($fields, FrmField::pro_field_selection()); |
|
| 60 | + $fields = array_merge($fields, FrmField::pro_field_selection()); |
|
| 61 | 61 | |
| 62 | - if ( isset( $fields[ $type ] ) ) { |
|
| 63 | - $values['name'] = is_array( $fields[ $type ] ) ? $fields[ $type ]['name'] : $fields[ $type ]; |
|
| 64 | - } |
|
| 62 | + if ( isset( $fields[ $type ] ) ) { |
|
| 63 | + $values['name'] = is_array( $fields[ $type ] ) ? $fields[ $type ]['name'] : $fields[ $type ]; |
|
| 64 | + } |
|
| 65 | 65 | |
| 66 | - unset($fields); |
|
| 66 | + unset($fields); |
|
| 67 | 67 | |
| 68 | - return $values; |
|
| 69 | - } |
|
| 68 | + return $values; |
|
| 69 | + } |
|
| 70 | 70 | |
| 71 | 71 | public static function get_html_id( $field, $plus = '' ) { |
| 72 | 72 | return apply_filters( 'frm_field_html_id', 'field_' . $field['field_key'] . $plus, $field ); |
| 73 | - } |
|
| 73 | + } |
|
| 74 | 74 | |
| 75 | - public static function setup_edit_vars( $record, $doing_ajax = false ) { |
|
| 75 | + public static function setup_edit_vars( $record, $doing_ajax = false ) { |
|
| 76 | 76 | $values = array( 'id' => $record->id, 'form_id' => $record->form_id ); |
| 77 | 77 | $defaults = array( |
| 78 | 78 | 'name' => $record->name, |
@@ -85,86 +85,86 @@ discard block |
||
| 85 | 85 | ); |
| 86 | 86 | |
| 87 | 87 | if ( $doing_ajax ) { |
| 88 | - $values = $values + $defaults; |
|
| 89 | - $values['form_name'] = ''; |
|
| 88 | + $values = $values + $defaults; |
|
| 89 | + $values['form_name'] = ''; |
|
| 90 | 90 | } else { |
| 91 | 91 | foreach ( $defaults as $var => $default ) { |
| 92 | - $values[ $var ] = FrmAppHelper::get_param( $var, $default, 'get', 'htmlspecialchars' ); |
|
| 93 | - unset($var, $default); |
|
| 94 | - } |
|
| 92 | + $values[ $var ] = FrmAppHelper::get_param( $var, $default, 'get', 'htmlspecialchars' ); |
|
| 93 | + unset($var, $default); |
|
| 94 | + } |
|
| 95 | 95 | |
| 96 | 96 | $values['form_name'] = $record->form_id ? FrmForm::getName( $record->form_id ) : ''; |
| 97 | - } |
|
| 97 | + } |
|
| 98 | 98 | |
| 99 | 99 | unset( $defaults ); |
| 100 | 100 | |
| 101 | - $values['options'] = $record->options; |
|
| 102 | - $values['field_options'] = $record->field_options; |
|
| 101 | + $values['options'] = $record->options; |
|
| 102 | + $values['field_options'] = $record->field_options; |
|
| 103 | 103 | |
| 104 | - $defaults = self::get_default_field_opts($values['type'], $record, true); |
|
| 104 | + $defaults = self::get_default_field_opts($values['type'], $record, true); |
|
| 105 | 105 | |
| 106 | 106 | if ( $values['type'] == 'captcha' ) { |
| 107 | - $frm_settings = FrmAppHelper::get_settings(); |
|
| 108 | - $defaults['invalid'] = $frm_settings->re_msg; |
|
| 109 | - } |
|
| 107 | + $frm_settings = FrmAppHelper::get_settings(); |
|
| 108 | + $defaults['invalid'] = $frm_settings->re_msg; |
|
| 109 | + } |
|
| 110 | 110 | |
| 111 | 111 | foreach ( $defaults as $opt => $default ) { |
| 112 | - $values[ $opt ] = isset( $record->field_options[ $opt ] ) ? $record->field_options[ $opt ] : $default; |
|
| 113 | - unset($opt, $default); |
|
| 114 | - } |
|
| 112 | + $values[ $opt ] = isset( $record->field_options[ $opt ] ) ? $record->field_options[ $opt ] : $default; |
|
| 113 | + unset($opt, $default); |
|
| 114 | + } |
|
| 115 | 115 | |
| 116 | - $values['custom_html'] = (isset($record->field_options['custom_html'])) ? $record->field_options['custom_html'] : self::get_default_html($record->type); |
|
| 116 | + $values['custom_html'] = (isset($record->field_options['custom_html'])) ? $record->field_options['custom_html'] : self::get_default_html($record->type); |
|
| 117 | 117 | |
| 118 | 118 | return apply_filters( 'frm_setup_edit_field_vars', $values, array( 'doing_ajax' => $doing_ajax ) ); |
| 119 | - } |
|
| 119 | + } |
|
| 120 | 120 | |
| 121 | - public static function get_default_field_opts( $type, $field, $limit = false ) { |
|
| 122 | - $field_options = array( |
|
| 123 | - 'size' => '', 'max' => '', 'label' => '', 'blank' => '', |
|
| 124 | - 'required_indicator' => '*', 'invalid' => '', 'separate_value' => 0, |
|
| 125 | - 'clear_on_focus' => 0, 'default_blank' => 0, 'classes' => '', |
|
| 121 | + public static function get_default_field_opts( $type, $field, $limit = false ) { |
|
| 122 | + $field_options = array( |
|
| 123 | + 'size' => '', 'max' => '', 'label' => '', 'blank' => '', |
|
| 124 | + 'required_indicator' => '*', 'invalid' => '', 'separate_value' => 0, |
|
| 125 | + 'clear_on_focus' => 0, 'default_blank' => 0, 'classes' => '', |
|
| 126 | 126 | 'custom_html' => '', 'captcha_size' => 'normal', 'captcha_theme' => 'light', |
| 127 | - ); |
|
| 127 | + ); |
|
| 128 | 128 | |
| 129 | 129 | if ( $limit ) { |
| 130 | - return $field_options; |
|
| 130 | + return $field_options; |
|
| 131 | 131 | } |
| 132 | 132 | |
| 133 | - global $wpdb; |
|
| 133 | + global $wpdb; |
|
| 134 | 134 | |
| 135 | - $form_id = (is_numeric($field)) ? $field : $field->form_id; |
|
| 135 | + $form_id = (is_numeric($field)) ? $field : $field->form_id; |
|
| 136 | 136 | |
| 137 | 137 | $key = is_numeric( $field ) ? FrmAppHelper::get_unique_key( '', $wpdb->prefix . 'frm_fields', 'field_key' ) : $field->field_key; |
| 138 | 138 | |
| 139 | - $field_count = FrmDb::get_var( 'frm_fields', array( 'form_id' => $form_id ), 'field_order', array( 'order_by' => 'field_order DESC' ) ); |
|
| 139 | + $field_count = FrmDb::get_var( 'frm_fields', array( 'form_id' => $form_id ), 'field_order', array( 'order_by' => 'field_order DESC' ) ); |
|
| 140 | 140 | |
| 141 | - $frm_settings = FrmAppHelper::get_settings(); |
|
| 142 | - return array( |
|
| 143 | - 'name' => __( 'Untitled', 'formidable' ), 'description' => '', |
|
| 141 | + $frm_settings = FrmAppHelper::get_settings(); |
|
| 142 | + return array( |
|
| 143 | + 'name' => __( 'Untitled', 'formidable' ), 'description' => '', |
|
| 144 | 144 | 'field_key' => $key, 'type' => $type, 'options' => '', 'default_value' => '', |
| 145 | 145 | 'field_order' => $field_count + 1, 'required' => false, |
| 146 | - 'blank' => $frm_settings->blank_msg, 'unique_msg' => $frm_settings->unique_msg, |
|
| 147 | - 'invalid' => __( 'This field is invalid', 'formidable' ), 'form_id' => $form_id, |
|
| 146 | + 'blank' => $frm_settings->blank_msg, 'unique_msg' => $frm_settings->unique_msg, |
|
| 147 | + 'invalid' => __( 'This field is invalid', 'formidable' ), 'form_id' => $form_id, |
|
| 148 | 148 | 'field_options' => $field_options, |
| 149 | - ); |
|
| 150 | - } |
|
| 149 | + ); |
|
| 150 | + } |
|
| 151 | 151 | |
| 152 | - public static function fill_field( &$values, $field, $form_id, $new_key = '' ) { |
|
| 153 | - global $wpdb; |
|
| 152 | + public static function fill_field( &$values, $field, $form_id, $new_key = '' ) { |
|
| 153 | + global $wpdb; |
|
| 154 | 154 | |
| 155 | 155 | $values['field_key'] = FrmAppHelper::get_unique_key( $new_key, $wpdb->prefix . 'frm_fields', 'field_key' ); |
| 156 | - $values['form_id'] = $form_id; |
|
| 157 | - $values['options'] = maybe_serialize($field->options); |
|
| 158 | - $values['default_value'] = maybe_serialize($field->default_value); |
|
| 159 | - |
|
| 160 | - foreach ( array( 'name', 'description', 'type', 'field_order', 'field_options', 'required' ) as $col ) { |
|
| 161 | - $values[ $col ] = $field->{$col}; |
|
| 162 | - } |
|
| 163 | - } |
|
| 164 | - |
|
| 165 | - /** |
|
| 166 | - * @since 2.0 |
|
| 167 | - */ |
|
| 156 | + $values['form_id'] = $form_id; |
|
| 157 | + $values['options'] = maybe_serialize($field->options); |
|
| 158 | + $values['default_value'] = maybe_serialize($field->default_value); |
|
| 159 | + |
|
| 160 | + foreach ( array( 'name', 'description', 'type', 'field_order', 'field_options', 'required' ) as $col ) { |
|
| 161 | + $values[ $col ] = $field->{$col}; |
|
| 162 | + } |
|
| 163 | + } |
|
| 164 | + |
|
| 165 | + /** |
|
| 166 | + * @since 2.0 |
|
| 167 | + */ |
|
| 168 | 168 | public static function get_error_msg( $field, $error ) { |
| 169 | 169 | $frm_settings = FrmAppHelper::get_settings(); |
| 170 | 170 | $default_settings = $frm_settings->default_options(); |
@@ -193,12 +193,12 @@ discard block |
||
| 193 | 193 | public static function get_default_html( $type = 'text' ) { |
| 194 | 194 | if ( apply_filters( 'frm_normal_field_type_html', true, $type ) ) { |
| 195 | 195 | $input = ( in_array( $type, array( 'radio', 'checkbox', 'data' ) ) ) ? '<div class="frm_opt_container">[input]</div>' : '[input]'; |
| 196 | - $for = ''; |
|
| 196 | + $for = ''; |
|
| 197 | 197 | if ( ! in_array( $type, array( 'radio', 'checkbox', 'data', 'scale' ) ) ) { |
| 198 | - $for = 'for="field_[key]"'; |
|
| 199 | - } |
|
| 198 | + $for = 'for="field_[key]"'; |
|
| 199 | + } |
|
| 200 | 200 | |
| 201 | - $default_html = <<<DEFAULT_HTML |
|
| 201 | + $default_html = <<<DEFAULT_HTML |
|
| 202 | 202 | <div id="frm_field_[id]_container" class="frm_form_field form-field [required_class][error_class]"> |
| 203 | 203 | <label $for class="frm_primary_label">[field_name] |
| 204 | 204 | <span class="frm_required">[required_label]</span> |
@@ -208,81 +208,81 @@ discard block |
||
| 208 | 208 | [if error]<div class="frm_error">[error]</div>[/if error] |
| 209 | 209 | </div> |
| 210 | 210 | DEFAULT_HTML; |
| 211 | - } else { |
|
| 211 | + } else { |
|
| 212 | 212 | $default_html = apply_filters('frm_other_custom_html', '', $type); |
| 213 | - } |
|
| 213 | + } |
|
| 214 | 214 | |
| 215 | - return apply_filters('frm_custom_html', $default_html, $type); |
|
| 216 | - } |
|
| 215 | + return apply_filters('frm_custom_html', $default_html, $type); |
|
| 216 | + } |
|
| 217 | 217 | |
| 218 | 218 | public static function replace_shortcodes( $html, $field, $errors = array(), $form = false, $args = array() ) { |
| 219 | - $html = apply_filters('frm_before_replace_shortcodes', $html, $field, $errors, $form); |
|
| 219 | + $html = apply_filters('frm_before_replace_shortcodes', $html, $field, $errors, $form); |
|
| 220 | 220 | |
| 221 | - $defaults = array( |
|
| 221 | + $defaults = array( |
|
| 222 | 222 | 'field_name' => 'item_meta[' . $field['id'] . ']', |
| 223 | 223 | 'field_id' => $field['id'], |
| 224 | - 'field_plus_id' => '', |
|
| 225 | - 'section_id' => '', |
|
| 226 | - ); |
|
| 227 | - $args = wp_parse_args($args, $defaults); |
|
| 228 | - $field_name = $args['field_name']; |
|
| 229 | - $field_id = $args['field_id']; |
|
| 230 | - $html_id = self::get_html_id($field, $args['field_plus_id']); |
|
| 224 | + 'field_plus_id' => '', |
|
| 225 | + 'section_id' => '', |
|
| 226 | + ); |
|
| 227 | + $args = wp_parse_args($args, $defaults); |
|
| 228 | + $field_name = $args['field_name']; |
|
| 229 | + $field_id = $args['field_id']; |
|
| 230 | + $html_id = self::get_html_id($field, $args['field_plus_id']); |
|
| 231 | 231 | |
| 232 | - if ( FrmField::is_multiple_select($field) ) { |
|
| 233 | - $field_name .= '[]'; |
|
| 234 | - } |
|
| 232 | + if ( FrmField::is_multiple_select($field) ) { |
|
| 233 | + $field_name .= '[]'; |
|
| 234 | + } |
|
| 235 | 235 | |
| 236 | - //replace [id] |
|
| 237 | - $html = str_replace('[id]', $field_id, $html); |
|
| 236 | + //replace [id] |
|
| 237 | + $html = str_replace('[id]', $field_id, $html); |
|
| 238 | 238 | |
| 239 | - // Remove the for attribute for captcha |
|
| 240 | - if ( $field['type'] == 'captcha' ) { |
|
| 241 | - $html = str_replace(' for="field_[key]"', '', $html); |
|
| 242 | - } |
|
| 239 | + // Remove the for attribute for captcha |
|
| 240 | + if ( $field['type'] == 'captcha' ) { |
|
| 241 | + $html = str_replace(' for="field_[key]"', '', $html); |
|
| 242 | + } |
|
| 243 | 243 | |
| 244 | - // set the label for |
|
| 245 | - $html = str_replace('field_[key]', $html_id, $html); |
|
| 244 | + // set the label for |
|
| 245 | + $html = str_replace('field_[key]', $html_id, $html); |
|
| 246 | 246 | |
| 247 | - //replace [key] |
|
| 248 | - $html = str_replace('[key]', $field['field_key'], $html); |
|
| 247 | + //replace [key] |
|
| 248 | + $html = str_replace('[key]', $field['field_key'], $html); |
|
| 249 | 249 | |
| 250 | - //replace [description] and [required_label] and [error] |
|
| 250 | + //replace [description] and [required_label] and [error] |
|
| 251 | 251 | $required = FrmField::is_required( $field ) ? $field['required_indicator'] : ''; |
| 252 | - if ( ! is_array( $errors ) ) { |
|
| 253 | - $errors = array(); |
|
| 254 | - } |
|
| 252 | + if ( ! is_array( $errors ) ) { |
|
| 253 | + $errors = array(); |
|
| 254 | + } |
|
| 255 | 255 | $error = isset( $errors[ 'field' . $field_id ] ) ? $errors[ 'field' . $field_id ] : false; |
| 256 | 256 | |
| 257 | - //If field type is section heading, add class so a bottom margin can be added to either the h3 or description |
|
| 258 | - if ( $field['type'] == 'divider' ) { |
|
| 259 | - if ( FrmField::is_option_true( $field, 'description' ) ) { |
|
| 260 | - $html = str_replace( 'frm_description', 'frm_description frm_section_spacing', $html ); |
|
| 261 | - } else { |
|
| 262 | - $html = str_replace('[label_position]', '[label_position] frm_section_spacing', $html); |
|
| 263 | - } |
|
| 264 | - } |
|
| 257 | + //If field type is section heading, add class so a bottom margin can be added to either the h3 or description |
|
| 258 | + if ( $field['type'] == 'divider' ) { |
|
| 259 | + if ( FrmField::is_option_true( $field, 'description' ) ) { |
|
| 260 | + $html = str_replace( 'frm_description', 'frm_description frm_section_spacing', $html ); |
|
| 261 | + } else { |
|
| 262 | + $html = str_replace('[label_position]', '[label_position] frm_section_spacing', $html); |
|
| 263 | + } |
|
| 264 | + } |
|
| 265 | 265 | |
| 266 | 266 | foreach ( array( 'description' => $field['description'], 'required_label' => $required, 'error' => $error ) as $code => $value ) { |
| 267 | - self::remove_inline_conditions( ( $value && $value != '' ), $code, $value, $html ); |
|
| 268 | - } |
|
| 267 | + self::remove_inline_conditions( ( $value && $value != '' ), $code, $value, $html ); |
|
| 268 | + } |
|
| 269 | 269 | |
| 270 | - //replace [required_class] |
|
| 270 | + //replace [required_class] |
|
| 271 | 271 | $required_class = FrmField::is_required( $field ) ? ' frm_required_field' : ''; |
| 272 | - $html = str_replace('[required_class]', $required_class, $html); |
|
| 272 | + $html = str_replace('[required_class]', $required_class, $html); |
|
| 273 | 273 | |
| 274 | - //replace [label_position] |
|
| 274 | + //replace [label_position] |
|
| 275 | 275 | $field['label'] = self::label_position( $field['label'], $field, $form ); |
| 276 | 276 | self::add_class_to_label( $field, $html ); |
| 277 | 277 | |
| 278 | - //replace [field_name] |
|
| 279 | - $html = str_replace('[field_name]', $field['name'], $html); |
|
| 278 | + //replace [field_name] |
|
| 279 | + $html = str_replace('[field_name]', $field['name'], $html); |
|
| 280 | 280 | |
| 281 | 281 | self::add_field_div_classes( $field_id, $field, $errors, $html ); |
| 282 | 282 | |
| 283 | - //replace [entry_key] |
|
| 284 | - $entry_key = FrmAppHelper::simple_get( 'entry', 'sanitize_title' ); |
|
| 285 | - $html = str_replace('[entry_key]', $entry_key, $html); |
|
| 283 | + //replace [entry_key] |
|
| 284 | + $entry_key = FrmAppHelper::simple_get( 'entry', 'sanitize_title' ); |
|
| 285 | + $html = str_replace('[entry_key]', $entry_key, $html); |
|
| 286 | 286 | |
| 287 | 287 | if ( $form ) { |
| 288 | 288 | $form = (array) $form; |
@@ -296,57 +296,57 @@ discard block |
||
| 296 | 296 | |
| 297 | 297 | self::process_wp_shortcodes( $html ); |
| 298 | 298 | |
| 299 | - //replace [input] |
|
| 300 | - preg_match_all("/\[(input|deletelink)\b(.*?)(?:(\/))?\]/s", $html, $shortcodes, PREG_PATTERN_ORDER); |
|
| 301 | - global $frm_vars; |
|
| 302 | - $frm_settings = FrmAppHelper::get_settings(); |
|
| 299 | + //replace [input] |
|
| 300 | + preg_match_all("/\[(input|deletelink)\b(.*?)(?:(\/))?\]/s", $html, $shortcodes, PREG_PATTERN_ORDER); |
|
| 301 | + global $frm_vars; |
|
| 302 | + $frm_settings = FrmAppHelper::get_settings(); |
|
| 303 | 303 | |
| 304 | - foreach ( $shortcodes[0] as $short_key => $tag ) { |
|
| 305 | - $atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[2][ $short_key ] ); |
|
| 304 | + foreach ( $shortcodes[0] as $short_key => $tag ) { |
|
| 305 | + $atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[2][ $short_key ] ); |
|
| 306 | 306 | $tag = self::get_shortcode_tag( $shortcodes, $short_key, array( 'conditional' => false, 'conditional_check' => false ) ); |
| 307 | 307 | |
| 308 | - $replace_with = ''; |
|
| 308 | + $replace_with = ''; |
|
| 309 | 309 | |
| 310 | - if ( $tag == 'input' ) { |
|
| 311 | - if ( isset($atts['opt']) ) { |
|
| 312 | - $atts['opt']--; |
|
| 313 | - } |
|
| 310 | + if ( $tag == 'input' ) { |
|
| 311 | + if ( isset($atts['opt']) ) { |
|
| 312 | + $atts['opt']--; |
|
| 313 | + } |
|
| 314 | 314 | |
| 315 | - $field['input_class'] = isset($atts['class']) ? $atts['class'] : ''; |
|
| 316 | - if ( isset($atts['class']) ) { |
|
| 317 | - unset($atts['class']); |
|
| 318 | - } |
|
| 315 | + $field['input_class'] = isset($atts['class']) ? $atts['class'] : ''; |
|
| 316 | + if ( isset($atts['class']) ) { |
|
| 317 | + unset($atts['class']); |
|
| 318 | + } |
|
| 319 | 319 | |
| 320 | - $field['shortcodes'] = $atts; |
|
| 321 | - ob_start(); |
|
| 320 | + $field['shortcodes'] = $atts; |
|
| 321 | + ob_start(); |
|
| 322 | 322 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/input.php' ); |
| 323 | - $replace_with = ob_get_contents(); |
|
| 324 | - ob_end_clean(); |
|
| 325 | - } else if ( $tag == 'deletelink' && FrmAppHelper::pro_is_installed() ) { |
|
| 326 | - $replace_with = FrmProEntriesController::entry_delete_link($atts); |
|
| 327 | - } |
|
| 323 | + $replace_with = ob_get_contents(); |
|
| 324 | + ob_end_clean(); |
|
| 325 | + } else if ( $tag == 'deletelink' && FrmAppHelper::pro_is_installed() ) { |
|
| 326 | + $replace_with = FrmProEntriesController::entry_delete_link($atts); |
|
| 327 | + } |
|
| 328 | 328 | |
| 329 | - $html = str_replace( $shortcodes[0][ $short_key ], $replace_with, $html ); |
|
| 330 | - } |
|
| 329 | + $html = str_replace( $shortcodes[0][ $short_key ], $replace_with, $html ); |
|
| 330 | + } |
|
| 331 | 331 | |
| 332 | - $html .= "\n"; |
|
| 332 | + $html .= "\n"; |
|
| 333 | 333 | |
| 334 | - //Return html if conf_field to prevent loop |
|
| 335 | - if ( isset($field['conf_field']) && $field['conf_field'] == 'stop' ) { |
|
| 336 | - return $html; |
|
| 337 | - } |
|
| 334 | + //Return html if conf_field to prevent loop |
|
| 335 | + if ( isset($field['conf_field']) && $field['conf_field'] == 'stop' ) { |
|
| 336 | + return $html; |
|
| 337 | + } |
|
| 338 | 338 | |
| 339 | - //If field is in repeating section |
|
| 340 | - if ( $args['section_id'] ) { |
|
| 341 | - $html = apply_filters('frm_replace_shortcodes', $html, $field, array( 'errors' => $errors, 'form' => $form, 'field_name' => $field_name, 'field_id' => $field_id, 'field_plus_id' => $args['field_plus_id'], 'section_id' => $args['section_id'] )); |
|
| 342 | - } else { |
|
| 343 | - $html = apply_filters('frm_replace_shortcodes', $html, $field, array( 'errors' => $errors, 'form' => $form )); |
|
| 344 | - } |
|
| 339 | + //If field is in repeating section |
|
| 340 | + if ( $args['section_id'] ) { |
|
| 341 | + $html = apply_filters('frm_replace_shortcodes', $html, $field, array( 'errors' => $errors, 'form' => $form, 'field_name' => $field_name, 'field_id' => $field_id, 'field_plus_id' => $args['field_plus_id'], 'section_id' => $args['section_id'] )); |
|
| 342 | + } else { |
|
| 343 | + $html = apply_filters('frm_replace_shortcodes', $html, $field, array( 'errors' => $errors, 'form' => $form )); |
|
| 344 | + } |
|
| 345 | 345 | |
| 346 | 346 | self::remove_collapse_shortcode( $html ); |
| 347 | 347 | |
| 348 | - return $html; |
|
| 349 | - } |
|
| 348 | + return $html; |
|
| 349 | + } |
|
| 350 | 350 | |
| 351 | 351 | /** |
| 352 | 352 | * Get the class to use for the label position |
@@ -457,46 +457,46 @@ discard block |
||
| 457 | 457 | return $classes; |
| 458 | 458 | } |
| 459 | 459 | |
| 460 | - public static function remove_inline_conditions( $no_vars, $code, $replace_with, &$html ) { |
|
| 461 | - if ( $no_vars ) { |
|
| 460 | + public static function remove_inline_conditions( $no_vars, $code, $replace_with, &$html ) { |
|
| 461 | + if ( $no_vars ) { |
|
| 462 | 462 | $html = str_replace( '[if ' . $code . ']', '', $html ); |
| 463 | 463 | $html = str_replace( '[/if ' . $code . ']', '', $html ); |
| 464 | - } else { |
|
| 464 | + } else { |
|
| 465 | 465 | $html = preg_replace( '/(\[if\s+' . $code . '\])(.*?)(\[\/if\s+' . $code . '\])/mis', '', $html ); |
| 466 | - } |
|
| 466 | + } |
|
| 467 | 467 | |
| 468 | 468 | $html = str_replace( '[' . $code . ']', $replace_with, $html ); |
| 469 | - } |
|
| 469 | + } |
|
| 470 | 470 | |
| 471 | 471 | public static function get_shortcode_tag( $shortcodes, $short_key, $args ) { |
| 472 | 472 | $args = wp_parse_args( $args, array( 'conditional' => false, 'conditional_check' => false, 'foreach' => false ) ); |
| 473 | - if ( ( $args['conditional'] || $args['foreach'] ) && ! $args['conditional_check'] ) { |
|
| 474 | - $args['conditional_check'] = true; |
|
| 475 | - } |
|
| 476 | - |
|
| 477 | - $prefix = ''; |
|
| 478 | - if ( $args['conditional_check'] ) { |
|
| 479 | - if ( $args['conditional'] ) { |
|
| 480 | - $prefix = 'if '; |
|
| 481 | - } else if ( $args['foreach'] ) { |
|
| 482 | - $prefix = 'foreach '; |
|
| 483 | - } |
|
| 484 | - } |
|
| 485 | - |
|
| 486 | - $with_tags = $args['conditional_check'] ? 3 : 2; |
|
| 487 | - if ( ! empty( $shortcodes[ $with_tags ][ $short_key ] ) ) { |
|
| 488 | - $tag = str_replace( '[' . $prefix, '', $shortcodes[0][ $short_key ] ); |
|
| 489 | - $tag = str_replace(']', '', $tag); |
|
| 490 | - $tags = explode(' ', $tag); |
|
| 491 | - if ( is_array($tags) ) { |
|
| 492 | - $tag = $tags[0]; |
|
| 493 | - } |
|
| 494 | - } else { |
|
| 495 | - $tag = $shortcodes[ $with_tags - 1 ][ $short_key ]; |
|
| 496 | - } |
|
| 497 | - |
|
| 498 | - return $tag; |
|
| 499 | - } |
|
| 473 | + if ( ( $args['conditional'] || $args['foreach'] ) && ! $args['conditional_check'] ) { |
|
| 474 | + $args['conditional_check'] = true; |
|
| 475 | + } |
|
| 476 | + |
|
| 477 | + $prefix = ''; |
|
| 478 | + if ( $args['conditional_check'] ) { |
|
| 479 | + if ( $args['conditional'] ) { |
|
| 480 | + $prefix = 'if '; |
|
| 481 | + } else if ( $args['foreach'] ) { |
|
| 482 | + $prefix = 'foreach '; |
|
| 483 | + } |
|
| 484 | + } |
|
| 485 | + |
|
| 486 | + $with_tags = $args['conditional_check'] ? 3 : 2; |
|
| 487 | + if ( ! empty( $shortcodes[ $with_tags ][ $short_key ] ) ) { |
|
| 488 | + $tag = str_replace( '[' . $prefix, '', $shortcodes[0][ $short_key ] ); |
|
| 489 | + $tag = str_replace(']', '', $tag); |
|
| 490 | + $tags = explode(' ', $tag); |
|
| 491 | + if ( is_array($tags) ) { |
|
| 492 | + $tag = $tags[0]; |
|
| 493 | + } |
|
| 494 | + } else { |
|
| 495 | + $tag = $shortcodes[ $with_tags - 1 ][ $short_key ]; |
|
| 496 | + } |
|
| 497 | + |
|
| 498 | + return $tag; |
|
| 499 | + } |
|
| 500 | 500 | |
| 501 | 501 | /** |
| 502 | 502 | * Remove [collapse_this] if it's still included after all processing |
@@ -534,8 +534,8 @@ discard block |
||
| 534 | 534 | } |
| 535 | 535 | $api_js_url = apply_filters( 'frm_recaptcha_js_url', $api_js_url ); |
| 536 | 536 | |
| 537 | - wp_register_script( 'recaptcha-api', $api_js_url, '', true ); |
|
| 538 | - wp_enqueue_script( 'recaptcha-api' ); |
|
| 537 | + wp_register_script( 'recaptcha-api', $api_js_url, '', true ); |
|
| 538 | + wp_enqueue_script( 'recaptcha-api' ); |
|
| 539 | 539 | |
| 540 | 540 | // for reverse compatibility |
| 541 | 541 | $field['captcha_size'] = ( $field['captcha_size'] == 'default' ) ? 'normal' : $field['captcha_size']; |
@@ -548,40 +548,40 @@ discard block |
||
| 548 | 548 | } |
| 549 | 549 | ?>></div> |
| 550 | 550 | <?php |
| 551 | - } |
|
| 551 | + } |
|
| 552 | 552 | |
| 553 | 553 | public static function show_single_option( $field ) { |
| 554 | - $field_name = $field['name']; |
|
| 555 | - $html_id = self::get_html_id($field); |
|
| 556 | - foreach ( $field['options'] as $opt_key => $opt ) { |
|
| 557 | - $field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field); |
|
| 558 | - $opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field); |
|
| 554 | + $field_name = $field['name']; |
|
| 555 | + $html_id = self::get_html_id($field); |
|
| 556 | + foreach ( $field['options'] as $opt_key => $opt ) { |
|
| 557 | + $field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field); |
|
| 558 | + $opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field); |
|
| 559 | 559 | |
| 560 | - // If this is an "Other" option, get the HTML for it |
|
| 560 | + // If this is an "Other" option, get the HTML for it |
|
| 561 | 561 | if ( self::is_other_opt( $opt_key ) ) { |
| 562 | - // Get string for Other text field, if needed |
|
| 562 | + // Get string for Other text field, if needed |
|
| 563 | 563 | $other_val = self::get_other_val( compact( 'opt_key', 'field' ) ); |
| 564 | 564 | require( FrmAppHelper::plugin_path() . '/pro/classes/views/frmpro-fields/other-option.php' ); |
| 565 | - } else { |
|
| 565 | + } else { |
|
| 566 | 566 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/single-option.php' ); |
| 567 | - } |
|
| 568 | - } |
|
| 569 | - } |
|
| 567 | + } |
|
| 568 | + } |
|
| 569 | + } |
|
| 570 | 570 | |
| 571 | 571 | public static function get_term_link( $tax_id ) { |
| 572 | - $tax = get_taxonomy($tax_id); |
|
| 573 | - if ( ! $tax ) { |
|
| 574 | - return; |
|
| 575 | - } |
|
| 572 | + $tax = get_taxonomy($tax_id); |
|
| 573 | + if ( ! $tax ) { |
|
| 574 | + return; |
|
| 575 | + } |
|
| 576 | 576 | |
| 577 | - $link = sprintf( |
|
| 578 | - __( 'Please add options from the WordPress "%1$s" page', 'formidable' ), |
|
| 577 | + $link = sprintf( |
|
| 578 | + __( 'Please add options from the WordPress "%1$s" page', 'formidable' ), |
|
| 579 | 579 | '<a href="' . esc_url( admin_url( 'edit-tags.php?taxonomy=' . $tax->name ) ) . '" target="_blank">' . ( empty( $tax->labels->name ) ? __( 'Categories' ) : $tax->labels->name ) . '</a>' |
| 580 | - ); |
|
| 581 | - unset($tax); |
|
| 580 | + ); |
|
| 581 | + unset($tax); |
|
| 582 | 582 | |
| 583 | - return $link; |
|
| 584 | - } |
|
| 583 | + return $link; |
|
| 584 | + } |
|
| 585 | 585 | |
| 586 | 586 | public static function value_meets_condition( $observed_value, $cond, $hide_opt ) { |
| 587 | 587 | // Remove white space from hide_opt |
@@ -592,199 +592,199 @@ discard block |
||
| 592 | 592 | $observed_value = wp_kses_post( $observed_value ); |
| 593 | 593 | $hide_opt = wp_kses_post( $hide_opt ); |
| 594 | 594 | |
| 595 | - if ( is_array($observed_value) ) { |
|
| 596 | - return self::array_value_condition($observed_value, $cond, $hide_opt); |
|
| 597 | - } |
|
| 598 | - |
|
| 599 | - $m = false; |
|
| 600 | - if ( $cond == '==' ) { |
|
| 601 | - $m = $observed_value == $hide_opt; |
|
| 602 | - } else if ( $cond == '!=' ) { |
|
| 603 | - $m = $observed_value != $hide_opt; |
|
| 604 | - } else if ( $cond == '>' ) { |
|
| 605 | - $m = $observed_value > $hide_opt; |
|
| 606 | - } else if ( $cond == '<' ) { |
|
| 607 | - $m = $observed_value < $hide_opt; |
|
| 608 | - } else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) { |
|
| 609 | - $m = stripos($observed_value, $hide_opt); |
|
| 610 | - if ( $cond == 'not LIKE' ) { |
|
| 611 | - $m = ( $m === false ) ? true : false; |
|
| 612 | - } else { |
|
| 613 | - $m = ( $m === false ) ? false : true; |
|
| 614 | - } |
|
| 615 | - } |
|
| 616 | - return $m; |
|
| 617 | - } |
|
| 595 | + if ( is_array($observed_value) ) { |
|
| 596 | + return self::array_value_condition($observed_value, $cond, $hide_opt); |
|
| 597 | + } |
|
| 598 | + |
|
| 599 | + $m = false; |
|
| 600 | + if ( $cond == '==' ) { |
|
| 601 | + $m = $observed_value == $hide_opt; |
|
| 602 | + } else if ( $cond == '!=' ) { |
|
| 603 | + $m = $observed_value != $hide_opt; |
|
| 604 | + } else if ( $cond == '>' ) { |
|
| 605 | + $m = $observed_value > $hide_opt; |
|
| 606 | + } else if ( $cond == '<' ) { |
|
| 607 | + $m = $observed_value < $hide_opt; |
|
| 608 | + } else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) { |
|
| 609 | + $m = stripos($observed_value, $hide_opt); |
|
| 610 | + if ( $cond == 'not LIKE' ) { |
|
| 611 | + $m = ( $m === false ) ? true : false; |
|
| 612 | + } else { |
|
| 613 | + $m = ( $m === false ) ? false : true; |
|
| 614 | + } |
|
| 615 | + } |
|
| 616 | + return $m; |
|
| 617 | + } |
|
| 618 | 618 | |
| 619 | 619 | public static function array_value_condition( $observed_value, $cond, $hide_opt ) { |
| 620 | - $m = false; |
|
| 621 | - if ( $cond == '==' ) { |
|
| 622 | - if ( is_array($hide_opt) ) { |
|
| 623 | - $m = array_intersect($hide_opt, $observed_value); |
|
| 624 | - $m = empty($m) ? false : true; |
|
| 625 | - } else { |
|
| 626 | - $m = in_array($hide_opt, $observed_value); |
|
| 627 | - } |
|
| 628 | - } else if ( $cond == '!=' ) { |
|
| 629 | - $m = ! in_array($hide_opt, $observed_value); |
|
| 630 | - } else if ( $cond == '>' ) { |
|
| 631 | - $min = min($observed_value); |
|
| 632 | - $m = $min > $hide_opt; |
|
| 633 | - } else if ( $cond == '<' ) { |
|
| 634 | - $max = max($observed_value); |
|
| 635 | - $m = $max < $hide_opt; |
|
| 636 | - } else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) { |
|
| 637 | - foreach ( $observed_value as $ob ) { |
|
| 638 | - $m = strpos($ob, $hide_opt); |
|
| 639 | - if ( $m !== false ) { |
|
| 640 | - $m = true; |
|
| 641 | - break; |
|
| 642 | - } |
|
| 643 | - } |
|
| 644 | - |
|
| 645 | - if ( $cond == 'not LIKE' ) { |
|
| 646 | - $m = ( $m === false ) ? true : false; |
|
| 647 | - } |
|
| 648 | - } |
|
| 649 | - |
|
| 650 | - return $m; |
|
| 651 | - } |
|
| 652 | - |
|
| 653 | - /** |
|
| 654 | - * Replace a few basic shortcodes and field ids |
|
| 655 | - * @since 2.0 |
|
| 656 | - * @return string |
|
| 657 | - */ |
|
| 620 | + $m = false; |
|
| 621 | + if ( $cond == '==' ) { |
|
| 622 | + if ( is_array($hide_opt) ) { |
|
| 623 | + $m = array_intersect($hide_opt, $observed_value); |
|
| 624 | + $m = empty($m) ? false : true; |
|
| 625 | + } else { |
|
| 626 | + $m = in_array($hide_opt, $observed_value); |
|
| 627 | + } |
|
| 628 | + } else if ( $cond == '!=' ) { |
|
| 629 | + $m = ! in_array($hide_opt, $observed_value); |
|
| 630 | + } else if ( $cond == '>' ) { |
|
| 631 | + $min = min($observed_value); |
|
| 632 | + $m = $min > $hide_opt; |
|
| 633 | + } else if ( $cond == '<' ) { |
|
| 634 | + $max = max($observed_value); |
|
| 635 | + $m = $max < $hide_opt; |
|
| 636 | + } else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) { |
|
| 637 | + foreach ( $observed_value as $ob ) { |
|
| 638 | + $m = strpos($ob, $hide_opt); |
|
| 639 | + if ( $m !== false ) { |
|
| 640 | + $m = true; |
|
| 641 | + break; |
|
| 642 | + } |
|
| 643 | + } |
|
| 644 | + |
|
| 645 | + if ( $cond == 'not LIKE' ) { |
|
| 646 | + $m = ( $m === false ) ? true : false; |
|
| 647 | + } |
|
| 648 | + } |
|
| 649 | + |
|
| 650 | + return $m; |
|
| 651 | + } |
|
| 652 | + |
|
| 653 | + /** |
|
| 654 | + * Replace a few basic shortcodes and field ids |
|
| 655 | + * @since 2.0 |
|
| 656 | + * @return string |
|
| 657 | + */ |
|
| 658 | 658 | public static function basic_replace_shortcodes( $value, $form, $entry ) { |
| 659 | - if ( strpos($value, '[sitename]') !== false ) { |
|
| 660 | - $new_value = wp_specialchars_decode( FrmAppHelper::site_name(), ENT_QUOTES ); |
|
| 661 | - $value = str_replace('[sitename]', $new_value, $value); |
|
| 662 | - } |
|
| 659 | + if ( strpos($value, '[sitename]') !== false ) { |
|
| 660 | + $new_value = wp_specialchars_decode( FrmAppHelper::site_name(), ENT_QUOTES ); |
|
| 661 | + $value = str_replace('[sitename]', $new_value, $value); |
|
| 662 | + } |
|
| 663 | 663 | |
| 664 | - $value = apply_filters('frm_content', $value, $form, $entry); |
|
| 665 | - $value = do_shortcode($value); |
|
| 664 | + $value = apply_filters('frm_content', $value, $form, $entry); |
|
| 665 | + $value = do_shortcode($value); |
|
| 666 | 666 | |
| 667 | - return $value; |
|
| 668 | - } |
|
| 667 | + return $value; |
|
| 668 | + } |
|
| 669 | 669 | |
| 670 | 670 | public static function get_shortcodes( $content, $form_id ) { |
| 671 | - if ( FrmAppHelper::pro_is_installed() ) { |
|
| 672 | - return FrmProDisplaysHelper::get_shortcodes($content, $form_id); |
|
| 673 | - } |
|
| 671 | + if ( FrmAppHelper::pro_is_installed() ) { |
|
| 672 | + return FrmProDisplaysHelper::get_shortcodes($content, $form_id); |
|
| 673 | + } |
|
| 674 | 674 | |
| 675 | - $fields = FrmField::getAll( array( 'fi.form_id' => (int) $form_id, 'fi.type not' => FrmField::no_save_fields() ) ); |
|
| 675 | + $fields = FrmField::getAll( array( 'fi.form_id' => (int) $form_id, 'fi.type not' => FrmField::no_save_fields() ) ); |
|
| 676 | 676 | |
| 677 | - $tagregexp = self::allowed_shortcodes($fields); |
|
| 677 | + $tagregexp = self::allowed_shortcodes($fields); |
|
| 678 | 678 | |
| 679 | - preg_match_all("/\[(if )?($tagregexp)\b(.*?)(?:(\/))?\](?:(.+?)\[\/\2\])?/s", $content, $matches, PREG_PATTERN_ORDER); |
|
| 679 | + preg_match_all("/\[(if )?($tagregexp)\b(.*?)(?:(\/))?\](?:(.+?)\[\/\2\])?/s", $content, $matches, PREG_PATTERN_ORDER); |
|
| 680 | 680 | |
| 681 | - return $matches; |
|
| 682 | - } |
|
| 681 | + return $matches; |
|
| 682 | + } |
|
| 683 | 683 | |
| 684 | 684 | public static function allowed_shortcodes( $fields = array() ) { |
| 685 | - $tagregexp = array( |
|
| 686 | - 'editlink', 'id', 'key', 'ip', |
|
| 687 | - 'siteurl', 'sitename', 'admin_email', |
|
| 688 | - 'post[-|_]id', 'created[-|_]at', 'updated[-|_]at', 'updated[-|_]by', |
|
| 685 | + $tagregexp = array( |
|
| 686 | + 'editlink', 'id', 'key', 'ip', |
|
| 687 | + 'siteurl', 'sitename', 'admin_email', |
|
| 688 | + 'post[-|_]id', 'created[-|_]at', 'updated[-|_]at', 'updated[-|_]by', |
|
| 689 | 689 | 'parent[-|_]id', |
| 690 | - ); |
|
| 690 | + ); |
|
| 691 | 691 | |
| 692 | - foreach ( $fields as $field ) { |
|
| 693 | - $tagregexp[] = $field->id; |
|
| 694 | - $tagregexp[] = $field->field_key; |
|
| 695 | - } |
|
| 692 | + foreach ( $fields as $field ) { |
|
| 693 | + $tagregexp[] = $field->id; |
|
| 694 | + $tagregexp[] = $field->field_key; |
|
| 695 | + } |
|
| 696 | 696 | |
| 697 | - $tagregexp = implode('|', $tagregexp); |
|
| 698 | - return $tagregexp; |
|
| 699 | - } |
|
| 697 | + $tagregexp = implode('|', $tagregexp); |
|
| 698 | + return $tagregexp; |
|
| 699 | + } |
|
| 700 | 700 | |
| 701 | 701 | public static function replace_content_shortcodes( $content, $entry, $shortcodes ) { |
| 702 | - $shortcode_values = array( |
|
| 703 | - 'id' => $entry->id, |
|
| 704 | - 'key' => $entry->item_key, |
|
| 705 | - 'ip' => $entry->ip, |
|
| 706 | - ); |
|
| 702 | + $shortcode_values = array( |
|
| 703 | + 'id' => $entry->id, |
|
| 704 | + 'key' => $entry->item_key, |
|
| 705 | + 'ip' => $entry->ip, |
|
| 706 | + ); |
|
| 707 | 707 | |
| 708 | - foreach ( $shortcodes[0] as $short_key => $tag ) { |
|
| 708 | + foreach ( $shortcodes[0] as $short_key => $tag ) { |
|
| 709 | 709 | if ( empty( $tag ) ) { |
| 710 | 710 | continue; |
| 711 | 711 | } |
| 712 | 712 | |
| 713 | - $atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[3][ $short_key ] ); |
|
| 713 | + $atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[3][ $short_key ] ); |
|
| 714 | 714 | |
| 715 | - if ( ! empty( $shortcodes[3][ $short_key ] ) ) { |
|
| 715 | + if ( ! empty( $shortcodes[3][ $short_key ] ) ) { |
|
| 716 | 716 | $tag = str_replace( array( '[', ']' ), '', $shortcodes[0][ $short_key ] ); |
| 717 | - $tags = explode(' ', $tag); |
|
| 718 | - if ( is_array($tags) ) { |
|
| 719 | - $tag = $tags[0]; |
|
| 720 | - } |
|
| 721 | - } else { |
|
| 722 | - $tag = $shortcodes[2][ $short_key ]; |
|
| 723 | - } |
|
| 724 | - |
|
| 725 | - switch ( $tag ) { |
|
| 726 | - case 'id': |
|
| 727 | - case 'key': |
|
| 728 | - case 'ip': |
|
| 729 | - $replace_with = $shortcode_values[ $tag ]; |
|
| 730 | - break; |
|
| 731 | - |
|
| 732 | - case 'user_agent': |
|
| 733 | - case 'user-agent': |
|
| 734 | - $entry->description = maybe_unserialize($entry->description); |
|
| 717 | + $tags = explode(' ', $tag); |
|
| 718 | + if ( is_array($tags) ) { |
|
| 719 | + $tag = $tags[0]; |
|
| 720 | + } |
|
| 721 | + } else { |
|
| 722 | + $tag = $shortcodes[2][ $short_key ]; |
|
| 723 | + } |
|
| 724 | + |
|
| 725 | + switch ( $tag ) { |
|
| 726 | + case 'id': |
|
| 727 | + case 'key': |
|
| 728 | + case 'ip': |
|
| 729 | + $replace_with = $shortcode_values[ $tag ]; |
|
| 730 | + break; |
|
| 731 | + |
|
| 732 | + case 'user_agent': |
|
| 733 | + case 'user-agent': |
|
| 734 | + $entry->description = maybe_unserialize($entry->description); |
|
| 735 | 735 | $replace_with = FrmEntriesHelper::get_browser( $entry->description['browser'] ); |
| 736 | - break; |
|
| 737 | - |
|
| 738 | - case 'created_at': |
|
| 739 | - case 'created-at': |
|
| 740 | - case 'updated_at': |
|
| 741 | - case 'updated-at': |
|
| 742 | - if ( isset($atts['format']) ) { |
|
| 743 | - $time_format = ' '; |
|
| 744 | - } else { |
|
| 745 | - $atts['format'] = get_option('date_format'); |
|
| 746 | - $time_format = ''; |
|
| 747 | - } |
|
| 748 | - |
|
| 749 | - $this_tag = str_replace('-', '_', $tag); |
|
| 750 | - $replace_with = FrmAppHelper::get_formatted_time($entry->{$this_tag}, $atts['format'], $time_format); |
|
| 751 | - unset($this_tag); |
|
| 752 | - break; |
|
| 753 | - |
|
| 754 | - case 'created_by': |
|
| 755 | - case 'created-by': |
|
| 756 | - case 'updated_by': |
|
| 757 | - case 'updated-by': |
|
| 758 | - $this_tag = str_replace('-', '_', $tag); |
|
| 736 | + break; |
|
| 737 | + |
|
| 738 | + case 'created_at': |
|
| 739 | + case 'created-at': |
|
| 740 | + case 'updated_at': |
|
| 741 | + case 'updated-at': |
|
| 742 | + if ( isset($atts['format']) ) { |
|
| 743 | + $time_format = ' '; |
|
| 744 | + } else { |
|
| 745 | + $atts['format'] = get_option('date_format'); |
|
| 746 | + $time_format = ''; |
|
| 747 | + } |
|
| 748 | + |
|
| 749 | + $this_tag = str_replace('-', '_', $tag); |
|
| 750 | + $replace_with = FrmAppHelper::get_formatted_time($entry->{$this_tag}, $atts['format'], $time_format); |
|
| 751 | + unset($this_tag); |
|
| 752 | + break; |
|
| 753 | + |
|
| 754 | + case 'created_by': |
|
| 755 | + case 'created-by': |
|
| 756 | + case 'updated_by': |
|
| 757 | + case 'updated-by': |
|
| 758 | + $this_tag = str_replace('-', '_', $tag); |
|
| 759 | 759 | $replace_with = self::get_display_value( $entry->{$this_tag}, (object) array( 'type' => 'user_id' ), $atts ); |
| 760 | - unset($this_tag); |
|
| 761 | - break; |
|
| 762 | - |
|
| 763 | - case 'admin_email': |
|
| 764 | - case 'siteurl': |
|
| 765 | - case 'frmurl': |
|
| 766 | - case 'sitename': |
|
| 767 | - case 'get': |
|
| 768 | - $replace_with = self::dynamic_default_values( $tag, $atts ); |
|
| 769 | - break; |
|
| 770 | - |
|
| 771 | - default: |
|
| 772 | - $field = FrmField::getOne( $tag ); |
|
| 773 | - if ( ! $field ) { |
|
| 774 | - break; |
|
| 775 | - } |
|
| 776 | - |
|
| 777 | - $sep = isset($atts['sep']) ? $atts['sep'] : ', '; |
|
| 778 | - |
|
| 779 | - $replace_with = FrmEntryMeta::get_meta_value( $entry, $field->id ); |
|
| 780 | - |
|
| 781 | - $atts['entry_id'] = $entry->id; |
|
| 782 | - $atts['entry_key'] = $entry->item_key; |
|
| 783 | - |
|
| 784 | - if ( isset($atts['show']) && $atts['show'] == 'field_label' ) { |
|
| 785 | - $replace_with = $field->name; |
|
| 786 | - } else if ( isset($atts['show']) && $atts['show'] == 'description' ) { |
|
| 787 | - $replace_with = $field->description; |
|
| 760 | + unset($this_tag); |
|
| 761 | + break; |
|
| 762 | + |
|
| 763 | + case 'admin_email': |
|
| 764 | + case 'siteurl': |
|
| 765 | + case 'frmurl': |
|
| 766 | + case 'sitename': |
|
| 767 | + case 'get': |
|
| 768 | + $replace_with = self::dynamic_default_values( $tag, $atts ); |
|
| 769 | + break; |
|
| 770 | + |
|
| 771 | + default: |
|
| 772 | + $field = FrmField::getOne( $tag ); |
|
| 773 | + if ( ! $field ) { |
|
| 774 | + break; |
|
| 775 | + } |
|
| 776 | + |
|
| 777 | + $sep = isset($atts['sep']) ? $atts['sep'] : ', '; |
|
| 778 | + |
|
| 779 | + $replace_with = FrmEntryMeta::get_meta_value( $entry, $field->id ); |
|
| 780 | + |
|
| 781 | + $atts['entry_id'] = $entry->id; |
|
| 782 | + $atts['entry_key'] = $entry->item_key; |
|
| 783 | + |
|
| 784 | + if ( isset($atts['show']) && $atts['show'] == 'field_label' ) { |
|
| 785 | + $replace_with = $field->name; |
|
| 786 | + } else if ( isset($atts['show']) && $atts['show'] == 'description' ) { |
|
| 787 | + $replace_with = $field->description; |
|
| 788 | 788 | } else { |
| 789 | 789 | $string_value = $replace_with; |
| 790 | 790 | if ( is_array( $replace_with ) ) { |
@@ -798,82 +798,82 @@ discard block |
||
| 798 | 798 | } |
| 799 | 799 | } |
| 800 | 800 | |
| 801 | - unset($field); |
|
| 802 | - break; |
|
| 803 | - } |
|
| 801 | + unset($field); |
|
| 802 | + break; |
|
| 803 | + } |
|
| 804 | 804 | |
| 805 | - if ( isset($replace_with) ) { |
|
| 806 | - $content = str_replace( $shortcodes[0][ $short_key ], $replace_with, $content ); |
|
| 807 | - } |
|
| 805 | + if ( isset($replace_with) ) { |
|
| 806 | + $content = str_replace( $shortcodes[0][ $short_key ], $replace_with, $content ); |
|
| 807 | + } |
|
| 808 | 808 | |
| 809 | - unset($atts, $conditional, $replace_with); |
|
| 809 | + unset($atts, $conditional, $replace_with); |
|
| 810 | 810 | } |
| 811 | 811 | |
| 812 | 812 | return $content; |
| 813 | - } |
|
| 814 | - |
|
| 815 | - /** |
|
| 816 | - * Get the value to replace a few standard shortcodes |
|
| 817 | - * |
|
| 818 | - * @since 2.0 |
|
| 819 | - * @return string |
|
| 820 | - */ |
|
| 821 | - public static function dynamic_default_values( $tag, $atts = array(), $return_array = false ) { |
|
| 822 | - $new_value = ''; |
|
| 823 | - switch ( $tag ) { |
|
| 824 | - case 'admin_email': |
|
| 825 | - $new_value = get_option('admin_email'); |
|
| 826 | - break; |
|
| 827 | - case 'siteurl': |
|
| 828 | - $new_value = FrmAppHelper::site_url(); |
|
| 829 | - break; |
|
| 830 | - case 'frmurl': |
|
| 831 | - $new_value = FrmAppHelper::plugin_url(); |
|
| 832 | - break; |
|
| 833 | - case 'sitename': |
|
| 834 | - $new_value = FrmAppHelper::site_name(); |
|
| 835 | - break; |
|
| 836 | - case 'get': |
|
| 837 | - $new_value = self::process_get_shortcode( $atts, $return_array ); |
|
| 838 | - break; |
|
| 839 | - } |
|
| 840 | - |
|
| 841 | - return $new_value; |
|
| 842 | - } |
|
| 843 | - |
|
| 844 | - /** |
|
| 845 | - * Process the [get] shortcode |
|
| 846 | - * |
|
| 847 | - * @since 2.0 |
|
| 848 | - * @return string|array |
|
| 849 | - */ |
|
| 850 | - public static function process_get_shortcode( $atts, $return_array = false ) { |
|
| 851 | - if ( ! isset($atts['param']) ) { |
|
| 852 | - return ''; |
|
| 853 | - } |
|
| 854 | - |
|
| 855 | - if ( strpos($atts['param'], '[') ) { |
|
| 856 | - $atts['param'] = str_replace('[', '[', $atts['param']); |
|
| 857 | - $atts['param'] = str_replace(']', ']', $atts['param']); |
|
| 858 | - } |
|
| 859 | - |
|
| 860 | - $new_value = FrmAppHelper::get_param($atts['param'], ''); |
|
| 861 | - $new_value = FrmAppHelper::get_query_var( $new_value, $atts['param'] ); |
|
| 862 | - |
|
| 863 | - if ( $new_value == '' ) { |
|
| 864 | - if ( ! isset($atts['prev_val']) ) { |
|
| 865 | - $atts['prev_val'] = ''; |
|
| 866 | - } |
|
| 867 | - |
|
| 868 | - $new_value = isset($atts['default']) ? $atts['default'] : $atts['prev_val']; |
|
| 869 | - } |
|
| 870 | - |
|
| 871 | - if ( is_array($new_value) && ! $return_array ) { |
|
| 872 | - $new_value = implode(', ', $new_value); |
|
| 873 | - } |
|
| 874 | - |
|
| 875 | - return $new_value; |
|
| 876 | - } |
|
| 813 | + } |
|
| 814 | + |
|
| 815 | + /** |
|
| 816 | + * Get the value to replace a few standard shortcodes |
|
| 817 | + * |
|
| 818 | + * @since 2.0 |
|
| 819 | + * @return string |
|
| 820 | + */ |
|
| 821 | + public static function dynamic_default_values( $tag, $atts = array(), $return_array = false ) { |
|
| 822 | + $new_value = ''; |
|
| 823 | + switch ( $tag ) { |
|
| 824 | + case 'admin_email': |
|
| 825 | + $new_value = get_option('admin_email'); |
|
| 826 | + break; |
|
| 827 | + case 'siteurl': |
|
| 828 | + $new_value = FrmAppHelper::site_url(); |
|
| 829 | + break; |
|
| 830 | + case 'frmurl': |
|
| 831 | + $new_value = FrmAppHelper::plugin_url(); |
|
| 832 | + break; |
|
| 833 | + case 'sitename': |
|
| 834 | + $new_value = FrmAppHelper::site_name(); |
|
| 835 | + break; |
|
| 836 | + case 'get': |
|
| 837 | + $new_value = self::process_get_shortcode( $atts, $return_array ); |
|
| 838 | + break; |
|
| 839 | + } |
|
| 840 | + |
|
| 841 | + return $new_value; |
|
| 842 | + } |
|
| 843 | + |
|
| 844 | + /** |
|
| 845 | + * Process the [get] shortcode |
|
| 846 | + * |
|
| 847 | + * @since 2.0 |
|
| 848 | + * @return string|array |
|
| 849 | + */ |
|
| 850 | + public static function process_get_shortcode( $atts, $return_array = false ) { |
|
| 851 | + if ( ! isset($atts['param']) ) { |
|
| 852 | + return ''; |
|
| 853 | + } |
|
| 854 | + |
|
| 855 | + if ( strpos($atts['param'], '[') ) { |
|
| 856 | + $atts['param'] = str_replace('[', '[', $atts['param']); |
|
| 857 | + $atts['param'] = str_replace(']', ']', $atts['param']); |
|
| 858 | + } |
|
| 859 | + |
|
| 860 | + $new_value = FrmAppHelper::get_param($atts['param'], ''); |
|
| 861 | + $new_value = FrmAppHelper::get_query_var( $new_value, $atts['param'] ); |
|
| 862 | + |
|
| 863 | + if ( $new_value == '' ) { |
|
| 864 | + if ( ! isset($atts['prev_val']) ) { |
|
| 865 | + $atts['prev_val'] = ''; |
|
| 866 | + } |
|
| 867 | + |
|
| 868 | + $new_value = isset($atts['default']) ? $atts['default'] : $atts['prev_val']; |
|
| 869 | + } |
|
| 870 | + |
|
| 871 | + if ( is_array($new_value) && ! $return_array ) { |
|
| 872 | + $new_value = implode(', ', $new_value); |
|
| 873 | + } |
|
| 874 | + |
|
| 875 | + return $new_value; |
|
| 876 | + } |
|
| 877 | 877 | |
| 878 | 878 | public static function get_display_value( $replace_with, $field, $atts = array() ) { |
| 879 | 879 | $sep = isset( $atts['sep'] ) ? $atts['sep'] : ', '; |
@@ -881,14 +881,14 @@ discard block |
||
| 881 | 881 | $replace_with = apply_filters( 'frm_get_' . $field->type . '_display_value', $replace_with, $field, $atts ); |
| 882 | 882 | $replace_with = apply_filters( 'frm_get_display_value', $replace_with, $field, $atts ); |
| 883 | 883 | |
| 884 | - if ( $field->type == 'textarea' || $field->type == 'rte' ) { |
|
| 885 | - $autop = isset($atts['wpautop']) ? $atts['wpautop'] : true; |
|
| 886 | - if ( apply_filters('frm_use_wpautop', $autop) ) { |
|
| 887 | - if ( is_array($replace_with) ) { |
|
| 888 | - $replace_with = implode("\n", $replace_with); |
|
| 889 | - } |
|
| 890 | - $replace_with = wpautop($replace_with); |
|
| 891 | - } |
|
| 884 | + if ( $field->type == 'textarea' || $field->type == 'rte' ) { |
|
| 885 | + $autop = isset($atts['wpautop']) ? $atts['wpautop'] : true; |
|
| 886 | + if ( apply_filters('frm_use_wpautop', $autop) ) { |
|
| 887 | + if ( is_array($replace_with) ) { |
|
| 888 | + $replace_with = implode("\n", $replace_with); |
|
| 889 | + } |
|
| 890 | + $replace_with = wpautop($replace_with); |
|
| 891 | + } |
|
| 892 | 892 | unset( $autop ); |
| 893 | 893 | } else if ( is_array( $replace_with ) ) { |
| 894 | 894 | if ( isset( $atts['show'] ) && $atts['show'] && isset( $replace_with[ $atts['show'] ] ) ) { |
@@ -902,37 +902,37 @@ discard block |
||
| 902 | 902 | } |
| 903 | 903 | |
| 904 | 904 | public static function get_field_types( $type ) { |
| 905 | - $single_input = array( |
|
| 906 | - 'text', 'textarea', 'rte', 'number', 'email', 'url', |
|
| 907 | - 'image', 'file', 'date', 'phone', 'hidden', 'time', |
|
| 908 | - 'user_id', 'tag', 'password', |
|
| 909 | - ); |
|
| 905 | + $single_input = array( |
|
| 906 | + 'text', 'textarea', 'rte', 'number', 'email', 'url', |
|
| 907 | + 'image', 'file', 'date', 'phone', 'hidden', 'time', |
|
| 908 | + 'user_id', 'tag', 'password', |
|
| 909 | + ); |
|
| 910 | 910 | $multiple_input = array( 'radio', 'checkbox', 'select', 'scale', 'lookup' ); |
| 911 | 911 | $other_type = array( 'html', 'break' ); |
| 912 | 912 | |
| 913 | 913 | $field_selection = array_merge( FrmField::pro_field_selection(), FrmField::field_selection() ); |
| 914 | 914 | |
| 915 | - $field_types = array(); |
|
| 916 | - if ( in_array($type, $single_input) ) { |
|
| 917 | - self::field_types_for_input( $single_input, $field_selection, $field_types ); |
|
| 918 | - } else if ( in_array($type, $multiple_input) ) { |
|
| 919 | - self::field_types_for_input( $multiple_input, $field_selection, $field_types ); |
|
| 920 | - } else if ( in_array($type, $other_type) ) { |
|
| 921 | - self::field_types_for_input( $other_type, $field_selection, $field_types ); |
|
| 915 | + $field_types = array(); |
|
| 916 | + if ( in_array($type, $single_input) ) { |
|
| 917 | + self::field_types_for_input( $single_input, $field_selection, $field_types ); |
|
| 918 | + } else if ( in_array($type, $multiple_input) ) { |
|
| 919 | + self::field_types_for_input( $multiple_input, $field_selection, $field_types ); |
|
| 920 | + } else if ( in_array($type, $other_type) ) { |
|
| 921 | + self::field_types_for_input( $other_type, $field_selection, $field_types ); |
|
| 922 | 922 | } else if ( isset( $field_selection[ $type ] ) ) { |
| 923 | - $field_types[ $type ] = $field_selection[ $type ]; |
|
| 924 | - } |
|
| 923 | + $field_types[ $type ] = $field_selection[ $type ]; |
|
| 924 | + } |
|
| 925 | 925 | |
| 926 | 926 | $field_types = apply_filters( 'frm_switch_field_types', $field_types, compact( 'type' ) ); |
| 927 | - return $field_types; |
|
| 928 | - } |
|
| 927 | + return $field_types; |
|
| 928 | + } |
|
| 929 | 929 | |
| 930 | - private static function field_types_for_input( $inputs, $fields, &$field_types ) { |
|
| 931 | - foreach ( $inputs as $input ) { |
|
| 932 | - $field_types[ $input ] = $fields[ $input ]; |
|
| 933 | - unset($input); |
|
| 934 | - } |
|
| 935 | - } |
|
| 930 | + private static function field_types_for_input( $inputs, $fields, &$field_types ) { |
|
| 931 | + foreach ( $inputs as $input ) { |
|
| 932 | + $field_types[ $input ] = $fields[ $input ]; |
|
| 933 | + unset($input); |
|
| 934 | + } |
|
| 935 | + } |
|
| 936 | 936 | |
| 937 | 937 | /** |
| 938 | 938 | * Check if current field option is an "other" option |
@@ -946,14 +946,14 @@ discard block |
||
| 946 | 946 | return $opt_key && strpos( $opt_key, 'other_' ) === 0; |
| 947 | 947 | } |
| 948 | 948 | |
| 949 | - /** |
|
| 950 | - * Get value that belongs in "Other" text box |
|
| 951 | - * |
|
| 952 | - * @since 2.0.6 |
|
| 953 | - * |
|
| 954 | - * @param array $args |
|
| 955 | - */ |
|
| 956 | - public static function get_other_val( $args ) { |
|
| 949 | + /** |
|
| 950 | + * Get value that belongs in "Other" text box |
|
| 951 | + * |
|
| 952 | + * @since 2.0.6 |
|
| 953 | + * |
|
| 954 | + * @param array $args |
|
| 955 | + */ |
|
| 956 | + public static function get_other_val( $args ) { |
|
| 957 | 957 | $defaults = array( |
| 958 | 958 | 'opt_key' => 0, 'field' => array(), |
| 959 | 959 | 'parent' => false, 'pointer' => false, |
@@ -1029,20 +1029,20 @@ discard block |
||
| 1029 | 1029 | } |
| 1030 | 1030 | |
| 1031 | 1031 | return $other_val; |
| 1032 | - } |
|
| 1033 | - |
|
| 1034 | - /** |
|
| 1035 | - * Check if there is a saved value for the "Other" text field. If so, set it as the $other_val. |
|
| 1036 | - * Intended for front-end use |
|
| 1037 | - * |
|
| 1038 | - * @since 2.0.6 |
|
| 1039 | - * |
|
| 1040 | - * @param array $args should include field, opt_key and field name |
|
| 1041 | - * @param boolean $other_opt |
|
| 1042 | - * @param string $checked |
|
| 1043 | - * @return string $other_val |
|
| 1044 | - */ |
|
| 1045 | - public static function prepare_other_input( $args, &$other_opt, &$checked ) { |
|
| 1032 | + } |
|
| 1033 | + |
|
| 1034 | + /** |
|
| 1035 | + * Check if there is a saved value for the "Other" text field. If so, set it as the $other_val. |
|
| 1036 | + * Intended for front-end use |
|
| 1037 | + * |
|
| 1038 | + * @since 2.0.6 |
|
| 1039 | + * |
|
| 1040 | + * @param array $args should include field, opt_key and field name |
|
| 1041 | + * @param boolean $other_opt |
|
| 1042 | + * @param string $checked |
|
| 1043 | + * @return string $other_val |
|
| 1044 | + */ |
|
| 1045 | + public static function prepare_other_input( $args, &$other_opt, &$checked ) { |
|
| 1046 | 1046 | //Check if this is an "Other" option |
| 1047 | 1047 | if ( ! self::is_other_opt( $args['opt_key'] ) ) { |
| 1048 | 1048 | return; |
@@ -1058,8 +1058,8 @@ discard block |
||
| 1058 | 1058 | $checked = 'checked="checked" '; |
| 1059 | 1059 | } |
| 1060 | 1060 | |
| 1061 | - return $other_args; |
|
| 1062 | - } |
|
| 1061 | + return $other_args; |
|
| 1062 | + } |
|
| 1063 | 1063 | |
| 1064 | 1064 | /** |
| 1065 | 1065 | * @param array $args |
@@ -1109,8 +1109,8 @@ discard block |
||
| 1109 | 1109 | * @since 2.0.6 |
| 1110 | 1110 | */ |
| 1111 | 1111 | public static function include_other_input( $args ) { |
| 1112 | - if ( ! $args['other_opt'] ) { |
|
| 1113 | - return; |
|
| 1112 | + if ( ! $args['other_opt'] ) { |
|
| 1113 | + return; |
|
| 1114 | 1114 | } |
| 1115 | 1115 | |
| 1116 | 1116 | $classes = array( 'frm_other_input' ); |
@@ -1131,15 +1131,15 @@ discard block |
||
| 1131 | 1131 | } |
| 1132 | 1132 | |
| 1133 | 1133 | /** |
| 1134 | - * Get the HTML id for an "Other" text field |
|
| 1135 | - * Note: This does not affect fields in repeating sections |
|
| 1136 | - * |
|
| 1137 | - * @since 2.0.08 |
|
| 1138 | - * @param string $type - field type |
|
| 1139 | - * @param string $html_id |
|
| 1140 | - * @param string|boolean $opt_key |
|
| 1141 | - * @return string $other_id |
|
| 1142 | - */ |
|
| 1134 | + * Get the HTML id for an "Other" text field |
|
| 1135 | + * Note: This does not affect fields in repeating sections |
|
| 1136 | + * |
|
| 1137 | + * @since 2.0.08 |
|
| 1138 | + * @param string $type - field type |
|
| 1139 | + * @param string $html_id |
|
| 1140 | + * @param string|boolean $opt_key |
|
| 1141 | + * @return string $other_id |
|
| 1142 | + */ |
|
| 1143 | 1143 | public static function get_other_field_html_id( $type, $html_id, $opt_key = false ) { |
| 1144 | 1144 | $other_id = $html_id; |
| 1145 | 1145 | |
@@ -1197,10 +1197,10 @@ discard block |
||
| 1197 | 1197 | } |
| 1198 | 1198 | |
| 1199 | 1199 | public static function switch_field_ids( $val ) { |
| 1200 | - global $frm_duplicate_ids; |
|
| 1201 | - $replace = array(); |
|
| 1202 | - $replace_with = array(); |
|
| 1203 | - foreach ( (array) $frm_duplicate_ids as $old => $new ) { |
|
| 1200 | + global $frm_duplicate_ids; |
|
| 1201 | + $replace = array(); |
|
| 1202 | + $replace_with = array(); |
|
| 1203 | + foreach ( (array) $frm_duplicate_ids as $old => $new ) { |
|
| 1204 | 1204 | $replace[] = '[if ' . $old . ']'; |
| 1205 | 1205 | $replace_with[] = '[if ' . $new . ']'; |
| 1206 | 1206 | $replace[] = '[if ' . $old . ' '; |
@@ -1215,153 +1215,153 @@ discard block |
||
| 1215 | 1215 | $replace_with[] = '[' . $new . ']'; |
| 1216 | 1216 | $replace[] = '[' . $old . ' '; |
| 1217 | 1217 | $replace_with[] = '[' . $new . ' '; |
| 1218 | - unset($old, $new); |
|
| 1219 | - } |
|
| 1218 | + unset($old, $new); |
|
| 1219 | + } |
|
| 1220 | 1220 | if ( is_array( $val ) ) { |
| 1221 | 1221 | foreach ( $val as $k => $v ) { |
| 1222 | - $val[ $k ] = str_replace( $replace, $replace_with, $v ); |
|
| 1223 | - unset($k, $v); |
|
| 1224 | - } |
|
| 1225 | - } else { |
|
| 1226 | - $val = str_replace($replace, $replace_with, $val); |
|
| 1227 | - } |
|
| 1228 | - |
|
| 1229 | - return $val; |
|
| 1230 | - } |
|
| 1231 | - |
|
| 1232 | - public static function get_us_states() { |
|
| 1233 | - return apply_filters( 'frm_us_states', array( |
|
| 1234 | - 'AL' => 'Alabama', 'AK' => 'Alaska', 'AR' => 'Arkansas', 'AZ' => 'Arizona', |
|
| 1235 | - 'CA' => 'California', 'CO' => 'Colorado', 'CT' => 'Connecticut', 'DE' => 'Delaware', |
|
| 1236 | - 'DC' => 'District of Columbia', |
|
| 1237 | - 'FL' => 'Florida', 'GA' => 'Georgia', 'HI' => 'Hawaii', 'ID' => 'Idaho', |
|
| 1238 | - 'IL' => 'Illinois', 'IN' => 'Indiana', 'IA' => 'Iowa', 'KS' => 'Kansas', |
|
| 1239 | - 'KY' => 'Kentucky', 'LA' => 'Louisiana', 'ME' => 'Maine','MD' => 'Maryland', |
|
| 1240 | - 'MA' => 'Massachusetts', 'MI' => 'Michigan', 'MN' => 'Minnesota', 'MS' => 'Mississippi', |
|
| 1241 | - 'MO' => 'Missouri', 'MT' => 'Montana', 'NE' => 'Nebraska', 'NV' => 'Nevada', |
|
| 1242 | - 'NH' => 'New Hampshire', 'NJ' => 'New Jersey', 'NM' => 'New Mexico', 'NY' => 'New York', |
|
| 1243 | - 'NC' => 'North Carolina', 'ND' => 'North Dakota', 'OH' => 'Ohio', 'OK' => 'Oklahoma', |
|
| 1244 | - 'OR' => 'Oregon', 'PA' => 'Pennsylvania', 'RI' => 'Rhode Island', 'SC' => 'South Carolina', |
|
| 1245 | - 'SD' => 'South Dakota', 'TN' => 'Tennessee', 'TX' => 'Texas', 'UT' => 'Utah', |
|
| 1246 | - 'VT' => 'Vermont', 'VA' => 'Virginia', 'WA' => 'Washington', 'WV' => 'West Virginia', |
|
| 1247 | - 'WI' => 'Wisconsin', 'WY' => 'Wyoming', |
|
| 1248 | - ) ); |
|
| 1249 | - } |
|
| 1250 | - |
|
| 1251 | - public static function get_countries() { |
|
| 1252 | - return apply_filters( 'frm_countries', array( |
|
| 1253 | - __( 'Afghanistan', 'formidable' ), __( 'Albania', 'formidable' ), __( 'Algeria', 'formidable' ), |
|
| 1254 | - __( 'American Samoa', 'formidable' ), __( 'Andorra', 'formidable' ), __( 'Angola', 'formidable' ), |
|
| 1255 | - __( 'Anguilla', 'formidable' ), __( 'Antarctica', 'formidable' ), __( 'Antigua and Barbuda', 'formidable' ), |
|
| 1256 | - __( 'Argentina', 'formidable' ), __( 'Armenia', 'formidable' ), __( 'Aruba', 'formidable' ), |
|
| 1257 | - __( 'Australia', 'formidable' ), __( 'Austria', 'formidable' ), __( 'Azerbaijan', 'formidable' ), |
|
| 1258 | - __( 'Bahamas', 'formidable' ), __( 'Bahrain', 'formidable' ), __( 'Bangladesh', 'formidable' ), |
|
| 1259 | - __( 'Barbados', 'formidable' ), __( 'Belarus', 'formidable' ), __( 'Belgium', 'formidable' ), |
|
| 1260 | - __( 'Belize', 'formidable' ), __( 'Benin', 'formidable' ), __( 'Bermuda', 'formidable' ), |
|
| 1261 | - __( 'Bhutan', 'formidable' ), __( 'Bolivia', 'formidable' ), __( 'Bosnia and Herzegovina', 'formidable' ), |
|
| 1262 | - __( 'Botswana', 'formidable' ), __( 'Brazil', 'formidable' ), __( 'Brunei', 'formidable' ), |
|
| 1263 | - __( 'Bulgaria', 'formidable' ), __( 'Burkina Faso', 'formidable' ), __( 'Burundi', 'formidable' ), |
|
| 1264 | - __( 'Cambodia', 'formidable' ), __( 'Cameroon', 'formidable' ), __( 'Canada', 'formidable' ), |
|
| 1265 | - __( 'Cape Verde', 'formidable' ), __( 'Cayman Islands', 'formidable' ), __( 'Central African Republic', 'formidable' ), |
|
| 1266 | - __( 'Chad', 'formidable' ), __( 'Chile', 'formidable' ), __( 'China', 'formidable' ), |
|
| 1267 | - __( 'Colombia', 'formidable' ), __( 'Comoros', 'formidable' ), __( 'Congo', 'formidable' ), |
|
| 1268 | - __( 'Costa Rica', 'formidable' ), __( 'Côte d\'Ivoire', 'formidable' ), __( 'Croatia', 'formidable' ), |
|
| 1269 | - __( 'Cuba', 'formidable' ), __( 'Cyprus', 'formidable' ), __( 'Czech Republic', 'formidable' ), |
|
| 1270 | - __( 'Denmark', 'formidable' ), __( 'Djibouti', 'formidable' ), __( 'Dominica', 'formidable' ), |
|
| 1271 | - __( 'Dominican Republic', 'formidable' ), __( 'East Timor', 'formidable' ), __( 'Ecuador', 'formidable' ), |
|
| 1272 | - __( 'Egypt', 'formidable' ), __( 'El Salvador', 'formidable' ), __( 'Equatorial Guinea', 'formidable' ), |
|
| 1273 | - __( 'Eritrea', 'formidable' ), __( 'Estonia', 'formidable' ), __( 'Ethiopia', 'formidable' ), |
|
| 1274 | - __( 'Fiji', 'formidable' ), __( 'Finland', 'formidable' ), __( 'France', 'formidable' ), |
|
| 1275 | - __( 'French Guiana', 'formidable' ), __( 'French Polynesia', 'formidable' ), __( 'Gabon', 'formidable' ), |
|
| 1276 | - __( 'Gambia', 'formidable' ), __( 'Georgia', 'formidable' ), __( 'Germany', 'formidable' ), |
|
| 1277 | - __( 'Ghana', 'formidable' ), __( 'Gibraltar', 'formidable' ), __( 'Greece', 'formidable' ), |
|
| 1278 | - __( 'Greenland', 'formidable' ), __( 'Grenada', 'formidable' ), __( 'Guam', 'formidable' ), |
|
| 1279 | - __( 'Guatemala', 'formidable' ), __( 'Guinea', 'formidable' ), __( 'Guinea-Bissau', 'formidable' ), |
|
| 1280 | - __( 'Guyana', 'formidable' ), __( 'Haiti', 'formidable' ), __( 'Honduras', 'formidable' ), |
|
| 1281 | - __( 'Hong Kong', 'formidable' ), __( 'Hungary', 'formidable' ), __( 'Iceland', 'formidable' ), |
|
| 1282 | - __( 'India', 'formidable' ), __( 'Indonesia', 'formidable' ), __( 'Iran', 'formidable' ), |
|
| 1283 | - __( 'Iraq', 'formidable' ), __( 'Ireland', 'formidable' ), __( 'Israel', 'formidable' ), |
|
| 1284 | - __( 'Italy', 'formidable' ), __( 'Jamaica', 'formidable' ), __( 'Japan', 'formidable' ), |
|
| 1285 | - __( 'Jordan', 'formidable' ), __( 'Kazakhstan', 'formidable' ), __( 'Kenya', 'formidable' ), |
|
| 1286 | - __( 'Kiribati', 'formidable' ), __( 'North Korea', 'formidable' ), __( 'South Korea', 'formidable' ), |
|
| 1287 | - __( 'Kuwait', 'formidable' ), __( 'Kyrgyzstan', 'formidable' ), __( 'Laos', 'formidable' ), |
|
| 1288 | - __( 'Latvia', 'formidable' ), __( 'Lebanon', 'formidable' ), __( 'Lesotho', 'formidable' ), |
|
| 1289 | - __( 'Liberia', 'formidable' ), __( 'Libya', 'formidable' ), __( 'Liechtenstein', 'formidable' ), |
|
| 1290 | - __( 'Lithuania', 'formidable' ), __( 'Luxembourg', 'formidable' ), __( 'Macedonia', 'formidable' ), |
|
| 1291 | - __( 'Madagascar', 'formidable' ), __( 'Malawi', 'formidable' ), __( 'Malaysia', 'formidable' ), |
|
| 1292 | - __( 'Maldives', 'formidable' ), __( 'Mali', 'formidable' ), __( 'Malta', 'formidable' ), |
|
| 1293 | - __( 'Marshall Islands', 'formidable' ), __( 'Mauritania', 'formidable' ), __( 'Mauritius', 'formidable' ), |
|
| 1294 | - __( 'Mexico', 'formidable' ), __( 'Micronesia', 'formidable' ), __( 'Moldova', 'formidable' ), |
|
| 1295 | - __( 'Monaco', 'formidable' ), __( 'Mongolia', 'formidable' ), __( 'Montenegro', 'formidable' ), |
|
| 1296 | - __( 'Montserrat', 'formidable' ), __( 'Morocco', 'formidable' ), __( 'Mozambique', 'formidable' ), |
|
| 1297 | - __( 'Myanmar', 'formidable' ), __( 'Namibia', 'formidable' ), __( 'Nauru', 'formidable' ), |
|
| 1298 | - __( 'Nepal', 'formidable' ), __( 'Netherlands', 'formidable' ), __( 'New Zealand', 'formidable' ), |
|
| 1299 | - __( 'Nicaragua', 'formidable' ), __( 'Niger', 'formidable' ), __( 'Nigeria', 'formidable' ), |
|
| 1300 | - __( 'Norway', 'formidable' ), __( 'Northern Mariana Islands', 'formidable' ), __( 'Oman', 'formidable' ), |
|
| 1301 | - __( 'Pakistan', 'formidable' ), __( 'Palau', 'formidable' ), __( 'Palestine', 'formidable' ), |
|
| 1302 | - __( 'Panama', 'formidable' ), __( 'Papua New Guinea', 'formidable' ), __( 'Paraguay', 'formidable' ), |
|
| 1303 | - __( 'Peru', 'formidable' ), __( 'Philippines', 'formidable' ), __( 'Poland', 'formidable' ), |
|
| 1304 | - __( 'Portugal', 'formidable' ), __( 'Puerto Rico', 'formidable' ), __( 'Qatar', 'formidable' ), |
|
| 1305 | - __( 'Romania', 'formidable' ), __( 'Russia', 'formidable' ), __( 'Rwanda', 'formidable' ), |
|
| 1306 | - __( 'Saint Kitts and Nevis', 'formidable' ), __( 'Saint Lucia', 'formidable' ), |
|
| 1307 | - __( 'Saint Vincent and the Grenadines', 'formidable' ), __( 'Samoa', 'formidable' ), |
|
| 1308 | - __( 'San Marino', 'formidable' ), __( 'Sao Tome and Principe', 'formidable' ), __( 'Saudi Arabia', 'formidable' ), |
|
| 1309 | - __( 'Senegal', 'formidable' ), __( 'Serbia and Montenegro', 'formidable' ), __( 'Seychelles', 'formidable' ), |
|
| 1310 | - __( 'Sierra Leone', 'formidable' ), __( 'Singapore', 'formidable' ), __( 'Slovakia', 'formidable' ), |
|
| 1311 | - __( 'Slovenia', 'formidable' ), __( 'Solomon Islands', 'formidable' ), __( 'Somalia', 'formidable' ), |
|
| 1312 | - __( 'South Africa', 'formidable' ), __( 'South Sudan', 'formidable' ), |
|
| 1313 | - __( 'Spain', 'formidable' ), __( 'Sri Lanka', 'formidable' ), |
|
| 1314 | - __( 'Sudan', 'formidable' ), __( 'Suriname', 'formidable' ), __( 'Swaziland', 'formidable' ), |
|
| 1315 | - __( 'Sweden', 'formidable' ), __( 'Switzerland', 'formidable' ), __( 'Syria', 'formidable' ), |
|
| 1316 | - __( 'Taiwan', 'formidable' ), __( 'Tajikistan', 'formidable' ), __( 'Tanzania', 'formidable' ), |
|
| 1317 | - __( 'Thailand', 'formidable' ), __( 'Togo', 'formidable' ), __( 'Tonga', 'formidable' ), |
|
| 1318 | - __( 'Trinidad and Tobago', 'formidable' ), __( 'Tunisia', 'formidable' ), __( 'Turkey', 'formidable' ), |
|
| 1319 | - __( 'Turkmenistan', 'formidable' ), __( 'Tuvalu', 'formidable' ), __( 'Uganda', 'formidable' ), |
|
| 1320 | - __( 'Ukraine', 'formidable' ), __( 'United Arab Emirates', 'formidable' ), __( 'United Kingdom', 'formidable' ), |
|
| 1321 | - __( 'United States', 'formidable' ), __( 'Uruguay', 'formidable' ), __( 'Uzbekistan', 'formidable' ), |
|
| 1322 | - __( 'Vanuatu', 'formidable' ), __( 'Vatican City', 'formidable' ), __( 'Venezuela', 'formidable' ), |
|
| 1323 | - __( 'Vietnam', 'formidable' ), __( 'Virgin Islands, British', 'formidable' ), |
|
| 1324 | - __( 'Virgin Islands, U.S.', 'formidable' ), __( 'Yemen', 'formidable' ), __( 'Zambia', 'formidable' ), |
|
| 1325 | - __( 'Zimbabwe', 'formidable' ), |
|
| 1326 | - ) ); |
|
| 1327 | - } |
|
| 1222 | + $val[ $k ] = str_replace( $replace, $replace_with, $v ); |
|
| 1223 | + unset($k, $v); |
|
| 1224 | + } |
|
| 1225 | + } else { |
|
| 1226 | + $val = str_replace($replace, $replace_with, $val); |
|
| 1227 | + } |
|
| 1228 | + |
|
| 1229 | + return $val; |
|
| 1230 | + } |
|
| 1231 | + |
|
| 1232 | + public static function get_us_states() { |
|
| 1233 | + return apply_filters( 'frm_us_states', array( |
|
| 1234 | + 'AL' => 'Alabama', 'AK' => 'Alaska', 'AR' => 'Arkansas', 'AZ' => 'Arizona', |
|
| 1235 | + 'CA' => 'California', 'CO' => 'Colorado', 'CT' => 'Connecticut', 'DE' => 'Delaware', |
|
| 1236 | + 'DC' => 'District of Columbia', |
|
| 1237 | + 'FL' => 'Florida', 'GA' => 'Georgia', 'HI' => 'Hawaii', 'ID' => 'Idaho', |
|
| 1238 | + 'IL' => 'Illinois', 'IN' => 'Indiana', 'IA' => 'Iowa', 'KS' => 'Kansas', |
|
| 1239 | + 'KY' => 'Kentucky', 'LA' => 'Louisiana', 'ME' => 'Maine','MD' => 'Maryland', |
|
| 1240 | + 'MA' => 'Massachusetts', 'MI' => 'Michigan', 'MN' => 'Minnesota', 'MS' => 'Mississippi', |
|
| 1241 | + 'MO' => 'Missouri', 'MT' => 'Montana', 'NE' => 'Nebraska', 'NV' => 'Nevada', |
|
| 1242 | + 'NH' => 'New Hampshire', 'NJ' => 'New Jersey', 'NM' => 'New Mexico', 'NY' => 'New York', |
|
| 1243 | + 'NC' => 'North Carolina', 'ND' => 'North Dakota', 'OH' => 'Ohio', 'OK' => 'Oklahoma', |
|
| 1244 | + 'OR' => 'Oregon', 'PA' => 'Pennsylvania', 'RI' => 'Rhode Island', 'SC' => 'South Carolina', |
|
| 1245 | + 'SD' => 'South Dakota', 'TN' => 'Tennessee', 'TX' => 'Texas', 'UT' => 'Utah', |
|
| 1246 | + 'VT' => 'Vermont', 'VA' => 'Virginia', 'WA' => 'Washington', 'WV' => 'West Virginia', |
|
| 1247 | + 'WI' => 'Wisconsin', 'WY' => 'Wyoming', |
|
| 1248 | + ) ); |
|
| 1249 | + } |
|
| 1250 | + |
|
| 1251 | + public static function get_countries() { |
|
| 1252 | + return apply_filters( 'frm_countries', array( |
|
| 1253 | + __( 'Afghanistan', 'formidable' ), __( 'Albania', 'formidable' ), __( 'Algeria', 'formidable' ), |
|
| 1254 | + __( 'American Samoa', 'formidable' ), __( 'Andorra', 'formidable' ), __( 'Angola', 'formidable' ), |
|
| 1255 | + __( 'Anguilla', 'formidable' ), __( 'Antarctica', 'formidable' ), __( 'Antigua and Barbuda', 'formidable' ), |
|
| 1256 | + __( 'Argentina', 'formidable' ), __( 'Armenia', 'formidable' ), __( 'Aruba', 'formidable' ), |
|
| 1257 | + __( 'Australia', 'formidable' ), __( 'Austria', 'formidable' ), __( 'Azerbaijan', 'formidable' ), |
|
| 1258 | + __( 'Bahamas', 'formidable' ), __( 'Bahrain', 'formidable' ), __( 'Bangladesh', 'formidable' ), |
|
| 1259 | + __( 'Barbados', 'formidable' ), __( 'Belarus', 'formidable' ), __( 'Belgium', 'formidable' ), |
|
| 1260 | + __( 'Belize', 'formidable' ), __( 'Benin', 'formidable' ), __( 'Bermuda', 'formidable' ), |
|
| 1261 | + __( 'Bhutan', 'formidable' ), __( 'Bolivia', 'formidable' ), __( 'Bosnia and Herzegovina', 'formidable' ), |
|
| 1262 | + __( 'Botswana', 'formidable' ), __( 'Brazil', 'formidable' ), __( 'Brunei', 'formidable' ), |
|
| 1263 | + __( 'Bulgaria', 'formidable' ), __( 'Burkina Faso', 'formidable' ), __( 'Burundi', 'formidable' ), |
|
| 1264 | + __( 'Cambodia', 'formidable' ), __( 'Cameroon', 'formidable' ), __( 'Canada', 'formidable' ), |
|
| 1265 | + __( 'Cape Verde', 'formidable' ), __( 'Cayman Islands', 'formidable' ), __( 'Central African Republic', 'formidable' ), |
|
| 1266 | + __( 'Chad', 'formidable' ), __( 'Chile', 'formidable' ), __( 'China', 'formidable' ), |
|
| 1267 | + __( 'Colombia', 'formidable' ), __( 'Comoros', 'formidable' ), __( 'Congo', 'formidable' ), |
|
| 1268 | + __( 'Costa Rica', 'formidable' ), __( 'Côte d\'Ivoire', 'formidable' ), __( 'Croatia', 'formidable' ), |
|
| 1269 | + __( 'Cuba', 'formidable' ), __( 'Cyprus', 'formidable' ), __( 'Czech Republic', 'formidable' ), |
|
| 1270 | + __( 'Denmark', 'formidable' ), __( 'Djibouti', 'formidable' ), __( 'Dominica', 'formidable' ), |
|
| 1271 | + __( 'Dominican Republic', 'formidable' ), __( 'East Timor', 'formidable' ), __( 'Ecuador', 'formidable' ), |
|
| 1272 | + __( 'Egypt', 'formidable' ), __( 'El Salvador', 'formidable' ), __( 'Equatorial Guinea', 'formidable' ), |
|
| 1273 | + __( 'Eritrea', 'formidable' ), __( 'Estonia', 'formidable' ), __( 'Ethiopia', 'formidable' ), |
|
| 1274 | + __( 'Fiji', 'formidable' ), __( 'Finland', 'formidable' ), __( 'France', 'formidable' ), |
|
| 1275 | + __( 'French Guiana', 'formidable' ), __( 'French Polynesia', 'formidable' ), __( 'Gabon', 'formidable' ), |
|
| 1276 | + __( 'Gambia', 'formidable' ), __( 'Georgia', 'formidable' ), __( 'Germany', 'formidable' ), |
|
| 1277 | + __( 'Ghana', 'formidable' ), __( 'Gibraltar', 'formidable' ), __( 'Greece', 'formidable' ), |
|
| 1278 | + __( 'Greenland', 'formidable' ), __( 'Grenada', 'formidable' ), __( 'Guam', 'formidable' ), |
|
| 1279 | + __( 'Guatemala', 'formidable' ), __( 'Guinea', 'formidable' ), __( 'Guinea-Bissau', 'formidable' ), |
|
| 1280 | + __( 'Guyana', 'formidable' ), __( 'Haiti', 'formidable' ), __( 'Honduras', 'formidable' ), |
|
| 1281 | + __( 'Hong Kong', 'formidable' ), __( 'Hungary', 'formidable' ), __( 'Iceland', 'formidable' ), |
|
| 1282 | + __( 'India', 'formidable' ), __( 'Indonesia', 'formidable' ), __( 'Iran', 'formidable' ), |
|
| 1283 | + __( 'Iraq', 'formidable' ), __( 'Ireland', 'formidable' ), __( 'Israel', 'formidable' ), |
|
| 1284 | + __( 'Italy', 'formidable' ), __( 'Jamaica', 'formidable' ), __( 'Japan', 'formidable' ), |
|
| 1285 | + __( 'Jordan', 'formidable' ), __( 'Kazakhstan', 'formidable' ), __( 'Kenya', 'formidable' ), |
|
| 1286 | + __( 'Kiribati', 'formidable' ), __( 'North Korea', 'formidable' ), __( 'South Korea', 'formidable' ), |
|
| 1287 | + __( 'Kuwait', 'formidable' ), __( 'Kyrgyzstan', 'formidable' ), __( 'Laos', 'formidable' ), |
|
| 1288 | + __( 'Latvia', 'formidable' ), __( 'Lebanon', 'formidable' ), __( 'Lesotho', 'formidable' ), |
|
| 1289 | + __( 'Liberia', 'formidable' ), __( 'Libya', 'formidable' ), __( 'Liechtenstein', 'formidable' ), |
|
| 1290 | + __( 'Lithuania', 'formidable' ), __( 'Luxembourg', 'formidable' ), __( 'Macedonia', 'formidable' ), |
|
| 1291 | + __( 'Madagascar', 'formidable' ), __( 'Malawi', 'formidable' ), __( 'Malaysia', 'formidable' ), |
|
| 1292 | + __( 'Maldives', 'formidable' ), __( 'Mali', 'formidable' ), __( 'Malta', 'formidable' ), |
|
| 1293 | + __( 'Marshall Islands', 'formidable' ), __( 'Mauritania', 'formidable' ), __( 'Mauritius', 'formidable' ), |
|
| 1294 | + __( 'Mexico', 'formidable' ), __( 'Micronesia', 'formidable' ), __( 'Moldova', 'formidable' ), |
|
| 1295 | + __( 'Monaco', 'formidable' ), __( 'Mongolia', 'formidable' ), __( 'Montenegro', 'formidable' ), |
|
| 1296 | + __( 'Montserrat', 'formidable' ), __( 'Morocco', 'formidable' ), __( 'Mozambique', 'formidable' ), |
|
| 1297 | + __( 'Myanmar', 'formidable' ), __( 'Namibia', 'formidable' ), __( 'Nauru', 'formidable' ), |
|
| 1298 | + __( 'Nepal', 'formidable' ), __( 'Netherlands', 'formidable' ), __( 'New Zealand', 'formidable' ), |
|
| 1299 | + __( 'Nicaragua', 'formidable' ), __( 'Niger', 'formidable' ), __( 'Nigeria', 'formidable' ), |
|
| 1300 | + __( 'Norway', 'formidable' ), __( 'Northern Mariana Islands', 'formidable' ), __( 'Oman', 'formidable' ), |
|
| 1301 | + __( 'Pakistan', 'formidable' ), __( 'Palau', 'formidable' ), __( 'Palestine', 'formidable' ), |
|
| 1302 | + __( 'Panama', 'formidable' ), __( 'Papua New Guinea', 'formidable' ), __( 'Paraguay', 'formidable' ), |
|
| 1303 | + __( 'Peru', 'formidable' ), __( 'Philippines', 'formidable' ), __( 'Poland', 'formidable' ), |
|
| 1304 | + __( 'Portugal', 'formidable' ), __( 'Puerto Rico', 'formidable' ), __( 'Qatar', 'formidable' ), |
|
| 1305 | + __( 'Romania', 'formidable' ), __( 'Russia', 'formidable' ), __( 'Rwanda', 'formidable' ), |
|
| 1306 | + __( 'Saint Kitts and Nevis', 'formidable' ), __( 'Saint Lucia', 'formidable' ), |
|
| 1307 | + __( 'Saint Vincent and the Grenadines', 'formidable' ), __( 'Samoa', 'formidable' ), |
|
| 1308 | + __( 'San Marino', 'formidable' ), __( 'Sao Tome and Principe', 'formidable' ), __( 'Saudi Arabia', 'formidable' ), |
|
| 1309 | + __( 'Senegal', 'formidable' ), __( 'Serbia and Montenegro', 'formidable' ), __( 'Seychelles', 'formidable' ), |
|
| 1310 | + __( 'Sierra Leone', 'formidable' ), __( 'Singapore', 'formidable' ), __( 'Slovakia', 'formidable' ), |
|
| 1311 | + __( 'Slovenia', 'formidable' ), __( 'Solomon Islands', 'formidable' ), __( 'Somalia', 'formidable' ), |
|
| 1312 | + __( 'South Africa', 'formidable' ), __( 'South Sudan', 'formidable' ), |
|
| 1313 | + __( 'Spain', 'formidable' ), __( 'Sri Lanka', 'formidable' ), |
|
| 1314 | + __( 'Sudan', 'formidable' ), __( 'Suriname', 'formidable' ), __( 'Swaziland', 'formidable' ), |
|
| 1315 | + __( 'Sweden', 'formidable' ), __( 'Switzerland', 'formidable' ), __( 'Syria', 'formidable' ), |
|
| 1316 | + __( 'Taiwan', 'formidable' ), __( 'Tajikistan', 'formidable' ), __( 'Tanzania', 'formidable' ), |
|
| 1317 | + __( 'Thailand', 'formidable' ), __( 'Togo', 'formidable' ), __( 'Tonga', 'formidable' ), |
|
| 1318 | + __( 'Trinidad and Tobago', 'formidable' ), __( 'Tunisia', 'formidable' ), __( 'Turkey', 'formidable' ), |
|
| 1319 | + __( 'Turkmenistan', 'formidable' ), __( 'Tuvalu', 'formidable' ), __( 'Uganda', 'formidable' ), |
|
| 1320 | + __( 'Ukraine', 'formidable' ), __( 'United Arab Emirates', 'formidable' ), __( 'United Kingdom', 'formidable' ), |
|
| 1321 | + __( 'United States', 'formidable' ), __( 'Uruguay', 'formidable' ), __( 'Uzbekistan', 'formidable' ), |
|
| 1322 | + __( 'Vanuatu', 'formidable' ), __( 'Vatican City', 'formidable' ), __( 'Venezuela', 'formidable' ), |
|
| 1323 | + __( 'Vietnam', 'formidable' ), __( 'Virgin Islands, British', 'formidable' ), |
|
| 1324 | + __( 'Virgin Islands, U.S.', 'formidable' ), __( 'Yemen', 'formidable' ), __( 'Zambia', 'formidable' ), |
|
| 1325 | + __( 'Zimbabwe', 'formidable' ), |
|
| 1326 | + ) ); |
|
| 1327 | + } |
|
| 1328 | 1328 | |
| 1329 | 1329 | public static function get_bulk_prefilled_opts( array &$prepop ) { |
| 1330 | 1330 | $prepop[ __( 'Countries', 'formidable' ) ] = FrmFieldsHelper::get_countries(); |
| 1331 | 1331 | |
| 1332 | - $states = FrmFieldsHelper::get_us_states(); |
|
| 1333 | - $state_abv = array_keys($states); |
|
| 1334 | - sort($state_abv); |
|
| 1332 | + $states = FrmFieldsHelper::get_us_states(); |
|
| 1333 | + $state_abv = array_keys($states); |
|
| 1334 | + sort($state_abv); |
|
| 1335 | 1335 | $prepop[ __( 'U.S. State Abbreviations', 'formidable' ) ] = $state_abv; |
| 1336 | 1336 | |
| 1337 | - $states = array_values($states); |
|
| 1338 | - sort($states); |
|
| 1337 | + $states = array_values($states); |
|
| 1338 | + sort($states); |
|
| 1339 | 1339 | $prepop[ __( 'U.S. States', 'formidable' ) ] = $states; |
| 1340 | - unset($state_abv, $states); |
|
| 1340 | + unset($state_abv, $states); |
|
| 1341 | 1341 | |
| 1342 | 1342 | $prepop[ __( 'Age', 'formidable' ) ] = array( |
| 1343 | - __( 'Under 18', 'formidable' ), __( '18-24', 'formidable' ), __( '25-34', 'formidable' ), |
|
| 1344 | - __( '35-44', 'formidable' ), __( '45-54', 'formidable' ), __( '55-64', 'formidable' ), |
|
| 1345 | - __( '65 or Above', 'formidable' ), __( 'Prefer Not to Answer', 'formidable' ), |
|
| 1346 | - ); |
|
| 1343 | + __( 'Under 18', 'formidable' ), __( '18-24', 'formidable' ), __( '25-34', 'formidable' ), |
|
| 1344 | + __( '35-44', 'formidable' ), __( '45-54', 'formidable' ), __( '55-64', 'formidable' ), |
|
| 1345 | + __( '65 or Above', 'formidable' ), __( 'Prefer Not to Answer', 'formidable' ), |
|
| 1346 | + ); |
|
| 1347 | 1347 | |
| 1348 | 1348 | $prepop[ __( 'Satisfaction', 'formidable' ) ] = array( |
| 1349 | - __( 'Very Satisfied', 'formidable' ), __( 'Satisfied', 'formidable' ), __( 'Neutral', 'formidable' ), |
|
| 1350 | - __( 'Unsatisfied', 'formidable' ), __( 'Very Unsatisfied', 'formidable' ), __( 'N/A', 'formidable' ), |
|
| 1351 | - ); |
|
| 1349 | + __( 'Very Satisfied', 'formidable' ), __( 'Satisfied', 'formidable' ), __( 'Neutral', 'formidable' ), |
|
| 1350 | + __( 'Unsatisfied', 'formidable' ), __( 'Very Unsatisfied', 'formidable' ), __( 'N/A', 'formidable' ), |
|
| 1351 | + ); |
|
| 1352 | 1352 | |
| 1353 | 1353 | $prepop[ __( 'Importance', 'formidable' ) ] = array( |
| 1354 | - __( 'Very Important', 'formidable' ), __( 'Important', 'formidable' ), __( 'Neutral', 'formidable' ), |
|
| 1355 | - __( 'Somewhat Important', 'formidable' ), __( 'Not at all Important', 'formidable' ), __( 'N/A', 'formidable' ), |
|
| 1356 | - ); |
|
| 1354 | + __( 'Very Important', 'formidable' ), __( 'Important', 'formidable' ), __( 'Neutral', 'formidable' ), |
|
| 1355 | + __( 'Somewhat Important', 'formidable' ), __( 'Not at all Important', 'formidable' ), __( 'N/A', 'formidable' ), |
|
| 1356 | + ); |
|
| 1357 | 1357 | |
| 1358 | 1358 | $prepop[ __( 'Agreement', 'formidable' ) ] = array( |
| 1359 | - __( 'Strongly Agree', 'formidable' ), __( 'Agree', 'formidable' ), __( 'Neutral', 'formidable' ), |
|
| 1360 | - __( 'Disagree', 'formidable' ), __( 'Strongly Disagree', 'formidable' ), __( 'N/A', 'formidable' ), |
|
| 1361 | - ); |
|
| 1359 | + __( 'Strongly Agree', 'formidable' ), __( 'Agree', 'formidable' ), __( 'Neutral', 'formidable' ), |
|
| 1360 | + __( 'Disagree', 'formidable' ), __( 'Strongly Disagree', 'formidable' ), __( 'N/A', 'formidable' ), |
|
| 1361 | + ); |
|
| 1362 | 1362 | |
| 1363 | 1363 | $prepop = apply_filters( 'frm_bulk_field_choices', $prepop ); |
| 1364 | - } |
|
| 1364 | + } |
|
| 1365 | 1365 | |
| 1366 | 1366 | /** |
| 1367 | 1367 | * Display a field value selector |
@@ -1371,10 +1371,10 @@ discard block |
||
| 1371 | 1371 | * @param int $selector_field_id |
| 1372 | 1372 | * @param array $selector_args |
| 1373 | 1373 | */ |
| 1374 | - public static function display_field_value_selector( $selector_field_id, $selector_args ) { |
|
| 1375 | - $field_value_selector = FrmFieldFactory::create_field_value_selector( $selector_field_id, $selector_args ); |
|
| 1376 | - $field_value_selector->display(); |
|
| 1377 | - } |
|
| 1374 | + public static function display_field_value_selector( $selector_field_id, $selector_args ) { |
|
| 1375 | + $field_value_selector = FrmFieldFactory::create_field_value_selector( $selector_field_id, $selector_args ); |
|
| 1376 | + $field_value_selector->display(); |
|
| 1377 | + } |
|
| 1378 | 1378 | |
| 1379 | 1379 | /** |
| 1380 | 1380 | * Convert a field object to a flat array |
@@ -1427,10 +1427,10 @@ discard block |
||
| 1427 | 1427 | return FrmField::is_required( $field ); |
| 1428 | 1428 | } |
| 1429 | 1429 | |
| 1430 | - public static function maybe_get_field( &$field ) { |
|
| 1430 | + public static function maybe_get_field( &$field ) { |
|
| 1431 | 1431 | _deprecated_function( __FUNCTION__, '2.0.9', 'FrmField::maybe_get_field' ); |
| 1432 | 1432 | FrmField::maybe_get_field( $field ); |
| 1433 | - } |
|
| 1433 | + } |
|
| 1434 | 1434 | |
| 1435 | 1435 | public static function dropdown_categories( $args ) { |
| 1436 | 1436 | _deprecated_function( __FUNCTION__, '2.02.07', 'FrmProPost::get_category_dropdown' ); |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if ( ! defined('ABSPATH') ) { |
|
| 2 | +if ( ! defined( 'ABSPATH' ) ) { |
|
| 3 | 3 | die( 'You are not allowed to call this page directly.' ); |
| 4 | 4 | } |
| 5 | 5 | |
@@ -7,12 +7,12 @@ discard block |
||
| 7 | 7 | |
| 8 | 8 | public static function setup_new_vars( $type = '', $form_id = '' ) { |
| 9 | 9 | |
| 10 | - if ( strpos($type, '|') ) { |
|
| 11 | - list($type, $setting) = explode('|', $type); |
|
| 10 | + if ( strpos( $type, '|' ) ) { |
|
| 11 | + list( $type, $setting ) = explode( '|', $type ); |
|
| 12 | 12 | } |
| 13 | 13 | |
| 14 | - $defaults = self::get_default_field_opts($type, $form_id); |
|
| 15 | - $defaults['field_options']['custom_html'] = self::get_default_html($type); |
|
| 14 | + $defaults = self::get_default_field_opts( $type, $form_id ); |
|
| 15 | + $defaults['field_options']['custom_html'] = self::get_default_html( $type ); |
|
| 16 | 16 | |
| 17 | 17 | $values = array(); |
| 18 | 18 | |
@@ -20,20 +20,20 @@ discard block |
||
| 20 | 20 | if ( $var == 'field_options' ) { |
| 21 | 21 | $values['field_options'] = array(); |
| 22 | 22 | foreach ( $default as $opt_var => $opt_default ) { |
| 23 | - $values['field_options'][ $opt_var ] = $opt_default; |
|
| 24 | - unset($opt_var, $opt_default); |
|
| 23 | + $values['field_options'][$opt_var] = $opt_default; |
|
| 24 | + unset( $opt_var, $opt_default ); |
|
| 25 | 25 | } |
| 26 | 26 | } else { |
| 27 | - $values[ $var ] = $default; |
|
| 27 | + $values[$var] = $default; |
|
| 28 | 28 | } |
| 29 | - unset($var, $default); |
|
| 29 | + unset( $var, $default ); |
|
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | if ( isset( $setting ) && ! empty( $setting ) ) { |
| 33 | 33 | if ( in_array( $type, array( 'data', 'lookup' ) ) ) { |
| 34 | 34 | $values['field_options']['data_type'] = $setting; |
| 35 | 35 | } else { |
| 36 | - $values['field_options'][ $setting ] = 1; |
|
| 36 | + $values['field_options'][$setting] = 1; |
|
| 37 | 37 | } |
| 38 | 38 | } |
| 39 | 39 | |
@@ -57,13 +57,13 @@ discard block |
||
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | $fields = FrmField::field_selection(); |
| 60 | - $fields = array_merge($fields, FrmField::pro_field_selection()); |
|
| 60 | + $fields = array_merge( $fields, FrmField::pro_field_selection() ); |
|
| 61 | 61 | |
| 62 | - if ( isset( $fields[ $type ] ) ) { |
|
| 63 | - $values['name'] = is_array( $fields[ $type ] ) ? $fields[ $type ]['name'] : $fields[ $type ]; |
|
| 62 | + if ( isset( $fields[$type] ) ) { |
|
| 63 | + $values['name'] = is_array( $fields[$type] ) ? $fields[$type]['name'] : $fields[$type]; |
|
| 64 | 64 | } |
| 65 | 65 | |
| 66 | - unset($fields); |
|
| 66 | + unset( $fields ); |
|
| 67 | 67 | |
| 68 | 68 | return $values; |
| 69 | 69 | } |
@@ -89,8 +89,8 @@ discard block |
||
| 89 | 89 | $values['form_name'] = ''; |
| 90 | 90 | } else { |
| 91 | 91 | foreach ( $defaults as $var => $default ) { |
| 92 | - $values[ $var ] = FrmAppHelper::get_param( $var, $default, 'get', 'htmlspecialchars' ); |
|
| 93 | - unset($var, $default); |
|
| 92 | + $values[$var] = FrmAppHelper::get_param( $var, $default, 'get', 'htmlspecialchars' ); |
|
| 93 | + unset( $var, $default ); |
|
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | $values['form_name'] = $record->form_id ? FrmForm::getName( $record->form_id ) : ''; |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | $values['options'] = $record->options; |
| 102 | 102 | $values['field_options'] = $record->field_options; |
| 103 | 103 | |
| 104 | - $defaults = self::get_default_field_opts($values['type'], $record, true); |
|
| 104 | + $defaults = self::get_default_field_opts( $values['type'], $record, true ); |
|
| 105 | 105 | |
| 106 | 106 | if ( $values['type'] == 'captcha' ) { |
| 107 | 107 | $frm_settings = FrmAppHelper::get_settings(); |
@@ -109,11 +109,11 @@ discard block |
||
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | foreach ( $defaults as $opt => $default ) { |
| 112 | - $values[ $opt ] = isset( $record->field_options[ $opt ] ) ? $record->field_options[ $opt ] : $default; |
|
| 113 | - unset($opt, $default); |
|
| 112 | + $values[$opt] = isset( $record->field_options[$opt] ) ? $record->field_options[$opt] : $default; |
|
| 113 | + unset( $opt, $default ); |
|
| 114 | 114 | } |
| 115 | 115 | |
| 116 | - $values['custom_html'] = (isset($record->field_options['custom_html'])) ? $record->field_options['custom_html'] : self::get_default_html($record->type); |
|
| 116 | + $values['custom_html'] = ( isset( $record->field_options['custom_html'] ) ) ? $record->field_options['custom_html'] : self::get_default_html( $record->type ); |
|
| 117 | 117 | |
| 118 | 118 | return apply_filters( 'frm_setup_edit_field_vars', $values, array( 'doing_ajax' => $doing_ajax ) ); |
| 119 | 119 | } |
@@ -132,7 +132,7 @@ discard block |
||
| 132 | 132 | |
| 133 | 133 | global $wpdb; |
| 134 | 134 | |
| 135 | - $form_id = (is_numeric($field)) ? $field : $field->form_id; |
|
| 135 | + $form_id = ( is_numeric( $field ) ) ? $field : $field->form_id; |
|
| 136 | 136 | |
| 137 | 137 | $key = is_numeric( $field ) ? FrmAppHelper::get_unique_key( '', $wpdb->prefix . 'frm_fields', 'field_key' ) : $field->field_key; |
| 138 | 138 | |
@@ -154,11 +154,11 @@ discard block |
||
| 154 | 154 | |
| 155 | 155 | $values['field_key'] = FrmAppHelper::get_unique_key( $new_key, $wpdb->prefix . 'frm_fields', 'field_key' ); |
| 156 | 156 | $values['form_id'] = $form_id; |
| 157 | - $values['options'] = maybe_serialize($field->options); |
|
| 158 | - $values['default_value'] = maybe_serialize($field->default_value); |
|
| 157 | + $values['options'] = maybe_serialize( $field->options ); |
|
| 158 | + $values['default_value'] = maybe_serialize( $field->default_value ); |
|
| 159 | 159 | |
| 160 | 160 | foreach ( array( 'name', 'description', 'type', 'field_order', 'field_options', 'required' ) as $col ) { |
| 161 | - $values[ $col ] = $field->{$col}; |
|
| 161 | + $values[$col] = $field->{$col}; |
|
| 162 | 162 | } |
| 163 | 163 | } |
| 164 | 164 | |
@@ -172,14 +172,14 @@ discard block |
||
| 172 | 172 | |
| 173 | 173 | $conf_msg = __( 'The entered values do not match', 'formidable' ); |
| 174 | 174 | $defaults = array( |
| 175 | - 'unique_msg' => array( 'full' => $default_settings['unique_msg'], 'part' => sprintf( __('%s must be unique', 'formidable' ), $field_name ) ), |
|
| 176 | - 'invalid' => array( 'full' => __( 'This field is invalid', 'formidable' ), 'part' => sprintf( __('%s is invalid', 'formidable' ), $field_name ) ), |
|
| 175 | + 'unique_msg' => array( 'full' => $default_settings['unique_msg'], 'part' => sprintf( __( '%s must be unique', 'formidable' ), $field_name ) ), |
|
| 176 | + 'invalid' => array( 'full' => __( 'This field is invalid', 'formidable' ), 'part' => sprintf( __( '%s is invalid', 'formidable' ), $field_name ) ), |
|
| 177 | 177 | 'blank' => array( 'full' => $frm_settings->blank_msg, 'part' => $frm_settings->blank_msg ), |
| 178 | 178 | 'conf_msg' => array( 'full' => $conf_msg, 'part' => $conf_msg ), |
| 179 | 179 | ); |
| 180 | 180 | |
| 181 | 181 | $msg = FrmField::get_option( $field, $error ); |
| 182 | - $msg = empty( $msg ) ? $defaults[ $error ]['part'] : $msg; |
|
| 182 | + $msg = empty( $msg ) ? $defaults[$error]['part'] : $msg; |
|
| 183 | 183 | $msg = do_shortcode( $msg ); |
| 184 | 184 | return $msg; |
| 185 | 185 | } |
@@ -209,14 +209,14 @@ discard block |
||
| 209 | 209 | </div> |
| 210 | 210 | DEFAULT_HTML; |
| 211 | 211 | } else { |
| 212 | - $default_html = apply_filters('frm_other_custom_html', '', $type); |
|
| 212 | + $default_html = apply_filters( 'frm_other_custom_html', '', $type ); |
|
| 213 | 213 | } |
| 214 | 214 | |
| 215 | - return apply_filters('frm_custom_html', $default_html, $type); |
|
| 215 | + return apply_filters( 'frm_custom_html', $default_html, $type ); |
|
| 216 | 216 | } |
| 217 | 217 | |
| 218 | 218 | public static function replace_shortcodes( $html, $field, $errors = array(), $form = false, $args = array() ) { |
| 219 | - $html = apply_filters('frm_before_replace_shortcodes', $html, $field, $errors, $form); |
|
| 219 | + $html = apply_filters( 'frm_before_replace_shortcodes', $html, $field, $errors, $form ); |
|
| 220 | 220 | |
| 221 | 221 | $defaults = array( |
| 222 | 222 | 'field_name' => 'item_meta[' . $field['id'] . ']', |
@@ -224,42 +224,42 @@ discard block |
||
| 224 | 224 | 'field_plus_id' => '', |
| 225 | 225 | 'section_id' => '', |
| 226 | 226 | ); |
| 227 | - $args = wp_parse_args($args, $defaults); |
|
| 227 | + $args = wp_parse_args( $args, $defaults ); |
|
| 228 | 228 | $field_name = $args['field_name']; |
| 229 | 229 | $field_id = $args['field_id']; |
| 230 | - $html_id = self::get_html_id($field, $args['field_plus_id']); |
|
| 230 | + $html_id = self::get_html_id( $field, $args['field_plus_id'] ); |
|
| 231 | 231 | |
| 232 | - if ( FrmField::is_multiple_select($field) ) { |
|
| 232 | + if ( FrmField::is_multiple_select( $field ) ) { |
|
| 233 | 233 | $field_name .= '[]'; |
| 234 | 234 | } |
| 235 | 235 | |
| 236 | 236 | //replace [id] |
| 237 | - $html = str_replace('[id]', $field_id, $html); |
|
| 237 | + $html = str_replace( '[id]', $field_id, $html ); |
|
| 238 | 238 | |
| 239 | 239 | // Remove the for attribute for captcha |
| 240 | 240 | if ( $field['type'] == 'captcha' ) { |
| 241 | - $html = str_replace(' for="field_[key]"', '', $html); |
|
| 241 | + $html = str_replace( ' for="field_[key]"', '', $html ); |
|
| 242 | 242 | } |
| 243 | 243 | |
| 244 | 244 | // set the label for |
| 245 | - $html = str_replace('field_[key]', $html_id, $html); |
|
| 245 | + $html = str_replace( 'field_[key]', $html_id, $html ); |
|
| 246 | 246 | |
| 247 | 247 | //replace [key] |
| 248 | - $html = str_replace('[key]', $field['field_key'], $html); |
|
| 248 | + $html = str_replace( '[key]', $field['field_key'], $html ); |
|
| 249 | 249 | |
| 250 | 250 | //replace [description] and [required_label] and [error] |
| 251 | 251 | $required = FrmField::is_required( $field ) ? $field['required_indicator'] : ''; |
| 252 | 252 | if ( ! is_array( $errors ) ) { |
| 253 | 253 | $errors = array(); |
| 254 | 254 | } |
| 255 | - $error = isset( $errors[ 'field' . $field_id ] ) ? $errors[ 'field' . $field_id ] : false; |
|
| 255 | + $error = isset( $errors['field' . $field_id] ) ? $errors['field' . $field_id] : false; |
|
| 256 | 256 | |
| 257 | 257 | //If field type is section heading, add class so a bottom margin can be added to either the h3 or description |
| 258 | 258 | if ( $field['type'] == 'divider' ) { |
| 259 | 259 | if ( FrmField::is_option_true( $field, 'description' ) ) { |
| 260 | 260 | $html = str_replace( 'frm_description', 'frm_description frm_section_spacing', $html ); |
| 261 | 261 | } else { |
| 262 | - $html = str_replace('[label_position]', '[label_position] frm_section_spacing', $html); |
|
| 262 | + $html = str_replace( '[label_position]', '[label_position] frm_section_spacing', $html ); |
|
| 263 | 263 | } |
| 264 | 264 | } |
| 265 | 265 | |
@@ -269,52 +269,52 @@ discard block |
||
| 269 | 269 | |
| 270 | 270 | //replace [required_class] |
| 271 | 271 | $required_class = FrmField::is_required( $field ) ? ' frm_required_field' : ''; |
| 272 | - $html = str_replace('[required_class]', $required_class, $html); |
|
| 272 | + $html = str_replace( '[required_class]', $required_class, $html ); |
|
| 273 | 273 | |
| 274 | 274 | //replace [label_position] |
| 275 | 275 | $field['label'] = self::label_position( $field['label'], $field, $form ); |
| 276 | 276 | self::add_class_to_label( $field, $html ); |
| 277 | 277 | |
| 278 | 278 | //replace [field_name] |
| 279 | - $html = str_replace('[field_name]', $field['name'], $html); |
|
| 279 | + $html = str_replace( '[field_name]', $field['name'], $html ); |
|
| 280 | 280 | |
| 281 | 281 | self::add_field_div_classes( $field_id, $field, $errors, $html ); |
| 282 | 282 | |
| 283 | 283 | //replace [entry_key] |
| 284 | 284 | $entry_key = FrmAppHelper::simple_get( 'entry', 'sanitize_title' ); |
| 285 | - $html = str_replace('[entry_key]', $entry_key, $html); |
|
| 285 | + $html = str_replace( '[entry_key]', $entry_key, $html ); |
|
| 286 | 286 | |
| 287 | 287 | if ( $form ) { |
| 288 | 288 | $form = (array) $form; |
| 289 | 289 | |
| 290 | 290 | //replace [form_key] |
| 291 | - $html = str_replace('[form_key]', $form['form_key'], $html); |
|
| 291 | + $html = str_replace( '[form_key]', $form['form_key'], $html ); |
|
| 292 | 292 | |
| 293 | 293 | //replace [form_name] |
| 294 | - $html = str_replace('[form_name]', $form['name'], $html); |
|
| 294 | + $html = str_replace( '[form_name]', $form['name'], $html ); |
|
| 295 | 295 | } |
| 296 | 296 | |
| 297 | 297 | self::process_wp_shortcodes( $html ); |
| 298 | 298 | |
| 299 | 299 | //replace [input] |
| 300 | - preg_match_all("/\[(input|deletelink)\b(.*?)(?:(\/))?\]/s", $html, $shortcodes, PREG_PATTERN_ORDER); |
|
| 300 | + preg_match_all( "/\[(input|deletelink)\b(.*?)(?:(\/))?\]/s", $html, $shortcodes, PREG_PATTERN_ORDER ); |
|
| 301 | 301 | global $frm_vars; |
| 302 | 302 | $frm_settings = FrmAppHelper::get_settings(); |
| 303 | 303 | |
| 304 | 304 | foreach ( $shortcodes[0] as $short_key => $tag ) { |
| 305 | - $atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[2][ $short_key ] ); |
|
| 305 | + $atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[2][$short_key] ); |
|
| 306 | 306 | $tag = self::get_shortcode_tag( $shortcodes, $short_key, array( 'conditional' => false, 'conditional_check' => false ) ); |
| 307 | 307 | |
| 308 | 308 | $replace_with = ''; |
| 309 | 309 | |
| 310 | 310 | if ( $tag == 'input' ) { |
| 311 | - if ( isset($atts['opt']) ) { |
|
| 312 | - $atts['opt']--; |
|
| 311 | + if ( isset( $atts['opt'] ) ) { |
|
| 312 | + $atts['opt'] --; |
|
| 313 | 313 | } |
| 314 | 314 | |
| 315 | - $field['input_class'] = isset($atts['class']) ? $atts['class'] : ''; |
|
| 316 | - if ( isset($atts['class']) ) { |
|
| 317 | - unset($atts['class']); |
|
| 315 | + $field['input_class'] = isset( $atts['class'] ) ? $atts['class'] : ''; |
|
| 316 | + if ( isset( $atts['class'] ) ) { |
|
| 317 | + unset( $atts['class'] ); |
|
| 318 | 318 | } |
| 319 | 319 | |
| 320 | 320 | $field['shortcodes'] = $atts; |
@@ -323,24 +323,24 @@ discard block |
||
| 323 | 323 | $replace_with = ob_get_contents(); |
| 324 | 324 | ob_end_clean(); |
| 325 | 325 | } else if ( $tag == 'deletelink' && FrmAppHelper::pro_is_installed() ) { |
| 326 | - $replace_with = FrmProEntriesController::entry_delete_link($atts); |
|
| 326 | + $replace_with = FrmProEntriesController::entry_delete_link( $atts ); |
|
| 327 | 327 | } |
| 328 | 328 | |
| 329 | - $html = str_replace( $shortcodes[0][ $short_key ], $replace_with, $html ); |
|
| 329 | + $html = str_replace( $shortcodes[0][$short_key], $replace_with, $html ); |
|
| 330 | 330 | } |
| 331 | 331 | |
| 332 | 332 | $html .= "\n"; |
| 333 | 333 | |
| 334 | 334 | //Return html if conf_field to prevent loop |
| 335 | - if ( isset($field['conf_field']) && $field['conf_field'] == 'stop' ) { |
|
| 335 | + if ( isset( $field['conf_field'] ) && $field['conf_field'] == 'stop' ) { |
|
| 336 | 336 | return $html; |
| 337 | 337 | } |
| 338 | 338 | |
| 339 | 339 | //If field is in repeating section |
| 340 | 340 | if ( $args['section_id'] ) { |
| 341 | - $html = apply_filters('frm_replace_shortcodes', $html, $field, array( 'errors' => $errors, 'form' => $form, 'field_name' => $field_name, 'field_id' => $field_id, 'field_plus_id' => $args['field_plus_id'], 'section_id' => $args['section_id'] )); |
|
| 341 | + $html = apply_filters( 'frm_replace_shortcodes', $html, $field, array( 'errors' => $errors, 'form' => $form, 'field_name' => $field_name, 'field_id' => $field_id, 'field_plus_id' => $args['field_plus_id'], 'section_id' => $args['section_id'] ) ); |
|
| 342 | 342 | } else { |
| 343 | - $html = apply_filters('frm_replace_shortcodes', $html, $field, array( 'errors' => $errors, 'form' => $form )); |
|
| 343 | + $html = apply_filters( 'frm_replace_shortcodes', $html, $field, array( 'errors' => $errors, 'form' => $form ) ); |
|
| 344 | 344 | } |
| 345 | 345 | |
| 346 | 346 | self::remove_collapse_shortcode( $html ); |
@@ -438,14 +438,14 @@ discard block |
||
| 438 | 438 | */ |
| 439 | 439 | private static function get_field_div_classes( $field_id, $field, $errors, $html ) { |
| 440 | 440 | // Add error class |
| 441 | - $classes = isset( $errors[ 'field' . $field_id ] ) ? ' frm_blank_field' : ''; |
|
| 441 | + $classes = isset( $errors['field' . $field_id] ) ? ' frm_blank_field' : ''; |
|
| 442 | 442 | |
| 443 | 443 | // Add label position class |
| 444 | 444 | $classes .= ' frm_' . $field['label'] . '_container'; |
| 445 | 445 | |
| 446 | 446 | // Add CSS layout classes |
| 447 | 447 | if ( ! empty( $field['classes'] ) ) { |
| 448 | - if ( ! strpos( $html, 'frm_form_field ') ) { |
|
| 448 | + if ( ! strpos( $html, 'frm_form_field ' ) ) { |
|
| 449 | 449 | $classes .= ' frm_form_field'; |
| 450 | 450 | } |
| 451 | 451 | $classes .= ' ' . $field['classes']; |
@@ -484,15 +484,15 @@ discard block |
||
| 484 | 484 | } |
| 485 | 485 | |
| 486 | 486 | $with_tags = $args['conditional_check'] ? 3 : 2; |
| 487 | - if ( ! empty( $shortcodes[ $with_tags ][ $short_key ] ) ) { |
|
| 488 | - $tag = str_replace( '[' . $prefix, '', $shortcodes[0][ $short_key ] ); |
|
| 489 | - $tag = str_replace(']', '', $tag); |
|
| 490 | - $tags = explode(' ', $tag); |
|
| 491 | - if ( is_array($tags) ) { |
|
| 487 | + if ( ! empty( $shortcodes[$with_tags][$short_key] ) ) { |
|
| 488 | + $tag = str_replace( '[' . $prefix, '', $shortcodes[0][$short_key] ); |
|
| 489 | + $tag = str_replace( ']', '', $tag ); |
|
| 490 | + $tags = explode( ' ', $tag ); |
|
| 491 | + if ( is_array( $tags ) ) { |
|
| 492 | 492 | $tag = $tags[0]; |
| 493 | 493 | } |
| 494 | 494 | } else { |
| 495 | - $tag = $shortcodes[ $with_tags - 1 ][ $short_key ]; |
|
| 495 | + $tag = $shortcodes[$with_tags - 1][$short_key]; |
|
| 496 | 496 | } |
| 497 | 497 | |
| 498 | 498 | return $tag; |
@@ -552,10 +552,10 @@ discard block |
||
| 552 | 552 | |
| 553 | 553 | public static function show_single_option( $field ) { |
| 554 | 554 | $field_name = $field['name']; |
| 555 | - $html_id = self::get_html_id($field); |
|
| 555 | + $html_id = self::get_html_id( $field ); |
|
| 556 | 556 | foreach ( $field['options'] as $opt_key => $opt ) { |
| 557 | - $field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field); |
|
| 558 | - $opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field); |
|
| 557 | + $field_val = apply_filters( 'frm_field_value_saved', $opt, $opt_key, $field ); |
|
| 558 | + $opt = apply_filters( 'frm_field_label_seen', $opt, $opt_key, $field ); |
|
| 559 | 559 | |
| 560 | 560 | // If this is an "Other" option, get the HTML for it |
| 561 | 561 | if ( self::is_other_opt( $opt_key ) ) { |
@@ -569,7 +569,7 @@ discard block |
||
| 569 | 569 | } |
| 570 | 570 | |
| 571 | 571 | public static function get_term_link( $tax_id ) { |
| 572 | - $tax = get_taxonomy($tax_id); |
|
| 572 | + $tax = get_taxonomy( $tax_id ); |
|
| 573 | 573 | if ( ! $tax ) { |
| 574 | 574 | return; |
| 575 | 575 | } |
@@ -578,7 +578,7 @@ discard block |
||
| 578 | 578 | __( 'Please add options from the WordPress "%1$s" page', 'formidable' ), |
| 579 | 579 | '<a href="' . esc_url( admin_url( 'edit-tags.php?taxonomy=' . $tax->name ) ) . '" target="_blank">' . ( empty( $tax->labels->name ) ? __( 'Categories' ) : $tax->labels->name ) . '</a>' |
| 580 | 580 | ); |
| 581 | - unset($tax); |
|
| 581 | + unset( $tax ); |
|
| 582 | 582 | |
| 583 | 583 | return $link; |
| 584 | 584 | } |
@@ -592,8 +592,8 @@ discard block |
||
| 592 | 592 | $observed_value = wp_kses_post( $observed_value ); |
| 593 | 593 | $hide_opt = wp_kses_post( $hide_opt ); |
| 594 | 594 | |
| 595 | - if ( is_array($observed_value) ) { |
|
| 596 | - return self::array_value_condition($observed_value, $cond, $hide_opt); |
|
| 595 | + if ( is_array( $observed_value ) ) { |
|
| 596 | + return self::array_value_condition( $observed_value, $cond, $hide_opt ); |
|
| 597 | 597 | } |
| 598 | 598 | |
| 599 | 599 | $m = false; |
@@ -606,7 +606,7 @@ discard block |
||
| 606 | 606 | } else if ( $cond == '<' ) { |
| 607 | 607 | $m = $observed_value < $hide_opt; |
| 608 | 608 | } else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) { |
| 609 | - $m = stripos($observed_value, $hide_opt); |
|
| 609 | + $m = stripos( $observed_value, $hide_opt ); |
|
| 610 | 610 | if ( $cond == 'not LIKE' ) { |
| 611 | 611 | $m = ( $m === false ) ? true : false; |
| 612 | 612 | } else { |
@@ -619,23 +619,23 @@ discard block |
||
| 619 | 619 | public static function array_value_condition( $observed_value, $cond, $hide_opt ) { |
| 620 | 620 | $m = false; |
| 621 | 621 | if ( $cond == '==' ) { |
| 622 | - if ( is_array($hide_opt) ) { |
|
| 623 | - $m = array_intersect($hide_opt, $observed_value); |
|
| 624 | - $m = empty($m) ? false : true; |
|
| 622 | + if ( is_array( $hide_opt ) ) { |
|
| 623 | + $m = array_intersect( $hide_opt, $observed_value ); |
|
| 624 | + $m = empty( $m ) ? false : true; |
|
| 625 | 625 | } else { |
| 626 | - $m = in_array($hide_opt, $observed_value); |
|
| 626 | + $m = in_array( $hide_opt, $observed_value ); |
|
| 627 | 627 | } |
| 628 | 628 | } else if ( $cond == '!=' ) { |
| 629 | - $m = ! in_array($hide_opt, $observed_value); |
|
| 629 | + $m = ! in_array( $hide_opt, $observed_value ); |
|
| 630 | 630 | } else if ( $cond == '>' ) { |
| 631 | - $min = min($observed_value); |
|
| 631 | + $min = min( $observed_value ); |
|
| 632 | 632 | $m = $min > $hide_opt; |
| 633 | 633 | } else if ( $cond == '<' ) { |
| 634 | - $max = max($observed_value); |
|
| 634 | + $max = max( $observed_value ); |
|
| 635 | 635 | $m = $max < $hide_opt; |
| 636 | 636 | } else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) { |
| 637 | 637 | foreach ( $observed_value as $ob ) { |
| 638 | - $m = strpos($ob, $hide_opt); |
|
| 638 | + $m = strpos( $ob, $hide_opt ); |
|
| 639 | 639 | if ( $m !== false ) { |
| 640 | 640 | $m = true; |
| 641 | 641 | break; |
@@ -656,27 +656,27 @@ discard block |
||
| 656 | 656 | * @return string |
| 657 | 657 | */ |
| 658 | 658 | public static function basic_replace_shortcodes( $value, $form, $entry ) { |
| 659 | - if ( strpos($value, '[sitename]') !== false ) { |
|
| 659 | + if ( strpos( $value, '[sitename]' ) !== false ) { |
|
| 660 | 660 | $new_value = wp_specialchars_decode( FrmAppHelper::site_name(), ENT_QUOTES ); |
| 661 | - $value = str_replace('[sitename]', $new_value, $value); |
|
| 661 | + $value = str_replace( '[sitename]', $new_value, $value ); |
|
| 662 | 662 | } |
| 663 | 663 | |
| 664 | - $value = apply_filters('frm_content', $value, $form, $entry); |
|
| 665 | - $value = do_shortcode($value); |
|
| 664 | + $value = apply_filters( 'frm_content', $value, $form, $entry ); |
|
| 665 | + $value = do_shortcode( $value ); |
|
| 666 | 666 | |
| 667 | 667 | return $value; |
| 668 | 668 | } |
| 669 | 669 | |
| 670 | 670 | public static function get_shortcodes( $content, $form_id ) { |
| 671 | 671 | if ( FrmAppHelper::pro_is_installed() ) { |
| 672 | - return FrmProDisplaysHelper::get_shortcodes($content, $form_id); |
|
| 672 | + return FrmProDisplaysHelper::get_shortcodes( $content, $form_id ); |
|
| 673 | 673 | } |
| 674 | 674 | |
| 675 | 675 | $fields = FrmField::getAll( array( 'fi.form_id' => (int) $form_id, 'fi.type not' => FrmField::no_save_fields() ) ); |
| 676 | 676 | |
| 677 | - $tagregexp = self::allowed_shortcodes($fields); |
|
| 677 | + $tagregexp = self::allowed_shortcodes( $fields ); |
|
| 678 | 678 | |
| 679 | - preg_match_all("/\[(if )?($tagregexp)\b(.*?)(?:(\/))?\](?:(.+?)\[\/\2\])?/s", $content, $matches, PREG_PATTERN_ORDER); |
|
| 679 | + preg_match_all( "/\[(if )?($tagregexp)\b(.*?)(?:(\/))?\](?:(.+?)\[\/\2\])?/s", $content, $matches, PREG_PATTERN_ORDER ); |
|
| 680 | 680 | |
| 681 | 681 | return $matches; |
| 682 | 682 | } |
@@ -694,7 +694,7 @@ discard block |
||
| 694 | 694 | $tagregexp[] = $field->field_key; |
| 695 | 695 | } |
| 696 | 696 | |
| 697 | - $tagregexp = implode('|', $tagregexp); |
|
| 697 | + $tagregexp = implode( '|', $tagregexp ); |
|
| 698 | 698 | return $tagregexp; |
| 699 | 699 | } |
| 700 | 700 | |
@@ -710,28 +710,28 @@ discard block |
||
| 710 | 710 | continue; |
| 711 | 711 | } |
| 712 | 712 | |
| 713 | - $atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[3][ $short_key ] ); |
|
| 713 | + $atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[3][$short_key] ); |
|
| 714 | 714 | |
| 715 | - if ( ! empty( $shortcodes[3][ $short_key ] ) ) { |
|
| 716 | - $tag = str_replace( array( '[', ']' ), '', $shortcodes[0][ $short_key ] ); |
|
| 717 | - $tags = explode(' ', $tag); |
|
| 718 | - if ( is_array($tags) ) { |
|
| 715 | + if ( ! empty( $shortcodes[3][$short_key] ) ) { |
|
| 716 | + $tag = str_replace( array( '[', ']' ), '', $shortcodes[0][$short_key] ); |
|
| 717 | + $tags = explode( ' ', $tag ); |
|
| 718 | + if ( is_array( $tags ) ) { |
|
| 719 | 719 | $tag = $tags[0]; |
| 720 | 720 | } |
| 721 | 721 | } else { |
| 722 | - $tag = $shortcodes[2][ $short_key ]; |
|
| 722 | + $tag = $shortcodes[2][$short_key]; |
|
| 723 | 723 | } |
| 724 | 724 | |
| 725 | 725 | switch ( $tag ) { |
| 726 | 726 | case 'id': |
| 727 | 727 | case 'key': |
| 728 | 728 | case 'ip': |
| 729 | - $replace_with = $shortcode_values[ $tag ]; |
|
| 729 | + $replace_with = $shortcode_values[$tag]; |
|
| 730 | 730 | break; |
| 731 | 731 | |
| 732 | 732 | case 'user_agent': |
| 733 | 733 | case 'user-agent': |
| 734 | - $entry->description = maybe_unserialize($entry->description); |
|
| 734 | + $entry->description = maybe_unserialize( $entry->description ); |
|
| 735 | 735 | $replace_with = FrmEntriesHelper::get_browser( $entry->description['browser'] ); |
| 736 | 736 | break; |
| 737 | 737 | |
@@ -739,25 +739,25 @@ discard block |
||
| 739 | 739 | case 'created-at': |
| 740 | 740 | case 'updated_at': |
| 741 | 741 | case 'updated-at': |
| 742 | - if ( isset($atts['format']) ) { |
|
| 742 | + if ( isset( $atts['format'] ) ) { |
|
| 743 | 743 | $time_format = ' '; |
| 744 | 744 | } else { |
| 745 | - $atts['format'] = get_option('date_format'); |
|
| 745 | + $atts['format'] = get_option( 'date_format' ); |
|
| 746 | 746 | $time_format = ''; |
| 747 | 747 | } |
| 748 | 748 | |
| 749 | - $this_tag = str_replace('-', '_', $tag); |
|
| 750 | - $replace_with = FrmAppHelper::get_formatted_time($entry->{$this_tag}, $atts['format'], $time_format); |
|
| 751 | - unset($this_tag); |
|
| 749 | + $this_tag = str_replace( '-', '_', $tag ); |
|
| 750 | + $replace_with = FrmAppHelper::get_formatted_time( $entry->{$this_tag}, $atts['format'], $time_format ); |
|
| 751 | + unset( $this_tag ); |
|
| 752 | 752 | break; |
| 753 | 753 | |
| 754 | 754 | case 'created_by': |
| 755 | 755 | case 'created-by': |
| 756 | 756 | case 'updated_by': |
| 757 | 757 | case 'updated-by': |
| 758 | - $this_tag = str_replace('-', '_', $tag); |
|
| 758 | + $this_tag = str_replace( '-', '_', $tag ); |
|
| 759 | 759 | $replace_with = self::get_display_value( $entry->{$this_tag}, (object) array( 'type' => 'user_id' ), $atts ); |
| 760 | - unset($this_tag); |
|
| 760 | + unset( $this_tag ); |
|
| 761 | 761 | break; |
| 762 | 762 | |
| 763 | 763 | case 'admin_email': |
@@ -774,16 +774,16 @@ discard block |
||
| 774 | 774 | break; |
| 775 | 775 | } |
| 776 | 776 | |
| 777 | - $sep = isset($atts['sep']) ? $atts['sep'] : ', '; |
|
| 777 | + $sep = isset( $atts['sep'] ) ? $atts['sep'] : ', '; |
|
| 778 | 778 | |
| 779 | 779 | $replace_with = FrmEntryMeta::get_meta_value( $entry, $field->id ); |
| 780 | 780 | |
| 781 | 781 | $atts['entry_id'] = $entry->id; |
| 782 | 782 | $atts['entry_key'] = $entry->item_key; |
| 783 | 783 | |
| 784 | - if ( isset($atts['show']) && $atts['show'] == 'field_label' ) { |
|
| 784 | + if ( isset( $atts['show'] ) && $atts['show'] == 'field_label' ) { |
|
| 785 | 785 | $replace_with = $field->name; |
| 786 | - } else if ( isset($atts['show']) && $atts['show'] == 'description' ) { |
|
| 786 | + } else if ( isset( $atts['show'] ) && $atts['show'] == 'description' ) { |
|
| 787 | 787 | $replace_with = $field->description; |
| 788 | 788 | } else { |
| 789 | 789 | $string_value = $replace_with; |
@@ -798,15 +798,15 @@ discard block |
||
| 798 | 798 | } |
| 799 | 799 | } |
| 800 | 800 | |
| 801 | - unset($field); |
|
| 801 | + unset( $field ); |
|
| 802 | 802 | break; |
| 803 | 803 | } |
| 804 | 804 | |
| 805 | - if ( isset($replace_with) ) { |
|
| 806 | - $content = str_replace( $shortcodes[0][ $short_key ], $replace_with, $content ); |
|
| 805 | + if ( isset( $replace_with ) ) { |
|
| 806 | + $content = str_replace( $shortcodes[0][$short_key], $replace_with, $content ); |
|
| 807 | 807 | } |
| 808 | 808 | |
| 809 | - unset($atts, $conditional, $replace_with); |
|
| 809 | + unset( $atts, $conditional, $replace_with ); |
|
| 810 | 810 | } |
| 811 | 811 | |
| 812 | 812 | return $content; |
@@ -822,7 +822,7 @@ discard block |
||
| 822 | 822 | $new_value = ''; |
| 823 | 823 | switch ( $tag ) { |
| 824 | 824 | case 'admin_email': |
| 825 | - $new_value = get_option('admin_email'); |
|
| 825 | + $new_value = get_option( 'admin_email' ); |
|
| 826 | 826 | break; |
| 827 | 827 | case 'siteurl': |
| 828 | 828 | $new_value = FrmAppHelper::site_url(); |
@@ -848,28 +848,28 @@ discard block |
||
| 848 | 848 | * @return string|array |
| 849 | 849 | */ |
| 850 | 850 | public static function process_get_shortcode( $atts, $return_array = false ) { |
| 851 | - if ( ! isset($atts['param']) ) { |
|
| 851 | + if ( ! isset( $atts['param'] ) ) { |
|
| 852 | 852 | return ''; |
| 853 | 853 | } |
| 854 | 854 | |
| 855 | - if ( strpos($atts['param'], '[') ) { |
|
| 856 | - $atts['param'] = str_replace('[', '[', $atts['param']); |
|
| 857 | - $atts['param'] = str_replace(']', ']', $atts['param']); |
|
| 855 | + if ( strpos( $atts['param'], '[' ) ) { |
|
| 856 | + $atts['param'] = str_replace( '[', '[', $atts['param'] ); |
|
| 857 | + $atts['param'] = str_replace( ']', ']', $atts['param'] ); |
|
| 858 | 858 | } |
| 859 | 859 | |
| 860 | - $new_value = FrmAppHelper::get_param($atts['param'], ''); |
|
| 860 | + $new_value = FrmAppHelper::get_param( $atts['param'], '' ); |
|
| 861 | 861 | $new_value = FrmAppHelper::get_query_var( $new_value, $atts['param'] ); |
| 862 | 862 | |
| 863 | 863 | if ( $new_value == '' ) { |
| 864 | - if ( ! isset($atts['prev_val']) ) { |
|
| 864 | + if ( ! isset( $atts['prev_val'] ) ) { |
|
| 865 | 865 | $atts['prev_val'] = ''; |
| 866 | 866 | } |
| 867 | 867 | |
| 868 | - $new_value = isset($atts['default']) ? $atts['default'] : $atts['prev_val']; |
|
| 868 | + $new_value = isset( $atts['default'] ) ? $atts['default'] : $atts['prev_val']; |
|
| 869 | 869 | } |
| 870 | 870 | |
| 871 | - if ( is_array($new_value) && ! $return_array ) { |
|
| 872 | - $new_value = implode(', ', $new_value); |
|
| 871 | + if ( is_array( $new_value ) && ! $return_array ) { |
|
| 872 | + $new_value = implode( ', ', $new_value ); |
|
| 873 | 873 | } |
| 874 | 874 | |
| 875 | 875 | return $new_value; |
@@ -882,17 +882,17 @@ discard block |
||
| 882 | 882 | $replace_with = apply_filters( 'frm_get_display_value', $replace_with, $field, $atts ); |
| 883 | 883 | |
| 884 | 884 | if ( $field->type == 'textarea' || $field->type == 'rte' ) { |
| 885 | - $autop = isset($atts['wpautop']) ? $atts['wpautop'] : true; |
|
| 886 | - if ( apply_filters('frm_use_wpautop', $autop) ) { |
|
| 887 | - if ( is_array($replace_with) ) { |
|
| 888 | - $replace_with = implode("\n", $replace_with); |
|
| 885 | + $autop = isset( $atts['wpautop'] ) ? $atts['wpautop'] : true; |
|
| 886 | + if ( apply_filters( 'frm_use_wpautop', $autop ) ) { |
|
| 887 | + if ( is_array( $replace_with ) ) { |
|
| 888 | + $replace_with = implode( "\n", $replace_with ); |
|
| 889 | 889 | } |
| 890 | - $replace_with = wpautop($replace_with); |
|
| 890 | + $replace_with = wpautop( $replace_with ); |
|
| 891 | 891 | } |
| 892 | 892 | unset( $autop ); |
| 893 | 893 | } else if ( is_array( $replace_with ) ) { |
| 894 | - if ( isset( $atts['show'] ) && $atts['show'] && isset( $replace_with[ $atts['show'] ] ) ) { |
|
| 895 | - $replace_with = $replace_with[ $atts['show'] ]; |
|
| 894 | + if ( isset( $atts['show'] ) && $atts['show'] && isset( $replace_with[$atts['show']] ) ) { |
|
| 895 | + $replace_with = $replace_with[$atts['show']]; |
|
| 896 | 896 | } else { |
| 897 | 897 | $replace_with = implode( $sep, $replace_with ); |
| 898 | 898 | } |
@@ -913,14 +913,14 @@ discard block |
||
| 913 | 913 | $field_selection = array_merge( FrmField::pro_field_selection(), FrmField::field_selection() ); |
| 914 | 914 | |
| 915 | 915 | $field_types = array(); |
| 916 | - if ( in_array($type, $single_input) ) { |
|
| 916 | + if ( in_array( $type, $single_input ) ) { |
|
| 917 | 917 | self::field_types_for_input( $single_input, $field_selection, $field_types ); |
| 918 | - } else if ( in_array($type, $multiple_input) ) { |
|
| 918 | + } else if ( in_array( $type, $multiple_input ) ) { |
|
| 919 | 919 | self::field_types_for_input( $multiple_input, $field_selection, $field_types ); |
| 920 | - } else if ( in_array($type, $other_type) ) { |
|
| 920 | + } else if ( in_array( $type, $other_type ) ) { |
|
| 921 | 921 | self::field_types_for_input( $other_type, $field_selection, $field_types ); |
| 922 | - } else if ( isset( $field_selection[ $type ] ) ) { |
|
| 923 | - $field_types[ $type ] = $field_selection[ $type ]; |
|
| 922 | + } else if ( isset( $field_selection[$type] ) ) { |
|
| 923 | + $field_types[$type] = $field_selection[$type]; |
|
| 924 | 924 | } |
| 925 | 925 | |
| 926 | 926 | $field_types = apply_filters( 'frm_switch_field_types', $field_types, compact( 'type' ) ); |
@@ -929,8 +929,8 @@ discard block |
||
| 929 | 929 | |
| 930 | 930 | private static function field_types_for_input( $inputs, $fields, &$field_types ) { |
| 931 | 931 | foreach ( $inputs as $input ) { |
| 932 | - $field_types[ $input ] = $fields[ $input ]; |
|
| 933 | - unset($input); |
|
| 932 | + $field_types[$input] = $fields[$input]; |
|
| 933 | + unset( $input ); |
|
| 934 | 934 | } |
| 935 | 935 | } |
| 936 | 936 | |
@@ -975,21 +975,21 @@ discard block |
||
| 975 | 975 | // Check posted vals before checking saved values |
| 976 | 976 | |
| 977 | 977 | // For fields inside repeating sections - note, don't check if $pointer is true because it will often be zero |
| 978 | - if ( $parent && isset( $_POST['item_meta'][ $parent ][ $pointer ]['other'][ $field['id'] ] ) ) { |
|
| 978 | + if ( $parent && isset( $_POST['item_meta'][$parent][$pointer]['other'][$field['id']] ) ) { |
|
| 979 | 979 | if ( FrmField::is_field_with_multiple_values( $field ) ) { |
| 980 | - $other_val = isset( $_POST['item_meta'][ $parent ][ $pointer ]['other'][ $field['id'] ][ $opt_key ] ) ? sanitize_text_field( $_POST['item_meta'][ $parent ][ $pointer ]['other'][ $field['id'] ][ $opt_key ] ) : ''; |
|
| 980 | + $other_val = isset( $_POST['item_meta'][$parent][$pointer]['other'][$field['id']][$opt_key] ) ? sanitize_text_field( $_POST['item_meta'][$parent][$pointer]['other'][$field['id']][$opt_key] ) : ''; |
|
| 981 | 981 | } else { |
| 982 | - $other_val = sanitize_text_field( $_POST['item_meta'][ $parent ][ $pointer ]['other'][ $field['id'] ] ); |
|
| 982 | + $other_val = sanitize_text_field( $_POST['item_meta'][$parent][$pointer]['other'][$field['id']] ); |
|
| 983 | 983 | } |
| 984 | 984 | return $other_val; |
| 985 | 985 | |
| 986 | - } else if ( isset( $field['id'] ) && isset( $_POST['item_meta']['other'][ $field['id'] ] ) ) { |
|
| 986 | + } else if ( isset( $field['id'] ) && isset( $_POST['item_meta']['other'][$field['id']] ) ) { |
|
| 987 | 987 | // For normal fields |
| 988 | 988 | |
| 989 | 989 | if ( FrmField::is_field_with_multiple_values( $field ) ) { |
| 990 | - $other_val = isset( $_POST['item_meta']['other'][ $field['id'] ][ $opt_key ] ) ? sanitize_text_field( $_POST['item_meta']['other'][ $field['id'] ][ $opt_key ] ) : ''; |
|
| 990 | + $other_val = isset( $_POST['item_meta']['other'][$field['id']][$opt_key] ) ? sanitize_text_field( $_POST['item_meta']['other'][$field['id']][$opt_key] ) : ''; |
|
| 991 | 991 | } else { |
| 992 | - $other_val = sanitize_text_field( $_POST['item_meta']['other'][ $field['id'] ] ); |
|
| 992 | + $other_val = sanitize_text_field( $_POST['item_meta']['other'][$field['id']] ); |
|
| 993 | 993 | } |
| 994 | 994 | return $other_val; |
| 995 | 995 | } |
@@ -998,8 +998,8 @@ discard block |
||
| 998 | 998 | if ( $field['type'] == 'checkbox' && is_array( $field['value'] ) ) { |
| 999 | 999 | // Check if there is an "other" val in saved value and make sure the |
| 1000 | 1000 | // "other" val is not equal to the Other checkbox option |
| 1001 | - if ( isset( $field['value'][ $opt_key ] ) && $field['options'][ $opt_key ] != $field['value'][ $opt_key ] ) { |
|
| 1002 | - $other_val = $field['value'][ $opt_key ]; |
|
| 1001 | + if ( isset( $field['value'][$opt_key] ) && $field['options'][$opt_key] != $field['value'][$opt_key] ) { |
|
| 1002 | + $other_val = $field['value'][$opt_key]; |
|
| 1003 | 1003 | } |
| 1004 | 1004 | } else { |
| 1005 | 1005 | /** |
@@ -1011,8 +1011,8 @@ discard block |
||
| 1011 | 1011 | // Multi-select dropdowns - key is not preserved |
| 1012 | 1012 | if ( is_array( $field['value'] ) ) { |
| 1013 | 1013 | $o_key = array_search( $temp_val, $field['value'] ); |
| 1014 | - if ( isset( $field['value'][ $o_key ] ) ) { |
|
| 1015 | - unset( $field['value'][ $o_key ], $o_key ); |
|
| 1014 | + if ( isset( $field['value'][$o_key] ) ) { |
|
| 1015 | + unset( $field['value'][$o_key], $o_key ); |
|
| 1016 | 1016 | } |
| 1017 | 1017 | } else if ( $temp_val == $field['value'] ) { |
| 1018 | 1018 | // For radio and regular dropdowns |
@@ -1069,7 +1069,7 @@ discard block |
||
| 1069 | 1069 | private static function set_other_name( $args, &$other_args ) { |
| 1070 | 1070 | //Set up name for other field |
| 1071 | 1071 | $other_args['name'] = str_replace( '[]', '', $args['field_name'] ); |
| 1072 | - $other_args['name'] = preg_replace('/\[' . $args['field']['id'] . '\]$/', '', $other_args['name']); |
|
| 1072 | + $other_args['name'] = preg_replace( '/\[' . $args['field']['id'] . '\]$/', '', $other_args['name'] ); |
|
| 1073 | 1073 | $other_args['name'] = $other_args['name'] . '[other]' . '[' . $args['field']['id'] . ']'; |
| 1074 | 1074 | |
| 1075 | 1075 | //Converts item_meta[field_id] => item_meta[other][field_id] and |
@@ -1096,7 +1096,7 @@ discard block |
||
| 1096 | 1096 | // Count should only be greater than 3 if inside of a repeating section |
| 1097 | 1097 | if ( count( $temp_array ) > 3 ) { |
| 1098 | 1098 | $parent = str_replace( ']', '', $temp_array[1] ); |
| 1099 | - $pointer = str_replace( ']', '', $temp_array[2]); |
|
| 1099 | + $pointer = str_replace( ']', '', $temp_array[2] ); |
|
| 1100 | 1100 | } |
| 1101 | 1101 | |
| 1102 | 1102 | // Get text for "other" text field |
@@ -1215,15 +1215,15 @@ discard block |
||
| 1215 | 1215 | $replace_with[] = '[' . $new . ']'; |
| 1216 | 1216 | $replace[] = '[' . $old . ' '; |
| 1217 | 1217 | $replace_with[] = '[' . $new . ' '; |
| 1218 | - unset($old, $new); |
|
| 1218 | + unset( $old, $new ); |
|
| 1219 | 1219 | } |
| 1220 | 1220 | if ( is_array( $val ) ) { |
| 1221 | 1221 | foreach ( $val as $k => $v ) { |
| 1222 | - $val[ $k ] = str_replace( $replace, $replace_with, $v ); |
|
| 1223 | - unset($k, $v); |
|
| 1222 | + $val[$k] = str_replace( $replace, $replace_with, $v ); |
|
| 1223 | + unset( $k, $v ); |
|
| 1224 | 1224 | } |
| 1225 | 1225 | } else { |
| 1226 | - $val = str_replace($replace, $replace_with, $val); |
|
| 1226 | + $val = str_replace( $replace, $replace_with, $val ); |
|
| 1227 | 1227 | } |
| 1228 | 1228 | |
| 1229 | 1229 | return $val; |
@@ -1236,7 +1236,7 @@ discard block |
||
| 1236 | 1236 | 'DC' => 'District of Columbia', |
| 1237 | 1237 | 'FL' => 'Florida', 'GA' => 'Georgia', 'HI' => 'Hawaii', 'ID' => 'Idaho', |
| 1238 | 1238 | 'IL' => 'Illinois', 'IN' => 'Indiana', 'IA' => 'Iowa', 'KS' => 'Kansas', |
| 1239 | - 'KY' => 'Kentucky', 'LA' => 'Louisiana', 'ME' => 'Maine','MD' => 'Maryland', |
|
| 1239 | + 'KY' => 'Kentucky', 'LA' => 'Louisiana', 'ME' => 'Maine', 'MD' => 'Maryland', |
|
| 1240 | 1240 | 'MA' => 'Massachusetts', 'MI' => 'Michigan', 'MN' => 'Minnesota', 'MS' => 'Mississippi', |
| 1241 | 1241 | 'MO' => 'Missouri', 'MT' => 'Montana', 'NE' => 'Nebraska', 'NV' => 'Nevada', |
| 1242 | 1242 | 'NH' => 'New Hampshire', 'NJ' => 'New Jersey', 'NM' => 'New Mexico', 'NY' => 'New York', |
@@ -1327,35 +1327,35 @@ discard block |
||
| 1327 | 1327 | } |
| 1328 | 1328 | |
| 1329 | 1329 | public static function get_bulk_prefilled_opts( array &$prepop ) { |
| 1330 | - $prepop[ __( 'Countries', 'formidable' ) ] = FrmFieldsHelper::get_countries(); |
|
| 1330 | + $prepop[__( 'Countries', 'formidable' )] = FrmFieldsHelper::get_countries(); |
|
| 1331 | 1331 | |
| 1332 | 1332 | $states = FrmFieldsHelper::get_us_states(); |
| 1333 | - $state_abv = array_keys($states); |
|
| 1334 | - sort($state_abv); |
|
| 1335 | - $prepop[ __( 'U.S. State Abbreviations', 'formidable' ) ] = $state_abv; |
|
| 1333 | + $state_abv = array_keys( $states ); |
|
| 1334 | + sort( $state_abv ); |
|
| 1335 | + $prepop[__( 'U.S. State Abbreviations', 'formidable' )] = $state_abv; |
|
| 1336 | 1336 | |
| 1337 | - $states = array_values($states); |
|
| 1338 | - sort($states); |
|
| 1339 | - $prepop[ __( 'U.S. States', 'formidable' ) ] = $states; |
|
| 1340 | - unset($state_abv, $states); |
|
| 1337 | + $states = array_values( $states ); |
|
| 1338 | + sort( $states ); |
|
| 1339 | + $prepop[__( 'U.S. States', 'formidable' )] = $states; |
|
| 1340 | + unset( $state_abv, $states ); |
|
| 1341 | 1341 | |
| 1342 | - $prepop[ __( 'Age', 'formidable' ) ] = array( |
|
| 1342 | + $prepop[__( 'Age', 'formidable' )] = array( |
|
| 1343 | 1343 | __( 'Under 18', 'formidable' ), __( '18-24', 'formidable' ), __( '25-34', 'formidable' ), |
| 1344 | 1344 | __( '35-44', 'formidable' ), __( '45-54', 'formidable' ), __( '55-64', 'formidable' ), |
| 1345 | 1345 | __( '65 or Above', 'formidable' ), __( 'Prefer Not to Answer', 'formidable' ), |
| 1346 | 1346 | ); |
| 1347 | 1347 | |
| 1348 | - $prepop[ __( 'Satisfaction', 'formidable' ) ] = array( |
|
| 1348 | + $prepop[__( 'Satisfaction', 'formidable' )] = array( |
|
| 1349 | 1349 | __( 'Very Satisfied', 'formidable' ), __( 'Satisfied', 'formidable' ), __( 'Neutral', 'formidable' ), |
| 1350 | 1350 | __( 'Unsatisfied', 'formidable' ), __( 'Very Unsatisfied', 'formidable' ), __( 'N/A', 'formidable' ), |
| 1351 | 1351 | ); |
| 1352 | 1352 | |
| 1353 | - $prepop[ __( 'Importance', 'formidable' ) ] = array( |
|
| 1353 | + $prepop[__( 'Importance', 'formidable' )] = array( |
|
| 1354 | 1354 | __( 'Very Important', 'formidable' ), __( 'Important', 'formidable' ), __( 'Neutral', 'formidable' ), |
| 1355 | 1355 | __( 'Somewhat Important', 'formidable' ), __( 'Not at all Important', 'formidable' ), __( 'N/A', 'formidable' ), |
| 1356 | 1356 | ); |
| 1357 | 1357 | |
| 1358 | - $prepop[ __( 'Agreement', 'formidable' ) ] = array( |
|
| 1358 | + $prepop[__( 'Agreement', 'formidable' )] = array( |
|
| 1359 | 1359 | __( 'Strongly Agree', 'formidable' ), __( 'Agree', 'formidable' ), __( 'Neutral', 'formidable' ), |
| 1360 | 1360 | __( 'Disagree', 'formidable' ), __( 'Strongly Disagree', 'formidable' ), __( 'N/A', 'formidable' ), |
| 1361 | 1361 | ); |
@@ -1,22 +1,22 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -$display = apply_filters('frm_display_field_options', array( |
|
| 3 | +$display = apply_filters( 'frm_display_field_options', array( |
|
| 4 | 4 | 'type' => $field['type'], 'field_data' => $field, |
| 5 | 5 | 'required' => true, 'unique' => false, 'read_only' => false, |
| 6 | 6 | 'description' => true, 'options' => true, 'label_position' => true, |
| 7 | 7 | 'invalid' => false, 'size' => false, 'clear_on_focus' => false, |
| 8 | 8 | 'default_blank' => true, 'css' => true, 'conf_field' => false, |
| 9 | 9 | 'max' => true, 'captcha_size' => false, |
| 10 | -)); |
|
| 10 | +) ); |
|
| 11 | 11 | |
| 12 | 12 | $li_classes = 'form-field edit_form_item frm_field_box frm_top_container frm_not_divider edit_field_type_' . $display['type']; |
| 13 | -$li_classes = apply_filters('frm_build_field_class', $li_classes, $field ); |
|
| 13 | +$li_classes = apply_filters( 'frm_build_field_class', $li_classes, $field ); |
|
| 14 | 14 | |
| 15 | 15 | if ( isset( $values ) && isset( $values['ajax_load'] ) && $values['ajax_load'] && isset( $count ) && $count > 10 && ! in_array( $field['type'], array( 'divider', 'end_divider' ) ) ) { |
| 16 | 16 | ?> |
| 17 | 17 | <li id="frm_field_id_<?php echo esc_attr( $field['id'] ); ?>" class="<?php echo esc_attr( $li_classes ) ?> frm_field_loading" data-fid="<?php echo esc_attr( $field['id'] ) ?>" data-formid="<?php echo esc_attr( 'divider' == $field['type'] ? $field['form_select'] : $field['form_id'] ); ?>" data-ftype="<?php echo esc_attr( $display['type'] ) ?>"> |
| 18 | 18 | <img src="<?php echo FrmAppHelper::plugin_url() ?>/images/ajax_loader.gif" alt="<?php esc_attr_e( 'Loading', 'formidable' ) ?>" /> |
| 19 | -<span class="frm_hidden_fdata frm_hidden"><?php echo htmlspecialchars(json_encode($field)) ?></span> |
|
| 19 | +<span class="frm_hidden_fdata frm_hidden"><?php echo htmlspecialchars( json_encode( $field ) ) ?></span> |
|
| 20 | 20 | </li> |
| 21 | 21 | <?php |
| 22 | 22 | return; |
@@ -25,8 +25,8 @@ discard block |
||
| 25 | 25 | $frm_settings = FrmAppHelper::get_settings(); |
| 26 | 26 | |
| 27 | 27 | if ( ! isset( $frm_all_field_selection ) ) { |
| 28 | - if ( isset($frm_field_selection) && isset($pro_field_selection) ) { |
|
| 29 | - $frm_all_field_selection = array_merge($frm_field_selection, $pro_field_selection); |
|
| 28 | + if ( isset( $frm_field_selection ) && isset( $pro_field_selection ) ) { |
|
| 29 | + $frm_all_field_selection = array_merge( $frm_field_selection, $pro_field_selection ); |
|
| 30 | 30 | } else { |
| 31 | 31 | $pro_field_selection = FrmField::pro_field_selection(); |
| 32 | 32 | $frm_all_field_selection = array_merge( FrmField::field_selection(), $pro_field_selection ); |
@@ -51,8 +51,8 @@ discard block |
||
| 51 | 51 | <a href="javascript:void(0);" class="frm_bstooltip alignright frm-show-hover frm-move frm-hover-icon frm_icon_font frm_move_icon" title="<?php esc_attr_e( 'Move Field', 'formidable' ) ?>"> </a> |
| 52 | 52 | <a href="#" class="frm_bstooltip alignright frm-show-hover frm-hover-icon frm_icon_font frm_delete_icon frm_delete_field" title="<?php esc_attr_e( 'Delete Field', 'formidable' ) ?>"> </a> |
| 53 | 53 | <a href="#" class="frm_bstooltip alignright frm-show-hover frm-hover-icon frm_icon_font frm_duplicate_icon" title="<?php ( $field['type'] == 'divider' ) ? esc_attr_e( 'Duplicate Section', 'formidable' ) : esc_attr_e( 'Duplicate Field', 'formidable' ) ?>"> </a> |
| 54 | - <input type="hidden" name="frm_fields_submitted[]" value="<?php echo esc_attr($field['id']) ?>" /> |
|
| 55 | - <?php do_action('frm_extra_field_actions', $field['id']); ?> |
|
| 54 | + <input type="hidden" name="frm_fields_submitted[]" value="<?php echo esc_attr( $field['id'] ) ?>" /> |
|
| 55 | + <?php do_action( 'frm_extra_field_actions', $field['id'] ); ?> |
|
| 56 | 56 | <?php if ( $display['required'] ) { ?> |
| 57 | 57 | <span id="require_field_<?php echo esc_attr( $field['id'] ); ?>"> |
| 58 | 58 | <a href="javascript:void(0);" class="frm_req_field frm_action_icon frm_required_icon frm_icon_font alignleft frm_required<?php echo (int) $field['required'] ?>" id="req_field_<?php echo esc_attr( $field['id'] ); ?>" title="Click to Mark as <?php echo FrmField::is_required( $field ) ? 'not ' : ''; ?>Required"></a> |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | <?php } |
| 61 | 61 | |
| 62 | 62 | ?> |
| 63 | - <label class="<?php echo ( $field['type'] == 'end_divider' ) ? '' : 'frm_ipe_field_label'; ?> frm_primary_label <?php echo ( $field['type'] == 'break' ) ? 'button': ''; ?>" id="field_label_<?php echo esc_attr( $field['id'] ); ?>"><?php echo ( $field['name'] == '' ) ? __( '(no label)', 'formidable' ) : force_balance_tags( $field['name'] ); ?></label> |
|
| 63 | + <label class="<?php echo ( $field['type'] == 'end_divider' ) ? '' : 'frm_ipe_field_label'; ?> frm_primary_label <?php echo ( $field['type'] == 'break' ) ? 'button' : ''; ?>" id="field_label_<?php echo esc_attr( $field['id'] ); ?>"><?php echo ( $field['name'] == '' ) ? __( '(no label)', 'formidable' ) : force_balance_tags( $field['name'] ); ?></label> |
|
| 64 | 64 | |
| 65 | 65 | |
| 66 | 66 | <div id="field_<?php echo esc_attr( $field['id'] ) ?>_inner_container" class="frm_inner_field_container"> |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | </div> |
| 79 | 79 | <?php |
| 80 | 80 | if ( $display['description'] ) { ?> |
| 81 | - <div class="frm_ipe_field_desc description <?php echo ($field['description'] == '') ? 'frm-show-click' : '' ?>" id="field_description_<?php echo esc_attr( $field['id'] ); ?>"><?php echo ($field['description'] == '') ? __( '(Click to add description)', 'formidable' ) : force_balance_tags( $field['description'] ); ?></div> |
|
| 81 | + <div class="frm_ipe_field_desc description <?php echo ( $field['description'] == '' ) ? 'frm-show-click' : '' ?>" id="field_description_<?php echo esc_attr( $field['id'] ); ?>"><?php echo ( $field['description'] == '' ) ? __( '(Click to add description)', 'formidable' ) : force_balance_tags( $field['description'] ); ?></div> |
|
| 82 | 82 | <input type="hidden" name="field_options[description_<?php echo esc_attr( $field['id'] ) ?>]" value="<?php echo esc_attr( $field['description'] ); ?>" /> |
| 83 | 83 | |
| 84 | 84 | <?php } ?> |
@@ -90,8 +90,8 @@ discard block |
||
| 90 | 90 | <div class="frm_form_fields"> |
| 91 | 91 | <input type="text" id="conf_field_<?php echo esc_attr( $field['field_key'] ) ?>" name="field_options[conf_input_<?php echo esc_attr( $field['id'] ) ?>]" value="<?php echo esc_attr( $field['conf_input'] ); ?>" class="dyn_default_value" /> |
| 92 | 92 | </div> |
| 93 | - <div id="conf_field_description_<?php echo esc_attr( $field['id'] ) ?>" class="frm_ipe_field_conf_desc description <?php echo ($field['conf_desc'] == '') ? 'frm-show-click' : '' ?>"><?php |
|
| 94 | - echo ($field['conf_desc'] == '') ? __( '(Click to add description)', 'formidable' ) : force_balance_tags($field['conf_desc']); ?></div> |
|
| 93 | + <div id="conf_field_description_<?php echo esc_attr( $field['id'] ) ?>" class="frm_ipe_field_conf_desc description <?php echo ( $field['conf_desc'] == '' ) ? 'frm-show-click' : '' ?>"><?php |
|
| 94 | + echo ( $field['conf_desc'] == '' ) ? __( '(Click to add description)', 'formidable' ) : force_balance_tags( $field['conf_desc'] ); ?></div> |
|
| 95 | 95 | <input type="hidden" name="field_options[conf_desc_<?php echo esc_attr( $field['id'] ) ?>]" value="<?php echo esc_attr( $field['conf_desc'] ); ?>" /> |
| 96 | 96 | </div> |
| 97 | 97 | <?php if ( $display['clear_on_focus'] ) { ?> |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | if ( in_array( $field['type'], array( 'select', 'radio', 'checkbox' ) ) ) { ?> |
| 107 | 107 | <div class="frm-show-click frm_small_top_margin"><?php |
| 108 | 108 | |
| 109 | - if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) { |
|
| 109 | + if ( isset( $field['post_field'] ) && $field['post_field'] == 'post_category' ) { |
|
| 110 | 110 | echo '<p class="howto">' . FrmFieldsHelper::get_term_link( $field['taxonomy'] ) . '</p>'; |
| 111 | 111 | } else if ( ! isset( $field['post_field'] ) || ! in_array( $field['post_field'], array( 'post_category' ) ) ) { |
| 112 | 112 | ?> |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | <?php |
| 121 | 121 | } |
| 122 | 122 | |
| 123 | - if ( ! isset($field['post_field']) || $field['post_field'] != 'post_category' ) { ?> |
|
| 123 | + if ( ! isset( $field['post_field'] ) || $field['post_field'] != 'post_category' ) { ?> |
|
| 124 | 124 | <a href="<?php echo esc_url( admin_url( 'admin-ajax.php?action=frm_import_choices&field_id=' . $field['id'] . '&TB_iframe=1' ) ) ?>" title="<?php echo esc_attr( FrmAppHelper::truncate( strip_tags( str_replace( '"', '"', $field['name'] ) ), 20 ) . ' ' . __( 'Field Choices', 'formidable' ) ); ?>" class="thickbox frm_orange"> |
| 125 | 125 | <?php _e( 'Bulk Edit Options', 'formidable' ) ?> |
| 126 | 126 | </a> |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | <?php |
| 134 | 134 | } |
| 135 | 135 | |
| 136 | -do_action('frm_before_field_options', $field); |
|
| 136 | +do_action( 'frm_before_field_options', $field ); |
|
| 137 | 137 | |
| 138 | 138 | if ( $display['options'] ) { ?> |
| 139 | 139 | <div class="widget"> |
@@ -143,13 +143,13 @@ discard block |
||
| 143 | 143 | </div> |
| 144 | 144 | <div class="widget-inside"> |
| 145 | 145 | <table class="form-table frm_clear_none"> |
| 146 | - <?php $field_types = FrmFieldsHelper::get_field_types($field['type']); ?> |
|
| 146 | + <?php $field_types = FrmFieldsHelper::get_field_types( $field['type'] ); ?> |
|
| 147 | 147 | <tr><td class="frm_150_width"><label><?php _e( 'Field Type', 'formidable' ) ?></label></td> |
| 148 | 148 | <td> |
| 149 | - <select <?php if ( count($field_types) == 1 ) { ?>disabled="disabled"<?php } else { ?>name="field_options[type_<?php echo esc_attr( $field['id'] ) ?>]"<?php } ?>> |
|
| 149 | + <select <?php if ( count( $field_types ) == 1 ) { ?>disabled="disabled"<?php } else { ?>name="field_options[type_<?php echo esc_attr( $field['id'] ) ?>]"<?php } ?>> |
|
| 150 | 150 | <?php |
| 151 | 151 | foreach ( $field_types as $fkey => $ftype ) { ?> |
| 152 | - <option value="<?php echo esc_attr( $fkey ) ?>" <?php echo ( $fkey == $field['type'] ) ? ' selected="selected"' : ''; ?> <?php echo array_key_exists($fkey, $disabled_fields ) ? 'disabled="disabled"' : ''; ?>><?php echo is_array($ftype) ? $ftype['name'] : $ftype ?> </option> |
|
| 152 | + <option value="<?php echo esc_attr( $fkey ) ?>" <?php echo ( $fkey == $field['type'] ) ? ' selected="selected"' : ''; ?> <?php echo array_key_exists( $fkey, $disabled_fields ) ? 'disabled="disabled"' : ''; ?>><?php echo is_array( $ftype ) ? $ftype['name'] : $ftype ?> </option> |
|
| 153 | 153 | <?php |
| 154 | 154 | unset( $fkey, $ftype ); |
| 155 | 155 | } ?> |
@@ -184,7 +184,7 @@ discard block |
||
| 184 | 184 | </label> |
| 185 | 185 | <?php } |
| 186 | 186 | |
| 187 | - do_action('frm_field_options_form_top', $field, $display, $values); |
|
| 187 | + do_action( 'frm_field_options_form_top', $field, $display, $values ); |
|
| 188 | 188 | |
| 189 | 189 | ?> |
| 190 | 190 | <?php |
@@ -223,7 +223,7 @@ discard block |
||
| 223 | 223 | <td class="frm_150_width"><label><?php _e( 'Label Position', 'formidable' ) ?></label></td> |
| 224 | 224 | <td> |
| 225 | 225 | <select name="field_options[label_<?php echo esc_attr( $field['id'] ) ?>]"> |
| 226 | - <option value=""<?php selected($field['label'], ''); ?>> |
|
| 226 | + <option value=""<?php selected( $field['label'], '' ); ?>> |
|
| 227 | 227 | <?php _e( 'Default', 'formidable' ) ?> |
| 228 | 228 | </option> |
| 229 | 229 | <?php foreach ( FrmStylesHelper::get_sigle_label_postitions() as $pos => $pos_label ) { ?> |
@@ -281,7 +281,7 @@ discard block |
||
| 281 | 281 | do_action( 'frm_field_options_form', $field, $display, $values ); |
| 282 | 282 | |
| 283 | 283 | if ( $display['required'] || $display['invalid'] || $display['unique'] || $display['conf_field'] ) { ?> |
| 284 | - <tr class="frm_validation_msg <?php echo ($display['invalid'] || $field['required'] || FrmField::is_option_true( $field, 'unique' ) || FrmField::is_option_true( $field, 'conf_field' ) ) ? '' : 'frm_hidden'; ?>"> |
|
| 284 | + <tr class="frm_validation_msg <?php echo ( $display['invalid'] || $field['required'] || FrmField::is_option_true( $field, 'unique' ) || FrmField::is_option_true( $field, 'conf_field' ) ) ? '' : 'frm_hidden'; ?>"> |
|
| 285 | 285 | <td colspan="2"> |
| 286 | 286 | <div class="menu-settings"> |
| 287 | 287 | <h3 class="frm_no_bg"><?php _e( 'Validation', 'formidable' ) ?></h3> |
@@ -345,4 +345,4 @@ discard block |
||
| 345 | 345 | <?php |
| 346 | 346 | } |
| 347 | 347 | |
| 348 | -unset($display); |
|
| 348 | +unset( $display ); |
|
@@ -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; |