@@ -9,25 +9,25 @@ discard block |
||
| 9 | 9 | 'vader' => 'black_matte', |
| 10 | 10 | 'mint-choc' => 'mint_choco', |
| 11 | 11 | ); |
| 12 | -$theme_names = array_keys($jquery_themes); |
|
| 13 | -$theme_names = array_combine($theme_names, $theme_names); |
|
| 12 | +$theme_names = array_keys( $jquery_themes ); |
|
| 13 | +$theme_names = array_combine( $theme_names, $theme_names ); |
|
| 14 | 14 | |
| 15 | 15 | foreach ( $theme_names as $k => $v ) { |
| 16 | - $theme_names[ $k ] = str_replace( '-', '_', $v ); |
|
| 17 | - unset($k, $v); |
|
| 16 | + $theme_names[$k] = str_replace( '-', '_', $v ); |
|
| 17 | + unset( $k, $v ); |
|
| 18 | 18 | } |
| 19 | 19 | |
| 20 | -$alt_img_name = array_merge($theme_names, $alt_img_name); |
|
| 20 | +$alt_img_name = array_merge( $theme_names, $alt_img_name ); |
|
| 21 | 21 | $alt_img_name['-1'] = ''; |
| 22 | -unset($theme_names); |
|
| 22 | +unset( $theme_names ); |
|
| 23 | 23 | |
| 24 | 24 | ?> |
| 25 | 25 | |
| 26 | 26 | <div class="field-group clearfix frm-half frm-first-row"> |
| 27 | 27 | <label><?php _e( 'Theme', 'formidable' ) ?></label> |
| 28 | - <select name="<?php echo esc_attr( $frm_style->get_field_name('theme_selector') ) ?>"> |
|
| 28 | + <select name="<?php echo esc_attr( $frm_style->get_field_name( 'theme_selector' ) ) ?>"> |
|
| 29 | 29 | <?php foreach ( $jquery_themes as $theme_name => $theme_title ) { ?> |
| 30 | - <option value="<?php echo esc_attr( $theme_name ) ?>" id="90_<?php echo esc_attr( $alt_img_name[ $theme_name ] ); ?>" <?php selected( $theme_title, $style->post_content['theme_name'] ) ?>> |
|
| 30 | + <option value="<?php echo esc_attr( $theme_name ) ?>" id="90_<?php echo esc_attr( $alt_img_name[$theme_name] ); ?>" <?php selected( $theme_title, $style->post_content['theme_name'] ) ?>> |
|
| 31 | 31 | <?php echo esc_html( $theme_title ) ?> |
| 32 | 32 | </option> |
| 33 | 33 | <?php } ?> |
@@ -38,8 +38,8 @@ discard block |
||
| 38 | 38 | </div> |
| 39 | 39 | |
| 40 | 40 | <div class="field-group clearfix frm-half frm-first-row frm_right_text"> |
| 41 | - <img id="frm_show_cal" src="//jqueryui.com/resources/images/themeGallery/theme_90_<?php echo esc_attr( $alt_img_name[ $style->post_content['theme_css'] ] ) ?>.png" alt="" /> |
|
| 42 | - <input type="hidden" value="<?php echo esc_attr($style->post_content['theme_css']) ?>" id="frm_theme_css" name="<?php echo esc_attr( $frm_style->get_field_name('theme_css') ) ?>" /> |
|
| 43 | - <input type="hidden" value="<?php echo esc_attr($style->post_content['theme_name']) ?>" id="frm_theme_name" name="<?php echo esc_attr( $frm_style->get_field_name('theme_name') ) ?>" /> |
|
| 41 | + <img id="frm_show_cal" src="//jqueryui.com/resources/images/themeGallery/theme_90_<?php echo esc_attr( $alt_img_name[$style->post_content['theme_css']] ) ?>.png" alt="" /> |
|
| 42 | + <input type="hidden" value="<?php echo esc_attr( $style->post_content['theme_css'] ) ?>" id="frm_theme_css" name="<?php echo esc_attr( $frm_style->get_field_name( 'theme_css' ) ) ?>" /> |
|
| 43 | + <input type="hidden" value="<?php echo esc_attr( $style->post_content['theme_name'] ) ?>" id="frm_theme_name" name="<?php echo esc_attr( $frm_style->get_field_name( 'theme_name' ) ) ?>" /> |
|
| 44 | 44 | </div> |
| 45 | 45 | <div class="clear"></div> |
@@ -4,7 +4,7 @@ discard block |
||
| 4 | 4 | public $id = 0; // the id of the post |
| 5 | 5 | |
| 6 | 6 | /** |
| 7 | - * @param int|string $id The id of the stylsheet or 'default' |
|
| 7 | + * @param integer $id The id of the stylsheet or 'default' |
|
| 8 | 8 | */ |
| 9 | 9 | public function __construct( $id = 0 ) { |
| 10 | 10 | $this->id = $id; |
@@ -120,6 +120,9 @@ discard block |
||
| 120 | 120 | set_transient('frmpro_css', $css); |
| 121 | 121 | } |
| 122 | 122 | |
| 123 | + /** |
|
| 124 | + * @param string $filename |
|
| 125 | + */ |
|
| 123 | 126 | private function get_css_content( $filename ) { |
| 124 | 127 | $css = '/* ' . __( 'WARNING: Any changes made to this file will be lost when your Formidable settings are updated', 'formidable' ) . ' */' . "\n"; |
| 125 | 128 | |
@@ -1,52 +1,52 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | class FrmStyle { |
| 3 | - public $number = false; // Unique ID number of the current instance. |
|
| 3 | + public $number = false; // Unique ID number of the current instance. |
|
| 4 | 4 | public $id = 0; // the id of the post |
| 5 | 5 | |
| 6 | 6 | /** |
| 7 | 7 | * @param int|string $id The id of the stylsheet or 'default' |
| 8 | 8 | */ |
| 9 | 9 | public function __construct( $id = 0 ) { |
| 10 | - $this->id = $id; |
|
| 11 | - } |
|
| 10 | + $this->id = $id; |
|
| 11 | + } |
|
| 12 | 12 | |
| 13 | - public function get_new() { |
|
| 13 | + public function get_new() { |
|
| 14 | 14 | $this->id = 0; |
| 15 | 15 | |
| 16 | - $max_slug_value = pow(36, 6); |
|
| 17 | - $min_slug_value = 37; // we want to have at least 2 characters in the slug |
|
| 18 | - $key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 ); |
|
| 19 | - |
|
| 20 | - $style = array( |
|
| 21 | - 'post_type' => FrmStylesController::$post_type, |
|
| 22 | - 'ID' => '', |
|
| 23 | - 'post_title' => __( 'New Style', 'formidable' ), |
|
| 24 | - 'post_name' => $key, |
|
| 25 | - 'post_content' => $this->get_defaults(), |
|
| 26 | - 'menu_order' => '', |
|
| 27 | - 'post_status' => 'publish', |
|
| 28 | - ); |
|
| 16 | + $max_slug_value = pow(36, 6); |
|
| 17 | + $min_slug_value = 37; // we want to have at least 2 characters in the slug |
|
| 18 | + $key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 ); |
|
| 19 | + |
|
| 20 | + $style = array( |
|
| 21 | + 'post_type' => FrmStylesController::$post_type, |
|
| 22 | + 'ID' => '', |
|
| 23 | + 'post_title' => __( 'New Style', 'formidable' ), |
|
| 24 | + 'post_name' => $key, |
|
| 25 | + 'post_content' => $this->get_defaults(), |
|
| 26 | + 'menu_order' => '', |
|
| 27 | + 'post_status' => 'publish', |
|
| 28 | + ); |
|
| 29 | 29 | |
| 30 | - return (object) $style; |
|
| 31 | - } |
|
| 30 | + return (object) $style; |
|
| 31 | + } |
|
| 32 | 32 | |
| 33 | 33 | public function save( $settings ) { |
| 34 | 34 | return FrmAppHelper::save_settings( $settings, 'frm_styles' ); |
| 35 | - } |
|
| 35 | + } |
|
| 36 | 36 | |
| 37 | 37 | public function duplicate( $id ) { |
| 38 | - // duplicating is a pro feature |
|
| 39 | - } |
|
| 38 | + // duplicating is a pro feature |
|
| 39 | + } |
|
| 40 | 40 | |
| 41 | - public function update( $id = 'default' ) { |
|
| 41 | + public function update( $id = 'default' ) { |
|
| 42 | 42 | $all_instances = $this->get_all(); |
| 43 | 43 | |
| 44 | 44 | if ( empty($id) ) { |
| 45 | - $new_style = (array) $this->get_new(); |
|
| 46 | - $all_instances[] = $new_style; |
|
| 45 | + $new_style = (array) $this->get_new(); |
|
| 46 | + $all_instances[] = $new_style; |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | - $action_ids = array(); |
|
| 49 | + $action_ids = array(); |
|
| 50 | 50 | |
| 51 | 51 | foreach ( $all_instances as $number => $new_instance ) { |
| 52 | 52 | $new_instance = stripslashes_deep( (array) $new_instance); |
@@ -54,42 +54,42 @@ discard block |
||
| 54 | 54 | if ( $id != $this->id || ! $_POST || ! isset($_POST['frm_style_setting']) ) { |
| 55 | 55 | $all_instances[ $number ] = $new_instance; |
| 56 | 56 | |
| 57 | - if ( $new_instance['menu_order'] && $_POST && empty($_POST['prev_menu_order']) && isset($_POST['frm_style_setting']['menu_order']) ) { |
|
| 58 | - // this style was set to default, so remove default setting on previous default style |
|
| 59 | - $new_instance['menu_order'] = 0; |
|
| 60 | - $action_ids[] = $this->save($new_instance); |
|
| 61 | - } |
|
| 57 | + if ( $new_instance['menu_order'] && $_POST && empty($_POST['prev_menu_order']) && isset($_POST['frm_style_setting']['menu_order']) ) { |
|
| 58 | + // this style was set to default, so remove default setting on previous default style |
|
| 59 | + $new_instance['menu_order'] = 0; |
|
| 60 | + $action_ids[] = $this->save($new_instance); |
|
| 61 | + } |
|
| 62 | 62 | |
| 63 | - // don't continue if not saving this style |
|
| 64 | - continue; |
|
| 63 | + // don't continue if not saving this style |
|
| 64 | + continue; |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | $new_instance['post_title'] = sanitize_text_field( $_POST['frm_style_setting']['post_title'] ); |
| 68 | 68 | $new_instance['post_content'] = $_POST['frm_style_setting']['post_content']; |
| 69 | 69 | $new_instance['post_type'] = FrmStylesController::$post_type; |
| 70 | - $new_instance['post_status'] = 'publish'; |
|
| 70 | + $new_instance['post_status'] = 'publish'; |
|
| 71 | 71 | $new_instance['menu_order'] = isset( $_POST['frm_style_setting']['menu_order'] ) ? absint( $_POST['frm_style_setting']['menu_order'] ) : 0; |
| 72 | 72 | |
| 73 | - if ( empty($id) ) { |
|
| 74 | - $new_instance['post_name'] = $new_instance['post_title']; |
|
| 75 | - } |
|
| 73 | + if ( empty($id) ) { |
|
| 74 | + $new_instance['post_name'] = $new_instance['post_title']; |
|
| 75 | + } |
|
| 76 | 76 | |
| 77 | - $default_settings = $this->get_defaults(); |
|
| 77 | + $default_settings = $this->get_defaults(); |
|
| 78 | 78 | |
| 79 | - foreach ( $default_settings as $setting => $default ) { |
|
| 79 | + foreach ( $default_settings as $setting => $default ) { |
|
| 80 | 80 | if ( strpos( $setting, 'color' ) !== false || in_array( $setting, array( 'error_bg', 'error_border', 'error_text' ) ) ) { |
| 81 | - //if is a color |
|
| 81 | + //if is a color |
|
| 82 | 82 | $new_instance['post_content'][ $setting ] = str_replace( '#', '', $new_instance['post_content'][ $setting ] ); |
| 83 | 83 | } else if ( in_array( $setting, array( 'submit_style', 'important_style', 'auto_width' ) ) && ! isset( $new_instance['post_content'][ $setting ] ) ) { |
| 84 | 84 | $new_instance['post_content'][ $setting ] = 0; |
| 85 | - } else if ( $setting == 'font' ) { |
|
| 86 | - $new_instance['post_content'][ $setting ] = $this->force_balanced_quotation( $new_instance['post_content'][ $setting ] ); |
|
| 87 | - } |
|
| 88 | - } |
|
| 85 | + } else if ( $setting == 'font' ) { |
|
| 86 | + $new_instance['post_content'][ $setting ] = $this->force_balanced_quotation( $new_instance['post_content'][ $setting ] ); |
|
| 87 | + } |
|
| 88 | + } |
|
| 89 | 89 | |
| 90 | 90 | $all_instances[ $number ] = $new_instance; |
| 91 | 91 | |
| 92 | - $action_ids[] = $this->save($new_instance); |
|
| 92 | + $action_ids[] = $this->save($new_instance); |
|
| 93 | 93 | |
| 94 | 94 | } |
| 95 | 95 | |
@@ -98,26 +98,26 @@ discard block |
||
| 98 | 98 | return $action_ids; |
| 99 | 99 | } |
| 100 | 100 | |
| 101 | - /** |
|
| 102 | - * Create static css file |
|
| 103 | - */ |
|
| 101 | + /** |
|
| 102 | + * Create static css file |
|
| 103 | + */ |
|
| 104 | 104 | public function save_settings( $styles ) { |
| 105 | 105 | $filename = FrmAppHelper::plugin_path() . '/css/custom_theme.css.php'; |
| 106 | 106 | update_option( 'frm_last_style_update', date('njGi') ); |
| 107 | 107 | |
| 108 | - if ( ! is_file($filename) ) { |
|
| 109 | - return; |
|
| 110 | - } |
|
| 108 | + if ( ! is_file($filename) ) { |
|
| 109 | + return; |
|
| 110 | + } |
|
| 111 | 111 | |
| 112 | 112 | $css = $this->get_css_content( $filename ); |
| 113 | 113 | |
| 114 | 114 | $create_file = new FrmCreateFile( array( 'folder_name' => 'formidable/css', 'file_name' => 'formidablepro.css' ) ); |
| 115 | 115 | $create_file->create_file( $css ); |
| 116 | 116 | |
| 117 | - update_option('frmpro_css', $css); |
|
| 117 | + update_option('frmpro_css', $css); |
|
| 118 | 118 | |
| 119 | - delete_transient('frmpro_css'); |
|
| 120 | - set_transient('frmpro_css', $css); |
|
| 119 | + delete_transient('frmpro_css'); |
|
| 120 | + set_transient('frmpro_css', $css); |
|
| 121 | 121 | } |
| 122 | 122 | |
| 123 | 123 | private function get_css_content( $filename ) { |
@@ -126,280 +126,280 @@ discard block |
||
| 126 | 126 | $saving = true; |
| 127 | 127 | $frm_style = $this; |
| 128 | 128 | |
| 129 | - ob_start(); |
|
| 130 | - include( $filename ); |
|
| 129 | + ob_start(); |
|
| 130 | + include( $filename ); |
|
| 131 | 131 | $css .= preg_replace( '/\/\*(.|\s)*?\*\//', '', str_replace( array( "\r\n", "\r", "\n", "\t", ' ' ), '', ob_get_contents() ) ); |
| 132 | - ob_end_clean(); |
|
| 132 | + ob_end_clean(); |
|
| 133 | 133 | |
| 134 | 134 | return $css; |
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | public function destroy( $id ) { |
| 138 | - return wp_delete_post($id); |
|
| 139 | - } |
|
| 138 | + return wp_delete_post($id); |
|
| 139 | + } |
|
| 140 | 140 | |
| 141 | - public function get_one() { |
|
| 142 | - if ( 'default' == $this->id ) { |
|
| 143 | - $style = $this->get_default_style(); |
|
| 144 | - if ( $style ) { |
|
| 145 | - $this->id = $style->ID; |
|
| 146 | - } else { |
|
| 147 | - $this->id = 0; |
|
| 148 | - } |
|
| 149 | - return $style; |
|
| 150 | - } |
|
| 141 | + public function get_one() { |
|
| 142 | + if ( 'default' == $this->id ) { |
|
| 143 | + $style = $this->get_default_style(); |
|
| 144 | + if ( $style ) { |
|
| 145 | + $this->id = $style->ID; |
|
| 146 | + } else { |
|
| 147 | + $this->id = 0; |
|
| 148 | + } |
|
| 149 | + return $style; |
|
| 150 | + } |
|
| 151 | 151 | |
| 152 | - $style = get_post($this->id); |
|
| 152 | + $style = get_post($this->id); |
|
| 153 | 153 | |
| 154 | - if ( ! $style ) { |
|
| 155 | - return $style; |
|
| 156 | - } |
|
| 154 | + if ( ! $style ) { |
|
| 155 | + return $style; |
|
| 156 | + } |
|
| 157 | 157 | |
| 158 | - $style->post_content = FrmAppHelper::maybe_json_decode($style->post_content); |
|
| 158 | + $style->post_content = FrmAppHelper::maybe_json_decode($style->post_content); |
|
| 159 | 159 | |
| 160 | - $default_values = $this->get_defaults(); |
|
| 160 | + $default_values = $this->get_defaults(); |
|
| 161 | 161 | |
| 162 | - // fill default values |
|
| 163 | - $style->post_content = $this->override_defaults($style->post_content); |
|
| 164 | - $style->post_content = wp_parse_args( $style->post_content, $default_values); |
|
| 162 | + // fill default values |
|
| 163 | + $style->post_content = $this->override_defaults($style->post_content); |
|
| 164 | + $style->post_content = wp_parse_args( $style->post_content, $default_values); |
|
| 165 | 165 | |
| 166 | - return $style; |
|
| 167 | - } |
|
| 166 | + return $style; |
|
| 167 | + } |
|
| 168 | 168 | |
| 169 | - public function get_all( $orderby = 'title', $order = 'ASC', $limit = 99 ) { |
|
| 170 | - $post_atts = array( |
|
| 169 | + public function get_all( $orderby = 'title', $order = 'ASC', $limit = 99 ) { |
|
| 170 | + $post_atts = array( |
|
| 171 | 171 | 'post_type' => FrmStylesController::$post_type, |
| 172 | 172 | 'post_status' => 'publish', |
| 173 | 173 | 'numberposts' => $limit, |
| 174 | 174 | 'orderby' => $orderby, |
| 175 | 175 | 'order' => $order, |
| 176 | - ); |
|
| 176 | + ); |
|
| 177 | 177 | |
| 178 | - $temp_styles = FrmAppHelper::check_cache(serialize($post_atts), 'frm_styles', $post_atts, 'get_posts'); |
|
| 178 | + $temp_styles = FrmAppHelper::check_cache(serialize($post_atts), 'frm_styles', $post_atts, 'get_posts'); |
|
| 179 | 179 | |
| 180 | - if ( empty($temp_styles) ) { |
|
| 181 | - global $wpdb; |
|
| 182 | - // make sure there wasn't a conflict with the query |
|
| 180 | + if ( empty($temp_styles) ) { |
|
| 181 | + global $wpdb; |
|
| 182 | + // make sure there wasn't a conflict with the query |
|
| 183 | 183 | $query = $wpdb->prepare( 'SELECT * FROM ' . $wpdb->posts . ' WHERE post_type=%s AND post_status=%s ORDER BY post_title ASC LIMIT 99', FrmStylesController::$post_type, 'publish' ); |
| 184 | - $temp_styles = FrmAppHelper::check_cache('frm_backup_style_check', 'frm_styles', $query, 'get_results'); |
|
| 185 | - |
|
| 186 | - if ( empty($temp_styles) ) { |
|
| 187 | - // create a new style if there are none |
|
| 188 | - $new = $this->get_new(); |
|
| 189 | - $new->post_title = $new->post_name = __( 'Formidable Style', 'formidable' ); |
|
| 190 | - $new->menu_order = 1; |
|
| 191 | - $new = $this->save( (array) $new); |
|
| 192 | - $this->update('default'); |
|
| 193 | - |
|
| 194 | - $post_atts['include'] = $new; |
|
| 195 | - |
|
| 196 | - $temp_styles = get_posts( $post_atts ); |
|
| 197 | - } |
|
| 198 | - } |
|
| 199 | - |
|
| 200 | - $default_values = $this->get_defaults(); |
|
| 201 | - $default_style = false; |
|
| 202 | - |
|
| 203 | - $styles = array(); |
|
| 204 | - foreach ( $temp_styles as $style ) { |
|
| 205 | - $this->id = $style->ID; |
|
| 206 | - if ( $style->menu_order ) { |
|
| 207 | - if ( $default_style ) { |
|
| 208 | - // only return one default |
|
| 209 | - $style->menu_order = 0; |
|
| 210 | - } else { |
|
| 211 | - // check for a default style |
|
| 212 | - $default_style = $style->ID; |
|
| 213 | - } |
|
| 214 | - } |
|
| 215 | - |
|
| 216 | - $style->post_content = FrmAppHelper::maybe_json_decode($style->post_content); |
|
| 217 | - |
|
| 218 | - // fill default values |
|
| 219 | - $style->post_content = $this->override_defaults($style->post_content); |
|
| 220 | - $style->post_content = wp_parse_args( $style->post_content, $default_values); |
|
| 184 | + $temp_styles = FrmAppHelper::check_cache('frm_backup_style_check', 'frm_styles', $query, 'get_results'); |
|
| 185 | + |
|
| 186 | + if ( empty($temp_styles) ) { |
|
| 187 | + // create a new style if there are none |
|
| 188 | + $new = $this->get_new(); |
|
| 189 | + $new->post_title = $new->post_name = __( 'Formidable Style', 'formidable' ); |
|
| 190 | + $new->menu_order = 1; |
|
| 191 | + $new = $this->save( (array) $new); |
|
| 192 | + $this->update('default'); |
|
| 193 | + |
|
| 194 | + $post_atts['include'] = $new; |
|
| 195 | + |
|
| 196 | + $temp_styles = get_posts( $post_atts ); |
|
| 197 | + } |
|
| 198 | + } |
|
| 199 | + |
|
| 200 | + $default_values = $this->get_defaults(); |
|
| 201 | + $default_style = false; |
|
| 202 | + |
|
| 203 | + $styles = array(); |
|
| 204 | + foreach ( $temp_styles as $style ) { |
|
| 205 | + $this->id = $style->ID; |
|
| 206 | + if ( $style->menu_order ) { |
|
| 207 | + if ( $default_style ) { |
|
| 208 | + // only return one default |
|
| 209 | + $style->menu_order = 0; |
|
| 210 | + } else { |
|
| 211 | + // check for a default style |
|
| 212 | + $default_style = $style->ID; |
|
| 213 | + } |
|
| 214 | + } |
|
| 215 | + |
|
| 216 | + $style->post_content = FrmAppHelper::maybe_json_decode($style->post_content); |
|
| 217 | + |
|
| 218 | + // fill default values |
|
| 219 | + $style->post_content = $this->override_defaults($style->post_content); |
|
| 220 | + $style->post_content = wp_parse_args( $style->post_content, $default_values); |
|
| 221 | 221 | |
| 222 | 222 | $styles[ $style->ID ] = $style; |
| 223 | - } |
|
| 223 | + } |
|
| 224 | 224 | |
| 225 | - if ( ! $default_style ) { |
|
| 226 | - $default_style = reset($styles); |
|
| 225 | + if ( ! $default_style ) { |
|
| 226 | + $default_style = reset($styles); |
|
| 227 | 227 | $styles[ $default_style->ID ]->menu_order = 1; |
| 228 | - } |
|
| 228 | + } |
|
| 229 | 229 | |
| 230 | - return $styles; |
|
| 231 | - } |
|
| 230 | + return $styles; |
|
| 231 | + } |
|
| 232 | 232 | |
| 233 | 233 | public function get_default_style( $styles = null ) { |
| 234 | - if ( ! isset($styles) ) { |
|
| 234 | + if ( ! isset($styles) ) { |
|
| 235 | 235 | $styles = $this->get_all( 'menu_order', 'DESC', 1 ); |
| 236 | - } |
|
| 236 | + } |
|
| 237 | 237 | |
| 238 | - foreach ( $styles as $style ) { |
|
| 239 | - if ( $style->menu_order ) { |
|
| 240 | - return $style; |
|
| 241 | - } |
|
| 242 | - } |
|
| 243 | - } |
|
| 238 | + foreach ( $styles as $style ) { |
|
| 239 | + if ( $style->menu_order ) { |
|
| 240 | + return $style; |
|
| 241 | + } |
|
| 242 | + } |
|
| 243 | + } |
|
| 244 | 244 | |
| 245 | 245 | public function override_defaults( $settings ) { |
| 246 | - if ( ! is_array($settings) ) { |
|
| 247 | - return $settings; |
|
| 248 | - } |
|
| 249 | - |
|
| 250 | - $settings['line_height'] = ( ! isset($settings['field_height']) || $settings['field_height'] == '' || $settings['field_height'] == 'auto') ? 'normal' : $settings['field_height']; |
|
| 251 | - |
|
| 252 | - if ( ! isset($settings['form_desc_size']) && isset($settings['description_font_size']) ) { |
|
| 253 | - $settings['form_desc_size'] = $settings['description_font_size']; |
|
| 254 | - $settings['form_desc_color'] = $settings['description_color']; |
|
| 255 | - $settings['title_color'] = $settings['label_color']; |
|
| 256 | - } |
|
| 257 | - |
|
| 258 | - if ( ! isset($settings['section_color']) && isset($settings['label_color']) ) { |
|
| 259 | - $settings['section_color'] = $settings['label_color']; |
|
| 260 | - $settings['section_border_color'] = $settings['border_color']; |
|
| 261 | - } |
|
| 262 | - |
|
| 263 | - if ( ! isset($settings['submit_hover_bg_color']) && isset($settings['submit_bg_color']) ) { |
|
| 264 | - $settings['submit_hover_bg_color'] = $settings['submit_bg_color']; |
|
| 265 | - $settings['submit_hover_color'] = $settings['submit_text_color']; |
|
| 266 | - $settings['submit_hover_border_color'] = $settings['submit_border_color']; |
|
| 267 | - |
|
| 268 | - $settings['submit_active_bg_color'] = $settings['submit_bg_color']; |
|
| 269 | - $settings['submit_active_color'] = $settings['submit_text_color']; |
|
| 270 | - $settings['submit_active_border_color'] = $settings['submit_border_color']; |
|
| 271 | - } |
|
| 272 | - |
|
| 273 | - return $settings; |
|
| 246 | + if ( ! is_array($settings) ) { |
|
| 247 | + return $settings; |
|
| 248 | + } |
|
| 249 | + |
|
| 250 | + $settings['line_height'] = ( ! isset($settings['field_height']) || $settings['field_height'] == '' || $settings['field_height'] == 'auto') ? 'normal' : $settings['field_height']; |
|
| 251 | + |
|
| 252 | + if ( ! isset($settings['form_desc_size']) && isset($settings['description_font_size']) ) { |
|
| 253 | + $settings['form_desc_size'] = $settings['description_font_size']; |
|
| 254 | + $settings['form_desc_color'] = $settings['description_color']; |
|
| 255 | + $settings['title_color'] = $settings['label_color']; |
|
| 256 | + } |
|
| 257 | + |
|
| 258 | + if ( ! isset($settings['section_color']) && isset($settings['label_color']) ) { |
|
| 259 | + $settings['section_color'] = $settings['label_color']; |
|
| 260 | + $settings['section_border_color'] = $settings['border_color']; |
|
| 261 | + } |
|
| 262 | + |
|
| 263 | + if ( ! isset($settings['submit_hover_bg_color']) && isset($settings['submit_bg_color']) ) { |
|
| 264 | + $settings['submit_hover_bg_color'] = $settings['submit_bg_color']; |
|
| 265 | + $settings['submit_hover_color'] = $settings['submit_text_color']; |
|
| 266 | + $settings['submit_hover_border_color'] = $settings['submit_border_color']; |
|
| 267 | + |
|
| 268 | + $settings['submit_active_bg_color'] = $settings['submit_bg_color']; |
|
| 269 | + $settings['submit_active_color'] = $settings['submit_text_color']; |
|
| 270 | + $settings['submit_active_border_color'] = $settings['submit_border_color']; |
|
| 271 | + } |
|
| 272 | + |
|
| 273 | + return $settings; |
|
| 274 | 274 | } |
| 275 | 275 | |
| 276 | 276 | public function get_defaults() { |
| 277 | - return array( |
|
| 278 | - 'theme_css' => 'ui-lightness', |
|
| 279 | - 'theme_name' => 'UI Lightness', |
|
| 277 | + return array( |
|
| 278 | + 'theme_css' => 'ui-lightness', |
|
| 279 | + 'theme_name' => 'UI Lightness', |
|
| 280 | 280 | |
| 281 | 281 | 'center_form' => '', |
| 282 | - 'form_width' => '100%', |
|
| 283 | - 'form_align' => 'left', |
|
| 284 | - 'direction' => is_rtl() ? 'rtl' : 'ltr', |
|
| 285 | - 'fieldset' => '0px', |
|
| 286 | - 'fieldset_color' => '000000', |
|
| 287 | - 'fieldset_padding' => '0 0 15px 0', |
|
| 288 | - 'fieldset_bg_color' => '', |
|
| 289 | - |
|
| 290 | - 'title_size' => '20px', |
|
| 291 | - 'title_color' => '444444', |
|
| 282 | + 'form_width' => '100%', |
|
| 283 | + 'form_align' => 'left', |
|
| 284 | + 'direction' => is_rtl() ? 'rtl' : 'ltr', |
|
| 285 | + 'fieldset' => '0px', |
|
| 286 | + 'fieldset_color' => '000000', |
|
| 287 | + 'fieldset_padding' => '0 0 15px 0', |
|
| 288 | + 'fieldset_bg_color' => '', |
|
| 289 | + |
|
| 290 | + 'title_size' => '20px', |
|
| 291 | + 'title_color' => '444444', |
|
| 292 | 292 | 'title_margin_top' => '10px', |
| 293 | 293 | 'title_margin_bottom' => '10px', |
| 294 | - 'form_desc_size' => '14px', |
|
| 295 | - 'form_desc_color' => '666666', |
|
| 294 | + 'form_desc_size' => '14px', |
|
| 295 | + 'form_desc_color' => '666666', |
|
| 296 | 296 | 'form_desc_margin_top' => '10px', |
| 297 | 297 | 'form_desc_margin_bottom' => '25px', |
| 298 | 298 | |
| 299 | - 'font' => '"Lucida Grande","Lucida Sans Unicode",Tahoma,sans-serif', |
|
| 300 | - 'font_size' => '14px', |
|
| 301 | - 'label_color' => '444444', |
|
| 302 | - 'weight' => 'bold', |
|
| 303 | - 'position' => 'none', |
|
| 304 | - 'align' => 'left', |
|
| 305 | - 'width' => '150px', |
|
| 306 | - 'required_color' => 'B94A48', |
|
| 307 | - 'required_weight' => 'bold', |
|
| 308 | - 'label_padding' => '0 0 3px 0', |
|
| 309 | - |
|
| 310 | - 'description_font_size' => '12px', |
|
| 311 | - 'description_color' => '666666', |
|
| 312 | - 'description_weight' => 'normal', |
|
| 313 | - 'description_style' => 'normal', |
|
| 314 | - 'description_align' => 'left', |
|
| 315 | - |
|
| 316 | - 'field_font_size' => '14px', |
|
| 317 | - 'field_height' => '32px', |
|
| 318 | - 'line_height' => 'normal', |
|
| 319 | - 'field_width' => '100%', |
|
| 320 | - 'auto_width' => false, |
|
| 321 | - 'field_pad' => '6px 10px', |
|
| 322 | - 'field_margin' => '20px', |
|
| 299 | + 'font' => '"Lucida Grande","Lucida Sans Unicode",Tahoma,sans-serif', |
|
| 300 | + 'font_size' => '14px', |
|
| 301 | + 'label_color' => '444444', |
|
| 302 | + 'weight' => 'bold', |
|
| 303 | + 'position' => 'none', |
|
| 304 | + 'align' => 'left', |
|
| 305 | + 'width' => '150px', |
|
| 306 | + 'required_color' => 'B94A48', |
|
| 307 | + 'required_weight' => 'bold', |
|
| 308 | + 'label_padding' => '0 0 3px 0', |
|
| 309 | + |
|
| 310 | + 'description_font_size' => '12px', |
|
| 311 | + 'description_color' => '666666', |
|
| 312 | + 'description_weight' => 'normal', |
|
| 313 | + 'description_style' => 'normal', |
|
| 314 | + 'description_align' => 'left', |
|
| 315 | + |
|
| 316 | + 'field_font_size' => '14px', |
|
| 317 | + 'field_height' => '32px', |
|
| 318 | + 'line_height' => 'normal', |
|
| 319 | + 'field_width' => '100%', |
|
| 320 | + 'auto_width' => false, |
|
| 321 | + 'field_pad' => '6px 10px', |
|
| 322 | + 'field_margin' => '20px', |
|
| 323 | 323 | 'field_weight' => 'normal', |
| 324 | - 'text_color' => '555555', |
|
| 325 | - //'border_color_hv' => 'cccccc', |
|
| 326 | - 'border_color' => 'cccccc', |
|
| 327 | - 'field_border_width' => '1px', |
|
| 328 | - 'field_border_style' => 'solid', |
|
| 329 | - |
|
| 330 | - 'bg_color' => 'ffffff', |
|
| 331 | - //'bg_color_hv' => 'ffffff', |
|
| 324 | + 'text_color' => '555555', |
|
| 325 | + //'border_color_hv' => 'cccccc', |
|
| 326 | + 'border_color' => 'cccccc', |
|
| 327 | + 'field_border_width' => '1px', |
|
| 328 | + 'field_border_style' => 'solid', |
|
| 329 | + |
|
| 330 | + 'bg_color' => 'ffffff', |
|
| 331 | + //'bg_color_hv' => 'ffffff', |
|
| 332 | 332 | 'remove_box_shadow' => '', |
| 333 | - 'bg_color_active' => 'ffffff', |
|
| 333 | + 'bg_color_active' => 'ffffff', |
|
| 334 | 334 | 'border_color_active' => '66afe9', |
| 335 | 335 | 'remove_box_shadow_active' => '', |
| 336 | - 'text_color_error' => '444444', |
|
| 337 | - 'bg_color_error' => 'ffffff', |
|
| 336 | + 'text_color_error' => '444444', |
|
| 337 | + 'bg_color_error' => 'ffffff', |
|
| 338 | 338 | 'border_color_error' => 'B94A48', |
| 339 | 339 | 'border_width_error' => '1px', |
| 340 | 340 | 'border_style_error' => 'solid', |
| 341 | - 'bg_color_disabled' => 'ffffff', |
|
| 342 | - 'border_color_disabled' => 'E5E5E5', |
|
| 343 | - 'text_color_disabled' => 'A1A1A1', |
|
| 344 | - |
|
| 345 | - 'radio_align' => 'block', |
|
| 346 | - 'check_align' => 'block', |
|
| 347 | - 'check_font_size' => '13px', |
|
| 348 | - 'check_label_color' => '444444', |
|
| 349 | - 'check_weight' => 'normal', |
|
| 350 | - |
|
| 351 | - 'section_font_size' => '18px', |
|
| 352 | - 'section_color' => '444444', |
|
| 353 | - 'section_weight' => 'bold', |
|
| 354 | - 'section_pad' => '15px 0 3px 0', |
|
| 355 | - 'section_mar_top' => '15px', |
|
| 341 | + 'bg_color_disabled' => 'ffffff', |
|
| 342 | + 'border_color_disabled' => 'E5E5E5', |
|
| 343 | + 'text_color_disabled' => 'A1A1A1', |
|
| 344 | + |
|
| 345 | + 'radio_align' => 'block', |
|
| 346 | + 'check_align' => 'block', |
|
| 347 | + 'check_font_size' => '13px', |
|
| 348 | + 'check_label_color' => '444444', |
|
| 349 | + 'check_weight' => 'normal', |
|
| 350 | + |
|
| 351 | + 'section_font_size' => '18px', |
|
| 352 | + 'section_color' => '444444', |
|
| 353 | + 'section_weight' => 'bold', |
|
| 354 | + 'section_pad' => '15px 0 3px 0', |
|
| 355 | + 'section_mar_top' => '15px', |
|
| 356 | 356 | 'section_mar_bottom' => '12px', |
| 357 | - 'section_bg_color' => '', |
|
| 358 | - 'section_border_color' => 'e8e8e8', |
|
| 359 | - 'section_border_width' => '2px', |
|
| 360 | - 'section_border_style' => 'solid', |
|
| 361 | - 'section_border_loc' => '-top', |
|
| 362 | - 'collapse_icon' => '6', |
|
| 363 | - 'collapse_pos' => 'after', |
|
| 364 | - 'repeat_icon' => '1', |
|
| 365 | - |
|
| 366 | - 'submit_style' => false, |
|
| 367 | - 'submit_font_size' => '14px', |
|
| 368 | - 'submit_width' => 'auto', |
|
| 369 | - 'submit_height' => 'auto', |
|
| 370 | - 'submit_bg_color' => 'ffffff', |
|
| 371 | - 'submit_border_color' => 'cccccc', |
|
| 372 | - 'submit_border_width' => '1px', |
|
| 373 | - 'submit_text_color' => '444444', |
|
| 374 | - 'submit_weight' => 'normal', |
|
| 375 | - 'submit_border_radius' => '4px', |
|
| 376 | - 'submit_bg_img' => '', |
|
| 377 | - 'submit_margin' => '10px', |
|
| 378 | - 'submit_padding' => '6px 11px', |
|
| 379 | - 'submit_shadow_color' => 'eeeeee', |
|
| 380 | - 'submit_hover_bg_color' => 'efefef', |
|
| 381 | - 'submit_hover_color' => '444444', |
|
| 382 | - 'submit_hover_border_color' => 'cccccc', |
|
| 383 | - 'submit_active_bg_color' => 'efefef', |
|
| 384 | - 'submit_active_color' => '444444', |
|
| 385 | - 'submit_active_border_color' => 'cccccc', |
|
| 386 | - |
|
| 387 | - 'border_radius' => '4px', |
|
| 388 | - 'error_bg' => 'F2DEDE', |
|
| 389 | - 'error_border' => 'EBCCD1', |
|
| 390 | - 'error_text' => 'B94A48', |
|
| 391 | - 'error_font_size' => '14px', |
|
| 392 | - |
|
| 393 | - 'success_bg_color' => 'DFF0D8', |
|
| 394 | - 'success_border_color' => 'D6E9C6', |
|
| 395 | - 'success_text_color' => '468847', |
|
| 396 | - 'success_font_size' => '14px', |
|
| 397 | - |
|
| 398 | - 'important_style' => false, |
|
| 399 | - |
|
| 400 | - 'custom_css' => '', |
|
| 401 | - ); |
|
| 402 | - } |
|
| 357 | + 'section_bg_color' => '', |
|
| 358 | + 'section_border_color' => 'e8e8e8', |
|
| 359 | + 'section_border_width' => '2px', |
|
| 360 | + 'section_border_style' => 'solid', |
|
| 361 | + 'section_border_loc' => '-top', |
|
| 362 | + 'collapse_icon' => '6', |
|
| 363 | + 'collapse_pos' => 'after', |
|
| 364 | + 'repeat_icon' => '1', |
|
| 365 | + |
|
| 366 | + 'submit_style' => false, |
|
| 367 | + 'submit_font_size' => '14px', |
|
| 368 | + 'submit_width' => 'auto', |
|
| 369 | + 'submit_height' => 'auto', |
|
| 370 | + 'submit_bg_color' => 'ffffff', |
|
| 371 | + 'submit_border_color' => 'cccccc', |
|
| 372 | + 'submit_border_width' => '1px', |
|
| 373 | + 'submit_text_color' => '444444', |
|
| 374 | + 'submit_weight' => 'normal', |
|
| 375 | + 'submit_border_radius' => '4px', |
|
| 376 | + 'submit_bg_img' => '', |
|
| 377 | + 'submit_margin' => '10px', |
|
| 378 | + 'submit_padding' => '6px 11px', |
|
| 379 | + 'submit_shadow_color' => 'eeeeee', |
|
| 380 | + 'submit_hover_bg_color' => 'efefef', |
|
| 381 | + 'submit_hover_color' => '444444', |
|
| 382 | + 'submit_hover_border_color' => 'cccccc', |
|
| 383 | + 'submit_active_bg_color' => 'efefef', |
|
| 384 | + 'submit_active_color' => '444444', |
|
| 385 | + 'submit_active_border_color' => 'cccccc', |
|
| 386 | + |
|
| 387 | + 'border_radius' => '4px', |
|
| 388 | + 'error_bg' => 'F2DEDE', |
|
| 389 | + 'error_border' => 'EBCCD1', |
|
| 390 | + 'error_text' => 'B94A48', |
|
| 391 | + 'error_font_size' => '14px', |
|
| 392 | + |
|
| 393 | + 'success_bg_color' => 'DFF0D8', |
|
| 394 | + 'success_border_color' => 'D6E9C6', |
|
| 395 | + 'success_text_color' => '468847', |
|
| 396 | + 'success_font_size' => '14px', |
|
| 397 | + |
|
| 398 | + 'important_style' => false, |
|
| 399 | + |
|
| 400 | + 'custom_css' => '', |
|
| 401 | + ); |
|
| 402 | + } |
|
| 403 | 403 | |
| 404 | 404 | public function get_field_name( $field_name, $post_field = 'post_content' ) { |
| 405 | 405 | return 'frm_style_setting' . ( empty( $post_field ) ? '' : '[' . $post_field . ']' ) . '[' . $field_name . ']'; |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | class FrmStyle { |
| 3 | - public $number = false; // Unique ID number of the current instance. |
|
| 3 | + public $number = false; // Unique ID number of the current instance. |
|
| 4 | 4 | public $id = 0; // the id of the post |
| 5 | 5 | |
| 6 | 6 | /** |
@@ -13,9 +13,9 @@ discard block |
||
| 13 | 13 | public function get_new() { |
| 14 | 14 | $this->id = 0; |
| 15 | 15 | |
| 16 | - $max_slug_value = pow(36, 6); |
|
| 16 | + $max_slug_value = pow( 36, 6 ); |
|
| 17 | 17 | $min_slug_value = 37; // we want to have at least 2 characters in the slug |
| 18 | - $key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 ); |
|
| 18 | + $key = base_convert( rand( $min_slug_value, $max_slug_value ), 10, 36 ); |
|
| 19 | 19 | |
| 20 | 20 | $style = array( |
| 21 | 21 | 'post_type' => FrmStylesController::$post_type, |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | public function update( $id = 'default' ) { |
| 42 | 42 | $all_instances = $this->get_all(); |
| 43 | 43 | |
| 44 | - if ( empty($id) ) { |
|
| 44 | + if ( empty( $id ) ) { |
|
| 45 | 45 | $new_style = (array) $this->get_new(); |
| 46 | 46 | $all_instances[] = $new_style; |
| 47 | 47 | } |
@@ -49,15 +49,15 @@ discard block |
||
| 49 | 49 | $action_ids = array(); |
| 50 | 50 | |
| 51 | 51 | foreach ( $all_instances as $number => $new_instance ) { |
| 52 | - $new_instance = stripslashes_deep( (array) $new_instance); |
|
| 52 | + $new_instance = stripslashes_deep( (array) $new_instance ); |
|
| 53 | 53 | $this->id = $new_instance['ID']; |
| 54 | - if ( $id != $this->id || ! $_POST || ! isset($_POST['frm_style_setting']) ) { |
|
| 55 | - $all_instances[ $number ] = $new_instance; |
|
| 54 | + if ( $id != $this->id || ! $_POST || ! isset( $_POST['frm_style_setting'] ) ) { |
|
| 55 | + $all_instances[$number] = $new_instance; |
|
| 56 | 56 | |
| 57 | - if ( $new_instance['menu_order'] && $_POST && empty($_POST['prev_menu_order']) && isset($_POST['frm_style_setting']['menu_order']) ) { |
|
| 57 | + if ( $new_instance['menu_order'] && $_POST && empty( $_POST['prev_menu_order'] ) && isset( $_POST['frm_style_setting']['menu_order'] ) ) { |
|
| 58 | 58 | // this style was set to default, so remove default setting on previous default style |
| 59 | 59 | $new_instance['menu_order'] = 0; |
| 60 | - $action_ids[] = $this->save($new_instance); |
|
| 60 | + $action_ids[] = $this->save( $new_instance ); |
|
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | // don't continue if not saving this style |
@@ -67,10 +67,10 @@ discard block |
||
| 67 | 67 | $new_instance['post_title'] = sanitize_text_field( $_POST['frm_style_setting']['post_title'] ); |
| 68 | 68 | $new_instance['post_content'] = $_POST['frm_style_setting']['post_content']; |
| 69 | 69 | $new_instance['post_type'] = FrmStylesController::$post_type; |
| 70 | - $new_instance['post_status'] = 'publish'; |
|
| 70 | + $new_instance['post_status'] = 'publish'; |
|
| 71 | 71 | $new_instance['menu_order'] = isset( $_POST['frm_style_setting']['menu_order'] ) ? absint( $_POST['frm_style_setting']['menu_order'] ) : 0; |
| 72 | 72 | |
| 73 | - if ( empty($id) ) { |
|
| 73 | + if ( empty( $id ) ) { |
|
| 74 | 74 | $new_instance['post_name'] = $new_instance['post_title']; |
| 75 | 75 | } |
| 76 | 76 | |
@@ -79,21 +79,21 @@ discard block |
||
| 79 | 79 | foreach ( $default_settings as $setting => $default ) { |
| 80 | 80 | if ( strpos( $setting, 'color' ) !== false || in_array( $setting, array( 'error_bg', 'error_border', 'error_text' ) ) ) { |
| 81 | 81 | //if is a color |
| 82 | - $new_instance['post_content'][ $setting ] = str_replace( '#', '', $new_instance['post_content'][ $setting ] ); |
|
| 83 | - } else if ( in_array( $setting, array( 'submit_style', 'important_style', 'auto_width' ) ) && ! isset( $new_instance['post_content'][ $setting ] ) ) { |
|
| 84 | - $new_instance['post_content'][ $setting ] = 0; |
|
| 82 | + $new_instance['post_content'][$setting] = str_replace( '#', '', $new_instance['post_content'][$setting] ); |
|
| 83 | + } else if ( in_array( $setting, array( 'submit_style', 'important_style', 'auto_width' ) ) && ! isset( $new_instance['post_content'][$setting] ) ) { |
|
| 84 | + $new_instance['post_content'][$setting] = 0; |
|
| 85 | 85 | } else if ( $setting == 'font' ) { |
| 86 | - $new_instance['post_content'][ $setting ] = $this->force_balanced_quotation( $new_instance['post_content'][ $setting ] ); |
|
| 86 | + $new_instance['post_content'][$setting] = $this->force_balanced_quotation( $new_instance['post_content'][$setting] ); |
|
| 87 | 87 | } |
| 88 | 88 | } |
| 89 | 89 | |
| 90 | - $all_instances[ $number ] = $new_instance; |
|
| 90 | + $all_instances[$number] = $new_instance; |
|
| 91 | 91 | |
| 92 | - $action_ids[] = $this->save($new_instance); |
|
| 92 | + $action_ids[] = $this->save( $new_instance ); |
|
| 93 | 93 | |
| 94 | 94 | } |
| 95 | 95 | |
| 96 | - $this->save_settings($all_instances); |
|
| 96 | + $this->save_settings( $all_instances ); |
|
| 97 | 97 | |
| 98 | 98 | return $action_ids; |
| 99 | 99 | } |
@@ -103,9 +103,9 @@ discard block |
||
| 103 | 103 | */ |
| 104 | 104 | public function save_settings( $styles ) { |
| 105 | 105 | $filename = FrmAppHelper::plugin_path() . '/css/custom_theme.css.php'; |
| 106 | - update_option( 'frm_last_style_update', date('njGi') ); |
|
| 106 | + update_option( 'frm_last_style_update', date( 'njGi' ) ); |
|
| 107 | 107 | |
| 108 | - if ( ! is_file($filename) ) { |
|
| 108 | + if ( ! is_file( $filename ) ) { |
|
| 109 | 109 | return; |
| 110 | 110 | } |
| 111 | 111 | |
@@ -114,10 +114,10 @@ discard block |
||
| 114 | 114 | $create_file = new FrmCreateFile( array( 'folder_name' => 'formidable/css', 'file_name' => 'formidablepro.css' ) ); |
| 115 | 115 | $create_file->create_file( $css ); |
| 116 | 116 | |
| 117 | - update_option('frmpro_css', $css); |
|
| 117 | + update_option( 'frmpro_css', $css ); |
|
| 118 | 118 | |
| 119 | - delete_transient('frmpro_css'); |
|
| 120 | - set_transient('frmpro_css', $css); |
|
| 119 | + delete_transient( 'frmpro_css' ); |
|
| 120 | + set_transient( 'frmpro_css', $css ); |
|
| 121 | 121 | } |
| 122 | 122 | |
| 123 | 123 | private function get_css_content( $filename ) { |
@@ -135,7 +135,7 @@ discard block |
||
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | public function destroy( $id ) { |
| 138 | - return wp_delete_post($id); |
|
| 138 | + return wp_delete_post( $id ); |
|
| 139 | 139 | } |
| 140 | 140 | |
| 141 | 141 | public function get_one() { |
@@ -149,19 +149,19 @@ discard block |
||
| 149 | 149 | return $style; |
| 150 | 150 | } |
| 151 | 151 | |
| 152 | - $style = get_post($this->id); |
|
| 152 | + $style = get_post( $this->id ); |
|
| 153 | 153 | |
| 154 | 154 | if ( ! $style ) { |
| 155 | 155 | return $style; |
| 156 | 156 | } |
| 157 | 157 | |
| 158 | - $style->post_content = FrmAppHelper::maybe_json_decode($style->post_content); |
|
| 158 | + $style->post_content = FrmAppHelper::maybe_json_decode( $style->post_content ); |
|
| 159 | 159 | |
| 160 | 160 | $default_values = $this->get_defaults(); |
| 161 | 161 | |
| 162 | 162 | // fill default values |
| 163 | - $style->post_content = $this->override_defaults($style->post_content); |
|
| 164 | - $style->post_content = wp_parse_args( $style->post_content, $default_values); |
|
| 163 | + $style->post_content = $this->override_defaults( $style->post_content ); |
|
| 164 | + $style->post_content = wp_parse_args( $style->post_content, $default_values ); |
|
| 165 | 165 | |
| 166 | 166 | return $style; |
| 167 | 167 | } |
@@ -175,21 +175,21 @@ discard block |
||
| 175 | 175 | 'order' => $order, |
| 176 | 176 | ); |
| 177 | 177 | |
| 178 | - $temp_styles = FrmAppHelper::check_cache(serialize($post_atts), 'frm_styles', $post_atts, 'get_posts'); |
|
| 178 | + $temp_styles = FrmAppHelper::check_cache( serialize( $post_atts ), 'frm_styles', $post_atts, 'get_posts' ); |
|
| 179 | 179 | |
| 180 | - if ( empty($temp_styles) ) { |
|
| 180 | + if ( empty( $temp_styles ) ) { |
|
| 181 | 181 | global $wpdb; |
| 182 | 182 | // make sure there wasn't a conflict with the query |
| 183 | 183 | $query = $wpdb->prepare( 'SELECT * FROM ' . $wpdb->posts . ' WHERE post_type=%s AND post_status=%s ORDER BY post_title ASC LIMIT 99', FrmStylesController::$post_type, 'publish' ); |
| 184 | - $temp_styles = FrmAppHelper::check_cache('frm_backup_style_check', 'frm_styles', $query, 'get_results'); |
|
| 184 | + $temp_styles = FrmAppHelper::check_cache( 'frm_backup_style_check', 'frm_styles', $query, 'get_results' ); |
|
| 185 | 185 | |
| 186 | - if ( empty($temp_styles) ) { |
|
| 186 | + if ( empty( $temp_styles ) ) { |
|
| 187 | 187 | // create a new style if there are none |
| 188 | 188 | $new = $this->get_new(); |
| 189 | 189 | $new->post_title = $new->post_name = __( 'Formidable Style', 'formidable' ); |
| 190 | 190 | $new->menu_order = 1; |
| 191 | - $new = $this->save( (array) $new); |
|
| 192 | - $this->update('default'); |
|
| 191 | + $new = $this->save( (array) $new ); |
|
| 192 | + $this->update( 'default' ); |
|
| 193 | 193 | |
| 194 | 194 | $post_atts['include'] = $new; |
| 195 | 195 | |
@@ -213,25 +213,25 @@ discard block |
||
| 213 | 213 | } |
| 214 | 214 | } |
| 215 | 215 | |
| 216 | - $style->post_content = FrmAppHelper::maybe_json_decode($style->post_content); |
|
| 216 | + $style->post_content = FrmAppHelper::maybe_json_decode( $style->post_content ); |
|
| 217 | 217 | |
| 218 | 218 | // fill default values |
| 219 | - $style->post_content = $this->override_defaults($style->post_content); |
|
| 220 | - $style->post_content = wp_parse_args( $style->post_content, $default_values); |
|
| 219 | + $style->post_content = $this->override_defaults( $style->post_content ); |
|
| 220 | + $style->post_content = wp_parse_args( $style->post_content, $default_values ); |
|
| 221 | 221 | |
| 222 | - $styles[ $style->ID ] = $style; |
|
| 222 | + $styles[$style->ID] = $style; |
|
| 223 | 223 | } |
| 224 | 224 | |
| 225 | 225 | if ( ! $default_style ) { |
| 226 | - $default_style = reset($styles); |
|
| 227 | - $styles[ $default_style->ID ]->menu_order = 1; |
|
| 226 | + $default_style = reset( $styles ); |
|
| 227 | + $styles[$default_style->ID]->menu_order = 1; |
|
| 228 | 228 | } |
| 229 | 229 | |
| 230 | 230 | return $styles; |
| 231 | 231 | } |
| 232 | 232 | |
| 233 | 233 | public function get_default_style( $styles = null ) { |
| 234 | - if ( ! isset($styles) ) { |
|
| 234 | + if ( ! isset( $styles ) ) { |
|
| 235 | 235 | $styles = $this->get_all( 'menu_order', 'DESC', 1 ); |
| 236 | 236 | } |
| 237 | 237 | |
@@ -243,24 +243,24 @@ discard block |
||
| 243 | 243 | } |
| 244 | 244 | |
| 245 | 245 | public function override_defaults( $settings ) { |
| 246 | - if ( ! is_array($settings) ) { |
|
| 246 | + if ( ! is_array( $settings ) ) { |
|
| 247 | 247 | return $settings; |
| 248 | 248 | } |
| 249 | 249 | |
| 250 | - $settings['line_height'] = ( ! isset($settings['field_height']) || $settings['field_height'] == '' || $settings['field_height'] == 'auto') ? 'normal' : $settings['field_height']; |
|
| 250 | + $settings['line_height'] = ( ! isset( $settings['field_height'] ) || $settings['field_height'] == '' || $settings['field_height'] == 'auto' ) ? 'normal' : $settings['field_height']; |
|
| 251 | 251 | |
| 252 | - if ( ! isset($settings['form_desc_size']) && isset($settings['description_font_size']) ) { |
|
| 252 | + if ( ! isset( $settings['form_desc_size'] ) && isset( $settings['description_font_size'] ) ) { |
|
| 253 | 253 | $settings['form_desc_size'] = $settings['description_font_size']; |
| 254 | 254 | $settings['form_desc_color'] = $settings['description_color']; |
| 255 | 255 | $settings['title_color'] = $settings['label_color']; |
| 256 | 256 | } |
| 257 | 257 | |
| 258 | - if ( ! isset($settings['section_color']) && isset($settings['label_color']) ) { |
|
| 258 | + if ( ! isset( $settings['section_color'] ) && isset( $settings['label_color'] ) ) { |
|
| 259 | 259 | $settings['section_color'] = $settings['label_color']; |
| 260 | 260 | $settings['section_border_color'] = $settings['border_color']; |
| 261 | 261 | } |
| 262 | 262 | |
| 263 | - if ( ! isset($settings['submit_hover_bg_color']) && isset($settings['submit_bg_color']) ) { |
|
| 263 | + if ( ! isset( $settings['submit_hover_bg_color'] ) && isset( $settings['submit_bg_color'] ) ) { |
|
| 264 | 264 | $settings['submit_hover_bg_color'] = $settings['submit_bg_color']; |
| 265 | 265 | $settings['submit_hover_color'] = $settings['submit_text_color']; |
| 266 | 266 | $settings['submit_hover_border_color'] = $settings['submit_border_color']; |
@@ -1,26 +1,26 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | class FrmEntryValidate { |
| 4 | - public static function validate( $values, $exclude = false ) { |
|
| 5 | - global $wpdb; |
|
| 4 | + public static function validate( $values, $exclude = false ) { |
|
| 5 | + global $wpdb; |
|
| 6 | 6 | |
| 7 | - FrmEntry::sanitize_entry_post( $values ); |
|
| 8 | - $errors = array(); |
|
| 7 | + FrmEntry::sanitize_entry_post( $values ); |
|
| 8 | + $errors = array(); |
|
| 9 | 9 | |
| 10 | - if ( ! isset($values['form_id']) || ! isset($values['item_meta']) ) { |
|
| 11 | - $errors['form'] = __( 'There was a problem with your submission. Please try again.', 'formidable' ); |
|
| 12 | - return $errors; |
|
| 13 | - } |
|
| 10 | + if ( ! isset($values['form_id']) || ! isset($values['item_meta']) ) { |
|
| 11 | + $errors['form'] = __( 'There was a problem with your submission. Please try again.', 'formidable' ); |
|
| 12 | + return $errors; |
|
| 13 | + } |
|
| 14 | 14 | |
| 15 | 15 | if ( FrmAppHelper::is_admin() && is_user_logged_in() && ( ! isset( $values[ 'frm_submit_entry_' . $values['form_id'] ] ) || ! wp_verify_nonce( $values[ 'frm_submit_entry_' . $values['form_id'] ], 'frm_submit_entry_nonce' ) ) ) { |
| 16 | - $errors['form'] = __( 'You do not have permission to do that', 'formidable' ); |
|
| 17 | - } |
|
| 16 | + $errors['form'] = __( 'You do not have permission to do that', 'formidable' ); |
|
| 17 | + } |
|
| 18 | 18 | |
| 19 | - if ( ! isset($values['item_key']) || $values['item_key'] == '' ) { |
|
| 19 | + if ( ! isset($values['item_key']) || $values['item_key'] == '' ) { |
|
| 20 | 20 | $_POST['item_key'] = $values['item_key'] = FrmAppHelper::get_unique_key( '', $wpdb->prefix . 'frm_items', 'item_key' ); |
| 21 | - } |
|
| 21 | + } |
|
| 22 | 22 | |
| 23 | - $where = apply_filters('frm_posted_field_ids', array( 'fi.form_id' => $values['form_id'] ) ); |
|
| 23 | + $where = apply_filters('frm_posted_field_ids', array( 'fi.form_id' => $values['form_id'] ) ); |
|
| 24 | 24 | // Don't get subfields |
| 25 | 25 | $where['fr.parent_form_id'] = array( null, 0 ); |
| 26 | 26 | // Don't get excluded fields (like file upload fields in the ajax validation) |
@@ -28,42 +28,42 @@ discard block |
||
| 28 | 28 | $where['fi.type not'] = $exclude; |
| 29 | 29 | } |
| 30 | 30 | |
| 31 | - $posted_fields = FrmField::getAll($where, 'field_order'); |
|
| 31 | + $posted_fields = FrmField::getAll($where, 'field_order'); |
|
| 32 | 32 | |
| 33 | - // Pass exclude value to validate_field function so it can be used for repeating sections |
|
| 34 | - $args = array( 'exclude' => $exclude ); |
|
| 33 | + // Pass exclude value to validate_field function so it can be used for repeating sections |
|
| 34 | + $args = array( 'exclude' => $exclude ); |
|
| 35 | 35 | |
| 36 | - foreach ( $posted_fields as $posted_field ) { |
|
| 37 | - self::validate_field($posted_field, $errors, $values, $args); |
|
| 38 | - unset($posted_field); |
|
| 39 | - } |
|
| 36 | + foreach ( $posted_fields as $posted_field ) { |
|
| 37 | + self::validate_field($posted_field, $errors, $values, $args); |
|
| 38 | + unset($posted_field); |
|
| 39 | + } |
|
| 40 | 40 | |
| 41 | - // check for spam |
|
| 42 | - self::spam_check( $exclude, $values, $errors ); |
|
| 41 | + // check for spam |
|
| 42 | + self::spam_check( $exclude, $values, $errors ); |
|
| 43 | 43 | |
| 44 | - $errors = apply_filters( 'frm_validate_entry', $errors, $values, compact('exclude') ); |
|
| 44 | + $errors = apply_filters( 'frm_validate_entry', $errors, $values, compact('exclude') ); |
|
| 45 | 45 | |
| 46 | - return $errors; |
|
| 47 | - } |
|
| 46 | + return $errors; |
|
| 47 | + } |
|
| 48 | 48 | |
| 49 | - public static function validate_field( $posted_field, &$errors, $values, $args = array() ) { |
|
| 50 | - $defaults = array( |
|
| 51 | - 'id' => $posted_field->id, |
|
| 52 | - 'parent_field_id' => '', // the id of the repeat or embed form |
|
| 53 | - 'key_pointer' => '', // the pointer in the posted array |
|
| 54 | - 'exclude' => array(), // exclude these field types from validation |
|
| 55 | - ); |
|
| 56 | - $args = wp_parse_args( $args, $defaults ); |
|
| 49 | + public static function validate_field( $posted_field, &$errors, $values, $args = array() ) { |
|
| 50 | + $defaults = array( |
|
| 51 | + 'id' => $posted_field->id, |
|
| 52 | + 'parent_field_id' => '', // the id of the repeat or embed form |
|
| 53 | + 'key_pointer' => '', // the pointer in the posted array |
|
| 54 | + 'exclude' => array(), // exclude these field types from validation |
|
| 55 | + ); |
|
| 56 | + $args = wp_parse_args( $args, $defaults ); |
|
| 57 | 57 | |
| 58 | - if ( empty($args['parent_field_id']) ) { |
|
| 58 | + if ( empty($args['parent_field_id']) ) { |
|
| 59 | 59 | $value = isset( $values['item_meta'][ $args['id'] ] ) ? $values['item_meta'][ $args['id'] ] : ''; |
| 60 | - } else { |
|
| 61 | - // value is from a nested form |
|
| 62 | - $value = $values; |
|
| 63 | - } |
|
| 60 | + } else { |
|
| 61 | + // value is from a nested form |
|
| 62 | + $value = $values; |
|
| 63 | + } |
|
| 64 | 64 | |
| 65 | - // Check for values in "Other" fields |
|
| 66 | - FrmEntriesHelper::maybe_set_other_validation( $posted_field, $value, $args ); |
|
| 65 | + // Check for values in "Other" fields |
|
| 66 | + FrmEntriesHelper::maybe_set_other_validation( $posted_field, $value, $args ); |
|
| 67 | 67 | |
| 68 | 68 | self::maybe_clear_value_for_default_blank_setting( $posted_field, $value ); |
| 69 | 69 | |
@@ -72,11 +72,11 @@ discard block |
||
| 72 | 72 | $value = reset($value); |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | - if ( $posted_field->required == '1' && ! is_array( $value ) && trim( $value ) == '' ) { |
|
| 75 | + if ( $posted_field->required == '1' && ! is_array( $value ) && trim( $value ) == '' ) { |
|
| 76 | 76 | $errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $posted_field, 'blank' ); |
| 77 | - } else if ( $posted_field->type == 'text' && ! isset( $_POST['item_name'] ) ) { |
|
| 78 | - $_POST['item_name'] = $value; |
|
| 79 | - } |
|
| 77 | + } else if ( $posted_field->type == 'text' && ! isset( $_POST['item_name'] ) ) { |
|
| 78 | + $_POST['item_name'] = $value; |
|
| 79 | + } |
|
| 80 | 80 | |
| 81 | 81 | if ( $value != '' ) { |
| 82 | 82 | self::validate_url_field( $errors, $posted_field, $value, $args ); |
@@ -85,13 +85,13 @@ discard block |
||
| 85 | 85 | self::validate_phone_field( $errors, $posted_field, $value, $args ); |
| 86 | 86 | } |
| 87 | 87 | |
| 88 | - FrmEntriesHelper::set_posted_value($posted_field, $value, $args); |
|
| 88 | + FrmEntriesHelper::set_posted_value($posted_field, $value, $args); |
|
| 89 | 89 | |
| 90 | - self::validate_recaptcha($errors, $posted_field, $args); |
|
| 90 | + self::validate_recaptcha($errors, $posted_field, $args); |
|
| 91 | 91 | |
| 92 | 92 | $errors = apply_filters( 'frm_validate_' . $posted_field->type . '_field_entry', $errors, $posted_field, $value, $args ); |
| 93 | 93 | $errors = apply_filters( 'frm_validate_field_entry', $errors, $posted_field, $value, $args ); |
| 94 | - } |
|
| 94 | + } |
|
| 95 | 95 | |
| 96 | 96 | private static function maybe_clear_value_for_default_blank_setting( $field, &$value ) { |
| 97 | 97 | if ( FrmField::is_option_true_in_object( $field, 'default_blank' ) && $value == $field->default_value ) { |
@@ -101,32 +101,32 @@ discard block |
||
| 101 | 101 | |
| 102 | 102 | public static function validate_url_field( &$errors, $field, &$value, $args ) { |
| 103 | 103 | if ( $value == '' || ! in_array( $field->type, array( 'website', 'url', 'image' ) ) ) { |
| 104 | - return; |
|
| 105 | - } |
|
| 104 | + return; |
|
| 105 | + } |
|
| 106 | 106 | |
| 107 | - if ( trim($value) == 'http://' ) { |
|
| 108 | - $value = ''; |
|
| 109 | - } else { |
|
| 110 | - $value = esc_url_raw( $value ); |
|
| 107 | + if ( trim($value) == 'http://' ) { |
|
| 108 | + $value = ''; |
|
| 109 | + } else { |
|
| 110 | + $value = esc_url_raw( $value ); |
|
| 111 | 111 | $value = preg_match( '/^(https?|ftps?|mailto|news|feed|telnet):/is', $value ) ? $value : 'http://' . $value; |
| 112 | - } |
|
| 112 | + } |
|
| 113 | 113 | |
| 114 | - //validate the url format |
|
| 115 | - if ( ! preg_match('/^http(s)?:\/\/([\da-z\.-]+)\.([\da-z\.-]+)/i', $value) ) { |
|
| 114 | + //validate the url format |
|
| 115 | + if ( ! preg_match('/^http(s)?:\/\/([\da-z\.-]+)\.([\da-z\.-]+)/i', $value) ) { |
|
| 116 | 116 | $errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $field, 'invalid' ); |
| 117 | - } |
|
| 118 | - } |
|
| 117 | + } |
|
| 118 | + } |
|
| 119 | 119 | |
| 120 | 120 | public static function validate_email_field( &$errors, $field, $value, $args ) { |
| 121 | - if ( $value == '' || $field->type != 'email' ) { |
|
| 122 | - return; |
|
| 123 | - } |
|
| 121 | + if ( $value == '' || $field->type != 'email' ) { |
|
| 122 | + return; |
|
| 123 | + } |
|
| 124 | 124 | |
| 125 | - //validate the email format |
|
| 126 | - if ( ! is_email($value) ) { |
|
| 125 | + //validate the email format |
|
| 126 | + if ( ! is_email($value) ) { |
|
| 127 | 127 | $errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $field, 'invalid' ); |
| 128 | - } |
|
| 129 | - } |
|
| 128 | + } |
|
| 129 | + } |
|
| 130 | 130 | |
| 131 | 131 | public static function validate_number_field( &$errors, $field, $value, $args ) { |
| 132 | 132 | //validate the number format |
@@ -203,9 +203,9 @@ discard block |
||
| 203 | 203 | } |
| 204 | 204 | |
| 205 | 205 | public static function validate_recaptcha( &$errors, $field, $args ) { |
| 206 | - if ( $field->type != 'captcha' || FrmAppHelper::is_admin() || apply_filters( 'frm_is_field_hidden', false, $field, stripslashes_deep( $_POST ) ) ) { |
|
| 207 | - return; |
|
| 208 | - } |
|
| 206 | + if ( $field->type != 'captcha' || FrmAppHelper::is_admin() || apply_filters( 'frm_is_field_hidden', false, $field, stripslashes_deep( $_POST ) ) ) { |
|
| 207 | + return; |
|
| 208 | + } |
|
| 209 | 209 | |
| 210 | 210 | $frm_settings = FrmAppHelper::get_settings(); |
| 211 | 211 | if ( empty( $frm_settings->pubkey ) ) { |
@@ -213,57 +213,57 @@ discard block |
||
| 213 | 213 | return; |
| 214 | 214 | } |
| 215 | 215 | |
| 216 | - if ( ! isset($_POST['g-recaptcha-response']) ) { |
|
| 217 | - // If captcha is missing, check if it was already verified |
|
| 216 | + if ( ! isset($_POST['g-recaptcha-response']) ) { |
|
| 217 | + // If captcha is missing, check if it was already verified |
|
| 218 | 218 | if ( ! isset( $_POST['recaptcha_checked'] ) || ! wp_verify_nonce( $_POST['recaptcha_checked'], 'frm_ajax' ) ) { |
| 219 | - // There was no captcha submitted |
|
| 219 | + // There was no captcha submitted |
|
| 220 | 220 | $errors[ 'field' . $args['id'] ] = __( 'The captcha is missing from this form', 'formidable' ); |
| 221 | - } |
|
| 222 | - return; |
|
| 223 | - } |
|
| 221 | + } |
|
| 222 | + return; |
|
| 223 | + } |
|
| 224 | 224 | |
| 225 | - $arg_array = array( |
|
| 226 | - 'body' => array( |
|
| 225 | + $arg_array = array( |
|
| 226 | + 'body' => array( |
|
| 227 | 227 | 'secret' => $frm_settings->privkey, |
| 228 | 228 | 'response' => $_POST['g-recaptcha-response'], |
| 229 | 229 | 'remoteip' => FrmAppHelper::get_ip_address(), |
| 230 | 230 | ), |
| 231 | 231 | ); |
| 232 | - $resp = wp_remote_post( 'https://www.google.com/recaptcha/api/siteverify', $arg_array ); |
|
| 233 | - $response = json_decode(wp_remote_retrieve_body( $resp ), true); |
|
| 232 | + $resp = wp_remote_post( 'https://www.google.com/recaptcha/api/siteverify', $arg_array ); |
|
| 233 | + $response = json_decode(wp_remote_retrieve_body( $resp ), true); |
|
| 234 | 234 | |
| 235 | - if ( isset( $response['success'] ) && ! $response['success'] ) { |
|
| 236 | - // What happens when the CAPTCHA was entered incorrectly |
|
| 235 | + if ( isset( $response['success'] ) && ! $response['success'] ) { |
|
| 236 | + // What happens when the CAPTCHA was entered incorrectly |
|
| 237 | 237 | $errors[ 'field' . $args['id'] ] = ( ! isset( $field->field_options['invalid'] ) || $field->field_options['invalid'] == '' ) ? $frm_settings->re_msg : $field->field_options['invalid']; |
| 238 | - } else if ( is_wp_error( $resp ) ) { |
|
| 238 | + } else if ( is_wp_error( $resp ) ) { |
|
| 239 | 239 | $error_string = $resp->get_error_message(); |
| 240 | 240 | $errors[ 'field' . $args['id'] ] = __( 'There was a problem verifying your recaptcha', 'formidable' ); |
| 241 | 241 | $errors[ 'field' . $args['id'] ] .= ' ' . $error_string; |
| 242 | - } |
|
| 243 | - } |
|
| 244 | - |
|
| 245 | - /** |
|
| 246 | - * check for spam |
|
| 247 | - * @param boolean $exclude |
|
| 248 | - * @param array $values |
|
| 249 | - * @param array $errors by reference |
|
| 250 | - */ |
|
| 251 | - public static function spam_check( $exclude, $values, &$errors ) { |
|
| 252 | - if ( ! empty( $exclude ) || ! isset( $values['item_meta'] ) || empty( $values['item_meta'] ) || ! empty( $errors ) ) { |
|
| 253 | - // only check spam if there are no other errors |
|
| 254 | - return; |
|
| 255 | - } |
|
| 256 | - |
|
| 257 | - if ( self::is_akismet_spam( $values ) ) { |
|
| 242 | + } |
|
| 243 | + } |
|
| 244 | + |
|
| 245 | + /** |
|
| 246 | + * check for spam |
|
| 247 | + * @param boolean $exclude |
|
| 248 | + * @param array $values |
|
| 249 | + * @param array $errors by reference |
|
| 250 | + */ |
|
| 251 | + public static function spam_check( $exclude, $values, &$errors ) { |
|
| 252 | + if ( ! empty( $exclude ) || ! isset( $values['item_meta'] ) || empty( $values['item_meta'] ) || ! empty( $errors ) ) { |
|
| 253 | + // only check spam if there are no other errors |
|
| 254 | + return; |
|
| 255 | + } |
|
| 256 | + |
|
| 257 | + if ( self::is_akismet_spam( $values ) ) { |
|
| 258 | 258 | if ( self::is_akismet_enabled_for_user( $values['form_id'] ) ) { |
| 259 | 259 | $errors['spam'] = __( 'Your entry appears to be spam!', 'formidable' ); |
| 260 | 260 | } |
| 261 | - } |
|
| 261 | + } |
|
| 262 | 262 | |
| 263 | - if ( self::blacklist_check( $values ) ) { |
|
| 264 | - $errors['spam'] = __( 'Your entry appears to be spam!', 'formidable' ); |
|
| 265 | - } |
|
| 266 | - } |
|
| 263 | + if ( self::blacklist_check( $values ) ) { |
|
| 264 | + $errors['spam'] = __( 'Your entry appears to be spam!', 'formidable' ); |
|
| 265 | + } |
|
| 266 | + } |
|
| 267 | 267 | |
| 268 | 268 | private static function is_akismet_spam( $values ) { |
| 269 | 269 | global $wpcom_api_key; |
@@ -275,54 +275,54 @@ discard block |
||
| 275 | 275 | return ( isset( $form->options['akismet'] ) && ! empty( $form->options['akismet'] ) && ( $form->options['akismet'] != 'logged' || ! is_user_logged_in() ) ); |
| 276 | 276 | } |
| 277 | 277 | |
| 278 | - public static function blacklist_check( $values ) { |
|
| 279 | - if ( ! apply_filters('frm_check_blacklist', true, $values) ) { |
|
| 280 | - return false; |
|
| 281 | - } |
|
| 278 | + public static function blacklist_check( $values ) { |
|
| 279 | + if ( ! apply_filters('frm_check_blacklist', true, $values) ) { |
|
| 280 | + return false; |
|
| 281 | + } |
|
| 282 | 282 | |
| 283 | - $mod_keys = trim( get_option( 'blacklist_keys' ) ); |
|
| 283 | + $mod_keys = trim( get_option( 'blacklist_keys' ) ); |
|
| 284 | 284 | |
| 285 | - if ( empty( $mod_keys ) ) { |
|
| 286 | - return false; |
|
| 287 | - } |
|
| 285 | + if ( empty( $mod_keys ) ) { |
|
| 286 | + return false; |
|
| 287 | + } |
|
| 288 | 288 | |
| 289 | - $content = FrmEntriesHelper::entry_array_to_string($values); |
|
| 289 | + $content = FrmEntriesHelper::entry_array_to_string($values); |
|
| 290 | 290 | |
| 291 | 291 | if ( empty($content) ) { |
| 292 | - return false; |
|
| 292 | + return false; |
|
| 293 | 293 | } |
| 294 | 294 | |
| 295 | - $words = explode( "\n", $mod_keys ); |
|
| 295 | + $words = explode( "\n", $mod_keys ); |
|
| 296 | 296 | |
| 297 | - foreach ( (array) $words as $word ) { |
|
| 298 | - $word = trim( $word ); |
|
| 297 | + foreach ( (array) $words as $word ) { |
|
| 298 | + $word = trim( $word ); |
|
| 299 | 299 | |
| 300 | - if ( empty($word) ) { |
|
| 301 | - continue; |
|
| 302 | - } |
|
| 300 | + if ( empty($word) ) { |
|
| 301 | + continue; |
|
| 302 | + } |
|
| 303 | 303 | |
| 304 | - if ( preg_match('#' . preg_quote( $word, '#' ) . '#', $content) ) { |
|
| 305 | - return true; |
|
| 306 | - } |
|
| 307 | - } |
|
| 304 | + if ( preg_match('#' . preg_quote( $word, '#' ) . '#', $content) ) { |
|
| 305 | + return true; |
|
| 306 | + } |
|
| 307 | + } |
|
| 308 | 308 | |
| 309 | - return false; |
|
| 310 | - } |
|
| 309 | + return false; |
|
| 310 | + } |
|
| 311 | 311 | |
| 312 | - /** |
|
| 313 | - * Check entries for spam |
|
| 314 | - * |
|
| 315 | - * @return boolean true if is spam |
|
| 316 | - */ |
|
| 317 | - public static function akismet( $values ) { |
|
| 318 | - $content = FrmEntriesHelper::entry_array_to_string( $values ); |
|
| 312 | + /** |
|
| 313 | + * Check entries for spam |
|
| 314 | + * |
|
| 315 | + * @return boolean true if is spam |
|
| 316 | + */ |
|
| 317 | + public static function akismet( $values ) { |
|
| 318 | + $content = FrmEntriesHelper::entry_array_to_string( $values ); |
|
| 319 | 319 | |
| 320 | 320 | if ( empty( $content ) ) { |
| 321 | - return false; |
|
| 321 | + return false; |
|
| 322 | 322 | } |
| 323 | 323 | |
| 324 | - $datas = array(); |
|
| 325 | - self::parse_akismet_array( $datas, $content ); |
|
| 324 | + $datas = array(); |
|
| 325 | + self::parse_akismet_array( $datas, $content ); |
|
| 326 | 326 | |
| 327 | 327 | $query_string = ''; |
| 328 | 328 | foreach ( $datas as $key => $data ) { |
@@ -330,35 +330,35 @@ discard block |
||
| 330 | 330 | unset( $key, $data ); |
| 331 | 331 | } |
| 332 | 332 | |
| 333 | - $response = Akismet::http_post($query_string, 'comment-check'); |
|
| 333 | + $response = Akismet::http_post($query_string, 'comment-check'); |
|
| 334 | 334 | |
| 335 | 335 | return ( is_array( $response ) && $response[1] == 'true' ); |
| 336 | - } |
|
| 337 | - |
|
| 338 | - /** |
|
| 339 | - * @since 2.0 |
|
| 340 | - * @param string $content |
|
| 341 | - */ |
|
| 342 | - private static function parse_akismet_array( &$datas, $content ) { |
|
| 343 | - $datas['blog'] = FrmAppHelper::site_url(); |
|
| 344 | - $datas['user_ip'] = preg_replace( '/[^0-9., ]/', '', FrmAppHelper::get_ip_address() ); |
|
| 336 | + } |
|
| 337 | + |
|
| 338 | + /** |
|
| 339 | + * @since 2.0 |
|
| 340 | + * @param string $content |
|
| 341 | + */ |
|
| 342 | + private static function parse_akismet_array( &$datas, $content ) { |
|
| 343 | + $datas['blog'] = FrmAppHelper::site_url(); |
|
| 344 | + $datas['user_ip'] = preg_replace( '/[^0-9., ]/', '', FrmAppHelper::get_ip_address() ); |
|
| 345 | 345 | $datas['user_agent'] = FrmAppHelper::get_server_value( 'HTTP_USER_AGENT' ); |
| 346 | 346 | $datas['referrer'] = isset( $_SERVER['HTTP_REFERER'] ) ? FrmAppHelper::get_server_value( 'HTTP_REFERER' ) : false; |
| 347 | - $datas['comment_type'] = 'formidable'; |
|
| 348 | - $datas['comment_content'] = $content; |
|
| 347 | + $datas['comment_type'] = 'formidable'; |
|
| 348 | + $datas['comment_content'] = $content; |
|
| 349 | 349 | |
| 350 | - if ( $permalink = get_permalink() ) { |
|
| 351 | - $datas['permalink'] = $permalink; |
|
| 352 | - } |
|
| 350 | + if ( $permalink = get_permalink() ) { |
|
| 351 | + $datas['permalink'] = $permalink; |
|
| 352 | + } |
|
| 353 | 353 | |
| 354 | - foreach ( $_SERVER as $key => $value ) { |
|
| 354 | + foreach ( $_SERVER as $key => $value ) { |
|
| 355 | 355 | if ( ! in_array( $key, array( 'HTTP_COOKIE', 'HTTP_COOKIE2', 'PHP_AUTH_PW' ) ) && is_string( $value ) ) { |
| 356 | 356 | $datas[ $key ] = wp_strip_all_tags( $value ); |
| 357 | - } else { |
|
| 357 | + } else { |
|
| 358 | 358 | $datas[ $key ] = ''; |
| 359 | - } |
|
| 359 | + } |
|
| 360 | 360 | |
| 361 | - unset($key, $value); |
|
| 362 | - } |
|
| 363 | - } |
|
| 361 | + unset($key, $value); |
|
| 362 | + } |
|
| 363 | + } |
|
| 364 | 364 | } |
@@ -7,20 +7,20 @@ discard block |
||
| 7 | 7 | FrmEntry::sanitize_entry_post( $values ); |
| 8 | 8 | $errors = array(); |
| 9 | 9 | |
| 10 | - if ( ! isset($values['form_id']) || ! isset($values['item_meta']) ) { |
|
| 10 | + if ( ! isset( $values['form_id'] ) || ! isset( $values['item_meta'] ) ) { |
|
| 11 | 11 | $errors['form'] = __( 'There was a problem with your submission. Please try again.', 'formidable' ); |
| 12 | 12 | return $errors; |
| 13 | 13 | } |
| 14 | 14 | |
| 15 | - if ( FrmAppHelper::is_admin() && is_user_logged_in() && ( ! isset( $values[ 'frm_submit_entry_' . $values['form_id'] ] ) || ! wp_verify_nonce( $values[ 'frm_submit_entry_' . $values['form_id'] ], 'frm_submit_entry_nonce' ) ) ) { |
|
| 15 | + if ( FrmAppHelper::is_admin() && is_user_logged_in() && ( ! isset( $values['frm_submit_entry_' . $values['form_id']] ) || ! wp_verify_nonce( $values['frm_submit_entry_' . $values['form_id']], 'frm_submit_entry_nonce' ) ) ) { |
|
| 16 | 16 | $errors['form'] = __( 'You do not have permission to do that', 'formidable' ); |
| 17 | 17 | } |
| 18 | 18 | |
| 19 | - if ( ! isset($values['item_key']) || $values['item_key'] == '' ) { |
|
| 19 | + if ( ! isset( $values['item_key'] ) || $values['item_key'] == '' ) { |
|
| 20 | 20 | $_POST['item_key'] = $values['item_key'] = FrmAppHelper::get_unique_key( '', $wpdb->prefix . 'frm_items', 'item_key' ); |
| 21 | 21 | } |
| 22 | 22 | |
| 23 | - $where = apply_filters('frm_posted_field_ids', array( 'fi.form_id' => $values['form_id'] ) ); |
|
| 23 | + $where = apply_filters( 'frm_posted_field_ids', array( 'fi.form_id' => $values['form_id'] ) ); |
|
| 24 | 24 | // Don't get subfields |
| 25 | 25 | $where['fr.parent_form_id'] = array( null, 0 ); |
| 26 | 26 | // Don't get excluded fields (like file upload fields in the ajax validation) |
@@ -28,20 +28,20 @@ discard block |
||
| 28 | 28 | $where['fi.type not'] = $exclude; |
| 29 | 29 | } |
| 30 | 30 | |
| 31 | - $posted_fields = FrmField::getAll($where, 'field_order'); |
|
| 31 | + $posted_fields = FrmField::getAll( $where, 'field_order' ); |
|
| 32 | 32 | |
| 33 | 33 | // Pass exclude value to validate_field function so it can be used for repeating sections |
| 34 | 34 | $args = array( 'exclude' => $exclude ); |
| 35 | 35 | |
| 36 | 36 | foreach ( $posted_fields as $posted_field ) { |
| 37 | - self::validate_field($posted_field, $errors, $values, $args); |
|
| 38 | - unset($posted_field); |
|
| 37 | + self::validate_field( $posted_field, $errors, $values, $args ); |
|
| 38 | + unset( $posted_field ); |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | // check for spam |
| 42 | 42 | self::spam_check( $exclude, $values, $errors ); |
| 43 | 43 | |
| 44 | - $errors = apply_filters( 'frm_validate_entry', $errors, $values, compact('exclude') ); |
|
| 44 | + $errors = apply_filters( 'frm_validate_entry', $errors, $values, compact( 'exclude' ) ); |
|
| 45 | 45 | |
| 46 | 46 | return $errors; |
| 47 | 47 | } |
@@ -55,8 +55,8 @@ discard block |
||
| 55 | 55 | ); |
| 56 | 56 | $args = wp_parse_args( $args, $defaults ); |
| 57 | 57 | |
| 58 | - if ( empty($args['parent_field_id']) ) { |
|
| 59 | - $value = isset( $values['item_meta'][ $args['id'] ] ) ? $values['item_meta'][ $args['id'] ] : ''; |
|
| 58 | + if ( empty( $args['parent_field_id'] ) ) { |
|
| 59 | + $value = isset( $values['item_meta'][$args['id']] ) ? $values['item_meta'][$args['id']] : ''; |
|
| 60 | 60 | } else { |
| 61 | 61 | // value is from a nested form |
| 62 | 62 | $value = $values; |
@@ -68,12 +68,12 @@ discard block |
||
| 68 | 68 | self::maybe_clear_value_for_default_blank_setting( $posted_field, $value ); |
| 69 | 69 | |
| 70 | 70 | // Reset arrays with only one value if it's not a field where array keys need to be preserved |
| 71 | - if ( is_array($value) && count( $value ) == 1 && isset( $value[0] ) ) { |
|
| 72 | - $value = reset($value); |
|
| 71 | + if ( is_array( $value ) && count( $value ) == 1 && isset( $value[0] ) ) { |
|
| 72 | + $value = reset( $value ); |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | if ( $posted_field->required == '1' && ! is_array( $value ) && trim( $value ) == '' ) { |
| 76 | - $errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $posted_field, 'blank' ); |
|
| 76 | + $errors['field' . $args['id']] = FrmFieldsHelper::get_error_msg( $posted_field, 'blank' ); |
|
| 77 | 77 | } else if ( $posted_field->type == 'text' && ! isset( $_POST['item_name'] ) ) { |
| 78 | 78 | $_POST['item_name'] = $value; |
| 79 | 79 | } |
@@ -85,9 +85,9 @@ discard block |
||
| 85 | 85 | self::validate_phone_field( $errors, $posted_field, $value, $args ); |
| 86 | 86 | } |
| 87 | 87 | |
| 88 | - FrmEntriesHelper::set_posted_value($posted_field, $value, $args); |
|
| 88 | + FrmEntriesHelper::set_posted_value( $posted_field, $value, $args ); |
|
| 89 | 89 | |
| 90 | - self::validate_recaptcha($errors, $posted_field, $args); |
|
| 90 | + self::validate_recaptcha( $errors, $posted_field, $args ); |
|
| 91 | 91 | |
| 92 | 92 | $errors = apply_filters( 'frm_validate_' . $posted_field->type . '_field_entry', $errors, $posted_field, $value, $args ); |
| 93 | 93 | $errors = apply_filters( 'frm_validate_field_entry', $errors, $posted_field, $value, $args ); |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | return; |
| 105 | 105 | } |
| 106 | 106 | |
| 107 | - if ( trim($value) == 'http://' ) { |
|
| 107 | + if ( trim( $value ) == 'http://' ) { |
|
| 108 | 108 | $value = ''; |
| 109 | 109 | } else { |
| 110 | 110 | $value = esc_url_raw( $value ); |
@@ -112,8 +112,8 @@ discard block |
||
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | //validate the url format |
| 115 | - if ( ! preg_match('/^http(s)?:\/\/([\da-z\.-]+)\.([\da-z\.-]+)/i', $value) ) { |
|
| 116 | - $errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $field, 'invalid' ); |
|
| 115 | + if ( ! preg_match( '/^http(s)?:\/\/([\da-z\.-]+)\.([\da-z\.-]+)/i', $value ) ) { |
|
| 116 | + $errors['field' . $args['id']] = FrmFieldsHelper::get_error_msg( $field, 'invalid' ); |
|
| 117 | 117 | } |
| 118 | 118 | } |
| 119 | 119 | |
@@ -123,8 +123,8 @@ discard block |
||
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | //validate the email format |
| 126 | - if ( ! is_email($value) ) { |
|
| 127 | - $errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $field, 'invalid' ); |
|
| 126 | + if ( ! is_email( $value ) ) { |
|
| 127 | + $errors['field' . $args['id']] = FrmFieldsHelper::get_error_msg( $field, 'invalid' ); |
|
| 128 | 128 | } |
| 129 | 129 | } |
| 130 | 130 | |
@@ -134,8 +134,8 @@ discard block |
||
| 134 | 134 | return; |
| 135 | 135 | } |
| 136 | 136 | |
| 137 | - if ( ! is_numeric( $value) ) { |
|
| 138 | - $errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $field, 'invalid' ); |
|
| 137 | + if ( ! is_numeric( $value ) ) { |
|
| 138 | + $errors['field' . $args['id']] = FrmFieldsHelper::get_error_msg( $field, 'invalid' ); |
|
| 139 | 139 | } |
| 140 | 140 | |
| 141 | 141 | // validate number settings |
@@ -145,9 +145,9 @@ discard block |
||
| 145 | 145 | if ( $frm_settings->use_html && isset( $field->field_options['minnum'] ) && isset( $field->field_options['maxnum'] ) ) { |
| 146 | 146 | //minnum maxnum |
| 147 | 147 | if ( (float) $value < $field->field_options['minnum'] ) { |
| 148 | - $errors[ 'field' . $args['id'] ] = __( 'Please select a higher number', 'formidable' ); |
|
| 148 | + $errors['field' . $args['id']] = __( 'Please select a higher number', 'formidable' ); |
|
| 149 | 149 | } else if ( (float) $value > $field->field_options['maxnum'] ) { |
| 150 | - $errors[ 'field' . $args['id'] ] = __( 'Please select a lower number', 'formidable' ); |
|
| 150 | + $errors['field' . $args['id']] = __( 'Please select a lower number', 'formidable' ); |
|
| 151 | 151 | } |
| 152 | 152 | } |
| 153 | 153 | } |
@@ -161,7 +161,7 @@ discard block |
||
| 161 | 161 | $pattern = self::phone_format( $field ); |
| 162 | 162 | |
| 163 | 163 | if ( ! preg_match( $pattern, $value ) ) { |
| 164 | - $errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $field, 'invalid' ); |
|
| 164 | + $errors['field' . $args['id']] = FrmFieldsHelper::get_error_msg( $field, 'invalid' ); |
|
| 165 | 165 | } |
| 166 | 166 | } |
| 167 | 167 | |
@@ -213,11 +213,11 @@ discard block |
||
| 213 | 213 | return; |
| 214 | 214 | } |
| 215 | 215 | |
| 216 | - if ( ! isset($_POST['g-recaptcha-response']) ) { |
|
| 216 | + if ( ! isset( $_POST['g-recaptcha-response'] ) ) { |
|
| 217 | 217 | // If captcha is missing, check if it was already verified |
| 218 | 218 | if ( ! isset( $_POST['recaptcha_checked'] ) || ! wp_verify_nonce( $_POST['recaptcha_checked'], 'frm_ajax' ) ) { |
| 219 | 219 | // There was no captcha submitted |
| 220 | - $errors[ 'field' . $args['id'] ] = __( 'The captcha is missing from this form', 'formidable' ); |
|
| 220 | + $errors['field' . $args['id']] = __( 'The captcha is missing from this form', 'formidable' ); |
|
| 221 | 221 | } |
| 222 | 222 | return; |
| 223 | 223 | } |
@@ -230,15 +230,15 @@ discard block |
||
| 230 | 230 | ), |
| 231 | 231 | ); |
| 232 | 232 | $resp = wp_remote_post( 'https://www.google.com/recaptcha/api/siteverify', $arg_array ); |
| 233 | - $response = json_decode(wp_remote_retrieve_body( $resp ), true); |
|
| 233 | + $response = json_decode( wp_remote_retrieve_body( $resp ), true ); |
|
| 234 | 234 | |
| 235 | 235 | if ( isset( $response['success'] ) && ! $response['success'] ) { |
| 236 | 236 | // What happens when the CAPTCHA was entered incorrectly |
| 237 | - $errors[ 'field' . $args['id'] ] = ( ! isset( $field->field_options['invalid'] ) || $field->field_options['invalid'] == '' ) ? $frm_settings->re_msg : $field->field_options['invalid']; |
|
| 237 | + $errors['field' . $args['id']] = ( ! isset( $field->field_options['invalid'] ) || $field->field_options['invalid'] == '' ) ? $frm_settings->re_msg : $field->field_options['invalid']; |
|
| 238 | 238 | } else if ( is_wp_error( $resp ) ) { |
| 239 | 239 | $error_string = $resp->get_error_message(); |
| 240 | - $errors[ 'field' . $args['id'] ] = __( 'There was a problem verifying your recaptcha', 'formidable' ); |
|
| 241 | - $errors[ 'field' . $args['id'] ] .= ' ' . $error_string; |
|
| 240 | + $errors['field' . $args['id']] = __( 'There was a problem verifying your recaptcha', 'formidable' ); |
|
| 241 | + $errors['field' . $args['id']] .= ' ' . $error_string; |
|
| 242 | 242 | } |
| 243 | 243 | } |
| 244 | 244 | |
@@ -267,7 +267,7 @@ discard block |
||
| 267 | 267 | |
| 268 | 268 | private static function is_akismet_spam( $values ) { |
| 269 | 269 | global $wpcom_api_key; |
| 270 | - return ( is_callable('Akismet::http_post') && ( get_option('wordpress_api_key') || $wpcom_api_key ) && self::akismet( $values ) ); |
|
| 270 | + return ( is_callable( 'Akismet::http_post' ) && ( get_option( 'wordpress_api_key' ) || $wpcom_api_key ) && self::akismet( $values ) ); |
|
| 271 | 271 | } |
| 272 | 272 | |
| 273 | 273 | private static function is_akismet_enabled_for_user( $form_id ) { |
@@ -276,7 +276,7 @@ discard block |
||
| 276 | 276 | } |
| 277 | 277 | |
| 278 | 278 | public static function blacklist_check( $values ) { |
| 279 | - if ( ! apply_filters('frm_check_blacklist', true, $values) ) { |
|
| 279 | + if ( ! apply_filters( 'frm_check_blacklist', true, $values ) ) { |
|
| 280 | 280 | return false; |
| 281 | 281 | } |
| 282 | 282 | |
@@ -286,9 +286,9 @@ discard block |
||
| 286 | 286 | return false; |
| 287 | 287 | } |
| 288 | 288 | |
| 289 | - $content = FrmEntriesHelper::entry_array_to_string($values); |
|
| 289 | + $content = FrmEntriesHelper::entry_array_to_string( $values ); |
|
| 290 | 290 | |
| 291 | - if ( empty($content) ) { |
|
| 291 | + if ( empty( $content ) ) { |
|
| 292 | 292 | return false; |
| 293 | 293 | } |
| 294 | 294 | |
@@ -297,11 +297,11 @@ discard block |
||
| 297 | 297 | foreach ( (array) $words as $word ) { |
| 298 | 298 | $word = trim( $word ); |
| 299 | 299 | |
| 300 | - if ( empty($word) ) { |
|
| 300 | + if ( empty( $word ) ) { |
|
| 301 | 301 | continue; |
| 302 | 302 | } |
| 303 | 303 | |
| 304 | - if ( preg_match('#' . preg_quote( $word, '#' ) . '#', $content) ) { |
|
| 304 | + if ( preg_match( '#' . preg_quote( $word, '#' ) . '#', $content ) ) { |
|
| 305 | 305 | return true; |
| 306 | 306 | } |
| 307 | 307 | } |
@@ -330,7 +330,7 @@ discard block |
||
| 330 | 330 | unset( $key, $data ); |
| 331 | 331 | } |
| 332 | 332 | |
| 333 | - $response = Akismet::http_post($query_string, 'comment-check'); |
|
| 333 | + $response = Akismet::http_post( $query_string, 'comment-check' ); |
|
| 334 | 334 | |
| 335 | 335 | return ( is_array( $response ) && $response[1] == 'true' ); |
| 336 | 336 | } |
@@ -353,12 +353,12 @@ discard block |
||
| 353 | 353 | |
| 354 | 354 | foreach ( $_SERVER as $key => $value ) { |
| 355 | 355 | if ( ! in_array( $key, array( 'HTTP_COOKIE', 'HTTP_COOKIE2', 'PHP_AUTH_PW' ) ) && is_string( $value ) ) { |
| 356 | - $datas[ $key ] = wp_strip_all_tags( $value ); |
|
| 356 | + $datas[$key] = wp_strip_all_tags( $value ); |
|
| 357 | 357 | } else { |
| 358 | - $datas[ $key ] = ''; |
|
| 358 | + $datas[$key] = ''; |
|
| 359 | 359 | } |
| 360 | 360 | |
| 361 | - unset($key, $value); |
|
| 361 | + unset( $key, $value ); |
|
| 362 | 362 | } |
| 363 | 363 | } |
| 364 | 364 | } |
@@ -18,8 +18,8 @@ discard block |
||
| 18 | 18 | $this->file_name = $atts['file_name']; |
| 19 | 19 | $this->error_message = isset( $atts['error_message'] ) ? $atts['error_message'] : ''; |
| 20 | 20 | $this->uploads = wp_upload_dir(); |
| 21 | - $this->chmod_dir = defined('FS_CHMOD_DIR') ? FS_CHMOD_DIR : ( fileperms( ABSPATH ) & 0777 | 0755 ); |
|
| 22 | - $this->chmod_file = defined('FS_CHMOD_FILE') ? FS_CHMOD_FILE : ( fileperms( ABSPATH . 'index.php' ) & 0777 | 0644 ); |
|
| 21 | + $this->chmod_dir = defined( 'FS_CHMOD_DIR' ) ? FS_CHMOD_DIR : ( fileperms( ABSPATH ) & 0777 | 0755 ); |
|
| 22 | + $this->chmod_file = defined( 'FS_CHMOD_FILE' ) ? FS_CHMOD_FILE : ( fileperms( ABSPATH . 'index.php' ) & 0777 | 0644 ); |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | public function create_file( $file_content ) { |
@@ -85,13 +85,13 @@ discard block |
||
| 85 | 85 | private function get_ftp_creds( $type ) { |
| 86 | 86 | $credentials = get_option( 'ftp_credentials', array( 'hostname' => '', 'username' => '' ) ); |
| 87 | 87 | |
| 88 | - $credentials['hostname'] = defined('FTP_HOST') ? FTP_HOST : $credentials['hostname']; |
|
| 89 | - $credentials['username'] = defined('FTP_USER') ? FTP_USER : $credentials['username']; |
|
| 90 | - $credentials['password'] = defined('FTP_PASS') ? FTP_PASS : ''; |
|
| 88 | + $credentials['hostname'] = defined( 'FTP_HOST' ) ? FTP_HOST : $credentials['hostname']; |
|
| 89 | + $credentials['username'] = defined( 'FTP_USER' ) ? FTP_USER : $credentials['username']; |
|
| 90 | + $credentials['password'] = defined( 'FTP_PASS' ) ? FTP_PASS : ''; |
|
| 91 | 91 | |
| 92 | 92 | // Check to see if we are setting the public/private keys for ssh |
| 93 | - $credentials['public_key'] = defined('FTP_PUBKEY') ? FTP_PUBKEY : ''; |
|
| 94 | - $credentials['private_key'] = defined('FTP_PRIKEY') ? FTP_PRIKEY : ''; |
|
| 93 | + $credentials['public_key'] = defined( 'FTP_PUBKEY' ) ? FTP_PUBKEY : ''; |
|
| 94 | + $credentials['private_key'] = defined( 'FTP_PRIKEY' ) ? FTP_PRIKEY : ''; |
|
| 95 | 95 | |
| 96 | 96 | // Sanitize the hostname, Some people might pass in odd-data: |
| 97 | 97 | $credentials['hostname'] = preg_replace( '|\w+://|', '', $credentials['hostname'] ); //Strip any schemes off |
@@ -22,8 +22,8 @@ discard block |
||
| 22 | 22 | <a href="javascript:void(0)" class="show_field_custom_html frmbutton button frm_insert_code <?php echo is_array( $sname ) ? 'frm_help' : ''; ?>" data-code="<?php echo esc_attr( $skey ) ?>" <?php echo is_array( $sname ) ? 'title="' . esc_attr( $sname['title'] ) . '"' : ''; ?>><?php echo is_array( $sname ) ? $sname['label'] : $sname; ?></a> |
| 23 | 23 | </li> |
| 24 | 24 | <?php |
| 25 | - $col = ($col == 'one') ? 'two' : 'one'; |
|
| 26 | - unset($skey, $sname); |
|
| 25 | + $col = ( $col == 'one' ) ? 'two' : 'one'; |
|
| 26 | + unset( $skey, $sname ); |
|
| 27 | 27 | } |
| 28 | 28 | ?> |
| 29 | 29 | </ul> |
@@ -36,18 +36,18 @@ discard block |
||
| 36 | 36 | 'form_key' => __( 'Form Key', 'formidable' ), 'deletelink' => __( 'Delete Entry Link', 'formidable' ), |
| 37 | 37 | ) as $skey => $sname ) { ?> |
| 38 | 38 | <li class="frm_col_<?php echo esc_attr( $col ) ?>"> |
| 39 | - <a href="javascript:void(0)" class="show_before_html show_after_html frmbutton button frm_insert_code" data-code="<?php echo esc_attr($skey) ?>"><?php echo esc_html( $sname ); ?></a> |
|
| 39 | + <a href="javascript:void(0)" class="show_before_html show_after_html frmbutton button frm_insert_code" data-code="<?php echo esc_attr( $skey ) ?>"><?php echo esc_html( $sname ); ?></a> |
|
| 40 | 40 | </li> |
| 41 | 41 | <?php |
| 42 | - $col = ($col == 'one') ? 'two' : 'one'; |
|
| 42 | + $col = ( $col == 'one' ) ? 'two' : 'one'; |
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | foreach ( array( 'button_label' => __( 'Button Label', 'formidable' ), 'button_action' => __( 'Button Hook', 'formidable' ) ) as $skey => $sname ) { ?> |
| 46 | 46 | <li class="frm_col_<?php echo esc_attr( $col ) ?>"> |
| 47 | - <a href="javascript:void(0)" class="show_submit_html frmbutton button frm_insert_code" data-code="<?php echo esc_attr($skey) ?>"><?php echo esc_html( $sname ); ?></a> |
|
| 47 | + <a href="javascript:void(0)" class="show_submit_html frmbutton button frm_insert_code" data-code="<?php echo esc_attr( $skey ) ?>"><?php echo esc_html( $sname ); ?></a> |
|
| 48 | 48 | </li> |
| 49 | 49 | <?php |
| 50 | - $col = ($col == 'one') ? 'two' : 'one'; |
|
| 50 | + $col = ( $col == 'one' ) ? 'two' : 'one'; |
|
| 51 | 51 | } ?> |
| 52 | 52 | </ul> |
| 53 | 53 | </div> |
@@ -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 } ?> |
@@ -88,10 +88,10 @@ discard block |
||
| 88 | 88 | <div id="frm_conf_field_<?php echo esc_attr( $field['id'] ) ?>_container" class="frm_conf_field_container frm_form_fields frm_conf_details<?php echo esc_attr( $field['id'] . ( $field['conf_field'] ? '' : ' frm_hidden' ) ); ?>"> |
| 89 | 89 | <div id="frm_conf_field_<?php echo esc_attr( $field['id'] ) ?>_inner_container" class="frm_inner_conf_container"> |
| 90 | 90 | <div class="frm_form_fields"> |
| 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'] ); ?>" <?php do_action('frm_field_input_html', $field) ?> /> |
|
| 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'] ); ?>" <?php do_action( 'frm_field_input_html', $field ) ?> /> |
|
| 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 |
@@ -221,13 +221,13 @@ discard block |
||
| 221 | 221 | if ( $display['label_position'] ) { ?> |
| 222 | 222 | <tr><td class="frm_150_width"><label><?php _e( 'Label Position', 'formidable' ) ?></label></td> |
| 223 | 223 | <td><select name="field_options[label_<?php echo esc_attr( $field['id'] ) ?>]"> |
| 224 | - <option value=""<?php selected($field['label'], ''); ?>><?php _e( 'Default', 'formidable' ) ?></option> |
|
| 225 | - <option value="top"<?php selected($field['label'], 'top'); ?>><?php _e( 'Top', 'formidable' ) ?></option> |
|
| 226 | - <option value="left"<?php selected($field['label'], 'left'); ?>><?php _e( 'Left', 'formidable' ) ?></option> |
|
| 227 | - <option value="right"<?php selected($field['label'], 'right'); ?>><?php _e( 'Right', 'formidable' ) ?></option> |
|
| 228 | - <option value="inline"<?php selected($field['label'], 'inline'); ?>><?php _e( 'Inline (left without a set width)', 'formidable' ) ?></option> |
|
| 229 | - <option value="none"<?php selected($field['label'], 'none'); ?>><?php _e( 'None', 'formidable' ) ?></option> |
|
| 230 | - <option value="hidden"<?php selected($field['label'], 'hidden'); ?>><?php _e( 'Hidden (but leave the space)', 'formidable' ) ?></option> |
|
| 224 | + <option value=""<?php selected( $field['label'], '' ); ?>><?php _e( 'Default', 'formidable' ) ?></option> |
|
| 225 | + <option value="top"<?php selected( $field['label'], 'top' ); ?>><?php _e( 'Top', 'formidable' ) ?></option> |
|
| 226 | + <option value="left"<?php selected( $field['label'], 'left' ); ?>><?php _e( 'Left', 'formidable' ) ?></option> |
|
| 227 | + <option value="right"<?php selected( $field['label'], 'right' ); ?>><?php _e( 'Right', 'formidable' ) ?></option> |
|
| 228 | + <option value="inline"<?php selected( $field['label'], 'inline' ); ?>><?php _e( 'Inline (left without a set width)', 'formidable' ) ?></option> |
|
| 229 | + <option value="none"<?php selected( $field['label'], 'none' ); ?>><?php _e( 'None', 'formidable' ) ?></option> |
|
| 230 | + <option value="hidden"<?php selected( $field['label'], 'hidden' ); ?>><?php _e( 'Hidden (but leave the space)', 'formidable' ) ?></option> |
|
| 231 | 231 | </select> |
| 232 | 232 | </td> |
| 233 | 233 | </tr> |
@@ -250,8 +250,8 @@ discard block |
||
| 250 | 250 | <span class="frm_help frm_icon_font frm_tooltip_icon" title="<?php esc_attr_e( 'Set the size of the captcha field. The compact option is best if your form is in a small area.', 'formidable' ) ?>" ></span> |
| 251 | 251 | </td> |
| 252 | 252 | <td><select name="field_options[captcha_size_<?php echo esc_attr( $field['id'] ) ?>]"> |
| 253 | - <option value="default"<?php selected($field['captcha_size'], 'default'); ?>><?php _e( 'Default', 'formidable' ) ?></option> |
|
| 254 | - <option value="compact"<?php selected($field['captcha_size'], 'compact'); ?>><?php _e( 'Compact', 'formidable' ) ?></option> |
|
| 253 | + <option value="default"<?php selected( $field['captcha_size'], 'default' ); ?>><?php _e( 'Default', 'formidable' ) ?></option> |
|
| 254 | + <option value="compact"<?php selected( $field['captcha_size'], 'compact' ); ?>><?php _e( 'Compact', 'formidable' ) ?></option> |
|
| 255 | 255 | </select> |
| 256 | 256 | </td> |
| 257 | 257 | </tr> |
@@ -273,7 +273,7 @@ discard block |
||
| 273 | 273 | do_action( 'frm_field_options_form', $field, $display, $values ); |
| 274 | 274 | |
| 275 | 275 | if ( $display['required'] || $display['invalid'] || $display['unique'] || $display['conf_field'] ) { ?> |
| 276 | - <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'; ?>"> |
|
| 276 | + <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'; ?>"> |
|
| 277 | 277 | <td colspan="2"> |
| 278 | 278 | <div class="menu-settings"> |
| 279 | 279 | <h3 class="frm_no_bg"><?php _e( 'Validation', 'formidable' ) ?></h3> |
@@ -337,4 +337,4 @@ discard block |
||
| 337 | 337 | <?php |
| 338 | 338 | } |
| 339 | 339 | |
| 340 | -unset($display); |
|
| 340 | +unset( $display ); |
|
@@ -1,12 +1,12 @@ |
||
| 1 | 1 | <li id="frm_delete_field_<?php echo esc_attr( $field['id'] ); ?>-<?php echo esc_attr( $opt_key ) ?>_container" class="frm_single_option"> |
| 2 | 2 | <a href="javascript:void(0)" class="frm_single_visible_hover frm_icon_font frm_delete_icon" data-fid="<?php echo esc_attr( $field['id'] ); ?>"> </a> |
| 3 | 3 | <?php if ( $field['type'] != 'select' ) { ?> |
| 4 | - <input type="<?php echo esc_attr( $field['type'] ) ?>" name="<?php echo esc_attr( $field_name ) ?><?php echo ( $field['type'] == 'checkbox' ) ? '[]' : ''; ?>" value="<?php echo esc_attr($field_val) ?>"<?php echo isset( $checked ) ? $checked : ''; ?>/> |
|
| 4 | + <input type="<?php echo esc_attr( $field['type'] ) ?>" name="<?php echo esc_attr( $field_name ) ?><?php echo ( $field['type'] == 'checkbox' ) ? '[]' : ''; ?>" value="<?php echo esc_attr( $field_val ) ?>"<?php echo isset( $checked ) ? $checked : ''; ?>/> |
|
| 5 | 5 | <?php } ?> |
| 6 | - <label class="frm_ipe_field_option field_<?php echo esc_attr( $field['id'] ) ?>_option <?php echo esc_attr( $field['separate_value'] ? 'frm_with_key' : '' ); ?>" id="<?php echo esc_attr( $html_id . '-' . $opt_key ) ?>"><?php echo ($opt == '') ? __( '(Blank)', 'formidable' ) : $opt ?></label> |
|
| 6 | + <label class="frm_ipe_field_option field_<?php echo esc_attr( $field['id'] ) ?>_option <?php echo esc_attr( $field['separate_value'] ? 'frm_with_key' : '' ); ?>" id="<?php echo esc_attr( $html_id . '-' . $opt_key ) ?>"><?php echo ( $opt == '' ) ? __( '(Blank)', 'formidable' ) : $opt ?></label> |
|
| 7 | 7 | <span class="frm_option_key field_<?php echo esc_attr( $field['id'] ) ?>_option_key<?php echo esc_attr( $field['separate_value'] ? '' : ' frm_hidden' ); ?>"> |
| 8 | 8 | <label class="frm-show-click frm_ipe_field_option_key" id="field_key_<?php echo esc_attr( $field['id'] . '-' . $opt_key ) ?>"><?php echo ( $field_val == '' ) ? esc_html__( '(Blank)', 'formidable' ) : $field_val ?></label> |
| 9 | 9 | </span> |
| 10 | 10 | </li> |
| 11 | 11 | <?php |
| 12 | -unset($field_val, $opt, $opt_key); |
|
| 12 | +unset( $field_val, $opt, $opt_key ); |
|
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | |
| 43 | 43 | if ( $f->type == 'data' ) { |
| 44 | 44 | //get all fields from linked form |
| 45 | - if ( isset($f->field_options['form_select']) && is_numeric($f->field_options['form_select']) ) { |
|
| 45 | + if ( isset( $f->field_options['form_select'] ) && is_numeric( $f->field_options['form_select'] ) ) { |
|
| 46 | 46 | $linked_form = FrmDb::get_var( $wpdb->prefix . 'frm_fields', array( 'id' => $f->field_options['form_select'] ), 'form_id' ); |
| 47 | 47 | if ( ! in_array( $linked_form, $linked_forms ) ) { |
| 48 | 48 | $linked_forms[] = $linked_form; |
@@ -53,14 +53,14 @@ discard block |
||
| 53 | 53 | FrmAppHelper::insert_opt_html( array( 'id' => $f->id . ' show=' . $linked_field->id, 'key' => $f->field_key . ' show=' . $linked_field->field_key, 'name' => $linked_field->name, 'type' => $linked_field->type ) ); |
| 54 | 54 | |
| 55 | 55 | $ldfe = $linked_field->id; |
| 56 | - unset($linked_field); |
|
| 56 | + unset( $linked_field ); |
|
| 57 | 57 | } |
| 58 | 58 | } |
| 59 | 59 | } |
| 60 | 60 | } |
| 61 | 61 | $dfe = $f->id; |
| 62 | 62 | } |
| 63 | - unset($f); |
|
| 63 | + unset( $f ); |
|
| 64 | 64 | } |
| 65 | 65 | } ?> |
| 66 | 66 | </ul> |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | </li> |
| 85 | 85 | <?php |
| 86 | 86 | $col = ( $col == 'one' ) ? 'two' : 'one'; |
| 87 | - unset($skey, $sname); |
|
| 87 | + unset( $skey, $sname ); |
|
| 88 | 88 | } |
| 89 | 89 | ?> |
| 90 | 90 | </ul> |
@@ -106,8 +106,8 @@ discard block |
||
| 106 | 106 | ?> |
| 107 | 107 | <li> |
| 108 | 108 | <a href="javascript:void(0)" class="frmids alignright frm_insert_code" data-code="if <?php echo esc_attr( $f->id ) ?>]<?php esc_attr_e( 'Conditional text here', 'formidable' ) ?>[/if <?php echo esc_attr( $f->id ) ?>">[if <?php echo (int) $f->id ?>]</a> |
| 109 | - <a href="javascript:void(0)" class="frmkeys alignright frm_insert_code" data-code="if <?php echo esc_attr( $f->field_key ) ?>]something[/if <?php echo esc_attr( $f->field_key ) ?>">[if <?php echo FrmAppHelper::truncate($f->field_key, 10) ?>]</a> |
|
| 110 | - <a href="javascript:void(0)" class="frm_insert_code" data-code="<?php echo esc_attr($f->id) ?>"><?php echo FrmAppHelper::truncate($f->name, 60) ?></a> |
|
| 109 | + <a href="javascript:void(0)" class="frmkeys alignright frm_insert_code" data-code="if <?php echo esc_attr( $f->field_key ) ?>]something[/if <?php echo esc_attr( $f->field_key ) ?>">[if <?php echo FrmAppHelper::truncate( $f->field_key, 10 ) ?>]</a> |
|
| 110 | + <a href="javascript:void(0)" class="frm_insert_code" data-code="<?php echo esc_attr( $f->id ) ?>"><?php echo FrmAppHelper::truncate( $f->name, 60 ) ?></a> |
|
| 111 | 111 | </li> |
| 112 | 112 | <?php |
| 113 | 113 | |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | } else if ( $f->type == 'file' ) { |
| 117 | 117 | $file = $f; |
| 118 | 118 | } |
| 119 | - unset($f); |
|
| 119 | + unset( $f ); |
|
| 120 | 120 | } |
| 121 | 121 | } ?> |
| 122 | 122 | </ul> |
@@ -128,11 +128,11 @@ discard block |
||
| 128 | 128 | foreach ( $cond_shortcodes as $skey => $sname ) { |
| 129 | 129 | ?> |
| 130 | 130 | <li class="frm_col_<?php echo esc_attr( $col ) ?>"> |
| 131 | - <a href="javascript:void(0)" class="frmbutton button frm_insert_code" data-code="if x <?php echo esc_attr($skey) ?>][/if x"><?php echo esc_html( $sname ) ?></a> |
|
| 131 | + <a href="javascript:void(0)" class="frmbutton button frm_insert_code" data-code="if x <?php echo esc_attr( $skey ) ?>][/if x"><?php echo esc_html( $sname ) ?></a> |
|
| 132 | 132 | </li> |
| 133 | 133 | <?php |
| 134 | 134 | $col = ( $col == 'one' ) ? 'two' : 'one'; |
| 135 | - unset($skey, $sname); |
|
| 135 | + unset( $skey, $sname ); |
|
| 136 | 136 | } |
| 137 | 137 | ?> |
| 138 | 138 | </ul> |
@@ -151,19 +151,19 @@ discard block |
||
| 151 | 151 | </a> |
| 152 | 152 | </li> |
| 153 | 153 | <?php |
| 154 | - $col = ($col == 'one') ? 'two' : 'one'; |
|
| 155 | - unset($skey, $sname); |
|
| 154 | + $col = ( $col == 'one' ) ? 'two' : 'one'; |
|
| 155 | + unset( $skey, $sname ); |
|
| 156 | 156 | } |
| 157 | 157 | ?> |
| 158 | - <?php if ( isset($file) ) { ?> |
|
| 158 | + <?php if ( isset( $file ) ) { ?> |
|
| 159 | 159 | <li class="frm_col_<?php echo esc_attr( $col ) ?>"> |
| 160 | - <a href="javascript:void(0)" class="frmbutton button frm_insert_code" data-code="<?php echo esc_attr($file->id) ?> show_image=1"><?php _e( 'Show image', 'formidable' ) ?></a> |
|
| 160 | + <a href="javascript:void(0)" class="frmbutton button frm_insert_code" data-code="<?php echo esc_attr( $file->id ) ?> show_image=1"><?php _e( 'Show image', 'formidable' ) ?></a> |
|
| 161 | 161 | </li> |
| 162 | 162 | <li class="frm_col_<?php echo esc_attr( $col = ( $col == 'one' ? 'two' : 'one' ) ) ?>"> |
| 163 | - <a href="javascript:void(0)" class="frmbutton button frm_insert_code" data-code="<?php echo esc_attr($file->id) ?> show=id"><?php _e( 'Image ID', 'formidable' ) ?></a> |
|
| 163 | + <a href="javascript:void(0)" class="frmbutton button frm_insert_code" data-code="<?php echo esc_attr( $file->id ) ?> show=id"><?php _e( 'Image ID', 'formidable' ) ?></a> |
|
| 164 | 164 | </li> |
| 165 | 165 | <li class="frm_col_<?php echo esc_attr( $col = ( $col == 'one' ? 'two' : 'one' ) ) ?>"> |
| 166 | - <a href="javascript:void(0)" class="frmbutton button frm_insert_code" data-code="<?php echo esc_attr($file->id) ?> show_filename=1"><?php _e( 'Image Name', 'formidable' ) ?></a> |
|
| 166 | + <a href="javascript:void(0)" class="frmbutton button frm_insert_code" data-code="<?php echo esc_attr( $file->id ) ?> show_filename=1"><?php _e( 'Image Name', 'formidable' ) ?></a> |
|
| 167 | 167 | </li> |
| 168 | 168 | <?php } ?> |
| 169 | 169 | </ul> |
@@ -171,7 +171,7 @@ discard block |
||
| 171 | 171 | <div class="clear"></div> |
| 172 | 172 | <?php |
| 173 | 173 | |
| 174 | - if ( isset($uid) && ! empty($user_fields) ) { |
|
| 174 | + if ( isset( $uid ) && ! empty( $user_fields ) ) { |
|
| 175 | 175 | $col = 'one'; ?> |
| 176 | 176 | <p class="howto"><?php _e( 'Insert user information', 'formidable' ) ?></p> |
| 177 | 177 | <ul class="frm_code_list"> |
@@ -180,14 +180,14 @@ discard block |
||
| 180 | 180 | <a href="javascript:void(0)" class="frmbutton button frm_insert_code" data-code="<?php echo esc_attr( $uid->id . ' show="' . $uk . '"' ) ?>"><?php echo esc_html( $uf ) ?></a> |
| 181 | 181 | </li> |
| 182 | 182 | <?php |
| 183 | - $col = ($col == 'one') ? 'two' : 'one'; |
|
| 184 | - unset($uf, $uk); |
|
| 183 | + $col = ( $col == 'one' ) ? 'two' : 'one'; |
|
| 184 | + unset( $uf, $uk ); |
|
| 185 | 185 | } |
| 186 | - unset($uid); ?> |
|
| 186 | + unset( $uid ); ?> |
|
| 187 | 187 | </ul> |
| 188 | 188 | <?php } |
| 189 | 189 | |
| 190 | - if ( isset($repeat_field) ) { ?> |
|
| 190 | + if ( isset( $repeat_field ) ) { ?> |
|
| 191 | 191 | <div class="clear"></div> |
| 192 | 192 | <p class="howto"><?php _e( 'Repeating field options', 'formidable' ) ?></p> |
| 193 | 193 | <ul class="frm_code_list"> |
@@ -198,7 +198,7 @@ discard block |
||
| 198 | 198 | <?php |
| 199 | 199 | } |
| 200 | 200 | |
| 201 | - if ( isset($dfe) ) { ?> |
|
| 201 | + if ( isset( $dfe ) ) { ?> |
|
| 202 | 202 | |
| 203 | 203 | <div class="clear"></div> |
| 204 | 204 | <p class="howto"><?php _e( 'Dynamic field options', 'formidable' ) ?></p> |
@@ -206,7 +206,7 @@ discard block |
||
| 206 | 206 | <li class="frm_col_one"> |
| 207 | 207 | <a href="javascript:void(0)" class="frmbutton button frm_insert_code" data-code="<?php echo esc_attr( $dfe . ' show="created-at"' ) ?>"><?php _e( 'Creation Date', 'formidable' ) ?></a> |
| 208 | 208 | </li> |
| 209 | - <?php if ( isset($ldfe) ) { ?> |
|
| 209 | + <?php if ( isset( $ldfe ) ) { ?> |
|
| 210 | 210 | <li class="frm_col_two"> |
| 211 | 211 | <a href="javascript:void(0)" class="frmbutton button frm_insert_code" data-code="<?php echo esc_attr( $dfe . ' show="' . $ldfe . '"' ) ?>"><?php _e( 'Field From Entry', 'formidable' ) ?></a> |
| 212 | 212 | </li> |
@@ -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 ( array( 'none' => __( 'top', 'formidable' ), 'left' => __( 'left', 'formidable' ), 'right' => __( 'right', 'formidable' ), 'no_label' => __( 'none', 'formidable' ) ) 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 } ?> |