@@ -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,27 +98,27 @@ 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() { |
| 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 | 119 | $this->clear_cache(); |
| 120 | 120 | |
| 121 | - set_transient('frmpro_css', $css); |
|
| 121 | + set_transient('frmpro_css', $css); |
|
| 122 | 122 | } |
| 123 | 123 | |
| 124 | 124 | private function get_css_content( $filename ) { |
@@ -127,10 +127,10 @@ discard block |
||
| 127 | 127 | $saving = true; |
| 128 | 128 | $frm_style = $this; |
| 129 | 129 | |
| 130 | - ob_start(); |
|
| 131 | - include( $filename ); |
|
| 130 | + ob_start(); |
|
| 131 | + include( $filename ); |
|
| 132 | 132 | $css .= preg_replace( '/\/\*(.|\s)*?\*\//', '', str_replace( array( "\r\n", "\r", "\n", "\t", ' ' ), '', ob_get_contents() ) ); |
| 133 | - ob_end_clean(); |
|
| 133 | + ob_end_clean(); |
|
| 134 | 134 | |
| 135 | 135 | return $css; |
| 136 | 136 | } |
@@ -150,272 +150,272 @@ discard block |
||
| 150 | 150 | } |
| 151 | 151 | |
| 152 | 152 | public function destroy( $id ) { |
| 153 | - return wp_delete_post($id); |
|
| 154 | - } |
|
| 153 | + return wp_delete_post($id); |
|
| 154 | + } |
|
| 155 | 155 | |
| 156 | - public function get_one() { |
|
| 157 | - if ( 'default' == $this->id ) { |
|
| 158 | - $style = $this->get_default_style(); |
|
| 159 | - if ( $style ) { |
|
| 160 | - $this->id = $style->ID; |
|
| 161 | - } else { |
|
| 162 | - $this->id = 0; |
|
| 163 | - } |
|
| 164 | - return $style; |
|
| 165 | - } |
|
| 156 | + public function get_one() { |
|
| 157 | + if ( 'default' == $this->id ) { |
|
| 158 | + $style = $this->get_default_style(); |
|
| 159 | + if ( $style ) { |
|
| 160 | + $this->id = $style->ID; |
|
| 161 | + } else { |
|
| 162 | + $this->id = 0; |
|
| 163 | + } |
|
| 164 | + return $style; |
|
| 165 | + } |
|
| 166 | 166 | |
| 167 | - $style = get_post($this->id); |
|
| 167 | + $style = get_post($this->id); |
|
| 168 | 168 | |
| 169 | - if ( ! $style ) { |
|
| 170 | - return $style; |
|
| 171 | - } |
|
| 169 | + if ( ! $style ) { |
|
| 170 | + return $style; |
|
| 171 | + } |
|
| 172 | 172 | |
| 173 | - $style->post_content = FrmAppHelper::maybe_json_decode($style->post_content); |
|
| 173 | + $style->post_content = FrmAppHelper::maybe_json_decode($style->post_content); |
|
| 174 | 174 | |
| 175 | - $default_values = $this->get_defaults(); |
|
| 175 | + $default_values = $this->get_defaults(); |
|
| 176 | 176 | |
| 177 | - // fill default values |
|
| 178 | - $style->post_content = $this->override_defaults($style->post_content); |
|
| 179 | - $style->post_content = wp_parse_args( $style->post_content, $default_values); |
|
| 177 | + // fill default values |
|
| 178 | + $style->post_content = $this->override_defaults($style->post_content); |
|
| 179 | + $style->post_content = wp_parse_args( $style->post_content, $default_values); |
|
| 180 | 180 | |
| 181 | - return $style; |
|
| 182 | - } |
|
| 181 | + return $style; |
|
| 182 | + } |
|
| 183 | 183 | |
| 184 | - public function get_all( $orderby = 'title', $order = 'ASC', $limit = 99 ) { |
|
| 185 | - $post_atts = array( |
|
| 184 | + public function get_all( $orderby = 'title', $order = 'ASC', $limit = 99 ) { |
|
| 185 | + $post_atts = array( |
|
| 186 | 186 | 'post_type' => FrmStylesController::$post_type, |
| 187 | 187 | 'post_status' => 'publish', |
| 188 | 188 | 'numberposts' => $limit, |
| 189 | 189 | 'orderby' => $orderby, |
| 190 | 190 | 'order' => $order, |
| 191 | - ); |
|
| 191 | + ); |
|
| 192 | 192 | |
| 193 | - $temp_styles = FrmAppHelper::check_cache(serialize($post_atts), 'frm_styles', $post_atts, 'get_posts'); |
|
| 193 | + $temp_styles = FrmAppHelper::check_cache(serialize($post_atts), 'frm_styles', $post_atts, 'get_posts'); |
|
| 194 | 194 | |
| 195 | - if ( empty($temp_styles) ) { |
|
| 196 | - global $wpdb; |
|
| 197 | - // make sure there wasn't a conflict with the query |
|
| 195 | + if ( empty($temp_styles) ) { |
|
| 196 | + global $wpdb; |
|
| 197 | + // make sure there wasn't a conflict with the query |
|
| 198 | 198 | $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' ); |
| 199 | - $temp_styles = FrmAppHelper::check_cache('frm_backup_style_check', 'frm_styles', $query, 'get_results'); |
|
| 200 | - |
|
| 201 | - if ( empty($temp_styles) ) { |
|
| 202 | - // create a new style if there are none |
|
| 203 | - $new = $this->get_new(); |
|
| 204 | - $new->post_title = $new->post_name = __( 'Formidable Style', 'formidable' ); |
|
| 205 | - $new->menu_order = 1; |
|
| 206 | - $new = $this->save( (array) $new); |
|
| 207 | - $this->update('default'); |
|
| 208 | - |
|
| 209 | - $post_atts['include'] = $new; |
|
| 210 | - |
|
| 211 | - $temp_styles = get_posts( $post_atts ); |
|
| 212 | - } |
|
| 213 | - } |
|
| 214 | - |
|
| 215 | - $default_values = $this->get_defaults(); |
|
| 216 | - $default_style = false; |
|
| 217 | - |
|
| 218 | - $styles = array(); |
|
| 219 | - foreach ( $temp_styles as $style ) { |
|
| 220 | - $this->id = $style->ID; |
|
| 221 | - if ( $style->menu_order ) { |
|
| 222 | - if ( $default_style ) { |
|
| 223 | - // only return one default |
|
| 224 | - $style->menu_order = 0; |
|
| 225 | - } else { |
|
| 226 | - // check for a default style |
|
| 227 | - $default_style = $style->ID; |
|
| 228 | - } |
|
| 229 | - } |
|
| 230 | - |
|
| 231 | - $style->post_content = FrmAppHelper::maybe_json_decode($style->post_content); |
|
| 232 | - |
|
| 233 | - // fill default values |
|
| 234 | - $style->post_content = $this->override_defaults($style->post_content); |
|
| 235 | - $style->post_content = wp_parse_args( $style->post_content, $default_values); |
|
| 199 | + $temp_styles = FrmAppHelper::check_cache('frm_backup_style_check', 'frm_styles', $query, 'get_results'); |
|
| 200 | + |
|
| 201 | + if ( empty($temp_styles) ) { |
|
| 202 | + // create a new style if there are none |
|
| 203 | + $new = $this->get_new(); |
|
| 204 | + $new->post_title = $new->post_name = __( 'Formidable Style', 'formidable' ); |
|
| 205 | + $new->menu_order = 1; |
|
| 206 | + $new = $this->save( (array) $new); |
|
| 207 | + $this->update('default'); |
|
| 208 | + |
|
| 209 | + $post_atts['include'] = $new; |
|
| 210 | + |
|
| 211 | + $temp_styles = get_posts( $post_atts ); |
|
| 212 | + } |
|
| 213 | + } |
|
| 214 | + |
|
| 215 | + $default_values = $this->get_defaults(); |
|
| 216 | + $default_style = false; |
|
| 217 | + |
|
| 218 | + $styles = array(); |
|
| 219 | + foreach ( $temp_styles as $style ) { |
|
| 220 | + $this->id = $style->ID; |
|
| 221 | + if ( $style->menu_order ) { |
|
| 222 | + if ( $default_style ) { |
|
| 223 | + // only return one default |
|
| 224 | + $style->menu_order = 0; |
|
| 225 | + } else { |
|
| 226 | + // check for a default style |
|
| 227 | + $default_style = $style->ID; |
|
| 228 | + } |
|
| 229 | + } |
|
| 230 | + |
|
| 231 | + $style->post_content = FrmAppHelper::maybe_json_decode($style->post_content); |
|
| 232 | + |
|
| 233 | + // fill default values |
|
| 234 | + $style->post_content = $this->override_defaults($style->post_content); |
|
| 235 | + $style->post_content = wp_parse_args( $style->post_content, $default_values); |
|
| 236 | 236 | |
| 237 | 237 | $styles[ $style->ID ] = $style; |
| 238 | - } |
|
| 238 | + } |
|
| 239 | 239 | |
| 240 | - if ( ! $default_style ) { |
|
| 241 | - $default_style = reset($styles); |
|
| 240 | + if ( ! $default_style ) { |
|
| 241 | + $default_style = reset($styles); |
|
| 242 | 242 | $styles[ $default_style->ID ]->menu_order = 1; |
| 243 | - } |
|
| 243 | + } |
|
| 244 | 244 | |
| 245 | - return $styles; |
|
| 246 | - } |
|
| 245 | + return $styles; |
|
| 246 | + } |
|
| 247 | 247 | |
| 248 | 248 | public function get_default_style( $styles = null ) { |
| 249 | - if ( ! isset($styles) ) { |
|
| 249 | + if ( ! isset($styles) ) { |
|
| 250 | 250 | $styles = $this->get_all( 'menu_order', 'DESC', 1 ); |
| 251 | - } |
|
| 251 | + } |
|
| 252 | 252 | |
| 253 | - foreach ( $styles as $style ) { |
|
| 254 | - if ( $style->menu_order ) { |
|
| 255 | - return $style; |
|
| 256 | - } |
|
| 257 | - } |
|
| 258 | - } |
|
| 253 | + foreach ( $styles as $style ) { |
|
| 254 | + if ( $style->menu_order ) { |
|
| 255 | + return $style; |
|
| 256 | + } |
|
| 257 | + } |
|
| 258 | + } |
|
| 259 | 259 | |
| 260 | 260 | public function override_defaults( $settings ) { |
| 261 | - if ( ! is_array($settings) ) { |
|
| 262 | - return $settings; |
|
| 263 | - } |
|
| 264 | - |
|
| 265 | - $settings['line_height'] = ( ! isset($settings['field_height']) || $settings['field_height'] == '' || $settings['field_height'] == 'auto') ? 'normal' : $settings['field_height']; |
|
| 266 | - |
|
| 267 | - if ( ! isset($settings['form_desc_size']) && isset($settings['description_font_size']) ) { |
|
| 268 | - $settings['form_desc_size'] = $settings['description_font_size']; |
|
| 269 | - $settings['form_desc_color'] = $settings['description_color']; |
|
| 270 | - $settings['title_color'] = $settings['label_color']; |
|
| 271 | - } |
|
| 272 | - |
|
| 273 | - if ( ! isset($settings['section_color']) && isset($settings['label_color']) ) { |
|
| 274 | - $settings['section_color'] = $settings['label_color']; |
|
| 275 | - $settings['section_border_color'] = $settings['border_color']; |
|
| 276 | - } |
|
| 277 | - |
|
| 278 | - if ( ! isset($settings['submit_hover_bg_color']) && isset($settings['submit_bg_color']) ) { |
|
| 279 | - $settings['submit_hover_bg_color'] = $settings['submit_bg_color']; |
|
| 280 | - $settings['submit_hover_color'] = $settings['submit_text_color']; |
|
| 281 | - $settings['submit_hover_border_color'] = $settings['submit_border_color']; |
|
| 282 | - |
|
| 283 | - $settings['submit_active_bg_color'] = $settings['submit_bg_color']; |
|
| 284 | - $settings['submit_active_color'] = $settings['submit_text_color']; |
|
| 285 | - $settings['submit_active_border_color'] = $settings['submit_border_color']; |
|
| 286 | - } |
|
| 287 | - |
|
| 288 | - return $settings; |
|
| 261 | + if ( ! is_array($settings) ) { |
|
| 262 | + return $settings; |
|
| 263 | + } |
|
| 264 | + |
|
| 265 | + $settings['line_height'] = ( ! isset($settings['field_height']) || $settings['field_height'] == '' || $settings['field_height'] == 'auto') ? 'normal' : $settings['field_height']; |
|
| 266 | + |
|
| 267 | + if ( ! isset($settings['form_desc_size']) && isset($settings['description_font_size']) ) { |
|
| 268 | + $settings['form_desc_size'] = $settings['description_font_size']; |
|
| 269 | + $settings['form_desc_color'] = $settings['description_color']; |
|
| 270 | + $settings['title_color'] = $settings['label_color']; |
|
| 271 | + } |
|
| 272 | + |
|
| 273 | + if ( ! isset($settings['section_color']) && isset($settings['label_color']) ) { |
|
| 274 | + $settings['section_color'] = $settings['label_color']; |
|
| 275 | + $settings['section_border_color'] = $settings['border_color']; |
|
| 276 | + } |
|
| 277 | + |
|
| 278 | + if ( ! isset($settings['submit_hover_bg_color']) && isset($settings['submit_bg_color']) ) { |
|
| 279 | + $settings['submit_hover_bg_color'] = $settings['submit_bg_color']; |
|
| 280 | + $settings['submit_hover_color'] = $settings['submit_text_color']; |
|
| 281 | + $settings['submit_hover_border_color'] = $settings['submit_border_color']; |
|
| 282 | + |
|
| 283 | + $settings['submit_active_bg_color'] = $settings['submit_bg_color']; |
|
| 284 | + $settings['submit_active_color'] = $settings['submit_text_color']; |
|
| 285 | + $settings['submit_active_border_color'] = $settings['submit_border_color']; |
|
| 286 | + } |
|
| 287 | + |
|
| 288 | + return $settings; |
|
| 289 | 289 | } |
| 290 | 290 | |
| 291 | 291 | public function get_defaults() { |
| 292 | - return array( |
|
| 293 | - 'theme_css' => 'ui-lightness', |
|
| 294 | - 'theme_name' => 'UI Lightness', |
|
| 292 | + return array( |
|
| 293 | + 'theme_css' => 'ui-lightness', |
|
| 294 | + 'theme_name' => 'UI Lightness', |
|
| 295 | 295 | |
| 296 | 296 | 'center_form' => '', |
| 297 | - 'form_width' => '100%', |
|
| 298 | - 'form_align' => 'left', |
|
| 299 | - 'direction' => is_rtl() ? 'rtl' : 'ltr', |
|
| 300 | - 'fieldset' => '0px', |
|
| 301 | - 'fieldset_color' => '000000', |
|
| 302 | - 'fieldset_padding' => '0 0 15px 0', |
|
| 303 | - 'fieldset_bg_color' => '', |
|
| 304 | - |
|
| 305 | - 'title_size' => '20px', |
|
| 306 | - 'title_color' => '444444', |
|
| 297 | + 'form_width' => '100%', |
|
| 298 | + 'form_align' => 'left', |
|
| 299 | + 'direction' => is_rtl() ? 'rtl' : 'ltr', |
|
| 300 | + 'fieldset' => '0px', |
|
| 301 | + 'fieldset_color' => '000000', |
|
| 302 | + 'fieldset_padding' => '0 0 15px 0', |
|
| 303 | + 'fieldset_bg_color' => '', |
|
| 304 | + |
|
| 305 | + 'title_size' => '20px', |
|
| 306 | + 'title_color' => '444444', |
|
| 307 | 307 | 'title_margin_top' => '10px', |
| 308 | 308 | 'title_margin_bottom' => '10px', |
| 309 | - 'form_desc_size' => '14px', |
|
| 310 | - 'form_desc_color' => '666666', |
|
| 309 | + 'form_desc_size' => '14px', |
|
| 310 | + 'form_desc_color' => '666666', |
|
| 311 | 311 | 'form_desc_margin_top' => '10px', |
| 312 | 312 | 'form_desc_margin_bottom' => '25px', |
| 313 | 313 | |
| 314 | - 'font' => '"Lucida Grande","Lucida Sans Unicode",Tahoma,sans-serif', |
|
| 315 | - 'font_size' => '14px', |
|
| 316 | - 'label_color' => '444444', |
|
| 317 | - 'weight' => 'bold', |
|
| 318 | - 'position' => 'none', |
|
| 319 | - 'align' => 'left', |
|
| 320 | - 'width' => '150px', |
|
| 321 | - 'required_color' => 'B94A48', |
|
| 322 | - 'required_weight' => 'bold', |
|
| 323 | - 'label_padding' => '0 0 3px 0', |
|
| 324 | - |
|
| 325 | - 'description_font_size' => '12px', |
|
| 326 | - 'description_color' => '666666', |
|
| 327 | - 'description_weight' => 'normal', |
|
| 328 | - 'description_style' => 'normal', |
|
| 329 | - 'description_align' => 'left', |
|
| 314 | + 'font' => '"Lucida Grande","Lucida Sans Unicode",Tahoma,sans-serif', |
|
| 315 | + 'font_size' => '14px', |
|
| 316 | + 'label_color' => '444444', |
|
| 317 | + 'weight' => 'bold', |
|
| 318 | + 'position' => 'none', |
|
| 319 | + 'align' => 'left', |
|
| 320 | + 'width' => '150px', |
|
| 321 | + 'required_color' => 'B94A48', |
|
| 322 | + 'required_weight' => 'bold', |
|
| 323 | + 'label_padding' => '0 0 3px 0', |
|
| 324 | + |
|
| 325 | + 'description_font_size' => '12px', |
|
| 326 | + 'description_color' => '666666', |
|
| 327 | + 'description_weight' => 'normal', |
|
| 328 | + 'description_style' => 'normal', |
|
| 329 | + 'description_align' => 'left', |
|
| 330 | 330 | 'description_margin' => '0', |
| 331 | 331 | |
| 332 | - 'field_font_size' => '14px', |
|
| 333 | - 'field_height' => '32px', |
|
| 334 | - 'line_height' => 'normal', |
|
| 335 | - 'field_width' => '100%', |
|
| 336 | - 'auto_width' => false, |
|
| 337 | - 'field_pad' => '6px 10px', |
|
| 338 | - 'field_margin' => '20px', |
|
| 332 | + 'field_font_size' => '14px', |
|
| 333 | + 'field_height' => '32px', |
|
| 334 | + 'line_height' => 'normal', |
|
| 335 | + 'field_width' => '100%', |
|
| 336 | + 'auto_width' => false, |
|
| 337 | + 'field_pad' => '6px 10px', |
|
| 338 | + 'field_margin' => '20px', |
|
| 339 | 339 | 'field_weight' => 'normal', |
| 340 | - 'text_color' => '555555', |
|
| 341 | - //'border_color_hv' => 'cccccc', |
|
| 342 | - 'border_color' => 'cccccc', |
|
| 343 | - 'field_border_width' => '1px', |
|
| 344 | - 'field_border_style' => 'solid', |
|
| 345 | - |
|
| 346 | - 'bg_color' => 'ffffff', |
|
| 347 | - //'bg_color_hv' => 'ffffff', |
|
| 340 | + 'text_color' => '555555', |
|
| 341 | + //'border_color_hv' => 'cccccc', |
|
| 342 | + 'border_color' => 'cccccc', |
|
| 343 | + 'field_border_width' => '1px', |
|
| 344 | + 'field_border_style' => 'solid', |
|
| 345 | + |
|
| 346 | + 'bg_color' => 'ffffff', |
|
| 347 | + //'bg_color_hv' => 'ffffff', |
|
| 348 | 348 | 'remove_box_shadow' => '', |
| 349 | - 'bg_color_active' => 'ffffff', |
|
| 349 | + 'bg_color_active' => 'ffffff', |
|
| 350 | 350 | 'border_color_active' => '66afe9', |
| 351 | 351 | 'remove_box_shadow_active' => '', |
| 352 | - 'text_color_error' => '444444', |
|
| 353 | - 'bg_color_error' => 'ffffff', |
|
| 352 | + 'text_color_error' => '444444', |
|
| 353 | + 'bg_color_error' => 'ffffff', |
|
| 354 | 354 | 'border_color_error' => 'B94A48', |
| 355 | 355 | 'border_width_error' => '1px', |
| 356 | 356 | 'border_style_error' => 'solid', |
| 357 | - 'bg_color_disabled' => 'ffffff', |
|
| 358 | - 'border_color_disabled' => 'E5E5E5', |
|
| 359 | - 'text_color_disabled' => 'A1A1A1', |
|
| 360 | - |
|
| 361 | - 'radio_align' => 'block', |
|
| 362 | - 'check_align' => 'block', |
|
| 363 | - 'check_font_size' => '13px', |
|
| 364 | - 'check_label_color' => '444444', |
|
| 365 | - 'check_weight' => 'normal', |
|
| 366 | - |
|
| 367 | - 'section_font_size' => '18px', |
|
| 368 | - 'section_color' => '444444', |
|
| 369 | - 'section_weight' => 'bold', |
|
| 370 | - 'section_pad' => '15px 0 3px 0', |
|
| 371 | - 'section_mar_top' => '15px', |
|
| 357 | + 'bg_color_disabled' => 'ffffff', |
|
| 358 | + 'border_color_disabled' => 'E5E5E5', |
|
| 359 | + 'text_color_disabled' => 'A1A1A1', |
|
| 360 | + |
|
| 361 | + 'radio_align' => 'block', |
|
| 362 | + 'check_align' => 'block', |
|
| 363 | + 'check_font_size' => '13px', |
|
| 364 | + 'check_label_color' => '444444', |
|
| 365 | + 'check_weight' => 'normal', |
|
| 366 | + |
|
| 367 | + 'section_font_size' => '18px', |
|
| 368 | + 'section_color' => '444444', |
|
| 369 | + 'section_weight' => 'bold', |
|
| 370 | + 'section_pad' => '15px 0 3px 0', |
|
| 371 | + 'section_mar_top' => '15px', |
|
| 372 | 372 | 'section_mar_bottom' => '12px', |
| 373 | - 'section_bg_color' => '', |
|
| 374 | - 'section_border_color' => 'e8e8e8', |
|
| 375 | - 'section_border_width' => '2px', |
|
| 376 | - 'section_border_style' => 'solid', |
|
| 377 | - 'section_border_loc' => '-top', |
|
| 378 | - 'collapse_icon' => '6', |
|
| 379 | - 'collapse_pos' => 'after', |
|
| 380 | - 'repeat_icon' => '1', |
|
| 381 | - |
|
| 382 | - 'submit_style' => false, |
|
| 383 | - 'submit_font_size' => '14px', |
|
| 384 | - 'submit_width' => 'auto', |
|
| 385 | - 'submit_height' => 'auto', |
|
| 386 | - 'submit_bg_color' => 'ffffff', |
|
| 387 | - 'submit_border_color' => 'cccccc', |
|
| 388 | - 'submit_border_width' => '1px', |
|
| 389 | - 'submit_text_color' => '444444', |
|
| 390 | - 'submit_weight' => 'normal', |
|
| 391 | - 'submit_border_radius' => '4px', |
|
| 392 | - 'submit_bg_img' => '', |
|
| 393 | - 'submit_margin' => '10px', |
|
| 394 | - 'submit_padding' => '6px 11px', |
|
| 395 | - 'submit_shadow_color' => 'eeeeee', |
|
| 396 | - 'submit_hover_bg_color' => 'efefef', |
|
| 397 | - 'submit_hover_color' => '444444', |
|
| 398 | - 'submit_hover_border_color' => 'cccccc', |
|
| 399 | - 'submit_active_bg_color' => 'efefef', |
|
| 400 | - 'submit_active_color' => '444444', |
|
| 401 | - 'submit_active_border_color' => 'cccccc', |
|
| 402 | - |
|
| 403 | - 'border_radius' => '4px', |
|
| 404 | - 'error_bg' => 'F2DEDE', |
|
| 405 | - 'error_border' => 'EBCCD1', |
|
| 406 | - 'error_text' => 'B94A48', |
|
| 407 | - 'error_font_size' => '14px', |
|
| 408 | - |
|
| 409 | - 'success_bg_color' => 'DFF0D8', |
|
| 410 | - 'success_border_color' => 'D6E9C6', |
|
| 411 | - 'success_text_color' => '468847', |
|
| 412 | - 'success_font_size' => '14px', |
|
| 413 | - |
|
| 414 | - 'important_style' => false, |
|
| 415 | - |
|
| 416 | - 'custom_css' => '', |
|
| 417 | - ); |
|
| 418 | - } |
|
| 373 | + 'section_bg_color' => '', |
|
| 374 | + 'section_border_color' => 'e8e8e8', |
|
| 375 | + 'section_border_width' => '2px', |
|
| 376 | + 'section_border_style' => 'solid', |
|
| 377 | + 'section_border_loc' => '-top', |
|
| 378 | + 'collapse_icon' => '6', |
|
| 379 | + 'collapse_pos' => 'after', |
|
| 380 | + 'repeat_icon' => '1', |
|
| 381 | + |
|
| 382 | + 'submit_style' => false, |
|
| 383 | + 'submit_font_size' => '14px', |
|
| 384 | + 'submit_width' => 'auto', |
|
| 385 | + 'submit_height' => 'auto', |
|
| 386 | + 'submit_bg_color' => 'ffffff', |
|
| 387 | + 'submit_border_color' => 'cccccc', |
|
| 388 | + 'submit_border_width' => '1px', |
|
| 389 | + 'submit_text_color' => '444444', |
|
| 390 | + 'submit_weight' => 'normal', |
|
| 391 | + 'submit_border_radius' => '4px', |
|
| 392 | + 'submit_bg_img' => '', |
|
| 393 | + 'submit_margin' => '10px', |
|
| 394 | + 'submit_padding' => '6px 11px', |
|
| 395 | + 'submit_shadow_color' => 'eeeeee', |
|
| 396 | + 'submit_hover_bg_color' => 'efefef', |
|
| 397 | + 'submit_hover_color' => '444444', |
|
| 398 | + 'submit_hover_border_color' => 'cccccc', |
|
| 399 | + 'submit_active_bg_color' => 'efefef', |
|
| 400 | + 'submit_active_color' => '444444', |
|
| 401 | + 'submit_active_border_color' => 'cccccc', |
|
| 402 | + |
|
| 403 | + 'border_radius' => '4px', |
|
| 404 | + 'error_bg' => 'F2DEDE', |
|
| 405 | + 'error_border' => 'EBCCD1', |
|
| 406 | + 'error_text' => 'B94A48', |
|
| 407 | + 'error_font_size' => '14px', |
|
| 408 | + |
|
| 409 | + 'success_bg_color' => 'DFF0D8', |
|
| 410 | + 'success_border_color' => 'D6E9C6', |
|
| 411 | + 'success_text_color' => '468847', |
|
| 412 | + 'success_font_size' => '14px', |
|
| 413 | + |
|
| 414 | + 'important_style' => false, |
|
| 415 | + |
|
| 416 | + 'custom_css' => '', |
|
| 417 | + ); |
|
| 418 | + } |
|
| 419 | 419 | |
| 420 | 420 | public function get_field_name( $field_name, $post_field = 'post_content' ) { |
| 421 | 421 | 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,17 +79,17 @@ 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 | |
@@ -103,9 +103,9 @@ discard block |
||
| 103 | 103 | */ |
| 104 | 104 | public function save_settings() { |
| 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,11 +114,11 @@ 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 | 119 | $this->clear_cache(); |
| 120 | 120 | |
| 121 | - set_transient('frmpro_css', $css); |
|
| 121 | + set_transient( 'frmpro_css', $css ); |
|
| 122 | 122 | } |
| 123 | 123 | |
| 124 | 124 | private function get_css_content( $filename ) { |
@@ -150,7 +150,7 @@ discard block |
||
| 150 | 150 | } |
| 151 | 151 | |
| 152 | 152 | public function destroy( $id ) { |
| 153 | - return wp_delete_post($id); |
|
| 153 | + return wp_delete_post( $id ); |
|
| 154 | 154 | } |
| 155 | 155 | |
| 156 | 156 | public function get_one() { |
@@ -164,19 +164,19 @@ discard block |
||
| 164 | 164 | return $style; |
| 165 | 165 | } |
| 166 | 166 | |
| 167 | - $style = get_post($this->id); |
|
| 167 | + $style = get_post( $this->id ); |
|
| 168 | 168 | |
| 169 | 169 | if ( ! $style ) { |
| 170 | 170 | return $style; |
| 171 | 171 | } |
| 172 | 172 | |
| 173 | - $style->post_content = FrmAppHelper::maybe_json_decode($style->post_content); |
|
| 173 | + $style->post_content = FrmAppHelper::maybe_json_decode( $style->post_content ); |
|
| 174 | 174 | |
| 175 | 175 | $default_values = $this->get_defaults(); |
| 176 | 176 | |
| 177 | 177 | // fill default values |
| 178 | - $style->post_content = $this->override_defaults($style->post_content); |
|
| 179 | - $style->post_content = wp_parse_args( $style->post_content, $default_values); |
|
| 178 | + $style->post_content = $this->override_defaults( $style->post_content ); |
|
| 179 | + $style->post_content = wp_parse_args( $style->post_content, $default_values ); |
|
| 180 | 180 | |
| 181 | 181 | return $style; |
| 182 | 182 | } |
@@ -190,21 +190,21 @@ discard block |
||
| 190 | 190 | 'order' => $order, |
| 191 | 191 | ); |
| 192 | 192 | |
| 193 | - $temp_styles = FrmAppHelper::check_cache(serialize($post_atts), 'frm_styles', $post_atts, 'get_posts'); |
|
| 193 | + $temp_styles = FrmAppHelper::check_cache( serialize( $post_atts ), 'frm_styles', $post_atts, 'get_posts' ); |
|
| 194 | 194 | |
| 195 | - if ( empty($temp_styles) ) { |
|
| 195 | + if ( empty( $temp_styles ) ) { |
|
| 196 | 196 | global $wpdb; |
| 197 | 197 | // make sure there wasn't a conflict with the query |
| 198 | 198 | $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' ); |
| 199 | - $temp_styles = FrmAppHelper::check_cache('frm_backup_style_check', 'frm_styles', $query, 'get_results'); |
|
| 199 | + $temp_styles = FrmAppHelper::check_cache( 'frm_backup_style_check', 'frm_styles', $query, 'get_results' ); |
|
| 200 | 200 | |
| 201 | - if ( empty($temp_styles) ) { |
|
| 201 | + if ( empty( $temp_styles ) ) { |
|
| 202 | 202 | // create a new style if there are none |
| 203 | 203 | $new = $this->get_new(); |
| 204 | 204 | $new->post_title = $new->post_name = __( 'Formidable Style', 'formidable' ); |
| 205 | 205 | $new->menu_order = 1; |
| 206 | - $new = $this->save( (array) $new); |
|
| 207 | - $this->update('default'); |
|
| 206 | + $new = $this->save( (array) $new ); |
|
| 207 | + $this->update( 'default' ); |
|
| 208 | 208 | |
| 209 | 209 | $post_atts['include'] = $new; |
| 210 | 210 | |
@@ -228,25 +228,25 @@ discard block |
||
| 228 | 228 | } |
| 229 | 229 | } |
| 230 | 230 | |
| 231 | - $style->post_content = FrmAppHelper::maybe_json_decode($style->post_content); |
|
| 231 | + $style->post_content = FrmAppHelper::maybe_json_decode( $style->post_content ); |
|
| 232 | 232 | |
| 233 | 233 | // fill default values |
| 234 | - $style->post_content = $this->override_defaults($style->post_content); |
|
| 235 | - $style->post_content = wp_parse_args( $style->post_content, $default_values); |
|
| 234 | + $style->post_content = $this->override_defaults( $style->post_content ); |
|
| 235 | + $style->post_content = wp_parse_args( $style->post_content, $default_values ); |
|
| 236 | 236 | |
| 237 | - $styles[ $style->ID ] = $style; |
|
| 237 | + $styles[$style->ID] = $style; |
|
| 238 | 238 | } |
| 239 | 239 | |
| 240 | 240 | if ( ! $default_style ) { |
| 241 | - $default_style = reset($styles); |
|
| 242 | - $styles[ $default_style->ID ]->menu_order = 1; |
|
| 241 | + $default_style = reset( $styles ); |
|
| 242 | + $styles[$default_style->ID]->menu_order = 1; |
|
| 243 | 243 | } |
| 244 | 244 | |
| 245 | 245 | return $styles; |
| 246 | 246 | } |
| 247 | 247 | |
| 248 | 248 | public function get_default_style( $styles = null ) { |
| 249 | - if ( ! isset($styles) ) { |
|
| 249 | + if ( ! isset( $styles ) ) { |
|
| 250 | 250 | $styles = $this->get_all( 'menu_order', 'DESC', 1 ); |
| 251 | 251 | } |
| 252 | 252 | |
@@ -258,24 +258,24 @@ discard block |
||
| 258 | 258 | } |
| 259 | 259 | |
| 260 | 260 | public function override_defaults( $settings ) { |
| 261 | - if ( ! is_array($settings) ) { |
|
| 261 | + if ( ! is_array( $settings ) ) { |
|
| 262 | 262 | return $settings; |
| 263 | 263 | } |
| 264 | 264 | |
| 265 | - $settings['line_height'] = ( ! isset($settings['field_height']) || $settings['field_height'] == '' || $settings['field_height'] == 'auto') ? 'normal' : $settings['field_height']; |
|
| 265 | + $settings['line_height'] = ( ! isset( $settings['field_height'] ) || $settings['field_height'] == '' || $settings['field_height'] == 'auto' ) ? 'normal' : $settings['field_height']; |
|
| 266 | 266 | |
| 267 | - if ( ! isset($settings['form_desc_size']) && isset($settings['description_font_size']) ) { |
|
| 267 | + if ( ! isset( $settings['form_desc_size'] ) && isset( $settings['description_font_size'] ) ) { |
|
| 268 | 268 | $settings['form_desc_size'] = $settings['description_font_size']; |
| 269 | 269 | $settings['form_desc_color'] = $settings['description_color']; |
| 270 | 270 | $settings['title_color'] = $settings['label_color']; |
| 271 | 271 | } |
| 272 | 272 | |
| 273 | - if ( ! isset($settings['section_color']) && isset($settings['label_color']) ) { |
|
| 273 | + if ( ! isset( $settings['section_color'] ) && isset( $settings['label_color'] ) ) { |
|
| 274 | 274 | $settings['section_color'] = $settings['label_color']; |
| 275 | 275 | $settings['section_border_color'] = $settings['border_color']; |
| 276 | 276 | } |
| 277 | 277 | |
| 278 | - if ( ! isset($settings['submit_hover_bg_color']) && isset($settings['submit_bg_color']) ) { |
|
| 278 | + if ( ! isset( $settings['submit_hover_bg_color'] ) && isset( $settings['submit_bg_color'] ) ) { |
|
| 279 | 279 | $settings['submit_hover_bg_color'] = $settings['submit_bg_color']; |
| 280 | 280 | $settings['submit_hover_color'] = $settings['submit_text_color']; |
| 281 | 281 | $settings['submit_hover_border_color'] = $settings['submit_border_color']; |
@@ -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 |
@@ -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 ); |
|
@@ -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 } ?> |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <p class="frm_no_top_margin"> |
| 2 | 2 | <label for="frm_submit_style"> |
| 3 | - <input type="checkbox" name="<?php echo esc_attr( $frm_style->get_field_name('submit_style') ) ?>" id="frm_submit_style" <?php checked( $style->post_content['submit_style'], 1 ) ?> value="1" /> |
|
| 3 | + <input type="checkbox" name="<?php echo esc_attr( $frm_style->get_field_name( 'submit_style' ) ) ?>" id="frm_submit_style" <?php checked( $style->post_content['submit_style'], 1 ) ?> value="1" /> |
|
| 4 | 4 | <?php esc_html_e( 'Disable submit button styling', 'formidable' ); ?> |
| 5 | 5 | <span class="frm_help frm_icon_font frm_tooltip_icon" title="<?php esc_attr_e( 'Note: If disabled, you may not see the change take effect until you make 2 more styling changes or click "Update Options".', 'formidable' ) ?>"></span> |
| 6 | 6 | </label> |
@@ -9,10 +9,10 @@ discard block |
||
| 9 | 9 | <div class="posttypediv"> |
| 10 | 10 | <ul class="posttype-tabs add-menu-item-tabs"> |
| 11 | 11 | <li <?php echo ( 'default' == $current_tab ? ' class="tabs"' : '' ); ?>> |
| 12 | - <a href="<?php echo esc_url('?page=formidable-styles&page-tab=default#tabs-panel-button-default') ?>" class="nav-tab-link" data-type="tabs-panel-button-default" ><?php _e( 'Default', 'formidable' ) ?></a> |
|
| 12 | + <a href="<?php echo esc_url( '?page=formidable-styles&page-tab=default#tabs-panel-button-default' ) ?>" class="nav-tab-link" data-type="tabs-panel-button-default" ><?php _e( 'Default', 'formidable' ) ?></a> |
|
| 13 | 13 | </li> |
| 14 | 14 | <li <?php echo ( 'button-hover' == $current_tab ? ' class="tabs"' : '' ); ?>> |
| 15 | - <a href="<?php echo esc_url('?page=formidable-styles&page-tab=button-hover#page-button-hover') ?>" class="nav-tab-link" data-type="tabs-panel-button-hover" ><?php _e( 'Hover', 'formidable' ) ?></a> |
|
| 15 | + <a href="<?php echo esc_url( '?page=formidable-styles&page-tab=button-hover#page-button-hover' ) ?>" class="nav-tab-link" data-type="tabs-panel-button-hover" ><?php _e( 'Hover', 'formidable' ) ?></a> |
|
| 16 | 16 | </li> |
| 17 | 17 | <li <?php echo ( 'button-click' == $current_tab ? ' class="tabs"' : '' ); ?>> |
| 18 | 18 | <a href="?page=formidable-styles&page-tab=button-click#tabs-panel-button-click" class="nav-tab-link" data-type="tabs-panel-button-click"><?php _e( 'Click', 'formidable' ) ?></a> |
@@ -24,22 +24,22 @@ discard block |
||
| 24 | 24 | ?>"> |
| 25 | 25 | <div class="field-group field-group-border clearfix"> |
| 26 | 26 | <label><?php _e( 'Size', 'formidable' ) ?></label> |
| 27 | - <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('submit_font_size') ) ?>" id="frm_submit_font_size" value="<?php echo esc_attr( $style->post_content['submit_font_size'] ) ?>" size="3" /> |
|
| 27 | + <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'submit_font_size' ) ) ?>" id="frm_submit_font_size" value="<?php echo esc_attr( $style->post_content['submit_font_size'] ) ?>" size="3" /> |
|
| 28 | 28 | </div> |
| 29 | 29 | |
| 30 | 30 | <div class="field-group clearfix"> |
| 31 | 31 | <label><?php _e( 'Width', 'formidable' ) ?></label> |
| 32 | - <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('submit_width') ) ?>" id="frm_submit_width" value="<?php echo esc_attr( $style->post_content['submit_width'] ) ?>" size="5" /> |
|
| 32 | + <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'submit_width' ) ) ?>" id="frm_submit_width" value="<?php echo esc_attr( $style->post_content['submit_width'] ) ?>" size="5" /> |
|
| 33 | 33 | </div> |
| 34 | 34 | |
| 35 | 35 | <div class="field-group clearfix"> |
| 36 | 36 | <label><?php _e( 'Height', 'formidable' ) ?></label> |
| 37 | - <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('submit_height') ) ?>" id="frm_submit_height" value="<?php echo esc_attr( $style->post_content['submit_height'] ) ?>" size="5" /> |
|
| 37 | + <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'submit_height' ) ) ?>" id="frm_submit_height" value="<?php echo esc_attr( $style->post_content['submit_height'] ) ?>" size="5" /> |
|
| 38 | 38 | </div> |
| 39 | 39 | |
| 40 | 40 | <div class="field-group clearfix"> |
| 41 | 41 | <label><?php _e( 'Weight', 'formidable' ) ?></label> |
| 42 | - <select name="<?php echo esc_attr( $frm_style->get_field_name('submit_weight') ) ?>" id="frm_submit_weight"> |
|
| 42 | + <select name="<?php echo esc_attr( $frm_style->get_field_name( 'submit_weight' ) ) ?>" id="frm_submit_weight"> |
|
| 43 | 43 | <?php foreach ( FrmStyle::get_bold_options() as $value => $name ) { ?> |
| 44 | 44 | <option value="<?php echo esc_attr( $value ) ?>" <?php selected( $style->post_content['submit_weight'], $value ) ?>><?php echo esc_html( $name ) ?></option> |
| 45 | 45 | <?php } ?> |
@@ -48,48 +48,48 @@ discard block |
||
| 48 | 48 | |
| 49 | 49 | <div class="field-group clearfix"> |
| 50 | 50 | <label><?php _e( 'Corners', 'formidable' ) ?></label> |
| 51 | - <input type="text" value="<?php echo esc_attr( $style->post_content['submit_border_radius'] ) ?>" name="<?php echo esc_attr( $frm_style->get_field_name('submit_border_radius') ) ?>" id="frm_submit_border_radius" size="4"/> |
|
| 51 | + <input type="text" value="<?php echo esc_attr( $style->post_content['submit_border_radius'] ) ?>" name="<?php echo esc_attr( $frm_style->get_field_name( 'submit_border_radius' ) ) ?>" id="frm_submit_border_radius" size="4"/> |
|
| 52 | 52 | </div> |
| 53 | 53 | |
| 54 | 54 | <div class="field-group field-group-border clearfix"> |
| 55 | 55 | <label><?php _e( 'BG Color', 'formidable' ) ?></label> |
| 56 | - <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('submit_bg_color') ) ?>" id="frm_submit_bg_color" class="hex" value="<?php echo esc_attr( $style->post_content['submit_bg_color'] ) ?>" /> |
|
| 56 | + <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'submit_bg_color' ) ) ?>" id="frm_submit_bg_color" class="hex" value="<?php echo esc_attr( $style->post_content['submit_bg_color'] ) ?>" /> |
|
| 57 | 57 | </div> |
| 58 | 58 | |
| 59 | 59 | <div class="field-group clearfix"> |
| 60 | 60 | <label><?php _e( 'Text', 'formidable' ) ?></label> |
| 61 | - <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('submit_text_color') ) ?>" id="frm_submit_text_color" class="hex" value="<?php echo esc_attr( $style->post_content['submit_text_color'] ) ?>" /> |
|
| 61 | + <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'submit_text_color' ) ) ?>" id="frm_submit_text_color" class="hex" value="<?php echo esc_attr( $style->post_content['submit_text_color'] ) ?>" /> |
|
| 62 | 62 | </div> |
| 63 | 63 | |
| 64 | 64 | <div class="field-group field-group-border clearfix"> |
| 65 | 65 | <label><?php _e( 'Border', 'formidable' ) ?></label> |
| 66 | - <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('submit_border_color') ) ?>" id="frm_submit_border_color" class="hex" value="<?php echo esc_attr( $style->post_content['submit_border_color'] ) ?>" /> |
|
| 66 | + <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'submit_border_color' ) ) ?>" id="frm_submit_border_color" class="hex" value="<?php echo esc_attr( $style->post_content['submit_border_color'] ) ?>" /> |
|
| 67 | 67 | </div> |
| 68 | 68 | |
| 69 | 69 | <div class="field-group clearfix"> |
| 70 | 70 | <label><?php _e( 'Thickness', 'formidable' ) ?></label> |
| 71 | - <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('submit_border_width') ) ?>" id="frm_submit_border_width" value="<?php echo esc_attr( $style->post_content['submit_border_width'] ) ?>" size="4" /> |
|
| 71 | + <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'submit_border_width' ) ) ?>" id="frm_submit_border_width" value="<?php echo esc_attr( $style->post_content['submit_border_width'] ) ?>" size="4" /> |
|
| 72 | 72 | </div> |
| 73 | 73 | |
| 74 | 74 | <div class="field-group clearfix"> |
| 75 | 75 | <label><?php _e( 'Shadow', 'formidable' ) ?></label> |
| 76 | - <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('submit_shadow_color') ) ?>" id="frm_submit_shadow_color" class="hex" value="<?php echo esc_attr( $style->post_content['submit_shadow_color'] ) ?>" /> |
|
| 76 | + <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'submit_shadow_color' ) ) ?>" id="frm_submit_shadow_color" class="hex" value="<?php echo esc_attr( $style->post_content['submit_shadow_color'] ) ?>" /> |
|
| 77 | 77 | </div> |
| 78 | 78 | |
| 79 | 79 | <div class="clear"></div> |
| 80 | 80 | <div class="field-group field-group-border frm-full"> |
| 81 | 81 | <label><?php _e( 'BG Image', 'formidable' ) ?></label> |
| 82 | - <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('submit_bg_img') ) ?>" id="frm_submit_bg_img" value="<?php echo esc_attr( $style->post_content['submit_bg_img'] ) ?>" /> |
|
| 82 | + <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'submit_bg_img' ) ) ?>" id="frm_submit_bg_img" value="<?php echo esc_attr( $style->post_content['submit_bg_img'] ) ?>" /> |
|
| 83 | 83 | </div> |
| 84 | 84 | |
| 85 | 85 | <div class="field-group field-group-border clearfix"> |
| 86 | 86 | <label><?php _e( 'Margin', 'formidable' ) ?></label> |
| 87 | - <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('submit_margin') ) ?>" id="frm_submit_margin" value="<?php echo esc_attr( $style->post_content['submit_margin'] ) ?>" size="6" /> |
|
| 87 | + <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'submit_margin' ) ) ?>" id="frm_submit_margin" value="<?php echo esc_attr( $style->post_content['submit_margin'] ) ?>" size="6" /> |
|
| 88 | 88 | </div> |
| 89 | 89 | |
| 90 | 90 | <div class="field-group clearfix"> |
| 91 | 91 | <label><?php _e( 'Padding', 'formidable' ) ?></label> |
| 92 | - <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('submit_padding') ) ?>" id="frm_submit_padding" value="<?php echo esc_attr( $style->post_content['submit_padding'] ) ?>" size="6" /> |
|
| 92 | + <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'submit_padding' ) ) ?>" id="frm_submit_padding" value="<?php echo esc_attr( $style->post_content['submit_padding'] ) ?>" size="6" /> |
|
| 93 | 93 | </div> |
| 94 | 94 | <div class="clear"></div> |
| 95 | 95 | </div><!-- /.tabs-panel --> |
@@ -99,17 +99,17 @@ discard block |
||
| 99 | 99 | ?>"> |
| 100 | 100 | <div class="field-group clearfix"> |
| 101 | 101 | <label><?php _e( 'BG Color', 'formidable' ) ?></label> |
| 102 | - <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('submit_hover_bg_color') ) ?>" id="frm_submit_hover_bg_color" class="hex" value="<?php echo esc_attr( $style->post_content['submit_hover_bg_color'] ) ?>" /> |
|
| 102 | + <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'submit_hover_bg_color' ) ) ?>" id="frm_submit_hover_bg_color" class="hex" value="<?php echo esc_attr( $style->post_content['submit_hover_bg_color'] ) ?>" /> |
|
| 103 | 103 | </div> |
| 104 | 104 | |
| 105 | 105 | <div class="field-group clearfix"> |
| 106 | 106 | <label><?php _e( 'Text', 'formidable' ) ?></label> |
| 107 | - <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('submit_hover_color') ) ?>" id="frm_submit_hover_color" class="hex" value="<?php echo esc_attr( $style->post_content['submit_hover_color'] ) ?>" /> |
|
| 107 | + <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'submit_hover_color' ) ) ?>" id="frm_submit_hover_color" class="hex" value="<?php echo esc_attr( $style->post_content['submit_hover_color'] ) ?>" /> |
|
| 108 | 108 | </div> |
| 109 | 109 | |
| 110 | 110 | <div class="field-group clearfix"> |
| 111 | 111 | <label><?php _e( 'Border', 'formidable' ) ?></label> |
| 112 | - <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('submit_hover_border_color') ) ?>" id="frm_submit_hover_border_color" class="hex" value="<?php echo esc_attr( $style->post_content['submit_hover_border_color'] ) ?>" /> |
|
| 112 | + <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'submit_hover_border_color' ) ) ?>" id="frm_submit_hover_border_color" class="hex" value="<?php echo esc_attr( $style->post_content['submit_hover_border_color'] ) ?>" /> |
|
| 113 | 113 | </div> |
| 114 | 114 | |
| 115 | 115 | <div class="clear"></div> |
@@ -120,17 +120,17 @@ discard block |
||
| 120 | 120 | ?>"> |
| 121 | 121 | <div class="field-group clearfix"> |
| 122 | 122 | <label><?php _e( 'BG Color', 'formidable' ) ?></label> |
| 123 | - <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('submit_active_bg_color') ) ?>" id="frm_submit_active_bg_color" class="hex" value="<?php echo esc_attr( $style->post_content['submit_active_bg_color'] ) ?>" /> |
|
| 123 | + <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'submit_active_bg_color' ) ) ?>" id="frm_submit_active_bg_color" class="hex" value="<?php echo esc_attr( $style->post_content['submit_active_bg_color'] ) ?>" /> |
|
| 124 | 124 | </div> |
| 125 | 125 | |
| 126 | 126 | <div class="field-group clearfix"> |
| 127 | 127 | <label><?php _e( 'Text', 'formidable' ) ?></label> |
| 128 | - <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('submit_active_color') ) ?>" id="frm_submit_active_color" class="hex" value="<?php echo esc_attr( $style->post_content['submit_active_color'] ) ?>" /> |
|
| 128 | + <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'submit_active_color' ) ) ?>" id="frm_submit_active_color" class="hex" value="<?php echo esc_attr( $style->post_content['submit_active_color'] ) ?>" /> |
|
| 129 | 129 | </div> |
| 130 | 130 | |
| 131 | 131 | <div class="field-group clearfix"> |
| 132 | 132 | <label><?php _e( 'Border', 'formidable' ) ?></label> |
| 133 | - <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('submit_active_border_color') ) ?>" id="frm_submit_active_border_color" class="hex" value="<?php echo esc_attr( $style->post_content['submit_active_border_color'] ) ?>" /> |
|
| 133 | + <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'submit_active_border_color' ) ) ?>" id="frm_submit_active_border_color" class="hex" value="<?php echo esc_attr( $style->post_content['submit_active_border_color'] ) ?>" /> |
|
| 134 | 134 | </div> |
| 135 | 135 | |
| 136 | 136 | <div class="clear"></div> |
@@ -2,26 +2,26 @@ discard block |
||
| 2 | 2 | |
| 3 | 3 | class FrmSettingsController { |
| 4 | 4 | |
| 5 | - public static function menu() { |
|
| 5 | + public static function menu() { |
|
| 6 | 6 | // Make sure admins can see the menu items |
| 7 | 7 | FrmAppHelper::force_capability( 'frm_change_settings' ); |
| 8 | 8 | |
| 9 | - add_submenu_page( 'formidable', 'Formidable | ' . __( 'Global Settings', 'formidable' ), __( 'Global Settings', 'formidable' ), 'frm_change_settings', 'formidable-settings', 'FrmSettingsController::route' ); |
|
| 10 | - } |
|
| 9 | + add_submenu_page( 'formidable', 'Formidable | ' . __( 'Global Settings', 'formidable' ), __( 'Global Settings', 'formidable' ), 'frm_change_settings', 'formidable-settings', 'FrmSettingsController::route' ); |
|
| 10 | + } |
|
| 11 | 11 | |
| 12 | - public static function license_box() { |
|
| 12 | + public static function license_box() { |
|
| 13 | 13 | $a = FrmAppHelper::simple_get( 't', 'sanitize_title', 'general_settings' ); |
| 14 | - include( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/license_box.php' ); |
|
| 15 | - } |
|
| 14 | + include( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/license_box.php' ); |
|
| 15 | + } |
|
| 16 | 16 | |
| 17 | - public static function display_form( $errors = array(), $message = '' ) { |
|
| 18 | - global $frm_vars; |
|
| 17 | + public static function display_form( $errors = array(), $message = '' ) { |
|
| 18 | + global $frm_vars; |
|
| 19 | 19 | |
| 20 | - $frm_settings = FrmAppHelper::get_settings(); |
|
| 21 | - $frm_roles = FrmAppHelper::frm_capabilities(); |
|
| 20 | + $frm_settings = FrmAppHelper::get_settings(); |
|
| 21 | + $frm_roles = FrmAppHelper::frm_capabilities(); |
|
| 22 | 22 | |
| 23 | - $uploads = wp_upload_dir(); |
|
| 24 | - $target_path = $uploads['basedir'] . '/formidable/css'; |
|
| 23 | + $uploads = wp_upload_dir(); |
|
| 24 | + $target_path = $uploads['basedir'] . '/formidable/css'; |
|
| 25 | 25 | |
| 26 | 26 | $sections = array(); |
| 27 | 27 | if ( apply_filters( 'frm_include_addon_page', false ) ) { |
@@ -30,53 +30,53 @@ discard block |
||
| 30 | 30 | 'name' => __( 'Plugin Licenses', 'formidable' ), |
| 31 | 31 | ); |
| 32 | 32 | } |
| 33 | - $sections = apply_filters( 'frm_add_settings_section', $sections ); |
|
| 33 | + $sections = apply_filters( 'frm_add_settings_section', $sections ); |
|
| 34 | 34 | |
| 35 | - $captcha_lang = FrmAppHelper::locales( 'captcha' ); |
|
| 35 | + $captcha_lang = FrmAppHelper::locales( 'captcha' ); |
|
| 36 | 36 | |
| 37 | - require( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/form.php' ); |
|
| 38 | - } |
|
| 37 | + require( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/form.php' ); |
|
| 38 | + } |
|
| 39 | 39 | |
| 40 | - public static function process_form( $stop_load = false ) { |
|
| 41 | - global $frm_vars; |
|
| 40 | + public static function process_form( $stop_load = false ) { |
|
| 41 | + global $frm_vars; |
|
| 42 | 42 | |
| 43 | - $frm_settings = FrmAppHelper::get_settings(); |
|
| 43 | + $frm_settings = FrmAppHelper::get_settings(); |
|
| 44 | 44 | |
| 45 | 45 | $process_form = FrmAppHelper::get_post_param( 'process_form', '', 'sanitize_text_field' ); |
| 46 | 46 | if ( ! wp_verify_nonce( $process_form, 'process_form_nonce' ) ) { |
| 47 | - wp_die( $frm_settings->admin_permission ); |
|
| 48 | - } |
|
| 47 | + wp_die( $frm_settings->admin_permission ); |
|
| 48 | + } |
|
| 49 | 49 | |
| 50 | - $errors = array(); |
|
| 51 | - $message = ''; |
|
| 50 | + $errors = array(); |
|
| 51 | + $message = ''; |
|
| 52 | 52 | |
| 53 | - if ( ! isset( $frm_vars['settings_routed'] ) || ! $frm_vars['settings_routed'] ) { |
|
| 54 | - //$errors = $frm_settings->validate($_POST,array()); |
|
| 55 | - $frm_settings->update( stripslashes_deep( $_POST ) ); |
|
| 53 | + if ( ! isset( $frm_vars['settings_routed'] ) || ! $frm_vars['settings_routed'] ) { |
|
| 54 | + //$errors = $frm_settings->validate($_POST,array()); |
|
| 55 | + $frm_settings->update( stripslashes_deep( $_POST ) ); |
|
| 56 | 56 | |
| 57 | - if ( empty( $errors ) ) { |
|
| 58 | - $frm_settings->store(); |
|
| 59 | - $message = __( 'Settings Saved', 'formidable' ); |
|
| 60 | - } |
|
| 61 | - } else { |
|
| 62 | - $message = __( 'Settings Saved', 'formidable' ); |
|
| 63 | - } |
|
| 57 | + if ( empty( $errors ) ) { |
|
| 58 | + $frm_settings->store(); |
|
| 59 | + $message = __( 'Settings Saved', 'formidable' ); |
|
| 60 | + } |
|
| 61 | + } else { |
|
| 62 | + $message = __( 'Settings Saved', 'formidable' ); |
|
| 63 | + } |
|
| 64 | 64 | |
| 65 | 65 | if ( $stop_load == 'stop_load' ) { |
| 66 | - $frm_vars['settings_routed'] = true; |
|
| 67 | - return; |
|
| 68 | - } |
|
| 66 | + $frm_vars['settings_routed'] = true; |
|
| 67 | + return; |
|
| 68 | + } |
|
| 69 | 69 | |
| 70 | - self::display_form( $errors, $message ); |
|
| 71 | - } |
|
| 70 | + self::display_form( $errors, $message ); |
|
| 71 | + } |
|
| 72 | 72 | |
| 73 | - public static function route( $stop_load = false ) { |
|
| 74 | - $action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action'; |
|
| 73 | + public static function route( $stop_load = false ) { |
|
| 74 | + $action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action'; |
|
| 75 | 75 | $action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' ); |
| 76 | - if ( $action == 'process-form' ) { |
|
| 76 | + if ( $action == 'process-form' ) { |
|
| 77 | 77 | self::process_form( $stop_load ); |
| 78 | - } else if ( $stop_load != 'stop_load' ) { |
|
| 78 | + } else if ( $stop_load != 'stop_load' ) { |
|
| 79 | 79 | self::display_form(); |
| 80 | - } |
|
| 81 | - } |
|
| 80 | + } |
|
| 81 | + } |
|
| 82 | 82 | } |
@@ -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('description_color') ) ?>" id="frm_description_color" class="hex" value="<?php echo esc_attr( $style->post_content['description_color'] ) ?>" /> |
|
| 3 | + <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'description_color' ) ) ?>" id="frm_description_color" class="hex" value="<?php echo esc_attr( $style->post_content['description_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('description_weight') ) ?>" id="frm_description_weight"> |
|
| 7 | + <select name="<?php echo esc_attr( $frm_style->get_field_name( 'description_weight' ) ) ?>" id="frm_description_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['description_weight'], $value ) ?>><?php echo esc_html( $name ) ?></option> |
| 10 | 10 | <?php } ?> |
@@ -12,25 +12,25 @@ discard block |
||
| 12 | 12 | </div> |
| 13 | 13 | <div class="field-group clearfix frm-first-row"> |
| 14 | 14 | <label><?php _e( 'Style', 'formidable' ) ?></label> |
| 15 | - <select name="<?php echo esc_attr( $frm_style->get_field_name('description_style') ) ?>" id="frm_description_style"> |
|
| 16 | - <option value="normal" <?php selected($style->post_content['description_style'], 'normal') ?>><?php _e( 'normal', 'formidable' ) ?></option> |
|
| 17 | - <option value="italic" <?php selected($style->post_content['description_style'], 'italic') ?>><?php _e( 'italic', 'formidable' ) ?></option> |
|
| 15 | + <select name="<?php echo esc_attr( $frm_style->get_field_name( 'description_style' ) ) ?>" id="frm_description_style"> |
|
| 16 | + <option value="normal" <?php selected( $style->post_content['description_style'], 'normal' ) ?>><?php _e( 'normal', 'formidable' ) ?></option> |
|
| 17 | + <option value="italic" <?php selected( $style->post_content['description_style'], 'italic' ) ?>><?php _e( 'italic', 'formidable' ) ?></option> |
|
| 18 | 18 | </select> |
| 19 | 19 | </div> |
| 20 | 20 | |
| 21 | 21 | <div class="field-group clearfix"> |
| 22 | 22 | <label><?php _e( 'Size', 'formidable' ) ?></label> |
| 23 | - <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('description_font_size') ) ?>" id="frm_description_font_size" value="<?php echo esc_attr( $style->post_content['description_font_size'] ) ?>" size="3" /> |
|
| 23 | + <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'description_font_size' ) ) ?>" id="frm_description_font_size" value="<?php echo esc_attr( $style->post_content['description_font_size'] ) ?>" size="3" /> |
|
| 24 | 24 | </div> |
| 25 | 25 | <div class="field-group clearfix"> |
| 26 | 26 | <label><?php _e( 'Align', 'formidable' ) ?></label> |
| 27 | - <select name="<?php echo esc_attr( $frm_style->get_field_name('description_align') ) ?>" id="frm_description_align"> |
|
| 28 | - <option value="left" <?php selected($style->post_content['description_align'], 'left') ?>><?php _e( 'left', 'formidable' ) ?></option> |
|
| 29 | - <option value="right" <?php selected($style->post_content['description_align'], 'right') ?>><?php _e( 'right', 'formidable' ) ?></option> |
|
| 27 | + <select name="<?php echo esc_attr( $frm_style->get_field_name( 'description_align' ) ) ?>" id="frm_description_align"> |
|
| 28 | + <option value="left" <?php selected( $style->post_content['description_align'], 'left' ) ?>><?php _e( 'left', 'formidable' ) ?></option> |
|
| 29 | + <option value="right" <?php selected( $style->post_content['description_align'], 'right' ) ?>><?php _e( 'right', 'formidable' ) ?></option> |
|
| 30 | 30 | </select> |
| 31 | 31 | </div> |
| 32 | 32 | <div class="field-group clearfix"> |
| 33 | 33 | <label><?php _e( 'Margin', 'formidable' ) ?></label> |
| 34 | - <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('description_margin') ) ?>" id="frm_description_margin" value="<?php echo esc_attr( $style->post_content['description_margin'] ) ?>" size="3" /> |
|
| 34 | + <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'description_margin' ) ) ?>" id="frm_description_margin" value="<?php echo esc_attr( $style->post_content['description_margin'] ) ?>" size="3" /> |
|
| 35 | 35 | </div> |
| 36 | 36 | <div class="clear"></div> |
@@ -308,7 +308,7 @@ |
||
| 308 | 308 | * |
| 309 | 309 | * @since 2.02.05 |
| 310 | 310 | * @param string $key |
| 311 | - * @param int|string $value |
|
| 311 | + * @param string $value |
|
| 312 | 312 | * @param string $where |
| 313 | 313 | */ |
| 314 | 314 | private static function add_query_placeholder( $key, $value, &$where ) { |
@@ -7,8 +7,8 @@ discard block |
||
| 7 | 7 | var $entry_metas; |
| 8 | 8 | |
| 9 | 9 | public function __construct() { |
| 10 | - if ( ! defined('ABSPATH') ) { |
|
| 11 | - die('You are not allowed to call this page directly.'); |
|
| 10 | + if ( ! defined( 'ABSPATH' ) ) { |
|
| 11 | + die( 'You are not allowed to call this page directly.' ); |
|
| 12 | 12 | } |
| 13 | 13 | |
| 14 | 14 | global $wpdb; |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | $frm_db_version = FrmAppHelper::$db_version; |
| 25 | 25 | $old_db_version = (float) $old_db_version; |
| 26 | 26 | if ( ! $old_db_version ) { |
| 27 | - $old_db_version = get_option('frm_db_version'); |
|
| 27 | + $old_db_version = get_option( 'frm_db_version' ); |
|
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | if ( $frm_db_version != $old_db_version ) { |
@@ -34,16 +34,16 @@ discard block |
||
| 34 | 34 | require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); |
| 35 | 35 | |
| 36 | 36 | $this->create_tables(); |
| 37 | - $this->migrate_data($frm_db_version, $old_db_version); |
|
| 37 | + $this->migrate_data( $frm_db_version, $old_db_version ); |
|
| 38 | 38 | |
| 39 | 39 | /***** SAVE DB VERSION *****/ |
| 40 | - update_option('frm_db_version', $frm_db_version); |
|
| 40 | + update_option( 'frm_db_version', $frm_db_version ); |
|
| 41 | 41 | |
| 42 | 42 | /**** ADD/UPDATE DEFAULT TEMPLATES ****/ |
| 43 | 43 | FrmXMLController::add_default_templates(); |
| 44 | 44 | } |
| 45 | 45 | |
| 46 | - do_action('frm_after_install'); |
|
| 46 | + do_action( 'frm_after_install' ); |
|
| 47 | 47 | |
| 48 | 48 | /**** update the styling settings ****/ |
| 49 | 49 | if ( is_admin() && function_exists( 'get_filesystem_method' ) ) { |
@@ -153,7 +153,7 @@ discard block |
||
| 153 | 153 | global $wpdb; |
| 154 | 154 | $wpdb->query( $q . $charset_collate ); |
| 155 | 155 | } |
| 156 | - unset($q); |
|
| 156 | + unset( $q ); |
|
| 157 | 157 | } |
| 158 | 158 | } |
| 159 | 159 | |
@@ -178,7 +178,7 @@ discard block |
||
| 178 | 178 | * @param string $starts_with |
| 179 | 179 | */ |
| 180 | 180 | public static function get_where_clause_and_values( &$args, $starts_with = ' WHERE ' ) { |
| 181 | - if ( empty($args) ) { |
|
| 181 | + if ( empty( $args ) ) { |
|
| 182 | 182 | // add an arg to prevent prepare from failing |
| 183 | 183 | $args = array( 'where' => $starts_with . '1=%d', 'values' => array( 1 ) ); |
| 184 | 184 | return; |
@@ -238,8 +238,8 @@ discard block |
||
| 238 | 238 | private static function interpret_array_to_sql( $key, $value, &$where, &$values ) { |
| 239 | 239 | $key = trim( $key ); |
| 240 | 240 | |
| 241 | - if ( strpos( $key, 'created_at' ) !== false || strpos( $key, 'updated_at' ) !== false ) { |
|
| 242 | - $k = explode(' ', $key); |
|
| 241 | + if ( strpos( $key, 'created_at' ) !== false || strpos( $key, 'updated_at' ) !== false ) { |
|
| 242 | + $k = explode( ' ', $key ); |
|
| 243 | 243 | $where .= ' DATE_FORMAT(' . reset( $k ) . ', %s) ' . str_replace( reset( $k ), '', $key ); |
| 244 | 244 | $values[] = '%Y-%m-%d %H:%i:%s'; |
| 245 | 245 | } else { |
@@ -252,7 +252,7 @@ discard block |
||
| 252 | 252 | if ( is_array( $value ) ) { |
| 253 | 253 | // translate array of values to "in" |
| 254 | 254 | if ( strpos( $lowercase_key, 'like' ) !== false ) { |
| 255 | - $where = preg_replace('/' . $key . '$/', '', $where); |
|
| 255 | + $where = preg_replace( '/' . $key . '$/', '', $where ); |
|
| 256 | 256 | $where .= '('; |
| 257 | 257 | $start = true; |
| 258 | 258 | foreach ( $value as $v ) { |
@@ -403,8 +403,8 @@ discard block |
||
| 403 | 403 | ); |
| 404 | 404 | |
| 405 | 405 | $where_is = strtolower( $where_is ); |
| 406 | - if ( isset( $switch_to[ $where_is ] ) ) { |
|
| 407 | - return ' ' . $switch_to[ $where_is ]; |
|
| 406 | + if ( isset( $switch_to[$where_is] ) ) { |
|
| 407 | + return ' ' . $switch_to[$where_is]; |
|
| 408 | 408 | } |
| 409 | 409 | |
| 410 | 410 | // > and < need a little more work since we don't want them switched to >= and <= |
@@ -426,8 +426,8 @@ discard block |
||
| 426 | 426 | private static function get_group_and_table_name( &$table, &$group ) { |
| 427 | 427 | global $wpdb, $wpmuBaseTablePrefix; |
| 428 | 428 | |
| 429 | - $table_parts = explode(' ', $table); |
|
| 430 | - $group = reset($table_parts); |
|
| 429 | + $table_parts = explode( ' ', $table ); |
|
| 430 | + $group = reset( $table_parts ); |
|
| 431 | 431 | $group = str_replace( $wpdb->prefix, '', $group ); |
| 432 | 432 | |
| 433 | 433 | $prefix = $wpmuBaseTablePrefix ? $wpmuBaseTablePrefix : $wpdb->base_prefix; |
@@ -442,7 +442,7 @@ discard block |
||
| 442 | 442 | } |
| 443 | 443 | |
| 444 | 444 | private static function convert_options_to_array( &$args, $order_by = '', $limit = '' ) { |
| 445 | - if ( ! is_array($args) ) { |
|
| 445 | + if ( ! is_array( $args ) ) { |
|
| 446 | 446 | $args = array( 'order_by' => $args ); |
| 447 | 447 | } |
| 448 | 448 | |
@@ -457,16 +457,16 @@ discard block |
||
| 457 | 457 | $temp_args = $args; |
| 458 | 458 | foreach ( $temp_args as $k => $v ) { |
| 459 | 459 | if ( $v == '' ) { |
| 460 | - unset( $args[ $k ] ); |
|
| 460 | + unset( $args[$k] ); |
|
| 461 | 461 | continue; |
| 462 | 462 | } |
| 463 | 463 | |
| 464 | 464 | if ( $k == 'limit' ) { |
| 465 | - $args[ $k ] = FrmAppHelper::esc_limit( $v ); |
|
| 465 | + $args[$k] = FrmAppHelper::esc_limit( $v ); |
|
| 466 | 466 | } |
| 467 | 467 | $db_name = strtoupper( str_replace( '_', ' ', $k ) ); |
| 468 | 468 | if ( strpos( $v, $db_name ) === false ) { |
| 469 | - $args[ $k ] = $db_name . ' ' . $v; |
|
| 469 | + $args[$k] = $db_name . ' ' . $v; |
|
| 470 | 470 | } |
| 471 | 471 | } |
| 472 | 472 | |
@@ -493,7 +493,7 @@ discard block |
||
| 493 | 493 | |
| 494 | 494 | $query = self::generate_query_string_from_pieces( $columns, $table, $where ); |
| 495 | 495 | |
| 496 | - $cache_key = str_replace( array( ' ', ',' ), '_', trim( implode( '_', FrmAppHelper::array_flatten( $where ) ) . $columns . '_results_ARRAY_A' , ' WHERE' ) ); |
|
| 496 | + $cache_key = str_replace( array( ' ', ',' ), '_', trim( implode( '_', FrmAppHelper::array_flatten( $where ) ) . $columns . '_results_ARRAY_A', ' WHERE' ) ); |
|
| 497 | 497 | $results = FrmAppHelper::check_cache( $cache_key, $group, $query, 'get_associative_results' ); |
| 498 | 498 | |
| 499 | 499 | return $results; |
@@ -532,7 +532,7 @@ discard block |
||
| 532 | 532 | public function uninstall() { |
| 533 | 533 | if ( ! current_user_can( 'administrator' ) ) { |
| 534 | 534 | $frm_settings = FrmAppHelper::get_settings(); |
| 535 | - wp_die($frm_settings->admin_permission); |
|
| 535 | + wp_die( $frm_settings->admin_permission ); |
|
| 536 | 536 | } |
| 537 | 537 | |
| 538 | 538 | global $wpdb, $wp_roles; |
@@ -542,8 +542,8 @@ discard block |
||
| 542 | 542 | $wpdb->query( 'DROP TABLE IF EXISTS ' . $this->entries ); |
| 543 | 543 | $wpdb->query( 'DROP TABLE IF EXISTS ' . $this->entry_metas ); |
| 544 | 544 | |
| 545 | - delete_option('frm_options'); |
|
| 546 | - delete_option('frm_db_version'); |
|
| 545 | + delete_option( 'frm_options' ); |
|
| 546 | + delete_option( 'frm_db_version' ); |
|
| 547 | 547 | |
| 548 | 548 | //delete roles |
| 549 | 549 | $frm_roles = FrmAppHelper::frm_capabilities(); |
@@ -551,11 +551,11 @@ discard block |
||
| 551 | 551 | foreach ( $frm_roles as $frm_role => $frm_role_description ) { |
| 552 | 552 | foreach ( $roles as $role => $details ) { |
| 553 | 553 | $wp_roles->remove_cap( $role, $frm_role ); |
| 554 | - unset($role, $details); |
|
| 554 | + unset( $role, $details ); |
|
| 555 | 555 | } |
| 556 | - unset($frm_role, $frm_role_description); |
|
| 556 | + unset( $frm_role, $frm_role_description ); |
|
| 557 | 557 | } |
| 558 | - unset($roles, $frm_roles); |
|
| 558 | + unset( $roles, $frm_roles ); |
|
| 559 | 559 | |
| 560 | 560 | // delete actions, views, and styles |
| 561 | 561 | |
@@ -577,7 +577,7 @@ discard block |
||
| 577 | 577 | |
| 578 | 578 | $wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->options . ' WHERE option_name LIKE %s OR option_name LIKE %s', '_transient_timeout_frm_form_fields_%', '_transient_frm_form_fields_%' ) ); |
| 579 | 579 | |
| 580 | - do_action('frm_after_uninstall'); |
|
| 580 | + do_action( 'frm_after_uninstall' ); |
|
| 581 | 581 | return true; |
| 582 | 582 | } |
| 583 | 583 | |
@@ -634,8 +634,8 @@ discard block |
||
| 634 | 634 | |
| 635 | 635 | $updated = 0; |
| 636 | 636 | foreach ( $fields as $f ) { |
| 637 | - $f->field_options = maybe_unserialize($f->field_options); |
|
| 638 | - if ( empty($f->field_options['size']) || ! is_numeric($f->field_options['size']) ) { |
|
| 637 | + $f->field_options = maybe_unserialize( $f->field_options ); |
|
| 638 | + if ( empty( $f->field_options['size'] ) || ! is_numeric( $f->field_options['size'] ) ) { |
|
| 639 | 639 | continue; |
| 640 | 640 | } |
| 641 | 641 | |
@@ -643,27 +643,27 @@ discard block |
||
| 643 | 643 | $f->field_options['size'] .= 'px'; |
| 644 | 644 | $u = FrmField::update( $f->id, array( 'field_options' => $f->field_options ) ); |
| 645 | 645 | if ( $u ) { |
| 646 | - $updated++; |
|
| 646 | + $updated ++; |
|
| 647 | 647 | } |
| 648 | - unset($f); |
|
| 648 | + unset( $f ); |
|
| 649 | 649 | } |
| 650 | 650 | |
| 651 | 651 | // Change the characters in widgets to pixels |
| 652 | - $widgets = get_option('widget_frm_show_form'); |
|
| 653 | - if ( empty($widgets) ) { |
|
| 652 | + $widgets = get_option( 'widget_frm_show_form' ); |
|
| 653 | + if ( empty( $widgets ) ) { |
|
| 654 | 654 | return; |
| 655 | 655 | } |
| 656 | 656 | |
| 657 | - $widgets = maybe_unserialize($widgets); |
|
| 657 | + $widgets = maybe_unserialize( $widgets ); |
|
| 658 | 658 | foreach ( $widgets as $k => $widget ) { |
| 659 | - if ( ! is_array($widget) || ! isset($widget['size']) ) { |
|
| 659 | + if ( ! is_array( $widget ) || ! isset( $widget['size'] ) ) { |
|
| 660 | 660 | continue; |
| 661 | 661 | } |
| 662 | 662 | $size = round( $pixel_conversion * (int) $widget['size'] ); |
| 663 | 663 | $size .= 'px'; |
| 664 | - $widgets[ $k ]['size'] = $size; |
|
| 664 | + $widgets[$k]['size'] = $size; |
|
| 665 | 665 | } |
| 666 | - update_option('widget_frm_show_form', $widgets); |
|
| 666 | + update_option( 'widget_frm_show_form', $widgets ); |
|
| 667 | 667 | } |
| 668 | 668 | |
| 669 | 669 | /** |
@@ -712,7 +712,7 @@ discard block |
||
| 712 | 712 | } |
| 713 | 713 | |
| 714 | 714 | // Format form options |
| 715 | - $form_options = maybe_unserialize($form->options); |
|
| 715 | + $form_options = maybe_unserialize( $form->options ); |
|
| 716 | 716 | |
| 717 | 717 | // Migrate settings to actions |
| 718 | 718 | FrmXMLHelper::migrate_form_settings_to_actions( $form_options, $form->id ); |
@@ -722,7 +722,7 @@ discard block |
||
| 722 | 722 | private function migrate_to_11() { |
| 723 | 723 | global $wpdb; |
| 724 | 724 | |
| 725 | - $forms = FrmDb::get_results( $this->forms, array(), 'id, options'); |
|
| 725 | + $forms = FrmDb::get_results( $this->forms, array(), 'id, options' ); |
|
| 726 | 726 | |
| 727 | 727 | $sending = __( 'Sending', 'formidable' ); |
| 728 | 728 | $img = FrmAppHelper::plugin_url() . '/images/ajax_loader.gif'; |
@@ -733,13 +733,13 @@ discard block |
||
| 733 | 733 | <img class="frm_ajax_loading" src="$img" alt="$sending" style="visibility:hidden;" /> |
| 734 | 734 | </div> |
| 735 | 735 | DEFAULT_HTML; |
| 736 | - unset($sending, $img); |
|
| 736 | + unset( $sending, $img ); |
|
| 737 | 737 | |
| 738 | - $new_default_html = FrmFormsHelper::get_default_html('submit'); |
|
| 738 | + $new_default_html = FrmFormsHelper::get_default_html( 'submit' ); |
|
| 739 | 739 | $draft_link = FrmFormsHelper::get_draft_link(); |
| 740 | 740 | foreach ( $forms as $form ) { |
| 741 | - $form->options = maybe_unserialize($form->options); |
|
| 742 | - if ( ! isset($form->options['submit_html']) || empty($form->options['submit_html']) ) { |
|
| 741 | + $form->options = maybe_unserialize( $form->options ); |
|
| 742 | + if ( ! isset( $form->options['submit_html'] ) || empty( $form->options['submit_html'] ) ) { |
|
| 743 | 743 | continue; |
| 744 | 744 | } |
| 745 | 745 | |
@@ -750,9 +750,9 @@ discard block |
||
| 750 | 750 | $form->options['submit_html'] = preg_replace( '~\<\/div\>(?!.*\<\/div\>)~', $draft_link . "\r\n</div>", $form->options['submit_html'] ); |
| 751 | 751 | $wpdb->update( $this->forms, array( 'options' => serialize( $form->options ) ), array( 'id' => $form->id ) ); |
| 752 | 752 | } |
| 753 | - unset($form); |
|
| 753 | + unset( $form ); |
|
| 754 | 754 | } |
| 755 | - unset($forms); |
|
| 755 | + unset( $forms ); |
|
| 756 | 756 | } |
| 757 | 757 | |
| 758 | 758 | private function migrate_to_6() { |
@@ -781,16 +781,16 @@ discard block |
||
| 781 | 781 | </div> |
| 782 | 782 | DEFAULT_HTML; |
| 783 | 783 | |
| 784 | - $new_default_html = FrmFieldsHelper::get_default_html('text'); |
|
| 784 | + $new_default_html = FrmFieldsHelper::get_default_html( 'text' ); |
|
| 785 | 785 | foreach ( $fields as $field ) { |
| 786 | - $field->field_options = maybe_unserialize($field->field_options); |
|
| 786 | + $field->field_options = maybe_unserialize( $field->field_options ); |
|
| 787 | 787 | if ( ! FrmField::is_option_empty( $field, 'custom_html' ) || $field->field_options['custom_html'] == $default_html || $field->field_options['custom_html'] == $old_default_html ) { |
| 788 | 788 | $field->field_options['custom_html'] = $new_default_html; |
| 789 | 789 | $wpdb->update( $this->fields, array( 'field_options' => maybe_serialize( $field->field_options ) ), array( 'id' => $field->id ) ); |
| 790 | 790 | } |
| 791 | - unset($field); |
|
| 791 | + unset( $field ); |
|
| 792 | 792 | } |
| 793 | - unset($default_html, $old_default_html, $fields); |
|
| 793 | + unset( $default_html, $old_default_html, $fields ); |
|
| 794 | 794 | } |
| 795 | 795 | |
| 796 | 796 | private function migrate_to_4() { |
@@ -808,6 +808,6 @@ discard block |
||
| 808 | 808 | |
| 809 | 809 | public static function get_records( $table, $args = array(), $order_by = '', $limit = '', $fields = '*' ) { |
| 810 | 810 | _deprecated_function( __FUNCTION__, '2.0', 'FrmDb::get_results' ); |
| 811 | - return self::get_results( $table, $args, $fields, compact('order_by', 'limit') ); |
|
| 811 | + return self::get_results( $table, $args, $fields, compact( 'order_by', 'limit' ) ); |
|
| 812 | 812 | } |
| 813 | 813 | } |
@@ -1,64 +1,64 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | class FrmDb { |
| 4 | - var $fields; |
|
| 5 | - var $forms; |
|
| 6 | - var $entries; |
|
| 7 | - var $entry_metas; |
|
| 8 | - |
|
| 9 | - public function __construct() { |
|
| 10 | - if ( ! defined('ABSPATH') ) { |
|
| 11 | - die('You are not allowed to call this page directly.'); |
|
| 12 | - } |
|
| 13 | - |
|
| 14 | - global $wpdb; |
|
| 15 | - $this->fields = $wpdb->prefix . 'frm_fields'; |
|
| 16 | - $this->forms = $wpdb->prefix . 'frm_forms'; |
|
| 17 | - $this->entries = $wpdb->prefix . 'frm_items'; |
|
| 18 | - $this->entry_metas = $wpdb->prefix . 'frm_item_metas'; |
|
| 19 | - } |
|
| 20 | - |
|
| 21 | - public function upgrade( $old_db_version = false ) { |
|
| 22 | - global $wpdb; |
|
| 23 | - //$frm_db_version is the version of the database we're moving to |
|
| 24 | - $frm_db_version = FrmAppHelper::$db_version; |
|
| 25 | - $old_db_version = (float) $old_db_version; |
|
| 26 | - if ( ! $old_db_version ) { |
|
| 27 | - $old_db_version = get_option('frm_db_version'); |
|
| 28 | - } |
|
| 29 | - |
|
| 30 | - if ( $frm_db_version != $old_db_version ) { |
|
| 4 | + var $fields; |
|
| 5 | + var $forms; |
|
| 6 | + var $entries; |
|
| 7 | + var $entry_metas; |
|
| 8 | + |
|
| 9 | + public function __construct() { |
|
| 10 | + if ( ! defined('ABSPATH') ) { |
|
| 11 | + die('You are not allowed to call this page directly.'); |
|
| 12 | + } |
|
| 13 | + |
|
| 14 | + global $wpdb; |
|
| 15 | + $this->fields = $wpdb->prefix . 'frm_fields'; |
|
| 16 | + $this->forms = $wpdb->prefix . 'frm_forms'; |
|
| 17 | + $this->entries = $wpdb->prefix . 'frm_items'; |
|
| 18 | + $this->entry_metas = $wpdb->prefix . 'frm_item_metas'; |
|
| 19 | + } |
|
| 20 | + |
|
| 21 | + public function upgrade( $old_db_version = false ) { |
|
| 22 | + global $wpdb; |
|
| 23 | + //$frm_db_version is the version of the database we're moving to |
|
| 24 | + $frm_db_version = FrmAppHelper::$db_version; |
|
| 25 | + $old_db_version = (float) $old_db_version; |
|
| 26 | + if ( ! $old_db_version ) { |
|
| 27 | + $old_db_version = get_option('frm_db_version'); |
|
| 28 | + } |
|
| 29 | + |
|
| 30 | + if ( $frm_db_version != $old_db_version ) { |
|
| 31 | 31 | // update rewrite rules for views and other custom post types |
| 32 | 32 | flush_rewrite_rules(); |
| 33 | 33 | |
| 34 | 34 | require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); |
| 35 | 35 | |
| 36 | - $this->create_tables(); |
|
| 37 | - $this->migrate_data($frm_db_version, $old_db_version); |
|
| 36 | + $this->create_tables(); |
|
| 37 | + $this->migrate_data($frm_db_version, $old_db_version); |
|
| 38 | 38 | |
| 39 | - /***** SAVE DB VERSION *****/ |
|
| 40 | - update_option('frm_db_version', $frm_db_version); |
|
| 39 | + /***** SAVE DB VERSION *****/ |
|
| 40 | + update_option('frm_db_version', $frm_db_version); |
|
| 41 | 41 | |
| 42 | - /**** ADD/UPDATE DEFAULT TEMPLATES ****/ |
|
| 43 | - FrmXMLController::add_default_templates(); |
|
| 44 | - } |
|
| 42 | + /**** ADD/UPDATE DEFAULT TEMPLATES ****/ |
|
| 43 | + FrmXMLController::add_default_templates(); |
|
| 44 | + } |
|
| 45 | 45 | |
| 46 | - do_action('frm_after_install'); |
|
| 46 | + do_action('frm_after_install'); |
|
| 47 | 47 | |
| 48 | - /**** update the styling settings ****/ |
|
| 48 | + /**** update the styling settings ****/ |
|
| 49 | 49 | if ( is_admin() && function_exists( 'get_filesystem_method' ) ) { |
| 50 | 50 | $frm_style = new FrmStyle(); |
| 51 | 51 | $frm_style->update( 'default' ); |
| 52 | 52 | } |
| 53 | - } |
|
| 53 | + } |
|
| 54 | 54 | |
| 55 | - public function collation() { |
|
| 56 | - global $wpdb; |
|
| 57 | - if ( ! $wpdb->has_cap( 'collation' ) ) { |
|
| 58 | - return ''; |
|
| 59 | - } |
|
| 55 | + public function collation() { |
|
| 56 | + global $wpdb; |
|
| 57 | + if ( ! $wpdb->has_cap( 'collation' ) ) { |
|
| 58 | + return ''; |
|
| 59 | + } |
|
| 60 | 60 | |
| 61 | - $charset_collate = ''; |
|
| 61 | + $charset_collate = ''; |
|
| 62 | 62 | if ( ! empty( $wpdb->charset ) ) { |
| 63 | 63 | $charset_collate .= ' DEFAULT CHARACTER SET ' . $wpdb->charset; |
| 64 | 64 | } |
@@ -67,14 +67,14 @@ discard block |
||
| 67 | 67 | $charset_collate .= ' COLLATE ' . $wpdb->collate; |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | - return $charset_collate; |
|
| 71 | - } |
|
| 70 | + return $charset_collate; |
|
| 71 | + } |
|
| 72 | 72 | |
| 73 | - private function create_tables() { |
|
| 74 | - $charset_collate = $this->collation(); |
|
| 75 | - $sql = array(); |
|
| 73 | + private function create_tables() { |
|
| 74 | + $charset_collate = $this->collation(); |
|
| 75 | + $sql = array(); |
|
| 76 | 76 | |
| 77 | - /* Create/Upgrade Fields Table */ |
|
| 77 | + /* Create/Upgrade Fields Table */ |
|
| 78 | 78 | $sql[] = 'CREATE TABLE ' . $this->fields . ' ( |
| 79 | 79 | id int(11) NOT NULL auto_increment, |
| 80 | 80 | field_key varchar(100) default NULL, |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | UNIQUE KEY field_key (field_key) |
| 94 | 94 | )'; |
| 95 | 95 | |
| 96 | - /* Create/Upgrade Forms Table */ |
|
| 96 | + /* Create/Upgrade Forms Table */ |
|
| 97 | 97 | $sql[] = 'CREATE TABLE ' . $this->forms . ' ( |
| 98 | 98 | id int(11) NOT NULL auto_increment, |
| 99 | 99 | form_key varchar(100) default NULL, |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | UNIQUE KEY form_key (form_key) |
| 112 | 112 | )'; |
| 113 | 113 | |
| 114 | - /* Create/Upgrade Items Table */ |
|
| 114 | + /* Create/Upgrade Items Table */ |
|
| 115 | 115 | $sql[] = 'CREATE TABLE ' . $this->entries . ' ( |
| 116 | 116 | id int(11) NOT NULL auto_increment, |
| 117 | 117 | item_key varchar(100) default NULL, |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | UNIQUE KEY item_key (item_key) |
| 135 | 135 | )'; |
| 136 | 136 | |
| 137 | - /* Create/Upgrade Meta Table */ |
|
| 137 | + /* Create/Upgrade Meta Table */ |
|
| 138 | 138 | $sql[] = 'CREATE TABLE ' . $this->entry_metas . ' ( |
| 139 | 139 | id int(11) NOT NULL auto_increment, |
| 140 | 140 | meta_value longtext default NULL, |
@@ -146,43 +146,43 @@ discard block |
||
| 146 | 146 | KEY item_id (item_id) |
| 147 | 147 | )'; |
| 148 | 148 | |
| 149 | - foreach ( $sql as $q ) { |
|
| 149 | + foreach ( $sql as $q ) { |
|
| 150 | 150 | if ( function_exists( 'dbDelta' ) ) { |
| 151 | 151 | dbDelta( $q . $charset_collate . ';' ); |
| 152 | 152 | } else { |
| 153 | 153 | global $wpdb; |
| 154 | 154 | $wpdb->query( $q . $charset_collate ); |
| 155 | 155 | } |
| 156 | - unset($q); |
|
| 157 | - } |
|
| 158 | - } |
|
| 156 | + unset($q); |
|
| 157 | + } |
|
| 158 | + } |
|
| 159 | 159 | |
| 160 | - /** |
|
| 161 | - * @param integer $frm_db_version |
|
| 160 | + /** |
|
| 161 | + * @param integer $frm_db_version |
|
| 162 | 162 | * @param int $old_db_version |
| 163 | - */ |
|
| 163 | + */ |
|
| 164 | 164 | private function migrate_data( $frm_db_version, $old_db_version ) { |
| 165 | 165 | $migrations = array( 4, 6, 11, 16, 17, 23, 25 ); |
| 166 | - foreach ( $migrations as $migration ) { |
|
| 167 | - if ( $frm_db_version >= $migration && $old_db_version < $migration ) { |
|
| 166 | + foreach ( $migrations as $migration ) { |
|
| 167 | + if ( $frm_db_version >= $migration && $old_db_version < $migration ) { |
|
| 168 | 168 | $function_name = 'migrate_to_' . $migration; |
| 169 | - $this->$function_name(); |
|
| 170 | - } |
|
| 171 | - } |
|
| 172 | - } |
|
| 169 | + $this->$function_name(); |
|
| 170 | + } |
|
| 171 | + } |
|
| 172 | + } |
|
| 173 | 173 | |
| 174 | - /** |
|
| 175 | - * Change array into format $wpdb->prepare can use |
|
| 174 | + /** |
|
| 175 | + * Change array into format $wpdb->prepare can use |
|
| 176 | 176 | * |
| 177 | 177 | * @param array $args |
| 178 | 178 | * @param string $starts_with |
| 179 | - */ |
|
| 180 | - public static function get_where_clause_and_values( &$args, $starts_with = ' WHERE ' ) { |
|
| 181 | - if ( empty($args) ) { |
|
| 179 | + */ |
|
| 180 | + public static function get_where_clause_and_values( &$args, $starts_with = ' WHERE ' ) { |
|
| 181 | + if ( empty($args) ) { |
|
| 182 | 182 | // add an arg to prevent prepare from failing |
| 183 | 183 | $args = array( 'where' => $starts_with . '1=%d', 'values' => array( 1 ) ); |
| 184 | 184 | return; |
| 185 | - } |
|
| 185 | + } |
|
| 186 | 186 | |
| 187 | 187 | $where = ''; |
| 188 | 188 | $values = array(); |
@@ -193,64 +193,64 @@ discard block |
||
| 193 | 193 | } |
| 194 | 194 | |
| 195 | 195 | $args = compact( 'where', 'values' ); |
| 196 | - } |
|
| 196 | + } |
|
| 197 | 197 | |
| 198 | - /** |
|
| 198 | + /** |
|
| 199 | 199 | * @param array $args |
| 200 | - * @param string $base_where |
|
| 201 | - * @param string $where |
|
| 200 | + * @param string $base_where |
|
| 201 | + * @param string $where |
|
| 202 | 202 | * @param array $values |
| 203 | - */ |
|
| 204 | - public static function parse_where_from_array( $args, $base_where, &$where, &$values ) { |
|
| 205 | - $condition = ' AND'; |
|
| 206 | - if ( isset( $args['or'] ) ) { |
|
| 207 | - $condition = ' OR'; |
|
| 208 | - unset( $args['or'] ); |
|
| 209 | - } |
|
| 210 | - |
|
| 211 | - foreach ( $args as $key => $value ) { |
|
| 212 | - $where .= empty( $where ) ? $base_where : $condition; |
|
| 213 | - $array_inc_null = ( ! is_numeric( $key ) && is_array( $value ) && in_array( null, $value ) ); |
|
| 214 | - if ( is_numeric( $key ) || $array_inc_null ) { |
|
| 215 | - $where .= ' ( '; |
|
| 216 | - $nested_where = ''; |
|
| 217 | - if ( $array_inc_null ) { |
|
| 218 | - foreach ( $value as $val ) { |
|
| 219 | - self::parse_where_from_array( array( $key => $val, 'or' => 1 ), '', $nested_where, $values ); |
|
| 220 | - } |
|
| 221 | - } else { |
|
| 222 | - self::parse_where_from_array( $value, '', $nested_where, $values ); |
|
| 223 | - } |
|
| 224 | - $where .= $nested_where; |
|
| 225 | - $where .= ' ) '; |
|
| 226 | - } else { |
|
| 227 | - self::interpret_array_to_sql( $key, $value, $where, $values ); |
|
| 228 | - } |
|
| 229 | - } |
|
| 230 | - } |
|
| 231 | - |
|
| 232 | - /** |
|
| 233 | - * @param string $key |
|
| 203 | + */ |
|
| 204 | + public static function parse_where_from_array( $args, $base_where, &$where, &$values ) { |
|
| 205 | + $condition = ' AND'; |
|
| 206 | + if ( isset( $args['or'] ) ) { |
|
| 207 | + $condition = ' OR'; |
|
| 208 | + unset( $args['or'] ); |
|
| 209 | + } |
|
| 210 | + |
|
| 211 | + foreach ( $args as $key => $value ) { |
|
| 212 | + $where .= empty( $where ) ? $base_where : $condition; |
|
| 213 | + $array_inc_null = ( ! is_numeric( $key ) && is_array( $value ) && in_array( null, $value ) ); |
|
| 214 | + if ( is_numeric( $key ) || $array_inc_null ) { |
|
| 215 | + $where .= ' ( '; |
|
| 216 | + $nested_where = ''; |
|
| 217 | + if ( $array_inc_null ) { |
|
| 218 | + foreach ( $value as $val ) { |
|
| 219 | + self::parse_where_from_array( array( $key => $val, 'or' => 1 ), '', $nested_where, $values ); |
|
| 220 | + } |
|
| 221 | + } else { |
|
| 222 | + self::parse_where_from_array( $value, '', $nested_where, $values ); |
|
| 223 | + } |
|
| 224 | + $where .= $nested_where; |
|
| 225 | + $where .= ' ) '; |
|
| 226 | + } else { |
|
| 227 | + self::interpret_array_to_sql( $key, $value, $where, $values ); |
|
| 228 | + } |
|
| 229 | + } |
|
| 230 | + } |
|
| 231 | + |
|
| 232 | + /** |
|
| 233 | + * @param string $key |
|
| 234 | 234 | * @param string|array $value |
| 235 | - * @param string $where |
|
| 235 | + * @param string $where |
|
| 236 | 236 | * @param array $values |
| 237 | - */ |
|
| 238 | - private static function interpret_array_to_sql( $key, $value, &$where, &$values ) { |
|
| 237 | + */ |
|
| 238 | + private static function interpret_array_to_sql( $key, $value, &$where, &$values ) { |
|
| 239 | 239 | $key = trim( $key ); |
| 240 | 240 | |
| 241 | - if ( strpos( $key, 'created_at' ) !== false || strpos( $key, 'updated_at' ) !== false ) { |
|
| 242 | - $k = explode(' ', $key); |
|
| 243 | - $where .= ' DATE_FORMAT(' . reset( $k ) . ', %s) ' . str_replace( reset( $k ), '', $key ); |
|
| 244 | - $values[] = '%Y-%m-%d %H:%i:%s'; |
|
| 245 | - } else { |
|
| 241 | + if ( strpos( $key, 'created_at' ) !== false || strpos( $key, 'updated_at' ) !== false ) { |
|
| 242 | + $k = explode(' ', $key); |
|
| 243 | + $where .= ' DATE_FORMAT(' . reset( $k ) . ', %s) ' . str_replace( reset( $k ), '', $key ); |
|
| 244 | + $values[] = '%Y-%m-%d %H:%i:%s'; |
|
| 245 | + } else { |
|
| 246 | 246 | $where .= ' ' . $key; |
| 247 | - } |
|
| 247 | + } |
|
| 248 | 248 | |
| 249 | 249 | $lowercase_key = explode( ' ', strtolower( $key ) ); |
| 250 | 250 | $lowercase_key = end( $lowercase_key ); |
| 251 | 251 | |
| 252 | - if ( is_array( $value ) ) { |
|
| 253 | - // translate array of values to "in" |
|
| 252 | + if ( is_array( $value ) ) { |
|
| 253 | + // translate array of values to "in" |
|
| 254 | 254 | if ( strpos( $lowercase_key, 'like' ) !== false ) { |
| 255 | 255 | $where = preg_replace('/' . $key . '$/', '', $where); |
| 256 | 256 | $where .= '('; |
@@ -268,7 +268,7 @@ discard block |
||
| 268 | 268 | $where .= ' in (' . FrmAppHelper::prepare_array_values( $value, '%s' ) . ')'; |
| 269 | 269 | $values = array_merge( $values, $value ); |
| 270 | 270 | } |
| 271 | - } else if ( strpos( $lowercase_key, 'like' ) !== false ) { |
|
| 271 | + } else if ( strpos( $lowercase_key, 'like' ) !== false ) { |
|
| 272 | 272 | /** |
| 273 | 273 | * Allow string to start or end with the value |
| 274 | 274 | * If the key is like% then skip the first % for starts with |
@@ -287,9 +287,9 @@ discard block |
||
| 287 | 287 | $where .= ' %s'; |
| 288 | 288 | $values[] = $start . FrmAppHelper::esc_like( $value ) . $end; |
| 289 | 289 | |
| 290 | - } else if ( $value === null ) { |
|
| 291 | - $where .= ' IS NULL'; |
|
| 292 | - } else { |
|
| 290 | + } else if ( $value === null ) { |
|
| 291 | + $where .= ' IS NULL'; |
|
| 292 | + } else { |
|
| 293 | 293 | // allow a - to prevent = from being added |
| 294 | 294 | if ( substr( $key, -1 ) == '-' ) { |
| 295 | 295 | $where = rtrim( $where, '-' ); |
@@ -299,9 +299,9 @@ discard block |
||
| 299 | 299 | |
| 300 | 300 | self::add_query_placeholder( $key, $value, $where ); |
| 301 | 301 | |
| 302 | - $values[] = $value; |
|
| 303 | - } |
|
| 304 | - } |
|
| 302 | + $values[] = $value; |
|
| 303 | + } |
|
| 304 | + } |
|
| 305 | 305 | |
| 306 | 306 | /** |
| 307 | 307 | * Add %d, or %s to query |
@@ -311,7 +311,7 @@ discard block |
||
| 311 | 311 | * @param int|string $value |
| 312 | 312 | * @param string $where |
| 313 | 313 | */ |
| 314 | - private static function add_query_placeholder( $key, $value, &$where ) { |
|
| 314 | + private static function add_query_placeholder( $key, $value, &$where ) { |
|
| 315 | 315 | if ( is_numeric( $value ) && strpos( $key, 'meta_value' ) === false ) { |
| 316 | 316 | $where .= '%d'; |
| 317 | 317 | } else { |
@@ -319,16 +319,16 @@ discard block |
||
| 319 | 319 | } |
| 320 | 320 | } |
| 321 | 321 | |
| 322 | - /** |
|
| 323 | - * @param string $table |
|
| 322 | + /** |
|
| 323 | + * @param string $table |
|
| 324 | 324 | * @param array $where |
| 325 | 325 | * @param array $args |
| 326 | 326 | * @return int |
| 327 | - */ |
|
| 328 | - public static function get_count( $table, $where = array(), $args = array() ) { |
|
| 329 | - $count = self::get_var( $table, $where, 'COUNT(*)', $args ); |
|
| 330 | - return $count; |
|
| 331 | - } |
|
| 327 | + */ |
|
| 328 | + public static function get_count( $table, $where = array(), $args = array() ) { |
|
| 329 | + $count = self::get_var( $table, $where, 'COUNT(*)', $args ); |
|
| 330 | + return $count; |
|
| 331 | + } |
|
| 332 | 332 | |
| 333 | 333 | /** |
| 334 | 334 | * @param string $table |
@@ -339,56 +339,56 @@ discard block |
||
| 339 | 339 | * @param string $type |
| 340 | 340 | * @return array|null|string|object |
| 341 | 341 | */ |
| 342 | - public static function get_var( $table, $where = array(), $field = 'id', $args = array(), $limit = '', $type = 'var' ) { |
|
| 343 | - $group = ''; |
|
| 344 | - self::get_group_and_table_name( $table, $group ); |
|
| 342 | + public static function get_var( $table, $where = array(), $field = 'id', $args = array(), $limit = '', $type = 'var' ) { |
|
| 343 | + $group = ''; |
|
| 344 | + self::get_group_and_table_name( $table, $group ); |
|
| 345 | 345 | self::convert_options_to_array( $args, '', $limit ); |
| 346 | 346 | |
| 347 | 347 | $query = self::generate_query_string_from_pieces( $field, $table, $where, $args ); |
| 348 | 348 | |
| 349 | 349 | $cache_key = str_replace( array( ' ', ',' ), '_', trim( implode( '_', FrmAppHelper::array_flatten( $where ) ) . implode( '_', $args ) . $field . '_' . $type, ' WHERE' ) ); |
| 350 | 350 | $results = FrmAppHelper::check_cache( $cache_key, $group, $query, 'get_' . $type ); |
| 351 | - return $results; |
|
| 352 | - } |
|
| 351 | + return $results; |
|
| 352 | + } |
|
| 353 | 353 | |
| 354 | - /** |
|
| 355 | - * @param string $table |
|
| 356 | - * @param array $where |
|
| 354 | + /** |
|
| 355 | + * @param string $table |
|
| 356 | + * @param array $where |
|
| 357 | 357 | * @param string $field |
| 358 | 358 | * @param array $args |
| 359 | 359 | * @param string $limit |
| 360 | 360 | * @return mixed |
| 361 | - */ |
|
| 362 | - public static function get_col( $table, $where = array(), $field = 'id', $args = array(), $limit = '' ) { |
|
| 363 | - return self::get_var( $table, $where, $field, $args, $limit, 'col' ); |
|
| 364 | - } |
|
| 365 | - |
|
| 366 | - /** |
|
| 367 | - * @since 2.0 |
|
| 368 | - * @param string $table |
|
| 361 | + */ |
|
| 362 | + public static function get_col( $table, $where = array(), $field = 'id', $args = array(), $limit = '' ) { |
|
| 363 | + return self::get_var( $table, $where, $field, $args, $limit, 'col' ); |
|
| 364 | + } |
|
| 365 | + |
|
| 366 | + /** |
|
| 367 | + * @since 2.0 |
|
| 368 | + * @param string $table |
|
| 369 | 369 | * @param array $where |
| 370 | 370 | * @param string $fields |
| 371 | 371 | * @param array $args |
| 372 | 372 | * @return mixed |
| 373 | - */ |
|
| 374 | - public static function get_row( $table, $where = array(), $fields = '*', $args = array() ) { |
|
| 375 | - $args['limit'] = 1; |
|
| 376 | - return self::get_var( $table, $where, $fields, $args, '', 'row' ); |
|
| 377 | - } |
|
| 378 | - |
|
| 379 | - /** |
|
| 380 | - * Prepare a key/value array before DB call |
|
| 373 | + */ |
|
| 374 | + public static function get_row( $table, $where = array(), $fields = '*', $args = array() ) { |
|
| 375 | + $args['limit'] = 1; |
|
| 376 | + return self::get_var( $table, $where, $fields, $args, '', 'row' ); |
|
| 377 | + } |
|
| 378 | + |
|
| 379 | + /** |
|
| 380 | + * Prepare a key/value array before DB call |
|
| 381 | 381 | * |
| 382 | - * @since 2.0 |
|
| 383 | - * @param string $table |
|
| 382 | + * @since 2.0 |
|
| 383 | + * @param string $table |
|
| 384 | 384 | * @param array $where |
| 385 | 385 | * @param string $fields |
| 386 | 386 | * @param array $args |
| 387 | 387 | * @return mixed |
| 388 | - */ |
|
| 389 | - public static function get_results( $table, $where = array(), $fields = '*', $args = array() ) { |
|
| 390 | - return self::get_var( $table, $where, $fields, $args, '', 'results' ); |
|
| 391 | - } |
|
| 388 | + */ |
|
| 389 | + public static function get_results( $table, $where = array(), $fields = '*', $args = array() ) { |
|
| 390 | + return self::get_var( $table, $where, $fields, $args, '', 'results' ); |
|
| 391 | + } |
|
| 392 | 392 | |
| 393 | 393 | /** |
| 394 | 394 | * Check for like, not like, in, not in, =, !=, >, <, <=, >= |
@@ -425,59 +425,59 @@ discard block |
||
| 425 | 425 | return ''; |
| 426 | 426 | } |
| 427 | 427 | |
| 428 | - /** |
|
| 429 | - * Get 'frm_forms' from wp_frm_forms or a longer table param that includes a join |
|
| 430 | - * Also add the wpdb->prefix to the table if it's missing |
|
| 431 | - * |
|
| 432 | - * @param string $table |
|
| 433 | - * @param string $group |
|
| 434 | - */ |
|
| 435 | - private static function get_group_and_table_name( &$table, &$group ) { |
|
| 428 | + /** |
|
| 429 | + * Get 'frm_forms' from wp_frm_forms or a longer table param that includes a join |
|
| 430 | + * Also add the wpdb->prefix to the table if it's missing |
|
| 431 | + * |
|
| 432 | + * @param string $table |
|
| 433 | + * @param string $group |
|
| 434 | + */ |
|
| 435 | + private static function get_group_and_table_name( &$table, &$group ) { |
|
| 436 | 436 | global $wpdb, $wpmuBaseTablePrefix; |
| 437 | 437 | |
| 438 | - $table_parts = explode(' ', $table); |
|
| 439 | - $group = reset($table_parts); |
|
| 440 | - $group = str_replace( $wpdb->prefix, '', $group ); |
|
| 438 | + $table_parts = explode(' ', $table); |
|
| 439 | + $group = reset($table_parts); |
|
| 440 | + $group = str_replace( $wpdb->prefix, '', $group ); |
|
| 441 | 441 | |
| 442 | 442 | $prefix = $wpmuBaseTablePrefix ? $wpmuBaseTablePrefix : $wpdb->base_prefix; |
| 443 | 443 | $group = str_replace( $prefix, '', $group ); |
| 444 | 444 | |
| 445 | - if ( $group == $table ) { |
|
| 446 | - $table = $wpdb->prefix . $table; |
|
| 447 | - } |
|
| 445 | + if ( $group == $table ) { |
|
| 446 | + $table = $wpdb->prefix . $table; |
|
| 447 | + } |
|
| 448 | 448 | |
| 449 | 449 | // switch to singular group name |
| 450 | 450 | $group = rtrim( $group, 's' ); |
| 451 | - } |
|
| 451 | + } |
|
| 452 | 452 | |
| 453 | - private static function convert_options_to_array( &$args, $order_by = '', $limit = '' ) { |
|
| 454 | - if ( ! is_array($args) ) { |
|
| 453 | + private static function convert_options_to_array( &$args, $order_by = '', $limit = '' ) { |
|
| 454 | + if ( ! is_array($args) ) { |
|
| 455 | 455 | $args = array( 'order_by' => $args ); |
| 456 | - } |
|
| 456 | + } |
|
| 457 | 457 | |
| 458 | - if ( ! empty( $order_by ) ) { |
|
| 459 | - $args['order_by'] = $order_by; |
|
| 460 | - } |
|
| 458 | + if ( ! empty( $order_by ) ) { |
|
| 459 | + $args['order_by'] = $order_by; |
|
| 460 | + } |
|
| 461 | 461 | |
| 462 | - if ( ! empty( $limit ) ) { |
|
| 463 | - $args['limit'] = $limit; |
|
| 464 | - } |
|
| 462 | + if ( ! empty( $limit ) ) { |
|
| 463 | + $args['limit'] = $limit; |
|
| 464 | + } |
|
| 465 | 465 | |
| 466 | - $temp_args = $args; |
|
| 467 | - foreach ( $temp_args as $k => $v ) { |
|
| 468 | - if ( $v == '' ) { |
|
| 466 | + $temp_args = $args; |
|
| 467 | + foreach ( $temp_args as $k => $v ) { |
|
| 468 | + if ( $v == '' ) { |
|
| 469 | 469 | unset( $args[ $k ] ); |
| 470 | - continue; |
|
| 471 | - } |
|
| 470 | + continue; |
|
| 471 | + } |
|
| 472 | 472 | |
| 473 | - if ( $k == 'limit' ) { |
|
| 473 | + if ( $k == 'limit' ) { |
|
| 474 | 474 | $args[ $k ] = FrmAppHelper::esc_limit( $v ); |
| 475 | - } |
|
| 476 | - $db_name = strtoupper( str_replace( '_', ' ', $k ) ); |
|
| 477 | - if ( strpos( $v, $db_name ) === false ) { |
|
| 475 | + } |
|
| 476 | + $db_name = strtoupper( str_replace( '_', ' ', $k ) ); |
|
| 477 | + if ( strpos( $v, $db_name ) === false ) { |
|
| 478 | 478 | $args[ $k ] = $db_name . ' ' . $v; |
| 479 | - } |
|
| 480 | - } |
|
| 479 | + } |
|
| 480 | + } |
|
| 481 | 481 | |
| 482 | 482 | // Make sure LIMIT is the last argument |
| 483 | 483 | if ( isset( $args['order_by'] ) && isset( $args['limit'] ) ) { |
@@ -485,7 +485,7 @@ discard block |
||
| 485 | 485 | unset( $args['limit'] ); |
| 486 | 486 | $args['limit'] = $temp_limit; |
| 487 | 487 | } |
| 488 | - } |
|
| 488 | + } |
|
| 489 | 489 | |
| 490 | 490 | /** |
| 491 | 491 | * Get the associative array results for the given columns, table, and where query |
@@ -538,31 +538,31 @@ discard block |
||
| 538 | 538 | return $query; |
| 539 | 539 | } |
| 540 | 540 | |
| 541 | - public function uninstall() { |
|
| 541 | + public function uninstall() { |
|
| 542 | 542 | if ( ! current_user_can( 'administrator' ) ) { |
| 543 | - $frm_settings = FrmAppHelper::get_settings(); |
|
| 544 | - wp_die($frm_settings->admin_permission); |
|
| 545 | - } |
|
| 543 | + $frm_settings = FrmAppHelper::get_settings(); |
|
| 544 | + wp_die($frm_settings->admin_permission); |
|
| 545 | + } |
|
| 546 | 546 | |
| 547 | - global $wpdb, $wp_roles; |
|
| 547 | + global $wpdb, $wp_roles; |
|
| 548 | 548 | |
| 549 | 549 | $wpdb->query( 'DROP TABLE IF EXISTS ' . $this->fields ); |
| 550 | 550 | $wpdb->query( 'DROP TABLE IF EXISTS ' . $this->forms ); |
| 551 | 551 | $wpdb->query( 'DROP TABLE IF EXISTS ' . $this->entries ); |
| 552 | 552 | $wpdb->query( 'DROP TABLE IF EXISTS ' . $this->entry_metas ); |
| 553 | 553 | |
| 554 | - delete_option('frm_options'); |
|
| 555 | - delete_option('frm_db_version'); |
|
| 554 | + delete_option('frm_options'); |
|
| 555 | + delete_option('frm_db_version'); |
|
| 556 | 556 | |
| 557 | - //delete roles |
|
| 558 | - $frm_roles = FrmAppHelper::frm_capabilities(); |
|
| 559 | - $roles = get_editable_roles(); |
|
| 560 | - foreach ( $frm_roles as $frm_role => $frm_role_description ) { |
|
| 561 | - foreach ( $roles as $role => $details ) { |
|
| 562 | - $wp_roles->remove_cap( $role, $frm_role ); |
|
| 563 | - unset($role, $details); |
|
| 564 | - } |
|
| 565 | - unset($frm_role, $frm_role_description); |
|
| 557 | + //delete roles |
|
| 558 | + $frm_roles = FrmAppHelper::frm_capabilities(); |
|
| 559 | + $roles = get_editable_roles(); |
|
| 560 | + foreach ( $frm_roles as $frm_role => $frm_role_description ) { |
|
| 561 | + foreach ( $roles as $role => $details ) { |
|
| 562 | + $wp_roles->remove_cap( $role, $frm_role ); |
|
| 563 | + unset($role, $details); |
|
| 564 | + } |
|
| 565 | + unset($frm_role, $frm_role_description); |
|
| 566 | 566 | } |
| 567 | 567 | unset($roles, $frm_roles); |
| 568 | 568 | |
@@ -586,9 +586,9 @@ discard block |
||
| 586 | 586 | |
| 587 | 587 | $wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->options . ' WHERE option_name LIKE %s OR option_name LIKE %s', '_transient_timeout_frm_form_fields_%', '_transient_frm_form_fields_%' ) ); |
| 588 | 588 | |
| 589 | - do_action('frm_after_uninstall'); |
|
| 590 | - return true; |
|
| 591 | - } |
|
| 589 | + do_action('frm_after_uninstall'); |
|
| 590 | + return true; |
|
| 591 | + } |
|
| 592 | 592 | |
| 593 | 593 | /** |
| 594 | 594 | * Migrate old styling settings. If sites are using the old |
@@ -627,150 +627,150 @@ discard block |
||
| 627 | 627 | } |
| 628 | 628 | } |
| 629 | 629 | |
| 630 | - /** |
|
| 631 | - * Change field size from character to pixel -- Multiply by 9 |
|
| 632 | - */ |
|
| 633 | - private function migrate_to_17() { |
|
| 634 | - global $wpdb; |
|
| 630 | + /** |
|
| 631 | + * Change field size from character to pixel -- Multiply by 9 |
|
| 632 | + */ |
|
| 633 | + private function migrate_to_17() { |
|
| 634 | + global $wpdb; |
|
| 635 | 635 | $pixel_conversion = 9; |
| 636 | 636 | |
| 637 | - // Get query arguments |
|
| 637 | + // Get query arguments |
|
| 638 | 638 | $field_types = array( 'textarea', 'text', 'number', 'email', 'url', 'rte', 'date', 'phone', 'password', 'image', 'tag', 'file' ); |
| 639 | 639 | $query = array( 'type' => $field_types, 'field_options like' => 's:4:"size";', 'field_options not like' => 's:4:"size";s:0:' ); |
| 640 | 640 | |
| 641 | - // Get results |
|
| 641 | + // Get results |
|
| 642 | 642 | $fields = FrmDb::get_results( $this->fields, $query, 'id, field_options' ); |
| 643 | 643 | |
| 644 | - $updated = 0; |
|
| 645 | - foreach ( $fields as $f ) { |
|
| 646 | - $f->field_options = maybe_unserialize($f->field_options); |
|
| 647 | - if ( empty($f->field_options['size']) || ! is_numeric($f->field_options['size']) ) { |
|
| 648 | - continue; |
|
| 649 | - } |
|
| 644 | + $updated = 0; |
|
| 645 | + foreach ( $fields as $f ) { |
|
| 646 | + $f->field_options = maybe_unserialize($f->field_options); |
|
| 647 | + if ( empty($f->field_options['size']) || ! is_numeric($f->field_options['size']) ) { |
|
| 648 | + continue; |
|
| 649 | + } |
|
| 650 | 650 | |
| 651 | 651 | $f->field_options['size'] = round( $pixel_conversion * (int) $f->field_options['size'] ); |
| 652 | - $f->field_options['size'] .= 'px'; |
|
| 653 | - $u = FrmField::update( $f->id, array( 'field_options' => $f->field_options ) ); |
|
| 654 | - if ( $u ) { |
|
| 655 | - $updated++; |
|
| 656 | - } |
|
| 657 | - unset($f); |
|
| 658 | - } |
|
| 659 | - |
|
| 660 | - // Change the characters in widgets to pixels |
|
| 661 | - $widgets = get_option('widget_frm_show_form'); |
|
| 662 | - if ( empty($widgets) ) { |
|
| 663 | - return; |
|
| 664 | - } |
|
| 665 | - |
|
| 666 | - $widgets = maybe_unserialize($widgets); |
|
| 667 | - foreach ( $widgets as $k => $widget ) { |
|
| 668 | - if ( ! is_array($widget) || ! isset($widget['size']) ) { |
|
| 669 | - continue; |
|
| 670 | - } |
|
| 652 | + $f->field_options['size'] .= 'px'; |
|
| 653 | + $u = FrmField::update( $f->id, array( 'field_options' => $f->field_options ) ); |
|
| 654 | + if ( $u ) { |
|
| 655 | + $updated++; |
|
| 656 | + } |
|
| 657 | + unset($f); |
|
| 658 | + } |
|
| 659 | + |
|
| 660 | + // Change the characters in widgets to pixels |
|
| 661 | + $widgets = get_option('widget_frm_show_form'); |
|
| 662 | + if ( empty($widgets) ) { |
|
| 663 | + return; |
|
| 664 | + } |
|
| 665 | + |
|
| 666 | + $widgets = maybe_unserialize($widgets); |
|
| 667 | + foreach ( $widgets as $k => $widget ) { |
|
| 668 | + if ( ! is_array($widget) || ! isset($widget['size']) ) { |
|
| 669 | + continue; |
|
| 670 | + } |
|
| 671 | 671 | $size = round( $pixel_conversion * (int) $widget['size'] ); |
| 672 | - $size .= 'px'; |
|
| 672 | + $size .= 'px'; |
|
| 673 | 673 | $widgets[ $k ]['size'] = $size; |
| 674 | - } |
|
| 675 | - update_option('widget_frm_show_form', $widgets); |
|
| 676 | - } |
|
| 677 | - |
|
| 678 | - /** |
|
| 679 | - * Migrate post and email notification settings into actions |
|
| 680 | - */ |
|
| 681 | - private function migrate_to_16() { |
|
| 682 | - global $wpdb; |
|
| 683 | - |
|
| 684 | - $forms = FrmDb::get_results( $this->forms, array(), 'id, options, is_template, default_template' ); |
|
| 685 | - |
|
| 686 | - /** |
|
| 687 | - * Old email settings format: |
|
| 688 | - * email_to: Email or field id |
|
| 689 | - * also_email_to: array of fields ids |
|
| 690 | - * reply_to: Email, field id, 'custom' |
|
| 691 | - * cust_reply_to: string |
|
| 692 | - * reply_to_name: field id, 'custom' |
|
| 693 | - * cust_reply_to_name: string |
|
| 694 | - * plain_text: 0|1 |
|
| 695 | - * email_message: string or '' |
|
| 696 | - * email_subject: string or '' |
|
| 697 | - * inc_user_info: 0|1 |
|
| 698 | - * update_email: 0, 1, 2 |
|
| 699 | - * |
|
| 700 | - * Old autoresponder settings format: |
|
| 701 | - * auto_responder: 0|1 |
|
| 702 | - * ar_email_message: string or '' |
|
| 703 | - * ar_email_to: field id |
|
| 704 | - * ar_plain_text: 0|1 |
|
| 705 | - * ar_reply_to_name: string |
|
| 706 | - * ar_reply_to: string |
|
| 707 | - * ar_email_subject: string |
|
| 708 | - * ar_update_email: 0, 1, 2 |
|
| 709 | - * |
|
| 710 | - * New email settings: |
|
| 711 | - * post_content: json settings |
|
| 712 | - * post_title: form id |
|
| 713 | - * post_excerpt: message |
|
| 714 | - * |
|
| 715 | - */ |
|
| 716 | - |
|
| 717 | - foreach ( $forms as $form ) { |
|
| 674 | + } |
|
| 675 | + update_option('widget_frm_show_form', $widgets); |
|
| 676 | + } |
|
| 677 | + |
|
| 678 | + /** |
|
| 679 | + * Migrate post and email notification settings into actions |
|
| 680 | + */ |
|
| 681 | + private function migrate_to_16() { |
|
| 682 | + global $wpdb; |
|
| 683 | + |
|
| 684 | + $forms = FrmDb::get_results( $this->forms, array(), 'id, options, is_template, default_template' ); |
|
| 685 | + |
|
| 686 | + /** |
|
| 687 | + * Old email settings format: |
|
| 688 | + * email_to: Email or field id |
|
| 689 | + * also_email_to: array of fields ids |
|
| 690 | + * reply_to: Email, field id, 'custom' |
|
| 691 | + * cust_reply_to: string |
|
| 692 | + * reply_to_name: field id, 'custom' |
|
| 693 | + * cust_reply_to_name: string |
|
| 694 | + * plain_text: 0|1 |
|
| 695 | + * email_message: string or '' |
|
| 696 | + * email_subject: string or '' |
|
| 697 | + * inc_user_info: 0|1 |
|
| 698 | + * update_email: 0, 1, 2 |
|
| 699 | + * |
|
| 700 | + * Old autoresponder settings format: |
|
| 701 | + * auto_responder: 0|1 |
|
| 702 | + * ar_email_message: string or '' |
|
| 703 | + * ar_email_to: field id |
|
| 704 | + * ar_plain_text: 0|1 |
|
| 705 | + * ar_reply_to_name: string |
|
| 706 | + * ar_reply_to: string |
|
| 707 | + * ar_email_subject: string |
|
| 708 | + * ar_update_email: 0, 1, 2 |
|
| 709 | + * |
|
| 710 | + * New email settings: |
|
| 711 | + * post_content: json settings |
|
| 712 | + * post_title: form id |
|
| 713 | + * post_excerpt: message |
|
| 714 | + * |
|
| 715 | + */ |
|
| 716 | + |
|
| 717 | + foreach ( $forms as $form ) { |
|
| 718 | 718 | if ( $form->is_template && $form->default_template ) { |
| 719 | 719 | // don't migrate the default templates since the email will be added anyway |
| 720 | 720 | continue; |
| 721 | 721 | } |
| 722 | 722 | |
| 723 | - // Format form options |
|
| 724 | - $form_options = maybe_unserialize($form->options); |
|
| 723 | + // Format form options |
|
| 724 | + $form_options = maybe_unserialize($form->options); |
|
| 725 | 725 | |
| 726 | - // Migrate settings to actions |
|
| 727 | - FrmXMLHelper::migrate_form_settings_to_actions( $form_options, $form->id ); |
|
| 728 | - } |
|
| 729 | - } |
|
| 726 | + // Migrate settings to actions |
|
| 727 | + FrmXMLHelper::migrate_form_settings_to_actions( $form_options, $form->id ); |
|
| 728 | + } |
|
| 729 | + } |
|
| 730 | 730 | |
| 731 | - private function migrate_to_11() { |
|
| 732 | - global $wpdb; |
|
| 731 | + private function migrate_to_11() { |
|
| 732 | + global $wpdb; |
|
| 733 | 733 | |
| 734 | - $forms = FrmDb::get_results( $this->forms, array(), 'id, options'); |
|
| 734 | + $forms = FrmDb::get_results( $this->forms, array(), 'id, options'); |
|
| 735 | 735 | |
| 736 | - $sending = __( 'Sending', 'formidable' ); |
|
| 736 | + $sending = __( 'Sending', 'formidable' ); |
|
| 737 | 737 | $img = FrmAppHelper::plugin_url() . '/images/ajax_loader.gif'; |
| 738 | - $old_default_html = <<<DEFAULT_HTML |
|
| 738 | + $old_default_html = <<<DEFAULT_HTML |
|
| 739 | 739 | <div class="frm_submit"> |
| 740 | 740 | [if back_button]<input type="submit" value="[back_label]" name="frm_prev_page" formnovalidate="formnovalidate" [back_hook] />[/if back_button] |
| 741 | 741 | <input type="submit" value="[button_label]" [button_action] /> |
| 742 | 742 | <img class="frm_ajax_loading" src="$img" alt="$sending" style="visibility:hidden;" /> |
| 743 | 743 | </div> |
| 744 | 744 | DEFAULT_HTML; |
| 745 | - unset($sending, $img); |
|
| 745 | + unset($sending, $img); |
|
| 746 | 746 | |
| 747 | - $new_default_html = FrmFormsHelper::get_default_html('submit'); |
|
| 748 | - $draft_link = FrmFormsHelper::get_draft_link(); |
|
| 747 | + $new_default_html = FrmFormsHelper::get_default_html('submit'); |
|
| 748 | + $draft_link = FrmFormsHelper::get_draft_link(); |
|
| 749 | 749 | foreach ( $forms as $form ) { |
| 750 | - $form->options = maybe_unserialize($form->options); |
|
| 751 | - if ( ! isset($form->options['submit_html']) || empty($form->options['submit_html']) ) { |
|
| 752 | - continue; |
|
| 753 | - } |
|
| 750 | + $form->options = maybe_unserialize($form->options); |
|
| 751 | + if ( ! isset($form->options['submit_html']) || empty($form->options['submit_html']) ) { |
|
| 752 | + continue; |
|
| 753 | + } |
|
| 754 | 754 | |
| 755 | - if ( $form->options['submit_html'] != $new_default_html && $form->options['submit_html'] == $old_default_html ) { |
|
| 756 | - $form->options['submit_html'] = $new_default_html; |
|
| 755 | + if ( $form->options['submit_html'] != $new_default_html && $form->options['submit_html'] == $old_default_html ) { |
|
| 756 | + $form->options['submit_html'] = $new_default_html; |
|
| 757 | 757 | $wpdb->update( $this->forms, array( 'options' => serialize( $form->options ) ), array( 'id' => $form->id ) ); |
| 758 | 758 | } else if ( ! strpos( $form->options['submit_html'], 'save_draft' ) ) { |
| 759 | 759 | $form->options['submit_html'] = preg_replace( '~\<\/div\>(?!.*\<\/div\>)~', $draft_link . "\r\n</div>", $form->options['submit_html'] ); |
| 760 | 760 | $wpdb->update( $this->forms, array( 'options' => serialize( $form->options ) ), array( 'id' => $form->id ) ); |
| 761 | - } |
|
| 762 | - unset($form); |
|
| 763 | - } |
|
| 764 | - unset($forms); |
|
| 765 | - } |
|
| 761 | + } |
|
| 762 | + unset($form); |
|
| 763 | + } |
|
| 764 | + unset($forms); |
|
| 765 | + } |
|
| 766 | 766 | |
| 767 | - private function migrate_to_6() { |
|
| 768 | - global $wpdb; |
|
| 767 | + private function migrate_to_6() { |
|
| 768 | + global $wpdb; |
|
| 769 | 769 | |
| 770 | 770 | $no_save = array_merge( FrmField::no_save_fields(), array( 'form', 'hidden', 'user_id' ) ); |
| 771 | 771 | $fields = FrmDb::get_results( $this->fields, array( 'type NOT' => $no_save ), 'id, field_options' ); |
| 772 | 772 | |
| 773 | - $default_html = <<<DEFAULT_HTML |
|
| 773 | + $default_html = <<<DEFAULT_HTML |
|
| 774 | 774 | <div id="frm_field_[id]_container" class="form-field [required_class] [error_class]"> |
| 775 | 775 | <label class="frm_pos_[label_position]">[field_name] |
| 776 | 776 | <span class="frm_required">[required_label]</span> |
@@ -780,7 +780,7 @@ discard block |
||
| 780 | 780 | </div> |
| 781 | 781 | DEFAULT_HTML; |
| 782 | 782 | |
| 783 | - $old_default_html = <<<DEFAULT_HTML |
|
| 783 | + $old_default_html = <<<DEFAULT_HTML |
|
| 784 | 784 | <div id="frm_field_[id]_container" class="form-field [required_class] [error_class]"> |
| 785 | 785 | <label class="frm_pos_[label_position]">[field_name] |
| 786 | 786 | <span class="frm_required">[required_label]</span> |
@@ -790,25 +790,25 @@ discard block |
||
| 790 | 790 | </div> |
| 791 | 791 | DEFAULT_HTML; |
| 792 | 792 | |
| 793 | - $new_default_html = FrmFieldsHelper::get_default_html('text'); |
|
| 794 | - foreach ( $fields as $field ) { |
|
| 795 | - $field->field_options = maybe_unserialize($field->field_options); |
|
| 793 | + $new_default_html = FrmFieldsHelper::get_default_html('text'); |
|
| 794 | + foreach ( $fields as $field ) { |
|
| 795 | + $field->field_options = maybe_unserialize($field->field_options); |
|
| 796 | 796 | if ( ! FrmField::is_option_empty( $field, 'custom_html' ) || $field->field_options['custom_html'] == $default_html || $field->field_options['custom_html'] == $old_default_html ) { |
| 797 | - $field->field_options['custom_html'] = $new_default_html; |
|
| 797 | + $field->field_options['custom_html'] = $new_default_html; |
|
| 798 | 798 | $wpdb->update( $this->fields, array( 'field_options' => maybe_serialize( $field->field_options ) ), array( 'id' => $field->id ) ); |
| 799 | - } |
|
| 800 | - unset($field); |
|
| 801 | - } |
|
| 802 | - unset($default_html, $old_default_html, $fields); |
|
| 803 | - } |
|
| 804 | - |
|
| 805 | - private function migrate_to_4() { |
|
| 806 | - global $wpdb; |
|
| 799 | + } |
|
| 800 | + unset($field); |
|
| 801 | + } |
|
| 802 | + unset($default_html, $old_default_html, $fields); |
|
| 803 | + } |
|
| 804 | + |
|
| 805 | + private function migrate_to_4() { |
|
| 806 | + global $wpdb; |
|
| 807 | 807 | $user_ids = FrmEntryMeta::getAll( array( 'fi.type' => 'user_id' ) ); |
| 808 | - foreach ( $user_ids as $user_id ) { |
|
| 808 | + foreach ( $user_ids as $user_id ) { |
|
| 809 | 809 | $wpdb->update( $this->entries, array( 'user_id' => $user_id->meta_value ), array( 'id' => $user_id->item_id ) ); |
| 810 | - } |
|
| 811 | - } |
|
| 810 | + } |
|
| 811 | + } |
|
| 812 | 812 | |
| 813 | 813 | public static function get_one_record( $table, $args = array(), $fields = '*', $order_by = '' ) { |
| 814 | 814 | _deprecated_function( __FUNCTION__, '2.0', 'FrmDb::get_row' ); |
@@ -3,7 +3,7 @@ discard block |
||
| 3 | 3 | class FrmFieldsController { |
| 4 | 4 | |
| 5 | 5 | public static function load_field() { |
| 6 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 6 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
| 7 | 7 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 8 | 8 | |
| 9 | 9 | $fields = $_POST['field']; |
@@ -34,17 +34,17 @@ discard block |
||
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | $field_name = 'item_meta[' . $field_id . ']'; |
| 37 | - $html_id = FrmFieldsHelper::get_html_id($field); |
|
| 37 | + $html_id = FrmFieldsHelper::get_html_id( $field ); |
|
| 38 | 38 | |
| 39 | 39 | ob_start(); |
| 40 | 40 | include( $path . '/classes/views/frm-forms/add_field.php' ); |
| 41 | - $field_html[ $field_id ] = ob_get_contents(); |
|
| 41 | + $field_html[$field_id] = ob_get_contents(); |
|
| 42 | 42 | ob_end_clean(); |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | - unset($path); |
|
| 45 | + unset( $path ); |
|
| 46 | 46 | |
| 47 | - echo json_encode($field_html); |
|
| 47 | + echo json_encode( $field_html ); |
|
| 48 | 48 | |
| 49 | 49 | wp_die(); |
| 50 | 50 | } |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | * Create a new field with ajax |
| 54 | 54 | */ |
| 55 | 55 | public static function create() { |
| 56 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 56 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
| 57 | 57 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 58 | 58 | |
| 59 | 59 | $field_type = FrmAppHelper::get_post_param( 'field_type', '', 'sanitize_text_field' ); |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | $field = self::include_new_field( $field_type, $form_id ); |
| 63 | 63 | |
| 64 | 64 | // this hook will allow for multiple fields to be added at once |
| 65 | - do_action('frm_after_field_created', $field, $form_id); |
|
| 65 | + do_action( 'frm_after_field_created', $field, $form_id ); |
|
| 66 | 66 | |
| 67 | 67 | wp_die(); |
| 68 | 68 | } |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | public static function include_new_field( $field_type, $form_id ) { |
| 78 | 78 | $values = array(); |
| 79 | 79 | if ( FrmAppHelper::pro_is_installed() ) { |
| 80 | - $values['post_type'] = FrmProFormsHelper::post_type($form_id); |
|
| 80 | + $values['post_type'] = FrmProFormsHelper::post_type( $form_id ); |
|
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | $field_values = FrmFieldsHelper::setup_new_vars( $field_type, $form_id ); |
@@ -89,27 +89,27 @@ discard block |
||
| 89 | 89 | return false; |
| 90 | 90 | } |
| 91 | 91 | |
| 92 | - $field = self::include_single_field($field_id, $values, $form_id); |
|
| 92 | + $field = self::include_single_field( $field_id, $values, $form_id ); |
|
| 93 | 93 | |
| 94 | 94 | return $field; |
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | public static function edit_name( $field = 'name', $id = '' ) { |
| 98 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 98 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
| 99 | 99 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 100 | 100 | |
| 101 | - if ( empty($field) ) { |
|
| 101 | + if ( empty( $field ) ) { |
|
| 102 | 102 | $field = 'name'; |
| 103 | 103 | } |
| 104 | 104 | |
| 105 | - if ( empty($id) ) { |
|
| 105 | + if ( empty( $id ) ) { |
|
| 106 | 106 | $id = FrmAppHelper::get_post_param( 'element_id', '', 'sanitize_title' ); |
| 107 | 107 | $id = str_replace( 'field_label_', '', $id ); |
| 108 | 108 | } |
| 109 | 109 | |
| 110 | 110 | $value = FrmAppHelper::get_post_param( 'update_value', '', 'wp_kses_post' ); |
| 111 | 111 | $value = trim( $value ); |
| 112 | - if ( trim(strip_tags($value)) == '' ) { |
|
| 112 | + if ( trim( strip_tags( $value ) ) == '' ) { |
|
| 113 | 113 | // set blank value if there is no content |
| 114 | 114 | $value = ''; |
| 115 | 115 | } |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | public static function update_ajax_option() { |
| 126 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 126 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
| 127 | 127 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 128 | 128 | |
| 129 | 129 | $field_id = FrmAppHelper::get_post_param( 'field', 0, 'absint' ); |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | if ( isset( $_POST['separate_value'] ) ) { |
| 137 | 137 | $new_val = FrmField::is_option_true( $field, 'separate_value' ) ? 0 : 1; |
| 138 | 138 | $field->field_options['separate_value'] = $new_val; |
| 139 | - unset($new_val); |
|
| 139 | + unset( $new_val ); |
|
| 140 | 140 | } |
| 141 | 141 | |
| 142 | 142 | FrmField::update( $field_id, array( |
@@ -147,7 +147,7 @@ discard block |
||
| 147 | 147 | } |
| 148 | 148 | |
| 149 | 149 | public static function duplicate() { |
| 150 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 150 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
| 151 | 151 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 152 | 152 | |
| 153 | 153 | global $wpdb; |
@@ -172,11 +172,11 @@ discard block |
||
| 172 | 172 | |
| 173 | 173 | $values = apply_filters( 'frm_prepare_single_field_for_duplication', $values ); |
| 174 | 174 | |
| 175 | - if ( ! $field_id = FrmField::create($values) ) { |
|
| 175 | + if ( ! $field_id = FrmField::create( $values ) ) { |
|
| 176 | 176 | wp_die(); |
| 177 | 177 | } |
| 178 | 178 | |
| 179 | - self::include_single_field($field_id, $values); |
|
| 179 | + self::include_single_field( $field_id, $values ); |
|
| 180 | 180 | |
| 181 | 181 | wp_die(); |
| 182 | 182 | } |
@@ -185,9 +185,9 @@ discard block |
||
| 185 | 185 | * Load a single field in the form builder along with all needed variables |
| 186 | 186 | */ |
| 187 | 187 | public static function include_single_field( $field_id, $values, $form_id = 0 ) { |
| 188 | - $field = FrmFieldsHelper::setup_edit_vars(FrmField::getOne($field_id)); |
|
| 188 | + $field = FrmFieldsHelper::setup_edit_vars( FrmField::getOne( $field_id ) ); |
|
| 189 | 189 | $field_name = 'item_meta[' . $field_id . ']'; |
| 190 | - $html_id = FrmFieldsHelper::get_html_id($field); |
|
| 190 | + $html_id = FrmFieldsHelper::get_html_id( $field ); |
|
| 191 | 191 | $id = $form_id ? $form_id : $field['form_id']; |
| 192 | 192 | if ( $field['type'] == 'html' ) { |
| 193 | 193 | $field['stop_filter'] = true; |
@@ -199,7 +199,7 @@ discard block |
||
| 199 | 199 | } |
| 200 | 200 | |
| 201 | 201 | public static function destroy() { |
| 202 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 202 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
| 203 | 203 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 204 | 204 | |
| 205 | 205 | $field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' ); |
@@ -211,14 +211,14 @@ discard block |
||
| 211 | 211 | |
| 212 | 212 | //Add Single Option or Other Option |
| 213 | 213 | public static function add_option() { |
| 214 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 214 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
| 215 | 215 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 216 | 216 | |
| 217 | 217 | $id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' ); |
| 218 | 218 | $opt_type = FrmAppHelper::get_post_param( 'opt_type', '', 'sanitize_text_field' ); |
| 219 | 219 | |
| 220 | 220 | //Get the field |
| 221 | - $field = FrmField::getOne($id); |
|
| 221 | + $field = FrmField::getOne( $id ); |
|
| 222 | 222 | |
| 223 | 223 | if ( ! empty( $field->options ) ) { |
| 224 | 224 | $keys = array_keys( $field->options ); |
@@ -241,13 +241,13 @@ discard block |
||
| 241 | 241 | $first_opt = reset( $field->options ); |
| 242 | 242 | $next_opt = count( $field->options ); |
| 243 | 243 | if ( $first_opt != '' ) { |
| 244 | - $next_opt++; |
|
| 244 | + $next_opt ++; |
|
| 245 | 245 | } |
| 246 | 246 | $opt = esc_html__( 'Option', 'formidable' ) . ' ' . $next_opt; |
| 247 | - unset($next_opt); |
|
| 247 | + unset( $next_opt ); |
|
| 248 | 248 | } |
| 249 | 249 | $field_val = $opt; |
| 250 | - $field->options[ $opt_key ] = $opt; |
|
| 250 | + $field->options[$opt_key] = $opt; |
|
| 251 | 251 | |
| 252 | 252 | //Update options in DB |
| 253 | 253 | FrmField::update( $id, array( 'options' => $field->options ) ); |
@@ -256,13 +256,13 @@ discard block |
||
| 256 | 256 | $field = array( |
| 257 | 257 | 'type' => $field_data->type, |
| 258 | 258 | 'id' => $id, |
| 259 | - 'separate_value' => isset($field_data->field_options['separate_value']) ? $field_data->field_options['separate_value'] : 0, |
|
| 259 | + 'separate_value' => isset( $field_data->field_options['separate_value'] ) ? $field_data->field_options['separate_value'] : 0, |
|
| 260 | 260 | 'form_id' => $field_data->form_id, |
| 261 | 261 | 'field_key' => $field_data->field_key, |
| 262 | 262 | ); |
| 263 | 263 | |
| 264 | 264 | $field_name = 'item_meta[' . $id . ']'; |
| 265 | - $html_id = FrmFieldsHelper::get_html_id($field); |
|
| 265 | + $html_id = FrmFieldsHelper::get_html_id( $field ); |
|
| 266 | 266 | $checked = ''; |
| 267 | 267 | |
| 268 | 268 | if ( 'other' == $opt_type ) { |
@@ -274,7 +274,7 @@ discard block |
||
| 274 | 274 | } |
| 275 | 275 | |
| 276 | 276 | public static function edit_option() { |
| 277 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 277 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
| 278 | 278 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 279 | 279 | |
| 280 | 280 | $element_id = FrmAppHelper::get_post_param( 'element_id', '', 'sanitize_title' ); |
@@ -288,28 +288,28 @@ discard block |
||
| 288 | 288 | $new_label = $update_value; |
| 289 | 289 | } |
| 290 | 290 | |
| 291 | - $field = FrmField::getOne($id); |
|
| 291 | + $field = FrmField::getOne( $id ); |
|
| 292 | 292 | $separate_values = FrmField::is_option_true( $field, 'separate_value' ); |
| 293 | 293 | |
| 294 | - $this_opt_id = end($ids); |
|
| 295 | - $this_opt = (array) $field->options[ $this_opt_id ]; |
|
| 296 | - $other_opt = ( $this_opt_id && strpos( $this_opt_id, 'other') !== false ); |
|
| 294 | + $this_opt_id = end( $ids ); |
|
| 295 | + $this_opt = (array) $field->options[$this_opt_id]; |
|
| 296 | + $other_opt = ( $this_opt_id && strpos( $this_opt_id, 'other' ) !== false ); |
|
| 297 | 297 | |
| 298 | - $label = isset($this_opt['label']) ? $this_opt['label'] : reset($this_opt); |
|
| 299 | - $value = isset($this_opt['value']) ? $this_opt['value'] : ''; |
|
| 298 | + $label = isset( $this_opt['label'] ) ? $this_opt['label'] : reset( $this_opt ); |
|
| 299 | + $value = isset( $this_opt['value'] ) ? $this_opt['value'] : ''; |
|
| 300 | 300 | |
| 301 | 301 | if ( ! isset( $new_label ) ) { |
| 302 | 302 | $new_label = $label; |
| 303 | 303 | } |
| 304 | 304 | |
| 305 | - if ( isset($new_value) || isset($value) ) { |
|
| 306 | - $update_value = isset($new_value) ? $new_value : $value; |
|
| 305 | + if ( isset( $new_value ) || isset( $value ) ) { |
|
| 306 | + $update_value = isset( $new_value ) ? $new_value : $value; |
|
| 307 | 307 | } |
| 308 | 308 | |
| 309 | 309 | if ( $update_value != $new_label && $other_opt === false && $separate_values ) { |
| 310 | - $field->options[ $this_opt_id ] = array( 'value' => $update_value, 'label' => $new_label ); |
|
| 310 | + $field->options[$this_opt_id] = array( 'value' => $update_value, 'label' => $new_label ); |
|
| 311 | 311 | } else { |
| 312 | - $field->options[ $this_opt_id ] = $orig_update_value; |
|
| 312 | + $field->options[$this_opt_id] = $orig_update_value; |
|
| 313 | 313 | } |
| 314 | 314 | |
| 315 | 315 | FrmField::update( $field->id, array( 'options' => $field->options ) ); |
@@ -318,7 +318,7 @@ discard block |
||
| 318 | 318 | } |
| 319 | 319 | |
| 320 | 320 | public static function delete_option() { |
| 321 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 321 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
| 322 | 322 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 323 | 323 | |
| 324 | 324 | $field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' ); |
@@ -327,7 +327,7 @@ discard block |
||
| 327 | 327 | $opt_key = FrmAppHelper::get_post_param( 'opt_key', 0, 'sanitize_title' ); |
| 328 | 328 | |
| 329 | 329 | $options = $field->options; |
| 330 | - unset( $options[ $opt_key ] ); |
|
| 330 | + unset( $options[$opt_key] ); |
|
| 331 | 331 | $response = array( 'other' => true ); |
| 332 | 332 | |
| 333 | 333 | //If the deleted option is an "other" option |
@@ -393,9 +393,9 @@ discard block |
||
| 393 | 393 | |
| 394 | 394 | $admin_body_class .= ' admin-color-' . sanitize_html_class( get_user_option( 'admin_color' ), 'fresh' ); |
| 395 | 395 | $prepop = array(); |
| 396 | - FrmFieldsHelper::get_bulk_prefilled_opts($prepop); |
|
| 396 | + FrmFieldsHelper::get_bulk_prefilled_opts( $prepop ); |
|
| 397 | 397 | |
| 398 | - $field = FrmField::getOne($field_id); |
|
| 398 | + $field = FrmField::getOne( $field_id ); |
|
| 399 | 399 | |
| 400 | 400 | wp_enqueue_script( 'utils' ); |
| 401 | 401 | wp_enqueue_style( 'formidable-admin', FrmAppHelper::plugin_url() . '/css/frm_admin.css' ); |
@@ -406,35 +406,35 @@ discard block |
||
| 406 | 406 | } |
| 407 | 407 | |
| 408 | 408 | public static function import_options() { |
| 409 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 409 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
| 410 | 410 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 411 | 411 | |
| 412 | - if ( ! is_admin() || ! current_user_can('frm_edit_forms') ) { |
|
| 412 | + if ( ! is_admin() || ! current_user_can( 'frm_edit_forms' ) ) { |
|
| 413 | 413 | return; |
| 414 | 414 | } |
| 415 | 415 | |
| 416 | 416 | $field_id = absint( $_POST['field_id'] ); |
| 417 | - $field = FrmField::getOne($field_id); |
|
| 417 | + $field = FrmField::getOne( $field_id ); |
|
| 418 | 418 | |
| 419 | 419 | if ( ! in_array( $field->type, array( 'radio', 'checkbox', 'select' ) ) ) { |
| 420 | 420 | return; |
| 421 | 421 | } |
| 422 | 422 | |
| 423 | - $field = FrmFieldsHelper::setup_edit_vars($field); |
|
| 423 | + $field = FrmFieldsHelper::setup_edit_vars( $field ); |
|
| 424 | 424 | $opts = FrmAppHelper::get_param( 'opts', '', 'post', 'wp_kses_post' ); |
| 425 | 425 | $opts = explode( "\n", rtrim( $opts, "\n" ) ); |
| 426 | 426 | $opts = array_map( 'trim', $opts ); |
| 427 | 427 | |
| 428 | 428 | if ( $field['separate_value'] ) { |
| 429 | 429 | foreach ( $opts as $opt_key => $opt ) { |
| 430 | - if ( strpos($opt, '|') !== false ) { |
|
| 431 | - $vals = explode('|', $opt); |
|
| 430 | + if ( strpos( $opt, '|' ) !== false ) { |
|
| 431 | + $vals = explode( '|', $opt ); |
|
| 432 | 432 | if ( $vals[0] != $vals[1] ) { |
| 433 | - $opts[ $opt_key ] = array( 'label' => trim( $vals[0] ), 'value' => trim( $vals[1] ) ); |
|
| 433 | + $opts[$opt_key] = array( 'label' => trim( $vals[0] ), 'value' => trim( $vals[1] ) ); |
|
| 434 | 434 | } |
| 435 | - unset($vals); |
|
| 435 | + unset( $vals ); |
|
| 436 | 436 | } |
| 437 | - unset($opt_key, $opt); |
|
| 437 | + unset( $opt_key, $opt ); |
|
| 438 | 438 | } |
| 439 | 439 | } |
| 440 | 440 | |
@@ -443,12 +443,12 @@ discard block |
||
| 443 | 443 | $other_array = array(); |
| 444 | 444 | foreach ( $field['options'] as $opt_key => $opt ) { |
| 445 | 445 | if ( $opt_key && strpos( $opt_key, 'other' ) !== false ) { |
| 446 | - $other_array[ $opt_key ] = $opt; |
|
| 446 | + $other_array[$opt_key] = $opt; |
|
| 447 | 447 | } |
| 448 | - unset($opt_key, $opt); |
|
| 448 | + unset( $opt_key, $opt ); |
|
| 449 | 449 | } |
| 450 | - if ( ! empty($other_array) ) { |
|
| 451 | - $opts = array_merge( $opts, $other_array); |
|
| 450 | + if ( ! empty( $other_array ) ) { |
|
| 451 | + $opts = array_merge( $opts, $other_array ); |
|
| 452 | 452 | } |
| 453 | 453 | } |
| 454 | 454 | |
@@ -463,14 +463,14 @@ discard block |
||
| 463 | 463 | if ( $field['type'] == 'radio' || $field['type'] == 'checkbox' ) { |
| 464 | 464 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/radio.php' ); |
| 465 | 465 | } else { |
| 466 | - FrmFieldsHelper::show_single_option($field); |
|
| 466 | + FrmFieldsHelper::show_single_option( $field ); |
|
| 467 | 467 | } |
| 468 | 468 | |
| 469 | 469 | wp_die(); |
| 470 | 470 | } |
| 471 | 471 | |
| 472 | 472 | public static function update_order() { |
| 473 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 473 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
| 474 | 474 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 475 | 475 | |
| 476 | 476 | $fields = FrmAppHelper::get_post_param( 'frm_field_id' ); |
@@ -487,13 +487,13 @@ discard block |
||
| 487 | 487 | 'rte' => 'textarea', |
| 488 | 488 | 'website' => 'url', |
| 489 | 489 | ); |
| 490 | - if ( isset( $type_switch[ $type ] ) ) { |
|
| 491 | - $type = $type_switch[ $type ]; |
|
| 490 | + if ( isset( $type_switch[$type] ) ) { |
|
| 491 | + $type = $type_switch[$type]; |
|
| 492 | 492 | } |
| 493 | 493 | |
| 494 | 494 | $frm_field_selection = FrmField::field_selection(); |
| 495 | - $types = array_keys($frm_field_selection); |
|
| 496 | - if ( ! in_array($type, $types) && $type != 'captcha' ) { |
|
| 495 | + $types = array_keys( $frm_field_selection ); |
|
| 496 | + if ( ! in_array( $type, $types ) && $type != 'captcha' ) { |
|
| 497 | 497 | $type = 'text'; |
| 498 | 498 | } |
| 499 | 499 | |
@@ -532,19 +532,19 @@ discard block |
||
| 532 | 532 | |
| 533 | 533 | public static function input_html( $field, $echo = true ) { |
| 534 | 534 | $class = array(); //$field['type']; |
| 535 | - self::add_input_classes($field, $class); |
|
| 535 | + self::add_input_classes( $field, $class ); |
|
| 536 | 536 | |
| 537 | 537 | $add_html = array(); |
| 538 | - self::add_html_size($field, $add_html); |
|
| 539 | - self::add_html_length($field, $add_html); |
|
| 540 | - self::add_html_placeholder($field, $add_html, $class); |
|
| 538 | + self::add_html_size( $field, $add_html ); |
|
| 539 | + self::add_html_length( $field, $add_html ); |
|
| 540 | + self::add_html_placeholder( $field, $add_html, $class ); |
|
| 541 | 541 | self::add_validation_messages( $field, $add_html ); |
| 542 | 542 | |
| 543 | - $class = apply_filters('frm_field_classes', implode(' ', $class), $field); |
|
| 543 | + $class = apply_filters( 'frm_field_classes', implode( ' ', $class ), $field ); |
|
| 544 | 544 | |
| 545 | 545 | FrmFormsHelper::add_html_attr( $class, 'class', $add_html ); |
| 546 | 546 | |
| 547 | - self::add_shortcodes_to_html($field, $add_html); |
|
| 547 | + self::add_shortcodes_to_html( $field, $add_html ); |
|
| 548 | 548 | |
| 549 | 549 | $add_html = apply_filters( 'frm_field_extra_html', $add_html, $field ); |
| 550 | 550 | $add_html = ' ' . implode( ' ', $add_html ) . ' '; |
@@ -557,7 +557,7 @@ discard block |
||
| 557 | 557 | } |
| 558 | 558 | |
| 559 | 559 | private static function add_input_classes( $field, array &$class ) { |
| 560 | - if ( isset($field['input_class']) && ! empty($field['input_class']) ) { |
|
| 560 | + if ( isset( $field['input_class'] ) && ! empty( $field['input_class'] ) ) { |
|
| 561 | 561 | $class[] = $field['input_class']; |
| 562 | 562 | } |
| 563 | 563 | |
@@ -571,7 +571,7 @@ discard block |
||
| 571 | 571 | $class[] = 'dyn_default_value'; |
| 572 | 572 | } |
| 573 | 573 | |
| 574 | - if ( isset($field['size']) && $field['size'] > 0 ) { |
|
| 574 | + if ( isset( $field['size'] ) && $field['size'] > 0 ) { |
|
| 575 | 575 | $class[] = 'auto_width'; |
| 576 | 576 | } |
| 577 | 577 | } |
@@ -581,19 +581,19 @@ discard block |
||
| 581 | 581 | return; |
| 582 | 582 | } |
| 583 | 583 | |
| 584 | - if ( FrmAppHelper::is_admin_page('formidable' ) ) { |
|
| 584 | + if ( FrmAppHelper::is_admin_page( 'formidable' ) ) { |
|
| 585 | 585 | return; |
| 586 | 586 | } |
| 587 | 587 | |
| 588 | - if ( is_numeric($field['size']) ) { |
|
| 588 | + if ( is_numeric( $field['size'] ) ) { |
|
| 589 | 589 | $field['size'] .= 'px'; |
| 590 | 590 | } |
| 591 | 591 | |
| 592 | - $important = apply_filters('frm_use_important_width', 1, $field); |
|
| 592 | + $important = apply_filters( 'frm_use_important_width', 1, $field ); |
|
| 593 | 593 | // Note: This inline styling must stay since we cannot realistically set a class for every possible field size |
| 594 | 594 | $add_html['style'] = 'style="width:' . esc_attr( $field['size'] ) . ( $important ? ' !important' : '' ) . '"'; |
| 595 | 595 | |
| 596 | - self::add_html_cols($field, $add_html); |
|
| 596 | + self::add_html_cols( $field, $add_html ); |
|
| 597 | 597 | } |
| 598 | 598 | |
| 599 | 599 | private static function add_html_cols( $field, array &$add_html ) { |
@@ -610,13 +610,13 @@ discard block |
||
| 610 | 610 | ); |
| 611 | 611 | |
| 612 | 612 | // include "col" for valid html |
| 613 | - $unit = trim(preg_replace('/[0-9]+/', '', $field['size'])); |
|
| 613 | + $unit = trim( preg_replace( '/[0-9]+/', '', $field['size'] ) ); |
|
| 614 | 614 | |
| 615 | - if ( ! isset( $calc[ $unit ] ) ) { |
|
| 615 | + if ( ! isset( $calc[$unit] ) ) { |
|
| 616 | 616 | return; |
| 617 | 617 | } |
| 618 | 618 | |
| 619 | - $size = (float) str_replace( $unit, '', $field['size'] ) / $calc[ $unit ]; |
|
| 619 | + $size = (float) str_replace( $unit, '', $field['size'] ) / $calc[$unit]; |
|
| 620 | 620 | |
| 621 | 621 | $add_html['cols'] = 'cols="' . absint( $size ) . '"'; |
| 622 | 622 | } |
@@ -627,7 +627,7 @@ discard block |
||
| 627 | 627 | return; |
| 628 | 628 | } |
| 629 | 629 | |
| 630 | - if ( FrmAppHelper::is_admin_page('formidable' ) ) { |
|
| 630 | + if ( FrmAppHelper::is_admin_page( 'formidable' ) ) { |
|
| 631 | 631 | // don't load on form builder page |
| 632 | 632 | return; |
| 633 | 633 | } |
@@ -659,7 +659,7 @@ discard block |
||
| 659 | 659 | if ( $frm_settings->use_html && ! in_array( $field['type'], array( 'select', 'radio', 'checkbox', 'hidden' ) ) ) { |
| 660 | 660 | // use HMTL5 placeholder with js fallback |
| 661 | 661 | $add_html['placeholder'] = 'placeholder="' . esc_attr( $field['default_value'] ) . '"'; |
| 662 | - wp_enqueue_script('jquery-placeholder'); |
|
| 662 | + wp_enqueue_script( 'jquery-placeholder' ); |
|
| 663 | 663 | } else if ( ! $frm_settings->use_html ) { |
| 664 | 664 | $val = str_replace( array( "\r\n", "\n" ), '\r', addslashes( str_replace( ''', "'", esc_attr( $field['default_value'] ) ) ) ); |
| 665 | 665 | $add_html['data-frmval'] = 'data-frmval="' . esc_attr( $val ) . '"'; |
@@ -693,15 +693,15 @@ discard block |
||
| 693 | 693 | continue; |
| 694 | 694 | } |
| 695 | 695 | |
| 696 | - if ( is_numeric($k) && strpos($v, '=') ) { |
|
| 696 | + if ( is_numeric( $k ) && strpos( $v, '=' ) ) { |
|
| 697 | 697 | $add_html[] = $v; |
| 698 | - } else if ( ! empty( $k ) && isset( $add_html[ $k ] ) ) { |
|
| 699 | - $add_html[ $k ] = str_replace( $k . '="', $k . '="' . $v, $add_html[ $k ] ); |
|
| 698 | + } else if ( ! empty( $k ) && isset( $add_html[$k] ) ) { |
|
| 699 | + $add_html[$k] = str_replace( $k . '="', $k . '="' . $v, $add_html[$k] ); |
|
| 700 | 700 | } else { |
| 701 | - $add_html[ $k ] = $k . '="' . esc_attr( $v ) . '"'; |
|
| 701 | + $add_html[$k] = $k . '="' . esc_attr( $v ) . '"'; |
|
| 702 | 702 | } |
| 703 | 703 | |
| 704 | - unset($k, $v); |
|
| 704 | + unset( $k, $v ); |
|
| 705 | 705 | } |
| 706 | 706 | } |
| 707 | 707 | |
@@ -717,8 +717,8 @@ discard block |
||
| 717 | 717 | } |
| 718 | 718 | |
| 719 | 719 | public static function check_label( $opt ) { |
| 720 | - if ( is_array($opt) ) { |
|
| 721 | - $opt = (isset($opt['label']) ? $opt['label'] : reset($opt)); |
|
| 720 | + if ( is_array( $opt ) ) { |
|
| 721 | + $opt = ( isset( $opt['label'] ) ? $opt['label'] : reset( $opt ) ); |
|
| 722 | 722 | } |
| 723 | 723 | |
| 724 | 724 | return $opt; |
@@ -2,129 +2,129 @@ discard block |
||
| 2 | 2 | |
| 3 | 3 | class FrmFieldsController { |
| 4 | 4 | |
| 5 | - public static function load_field() { |
|
| 5 | + public static function load_field() { |
|
| 6 | 6 | FrmAppHelper::permission_check('frm_edit_forms'); |
| 7 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 7 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 8 | 8 | |
| 9 | - $fields = $_POST['field']; |
|
| 10 | - if ( empty( $fields ) ) { |
|
| 11 | - wp_die(); |
|
| 12 | - } |
|
| 9 | + $fields = $_POST['field']; |
|
| 10 | + if ( empty( $fields ) ) { |
|
| 11 | + wp_die(); |
|
| 12 | + } |
|
| 13 | 13 | |
| 14 | - $_GET['page'] = 'formidable'; |
|
| 15 | - $fields = stripslashes_deep( $fields ); |
|
| 14 | + $_GET['page'] = 'formidable'; |
|
| 15 | + $fields = stripslashes_deep( $fields ); |
|
| 16 | 16 | |
| 17 | - $ajax = true; |
|
| 17 | + $ajax = true; |
|
| 18 | 18 | $values = array( 'id' => FrmAppHelper::get_post_param( 'form_id', '', 'absint' ) ); |
| 19 | - $path = FrmAppHelper::plugin_path(); |
|
| 20 | - $field_html = array(); |
|
| 21 | - |
|
| 22 | - foreach ( $fields as $field ) { |
|
| 23 | - $field = htmlspecialchars_decode( nl2br( $field ) ); |
|
| 24 | - $field = json_decode( $field, true ); |
|
| 25 | - if ( ! isset( $field['id'] ) ) { |
|
| 26 | - // this field may have already been loaded |
|
| 27 | - continue; |
|
| 28 | - } |
|
| 19 | + $path = FrmAppHelper::plugin_path(); |
|
| 20 | + $field_html = array(); |
|
| 21 | + |
|
| 22 | + foreach ( $fields as $field ) { |
|
| 23 | + $field = htmlspecialchars_decode( nl2br( $field ) ); |
|
| 24 | + $field = json_decode( $field, true ); |
|
| 25 | + if ( ! isset( $field['id'] ) ) { |
|
| 26 | + // this field may have already been loaded |
|
| 27 | + continue; |
|
| 28 | + } |
|
| 29 | 29 | |
| 30 | - $field_id = absint( $field['id'] ); |
|
| 30 | + $field_id = absint( $field['id'] ); |
|
| 31 | 31 | |
| 32 | - if ( ! isset( $field['value'] ) ) { |
|
| 33 | - $field['value'] = ''; |
|
| 34 | - } |
|
| 32 | + if ( ! isset( $field['value'] ) ) { |
|
| 33 | + $field['value'] = ''; |
|
| 34 | + } |
|
| 35 | 35 | |
| 36 | 36 | $field_name = 'item_meta[' . $field_id . ']'; |
| 37 | - $html_id = FrmFieldsHelper::get_html_id($field); |
|
| 37 | + $html_id = FrmFieldsHelper::get_html_id($field); |
|
| 38 | 38 | |
| 39 | - ob_start(); |
|
| 39 | + ob_start(); |
|
| 40 | 40 | include( $path . '/classes/views/frm-forms/add_field.php' ); |
| 41 | - $field_html[ $field_id ] = ob_get_contents(); |
|
| 42 | - ob_end_clean(); |
|
| 43 | - } |
|
| 41 | + $field_html[ $field_id ] = ob_get_contents(); |
|
| 42 | + ob_end_clean(); |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | - unset($path); |
|
| 45 | + unset($path); |
|
| 46 | 46 | |
| 47 | - echo json_encode($field_html); |
|
| 47 | + echo json_encode($field_html); |
|
| 48 | 48 | |
| 49 | - wp_die(); |
|
| 50 | - } |
|
| 49 | + wp_die(); |
|
| 50 | + } |
|
| 51 | 51 | |
| 52 | 52 | /** |
| 53 | 53 | * Create a new field with ajax |
| 54 | 54 | */ |
| 55 | - public static function create() { |
|
| 55 | + public static function create() { |
|
| 56 | 56 | FrmAppHelper::permission_check('frm_edit_forms'); |
| 57 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 57 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 58 | 58 | |
| 59 | 59 | $field_type = FrmAppHelper::get_post_param( 'field_type', '', 'sanitize_text_field' ); |
| 60 | 60 | $form_id = FrmAppHelper::get_post_param( 'form_id', 0, 'absint' ); |
| 61 | 61 | |
| 62 | 62 | $field = self::include_new_field( $field_type, $form_id ); |
| 63 | 63 | |
| 64 | - // this hook will allow for multiple fields to be added at once |
|
| 65 | - do_action('frm_after_field_created', $field, $form_id); |
|
| 64 | + // this hook will allow for multiple fields to be added at once |
|
| 65 | + do_action('frm_after_field_created', $field, $form_id); |
|
| 66 | 66 | |
| 67 | - wp_die(); |
|
| 68 | - } |
|
| 67 | + wp_die(); |
|
| 68 | + } |
|
| 69 | 69 | |
| 70 | - /** |
|
| 71 | - * Set up and create a new field |
|
| 72 | - * |
|
| 73 | - * @param string $field_type |
|
| 74 | - * @param integer $form_id |
|
| 75 | - * @return array|bool |
|
| 76 | - */ |
|
| 70 | + /** |
|
| 71 | + * Set up and create a new field |
|
| 72 | + * |
|
| 73 | + * @param string $field_type |
|
| 74 | + * @param integer $form_id |
|
| 75 | + * @return array|bool |
|
| 76 | + */ |
|
| 77 | 77 | public static function include_new_field( $field_type, $form_id ) { |
| 78 | - $values = array(); |
|
| 79 | - if ( FrmAppHelper::pro_is_installed() ) { |
|
| 80 | - $values['post_type'] = FrmProFormsHelper::post_type($form_id); |
|
| 81 | - } |
|
| 78 | + $values = array(); |
|
| 79 | + if ( FrmAppHelper::pro_is_installed() ) { |
|
| 80 | + $values['post_type'] = FrmProFormsHelper::post_type($form_id); |
|
| 81 | + } |
|
| 82 | 82 | |
| 83 | 83 | $field_values = FrmFieldsHelper::setup_new_vars( $field_type, $form_id ); |
| 84 | - $field_values = apply_filters( 'frm_before_field_created', $field_values ); |
|
| 84 | + $field_values = apply_filters( 'frm_before_field_created', $field_values ); |
|
| 85 | 85 | |
| 86 | - $field_id = FrmField::create( $field_values ); |
|
| 86 | + $field_id = FrmField::create( $field_values ); |
|
| 87 | 87 | |
| 88 | - if ( ! $field_id ) { |
|
| 89 | - return false; |
|
| 90 | - } |
|
| 88 | + if ( ! $field_id ) { |
|
| 89 | + return false; |
|
| 90 | + } |
|
| 91 | 91 | |
| 92 | - $field = self::include_single_field($field_id, $values, $form_id); |
|
| 92 | + $field = self::include_single_field($field_id, $values, $form_id); |
|
| 93 | 93 | |
| 94 | - return $field; |
|
| 95 | - } |
|
| 94 | + return $field; |
|
| 95 | + } |
|
| 96 | 96 | |
| 97 | 97 | public static function edit_name( $field = 'name', $id = '' ) { |
| 98 | 98 | FrmAppHelper::permission_check('frm_edit_forms'); |
| 99 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 99 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 100 | 100 | |
| 101 | - if ( empty($field) ) { |
|
| 102 | - $field = 'name'; |
|
| 103 | - } |
|
| 101 | + if ( empty($field) ) { |
|
| 102 | + $field = 'name'; |
|
| 103 | + } |
|
| 104 | 104 | |
| 105 | - if ( empty($id) ) { |
|
| 105 | + if ( empty($id) ) { |
|
| 106 | 106 | $id = FrmAppHelper::get_post_param( 'element_id', '', 'sanitize_title' ); |
| 107 | 107 | $id = str_replace( 'field_label_', '', $id ); |
| 108 | - } |
|
| 108 | + } |
|
| 109 | 109 | |
| 110 | 110 | $value = FrmAppHelper::get_post_param( 'update_value', '', 'wp_kses_post' ); |
| 111 | 111 | $value = trim( $value ); |
| 112 | - if ( trim(strip_tags($value)) == '' ) { |
|
| 113 | - // set blank value if there is no content |
|
| 114 | - $value = ''; |
|
| 115 | - } |
|
| 112 | + if ( trim(strip_tags($value)) == '' ) { |
|
| 113 | + // set blank value if there is no content |
|
| 114 | + $value = ''; |
|
| 115 | + } |
|
| 116 | 116 | |
| 117 | 117 | FrmField::update( $id, array( $field => $value ) ); |
| 118 | 118 | |
| 119 | 119 | do_action( 'frm_after_update_field_' . $field, compact( 'id', 'value' ) ); |
| 120 | 120 | |
| 121 | 121 | echo stripslashes( wp_kses_post( $value ) ); |
| 122 | - wp_die(); |
|
| 123 | - } |
|
| 122 | + wp_die(); |
|
| 123 | + } |
|
| 124 | 124 | |
| 125 | - public static function update_ajax_option() { |
|
| 125 | + public static function update_ajax_option() { |
|
| 126 | 126 | FrmAppHelper::permission_check('frm_edit_forms'); |
| 127 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 127 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 128 | 128 | |
| 129 | 129 | $field_id = FrmAppHelper::get_post_param( 'field', 0, 'absint' ); |
| 130 | 130 | if ( ! $field_id ) { |
@@ -139,143 +139,143 @@ discard block |
||
| 139 | 139 | unset($new_val); |
| 140 | 140 | } |
| 141 | 141 | |
| 142 | - FrmField::update( $field_id, array( |
|
| 143 | - 'field_options' => $field->field_options, |
|
| 142 | + FrmField::update( $field_id, array( |
|
| 143 | + 'field_options' => $field->field_options, |
|
| 144 | 144 | 'form_id' => $field->form_id, |
| 145 | - ) ); |
|
| 146 | - wp_die(); |
|
| 147 | - } |
|
| 145 | + ) ); |
|
| 146 | + wp_die(); |
|
| 147 | + } |
|
| 148 | 148 | |
| 149 | - public static function duplicate() { |
|
| 149 | + public static function duplicate() { |
|
| 150 | 150 | FrmAppHelper::permission_check('frm_edit_forms'); |
| 151 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 151 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 152 | 152 | |
| 153 | - global $wpdb; |
|
| 153 | + global $wpdb; |
|
| 154 | 154 | |
| 155 | 155 | $field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' ); |
| 156 | 156 | $form_id = FrmAppHelper::get_post_param( 'form_id', 0, 'absint' ); |
| 157 | 157 | |
| 158 | 158 | $copy_field = FrmField::getOne( $field_id ); |
| 159 | - if ( ! $copy_field ) { |
|
| 160 | - wp_die(); |
|
| 161 | - } |
|
| 159 | + if ( ! $copy_field ) { |
|
| 160 | + wp_die(); |
|
| 161 | + } |
|
| 162 | 162 | |
| 163 | 163 | do_action( 'frm_duplicate_field', $copy_field, $form_id ); |
| 164 | 164 | do_action( 'frm_duplicate_field_' . $copy_field->type, $copy_field, $form_id ); |
| 165 | 165 | |
| 166 | 166 | $values = array(); |
| 167 | - FrmFieldsHelper::fill_field( $values, $copy_field, $form_id ); |
|
| 167 | + FrmFieldsHelper::fill_field( $values, $copy_field, $form_id ); |
|
| 168 | 168 | |
| 169 | 169 | $field_count = FrmDb::get_count( $wpdb->prefix . 'frm_fields fi LEFT JOIN ' . $wpdb->prefix . 'frm_forms fr ON (fi.form_id = fr.id)', array( 'or' => 1, 'fr.id' => $form_id, 'fr.parent_form_id' => $form_id ) ); |
| 170 | 170 | |
| 171 | - $values['field_order'] = $field_count + 1; |
|
| 171 | + $values['field_order'] = $field_count + 1; |
|
| 172 | 172 | |
| 173 | - $values = apply_filters( 'frm_prepare_single_field_for_duplication', $values ); |
|
| 173 | + $values = apply_filters( 'frm_prepare_single_field_for_duplication', $values ); |
|
| 174 | 174 | |
| 175 | - if ( ! $field_id = FrmField::create($values) ) { |
|
| 176 | - wp_die(); |
|
| 177 | - } |
|
| 175 | + if ( ! $field_id = FrmField::create($values) ) { |
|
| 176 | + wp_die(); |
|
| 177 | + } |
|
| 178 | 178 | |
| 179 | - self::include_single_field($field_id, $values); |
|
| 179 | + self::include_single_field($field_id, $values); |
|
| 180 | 180 | |
| 181 | - wp_die(); |
|
| 182 | - } |
|
| 181 | + wp_die(); |
|
| 182 | + } |
|
| 183 | 183 | |
| 184 | - /** |
|
| 185 | - * Load a single field in the form builder along with all needed variables |
|
| 186 | - */ |
|
| 187 | - public static function include_single_field( $field_id, $values, $form_id = 0 ) { |
|
| 188 | - $field = FrmFieldsHelper::setup_edit_vars(FrmField::getOne($field_id)); |
|
| 184 | + /** |
|
| 185 | + * Load a single field in the form builder along with all needed variables |
|
| 186 | + */ |
|
| 187 | + public static function include_single_field( $field_id, $values, $form_id = 0 ) { |
|
| 188 | + $field = FrmFieldsHelper::setup_edit_vars(FrmField::getOne($field_id)); |
|
| 189 | 189 | $field_name = 'item_meta[' . $field_id . ']'; |
| 190 | - $html_id = FrmFieldsHelper::get_html_id($field); |
|
| 191 | - $id = $form_id ? $form_id : $field['form_id']; |
|
| 192 | - if ( $field['type'] == 'html' ) { |
|
| 193 | - $field['stop_filter'] = true; |
|
| 194 | - } |
|
| 190 | + $html_id = FrmFieldsHelper::get_html_id($field); |
|
| 191 | + $id = $form_id ? $form_id : $field['form_id']; |
|
| 192 | + if ( $field['type'] == 'html' ) { |
|
| 193 | + $field['stop_filter'] = true; |
|
| 194 | + } |
|
| 195 | 195 | |
| 196 | 196 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/add_field.php' ); |
| 197 | 197 | |
| 198 | - return $field; |
|
| 199 | - } |
|
| 198 | + return $field; |
|
| 199 | + } |
|
| 200 | 200 | |
| 201 | - public static function destroy() { |
|
| 201 | + public static function destroy() { |
|
| 202 | 202 | FrmAppHelper::permission_check('frm_edit_forms'); |
| 203 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 203 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 204 | 204 | |
| 205 | 205 | $field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' ); |
| 206 | 206 | FrmField::destroy( $field_id ); |
| 207 | - wp_die(); |
|
| 208 | - } |
|
| 207 | + wp_die(); |
|
| 208 | + } |
|
| 209 | 209 | |
| 210 | - /* Field Options */ |
|
| 210 | + /* Field Options */ |
|
| 211 | 211 | |
| 212 | - //Add Single Option or Other Option |
|
| 213 | - public static function add_option() { |
|
| 212 | + //Add Single Option or Other Option |
|
| 213 | + public static function add_option() { |
|
| 214 | 214 | FrmAppHelper::permission_check('frm_edit_forms'); |
| 215 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 215 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 216 | 216 | |
| 217 | 217 | $id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' ); |
| 218 | 218 | $opt_type = FrmAppHelper::get_post_param( 'opt_type', '', 'sanitize_text_field' ); |
| 219 | 219 | |
| 220 | - //Get the field |
|
| 221 | - $field = FrmField::getOne($id); |
|
| 220 | + //Get the field |
|
| 221 | + $field = FrmField::getOne($id); |
|
| 222 | 222 | |
| 223 | 223 | if ( ! empty( $field->options ) ) { |
| 224 | 224 | $keys = array_keys( $field->options ); |
| 225 | - $last = str_replace( 'other_', '', end( $keys ) ); |
|
| 226 | - } else { |
|
| 227 | - $last = 0; |
|
| 228 | - } |
|
| 229 | - $opt_key = $last + 1; |
|
| 225 | + $last = str_replace( 'other_', '', end( $keys ) ); |
|
| 226 | + } else { |
|
| 227 | + $last = 0; |
|
| 228 | + } |
|
| 229 | + $opt_key = $last + 1; |
|
| 230 | 230 | |
| 231 | - if ( 'other' == $opt_type ) { |
|
| 231 | + if ( 'other' == $opt_type ) { |
|
| 232 | 232 | $opt = esc_html__( 'Other', 'formidable' ); |
| 233 | - $other_val = ''; |
|
| 234 | - $opt_key = 'other_' . $opt_key; |
|
| 235 | - |
|
| 236 | - //Update value of "other" in DB |
|
| 237 | - $field_options = maybe_unserialize( $field->field_options ); |
|
| 238 | - $field_options['other'] = 1; |
|
| 239 | - FrmField::update( $id, array( 'field_options' => maybe_serialize( $field_options ) ) ); |
|
| 240 | - } else { |
|
| 233 | + $other_val = ''; |
|
| 234 | + $opt_key = 'other_' . $opt_key; |
|
| 235 | + |
|
| 236 | + //Update value of "other" in DB |
|
| 237 | + $field_options = maybe_unserialize( $field->field_options ); |
|
| 238 | + $field_options['other'] = 1; |
|
| 239 | + FrmField::update( $id, array( 'field_options' => maybe_serialize( $field_options ) ) ); |
|
| 240 | + } else { |
|
| 241 | 241 | $first_opt = reset( $field->options ); |
| 242 | 242 | $next_opt = count( $field->options ); |
| 243 | - if ( $first_opt != '' ) { |
|
| 244 | - $next_opt++; |
|
| 245 | - } |
|
| 243 | + if ( $first_opt != '' ) { |
|
| 244 | + $next_opt++; |
|
| 245 | + } |
|
| 246 | 246 | $opt = esc_html__( 'Option', 'formidable' ) . ' ' . $next_opt; |
| 247 | - unset($next_opt); |
|
| 248 | - } |
|
| 249 | - $field_val = $opt; |
|
| 247 | + unset($next_opt); |
|
| 248 | + } |
|
| 249 | + $field_val = $opt; |
|
| 250 | 250 | $field->options[ $opt_key ] = $opt; |
| 251 | 251 | |
| 252 | - //Update options in DB |
|
| 252 | + //Update options in DB |
|
| 253 | 253 | FrmField::update( $id, array( 'options' => $field->options ) ); |
| 254 | 254 | |
| 255 | - $field_data = $field; |
|
| 256 | - $field = array( |
|
| 257 | - 'type' => $field_data->type, |
|
| 258 | - 'id' => $id, |
|
| 259 | - 'separate_value' => isset($field_data->field_options['separate_value']) ? $field_data->field_options['separate_value'] : 0, |
|
| 260 | - 'form_id' => $field_data->form_id, |
|
| 261 | - 'field_key' => $field_data->field_key, |
|
| 262 | - ); |
|
| 255 | + $field_data = $field; |
|
| 256 | + $field = array( |
|
| 257 | + 'type' => $field_data->type, |
|
| 258 | + 'id' => $id, |
|
| 259 | + 'separate_value' => isset($field_data->field_options['separate_value']) ? $field_data->field_options['separate_value'] : 0, |
|
| 260 | + 'form_id' => $field_data->form_id, |
|
| 261 | + 'field_key' => $field_data->field_key, |
|
| 262 | + ); |
|
| 263 | 263 | |
| 264 | 264 | $field_name = 'item_meta[' . $id . ']'; |
| 265 | - $html_id = FrmFieldsHelper::get_html_id($field); |
|
| 266 | - $checked = ''; |
|
| 265 | + $html_id = FrmFieldsHelper::get_html_id($field); |
|
| 266 | + $checked = ''; |
|
| 267 | 267 | |
| 268 | - if ( 'other' == $opt_type ) { |
|
| 268 | + if ( 'other' == $opt_type ) { |
|
| 269 | 269 | require( FrmAppHelper::plugin_path() . '/pro/classes/views/frmpro-fields/other-option.php' ); |
| 270 | - } else { |
|
| 270 | + } else { |
|
| 271 | 271 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/single-option.php' ); |
| 272 | - } |
|
| 273 | - wp_die(); |
|
| 274 | - } |
|
| 272 | + } |
|
| 273 | + wp_die(); |
|
| 274 | + } |
|
| 275 | 275 | |
| 276 | - public static function edit_option() { |
|
| 276 | + public static function edit_option() { |
|
| 277 | 277 | FrmAppHelper::permission_check('frm_edit_forms'); |
| 278 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 278 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 279 | 279 | |
| 280 | 280 | $element_id = FrmAppHelper::get_post_param( 'element_id', '', 'sanitize_title' ); |
| 281 | 281 | $ids = explode( '-', $element_id ); |
@@ -283,43 +283,43 @@ discard block |
||
| 283 | 283 | |
| 284 | 284 | $orig_update_value = $update_value = trim( FrmAppHelper::get_post_param( 'update_value', '', 'wp_kses_post' ) ); |
| 285 | 285 | if ( strpos( $element_id, 'key_' ) ) { |
| 286 | - $new_value = $update_value; |
|
| 287 | - } else { |
|
| 288 | - $new_label = $update_value; |
|
| 289 | - } |
|
| 286 | + $new_value = $update_value; |
|
| 287 | + } else { |
|
| 288 | + $new_label = $update_value; |
|
| 289 | + } |
|
| 290 | 290 | |
| 291 | - $field = FrmField::getOne($id); |
|
| 292 | - $separate_values = FrmField::is_option_true( $field, 'separate_value' ); |
|
| 291 | + $field = FrmField::getOne($id); |
|
| 292 | + $separate_values = FrmField::is_option_true( $field, 'separate_value' ); |
|
| 293 | 293 | |
| 294 | - $this_opt_id = end($ids); |
|
| 294 | + $this_opt_id = end($ids); |
|
| 295 | 295 | $this_opt = (array) $field->options[ $this_opt_id ]; |
| 296 | 296 | $other_opt = ( $this_opt_id && strpos( $this_opt_id, 'other') !== false ); |
| 297 | 297 | |
| 298 | - $label = isset($this_opt['label']) ? $this_opt['label'] : reset($this_opt); |
|
| 299 | - $value = isset($this_opt['value']) ? $this_opt['value'] : ''; |
|
| 298 | + $label = isset($this_opt['label']) ? $this_opt['label'] : reset($this_opt); |
|
| 299 | + $value = isset($this_opt['value']) ? $this_opt['value'] : ''; |
|
| 300 | 300 | |
| 301 | - if ( ! isset( $new_label ) ) { |
|
| 302 | - $new_label = $label; |
|
| 303 | - } |
|
| 301 | + if ( ! isset( $new_label ) ) { |
|
| 302 | + $new_label = $label; |
|
| 303 | + } |
|
| 304 | 304 | |
| 305 | - if ( isset($new_value) || isset($value) ) { |
|
| 306 | - $update_value = isset($new_value) ? $new_value : $value; |
|
| 307 | - } |
|
| 305 | + if ( isset($new_value) || isset($value) ) { |
|
| 306 | + $update_value = isset($new_value) ? $new_value : $value; |
|
| 307 | + } |
|
| 308 | 308 | |
| 309 | 309 | if ( $update_value != $new_label && $other_opt === false && $separate_values ) { |
| 310 | 310 | $field->options[ $this_opt_id ] = array( 'value' => $update_value, 'label' => $new_label ); |
| 311 | - } else { |
|
| 311 | + } else { |
|
| 312 | 312 | $field->options[ $this_opt_id ] = $orig_update_value; |
| 313 | - } |
|
| 313 | + } |
|
| 314 | 314 | |
| 315 | 315 | FrmField::update( $field->id, array( 'options' => $field->options ) ); |
| 316 | 316 | echo ( $orig_update_value == '' ) ? esc_html__( '(Blank)', 'formidable' ) : stripslashes( $orig_update_value ); |
| 317 | - wp_die(); |
|
| 318 | - } |
|
| 317 | + wp_die(); |
|
| 318 | + } |
|
| 319 | 319 | |
| 320 | - public static function delete_option() { |
|
| 320 | + public static function delete_option() { |
|
| 321 | 321 | FrmAppHelper::permission_check('frm_edit_forms'); |
| 322 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 322 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 323 | 323 | |
| 324 | 324 | $field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' ); |
| 325 | 325 | $field = FrmField::getOne( $field_id ); |
@@ -327,307 +327,307 @@ discard block |
||
| 327 | 327 | $opt_key = FrmAppHelper::get_post_param( 'opt_key', 0, 'sanitize_title' ); |
| 328 | 328 | |
| 329 | 329 | $options = $field->options; |
| 330 | - unset( $options[ $opt_key ] ); |
|
| 331 | - $response = array( 'other' => true ); |
|
| 330 | + unset( $options[ $opt_key ] ); |
|
| 331 | + $response = array( 'other' => true ); |
|
| 332 | 332 | |
| 333 | - //If the deleted option is an "other" option |
|
| 333 | + //If the deleted option is an "other" option |
|
| 334 | 334 | if ( FrmFieldsHelper::is_other_opt( $opt_key ) ) { |
| 335 | - //Assume all other options are gone, unless proven otherwise |
|
| 336 | - $other = false; |
|
| 335 | + //Assume all other options are gone, unless proven otherwise |
|
| 336 | + $other = false; |
|
| 337 | 337 | |
| 338 | - //Check if all other options are really gone |
|
| 339 | - foreach ( $options as $o_key => $o_val ) { |
|
| 340 | - //If there is still an other option in the field, set other to true |
|
| 338 | + //Check if all other options are really gone |
|
| 339 | + foreach ( $options as $o_key => $o_val ) { |
|
| 340 | + //If there is still an other option in the field, set other to true |
|
| 341 | 341 | if ( FrmFieldsHelper::is_other_opt( $o_key ) ) { |
| 342 | - $other = true; |
|
| 343 | - break; |
|
| 344 | - } |
|
| 345 | - unset( $o_key, $o_val ); |
|
| 346 | - } |
|
| 347 | - |
|
| 348 | - //If all other options are gone |
|
| 349 | - if ( false === $other ) { |
|
| 350 | - $field_options = maybe_unserialize( $field->field_options ); |
|
| 351 | - $field_options['other'] = 0; |
|
| 342 | + $other = true; |
|
| 343 | + break; |
|
| 344 | + } |
|
| 345 | + unset( $o_key, $o_val ); |
|
| 346 | + } |
|
| 347 | + |
|
| 348 | + //If all other options are gone |
|
| 349 | + if ( false === $other ) { |
|
| 350 | + $field_options = maybe_unserialize( $field->field_options ); |
|
| 351 | + $field_options['other'] = 0; |
|
| 352 | 352 | FrmField::update( $field_id, array( 'field_options' => maybe_serialize( $field_options ) ) ); |
| 353 | - $response = array( 'other' => false ); |
|
| 354 | - } |
|
| 355 | - } |
|
| 356 | - echo json_encode( $response ); |
|
| 353 | + $response = array( 'other' => false ); |
|
| 354 | + } |
|
| 355 | + } |
|
| 356 | + echo json_encode( $response ); |
|
| 357 | 357 | |
| 358 | 358 | FrmField::update( $field_id, array( 'options' => maybe_serialize( $options ) ) ); |
| 359 | 359 | |
| 360 | - wp_die(); |
|
| 361 | - } |
|
| 360 | + wp_die(); |
|
| 361 | + } |
|
| 362 | 362 | |
| 363 | - public static function import_choices() { |
|
| 364 | - FrmAppHelper::permission_check( 'frm_edit_forms', 'hide' ); |
|
| 363 | + public static function import_choices() { |
|
| 364 | + FrmAppHelper::permission_check( 'frm_edit_forms', 'hide' ); |
|
| 365 | 365 | |
| 366 | 366 | $field_id = absint( $_REQUEST['field_id'] ); |
| 367 | 367 | |
| 368 | - global $current_screen, $hook_suffix; |
|
| 368 | + global $current_screen, $hook_suffix; |
|
| 369 | 369 | |
| 370 | - // Catch plugins that include admin-header.php before admin.php completes. |
|
| 371 | - if ( empty( $current_screen ) && function_exists( 'set_current_screen' ) ) { |
|
| 372 | - $hook_suffix = ''; |
|
| 373 | - set_current_screen(); |
|
| 374 | - } |
|
| 370 | + // Catch plugins that include admin-header.php before admin.php completes. |
|
| 371 | + if ( empty( $current_screen ) && function_exists( 'set_current_screen' ) ) { |
|
| 372 | + $hook_suffix = ''; |
|
| 373 | + set_current_screen(); |
|
| 374 | + } |
|
| 375 | 375 | |
| 376 | - if ( function_exists( 'register_admin_color_schemes' ) ) { |
|
| 377 | - register_admin_color_schemes(); |
|
| 378 | - } |
|
| 376 | + if ( function_exists( 'register_admin_color_schemes' ) ) { |
|
| 377 | + register_admin_color_schemes(); |
|
| 378 | + } |
|
| 379 | 379 | |
| 380 | - $hook_suffix = $admin_body_class = ''; |
|
| 380 | + $hook_suffix = $admin_body_class = ''; |
|
| 381 | 381 | |
| 382 | - if ( get_user_setting( 'mfold' ) == 'f' ) { |
|
| 383 | - $admin_body_class .= ' folded'; |
|
| 384 | - } |
|
| 382 | + if ( get_user_setting( 'mfold' ) == 'f' ) { |
|
| 383 | + $admin_body_class .= ' folded'; |
|
| 384 | + } |
|
| 385 | 385 | |
| 386 | - if ( function_exists( 'is_admin_bar_showing' ) && is_admin_bar_showing() ) { |
|
| 387 | - $admin_body_class .= ' admin-bar'; |
|
| 388 | - } |
|
| 386 | + if ( function_exists( 'is_admin_bar_showing' ) && is_admin_bar_showing() ) { |
|
| 387 | + $admin_body_class .= ' admin-bar'; |
|
| 388 | + } |
|
| 389 | 389 | |
| 390 | - if ( is_rtl() ) { |
|
| 391 | - $admin_body_class .= ' rtl'; |
|
| 392 | - } |
|
| 390 | + if ( is_rtl() ) { |
|
| 391 | + $admin_body_class .= ' rtl'; |
|
| 392 | + } |
|
| 393 | 393 | |
| 394 | - $admin_body_class .= ' admin-color-' . sanitize_html_class( get_user_option( 'admin_color' ), 'fresh' ); |
|
| 395 | - $prepop = array(); |
|
| 396 | - FrmFieldsHelper::get_bulk_prefilled_opts($prepop); |
|
| 394 | + $admin_body_class .= ' admin-color-' . sanitize_html_class( get_user_option( 'admin_color' ), 'fresh' ); |
|
| 395 | + $prepop = array(); |
|
| 396 | + FrmFieldsHelper::get_bulk_prefilled_opts($prepop); |
|
| 397 | 397 | |
| 398 | - $field = FrmField::getOne($field_id); |
|
| 398 | + $field = FrmField::getOne($field_id); |
|
| 399 | 399 | |
| 400 | - wp_enqueue_script( 'utils' ); |
|
| 400 | + wp_enqueue_script( 'utils' ); |
|
| 401 | 401 | wp_enqueue_style( 'formidable-admin', FrmAppHelper::plugin_url() . '/css/frm_admin.css' ); |
| 402 | - FrmAppHelper::load_admin_wide_js(); |
|
| 402 | + FrmAppHelper::load_admin_wide_js(); |
|
| 403 | 403 | |
| 404 | 404 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/import_choices.php' ); |
| 405 | - wp_die(); |
|
| 406 | - } |
|
| 405 | + wp_die(); |
|
| 406 | + } |
|
| 407 | 407 | |
| 408 | - public static function import_options() { |
|
| 408 | + public static function import_options() { |
|
| 409 | 409 | FrmAppHelper::permission_check('frm_edit_forms'); |
| 410 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 410 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 411 | 411 | |
| 412 | - if ( ! is_admin() || ! current_user_can('frm_edit_forms') ) { |
|
| 413 | - return; |
|
| 414 | - } |
|
| 412 | + if ( ! is_admin() || ! current_user_can('frm_edit_forms') ) { |
|
| 413 | + return; |
|
| 414 | + } |
|
| 415 | 415 | |
| 416 | 416 | $field_id = absint( $_POST['field_id'] ); |
| 417 | - $field = FrmField::getOne($field_id); |
|
| 417 | + $field = FrmField::getOne($field_id); |
|
| 418 | 418 | |
| 419 | 419 | if ( ! in_array( $field->type, array( 'radio', 'checkbox', 'select' ) ) ) { |
| 420 | - return; |
|
| 421 | - } |
|
| 420 | + return; |
|
| 421 | + } |
|
| 422 | 422 | |
| 423 | - $field = FrmFieldsHelper::setup_edit_vars($field); |
|
| 423 | + $field = FrmFieldsHelper::setup_edit_vars($field); |
|
| 424 | 424 | $opts = FrmAppHelper::get_param( 'opts', '', 'post', 'wp_kses_post' ); |
| 425 | 425 | $opts = explode( "\n", rtrim( $opts, "\n" ) ); |
| 426 | 426 | $opts = array_map( 'trim', $opts ); |
| 427 | 427 | |
| 428 | - if ( $field['separate_value'] ) { |
|
| 429 | - foreach ( $opts as $opt_key => $opt ) { |
|
| 430 | - if ( strpos($opt, '|') !== false ) { |
|
| 431 | - $vals = explode('|', $opt); |
|
| 432 | - if ( $vals[0] != $vals[1] ) { |
|
| 433 | - $opts[ $opt_key ] = array( 'label' => trim( $vals[0] ), 'value' => trim( $vals[1] ) ); |
|
| 434 | - } |
|
| 435 | - unset($vals); |
|
| 436 | - } |
|
| 437 | - unset($opt_key, $opt); |
|
| 438 | - } |
|
| 439 | - } |
|
| 440 | - |
|
| 441 | - //Keep other options after bulk update |
|
| 442 | - if ( isset( $field['field_options']['other'] ) && $field['field_options']['other'] == true ) { |
|
| 443 | - $other_array = array(); |
|
| 444 | - foreach ( $field['options'] as $opt_key => $opt ) { |
|
| 445 | - if ( $opt_key && strpos( $opt_key, 'other' ) !== false ) { |
|
| 446 | - $other_array[ $opt_key ] = $opt; |
|
| 447 | - } |
|
| 448 | - unset($opt_key, $opt); |
|
| 449 | - } |
|
| 450 | - if ( ! empty($other_array) ) { |
|
| 451 | - $opts = array_merge( $opts, $other_array); |
|
| 452 | - } |
|
| 453 | - } |
|
| 454 | - |
|
| 455 | - FrmField::update( $field_id, array( 'options' => maybe_serialize( $opts ) ) ); |
|
| 456 | - |
|
| 457 | - $field['options'] = $opts; |
|
| 458 | - $field_name = $field['name']; |
|
| 459 | - |
|
| 460 | - // Get html_id which will be used in single-option.php |
|
| 461 | - $html_id = FrmFieldsHelper::get_html_id( $field ); |
|
| 462 | - |
|
| 463 | - if ( $field['type'] == 'radio' || $field['type'] == 'checkbox' ) { |
|
| 428 | + if ( $field['separate_value'] ) { |
|
| 429 | + foreach ( $opts as $opt_key => $opt ) { |
|
| 430 | + if ( strpos($opt, '|') !== false ) { |
|
| 431 | + $vals = explode('|', $opt); |
|
| 432 | + if ( $vals[0] != $vals[1] ) { |
|
| 433 | + $opts[ $opt_key ] = array( 'label' => trim( $vals[0] ), 'value' => trim( $vals[1] ) ); |
|
| 434 | + } |
|
| 435 | + unset($vals); |
|
| 436 | + } |
|
| 437 | + unset($opt_key, $opt); |
|
| 438 | + } |
|
| 439 | + } |
|
| 440 | + |
|
| 441 | + //Keep other options after bulk update |
|
| 442 | + if ( isset( $field['field_options']['other'] ) && $field['field_options']['other'] == true ) { |
|
| 443 | + $other_array = array(); |
|
| 444 | + foreach ( $field['options'] as $opt_key => $opt ) { |
|
| 445 | + if ( $opt_key && strpos( $opt_key, 'other' ) !== false ) { |
|
| 446 | + $other_array[ $opt_key ] = $opt; |
|
| 447 | + } |
|
| 448 | + unset($opt_key, $opt); |
|
| 449 | + } |
|
| 450 | + if ( ! empty($other_array) ) { |
|
| 451 | + $opts = array_merge( $opts, $other_array); |
|
| 452 | + } |
|
| 453 | + } |
|
| 454 | + |
|
| 455 | + FrmField::update( $field_id, array( 'options' => maybe_serialize( $opts ) ) ); |
|
| 456 | + |
|
| 457 | + $field['options'] = $opts; |
|
| 458 | + $field_name = $field['name']; |
|
| 459 | + |
|
| 460 | + // Get html_id which will be used in single-option.php |
|
| 461 | + $html_id = FrmFieldsHelper::get_html_id( $field ); |
|
| 462 | + |
|
| 463 | + if ( $field['type'] == 'radio' || $field['type'] == 'checkbox' ) { |
|
| 464 | 464 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/radio.php' ); |
| 465 | - } else { |
|
| 466 | - FrmFieldsHelper::show_single_option($field); |
|
| 467 | - } |
|
| 465 | + } else { |
|
| 466 | + FrmFieldsHelper::show_single_option($field); |
|
| 467 | + } |
|
| 468 | 468 | |
| 469 | - wp_die(); |
|
| 470 | - } |
|
| 469 | + wp_die(); |
|
| 470 | + } |
|
| 471 | 471 | |
| 472 | - public static function update_order() { |
|
| 472 | + public static function update_order() { |
|
| 473 | 473 | FrmAppHelper::permission_check('frm_edit_forms'); |
| 474 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 474 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 475 | 475 | |
| 476 | 476 | $fields = FrmAppHelper::get_post_param( 'frm_field_id' ); |
| 477 | 477 | foreach ( (array) $fields as $position => $item ) { |
| 478 | 478 | FrmField::update( absint( $item ), array( 'field_order' => absint( $position ) ) ); |
| 479 | 479 | } |
| 480 | - wp_die(); |
|
| 481 | - } |
|
| 480 | + wp_die(); |
|
| 481 | + } |
|
| 482 | 482 | |
| 483 | 483 | public static function change_type( $type ) { |
| 484 | - $type_switch = array( |
|
| 485 | - 'scale' => 'radio', |
|
| 486 | - '10radio' => 'radio', |
|
| 487 | - 'rte' => 'textarea', |
|
| 488 | - 'website' => 'url', |
|
| 489 | - ); |
|
| 490 | - if ( isset( $type_switch[ $type ] ) ) { |
|
| 491 | - $type = $type_switch[ $type ]; |
|
| 492 | - } |
|
| 484 | + $type_switch = array( |
|
| 485 | + 'scale' => 'radio', |
|
| 486 | + '10radio' => 'radio', |
|
| 487 | + 'rte' => 'textarea', |
|
| 488 | + 'website' => 'url', |
|
| 489 | + ); |
|
| 490 | + if ( isset( $type_switch[ $type ] ) ) { |
|
| 491 | + $type = $type_switch[ $type ]; |
|
| 492 | + } |
|
| 493 | 493 | |
| 494 | 494 | $frm_field_selection = FrmField::field_selection(); |
| 495 | - $types = array_keys($frm_field_selection); |
|
| 496 | - if ( ! in_array($type, $types) && $type != 'captcha' ) { |
|
| 497 | - $type = 'text'; |
|
| 498 | - } |
|
| 495 | + $types = array_keys($frm_field_selection); |
|
| 496 | + if ( ! in_array($type, $types) && $type != 'captcha' ) { |
|
| 497 | + $type = 'text'; |
|
| 498 | + } |
|
| 499 | 499 | |
| 500 | - return $type; |
|
| 501 | - } |
|
| 500 | + return $type; |
|
| 501 | + } |
|
| 502 | 502 | |
| 503 | 503 | public static function display_field_options( $display ) { |
| 504 | 504 | switch ( $display['type'] ) { |
| 505 | - case 'captcha': |
|
| 506 | - $display['required'] = false; |
|
| 507 | - $display['invalid'] = true; |
|
| 508 | - $display['default_blank'] = false; |
|
| 505 | + case 'captcha': |
|
| 506 | + $display['required'] = false; |
|
| 507 | + $display['invalid'] = true; |
|
| 508 | + $display['default_blank'] = false; |
|
| 509 | 509 | $display['captcha_size'] = true; |
| 510 | - break; |
|
| 511 | - case 'radio': |
|
| 512 | - $display['default_blank'] = false; |
|
| 513 | - break; |
|
| 514 | - case 'text': |
|
| 515 | - case 'textarea': |
|
| 516 | - $display['size'] = true; |
|
| 517 | - $display['clear_on_focus'] = true; |
|
| 518 | - break; |
|
| 519 | - case 'select': |
|
| 520 | - $display['size'] = true; |
|
| 521 | - break; |
|
| 522 | - case 'url': |
|
| 523 | - case 'website': |
|
| 524 | - case 'email': |
|
| 525 | - $display['size'] = true; |
|
| 526 | - $display['clear_on_focus'] = true; |
|
| 527 | - $display['invalid'] = true; |
|
| 528 | - } |
|
| 529 | - |
|
| 530 | - return $display; |
|
| 531 | - } |
|
| 532 | - |
|
| 533 | - public static function input_html( $field, $echo = true ) { |
|
| 534 | - $class = array(); //$field['type']; |
|
| 535 | - self::add_input_classes($field, $class); |
|
| 536 | - |
|
| 537 | - $add_html = array(); |
|
| 538 | - self::add_html_size($field, $add_html); |
|
| 539 | - self::add_html_length($field, $add_html); |
|
| 540 | - self::add_html_placeholder($field, $add_html, $class); |
|
| 510 | + break; |
|
| 511 | + case 'radio': |
|
| 512 | + $display['default_blank'] = false; |
|
| 513 | + break; |
|
| 514 | + case 'text': |
|
| 515 | + case 'textarea': |
|
| 516 | + $display['size'] = true; |
|
| 517 | + $display['clear_on_focus'] = true; |
|
| 518 | + break; |
|
| 519 | + case 'select': |
|
| 520 | + $display['size'] = true; |
|
| 521 | + break; |
|
| 522 | + case 'url': |
|
| 523 | + case 'website': |
|
| 524 | + case 'email': |
|
| 525 | + $display['size'] = true; |
|
| 526 | + $display['clear_on_focus'] = true; |
|
| 527 | + $display['invalid'] = true; |
|
| 528 | + } |
|
| 529 | + |
|
| 530 | + return $display; |
|
| 531 | + } |
|
| 532 | + |
|
| 533 | + public static function input_html( $field, $echo = true ) { |
|
| 534 | + $class = array(); //$field['type']; |
|
| 535 | + self::add_input_classes($field, $class); |
|
| 536 | + |
|
| 537 | + $add_html = array(); |
|
| 538 | + self::add_html_size($field, $add_html); |
|
| 539 | + self::add_html_length($field, $add_html); |
|
| 540 | + self::add_html_placeholder($field, $add_html, $class); |
|
| 541 | 541 | self::add_validation_messages( $field, $add_html ); |
| 542 | 542 | |
| 543 | - $class = apply_filters('frm_field_classes', implode(' ', $class), $field); |
|
| 543 | + $class = apply_filters('frm_field_classes', implode(' ', $class), $field); |
|
| 544 | 544 | |
| 545 | 545 | FrmFormsHelper::add_html_attr( $class, 'class', $add_html ); |
| 546 | 546 | |
| 547 | - self::add_shortcodes_to_html($field, $add_html); |
|
| 547 | + self::add_shortcodes_to_html($field, $add_html); |
|
| 548 | 548 | |
| 549 | 549 | $add_html = apply_filters( 'frm_field_extra_html', $add_html, $field ); |
| 550 | 550 | $add_html = ' ' . implode( ' ', $add_html ) . ' '; |
| 551 | 551 | |
| 552 | - if ( $echo ) { |
|
| 553 | - echo $add_html; |
|
| 554 | - } |
|
| 552 | + if ( $echo ) { |
|
| 553 | + echo $add_html; |
|
| 554 | + } |
|
| 555 | 555 | |
| 556 | - return $add_html; |
|
| 557 | - } |
|
| 556 | + return $add_html; |
|
| 557 | + } |
|
| 558 | 558 | |
| 559 | 559 | private static function add_input_classes( $field, array &$class ) { |
| 560 | - if ( isset($field['input_class']) && ! empty($field['input_class']) ) { |
|
| 561 | - $class[] = $field['input_class']; |
|
| 562 | - } |
|
| 560 | + if ( isset($field['input_class']) && ! empty($field['input_class']) ) { |
|
| 561 | + $class[] = $field['input_class']; |
|
| 562 | + } |
|
| 563 | 563 | |
| 564 | - if ( $field['type'] == 'hidden' || $field['type'] == 'user_id' ) { |
|
| 565 | - return; |
|
| 566 | - } |
|
| 564 | + if ( $field['type'] == 'hidden' || $field['type'] == 'user_id' ) { |
|
| 565 | + return; |
|
| 566 | + } |
|
| 567 | 567 | |
| 568 | - if ( isset($field['size']) && $field['size'] > 0 ) { |
|
| 569 | - $class[] = 'auto_width'; |
|
| 570 | - } |
|
| 571 | - } |
|
| 568 | + if ( isset($field['size']) && $field['size'] > 0 ) { |
|
| 569 | + $class[] = 'auto_width'; |
|
| 570 | + } |
|
| 571 | + } |
|
| 572 | 572 | |
| 573 | 573 | private static function add_html_size( $field, array &$add_html ) { |
| 574 | 574 | if ( ! isset( $field['size'] ) || $field['size'] <= 0 || in_array( $field['type'], array( 'select', 'data', 'time', 'hidden', 'file', 'lookup' ) ) ) { |
| 575 | - return; |
|
| 576 | - } |
|
| 575 | + return; |
|
| 576 | + } |
|
| 577 | 577 | |
| 578 | - if ( FrmAppHelper::is_admin_page('formidable' ) ) { |
|
| 579 | - return; |
|
| 580 | - } |
|
| 578 | + if ( FrmAppHelper::is_admin_page('formidable' ) ) { |
|
| 579 | + return; |
|
| 580 | + } |
|
| 581 | 581 | |
| 582 | - if ( is_numeric($field['size']) ) { |
|
| 583 | - $field['size'] .= 'px'; |
|
| 584 | - } |
|
| 582 | + if ( is_numeric($field['size']) ) { |
|
| 583 | + $field['size'] .= 'px'; |
|
| 584 | + } |
|
| 585 | 585 | |
| 586 | - $important = apply_filters('frm_use_important_width', 1, $field); |
|
| 587 | - // Note: This inline styling must stay since we cannot realistically set a class for every possible field size |
|
| 586 | + $important = apply_filters('frm_use_important_width', 1, $field); |
|
| 587 | + // Note: This inline styling must stay since we cannot realistically set a class for every possible field size |
|
| 588 | 588 | $add_html['style'] = 'style="width:' . esc_attr( $field['size'] ) . ( $important ? ' !important' : '' ) . '"'; |
| 589 | 589 | |
| 590 | - self::add_html_cols($field, $add_html); |
|
| 591 | - } |
|
| 590 | + self::add_html_cols($field, $add_html); |
|
| 591 | + } |
|
| 592 | 592 | |
| 593 | 593 | private static function add_html_cols( $field, array &$add_html ) { |
| 594 | 594 | if ( ! in_array( $field['type'], array( 'textarea', 'rte' ) ) ) { |
| 595 | - return; |
|
| 596 | - } |
|
| 595 | + return; |
|
| 596 | + } |
|
| 597 | 597 | |
| 598 | - // convert to cols for textareas |
|
| 599 | - $calc = array( |
|
| 600 | - '' => 9, |
|
| 601 | - 'px' => 9, |
|
| 602 | - 'rem' => 0.444, |
|
| 603 | - 'em' => 0.544, |
|
| 604 | - ); |
|
| 598 | + // convert to cols for textareas |
|
| 599 | + $calc = array( |
|
| 600 | + '' => 9, |
|
| 601 | + 'px' => 9, |
|
| 602 | + 'rem' => 0.444, |
|
| 603 | + 'em' => 0.544, |
|
| 604 | + ); |
|
| 605 | 605 | |
| 606 | - // include "col" for valid html |
|
| 607 | - $unit = trim(preg_replace('/[0-9]+/', '', $field['size'])); |
|
| 606 | + // include "col" for valid html |
|
| 607 | + $unit = trim(preg_replace('/[0-9]+/', '', $field['size'])); |
|
| 608 | 608 | |
| 609 | - if ( ! isset( $calc[ $unit ] ) ) { |
|
| 610 | - return; |
|
| 611 | - } |
|
| 609 | + if ( ! isset( $calc[ $unit ] ) ) { |
|
| 610 | + return; |
|
| 611 | + } |
|
| 612 | 612 | |
| 613 | - $size = (float) str_replace( $unit, '', $field['size'] ) / $calc[ $unit ]; |
|
| 613 | + $size = (float) str_replace( $unit, '', $field['size'] ) / $calc[ $unit ]; |
|
| 614 | 614 | |
| 615 | 615 | $add_html['cols'] = 'cols="' . absint( $size ) . '"'; |
| 616 | - } |
|
| 616 | + } |
|
| 617 | 617 | |
| 618 | 618 | private static function add_html_length( $field, array &$add_html ) { |
| 619 | - // check for max setting and if this field accepts maxlength |
|
| 619 | + // check for max setting and if this field accepts maxlength |
|
| 620 | 620 | if ( FrmField::is_option_empty( $field, 'max' ) || in_array( $field['type'], array( 'textarea', 'rte', 'hidden', 'file' ) ) ) { |
| 621 | - return; |
|
| 622 | - } |
|
| 621 | + return; |
|
| 622 | + } |
|
| 623 | 623 | |
| 624 | - if ( FrmAppHelper::is_admin_page('formidable' ) ) { |
|
| 625 | - // don't load on form builder page |
|
| 626 | - return; |
|
| 627 | - } |
|
| 624 | + if ( FrmAppHelper::is_admin_page('formidable' ) ) { |
|
| 625 | + // don't load on form builder page |
|
| 626 | + return; |
|
| 627 | + } |
|
| 628 | 628 | |
| 629 | 629 | $add_html['maxlength'] = 'maxlength="' . esc_attr( $field['max'] ) . '"'; |
| 630 | - } |
|
| 630 | + } |
|
| 631 | 631 | |
| 632 | 632 | private static function add_html_placeholder( $field, array &$add_html, array &$class ) { |
| 633 | 633 | if ( empty( $field['default_value'] ) || FrmAppHelper::is_admin_page( 'formidable' ) ) { |
@@ -635,35 +635,35 @@ discard block |
||
| 635 | 635 | } |
| 636 | 636 | |
| 637 | 637 | $default_value_array = is_array( $field['default_value'] ); |
| 638 | - if ( ! FrmField::is_option_true( $field, 'clear_on_focus' ) ) { |
|
| 638 | + if ( ! FrmField::is_option_true( $field, 'clear_on_focus' ) ) { |
|
| 639 | 639 | if ( $default_value_array ) { |
| 640 | 640 | $field['default_value'] = json_encode( $field['default_value'] ); |
| 641 | 641 | } |
| 642 | 642 | $add_html['data-frmval'] = 'data-frmval="' . esc_attr( $field['default_value'] ) . '"'; |
| 643 | - return; |
|
| 644 | - } |
|
| 643 | + return; |
|
| 644 | + } |
|
| 645 | 645 | |
| 646 | 646 | if ( $default_value_array ) { |
| 647 | 647 | // don't include a json placeholder |
| 648 | 648 | return; |
| 649 | 649 | } |
| 650 | 650 | |
| 651 | - $frm_settings = FrmAppHelper::get_settings(); |
|
| 651 | + $frm_settings = FrmAppHelper::get_settings(); |
|
| 652 | 652 | |
| 653 | 653 | if ( $frm_settings->use_html && ! in_array( $field['type'], array( 'select', 'radio', 'checkbox', 'hidden' ) ) ) { |
| 654 | - // use HMTL5 placeholder with js fallback |
|
| 654 | + // use HMTL5 placeholder with js fallback |
|
| 655 | 655 | $add_html['placeholder'] = 'placeholder="' . esc_attr( $field['default_value'] ) . '"'; |
| 656 | - wp_enqueue_script('jquery-placeholder'); |
|
| 657 | - } else if ( ! $frm_settings->use_html ) { |
|
| 656 | + wp_enqueue_script('jquery-placeholder'); |
|
| 657 | + } else if ( ! $frm_settings->use_html ) { |
|
| 658 | 658 | $val = str_replace( array( "\r\n", "\n" ), '\r', addslashes( str_replace( ''', "'", esc_attr( $field['default_value'] ) ) ) ); |
| 659 | 659 | $add_html['data-frmval'] = 'data-frmval="' . esc_attr( $val ) . '"'; |
| 660 | - $class[] = 'frm_toggle_default'; |
|
| 660 | + $class[] = 'frm_toggle_default'; |
|
| 661 | 661 | |
| 662 | - if ( $field['value'] == $field['default_value'] ) { |
|
| 663 | - $class[] = 'frm_default'; |
|
| 664 | - } |
|
| 665 | - } |
|
| 666 | - } |
|
| 662 | + if ( $field['value'] == $field['default_value'] ) { |
|
| 663 | + $class[] = 'frm_default'; |
|
| 664 | + } |
|
| 665 | + } |
|
| 666 | + } |
|
| 667 | 667 | |
| 668 | 668 | private static function add_validation_messages( $field, array &$add_html ) { |
| 669 | 669 | if ( FrmField::is_required( $field ) ) { |
@@ -677,44 +677,44 @@ discard block |
||
| 677 | 677 | } |
| 678 | 678 | } |
| 679 | 679 | |
| 680 | - private static function add_shortcodes_to_html( $field, array &$add_html ) { |
|
| 681 | - if ( FrmField::is_option_empty( $field, 'shortcodes' ) ) { |
|
| 682 | - return; |
|
| 683 | - } |
|
| 680 | + private static function add_shortcodes_to_html( $field, array &$add_html ) { |
|
| 681 | + if ( FrmField::is_option_empty( $field, 'shortcodes' ) ) { |
|
| 682 | + return; |
|
| 683 | + } |
|
| 684 | 684 | |
| 685 | - foreach ( $field['shortcodes'] as $k => $v ) { |
|
| 686 | - if ( 'opt' === $k ) { |
|
| 687 | - continue; |
|
| 688 | - } |
|
| 685 | + foreach ( $field['shortcodes'] as $k => $v ) { |
|
| 686 | + if ( 'opt' === $k ) { |
|
| 687 | + continue; |
|
| 688 | + } |
|
| 689 | 689 | |
| 690 | - if ( is_numeric($k) && strpos($v, '=') ) { |
|
| 691 | - $add_html[] = $v; |
|
| 692 | - } else if ( ! empty( $k ) && isset( $add_html[ $k ] ) ) { |
|
| 690 | + if ( is_numeric($k) && strpos($v, '=') ) { |
|
| 691 | + $add_html[] = $v; |
|
| 692 | + } else if ( ! empty( $k ) && isset( $add_html[ $k ] ) ) { |
|
| 693 | 693 | $add_html[ $k ] = str_replace( $k . '="', $k . '="' . $v, $add_html[ $k ] ); |
| 694 | - } else { |
|
| 694 | + } else { |
|
| 695 | 695 | $add_html[ $k ] = $k . '="' . esc_attr( $v ) . '"'; |
| 696 | - } |
|
| 697 | - |
|
| 698 | - unset($k, $v); |
|
| 699 | - } |
|
| 700 | - } |
|
| 701 | - |
|
| 702 | - public static function check_value( $opt, $opt_key, $field ) { |
|
| 703 | - if ( is_array( $opt ) ) { |
|
| 704 | - if ( FrmField::is_option_true( $field, 'separate_value' ) ) { |
|
| 705 | - $opt = isset( $opt['value'] ) ? $opt['value'] : ( isset( $opt['label'] ) ? $opt['label'] : reset( $opt ) ); |
|
| 706 | - } else { |
|
| 707 | - $opt = isset( $opt['label'] ) ? $opt['label'] : reset( $opt ); |
|
| 708 | - } |
|
| 709 | - } |
|
| 710 | - return $opt; |
|
| 711 | - } |
|
| 696 | + } |
|
| 697 | + |
|
| 698 | + unset($k, $v); |
|
| 699 | + } |
|
| 700 | + } |
|
| 701 | + |
|
| 702 | + public static function check_value( $opt, $opt_key, $field ) { |
|
| 703 | + if ( is_array( $opt ) ) { |
|
| 704 | + if ( FrmField::is_option_true( $field, 'separate_value' ) ) { |
|
| 705 | + $opt = isset( $opt['value'] ) ? $opt['value'] : ( isset( $opt['label'] ) ? $opt['label'] : reset( $opt ) ); |
|
| 706 | + } else { |
|
| 707 | + $opt = isset( $opt['label'] ) ? $opt['label'] : reset( $opt ); |
|
| 708 | + } |
|
| 709 | + } |
|
| 710 | + return $opt; |
|
| 711 | + } |
|
| 712 | 712 | |
| 713 | 713 | public static function check_label( $opt ) { |
| 714 | - if ( is_array($opt) ) { |
|
| 715 | - $opt = (isset($opt['label']) ? $opt['label'] : reset($opt)); |
|
| 716 | - } |
|
| 714 | + if ( is_array($opt) ) { |
|
| 715 | + $opt = (isset($opt['label']) ? $opt['label'] : reset($opt)); |
|
| 716 | + } |
|
| 717 | 717 | |
| 718 | - return $opt; |
|
| 719 | - } |
|
| 718 | + return $opt; |
|
| 719 | + } |
|
| 720 | 720 | } |