@@ -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,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,10 +114,10 @@ discard block |
||
| 114 | 114 | $create_file = new FrmCreateFile( array( 'folder_name' => 'formidable/css', 'file_name' => 'formidablepro.css' ) ); |
| 115 | 115 | $create_file->create_file( $css ); |
| 116 | 116 | |
| 117 | - update_option('frmpro_css', $css); |
|
| 117 | + update_option( 'frmpro_css', $css ); |
|
| 118 | 118 | |
| 119 | - delete_transient('frmpro_css'); |
|
| 120 | - set_transient('frmpro_css', $css); |
|
| 119 | + delete_transient( 'frmpro_css' ); |
|
| 120 | + set_transient( 'frmpro_css', $css ); |
|
| 121 | 121 | } |
| 122 | 122 | |
| 123 | 123 | private function get_css_content( $filename ) { |
@@ -135,7 +135,7 @@ discard block |
||
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | public function destroy( $id ) { |
| 138 | - return wp_delete_post($id); |
|
| 138 | + return wp_delete_post( $id ); |
|
| 139 | 139 | } |
| 140 | 140 | |
| 141 | 141 | public function get_one() { |
@@ -149,19 +149,19 @@ discard block |
||
| 149 | 149 | return $style; |
| 150 | 150 | } |
| 151 | 151 | |
| 152 | - $style = get_post($this->id); |
|
| 152 | + $style = get_post( $this->id ); |
|
| 153 | 153 | |
| 154 | 154 | if ( ! $style ) { |
| 155 | 155 | return $style; |
| 156 | 156 | } |
| 157 | 157 | |
| 158 | - $style->post_content = FrmAppHelper::maybe_json_decode($style->post_content); |
|
| 158 | + $style->post_content = FrmAppHelper::maybe_json_decode( $style->post_content ); |
|
| 159 | 159 | |
| 160 | 160 | $default_values = $this->get_defaults(); |
| 161 | 161 | |
| 162 | 162 | // fill default values |
| 163 | - $style->post_content = $this->override_defaults($style->post_content); |
|
| 164 | - $style->post_content = wp_parse_args( $style->post_content, $default_values); |
|
| 163 | + $style->post_content = $this->override_defaults( $style->post_content ); |
|
| 164 | + $style->post_content = wp_parse_args( $style->post_content, $default_values ); |
|
| 165 | 165 | |
| 166 | 166 | return $style; |
| 167 | 167 | } |
@@ -175,21 +175,21 @@ discard block |
||
| 175 | 175 | 'order' => $order, |
| 176 | 176 | ); |
| 177 | 177 | |
| 178 | - $temp_styles = FrmAppHelper::check_cache(serialize($post_atts), 'frm_styles', $post_atts, 'get_posts'); |
|
| 178 | + $temp_styles = FrmAppHelper::check_cache( serialize( $post_atts ), 'frm_styles', $post_atts, 'get_posts' ); |
|
| 179 | 179 | |
| 180 | - if ( empty($temp_styles) ) { |
|
| 180 | + if ( empty( $temp_styles ) ) { |
|
| 181 | 181 | global $wpdb; |
| 182 | 182 | // make sure there wasn't a conflict with the query |
| 183 | 183 | $query = $wpdb->prepare( 'SELECT * FROM ' . $wpdb->posts . ' WHERE post_type=%s AND post_status=%s ORDER BY post_title ASC LIMIT 99', FrmStylesController::$post_type, 'publish' ); |
| 184 | - $temp_styles = FrmAppHelper::check_cache('frm_backup_style_check', 'frm_styles', $query, 'get_results'); |
|
| 184 | + $temp_styles = FrmAppHelper::check_cache( 'frm_backup_style_check', 'frm_styles', $query, 'get_results' ); |
|
| 185 | 185 | |
| 186 | - if ( empty($temp_styles) ) { |
|
| 186 | + if ( empty( $temp_styles ) ) { |
|
| 187 | 187 | // create a new style if there are none |
| 188 | 188 | $new = $this->get_new(); |
| 189 | 189 | $new->post_title = $new->post_name = __( 'Formidable Style', 'formidable' ); |
| 190 | 190 | $new->menu_order = 1; |
| 191 | - $new = $this->save( (array) $new); |
|
| 192 | - $this->update('default'); |
|
| 191 | + $new = $this->save( (array) $new ); |
|
| 192 | + $this->update( 'default' ); |
|
| 193 | 193 | |
| 194 | 194 | $post_atts['include'] = $new; |
| 195 | 195 | |
@@ -213,25 +213,25 @@ discard block |
||
| 213 | 213 | } |
| 214 | 214 | } |
| 215 | 215 | |
| 216 | - $style->post_content = FrmAppHelper::maybe_json_decode($style->post_content); |
|
| 216 | + $style->post_content = FrmAppHelper::maybe_json_decode( $style->post_content ); |
|
| 217 | 217 | |
| 218 | 218 | // fill default values |
| 219 | - $style->post_content = $this->override_defaults($style->post_content); |
|
| 220 | - $style->post_content = wp_parse_args( $style->post_content, $default_values); |
|
| 219 | + $style->post_content = $this->override_defaults( $style->post_content ); |
|
| 220 | + $style->post_content = wp_parse_args( $style->post_content, $default_values ); |
|
| 221 | 221 | |
| 222 | - $styles[ $style->ID ] = $style; |
|
| 222 | + $styles[$style->ID] = $style; |
|
| 223 | 223 | } |
| 224 | 224 | |
| 225 | 225 | if ( ! $default_style ) { |
| 226 | - $default_style = reset($styles); |
|
| 227 | - $styles[ $default_style->ID ]->menu_order = 1; |
|
| 226 | + $default_style = reset( $styles ); |
|
| 227 | + $styles[$default_style->ID]->menu_order = 1; |
|
| 228 | 228 | } |
| 229 | 229 | |
| 230 | 230 | return $styles; |
| 231 | 231 | } |
| 232 | 232 | |
| 233 | 233 | public function get_default_style( $styles = null ) { |
| 234 | - if ( ! isset($styles) ) { |
|
| 234 | + if ( ! isset( $styles ) ) { |
|
| 235 | 235 | $styles = $this->get_all( 'menu_order', 'DESC', 1 ); |
| 236 | 236 | } |
| 237 | 237 | |
@@ -243,24 +243,24 @@ discard block |
||
| 243 | 243 | } |
| 244 | 244 | |
| 245 | 245 | public function override_defaults( $settings ) { |
| 246 | - if ( ! is_array($settings) ) { |
|
| 246 | + if ( ! is_array( $settings ) ) { |
|
| 247 | 247 | return $settings; |
| 248 | 248 | } |
| 249 | 249 | |
| 250 | - $settings['line_height'] = ( ! isset($settings['field_height']) || $settings['field_height'] == '' || $settings['field_height'] == 'auto') ? 'normal' : $settings['field_height']; |
|
| 250 | + $settings['line_height'] = ( ! isset( $settings['field_height'] ) || $settings['field_height'] == '' || $settings['field_height'] == 'auto' ) ? 'normal' : $settings['field_height']; |
|
| 251 | 251 | |
| 252 | - if ( ! isset($settings['form_desc_size']) && isset($settings['description_font_size']) ) { |
|
| 252 | + if ( ! isset( $settings['form_desc_size'] ) && isset( $settings['description_font_size'] ) ) { |
|
| 253 | 253 | $settings['form_desc_size'] = $settings['description_font_size']; |
| 254 | 254 | $settings['form_desc_color'] = $settings['description_color']; |
| 255 | 255 | $settings['title_color'] = $settings['label_color']; |
| 256 | 256 | } |
| 257 | 257 | |
| 258 | - if ( ! isset($settings['section_color']) && isset($settings['label_color']) ) { |
|
| 258 | + if ( ! isset( $settings['section_color'] ) && isset( $settings['label_color'] ) ) { |
|
| 259 | 259 | $settings['section_color'] = $settings['label_color']; |
| 260 | 260 | $settings['section_border_color'] = $settings['border_color']; |
| 261 | 261 | } |
| 262 | 262 | |
| 263 | - if ( ! isset($settings['submit_hover_bg_color']) && isset($settings['submit_bg_color']) ) { |
|
| 263 | + if ( ! isset( $settings['submit_hover_bg_color'] ) && isset( $settings['submit_bg_color'] ) ) { |
|
| 264 | 264 | $settings['submit_hover_bg_color'] = $settings['submit_bg_color']; |
| 265 | 265 | $settings['submit_hover_color'] = $settings['submit_text_color']; |
| 266 | 266 | $settings['submit_hover_border_color'] = $settings['submit_border_color']; |
@@ -1,52 +1,52 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | class FrmStyle { |
| 3 | - public $number = false; // Unique ID number of the current instance. |
|
| 3 | + public $number = false; // Unique ID number of the current instance. |
|
| 4 | 4 | public $id = 0; // the id of the post |
| 5 | 5 | |
| 6 | 6 | /** |
| 7 | 7 | * @param int|string $id The id of the stylsheet or 'default' |
| 8 | 8 | */ |
| 9 | 9 | public function __construct( $id = 0 ) { |
| 10 | - $this->id = $id; |
|
| 11 | - } |
|
| 10 | + $this->id = $id; |
|
| 11 | + } |
|
| 12 | 12 | |
| 13 | - public function get_new() { |
|
| 13 | + public function get_new() { |
|
| 14 | 14 | $this->id = 0; |
| 15 | 15 | |
| 16 | - $max_slug_value = pow(36, 6); |
|
| 17 | - $min_slug_value = 37; // we want to have at least 2 characters in the slug |
|
| 18 | - $key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 ); |
|
| 19 | - |
|
| 20 | - $style = array( |
|
| 21 | - 'post_type' => FrmStylesController::$post_type, |
|
| 22 | - 'ID' => '', |
|
| 23 | - 'post_title' => __( 'New Style', 'formidable' ), |
|
| 24 | - 'post_name' => $key, |
|
| 25 | - 'post_content' => $this->get_defaults(), |
|
| 26 | - 'menu_order' => '', |
|
| 27 | - 'post_status' => 'publish', |
|
| 28 | - ); |
|
| 16 | + $max_slug_value = pow(36, 6); |
|
| 17 | + $min_slug_value = 37; // we want to have at least 2 characters in the slug |
|
| 18 | + $key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 ); |
|
| 19 | + |
|
| 20 | + $style = array( |
|
| 21 | + 'post_type' => FrmStylesController::$post_type, |
|
| 22 | + 'ID' => '', |
|
| 23 | + 'post_title' => __( 'New Style', 'formidable' ), |
|
| 24 | + 'post_name' => $key, |
|
| 25 | + 'post_content' => $this->get_defaults(), |
|
| 26 | + 'menu_order' => '', |
|
| 27 | + 'post_status' => 'publish', |
|
| 28 | + ); |
|
| 29 | 29 | |
| 30 | - return (object) $style; |
|
| 31 | - } |
|
| 30 | + return (object) $style; |
|
| 31 | + } |
|
| 32 | 32 | |
| 33 | 33 | public function save( $settings ) { |
| 34 | 34 | return FrmAppHelper::save_settings( $settings, 'frm_styles' ); |
| 35 | - } |
|
| 35 | + } |
|
| 36 | 36 | |
| 37 | 37 | public function duplicate( $id ) { |
| 38 | - // duplicating is a pro feature |
|
| 39 | - } |
|
| 38 | + // duplicating is a pro feature |
|
| 39 | + } |
|
| 40 | 40 | |
| 41 | - public function update( $id = 'default' ) { |
|
| 41 | + public function update( $id = 'default' ) { |
|
| 42 | 42 | $all_instances = $this->get_all(); |
| 43 | 43 | |
| 44 | 44 | if ( empty($id) ) { |
| 45 | - $new_style = (array) $this->get_new(); |
|
| 46 | - $all_instances[] = $new_style; |
|
| 45 | + $new_style = (array) $this->get_new(); |
|
| 46 | + $all_instances[] = $new_style; |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | - $action_ids = array(); |
|
| 49 | + $action_ids = array(); |
|
| 50 | 50 | |
| 51 | 51 | foreach ( $all_instances as $number => $new_instance ) { |
| 52 | 52 | $new_instance = stripslashes_deep( (array) $new_instance); |
@@ -54,42 +54,42 @@ discard block |
||
| 54 | 54 | if ( $id != $this->id || ! $_POST || ! isset($_POST['frm_style_setting']) ) { |
| 55 | 55 | $all_instances[ $number ] = $new_instance; |
| 56 | 56 | |
| 57 | - if ( $new_instance['menu_order'] && $_POST && empty($_POST['prev_menu_order']) && isset($_POST['frm_style_setting']['menu_order']) ) { |
|
| 58 | - // this style was set to default, so remove default setting on previous default style |
|
| 59 | - $new_instance['menu_order'] = 0; |
|
| 60 | - $action_ids[] = $this->save($new_instance); |
|
| 61 | - } |
|
| 57 | + if ( $new_instance['menu_order'] && $_POST && empty($_POST['prev_menu_order']) && isset($_POST['frm_style_setting']['menu_order']) ) { |
|
| 58 | + // this style was set to default, so remove default setting on previous default style |
|
| 59 | + $new_instance['menu_order'] = 0; |
|
| 60 | + $action_ids[] = $this->save($new_instance); |
|
| 61 | + } |
|
| 62 | 62 | |
| 63 | - // don't continue if not saving this style |
|
| 64 | - continue; |
|
| 63 | + // don't continue if not saving this style |
|
| 64 | + continue; |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | $new_instance['post_title'] = sanitize_text_field( $_POST['frm_style_setting']['post_title'] ); |
| 68 | 68 | $new_instance['post_content'] = $_POST['frm_style_setting']['post_content']; |
| 69 | 69 | $new_instance['post_type'] = FrmStylesController::$post_type; |
| 70 | - $new_instance['post_status'] = 'publish'; |
|
| 70 | + $new_instance['post_status'] = 'publish'; |
|
| 71 | 71 | $new_instance['menu_order'] = isset( $_POST['frm_style_setting']['menu_order'] ) ? absint( $_POST['frm_style_setting']['menu_order'] ) : 0; |
| 72 | 72 | |
| 73 | - if ( empty($id) ) { |
|
| 74 | - $new_instance['post_name'] = $new_instance['post_title']; |
|
| 75 | - } |
|
| 73 | + if ( empty($id) ) { |
|
| 74 | + $new_instance['post_name'] = $new_instance['post_title']; |
|
| 75 | + } |
|
| 76 | 76 | |
| 77 | - $default_settings = $this->get_defaults(); |
|
| 77 | + $default_settings = $this->get_defaults(); |
|
| 78 | 78 | |
| 79 | - foreach ( $default_settings as $setting => $default ) { |
|
| 79 | + foreach ( $default_settings as $setting => $default ) { |
|
| 80 | 80 | if ( strpos( $setting, 'color' ) !== false || in_array( $setting, array( 'error_bg', 'error_border', 'error_text' ) ) ) { |
| 81 | - //if is a color |
|
| 81 | + //if is a color |
|
| 82 | 82 | $new_instance['post_content'][ $setting ] = str_replace( '#', '', $new_instance['post_content'][ $setting ] ); |
| 83 | 83 | } else if ( in_array( $setting, array( 'submit_style', 'important_style', 'auto_width' ) ) && ! isset( $new_instance['post_content'][ $setting ] ) ) { |
| 84 | 84 | $new_instance['post_content'][ $setting ] = 0; |
| 85 | - } else if ( $setting == 'font' ) { |
|
| 86 | - $new_instance['post_content'][ $setting ] = $this->force_balanced_quotation( $new_instance['post_content'][ $setting ] ); |
|
| 87 | - } |
|
| 88 | - } |
|
| 85 | + } else if ( $setting == 'font' ) { |
|
| 86 | + $new_instance['post_content'][ $setting ] = $this->force_balanced_quotation( $new_instance['post_content'][ $setting ] ); |
|
| 87 | + } |
|
| 88 | + } |
|
| 89 | 89 | |
| 90 | 90 | $all_instances[ $number ] = $new_instance; |
| 91 | 91 | |
| 92 | - $action_ids[] = $this->save($new_instance); |
|
| 92 | + $action_ids[] = $this->save($new_instance); |
|
| 93 | 93 | |
| 94 | 94 | } |
| 95 | 95 | |
@@ -98,26 +98,26 @@ discard block |
||
| 98 | 98 | return $action_ids; |
| 99 | 99 | } |
| 100 | 100 | |
| 101 | - /** |
|
| 102 | - * Create static css file |
|
| 103 | - */ |
|
| 101 | + /** |
|
| 102 | + * Create static css file |
|
| 103 | + */ |
|
| 104 | 104 | public function save_settings() { |
| 105 | 105 | $filename = FrmAppHelper::plugin_path() . '/css/custom_theme.css.php'; |
| 106 | 106 | update_option( 'frm_last_style_update', date('njGi') ); |
| 107 | 107 | |
| 108 | - if ( ! is_file($filename) ) { |
|
| 109 | - return; |
|
| 110 | - } |
|
| 108 | + if ( ! is_file($filename) ) { |
|
| 109 | + return; |
|
| 110 | + } |
|
| 111 | 111 | |
| 112 | 112 | $css = $this->get_css_content( $filename ); |
| 113 | 113 | |
| 114 | 114 | $create_file = new FrmCreateFile( array( 'folder_name' => 'formidable/css', 'file_name' => 'formidablepro.css' ) ); |
| 115 | 115 | $create_file->create_file( $css ); |
| 116 | 116 | |
| 117 | - update_option('frmpro_css', $css); |
|
| 117 | + update_option('frmpro_css', $css); |
|
| 118 | 118 | |
| 119 | - delete_transient('frmpro_css'); |
|
| 120 | - set_transient('frmpro_css', $css); |
|
| 119 | + delete_transient('frmpro_css'); |
|
| 120 | + set_transient('frmpro_css', $css); |
|
| 121 | 121 | } |
| 122 | 122 | |
| 123 | 123 | private function get_css_content( $filename ) { |
@@ -126,281 +126,281 @@ discard block |
||
| 126 | 126 | $saving = true; |
| 127 | 127 | $frm_style = $this; |
| 128 | 128 | |
| 129 | - ob_start(); |
|
| 130 | - include( $filename ); |
|
| 129 | + ob_start(); |
|
| 130 | + include( $filename ); |
|
| 131 | 131 | $css .= preg_replace( '/\/\*(.|\s)*?\*\//', '', str_replace( array( "\r\n", "\r", "\n", "\t", ' ' ), '', ob_get_contents() ) ); |
| 132 | - ob_end_clean(); |
|
| 132 | + ob_end_clean(); |
|
| 133 | 133 | |
| 134 | 134 | return $css; |
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | public function destroy( $id ) { |
| 138 | - return wp_delete_post($id); |
|
| 139 | - } |
|
| 138 | + return wp_delete_post($id); |
|
| 139 | + } |
|
| 140 | 140 | |
| 141 | - public function get_one() { |
|
| 142 | - if ( 'default' == $this->id ) { |
|
| 143 | - $style = $this->get_default_style(); |
|
| 144 | - if ( $style ) { |
|
| 145 | - $this->id = $style->ID; |
|
| 146 | - } else { |
|
| 147 | - $this->id = 0; |
|
| 148 | - } |
|
| 149 | - return $style; |
|
| 150 | - } |
|
| 141 | + public function get_one() { |
|
| 142 | + if ( 'default' == $this->id ) { |
|
| 143 | + $style = $this->get_default_style(); |
|
| 144 | + if ( $style ) { |
|
| 145 | + $this->id = $style->ID; |
|
| 146 | + } else { |
|
| 147 | + $this->id = 0; |
|
| 148 | + } |
|
| 149 | + return $style; |
|
| 150 | + } |
|
| 151 | 151 | |
| 152 | - $style = get_post($this->id); |
|
| 152 | + $style = get_post($this->id); |
|
| 153 | 153 | |
| 154 | - if ( ! $style ) { |
|
| 155 | - return $style; |
|
| 156 | - } |
|
| 154 | + if ( ! $style ) { |
|
| 155 | + return $style; |
|
| 156 | + } |
|
| 157 | 157 | |
| 158 | - $style->post_content = FrmAppHelper::maybe_json_decode($style->post_content); |
|
| 158 | + $style->post_content = FrmAppHelper::maybe_json_decode($style->post_content); |
|
| 159 | 159 | |
| 160 | - $default_values = $this->get_defaults(); |
|
| 160 | + $default_values = $this->get_defaults(); |
|
| 161 | 161 | |
| 162 | - // fill default values |
|
| 163 | - $style->post_content = $this->override_defaults($style->post_content); |
|
| 164 | - $style->post_content = wp_parse_args( $style->post_content, $default_values); |
|
| 162 | + // fill default values |
|
| 163 | + $style->post_content = $this->override_defaults($style->post_content); |
|
| 164 | + $style->post_content = wp_parse_args( $style->post_content, $default_values); |
|
| 165 | 165 | |
| 166 | - return $style; |
|
| 167 | - } |
|
| 166 | + return $style; |
|
| 167 | + } |
|
| 168 | 168 | |
| 169 | - public function get_all( $orderby = 'title', $order = 'ASC', $limit = 99 ) { |
|
| 170 | - $post_atts = array( |
|
| 169 | + public function get_all( $orderby = 'title', $order = 'ASC', $limit = 99 ) { |
|
| 170 | + $post_atts = array( |
|
| 171 | 171 | 'post_type' => FrmStylesController::$post_type, |
| 172 | 172 | 'post_status' => 'publish', |
| 173 | 173 | 'numberposts' => $limit, |
| 174 | 174 | 'orderby' => $orderby, |
| 175 | 175 | 'order' => $order, |
| 176 | - ); |
|
| 176 | + ); |
|
| 177 | 177 | |
| 178 | - $temp_styles = FrmAppHelper::check_cache(serialize($post_atts), 'frm_styles', $post_atts, 'get_posts'); |
|
| 178 | + $temp_styles = FrmAppHelper::check_cache(serialize($post_atts), 'frm_styles', $post_atts, 'get_posts'); |
|
| 179 | 179 | |
| 180 | - if ( empty($temp_styles) ) { |
|
| 181 | - global $wpdb; |
|
| 182 | - // make sure there wasn't a conflict with the query |
|
| 180 | + if ( empty($temp_styles) ) { |
|
| 181 | + global $wpdb; |
|
| 182 | + // make sure there wasn't a conflict with the query |
|
| 183 | 183 | $query = $wpdb->prepare( 'SELECT * FROM ' . $wpdb->posts . ' WHERE post_type=%s AND post_status=%s ORDER BY post_title ASC LIMIT 99', FrmStylesController::$post_type, 'publish' ); |
| 184 | - $temp_styles = FrmAppHelper::check_cache('frm_backup_style_check', 'frm_styles', $query, 'get_results'); |
|
| 185 | - |
|
| 186 | - if ( empty($temp_styles) ) { |
|
| 187 | - // create a new style if there are none |
|
| 188 | - $new = $this->get_new(); |
|
| 189 | - $new->post_title = $new->post_name = __( 'Formidable Style', 'formidable' ); |
|
| 190 | - $new->menu_order = 1; |
|
| 191 | - $new = $this->save( (array) $new); |
|
| 192 | - $this->update('default'); |
|
| 193 | - |
|
| 194 | - $post_atts['include'] = $new; |
|
| 195 | - |
|
| 196 | - $temp_styles = get_posts( $post_atts ); |
|
| 197 | - } |
|
| 198 | - } |
|
| 199 | - |
|
| 200 | - $default_values = $this->get_defaults(); |
|
| 201 | - $default_style = false; |
|
| 202 | - |
|
| 203 | - $styles = array(); |
|
| 204 | - foreach ( $temp_styles as $style ) { |
|
| 205 | - $this->id = $style->ID; |
|
| 206 | - if ( $style->menu_order ) { |
|
| 207 | - if ( $default_style ) { |
|
| 208 | - // only return one default |
|
| 209 | - $style->menu_order = 0; |
|
| 210 | - } else { |
|
| 211 | - // check for a default style |
|
| 212 | - $default_style = $style->ID; |
|
| 213 | - } |
|
| 214 | - } |
|
| 215 | - |
|
| 216 | - $style->post_content = FrmAppHelper::maybe_json_decode($style->post_content); |
|
| 217 | - |
|
| 218 | - // fill default values |
|
| 219 | - $style->post_content = $this->override_defaults($style->post_content); |
|
| 220 | - $style->post_content = wp_parse_args( $style->post_content, $default_values); |
|
| 184 | + $temp_styles = FrmAppHelper::check_cache('frm_backup_style_check', 'frm_styles', $query, 'get_results'); |
|
| 185 | + |
|
| 186 | + if ( empty($temp_styles) ) { |
|
| 187 | + // create a new style if there are none |
|
| 188 | + $new = $this->get_new(); |
|
| 189 | + $new->post_title = $new->post_name = __( 'Formidable Style', 'formidable' ); |
|
| 190 | + $new->menu_order = 1; |
|
| 191 | + $new = $this->save( (array) $new); |
|
| 192 | + $this->update('default'); |
|
| 193 | + |
|
| 194 | + $post_atts['include'] = $new; |
|
| 195 | + |
|
| 196 | + $temp_styles = get_posts( $post_atts ); |
|
| 197 | + } |
|
| 198 | + } |
|
| 199 | + |
|
| 200 | + $default_values = $this->get_defaults(); |
|
| 201 | + $default_style = false; |
|
| 202 | + |
|
| 203 | + $styles = array(); |
|
| 204 | + foreach ( $temp_styles as $style ) { |
|
| 205 | + $this->id = $style->ID; |
|
| 206 | + if ( $style->menu_order ) { |
|
| 207 | + if ( $default_style ) { |
|
| 208 | + // only return one default |
|
| 209 | + $style->menu_order = 0; |
|
| 210 | + } else { |
|
| 211 | + // check for a default style |
|
| 212 | + $default_style = $style->ID; |
|
| 213 | + } |
|
| 214 | + } |
|
| 215 | + |
|
| 216 | + $style->post_content = FrmAppHelper::maybe_json_decode($style->post_content); |
|
| 217 | + |
|
| 218 | + // fill default values |
|
| 219 | + $style->post_content = $this->override_defaults($style->post_content); |
|
| 220 | + $style->post_content = wp_parse_args( $style->post_content, $default_values); |
|
| 221 | 221 | |
| 222 | 222 | $styles[ $style->ID ] = $style; |
| 223 | - } |
|
| 223 | + } |
|
| 224 | 224 | |
| 225 | - if ( ! $default_style ) { |
|
| 226 | - $default_style = reset($styles); |
|
| 225 | + if ( ! $default_style ) { |
|
| 226 | + $default_style = reset($styles); |
|
| 227 | 227 | $styles[ $default_style->ID ]->menu_order = 1; |
| 228 | - } |
|
| 228 | + } |
|
| 229 | 229 | |
| 230 | - return $styles; |
|
| 231 | - } |
|
| 230 | + return $styles; |
|
| 231 | + } |
|
| 232 | 232 | |
| 233 | 233 | public function get_default_style( $styles = null ) { |
| 234 | - if ( ! isset($styles) ) { |
|
| 234 | + if ( ! isset($styles) ) { |
|
| 235 | 235 | $styles = $this->get_all( 'menu_order', 'DESC', 1 ); |
| 236 | - } |
|
| 236 | + } |
|
| 237 | 237 | |
| 238 | - foreach ( $styles as $style ) { |
|
| 239 | - if ( $style->menu_order ) { |
|
| 240 | - return $style; |
|
| 241 | - } |
|
| 242 | - } |
|
| 243 | - } |
|
| 238 | + foreach ( $styles as $style ) { |
|
| 239 | + if ( $style->menu_order ) { |
|
| 240 | + return $style; |
|
| 241 | + } |
|
| 242 | + } |
|
| 243 | + } |
|
| 244 | 244 | |
| 245 | 245 | public function override_defaults( $settings ) { |
| 246 | - if ( ! is_array($settings) ) { |
|
| 247 | - return $settings; |
|
| 248 | - } |
|
| 249 | - |
|
| 250 | - $settings['line_height'] = ( ! isset($settings['field_height']) || $settings['field_height'] == '' || $settings['field_height'] == 'auto') ? 'normal' : $settings['field_height']; |
|
| 251 | - |
|
| 252 | - if ( ! isset($settings['form_desc_size']) && isset($settings['description_font_size']) ) { |
|
| 253 | - $settings['form_desc_size'] = $settings['description_font_size']; |
|
| 254 | - $settings['form_desc_color'] = $settings['description_color']; |
|
| 255 | - $settings['title_color'] = $settings['label_color']; |
|
| 256 | - } |
|
| 257 | - |
|
| 258 | - if ( ! isset($settings['section_color']) && isset($settings['label_color']) ) { |
|
| 259 | - $settings['section_color'] = $settings['label_color']; |
|
| 260 | - $settings['section_border_color'] = $settings['border_color']; |
|
| 261 | - } |
|
| 262 | - |
|
| 263 | - if ( ! isset($settings['submit_hover_bg_color']) && isset($settings['submit_bg_color']) ) { |
|
| 264 | - $settings['submit_hover_bg_color'] = $settings['submit_bg_color']; |
|
| 265 | - $settings['submit_hover_color'] = $settings['submit_text_color']; |
|
| 266 | - $settings['submit_hover_border_color'] = $settings['submit_border_color']; |
|
| 267 | - |
|
| 268 | - $settings['submit_active_bg_color'] = $settings['submit_bg_color']; |
|
| 269 | - $settings['submit_active_color'] = $settings['submit_text_color']; |
|
| 270 | - $settings['submit_active_border_color'] = $settings['submit_border_color']; |
|
| 271 | - } |
|
| 272 | - |
|
| 273 | - return $settings; |
|
| 246 | + if ( ! is_array($settings) ) { |
|
| 247 | + return $settings; |
|
| 248 | + } |
|
| 249 | + |
|
| 250 | + $settings['line_height'] = ( ! isset($settings['field_height']) || $settings['field_height'] == '' || $settings['field_height'] == 'auto') ? 'normal' : $settings['field_height']; |
|
| 251 | + |
|
| 252 | + if ( ! isset($settings['form_desc_size']) && isset($settings['description_font_size']) ) { |
|
| 253 | + $settings['form_desc_size'] = $settings['description_font_size']; |
|
| 254 | + $settings['form_desc_color'] = $settings['description_color']; |
|
| 255 | + $settings['title_color'] = $settings['label_color']; |
|
| 256 | + } |
|
| 257 | + |
|
| 258 | + if ( ! isset($settings['section_color']) && isset($settings['label_color']) ) { |
|
| 259 | + $settings['section_color'] = $settings['label_color']; |
|
| 260 | + $settings['section_border_color'] = $settings['border_color']; |
|
| 261 | + } |
|
| 262 | + |
|
| 263 | + if ( ! isset($settings['submit_hover_bg_color']) && isset($settings['submit_bg_color']) ) { |
|
| 264 | + $settings['submit_hover_bg_color'] = $settings['submit_bg_color']; |
|
| 265 | + $settings['submit_hover_color'] = $settings['submit_text_color']; |
|
| 266 | + $settings['submit_hover_border_color'] = $settings['submit_border_color']; |
|
| 267 | + |
|
| 268 | + $settings['submit_active_bg_color'] = $settings['submit_bg_color']; |
|
| 269 | + $settings['submit_active_color'] = $settings['submit_text_color']; |
|
| 270 | + $settings['submit_active_border_color'] = $settings['submit_border_color']; |
|
| 271 | + } |
|
| 272 | + |
|
| 273 | + return $settings; |
|
| 274 | 274 | } |
| 275 | 275 | |
| 276 | 276 | public function get_defaults() { |
| 277 | - return array( |
|
| 278 | - 'theme_css' => 'ui-lightness', |
|
| 279 | - 'theme_name' => 'UI Lightness', |
|
| 277 | + return array( |
|
| 278 | + 'theme_css' => 'ui-lightness', |
|
| 279 | + 'theme_name' => 'UI Lightness', |
|
| 280 | 280 | |
| 281 | 281 | 'center_form' => '', |
| 282 | - 'form_width' => '100%', |
|
| 283 | - 'form_align' => 'left', |
|
| 284 | - 'direction' => is_rtl() ? 'rtl' : 'ltr', |
|
| 285 | - 'fieldset' => '0px', |
|
| 286 | - 'fieldset_color' => '000000', |
|
| 287 | - 'fieldset_padding' => '0 0 15px 0', |
|
| 288 | - 'fieldset_bg_color' => '', |
|
| 289 | - |
|
| 290 | - 'title_size' => '20px', |
|
| 291 | - 'title_color' => '444444', |
|
| 282 | + 'form_width' => '100%', |
|
| 283 | + 'form_align' => 'left', |
|
| 284 | + 'direction' => is_rtl() ? 'rtl' : 'ltr', |
|
| 285 | + 'fieldset' => '0px', |
|
| 286 | + 'fieldset_color' => '000000', |
|
| 287 | + 'fieldset_padding' => '0 0 15px 0', |
|
| 288 | + 'fieldset_bg_color' => '', |
|
| 289 | + |
|
| 290 | + 'title_size' => '20px', |
|
| 291 | + 'title_color' => '444444', |
|
| 292 | 292 | 'title_margin_top' => '10px', |
| 293 | 293 | 'title_margin_bottom' => '10px', |
| 294 | - 'form_desc_size' => '14px', |
|
| 295 | - 'form_desc_color' => '666666', |
|
| 294 | + 'form_desc_size' => '14px', |
|
| 295 | + 'form_desc_color' => '666666', |
|
| 296 | 296 | 'form_desc_margin_top' => '10px', |
| 297 | 297 | 'form_desc_margin_bottom' => '25px', |
| 298 | 298 | |
| 299 | - 'font' => '"Lucida Grande","Lucida Sans Unicode",Tahoma,sans-serif', |
|
| 300 | - 'font_size' => '14px', |
|
| 301 | - 'label_color' => '444444', |
|
| 302 | - 'weight' => 'bold', |
|
| 303 | - 'position' => 'none', |
|
| 304 | - 'align' => 'left', |
|
| 305 | - 'width' => '150px', |
|
| 306 | - 'required_color' => 'B94A48', |
|
| 307 | - 'required_weight' => 'bold', |
|
| 308 | - 'label_padding' => '0 0 3px 0', |
|
| 309 | - |
|
| 310 | - 'description_font_size' => '12px', |
|
| 311 | - 'description_color' => '666666', |
|
| 312 | - 'description_weight' => 'normal', |
|
| 313 | - 'description_style' => 'normal', |
|
| 314 | - 'description_align' => 'left', |
|
| 299 | + 'font' => '"Lucida Grande","Lucida Sans Unicode",Tahoma,sans-serif', |
|
| 300 | + 'font_size' => '14px', |
|
| 301 | + 'label_color' => '444444', |
|
| 302 | + 'weight' => 'bold', |
|
| 303 | + 'position' => 'none', |
|
| 304 | + 'align' => 'left', |
|
| 305 | + 'width' => '150px', |
|
| 306 | + 'required_color' => 'B94A48', |
|
| 307 | + 'required_weight' => 'bold', |
|
| 308 | + 'label_padding' => '0 0 3px 0', |
|
| 309 | + |
|
| 310 | + 'description_font_size' => '12px', |
|
| 311 | + 'description_color' => '666666', |
|
| 312 | + 'description_weight' => 'normal', |
|
| 313 | + 'description_style' => 'normal', |
|
| 314 | + 'description_align' => 'left', |
|
| 315 | 315 | 'description_margin' => '0', |
| 316 | 316 | |
| 317 | - 'field_font_size' => '14px', |
|
| 318 | - 'field_height' => '32px', |
|
| 319 | - 'line_height' => 'normal', |
|
| 320 | - 'field_width' => '100%', |
|
| 321 | - 'auto_width' => false, |
|
| 322 | - 'field_pad' => '6px 10px', |
|
| 323 | - 'field_margin' => '20px', |
|
| 317 | + 'field_font_size' => '14px', |
|
| 318 | + 'field_height' => '32px', |
|
| 319 | + 'line_height' => 'normal', |
|
| 320 | + 'field_width' => '100%', |
|
| 321 | + 'auto_width' => false, |
|
| 322 | + 'field_pad' => '6px 10px', |
|
| 323 | + 'field_margin' => '20px', |
|
| 324 | 324 | 'field_weight' => 'normal', |
| 325 | - 'text_color' => '555555', |
|
| 326 | - //'border_color_hv' => 'cccccc', |
|
| 327 | - 'border_color' => 'cccccc', |
|
| 328 | - 'field_border_width' => '1px', |
|
| 329 | - 'field_border_style' => 'solid', |
|
| 330 | - |
|
| 331 | - 'bg_color' => 'ffffff', |
|
| 332 | - //'bg_color_hv' => 'ffffff', |
|
| 325 | + 'text_color' => '555555', |
|
| 326 | + //'border_color_hv' => 'cccccc', |
|
| 327 | + 'border_color' => 'cccccc', |
|
| 328 | + 'field_border_width' => '1px', |
|
| 329 | + 'field_border_style' => 'solid', |
|
| 330 | + |
|
| 331 | + 'bg_color' => 'ffffff', |
|
| 332 | + //'bg_color_hv' => 'ffffff', |
|
| 333 | 333 | 'remove_box_shadow' => '', |
| 334 | - 'bg_color_active' => 'ffffff', |
|
| 334 | + 'bg_color_active' => 'ffffff', |
|
| 335 | 335 | 'border_color_active' => '66afe9', |
| 336 | 336 | 'remove_box_shadow_active' => '', |
| 337 | - 'text_color_error' => '444444', |
|
| 338 | - 'bg_color_error' => 'ffffff', |
|
| 337 | + 'text_color_error' => '444444', |
|
| 338 | + 'bg_color_error' => 'ffffff', |
|
| 339 | 339 | 'border_color_error' => 'B94A48', |
| 340 | 340 | 'border_width_error' => '1px', |
| 341 | 341 | 'border_style_error' => 'solid', |
| 342 | - 'bg_color_disabled' => 'ffffff', |
|
| 343 | - 'border_color_disabled' => 'E5E5E5', |
|
| 344 | - 'text_color_disabled' => 'A1A1A1', |
|
| 345 | - |
|
| 346 | - 'radio_align' => 'block', |
|
| 347 | - 'check_align' => 'block', |
|
| 348 | - 'check_font_size' => '13px', |
|
| 349 | - 'check_label_color' => '444444', |
|
| 350 | - 'check_weight' => 'normal', |
|
| 351 | - |
|
| 352 | - 'section_font_size' => '18px', |
|
| 353 | - 'section_color' => '444444', |
|
| 354 | - 'section_weight' => 'bold', |
|
| 355 | - 'section_pad' => '15px 0 3px 0', |
|
| 356 | - 'section_mar_top' => '15px', |
|
| 342 | + 'bg_color_disabled' => 'ffffff', |
|
| 343 | + 'border_color_disabled' => 'E5E5E5', |
|
| 344 | + 'text_color_disabled' => 'A1A1A1', |
|
| 345 | + |
|
| 346 | + 'radio_align' => 'block', |
|
| 347 | + 'check_align' => 'block', |
|
| 348 | + 'check_font_size' => '13px', |
|
| 349 | + 'check_label_color' => '444444', |
|
| 350 | + 'check_weight' => 'normal', |
|
| 351 | + |
|
| 352 | + 'section_font_size' => '18px', |
|
| 353 | + 'section_color' => '444444', |
|
| 354 | + 'section_weight' => 'bold', |
|
| 355 | + 'section_pad' => '15px 0 3px 0', |
|
| 356 | + 'section_mar_top' => '15px', |
|
| 357 | 357 | 'section_mar_bottom' => '12px', |
| 358 | - 'section_bg_color' => '', |
|
| 359 | - 'section_border_color' => 'e8e8e8', |
|
| 360 | - 'section_border_width' => '2px', |
|
| 361 | - 'section_border_style' => 'solid', |
|
| 362 | - 'section_border_loc' => '-top', |
|
| 363 | - 'collapse_icon' => '6', |
|
| 364 | - 'collapse_pos' => 'after', |
|
| 365 | - 'repeat_icon' => '1', |
|
| 366 | - |
|
| 367 | - 'submit_style' => false, |
|
| 368 | - 'submit_font_size' => '14px', |
|
| 369 | - 'submit_width' => 'auto', |
|
| 370 | - 'submit_height' => 'auto', |
|
| 371 | - 'submit_bg_color' => 'ffffff', |
|
| 372 | - 'submit_border_color' => 'cccccc', |
|
| 373 | - 'submit_border_width' => '1px', |
|
| 374 | - 'submit_text_color' => '444444', |
|
| 375 | - 'submit_weight' => 'normal', |
|
| 376 | - 'submit_border_radius' => '4px', |
|
| 377 | - 'submit_bg_img' => '', |
|
| 378 | - 'submit_margin' => '10px', |
|
| 379 | - 'submit_padding' => '6px 11px', |
|
| 380 | - 'submit_shadow_color' => 'eeeeee', |
|
| 381 | - 'submit_hover_bg_color' => 'efefef', |
|
| 382 | - 'submit_hover_color' => '444444', |
|
| 383 | - 'submit_hover_border_color' => 'cccccc', |
|
| 384 | - 'submit_active_bg_color' => 'efefef', |
|
| 385 | - 'submit_active_color' => '444444', |
|
| 386 | - 'submit_active_border_color' => 'cccccc', |
|
| 387 | - |
|
| 388 | - 'border_radius' => '4px', |
|
| 389 | - 'error_bg' => 'F2DEDE', |
|
| 390 | - 'error_border' => 'EBCCD1', |
|
| 391 | - 'error_text' => 'B94A48', |
|
| 392 | - 'error_font_size' => '14px', |
|
| 393 | - |
|
| 394 | - 'success_bg_color' => 'DFF0D8', |
|
| 395 | - 'success_border_color' => 'D6E9C6', |
|
| 396 | - 'success_text_color' => '468847', |
|
| 397 | - 'success_font_size' => '14px', |
|
| 398 | - |
|
| 399 | - 'important_style' => false, |
|
| 400 | - |
|
| 401 | - 'custom_css' => '', |
|
| 402 | - ); |
|
| 403 | - } |
|
| 358 | + 'section_bg_color' => '', |
|
| 359 | + 'section_border_color' => 'e8e8e8', |
|
| 360 | + 'section_border_width' => '2px', |
|
| 361 | + 'section_border_style' => 'solid', |
|
| 362 | + 'section_border_loc' => '-top', |
|
| 363 | + 'collapse_icon' => '6', |
|
| 364 | + 'collapse_pos' => 'after', |
|
| 365 | + 'repeat_icon' => '1', |
|
| 366 | + |
|
| 367 | + 'submit_style' => false, |
|
| 368 | + 'submit_font_size' => '14px', |
|
| 369 | + 'submit_width' => 'auto', |
|
| 370 | + 'submit_height' => 'auto', |
|
| 371 | + 'submit_bg_color' => 'ffffff', |
|
| 372 | + 'submit_border_color' => 'cccccc', |
|
| 373 | + 'submit_border_width' => '1px', |
|
| 374 | + 'submit_text_color' => '444444', |
|
| 375 | + 'submit_weight' => 'normal', |
|
| 376 | + 'submit_border_radius' => '4px', |
|
| 377 | + 'submit_bg_img' => '', |
|
| 378 | + 'submit_margin' => '10px', |
|
| 379 | + 'submit_padding' => '6px 11px', |
|
| 380 | + 'submit_shadow_color' => 'eeeeee', |
|
| 381 | + 'submit_hover_bg_color' => 'efefef', |
|
| 382 | + 'submit_hover_color' => '444444', |
|
| 383 | + 'submit_hover_border_color' => 'cccccc', |
|
| 384 | + 'submit_active_bg_color' => 'efefef', |
|
| 385 | + 'submit_active_color' => '444444', |
|
| 386 | + 'submit_active_border_color' => 'cccccc', |
|
| 387 | + |
|
| 388 | + 'border_radius' => '4px', |
|
| 389 | + 'error_bg' => 'F2DEDE', |
|
| 390 | + 'error_border' => 'EBCCD1', |
|
| 391 | + 'error_text' => 'B94A48', |
|
| 392 | + 'error_font_size' => '14px', |
|
| 393 | + |
|
| 394 | + 'success_bg_color' => 'DFF0D8', |
|
| 395 | + 'success_border_color' => 'D6E9C6', |
|
| 396 | + 'success_text_color' => '468847', |
|
| 397 | + 'success_font_size' => '14px', |
|
| 398 | + |
|
| 399 | + 'important_style' => false, |
|
| 400 | + |
|
| 401 | + 'custom_css' => '', |
|
| 402 | + ); |
|
| 403 | + } |
|
| 404 | 404 | |
| 405 | 405 | public function get_field_name( $field_name, $post_field = 'post_content' ) { |
| 406 | 406 | return 'frm_style_setting' . ( empty( $post_field ) ? '' : '[' . $post_field . ']' ) . '[' . $field_name . ']'; |
@@ -1,26 +1,26 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | class FrmEntryValidate { |
| 4 | - public static function validate( $values, $exclude = false ) { |
|
| 5 | - global $wpdb; |
|
| 4 | + public static function validate( $values, $exclude = false ) { |
|
| 5 | + global $wpdb; |
|
| 6 | 6 | |
| 7 | - FrmEntry::sanitize_entry_post( $values ); |
|
| 8 | - $errors = array(); |
|
| 7 | + FrmEntry::sanitize_entry_post( $values ); |
|
| 8 | + $errors = array(); |
|
| 9 | 9 | |
| 10 | - if ( ! isset($values['form_id']) || ! isset($values['item_meta']) ) { |
|
| 11 | - $errors['form'] = __( 'There was a problem with your submission. Please try again.', 'formidable' ); |
|
| 12 | - return $errors; |
|
| 13 | - } |
|
| 10 | + if ( ! isset($values['form_id']) || ! isset($values['item_meta']) ) { |
|
| 11 | + $errors['form'] = __( 'There was a problem with your submission. Please try again.', 'formidable' ); |
|
| 12 | + return $errors; |
|
| 13 | + } |
|
| 14 | 14 | |
| 15 | 15 | if ( FrmAppHelper::is_admin() && is_user_logged_in() && ( ! isset( $values[ 'frm_submit_entry_' . $values['form_id'] ] ) || ! wp_verify_nonce( $values[ 'frm_submit_entry_' . $values['form_id'] ], 'frm_submit_entry_nonce' ) ) ) { |
| 16 | - $errors['form'] = __( 'You do not have permission to do that', 'formidable' ); |
|
| 17 | - } |
|
| 16 | + $errors['form'] = __( 'You do not have permission to do that', 'formidable' ); |
|
| 17 | + } |
|
| 18 | 18 | |
| 19 | - if ( ! isset($values['item_key']) || $values['item_key'] == '' ) { |
|
| 19 | + if ( ! isset($values['item_key']) || $values['item_key'] == '' ) { |
|
| 20 | 20 | $_POST['item_key'] = $values['item_key'] = FrmAppHelper::get_unique_key( '', $wpdb->prefix . 'frm_items', 'item_key' ); |
| 21 | - } |
|
| 21 | + } |
|
| 22 | 22 | |
| 23 | - $where = apply_filters('frm_posted_field_ids', array( 'fi.form_id' => $values['form_id'] ) ); |
|
| 23 | + $where = apply_filters('frm_posted_field_ids', array( 'fi.form_id' => $values['form_id'] ) ); |
|
| 24 | 24 | // Don't get subfields |
| 25 | 25 | $where['fr.parent_form_id'] = array( null, 0 ); |
| 26 | 26 | // Don't get excluded fields (like file upload fields in the ajax validation) |
@@ -28,42 +28,42 @@ discard block |
||
| 28 | 28 | $where['fi.type not'] = $exclude; |
| 29 | 29 | } |
| 30 | 30 | |
| 31 | - $posted_fields = FrmField::getAll($where, 'field_order'); |
|
| 31 | + $posted_fields = FrmField::getAll($where, 'field_order'); |
|
| 32 | 32 | |
| 33 | - // Pass exclude value to validate_field function so it can be used for repeating sections |
|
| 34 | - $args = array( 'exclude' => $exclude ); |
|
| 33 | + // Pass exclude value to validate_field function so it can be used for repeating sections |
|
| 34 | + $args = array( 'exclude' => $exclude ); |
|
| 35 | 35 | |
| 36 | - foreach ( $posted_fields as $posted_field ) { |
|
| 37 | - self::validate_field($posted_field, $errors, $values, $args); |
|
| 38 | - unset($posted_field); |
|
| 39 | - } |
|
| 36 | + foreach ( $posted_fields as $posted_field ) { |
|
| 37 | + self::validate_field($posted_field, $errors, $values, $args); |
|
| 38 | + unset($posted_field); |
|
| 39 | + } |
|
| 40 | 40 | |
| 41 | - // check for spam |
|
| 42 | - self::spam_check( $exclude, $values, $errors ); |
|
| 41 | + // check for spam |
|
| 42 | + self::spam_check( $exclude, $values, $errors ); |
|
| 43 | 43 | |
| 44 | - $errors = apply_filters( 'frm_validate_entry', $errors, $values, compact('exclude') ); |
|
| 44 | + $errors = apply_filters( 'frm_validate_entry', $errors, $values, compact('exclude') ); |
|
| 45 | 45 | |
| 46 | - return $errors; |
|
| 47 | - } |
|
| 46 | + return $errors; |
|
| 47 | + } |
|
| 48 | 48 | |
| 49 | - public static function validate_field( $posted_field, &$errors, $values, $args = array() ) { |
|
| 50 | - $defaults = array( |
|
| 51 | - 'id' => $posted_field->id, |
|
| 52 | - 'parent_field_id' => '', // the id of the repeat or embed form |
|
| 53 | - 'key_pointer' => '', // the pointer in the posted array |
|
| 54 | - 'exclude' => array(), // exclude these field types from validation |
|
| 55 | - ); |
|
| 56 | - $args = wp_parse_args( $args, $defaults ); |
|
| 49 | + public static function validate_field( $posted_field, &$errors, $values, $args = array() ) { |
|
| 50 | + $defaults = array( |
|
| 51 | + 'id' => $posted_field->id, |
|
| 52 | + 'parent_field_id' => '', // the id of the repeat or embed form |
|
| 53 | + 'key_pointer' => '', // the pointer in the posted array |
|
| 54 | + 'exclude' => array(), // exclude these field types from validation |
|
| 55 | + ); |
|
| 56 | + $args = wp_parse_args( $args, $defaults ); |
|
| 57 | 57 | |
| 58 | - if ( empty($args['parent_field_id']) ) { |
|
| 58 | + if ( empty($args['parent_field_id']) ) { |
|
| 59 | 59 | $value = isset( $values['item_meta'][ $args['id'] ] ) ? $values['item_meta'][ $args['id'] ] : ''; |
| 60 | - } else { |
|
| 61 | - // value is from a nested form |
|
| 62 | - $value = $values; |
|
| 63 | - } |
|
| 60 | + } else { |
|
| 61 | + // value is from a nested form |
|
| 62 | + $value = $values; |
|
| 63 | + } |
|
| 64 | 64 | |
| 65 | - // Check for values in "Other" fields |
|
| 66 | - FrmEntriesHelper::maybe_set_other_validation( $posted_field, $value, $args ); |
|
| 65 | + // Check for values in "Other" fields |
|
| 66 | + FrmEntriesHelper::maybe_set_other_validation( $posted_field, $value, $args ); |
|
| 67 | 67 | |
| 68 | 68 | self::maybe_clear_value_for_default_blank_setting( $posted_field, $value ); |
| 69 | 69 | |
@@ -72,11 +72,11 @@ discard block |
||
| 72 | 72 | $value = reset($value); |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | - if ( $posted_field->required == '1' && ! is_array( $value ) && trim( $value ) == '' ) { |
|
| 75 | + if ( $posted_field->required == '1' && ! is_array( $value ) && trim( $value ) == '' ) { |
|
| 76 | 76 | $errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $posted_field, 'blank' ); |
| 77 | - } else if ( $posted_field->type == 'text' && ! isset( $_POST['item_name'] ) ) { |
|
| 78 | - $_POST['item_name'] = $value; |
|
| 79 | - } |
|
| 77 | + } else if ( $posted_field->type == 'text' && ! isset( $_POST['item_name'] ) ) { |
|
| 78 | + $_POST['item_name'] = $value; |
|
| 79 | + } |
|
| 80 | 80 | |
| 81 | 81 | if ( $value != '' ) { |
| 82 | 82 | self::validate_url_field( $errors, $posted_field, $value, $args ); |
@@ -85,13 +85,13 @@ discard block |
||
| 85 | 85 | self::validate_phone_field( $errors, $posted_field, $value, $args ); |
| 86 | 86 | } |
| 87 | 87 | |
| 88 | - FrmEntriesHelper::set_posted_value($posted_field, $value, $args); |
|
| 88 | + FrmEntriesHelper::set_posted_value($posted_field, $value, $args); |
|
| 89 | 89 | |
| 90 | - self::validate_recaptcha($errors, $posted_field, $args); |
|
| 90 | + self::validate_recaptcha($errors, $posted_field, $args); |
|
| 91 | 91 | |
| 92 | 92 | $errors = apply_filters( 'frm_validate_' . $posted_field->type . '_field_entry', $errors, $posted_field, $value, $args ); |
| 93 | 93 | $errors = apply_filters( 'frm_validate_field_entry', $errors, $posted_field, $value, $args ); |
| 94 | - } |
|
| 94 | + } |
|
| 95 | 95 | |
| 96 | 96 | private static function maybe_clear_value_for_default_blank_setting( $field, &$value ) { |
| 97 | 97 | if ( FrmField::is_option_true_in_object( $field, 'default_blank' ) && $value == $field->default_value ) { |
@@ -101,32 +101,32 @@ discard block |
||
| 101 | 101 | |
| 102 | 102 | public static function validate_url_field( &$errors, $field, &$value, $args ) { |
| 103 | 103 | if ( $value == '' || ! in_array( $field->type, array( 'website', 'url', 'image' ) ) ) { |
| 104 | - return; |
|
| 105 | - } |
|
| 104 | + return; |
|
| 105 | + } |
|
| 106 | 106 | |
| 107 | - if ( trim($value) == 'http://' ) { |
|
| 108 | - $value = ''; |
|
| 109 | - } else { |
|
| 110 | - $value = esc_url_raw( $value ); |
|
| 107 | + if ( trim($value) == 'http://' ) { |
|
| 108 | + $value = ''; |
|
| 109 | + } else { |
|
| 110 | + $value = esc_url_raw( $value ); |
|
| 111 | 111 | $value = preg_match( '/^(https?|ftps?|mailto|news|feed|telnet):/is', $value ) ? $value : 'http://' . $value; |
| 112 | - } |
|
| 112 | + } |
|
| 113 | 113 | |
| 114 | - //validate the url format |
|
| 115 | - if ( ! preg_match('/^http(s)?:\/\/([\da-z\.-]+)\.([\da-z\.-]+)/i', $value) ) { |
|
| 114 | + //validate the url format |
|
| 115 | + if ( ! preg_match('/^http(s)?:\/\/([\da-z\.-]+)\.([\da-z\.-]+)/i', $value) ) { |
|
| 116 | 116 | $errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $field, 'invalid' ); |
| 117 | - } |
|
| 118 | - } |
|
| 117 | + } |
|
| 118 | + } |
|
| 119 | 119 | |
| 120 | 120 | public static function validate_email_field( &$errors, $field, $value, $args ) { |
| 121 | - if ( $value == '' || $field->type != 'email' ) { |
|
| 122 | - return; |
|
| 123 | - } |
|
| 121 | + if ( $value == '' || $field->type != 'email' ) { |
|
| 122 | + return; |
|
| 123 | + } |
|
| 124 | 124 | |
| 125 | - //validate the email format |
|
| 126 | - if ( ! is_email($value) ) { |
|
| 125 | + //validate the email format |
|
| 126 | + if ( ! is_email($value) ) { |
|
| 127 | 127 | $errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $field, 'invalid' ); |
| 128 | - } |
|
| 129 | - } |
|
| 128 | + } |
|
| 129 | + } |
|
| 130 | 130 | |
| 131 | 131 | public static function validate_number_field( &$errors, $field, $value, $args ) { |
| 132 | 132 | //validate the number format |
@@ -203,9 +203,9 @@ discard block |
||
| 203 | 203 | } |
| 204 | 204 | |
| 205 | 205 | public static function validate_recaptcha( &$errors, $field, $args ) { |
| 206 | - if ( $field->type != 'captcha' || FrmAppHelper::is_admin() || apply_filters( 'frm_is_field_hidden', false, $field, stripslashes_deep( $_POST ) ) ) { |
|
| 207 | - return; |
|
| 208 | - } |
|
| 206 | + if ( $field->type != 'captcha' || FrmAppHelper::is_admin() || apply_filters( 'frm_is_field_hidden', false, $field, stripslashes_deep( $_POST ) ) ) { |
|
| 207 | + return; |
|
| 208 | + } |
|
| 209 | 209 | |
| 210 | 210 | $frm_settings = FrmAppHelper::get_settings(); |
| 211 | 211 | if ( empty( $frm_settings->pubkey ) ) { |
@@ -213,57 +213,57 @@ discard block |
||
| 213 | 213 | return; |
| 214 | 214 | } |
| 215 | 215 | |
| 216 | - if ( ! isset($_POST['g-recaptcha-response']) ) { |
|
| 217 | - // If captcha is missing, check if it was already verified |
|
| 216 | + if ( ! isset($_POST['g-recaptcha-response']) ) { |
|
| 217 | + // If captcha is missing, check if it was already verified |
|
| 218 | 218 | if ( ! isset( $_POST['recaptcha_checked'] ) || ! wp_verify_nonce( $_POST['recaptcha_checked'], 'frm_ajax' ) ) { |
| 219 | - // There was no captcha submitted |
|
| 219 | + // There was no captcha submitted |
|
| 220 | 220 | $errors[ 'field' . $args['id'] ] = __( 'The captcha is missing from this form', 'formidable' ); |
| 221 | - } |
|
| 222 | - return; |
|
| 223 | - } |
|
| 221 | + } |
|
| 222 | + return; |
|
| 223 | + } |
|
| 224 | 224 | |
| 225 | - $arg_array = array( |
|
| 226 | - 'body' => array( |
|
| 225 | + $arg_array = array( |
|
| 226 | + 'body' => array( |
|
| 227 | 227 | 'secret' => $frm_settings->privkey, |
| 228 | 228 | 'response' => $_POST['g-recaptcha-response'], |
| 229 | 229 | 'remoteip' => FrmAppHelper::get_ip_address(), |
| 230 | 230 | ), |
| 231 | 231 | ); |
| 232 | - $resp = wp_remote_post( 'https://www.google.com/recaptcha/api/siteverify', $arg_array ); |
|
| 233 | - $response = json_decode(wp_remote_retrieve_body( $resp ), true); |
|
| 232 | + $resp = wp_remote_post( 'https://www.google.com/recaptcha/api/siteverify', $arg_array ); |
|
| 233 | + $response = json_decode(wp_remote_retrieve_body( $resp ), true); |
|
| 234 | 234 | |
| 235 | - if ( isset( $response['success'] ) && ! $response['success'] ) { |
|
| 236 | - // What happens when the CAPTCHA was entered incorrectly |
|
| 235 | + if ( isset( $response['success'] ) && ! $response['success'] ) { |
|
| 236 | + // What happens when the CAPTCHA was entered incorrectly |
|
| 237 | 237 | $errors[ 'field' . $args['id'] ] = ( ! isset( $field->field_options['invalid'] ) || $field->field_options['invalid'] == '' ) ? $frm_settings->re_msg : $field->field_options['invalid']; |
| 238 | - } else if ( is_wp_error( $resp ) ) { |
|
| 238 | + } else if ( is_wp_error( $resp ) ) { |
|
| 239 | 239 | $error_string = $resp->get_error_message(); |
| 240 | 240 | $errors[ 'field' . $args['id'] ] = __( 'There was a problem verifying your recaptcha', 'formidable' ); |
| 241 | 241 | $errors[ 'field' . $args['id'] ] .= ' ' . $error_string; |
| 242 | - } |
|
| 243 | - } |
|
| 244 | - |
|
| 245 | - /** |
|
| 246 | - * check for spam |
|
| 247 | - * @param boolean $exclude |
|
| 248 | - * @param array $values |
|
| 249 | - * @param array $errors by reference |
|
| 250 | - */ |
|
| 251 | - public static function spam_check( $exclude, $values, &$errors ) { |
|
| 252 | - if ( ! empty( $exclude ) || ! isset( $values['item_meta'] ) || empty( $values['item_meta'] ) || ! empty( $errors ) ) { |
|
| 253 | - // only check spam if there are no other errors |
|
| 254 | - return; |
|
| 255 | - } |
|
| 256 | - |
|
| 257 | - if ( self::is_akismet_spam( $values ) ) { |
|
| 242 | + } |
|
| 243 | + } |
|
| 244 | + |
|
| 245 | + /** |
|
| 246 | + * check for spam |
|
| 247 | + * @param boolean $exclude |
|
| 248 | + * @param array $values |
|
| 249 | + * @param array $errors by reference |
|
| 250 | + */ |
|
| 251 | + public static function spam_check( $exclude, $values, &$errors ) { |
|
| 252 | + if ( ! empty( $exclude ) || ! isset( $values['item_meta'] ) || empty( $values['item_meta'] ) || ! empty( $errors ) ) { |
|
| 253 | + // only check spam if there are no other errors |
|
| 254 | + return; |
|
| 255 | + } |
|
| 256 | + |
|
| 257 | + if ( self::is_akismet_spam( $values ) ) { |
|
| 258 | 258 | if ( self::is_akismet_enabled_for_user( $values['form_id'] ) ) { |
| 259 | 259 | $errors['spam'] = __( 'Your entry appears to be spam!', 'formidable' ); |
| 260 | 260 | } |
| 261 | - } |
|
| 261 | + } |
|
| 262 | 262 | |
| 263 | - if ( self::blacklist_check( $values ) ) { |
|
| 264 | - $errors['spam'] = __( 'Your entry appears to be spam!', 'formidable' ); |
|
| 265 | - } |
|
| 266 | - } |
|
| 263 | + if ( self::blacklist_check( $values ) ) { |
|
| 264 | + $errors['spam'] = __( 'Your entry appears to be spam!', 'formidable' ); |
|
| 265 | + } |
|
| 266 | + } |
|
| 267 | 267 | |
| 268 | 268 | private static function is_akismet_spam( $values ) { |
| 269 | 269 | global $wpcom_api_key; |
@@ -275,54 +275,54 @@ discard block |
||
| 275 | 275 | return ( isset( $form->options['akismet'] ) && ! empty( $form->options['akismet'] ) && ( $form->options['akismet'] != 'logged' || ! is_user_logged_in() ) ); |
| 276 | 276 | } |
| 277 | 277 | |
| 278 | - public static function blacklist_check( $values ) { |
|
| 279 | - if ( ! apply_filters('frm_check_blacklist', true, $values) ) { |
|
| 280 | - return false; |
|
| 281 | - } |
|
| 278 | + public static function blacklist_check( $values ) { |
|
| 279 | + if ( ! apply_filters('frm_check_blacklist', true, $values) ) { |
|
| 280 | + return false; |
|
| 281 | + } |
|
| 282 | 282 | |
| 283 | - $mod_keys = trim( get_option( 'blacklist_keys' ) ); |
|
| 283 | + $mod_keys = trim( get_option( 'blacklist_keys' ) ); |
|
| 284 | 284 | |
| 285 | - if ( empty( $mod_keys ) ) { |
|
| 286 | - return false; |
|
| 287 | - } |
|
| 285 | + if ( empty( $mod_keys ) ) { |
|
| 286 | + return false; |
|
| 287 | + } |
|
| 288 | 288 | |
| 289 | - $content = FrmEntriesHelper::entry_array_to_string($values); |
|
| 289 | + $content = FrmEntriesHelper::entry_array_to_string($values); |
|
| 290 | 290 | |
| 291 | 291 | if ( empty($content) ) { |
| 292 | - return false; |
|
| 292 | + return false; |
|
| 293 | 293 | } |
| 294 | 294 | |
| 295 | - $words = explode( "\n", $mod_keys ); |
|
| 295 | + $words = explode( "\n", $mod_keys ); |
|
| 296 | 296 | |
| 297 | - foreach ( (array) $words as $word ) { |
|
| 298 | - $word = trim( $word ); |
|
| 297 | + foreach ( (array) $words as $word ) { |
|
| 298 | + $word = trim( $word ); |
|
| 299 | 299 | |
| 300 | - if ( empty($word) ) { |
|
| 301 | - continue; |
|
| 302 | - } |
|
| 300 | + if ( empty($word) ) { |
|
| 301 | + continue; |
|
| 302 | + } |
|
| 303 | 303 | |
| 304 | - if ( preg_match('#' . preg_quote( $word, '#' ) . '#', $content) ) { |
|
| 305 | - return true; |
|
| 306 | - } |
|
| 307 | - } |
|
| 304 | + if ( preg_match('#' . preg_quote( $word, '#' ) . '#', $content) ) { |
|
| 305 | + return true; |
|
| 306 | + } |
|
| 307 | + } |
|
| 308 | 308 | |
| 309 | - return false; |
|
| 310 | - } |
|
| 309 | + return false; |
|
| 310 | + } |
|
| 311 | 311 | |
| 312 | - /** |
|
| 313 | - * Check entries for spam |
|
| 314 | - * |
|
| 315 | - * @return boolean true if is spam |
|
| 316 | - */ |
|
| 317 | - public static function akismet( $values ) { |
|
| 318 | - $content = FrmEntriesHelper::entry_array_to_string( $values ); |
|
| 312 | + /** |
|
| 313 | + * Check entries for spam |
|
| 314 | + * |
|
| 315 | + * @return boolean true if is spam |
|
| 316 | + */ |
|
| 317 | + public static function akismet( $values ) { |
|
| 318 | + $content = FrmEntriesHelper::entry_array_to_string( $values ); |
|
| 319 | 319 | |
| 320 | 320 | if ( empty( $content ) ) { |
| 321 | - return false; |
|
| 321 | + return false; |
|
| 322 | 322 | } |
| 323 | 323 | |
| 324 | - $datas = array(); |
|
| 325 | - self::parse_akismet_array( $datas, $content ); |
|
| 324 | + $datas = array(); |
|
| 325 | + self::parse_akismet_array( $datas, $content ); |
|
| 326 | 326 | |
| 327 | 327 | $query_string = ''; |
| 328 | 328 | foreach ( $datas as $key => $data ) { |
@@ -330,35 +330,35 @@ discard block |
||
| 330 | 330 | unset( $key, $data ); |
| 331 | 331 | } |
| 332 | 332 | |
| 333 | - $response = Akismet::http_post($query_string, 'comment-check'); |
|
| 333 | + $response = Akismet::http_post($query_string, 'comment-check'); |
|
| 334 | 334 | |
| 335 | 335 | return ( is_array( $response ) && $response[1] == 'true' ); |
| 336 | - } |
|
| 337 | - |
|
| 338 | - /** |
|
| 339 | - * @since 2.0 |
|
| 340 | - * @param string $content |
|
| 341 | - */ |
|
| 342 | - private static function parse_akismet_array( &$datas, $content ) { |
|
| 343 | - $datas['blog'] = FrmAppHelper::site_url(); |
|
| 344 | - $datas['user_ip'] = preg_replace( '/[^0-9., ]/', '', FrmAppHelper::get_ip_address() ); |
|
| 336 | + } |
|
| 337 | + |
|
| 338 | + /** |
|
| 339 | + * @since 2.0 |
|
| 340 | + * @param string $content |
|
| 341 | + */ |
|
| 342 | + private static function parse_akismet_array( &$datas, $content ) { |
|
| 343 | + $datas['blog'] = FrmAppHelper::site_url(); |
|
| 344 | + $datas['user_ip'] = preg_replace( '/[^0-9., ]/', '', FrmAppHelper::get_ip_address() ); |
|
| 345 | 345 | $datas['user_agent'] = FrmAppHelper::get_server_value( 'HTTP_USER_AGENT' ); |
| 346 | 346 | $datas['referrer'] = isset( $_SERVER['HTTP_REFERER'] ) ? FrmAppHelper::get_server_value( 'HTTP_REFERER' ) : false; |
| 347 | - $datas['comment_type'] = 'formidable'; |
|
| 348 | - $datas['comment_content'] = $content; |
|
| 347 | + $datas['comment_type'] = 'formidable'; |
|
| 348 | + $datas['comment_content'] = $content; |
|
| 349 | 349 | |
| 350 | - if ( $permalink = get_permalink() ) { |
|
| 351 | - $datas['permalink'] = $permalink; |
|
| 352 | - } |
|
| 350 | + if ( $permalink = get_permalink() ) { |
|
| 351 | + $datas['permalink'] = $permalink; |
|
| 352 | + } |
|
| 353 | 353 | |
| 354 | - foreach ( $_SERVER as $key => $value ) { |
|
| 354 | + foreach ( $_SERVER as $key => $value ) { |
|
| 355 | 355 | if ( ! in_array( $key, array( 'HTTP_COOKIE', 'HTTP_COOKIE2', 'PHP_AUTH_PW' ) ) && is_string( $value ) ) { |
| 356 | 356 | $datas[ $key ] = wp_strip_all_tags( $value ); |
| 357 | - } else { |
|
| 357 | + } else { |
|
| 358 | 358 | $datas[ $key ] = ''; |
| 359 | - } |
|
| 359 | + } |
|
| 360 | 360 | |
| 361 | - unset($key, $value); |
|
| 362 | - } |
|
| 363 | - } |
|
| 361 | + unset($key, $value); |
|
| 362 | + } |
|
| 363 | + } |
|
| 364 | 364 | } |
@@ -7,20 +7,20 @@ discard block |
||
| 7 | 7 | FrmEntry::sanitize_entry_post( $values ); |
| 8 | 8 | $errors = array(); |
| 9 | 9 | |
| 10 | - if ( ! isset($values['form_id']) || ! isset($values['item_meta']) ) { |
|
| 10 | + if ( ! isset( $values['form_id'] ) || ! isset( $values['item_meta'] ) ) { |
|
| 11 | 11 | $errors['form'] = __( 'There was a problem with your submission. Please try again.', 'formidable' ); |
| 12 | 12 | return $errors; |
| 13 | 13 | } |
| 14 | 14 | |
| 15 | - if ( FrmAppHelper::is_admin() && is_user_logged_in() && ( ! isset( $values[ 'frm_submit_entry_' . $values['form_id'] ] ) || ! wp_verify_nonce( $values[ 'frm_submit_entry_' . $values['form_id'] ], 'frm_submit_entry_nonce' ) ) ) { |
|
| 15 | + if ( FrmAppHelper::is_admin() && is_user_logged_in() && ( ! isset( $values['frm_submit_entry_' . $values['form_id']] ) || ! wp_verify_nonce( $values['frm_submit_entry_' . $values['form_id']], 'frm_submit_entry_nonce' ) ) ) { |
|
| 16 | 16 | $errors['form'] = __( 'You do not have permission to do that', 'formidable' ); |
| 17 | 17 | } |
| 18 | 18 | |
| 19 | - if ( ! isset($values['item_key']) || $values['item_key'] == '' ) { |
|
| 19 | + if ( ! isset( $values['item_key'] ) || $values['item_key'] == '' ) { |
|
| 20 | 20 | $_POST['item_key'] = $values['item_key'] = FrmAppHelper::get_unique_key( '', $wpdb->prefix . 'frm_items', 'item_key' ); |
| 21 | 21 | } |
| 22 | 22 | |
| 23 | - $where = apply_filters('frm_posted_field_ids', array( 'fi.form_id' => $values['form_id'] ) ); |
|
| 23 | + $where = apply_filters( 'frm_posted_field_ids', array( 'fi.form_id' => $values['form_id'] ) ); |
|
| 24 | 24 | // Don't get subfields |
| 25 | 25 | $where['fr.parent_form_id'] = array( null, 0 ); |
| 26 | 26 | // Don't get excluded fields (like file upload fields in the ajax validation) |
@@ -28,20 +28,20 @@ discard block |
||
| 28 | 28 | $where['fi.type not'] = $exclude; |
| 29 | 29 | } |
| 30 | 30 | |
| 31 | - $posted_fields = FrmField::getAll($where, 'field_order'); |
|
| 31 | + $posted_fields = FrmField::getAll( $where, 'field_order' ); |
|
| 32 | 32 | |
| 33 | 33 | // Pass exclude value to validate_field function so it can be used for repeating sections |
| 34 | 34 | $args = array( 'exclude' => $exclude ); |
| 35 | 35 | |
| 36 | 36 | foreach ( $posted_fields as $posted_field ) { |
| 37 | - self::validate_field($posted_field, $errors, $values, $args); |
|
| 38 | - unset($posted_field); |
|
| 37 | + self::validate_field( $posted_field, $errors, $values, $args ); |
|
| 38 | + unset( $posted_field ); |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | // check for spam |
| 42 | 42 | self::spam_check( $exclude, $values, $errors ); |
| 43 | 43 | |
| 44 | - $errors = apply_filters( 'frm_validate_entry', $errors, $values, compact('exclude') ); |
|
| 44 | + $errors = apply_filters( 'frm_validate_entry', $errors, $values, compact( 'exclude' ) ); |
|
| 45 | 45 | |
| 46 | 46 | return $errors; |
| 47 | 47 | } |
@@ -55,8 +55,8 @@ discard block |
||
| 55 | 55 | ); |
| 56 | 56 | $args = wp_parse_args( $args, $defaults ); |
| 57 | 57 | |
| 58 | - if ( empty($args['parent_field_id']) ) { |
|
| 59 | - $value = isset( $values['item_meta'][ $args['id'] ] ) ? $values['item_meta'][ $args['id'] ] : ''; |
|
| 58 | + if ( empty( $args['parent_field_id'] ) ) { |
|
| 59 | + $value = isset( $values['item_meta'][$args['id']] ) ? $values['item_meta'][$args['id']] : ''; |
|
| 60 | 60 | } else { |
| 61 | 61 | // value is from a nested form |
| 62 | 62 | $value = $values; |
@@ -68,12 +68,12 @@ discard block |
||
| 68 | 68 | self::maybe_clear_value_for_default_blank_setting( $posted_field, $value ); |
| 69 | 69 | |
| 70 | 70 | // Reset arrays with only one value if it's not a field where array keys need to be preserved |
| 71 | - if ( is_array($value) && count( $value ) == 1 && isset( $value[0] ) ) { |
|
| 72 | - $value = reset($value); |
|
| 71 | + if ( is_array( $value ) && count( $value ) == 1 && isset( $value[0] ) ) { |
|
| 72 | + $value = reset( $value ); |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | if ( $posted_field->required == '1' && ! is_array( $value ) && trim( $value ) == '' ) { |
| 76 | - $errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $posted_field, 'blank' ); |
|
| 76 | + $errors['field' . $args['id']] = FrmFieldsHelper::get_error_msg( $posted_field, 'blank' ); |
|
| 77 | 77 | } else if ( $posted_field->type == 'text' && ! isset( $_POST['item_name'] ) ) { |
| 78 | 78 | $_POST['item_name'] = $value; |
| 79 | 79 | } |
@@ -85,9 +85,9 @@ discard block |
||
| 85 | 85 | self::validate_phone_field( $errors, $posted_field, $value, $args ); |
| 86 | 86 | } |
| 87 | 87 | |
| 88 | - FrmEntriesHelper::set_posted_value($posted_field, $value, $args); |
|
| 88 | + FrmEntriesHelper::set_posted_value( $posted_field, $value, $args ); |
|
| 89 | 89 | |
| 90 | - self::validate_recaptcha($errors, $posted_field, $args); |
|
| 90 | + self::validate_recaptcha( $errors, $posted_field, $args ); |
|
| 91 | 91 | |
| 92 | 92 | $errors = apply_filters( 'frm_validate_' . $posted_field->type . '_field_entry', $errors, $posted_field, $value, $args ); |
| 93 | 93 | $errors = apply_filters( 'frm_validate_field_entry', $errors, $posted_field, $value, $args ); |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | return; |
| 105 | 105 | } |
| 106 | 106 | |
| 107 | - if ( trim($value) == 'http://' ) { |
|
| 107 | + if ( trim( $value ) == 'http://' ) { |
|
| 108 | 108 | $value = ''; |
| 109 | 109 | } else { |
| 110 | 110 | $value = esc_url_raw( $value ); |
@@ -112,8 +112,8 @@ discard block |
||
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | //validate the url format |
| 115 | - if ( ! preg_match('/^http(s)?:\/\/([\da-z\.-]+)\.([\da-z\.-]+)/i', $value) ) { |
|
| 116 | - $errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $field, 'invalid' ); |
|
| 115 | + if ( ! preg_match( '/^http(s)?:\/\/([\da-z\.-]+)\.([\da-z\.-]+)/i', $value ) ) { |
|
| 116 | + $errors['field' . $args['id']] = FrmFieldsHelper::get_error_msg( $field, 'invalid' ); |
|
| 117 | 117 | } |
| 118 | 118 | } |
| 119 | 119 | |
@@ -123,8 +123,8 @@ discard block |
||
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | //validate the email format |
| 126 | - if ( ! is_email($value) ) { |
|
| 127 | - $errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $field, 'invalid' ); |
|
| 126 | + if ( ! is_email( $value ) ) { |
|
| 127 | + $errors['field' . $args['id']] = FrmFieldsHelper::get_error_msg( $field, 'invalid' ); |
|
| 128 | 128 | } |
| 129 | 129 | } |
| 130 | 130 | |
@@ -134,8 +134,8 @@ discard block |
||
| 134 | 134 | return; |
| 135 | 135 | } |
| 136 | 136 | |
| 137 | - if ( ! is_numeric( $value) ) { |
|
| 138 | - $errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $field, 'invalid' ); |
|
| 137 | + if ( ! is_numeric( $value ) ) { |
|
| 138 | + $errors['field' . $args['id']] = FrmFieldsHelper::get_error_msg( $field, 'invalid' ); |
|
| 139 | 139 | } |
| 140 | 140 | |
| 141 | 141 | // validate number settings |
@@ -145,9 +145,9 @@ discard block |
||
| 145 | 145 | if ( $frm_settings->use_html && isset( $field->field_options['minnum'] ) && isset( $field->field_options['maxnum'] ) ) { |
| 146 | 146 | //minnum maxnum |
| 147 | 147 | if ( (float) $value < $field->field_options['minnum'] ) { |
| 148 | - $errors[ 'field' . $args['id'] ] = __( 'Please select a higher number', 'formidable' ); |
|
| 148 | + $errors['field' . $args['id']] = __( 'Please select a higher number', 'formidable' ); |
|
| 149 | 149 | } else if ( (float) $value > $field->field_options['maxnum'] ) { |
| 150 | - $errors[ 'field' . $args['id'] ] = __( 'Please select a lower number', 'formidable' ); |
|
| 150 | + $errors['field' . $args['id']] = __( 'Please select a lower number', 'formidable' ); |
|
| 151 | 151 | } |
| 152 | 152 | } |
| 153 | 153 | } |
@@ -161,7 +161,7 @@ discard block |
||
| 161 | 161 | $pattern = self::phone_format( $field ); |
| 162 | 162 | |
| 163 | 163 | if ( ! preg_match( $pattern, $value ) ) { |
| 164 | - $errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $field, 'invalid' ); |
|
| 164 | + $errors['field' . $args['id']] = FrmFieldsHelper::get_error_msg( $field, 'invalid' ); |
|
| 165 | 165 | } |
| 166 | 166 | } |
| 167 | 167 | |
@@ -213,11 +213,11 @@ discard block |
||
| 213 | 213 | return; |
| 214 | 214 | } |
| 215 | 215 | |
| 216 | - if ( ! isset($_POST['g-recaptcha-response']) ) { |
|
| 216 | + if ( ! isset( $_POST['g-recaptcha-response'] ) ) { |
|
| 217 | 217 | // If captcha is missing, check if it was already verified |
| 218 | 218 | if ( ! isset( $_POST['recaptcha_checked'] ) || ! wp_verify_nonce( $_POST['recaptcha_checked'], 'frm_ajax' ) ) { |
| 219 | 219 | // There was no captcha submitted |
| 220 | - $errors[ 'field' . $args['id'] ] = __( 'The captcha is missing from this form', 'formidable' ); |
|
| 220 | + $errors['field' . $args['id']] = __( 'The captcha is missing from this form', 'formidable' ); |
|
| 221 | 221 | } |
| 222 | 222 | return; |
| 223 | 223 | } |
@@ -230,15 +230,15 @@ discard block |
||
| 230 | 230 | ), |
| 231 | 231 | ); |
| 232 | 232 | $resp = wp_remote_post( 'https://www.google.com/recaptcha/api/siteverify', $arg_array ); |
| 233 | - $response = json_decode(wp_remote_retrieve_body( $resp ), true); |
|
| 233 | + $response = json_decode( wp_remote_retrieve_body( $resp ), true ); |
|
| 234 | 234 | |
| 235 | 235 | if ( isset( $response['success'] ) && ! $response['success'] ) { |
| 236 | 236 | // What happens when the CAPTCHA was entered incorrectly |
| 237 | - $errors[ 'field' . $args['id'] ] = ( ! isset( $field->field_options['invalid'] ) || $field->field_options['invalid'] == '' ) ? $frm_settings->re_msg : $field->field_options['invalid']; |
|
| 237 | + $errors['field' . $args['id']] = ( ! isset( $field->field_options['invalid'] ) || $field->field_options['invalid'] == '' ) ? $frm_settings->re_msg : $field->field_options['invalid']; |
|
| 238 | 238 | } else if ( is_wp_error( $resp ) ) { |
| 239 | 239 | $error_string = $resp->get_error_message(); |
| 240 | - $errors[ 'field' . $args['id'] ] = __( 'There was a problem verifying your recaptcha', 'formidable' ); |
|
| 241 | - $errors[ 'field' . $args['id'] ] .= ' ' . $error_string; |
|
| 240 | + $errors['field' . $args['id']] = __( 'There was a problem verifying your recaptcha', 'formidable' ); |
|
| 241 | + $errors['field' . $args['id']] .= ' ' . $error_string; |
|
| 242 | 242 | } |
| 243 | 243 | } |
| 244 | 244 | |
@@ -267,7 +267,7 @@ discard block |
||
| 267 | 267 | |
| 268 | 268 | private static function is_akismet_spam( $values ) { |
| 269 | 269 | global $wpcom_api_key; |
| 270 | - return ( is_callable('Akismet::http_post') && ( get_option('wordpress_api_key') || $wpcom_api_key ) && self::akismet( $values ) ); |
|
| 270 | + return ( is_callable( 'Akismet::http_post' ) && ( get_option( 'wordpress_api_key' ) || $wpcom_api_key ) && self::akismet( $values ) ); |
|
| 271 | 271 | } |
| 272 | 272 | |
| 273 | 273 | private static function is_akismet_enabled_for_user( $form_id ) { |
@@ -276,7 +276,7 @@ discard block |
||
| 276 | 276 | } |
| 277 | 277 | |
| 278 | 278 | public static function blacklist_check( $values ) { |
| 279 | - if ( ! apply_filters('frm_check_blacklist', true, $values) ) { |
|
| 279 | + if ( ! apply_filters( 'frm_check_blacklist', true, $values ) ) { |
|
| 280 | 280 | return false; |
| 281 | 281 | } |
| 282 | 282 | |
@@ -286,9 +286,9 @@ discard block |
||
| 286 | 286 | return false; |
| 287 | 287 | } |
| 288 | 288 | |
| 289 | - $content = FrmEntriesHelper::entry_array_to_string($values); |
|
| 289 | + $content = FrmEntriesHelper::entry_array_to_string( $values ); |
|
| 290 | 290 | |
| 291 | - if ( empty($content) ) { |
|
| 291 | + if ( empty( $content ) ) { |
|
| 292 | 292 | return false; |
| 293 | 293 | } |
| 294 | 294 | |
@@ -297,11 +297,11 @@ discard block |
||
| 297 | 297 | foreach ( (array) $words as $word ) { |
| 298 | 298 | $word = trim( $word ); |
| 299 | 299 | |
| 300 | - if ( empty($word) ) { |
|
| 300 | + if ( empty( $word ) ) { |
|
| 301 | 301 | continue; |
| 302 | 302 | } |
| 303 | 303 | |
| 304 | - if ( preg_match('#' . preg_quote( $word, '#' ) . '#', $content) ) { |
|
| 304 | + if ( preg_match( '#' . preg_quote( $word, '#' ) . '#', $content ) ) { |
|
| 305 | 305 | return true; |
| 306 | 306 | } |
| 307 | 307 | } |
@@ -330,7 +330,7 @@ discard block |
||
| 330 | 330 | unset( $key, $data ); |
| 331 | 331 | } |
| 332 | 332 | |
| 333 | - $response = Akismet::http_post($query_string, 'comment-check'); |
|
| 333 | + $response = Akismet::http_post( $query_string, 'comment-check' ); |
|
| 334 | 334 | |
| 335 | 335 | return ( is_array( $response ) && $response[1] == 'true' ); |
| 336 | 336 | } |
@@ -353,12 +353,12 @@ discard block |
||
| 353 | 353 | |
| 354 | 354 | foreach ( $_SERVER as $key => $value ) { |
| 355 | 355 | if ( ! in_array( $key, array( 'HTTP_COOKIE', 'HTTP_COOKIE2', 'PHP_AUTH_PW' ) ) && is_string( $value ) ) { |
| 356 | - $datas[ $key ] = wp_strip_all_tags( $value ); |
|
| 356 | + $datas[$key] = wp_strip_all_tags( $value ); |
|
| 357 | 357 | } else { |
| 358 | - $datas[ $key ] = ''; |
|
| 358 | + $datas[$key] = ''; |
|
| 359 | 359 | } |
| 360 | 360 | |
| 361 | - unset($key, $value); |
|
| 361 | + unset( $key, $value ); |
|
| 362 | 362 | } |
| 363 | 363 | } |
| 364 | 364 | } |
@@ -18,8 +18,8 @@ discard block |
||
| 18 | 18 | $this->file_name = $atts['file_name']; |
| 19 | 19 | $this->error_message = isset( $atts['error_message'] ) ? $atts['error_message'] : ''; |
| 20 | 20 | $this->uploads = wp_upload_dir(); |
| 21 | - $this->chmod_dir = defined('FS_CHMOD_DIR') ? FS_CHMOD_DIR : ( fileperms( ABSPATH ) & 0777 | 0755 ); |
|
| 22 | - $this->chmod_file = defined('FS_CHMOD_FILE') ? FS_CHMOD_FILE : ( fileperms( ABSPATH . 'index.php' ) & 0777 | 0644 ); |
|
| 21 | + $this->chmod_dir = defined( 'FS_CHMOD_DIR' ) ? FS_CHMOD_DIR : ( fileperms( ABSPATH ) & 0777 | 0755 ); |
|
| 22 | + $this->chmod_file = defined( 'FS_CHMOD_FILE' ) ? FS_CHMOD_FILE : ( fileperms( ABSPATH . 'index.php' ) & 0777 | 0644 ); |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | public function create_file( $file_content ) { |
@@ -85,13 +85,13 @@ discard block |
||
| 85 | 85 | private function get_ftp_creds( $type ) { |
| 86 | 86 | $credentials = get_option( 'ftp_credentials', array( 'hostname' => '', 'username' => '' ) ); |
| 87 | 87 | |
| 88 | - $credentials['hostname'] = defined('FTP_HOST') ? FTP_HOST : $credentials['hostname']; |
|
| 89 | - $credentials['username'] = defined('FTP_USER') ? FTP_USER : $credentials['username']; |
|
| 90 | - $credentials['password'] = defined('FTP_PASS') ? FTP_PASS : ''; |
|
| 88 | + $credentials['hostname'] = defined( 'FTP_HOST' ) ? FTP_HOST : $credentials['hostname']; |
|
| 89 | + $credentials['username'] = defined( 'FTP_USER' ) ? FTP_USER : $credentials['username']; |
|
| 90 | + $credentials['password'] = defined( 'FTP_PASS' ) ? FTP_PASS : ''; |
|
| 91 | 91 | |
| 92 | 92 | // Check to see if we are setting the public/private keys for ssh |
| 93 | - $credentials['public_key'] = defined('FTP_PUBKEY') ? FTP_PUBKEY : ''; |
|
| 94 | - $credentials['private_key'] = defined('FTP_PRIKEY') ? FTP_PRIKEY : ''; |
|
| 93 | + $credentials['public_key'] = defined( 'FTP_PUBKEY' ) ? FTP_PUBKEY : ''; |
|
| 94 | + $credentials['private_key'] = defined( 'FTP_PRIKEY' ) ? FTP_PRIKEY : ''; |
|
| 95 | 95 | |
| 96 | 96 | // Sanitize the hostname, Some people might pass in odd-data: |
| 97 | 97 | $credentials['hostname'] = preg_replace( '|\w+://|', '', $credentials['hostname'] ); //Strip any schemes off |
@@ -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> |
@@ -2,7 +2,7 @@ discard block |
||
| 2 | 2 | |
| 3 | 3 | class FrmFormsController { |
| 4 | 4 | |
| 5 | - public static function menu() { |
|
| 5 | + public static function menu() { |
|
| 6 | 6 | $menu_label = __( 'Forms', 'formidable' ); |
| 7 | 7 | if ( ! FrmAppHelper::pro_is_installed() ) { |
| 8 | 8 | $menu_label .= ' (Lite)'; |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | add_submenu_page('formidable', 'Formidable | ' . $menu_label, $menu_label, 'frm_view_forms', 'formidable', 'FrmFormsController::route' ); |
| 11 | 11 | |
| 12 | 12 | self::maybe_load_listing_hooks(); |
| 13 | - } |
|
| 13 | + } |
|
| 14 | 14 | |
| 15 | 15 | public static function maybe_load_listing_hooks() { |
| 16 | 16 | $action = FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' ); |
@@ -24,128 +24,128 @@ discard block |
||
| 24 | 24 | add_filter('manage_toplevel_page_formidable_sortable_columns', 'FrmFormsController::get_sortable_columns' ); |
| 25 | 25 | } |
| 26 | 26 | |
| 27 | - public static function head() { |
|
| 28 | - wp_enqueue_script('formidable-editinplace'); |
|
| 27 | + public static function head() { |
|
| 28 | + wp_enqueue_script('formidable-editinplace'); |
|
| 29 | 29 | |
| 30 | - if ( wp_is_mobile() ) { |
|
| 31 | - wp_enqueue_script( 'jquery-touch-punch' ); |
|
| 32 | - } |
|
| 33 | - } |
|
| 30 | + if ( wp_is_mobile() ) { |
|
| 31 | + wp_enqueue_script( 'jquery-touch-punch' ); |
|
| 32 | + } |
|
| 33 | + } |
|
| 34 | 34 | |
| 35 | - public static function register_widgets() { |
|
| 36 | - require_once(FrmAppHelper::plugin_path() . '/classes/widgets/FrmShowForm.php'); |
|
| 37 | - register_widget('FrmShowForm'); |
|
| 38 | - } |
|
| 35 | + public static function register_widgets() { |
|
| 36 | + require_once(FrmAppHelper::plugin_path() . '/classes/widgets/FrmShowForm.php'); |
|
| 37 | + register_widget('FrmShowForm'); |
|
| 38 | + } |
|
| 39 | 39 | |
| 40 | - public static function list_form() { |
|
| 41 | - FrmAppHelper::permission_check('frm_view_forms'); |
|
| 40 | + public static function list_form() { |
|
| 41 | + FrmAppHelper::permission_check('frm_view_forms'); |
|
| 42 | 42 | |
| 43 | 43 | $params = FrmForm::list_page_params(); |
| 44 | - $errors = self::process_bulk_form_actions( array()); |
|
| 45 | - $errors = apply_filters('frm_admin_list_form_action', $errors); |
|
| 44 | + $errors = self::process_bulk_form_actions( array()); |
|
| 45 | + $errors = apply_filters('frm_admin_list_form_action', $errors); |
|
| 46 | 46 | |
| 47 | 47 | return self::display_forms_list( $params, '', $errors ); |
| 48 | - } |
|
| 48 | + } |
|
| 49 | 49 | |
| 50 | 50 | public static function new_form( $values = array() ) { |
| 51 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 51 | + FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 52 | 52 | |
| 53 | - global $frm_vars; |
|
| 53 | + global $frm_vars; |
|
| 54 | 54 | |
| 55 | - $action = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action'; |
|
| 55 | + $action = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action'; |
|
| 56 | 56 | $action = empty( $values ) ? FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' ) : $values[ $action ]; |
| 57 | 57 | |
| 58 | 58 | if ( $action == 'create' ) { |
| 59 | - return self::create($values); |
|
| 59 | + return self::create($values); |
|
| 60 | 60 | } else if ( $action == 'new' ) { |
| 61 | 61 | $frm_field_selection = FrmField::field_selection(); |
| 62 | - $values = FrmFormsHelper::setup_new_vars($values); |
|
| 63 | - $id = FrmForm::create( $values ); |
|
| 64 | - $form = FrmForm::getOne($id); |
|
| 62 | + $values = FrmFormsHelper::setup_new_vars($values); |
|
| 63 | + $id = FrmForm::create( $values ); |
|
| 64 | + $form = FrmForm::getOne($id); |
|
| 65 | 65 | |
| 66 | - // add default email notification |
|
| 67 | - $action_control = FrmFormActionsController::get_form_actions( 'email' ); |
|
| 68 | - $action_control->create($form->id); |
|
| 66 | + // add default email notification |
|
| 67 | + $action_control = FrmFormActionsController::get_form_actions( 'email' ); |
|
| 68 | + $action_control->create($form->id); |
|
| 69 | 69 | |
| 70 | 70 | $all_templates = FrmForm::getAll( array( 'is_template' => 1 ), 'name' ); |
| 71 | 71 | |
| 72 | - $values['id'] = $id; |
|
| 72 | + $values['id'] = $id; |
|
| 73 | 73 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/new.php' ); |
| 74 | - } |
|
| 75 | - } |
|
| 74 | + } |
|
| 75 | + } |
|
| 76 | 76 | |
| 77 | 77 | public static function create( $values = array() ) { |
| 78 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 78 | + FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 79 | 79 | |
| 80 | - global $frm_vars; |
|
| 81 | - if ( empty( $values ) ) { |
|
| 82 | - $values = $_POST; |
|
| 83 | - } |
|
| 80 | + global $frm_vars; |
|
| 81 | + if ( empty( $values ) ) { |
|
| 82 | + $values = $_POST; |
|
| 83 | + } |
|
| 84 | 84 | |
| 85 | - //Set radio button and checkbox meta equal to "other" value |
|
| 86 | - if ( FrmAppHelper::pro_is_installed() ) { |
|
| 87 | - $values = FrmProEntry::mod_other_vals( $values, 'back' ); |
|
| 88 | - } |
|
| 85 | + //Set radio button and checkbox meta equal to "other" value |
|
| 86 | + if ( FrmAppHelper::pro_is_installed() ) { |
|
| 87 | + $values = FrmProEntry::mod_other_vals( $values, 'back' ); |
|
| 88 | + } |
|
| 89 | 89 | |
| 90 | 90 | $id = isset($values['id']) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' ); |
| 91 | 91 | |
| 92 | - if ( ! current_user_can( 'frm_edit_forms' ) || ( $_POST && ( ! isset( $values['frm_save_form'] ) || ! wp_verify_nonce( $values['frm_save_form'], 'frm_save_form_nonce' ) ) ) ) { |
|
| 93 | - $frm_settings = FrmAppHelper::get_settings(); |
|
| 94 | - $errors = array( 'form' => $frm_settings->admin_permission ); |
|
| 95 | - } else { |
|
| 96 | - $errors = FrmForm::validate($values); |
|
| 97 | - } |
|
| 92 | + if ( ! current_user_can( 'frm_edit_forms' ) || ( $_POST && ( ! isset( $values['frm_save_form'] ) || ! wp_verify_nonce( $values['frm_save_form'], 'frm_save_form_nonce' ) ) ) ) { |
|
| 93 | + $frm_settings = FrmAppHelper::get_settings(); |
|
| 94 | + $errors = array( 'form' => $frm_settings->admin_permission ); |
|
| 95 | + } else { |
|
| 96 | + $errors = FrmForm::validate($values); |
|
| 97 | + } |
|
| 98 | 98 | |
| 99 | - if ( count($errors) > 0 ) { |
|
| 100 | - $hide_preview = true; |
|
| 99 | + if ( count($errors) > 0 ) { |
|
| 100 | + $hide_preview = true; |
|
| 101 | 101 | $frm_field_selection = FrmField::field_selection(); |
| 102 | - $form = FrmForm::getOne( $id ); |
|
| 103 | - $fields = FrmField::get_all_for_form($id); |
|
| 102 | + $form = FrmForm::getOne( $id ); |
|
| 103 | + $fields = FrmField::get_all_for_form($id); |
|
| 104 | 104 | |
| 105 | - $values = FrmAppHelper::setup_edit_vars($form, 'forms', $fields, true); |
|
| 105 | + $values = FrmAppHelper::setup_edit_vars($form, 'forms', $fields, true); |
|
| 106 | 106 | $all_templates = FrmForm::getAll( array( 'is_template' => 1 ), 'name' ); |
| 107 | 107 | |
| 108 | 108 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/new.php' ); |
| 109 | - } else { |
|
| 110 | - FrmForm::update( $id, $values, true ); |
|
| 109 | + } else { |
|
| 110 | + FrmForm::update( $id, $values, true ); |
|
| 111 | 111 | $url = admin_url( 'admin.php?page=formidable&frm_action=settings&id=' . $id ); |
| 112 | 112 | die( FrmAppHelper::js_redirect( $url ) ); |
| 113 | - } |
|
| 114 | - } |
|
| 113 | + } |
|
| 114 | + } |
|
| 115 | 115 | |
| 116 | - public static function edit( $values = false ) { |
|
| 117 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 116 | + public static function edit( $values = false ) { |
|
| 117 | + FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 118 | 118 | |
| 119 | 119 | $id = isset( $values['id'] ) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' ); |
| 120 | - return self::get_edit_vars($id); |
|
| 121 | - } |
|
| 120 | + return self::get_edit_vars($id); |
|
| 121 | + } |
|
| 122 | 122 | |
| 123 | - public static function settings( $id = false, $message = '' ) { |
|
| 124 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 123 | + public static function settings( $id = false, $message = '' ) { |
|
| 124 | + FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 125 | 125 | |
| 126 | - if ( ! $id || ! is_numeric($id) ) { |
|
| 126 | + if ( ! $id || ! is_numeric($id) ) { |
|
| 127 | 127 | $id = FrmAppHelper::get_param( 'id', '', 'get', 'absint' ); |
| 128 | - } |
|
| 128 | + } |
|
| 129 | 129 | return self::get_settings_vars( $id, array(), $message ); |
| 130 | - } |
|
| 130 | + } |
|
| 131 | 131 | |
| 132 | - public static function update_settings() { |
|
| 133 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 132 | + public static function update_settings() { |
|
| 133 | + FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 134 | 134 | |
| 135 | 135 | $id = FrmAppHelper::get_param( 'id', '', 'get', 'absint' ); |
| 136 | 136 | |
| 137 | - $errors = FrmForm::validate($_POST); |
|
| 138 | - if ( count($errors) > 0 ) { |
|
| 139 | - return self::get_settings_vars($id, $errors); |
|
| 140 | - } |
|
| 137 | + $errors = FrmForm::validate($_POST); |
|
| 138 | + if ( count($errors) > 0 ) { |
|
| 139 | + return self::get_settings_vars($id, $errors); |
|
| 140 | + } |
|
| 141 | 141 | |
| 142 | - do_action('frm_before_update_form_settings', $id); |
|
| 142 | + do_action('frm_before_update_form_settings', $id); |
|
| 143 | 143 | |
| 144 | 144 | FrmForm::update( $id, $_POST ); |
| 145 | 145 | |
| 146 | - $message = __( 'Settings Successfully Updated', 'formidable' ); |
|
| 146 | + $message = __( 'Settings Successfully Updated', 'formidable' ); |
|
| 147 | 147 | return self::get_settings_vars( $id, array(), $message ); |
| 148 | - } |
|
| 148 | + } |
|
| 149 | 149 | |
| 150 | 150 | public static function edit_key() { |
| 151 | 151 | $values = self::edit_in_place_value( 'form_key' ); |
@@ -175,43 +175,43 @@ discard block |
||
| 175 | 175 | |
| 176 | 176 | public static function update( $values = array() ) { |
| 177 | 177 | if ( empty( $values ) ) { |
| 178 | - $values = $_POST; |
|
| 179 | - } |
|
| 178 | + $values = $_POST; |
|
| 179 | + } |
|
| 180 | 180 | |
| 181 | - //Set radio button and checkbox meta equal to "other" value |
|
| 182 | - if ( FrmAppHelper::pro_is_installed() ) { |
|
| 183 | - $values = FrmProEntry::mod_other_vals( $values, 'back' ); |
|
| 184 | - } |
|
| 181 | + //Set radio button and checkbox meta equal to "other" value |
|
| 182 | + if ( FrmAppHelper::pro_is_installed() ) { |
|
| 183 | + $values = FrmProEntry::mod_other_vals( $values, 'back' ); |
|
| 184 | + } |
|
| 185 | 185 | |
| 186 | - $errors = FrmForm::validate( $values ); |
|
| 187 | - $permission_error = FrmAppHelper::permission_nonce_error( 'frm_edit_forms', 'frm_save_form', 'frm_save_form_nonce' ); |
|
| 188 | - if ( $permission_error !== false ) { |
|
| 189 | - $errors['form'] = $permission_error; |
|
| 190 | - } |
|
| 186 | + $errors = FrmForm::validate( $values ); |
|
| 187 | + $permission_error = FrmAppHelper::permission_nonce_error( 'frm_edit_forms', 'frm_save_form', 'frm_save_form_nonce' ); |
|
| 188 | + if ( $permission_error !== false ) { |
|
| 189 | + $errors['form'] = $permission_error; |
|
| 190 | + } |
|
| 191 | 191 | |
| 192 | 192 | $id = isset( $values['id'] ) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' ); |
| 193 | 193 | |
| 194 | 194 | if ( count( $errors ) > 0 ) { |
| 195 | - return self::get_edit_vars( $id, $errors ); |
|
| 195 | + return self::get_edit_vars( $id, $errors ); |
|
| 196 | 196 | } else { |
| 197 | - FrmForm::update( $id, $values ); |
|
| 198 | - $message = __( 'Form was Successfully Updated', 'formidable' ); |
|
| 199 | - if ( defined( 'DOING_AJAX' ) ) { |
|
| 197 | + FrmForm::update( $id, $values ); |
|
| 198 | + $message = __( 'Form was Successfully Updated', 'formidable' ); |
|
| 199 | + if ( defined( 'DOING_AJAX' ) ) { |
|
| 200 | 200 | wp_die( $message ); |
| 201 | - } |
|
| 201 | + } |
|
| 202 | 202 | return self::get_edit_vars( $id, array(), $message ); |
| 203 | - } |
|
| 204 | - } |
|
| 203 | + } |
|
| 204 | + } |
|
| 205 | 205 | |
| 206 | - public static function bulk_create_template( $ids ) { |
|
| 207 | - FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
| 206 | + public static function bulk_create_template( $ids ) { |
|
| 207 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
| 208 | 208 | |
| 209 | - foreach ( $ids as $id ) { |
|
| 210 | - FrmForm::duplicate( $id, true, true ); |
|
| 211 | - } |
|
| 209 | + foreach ( $ids as $id ) { |
|
| 210 | + FrmForm::duplicate( $id, true, true ); |
|
| 211 | + } |
|
| 212 | 212 | |
| 213 | - return __( 'Form template was Successfully Created', 'formidable' ); |
|
| 214 | - } |
|
| 213 | + return __( 'Form template was Successfully Created', 'formidable' ); |
|
| 214 | + } |
|
| 215 | 215 | |
| 216 | 216 | /** |
| 217 | 217 | * Redirect to the url for creating from a template |
@@ -233,45 +233,45 @@ discard block |
||
| 233 | 233 | wp_die(); |
| 234 | 234 | } |
| 235 | 235 | |
| 236 | - public static function duplicate() { |
|
| 237 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 236 | + public static function duplicate() { |
|
| 237 | + FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 238 | 238 | |
| 239 | 239 | $params = FrmForm::list_page_params(); |
| 240 | - $form = FrmForm::duplicate( $params['id'], $params['template'], true ); |
|
| 241 | - $message = ($params['template']) ? __( 'Form template was Successfully Created', 'formidable' ) : __( 'Form was Successfully Copied', 'formidable' ); |
|
| 242 | - if ( $form ) { |
|
| 240 | + $form = FrmForm::duplicate( $params['id'], $params['template'], true ); |
|
| 241 | + $message = ($params['template']) ? __( 'Form template was Successfully Created', 'formidable' ) : __( 'Form was Successfully Copied', 'formidable' ); |
|
| 242 | + if ( $form ) { |
|
| 243 | 243 | return self::get_edit_vars( $form, array(), $message, true ); |
| 244 | - } else { |
|
| 245 | - return self::display_forms_list($params, __( 'There was a problem creating the new template.', 'formidable' )); |
|
| 246 | - } |
|
| 247 | - } |
|
| 244 | + } else { |
|
| 245 | + return self::display_forms_list($params, __( 'There was a problem creating the new template.', 'formidable' )); |
|
| 246 | + } |
|
| 247 | + } |
|
| 248 | 248 | |
| 249 | - public static function page_preview() { |
|
| 249 | + public static function page_preview() { |
|
| 250 | 250 | $params = FrmForm::list_page_params(); |
| 251 | - if ( ! $params['form'] ) { |
|
| 252 | - return; |
|
| 253 | - } |
|
| 254 | - |
|
| 255 | - $form = FrmForm::getOne( $params['form'] ); |
|
| 256 | - if ( ! $form ) { |
|
| 257 | - return; |
|
| 258 | - } |
|
| 259 | - return self::show_form( $form->id, '', true, true ); |
|
| 260 | - } |
|
| 261 | - |
|
| 262 | - public static function preview() { |
|
| 263 | - do_action( 'frm_wp' ); |
|
| 264 | - |
|
| 265 | - global $frm_vars; |
|
| 266 | - $frm_vars['preview'] = true; |
|
| 267 | - |
|
| 268 | - if ( ! defined( 'ABSPATH' ) && ! defined( 'XMLRPC_REQUEST' ) ) { |
|
| 269 | - global $wp; |
|
| 270 | - $root = dirname( dirname( dirname( dirname( __FILE__ ) ) ) ); |
|
| 251 | + if ( ! $params['form'] ) { |
|
| 252 | + return; |
|
| 253 | + } |
|
| 254 | + |
|
| 255 | + $form = FrmForm::getOne( $params['form'] ); |
|
| 256 | + if ( ! $form ) { |
|
| 257 | + return; |
|
| 258 | + } |
|
| 259 | + return self::show_form( $form->id, '', true, true ); |
|
| 260 | + } |
|
| 261 | + |
|
| 262 | + public static function preview() { |
|
| 263 | + do_action( 'frm_wp' ); |
|
| 264 | + |
|
| 265 | + global $frm_vars; |
|
| 266 | + $frm_vars['preview'] = true; |
|
| 267 | + |
|
| 268 | + if ( ! defined( 'ABSPATH' ) && ! defined( 'XMLRPC_REQUEST' ) ) { |
|
| 269 | + global $wp; |
|
| 270 | + $root = dirname( dirname( dirname( dirname( __FILE__ ) ) ) ); |
|
| 271 | 271 | include_once( $root . '/wp-config.php' ); |
| 272 | - $wp->init(); |
|
| 273 | - $wp->register_globals(); |
|
| 274 | - } |
|
| 272 | + $wp->init(); |
|
| 273 | + $wp->register_globals(); |
|
| 274 | + } |
|
| 275 | 275 | |
| 276 | 276 | self::register_pro_scripts(); |
| 277 | 277 | |
@@ -285,11 +285,11 @@ discard block |
||
| 285 | 285 | $form = FrmForm::getAll( array( 'form_key' => $key ), '', 1 ); |
| 286 | 286 | if ( empty( $form ) ) { |
| 287 | 287 | $form = FrmForm::getAll( array(), '', 1 ); |
| 288 | - } |
|
| 288 | + } |
|
| 289 | 289 | |
| 290 | 290 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/direct.php' ); |
| 291 | - wp_die(); |
|
| 292 | - } |
|
| 291 | + wp_die(); |
|
| 292 | + } |
|
| 293 | 293 | |
| 294 | 294 | public static function register_pro_scripts() { |
| 295 | 295 | if ( FrmAppHelper::pro_is_installed() ) { |
@@ -300,22 +300,22 @@ discard block |
||
| 300 | 300 | } |
| 301 | 301 | } |
| 302 | 302 | |
| 303 | - public static function untrash() { |
|
| 303 | + public static function untrash() { |
|
| 304 | 304 | self::change_form_status( 'untrash' ); |
| 305 | - } |
|
| 305 | + } |
|
| 306 | 306 | |
| 307 | 307 | public static function bulk_untrash( $ids ) { |
| 308 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 308 | + FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 309 | 309 | |
| 310 | - $count = FrmForm::set_status( $ids, 'published' ); |
|
| 310 | + $count = FrmForm::set_status( $ids, 'published' ); |
|
| 311 | 311 | |
| 312 | - $message = sprintf(_n( '%1$s form restored from the Trash.', '%1$s forms restored from the Trash.', $count, 'formidable' ), 1 ); |
|
| 313 | - return $message; |
|
| 314 | - } |
|
| 312 | + $message = sprintf(_n( '%1$s form restored from the Trash.', '%1$s forms restored from the Trash.', $count, 'formidable' ), 1 ); |
|
| 313 | + return $message; |
|
| 314 | + } |
|
| 315 | 315 | |
| 316 | - public static function trash() { |
|
| 316 | + public static function trash() { |
|
| 317 | 317 | self::change_form_status( 'trash' ); |
| 318 | - } |
|
| 318 | + } |
|
| 319 | 319 | |
| 320 | 320 | /** |
| 321 | 321 | * @param string $status |
@@ -353,68 +353,68 @@ discard block |
||
| 353 | 353 | } |
| 354 | 354 | |
| 355 | 355 | public static function bulk_trash( $ids ) { |
| 356 | - FrmAppHelper::permission_check('frm_delete_forms'); |
|
| 356 | + FrmAppHelper::permission_check('frm_delete_forms'); |
|
| 357 | 357 | |
| 358 | - $count = 0; |
|
| 359 | - foreach ( $ids as $id ) { |
|
| 360 | - if ( FrmForm::trash( $id ) ) { |
|
| 361 | - $count++; |
|
| 362 | - } |
|
| 363 | - } |
|
| 358 | + $count = 0; |
|
| 359 | + foreach ( $ids as $id ) { |
|
| 360 | + if ( FrmForm::trash( $id ) ) { |
|
| 361 | + $count++; |
|
| 362 | + } |
|
| 363 | + } |
|
| 364 | 364 | |
| 365 | - $current_page = isset( $_REQUEST['form_type'] ) ? $_REQUEST['form_type'] : ''; |
|
| 365 | + $current_page = isset( $_REQUEST['form_type'] ) ? $_REQUEST['form_type'] : ''; |
|
| 366 | 366 | $message = sprintf( _n( '%1$s form moved to the Trash. %2$sUndo%3$s', '%1$s forms moved to the Trash. %2$sUndo%3$s', $count, 'formidable' ), $count, '<a href="' . esc_url( wp_nonce_url( '?page=formidable&frm_action=list&action=bulk_untrash&form_type=' . $current_page . '&item-action=' . implode( ',', $ids ), 'bulk-toplevel_page_formidable' ) ) . '">', '</a>' ); |
| 367 | 367 | |
| 368 | - return $message; |
|
| 369 | - } |
|
| 368 | + return $message; |
|
| 369 | + } |
|
| 370 | 370 | |
| 371 | - public static function destroy() { |
|
| 372 | - FrmAppHelper::permission_check('frm_delete_forms'); |
|
| 371 | + public static function destroy() { |
|
| 372 | + FrmAppHelper::permission_check('frm_delete_forms'); |
|
| 373 | 373 | |
| 374 | 374 | $params = FrmForm::list_page_params(); |
| 375 | 375 | |
| 376 | - //check nonce url |
|
| 377 | - check_admin_referer('destroy_form_' . $params['id']); |
|
| 376 | + //check nonce url |
|
| 377 | + check_admin_referer('destroy_form_' . $params['id']); |
|
| 378 | 378 | |
| 379 | - $count = 0; |
|
| 380 | - if ( FrmForm::destroy( $params['id'] ) ) { |
|
| 381 | - $count++; |
|
| 382 | - } |
|
| 379 | + $count = 0; |
|
| 380 | + if ( FrmForm::destroy( $params['id'] ) ) { |
|
| 381 | + $count++; |
|
| 382 | + } |
|
| 383 | 383 | |
| 384 | - $message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count); |
|
| 384 | + $message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count); |
|
| 385 | 385 | |
| 386 | 386 | self::display_forms_list( $params, $message ); |
| 387 | - } |
|
| 387 | + } |
|
| 388 | 388 | |
| 389 | 389 | public static function bulk_destroy( $ids ) { |
| 390 | - FrmAppHelper::permission_check('frm_delete_forms'); |
|
| 390 | + FrmAppHelper::permission_check('frm_delete_forms'); |
|
| 391 | 391 | |
| 392 | - $count = 0; |
|
| 393 | - foreach ( $ids as $id ) { |
|
| 394 | - $d = FrmForm::destroy( $id ); |
|
| 395 | - if ( $d ) { |
|
| 396 | - $count++; |
|
| 397 | - } |
|
| 398 | - } |
|
| 392 | + $count = 0; |
|
| 393 | + foreach ( $ids as $id ) { |
|
| 394 | + $d = FrmForm::destroy( $id ); |
|
| 395 | + if ( $d ) { |
|
| 396 | + $count++; |
|
| 397 | + } |
|
| 398 | + } |
|
| 399 | 399 | |
| 400 | - $message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count); |
|
| 400 | + $message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count); |
|
| 401 | 401 | |
| 402 | - return $message; |
|
| 403 | - } |
|
| 402 | + return $message; |
|
| 403 | + } |
|
| 404 | 404 | |
| 405 | - private static function delete_all() { |
|
| 406 | - //check nonce url |
|
| 407 | - $permission_error = FrmAppHelper::permission_nonce_error('frm_delete_forms', '_wpnonce', 'bulk-toplevel_page_formidable'); |
|
| 408 | - if ( $permission_error !== false ) { |
|
| 405 | + private static function delete_all() { |
|
| 406 | + //check nonce url |
|
| 407 | + $permission_error = FrmAppHelper::permission_nonce_error('frm_delete_forms', '_wpnonce', 'bulk-toplevel_page_formidable'); |
|
| 408 | + if ( $permission_error !== false ) { |
|
| 409 | 409 | self::display_forms_list( array(), '', array( $permission_error ) ); |
| 410 | - return; |
|
| 411 | - } |
|
| 410 | + return; |
|
| 411 | + } |
|
| 412 | 412 | |
| 413 | 413 | $count = FrmForm::scheduled_delete( time() ); |
| 414 | - $message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count); |
|
| 414 | + $message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count); |
|
| 415 | 415 | |
| 416 | 416 | self::display_forms_list( array(), $message ); |
| 417 | - } |
|
| 417 | + } |
|
| 418 | 418 | |
| 419 | 419 | public static function scheduled_delete( $delete_timestamp = '' ) { |
| 420 | 420 | _deprecated_function( __FUNCTION__, '2.0.9', 'FrmForm::scheduled_delete' ); |
@@ -422,11 +422,11 @@ discard block |
||
| 422 | 422 | } |
| 423 | 423 | |
| 424 | 424 | /** |
| 425 | - * Inserts Formidable button |
|
| 426 | - * Hook exists since 2.5.0 |
|
| 427 | - * |
|
| 428 | - * @since 2.0.15 |
|
| 429 | - */ |
|
| 425 | + * Inserts Formidable button |
|
| 426 | + * Hook exists since 2.5.0 |
|
| 427 | + * |
|
| 428 | + * @since 2.0.15 |
|
| 429 | + */ |
|
| 430 | 430 | public static function insert_form_button() { |
| 431 | 431 | if ( current_user_can('frm_view_forms') ) { |
| 432 | 432 | $menu_name = FrmAppHelper::get_menu_name(); |
@@ -437,49 +437,49 @@ discard block |
||
| 437 | 437 | } |
| 438 | 438 | } |
| 439 | 439 | |
| 440 | - public static function insert_form_popup() { |
|
| 440 | + public static function insert_form_popup() { |
|
| 441 | 441 | $page = basename( FrmAppHelper::get_server_value( 'PHP_SELF' ) ); |
| 442 | 442 | if ( ! in_array( $page, array( 'post.php', 'page.php', 'page-new.php', 'post-new.php' ) ) ) { |
| 443 | - return; |
|
| 444 | - } |
|
| 443 | + return; |
|
| 444 | + } |
|
| 445 | 445 | |
| 446 | - FrmAppHelper::load_admin_wide_js(); |
|
| 446 | + FrmAppHelper::load_admin_wide_js(); |
|
| 447 | 447 | |
| 448 | - $shortcodes = array( |
|
| 448 | + $shortcodes = array( |
|
| 449 | 449 | 'formidable' => array( 'name' => __( 'Form', 'formidable' ), 'label' => __( 'Insert a Form', 'formidable' ) ), |
| 450 | - ); |
|
| 450 | + ); |
|
| 451 | 451 | |
| 452 | - $shortcodes = apply_filters('frm_popup_shortcodes', $shortcodes); |
|
| 452 | + $shortcodes = apply_filters('frm_popup_shortcodes', $shortcodes); |
|
| 453 | 453 | |
| 454 | 454 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/insert_form_popup.php' ); |
| 455 | - } |
|
| 455 | + } |
|
| 456 | 456 | |
| 457 | - public static function get_shortcode_opts() { |
|
| 457 | + public static function get_shortcode_opts() { |
|
| 458 | 458 | FrmAppHelper::permission_check('frm_view_forms'); |
| 459 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 459 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 460 | 460 | |
| 461 | 461 | $shortcode = FrmAppHelper::get_post_param( 'shortcode', '', 'sanitize_text_field' ); |
| 462 | - if ( empty($shortcode) ) { |
|
| 463 | - wp_die(); |
|
| 464 | - } |
|
| 462 | + if ( empty($shortcode) ) { |
|
| 463 | + wp_die(); |
|
| 464 | + } |
|
| 465 | 465 | |
| 466 | 466 | echo '<div id="sc-opts-' . esc_attr( $shortcode ) . '" class="frm_shortcode_option">'; |
| 467 | 467 | echo '<input type="radio" name="frmsc" value="' . esc_attr( $shortcode ) . '" id="sc-' . esc_attr( $shortcode ) . '" class="frm_hidden" />'; |
| 468 | 468 | |
| 469 | - $form_id = ''; |
|
| 470 | - $opts = array(); |
|
| 469 | + $form_id = ''; |
|
| 470 | + $opts = array(); |
|
| 471 | 471 | switch ( $shortcode ) { |
| 472 | - case 'formidable': |
|
| 473 | - $opts = array( |
|
| 472 | + case 'formidable': |
|
| 473 | + $opts = array( |
|
| 474 | 474 | 'form_id' => 'id', |
| 475 | - //'key' => ', |
|
| 475 | + //'key' => ', |
|
| 476 | 476 | 'title' => array( 'val' => 1, 'label' => __( 'Display form title', 'formidable' ) ), |
| 477 | 477 | 'description' => array( 'val' => 1, 'label' => __( 'Display form description', 'formidable' ) ), |
| 478 | 478 | 'minimize' => array( 'val' => 1, 'label' => __( 'Minimize form HTML', 'formidable' ) ), |
| 479 | - ); |
|
| 480 | - break; |
|
| 481 | - } |
|
| 482 | - $opts = apply_filters('frm_sc_popup_opts', $opts, $shortcode); |
|
| 479 | + ); |
|
| 480 | + break; |
|
| 481 | + } |
|
| 482 | + $opts = apply_filters('frm_sc_popup_opts', $opts, $shortcode); |
|
| 483 | 483 | |
| 484 | 484 | if ( isset( $opts['form_id'] ) && is_string( $opts['form_id'] ) ) { |
| 485 | 485 | // allow other shortcodes to use the required form id option |
@@ -489,61 +489,61 @@ discard block |
||
| 489 | 489 | |
| 490 | 490 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/shortcode_opts.php' ); |
| 491 | 491 | |
| 492 | - echo '</div>'; |
|
| 492 | + echo '</div>'; |
|
| 493 | 493 | |
| 494 | - wp_die(); |
|
| 495 | - } |
|
| 494 | + wp_die(); |
|
| 495 | + } |
|
| 496 | 496 | |
| 497 | 497 | public static function display_forms_list( $params = array(), $message = '', $errors = array(), $deprecated_errors = array() ) { |
| 498 | - FrmAppHelper::permission_check( 'frm_view_forms' ); |
|
| 498 | + FrmAppHelper::permission_check( 'frm_view_forms' ); |
|
| 499 | 499 | if ( ! empty( $deprecated_errors ) ) { |
| 500 | 500 | $errors = $deprecated_errors; |
| 501 | 501 | _deprecated_argument( 'errors', '2.0.8' ); |
| 502 | 502 | } |
| 503 | 503 | |
| 504 | - global $wpdb, $frm_vars; |
|
| 504 | + global $wpdb, $frm_vars; |
|
| 505 | 505 | |
| 506 | 506 | if ( empty( $params ) ) { |
| 507 | 507 | $params = FrmForm::list_page_params(); |
| 508 | - } |
|
| 508 | + } |
|
| 509 | 509 | |
| 510 | - $wp_list_table = new FrmFormsListHelper( compact( 'params' ) ); |
|
| 510 | + $wp_list_table = new FrmFormsListHelper( compact( 'params' ) ); |
|
| 511 | 511 | |
| 512 | - $pagenum = $wp_list_table->get_pagenum(); |
|
| 512 | + $pagenum = $wp_list_table->get_pagenum(); |
|
| 513 | 513 | |
| 514 | - $wp_list_table->prepare_items(); |
|
| 514 | + $wp_list_table->prepare_items(); |
|
| 515 | 515 | |
| 516 | - $total_pages = $wp_list_table->get_pagination_arg( 'total_pages' ); |
|
| 517 | - if ( $pagenum > $total_pages && $total_pages > 0 ) { |
|
| 516 | + $total_pages = $wp_list_table->get_pagination_arg( 'total_pages' ); |
|
| 517 | + if ( $pagenum > $total_pages && $total_pages > 0 ) { |
|
| 518 | 518 | wp_redirect( esc_url_raw( add_query_arg( 'paged', $total_pages ) ) ); |
| 519 | - die(); |
|
| 520 | - } |
|
| 519 | + die(); |
|
| 520 | + } |
|
| 521 | 521 | |
| 522 | 522 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/list.php' ); |
| 523 | - } |
|
| 523 | + } |
|
| 524 | 524 | |
| 525 | 525 | public static function get_columns( $columns ) { |
| 526 | - $columns['cb'] = '<input type="checkbox" />'; |
|
| 527 | - $columns['id'] = 'ID'; |
|
| 526 | + $columns['cb'] = '<input type="checkbox" />'; |
|
| 527 | + $columns['id'] = 'ID'; |
|
| 528 | 528 | |
| 529 | - $type = isset( $_REQUEST['form_type'] ) ? $_REQUEST['form_type'] : 'published'; |
|
| 529 | + $type = isset( $_REQUEST['form_type'] ) ? $_REQUEST['form_type'] : 'published'; |
|
| 530 | 530 | |
| 531 | - if ( 'template' == $type ) { |
|
| 532 | - $columns['name'] = __( 'Template Name', 'formidable' ); |
|
| 533 | - $columns['type'] = __( 'Type', 'formidable' ); |
|
| 534 | - $columns['form_key'] = __( 'Key', 'formidable' ); |
|
| 535 | - } else { |
|
| 536 | - $columns['name'] = __( 'Form Title', 'formidable' ); |
|
| 537 | - $columns['entries'] = __( 'Entries', 'formidable' ); |
|
| 538 | - $columns['form_key'] = __( 'Key', 'formidable' ); |
|
| 539 | - $columns['shortcode'] = __( 'Shortcodes', 'formidable' ); |
|
| 540 | - } |
|
| 531 | + if ( 'template' == $type ) { |
|
| 532 | + $columns['name'] = __( 'Template Name', 'formidable' ); |
|
| 533 | + $columns['type'] = __( 'Type', 'formidable' ); |
|
| 534 | + $columns['form_key'] = __( 'Key', 'formidable' ); |
|
| 535 | + } else { |
|
| 536 | + $columns['name'] = __( 'Form Title', 'formidable' ); |
|
| 537 | + $columns['entries'] = __( 'Entries', 'formidable' ); |
|
| 538 | + $columns['form_key'] = __( 'Key', 'formidable' ); |
|
| 539 | + $columns['shortcode'] = __( 'Shortcodes', 'formidable' ); |
|
| 540 | + } |
|
| 541 | 541 | |
| 542 | - $columns['created_at'] = __( 'Date', 'formidable' ); |
|
| 542 | + $columns['created_at'] = __( 'Date', 'formidable' ); |
|
| 543 | 543 | |
| 544 | 544 | add_screen_option( 'per_page', array( 'label' => __( 'Forms', 'formidable' ), 'default' => 20, 'option' => 'formidable_page_formidable_per_page' ) ); |
| 545 | 545 | |
| 546 | - return $columns; |
|
| 546 | + return $columns; |
|
| 547 | 547 | } |
| 548 | 548 | |
| 549 | 549 | public static function get_sortable_columns() { |
@@ -557,111 +557,111 @@ discard block |
||
| 557 | 557 | } |
| 558 | 558 | |
| 559 | 559 | public static function hidden_columns( $result ) { |
| 560 | - $return = false; |
|
| 561 | - foreach ( (array) $result as $r ) { |
|
| 562 | - if ( ! empty( $r ) ) { |
|
| 563 | - $return = true; |
|
| 564 | - break; |
|
| 565 | - } |
|
| 566 | - } |
|
| 560 | + $return = false; |
|
| 561 | + foreach ( (array) $result as $r ) { |
|
| 562 | + if ( ! empty( $r ) ) { |
|
| 563 | + $return = true; |
|
| 564 | + break; |
|
| 565 | + } |
|
| 566 | + } |
|
| 567 | 567 | |
| 568 | - if ( $return ) { |
|
| 569 | - return $result; |
|
| 568 | + if ( $return ) { |
|
| 569 | + return $result; |
|
| 570 | 570 | } |
| 571 | 571 | |
| 572 | - $type = isset( $_REQUEST['form_type'] ) ? $_REQUEST['form_type'] : ''; |
|
| 572 | + $type = isset( $_REQUEST['form_type'] ) ? $_REQUEST['form_type'] : ''; |
|
| 573 | 573 | |
| 574 | - $result[] = 'created_at'; |
|
| 575 | - if ( $type == 'template' ) { |
|
| 576 | - $result[] = 'id'; |
|
| 577 | - $result[] = 'form_key'; |
|
| 578 | - } |
|
| 574 | + $result[] = 'created_at'; |
|
| 575 | + if ( $type == 'template' ) { |
|
| 576 | + $result[] = 'id'; |
|
| 577 | + $result[] = 'form_key'; |
|
| 578 | + } |
|
| 579 | 579 | |
| 580 | - return $result; |
|
| 581 | - } |
|
| 580 | + return $result; |
|
| 581 | + } |
|
| 582 | 582 | |
| 583 | 583 | public static function save_per_page( $save, $option, $value ) { |
| 584 | - if ( $option == 'formidable_page_formidable_per_page' ) { |
|
| 585 | - $save = (int) $value; |
|
| 586 | - } |
|
| 587 | - return $save; |
|
| 588 | - } |
|
| 584 | + if ( $option == 'formidable_page_formidable_per_page' ) { |
|
| 585 | + $save = (int) $value; |
|
| 586 | + } |
|
| 587 | + return $save; |
|
| 588 | + } |
|
| 589 | 589 | |
| 590 | 590 | private static function get_edit_vars( $id, $errors = array(), $message = '', $create_link = false ) { |
| 591 | - global $frm_vars; |
|
| 591 | + global $frm_vars; |
|
| 592 | 592 | |
| 593 | - $form = FrmForm::getOne( $id ); |
|
| 594 | - if ( ! $form ) { |
|
| 595 | - wp_die( __( 'You are trying to edit a form that does not exist.', 'formidable' ) ); |
|
| 596 | - } |
|
| 593 | + $form = FrmForm::getOne( $id ); |
|
| 594 | + if ( ! $form ) { |
|
| 595 | + wp_die( __( 'You are trying to edit a form that does not exist.', 'formidable' ) ); |
|
| 596 | + } |
|
| 597 | 597 | |
| 598 | - if ( $form->parent_form_id ) { |
|
| 598 | + if ( $form->parent_form_id ) { |
|
| 599 | 599 | wp_die( sprintf( __( 'You are trying to edit a child form. Please edit from %1$shere%2$s', 'formidable' ), '<a href="' . esc_url( admin_url( 'admin.php?page=formidable&frm_action=edit&id=' . $form->parent_form_id ) ) . '">', '</a>' )); |
| 600 | - } |
|
| 600 | + } |
|
| 601 | 601 | |
| 602 | 602 | $frm_field_selection = FrmField::field_selection(); |
| 603 | - $fields = FrmField::get_all_for_form($form->id); |
|
| 603 | + $fields = FrmField::get_all_for_form($form->id); |
|
| 604 | 604 | |
| 605 | - // Automatically add end section fields if they don't exist (2.0 migration) |
|
| 606 | - $reset_fields = false; |
|
| 607 | - FrmFormsHelper::auto_add_end_section_fields( $form, $fields, $reset_fields ); |
|
| 605 | + // Automatically add end section fields if they don't exist (2.0 migration) |
|
| 606 | + $reset_fields = false; |
|
| 607 | + FrmFormsHelper::auto_add_end_section_fields( $form, $fields, $reset_fields ); |
|
| 608 | 608 | |
| 609 | - if ( $reset_fields ) { |
|
| 610 | - $fields = FrmField::get_all_for_form( $form->id, '', 'exclude' ); |
|
| 611 | - } |
|
| 609 | + if ( $reset_fields ) { |
|
| 610 | + $fields = FrmField::get_all_for_form( $form->id, '', 'exclude' ); |
|
| 611 | + } |
|
| 612 | 612 | |
| 613 | - unset($end_section_values, $last_order, $open, $reset_fields); |
|
| 613 | + unset($end_section_values, $last_order, $open, $reset_fields); |
|
| 614 | 614 | |
| 615 | 615 | $args = array( 'parent_form_id' => $form->id ); |
| 616 | - $values = FrmAppHelper::setup_edit_vars( $form, 'forms', $fields, true, array(), $args ); |
|
| 616 | + $values = FrmAppHelper::setup_edit_vars( $form, 'forms', $fields, true, array(), $args ); |
|
| 617 | 617 | |
| 618 | - $edit_message = __( 'Form was Successfully Updated', 'formidable' ); |
|
| 619 | - if ( $form->is_template && $message == $edit_message ) { |
|
| 620 | - $message = __( 'Template was Successfully Updated', 'formidable' ); |
|
| 621 | - } |
|
| 618 | + $edit_message = __( 'Form was Successfully Updated', 'formidable' ); |
|
| 619 | + if ( $form->is_template && $message == $edit_message ) { |
|
| 620 | + $message = __( 'Template was Successfully Updated', 'formidable' ); |
|
| 621 | + } |
|
| 622 | 622 | |
| 623 | 623 | $all_templates = FrmForm::getAll( array( 'is_template' => 1 ), 'name' ); |
| 624 | 624 | |
| 625 | - if ( $form->default_template ) { |
|
| 626 | - wp_die(__( 'That template cannot be edited', 'formidable' )); |
|
| 627 | - } else if ( defined('DOING_AJAX') ) { |
|
| 628 | - wp_die(); |
|
| 629 | - } else if ( $create_link ) { |
|
| 625 | + if ( $form->default_template ) { |
|
| 626 | + wp_die(__( 'That template cannot be edited', 'formidable' )); |
|
| 627 | + } else if ( defined('DOING_AJAX') ) { |
|
| 628 | + wp_die(); |
|
| 629 | + } else if ( $create_link ) { |
|
| 630 | 630 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/new.php' ); |
| 631 | - } else { |
|
| 631 | + } else { |
|
| 632 | 632 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/edit.php' ); |
| 633 | - } |
|
| 634 | - } |
|
| 633 | + } |
|
| 634 | + } |
|
| 635 | 635 | |
| 636 | 636 | public static function get_settings_vars( $id, $errors = array(), $message = '' ) { |
| 637 | 637 | FrmAppHelper::permission_check( 'frm_edit_forms' ); |
| 638 | 638 | |
| 639 | - global $frm_vars; |
|
| 639 | + global $frm_vars; |
|
| 640 | 640 | |
| 641 | - $form = FrmForm::getOne( $id ); |
|
| 641 | + $form = FrmForm::getOne( $id ); |
|
| 642 | 642 | |
| 643 | - $fields = FrmField::get_all_for_form($id); |
|
| 644 | - $values = FrmAppHelper::setup_edit_vars($form, 'forms', $fields, true); |
|
| 643 | + $fields = FrmField::get_all_for_form($id); |
|
| 644 | + $values = FrmAppHelper::setup_edit_vars($form, 'forms', $fields, true); |
|
| 645 | 645 | |
| 646 | - if ( isset($values['default_template']) && $values['default_template'] ) { |
|
| 647 | - wp_die(__( 'That template cannot be edited', 'formidable' )); |
|
| 648 | - } |
|
| 646 | + if ( isset($values['default_template']) && $values['default_template'] ) { |
|
| 647 | + wp_die(__( 'That template cannot be edited', 'formidable' )); |
|
| 648 | + } |
|
| 649 | 649 | |
| 650 | - $action_controls = FrmFormActionsController::get_form_actions(); |
|
| 650 | + $action_controls = FrmFormActionsController::get_form_actions(); |
|
| 651 | 651 | |
| 652 | - $sections = apply_filters('frm_add_form_settings_section', array(), $values); |
|
| 653 | - $pro_feature = FrmAppHelper::pro_is_installed() ? '' : ' class="pro_feature"'; |
|
| 652 | + $sections = apply_filters('frm_add_form_settings_section', array(), $values); |
|
| 653 | + $pro_feature = FrmAppHelper::pro_is_installed() ? '' : ' class="pro_feature"'; |
|
| 654 | 654 | |
| 655 | - $styles = apply_filters('frm_get_style_opts', array()); |
|
| 655 | + $styles = apply_filters('frm_get_style_opts', array()); |
|
| 656 | 656 | |
| 657 | 657 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/settings.php' ); |
| 658 | - } |
|
| 658 | + } |
|
| 659 | 659 | |
| 660 | - public static function mb_tags_box( $form_id, $class = '' ) { |
|
| 661 | - $fields = FrmField::get_all_for_form($form_id, '', 'include'); |
|
| 662 | - $linked_forms = array(); |
|
| 663 | - $col = 'one'; |
|
| 664 | - $settings_tab = FrmAppHelper::is_admin_page('formidable' ) ? true : false; |
|
| 660 | + public static function mb_tags_box( $form_id, $class = '' ) { |
|
| 661 | + $fields = FrmField::get_all_for_form($form_id, '', 'include'); |
|
| 662 | + $linked_forms = array(); |
|
| 663 | + $col = 'one'; |
|
| 664 | + $settings_tab = FrmAppHelper::is_admin_page('formidable' ) ? true : false; |
|
| 665 | 665 | |
| 666 | 666 | $cond_shortcodes = apply_filters( 'frm_conditional_shortcodes', array() ); |
| 667 | 667 | $adv_shortcodes = self::get_advanced_shortcodes(); |
@@ -669,7 +669,7 @@ discard block |
||
| 669 | 669 | $entry_shortcodes = self::get_shortcode_helpers( $settings_tab ); |
| 670 | 670 | |
| 671 | 671 | include( FrmAppHelper::plugin_path() . '/classes/views/shared/mb_adv_info.php' ); |
| 672 | - } |
|
| 672 | + } |
|
| 673 | 673 | |
| 674 | 674 | /** |
| 675 | 675 | * Get an array of the options to display in the advanced tab |
@@ -710,7 +710,7 @@ discard block |
||
| 710 | 710 | '' => '', |
| 711 | 711 | 'siteurl' => __( 'Site URL', 'formidable' ), |
| 712 | 712 | 'sitename' => __( 'Site Name', 'formidable' ), |
| 713 | - ); |
|
| 713 | + ); |
|
| 714 | 714 | |
| 715 | 715 | if ( ! FrmAppHelper::pro_is_installed() ) { |
| 716 | 716 | unset( $entry_shortcodes['post_id'] ); |
@@ -737,39 +737,39 @@ discard block |
||
| 737 | 737 | return $entry_shortcodes; |
| 738 | 738 | } |
| 739 | 739 | |
| 740 | - // Insert the form class setting into the form |
|
| 740 | + // Insert the form class setting into the form |
|
| 741 | 741 | public static function form_classes( $form ) { |
| 742 | - if ( isset($form->options['form_class']) ) { |
|
| 742 | + if ( isset($form->options['form_class']) ) { |
|
| 743 | 743 | echo esc_attr( sanitize_text_field( $form->options['form_class'] ) ); |
| 744 | - } |
|
| 745 | - } |
|
| 744 | + } |
|
| 745 | + } |
|
| 746 | 746 | |
| 747 | - public static function get_email_html() { |
|
| 747 | + public static function get_email_html() { |
|
| 748 | 748 | FrmAppHelper::permission_check('frm_view_forms'); |
| 749 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 749 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 750 | 750 | echo FrmEntryFormat::show_entry( array( |
| 751 | 751 | 'form_id' => FrmAppHelper::get_post_param( 'form_id', '', 'absint' ), |
| 752 | - 'default_email' => true, |
|
| 752 | + 'default_email' => true, |
|
| 753 | 753 | 'plain_text' => FrmAppHelper::get_post_param( 'plain_text', '', 'absint' ), |
| 754 | - ) ); |
|
| 755 | - wp_die(); |
|
| 754 | + ) ); |
|
| 755 | + wp_die(); |
|
| 756 | 756 | } |
| 757 | 757 | |
| 758 | - public static function filter_content( $content, $form, $entry = false ) { |
|
| 758 | + public static function filter_content( $content, $form, $entry = false ) { |
|
| 759 | 759 | self::get_entry_by_param( $entry ); |
| 760 | - if ( ! $entry ) { |
|
| 761 | - return $content; |
|
| 762 | - } |
|
| 760 | + if ( ! $entry ) { |
|
| 761 | + return $content; |
|
| 762 | + } |
|
| 763 | 763 | |
| 764 | - if ( is_object( $form ) ) { |
|
| 765 | - $form = $form->id; |
|
| 766 | - } |
|
| 764 | + if ( is_object( $form ) ) { |
|
| 765 | + $form = $form->id; |
|
| 766 | + } |
|
| 767 | 767 | |
| 768 | - $shortcodes = FrmFieldsHelper::get_shortcodes( $content, $form ); |
|
| 769 | - $content = apply_filters( 'frm_replace_content_shortcodes', $content, $entry, $shortcodes ); |
|
| 768 | + $shortcodes = FrmFieldsHelper::get_shortcodes( $content, $form ); |
|
| 769 | + $content = apply_filters( 'frm_replace_content_shortcodes', $content, $entry, $shortcodes ); |
|
| 770 | 770 | |
| 771 | - return $content; |
|
| 772 | - } |
|
| 771 | + return $content; |
|
| 772 | + } |
|
| 773 | 773 | |
| 774 | 774 | private static function get_entry_by_param( &$entry ) { |
| 775 | 775 | if ( ! $entry || ! is_object( $entry ) ) { |
@@ -781,287 +781,287 @@ discard block |
||
| 781 | 781 | } |
| 782 | 782 | } |
| 783 | 783 | |
| 784 | - public static function replace_content_shortcodes( $content, $entry, $shortcodes ) { |
|
| 785 | - return FrmFieldsHelper::replace_content_shortcodes( $content, $entry, $shortcodes ); |
|
| 786 | - } |
|
| 784 | + public static function replace_content_shortcodes( $content, $entry, $shortcodes ) { |
|
| 785 | + return FrmFieldsHelper::replace_content_shortcodes( $content, $entry, $shortcodes ); |
|
| 786 | + } |
|
| 787 | 787 | |
| 788 | - public static function process_bulk_form_actions( $errors ) { |
|
| 789 | - if ( ! $_REQUEST ) { |
|
| 790 | - return $errors; |
|
| 791 | - } |
|
| 788 | + public static function process_bulk_form_actions( $errors ) { |
|
| 789 | + if ( ! $_REQUEST ) { |
|
| 790 | + return $errors; |
|
| 791 | + } |
|
| 792 | 792 | |
| 793 | 793 | $bulkaction = FrmAppHelper::get_param( 'action', '', 'get', 'sanitize_text_field' ); |
| 794 | - if ( $bulkaction == -1 ) { |
|
| 794 | + if ( $bulkaction == -1 ) { |
|
| 795 | 795 | $bulkaction = FrmAppHelper::get_param( 'action2', '', 'get', 'sanitize_title' ); |
| 796 | - } |
|
| 797 | - |
|
| 798 | - if ( ! empty( $bulkaction ) && strpos( $bulkaction, 'bulk_' ) === 0 ) { |
|
| 799 | - FrmAppHelper::remove_get_action(); |
|
| 800 | - |
|
| 801 | - $bulkaction = str_replace( 'bulk_', '', $bulkaction ); |
|
| 802 | - } |
|
| 803 | - |
|
| 804 | - $ids = FrmAppHelper::get_param( 'item-action', '' ); |
|
| 805 | - if ( empty( $ids ) ) { |
|
| 806 | - $errors[] = __( 'No forms were specified', 'formidable' ); |
|
| 807 | - return $errors; |
|
| 808 | - } |
|
| 809 | - |
|
| 810 | - $permission_error = FrmAppHelper::permission_nonce_error( '', '_wpnonce', 'bulk-toplevel_page_formidable' ); |
|
| 811 | - if ( $permission_error !== false ) { |
|
| 812 | - $errors[] = $permission_error; |
|
| 813 | - return $errors; |
|
| 814 | - } |
|
| 815 | - |
|
| 816 | - if ( ! is_array( $ids ) ) { |
|
| 817 | - $ids = explode( ',', $ids ); |
|
| 818 | - } |
|
| 819 | - |
|
| 820 | - switch ( $bulkaction ) { |
|
| 821 | - case 'delete': |
|
| 822 | - $message = self::bulk_destroy( $ids ); |
|
| 823 | - break; |
|
| 824 | - case 'trash': |
|
| 825 | - $message = self::bulk_trash( $ids ); |
|
| 826 | - break; |
|
| 827 | - case 'untrash': |
|
| 828 | - $message = self::bulk_untrash( $ids ); |
|
| 829 | - break; |
|
| 830 | - case 'create_template': |
|
| 831 | - $message = self::bulk_create_template( $ids ); |
|
| 832 | - break; |
|
| 833 | - } |
|
| 834 | - |
|
| 835 | - if ( isset( $message ) && ! empty( $message ) ) { |
|
| 796 | + } |
|
| 797 | + |
|
| 798 | + if ( ! empty( $bulkaction ) && strpos( $bulkaction, 'bulk_' ) === 0 ) { |
|
| 799 | + FrmAppHelper::remove_get_action(); |
|
| 800 | + |
|
| 801 | + $bulkaction = str_replace( 'bulk_', '', $bulkaction ); |
|
| 802 | + } |
|
| 803 | + |
|
| 804 | + $ids = FrmAppHelper::get_param( 'item-action', '' ); |
|
| 805 | + if ( empty( $ids ) ) { |
|
| 806 | + $errors[] = __( 'No forms were specified', 'formidable' ); |
|
| 807 | + return $errors; |
|
| 808 | + } |
|
| 809 | + |
|
| 810 | + $permission_error = FrmAppHelper::permission_nonce_error( '', '_wpnonce', 'bulk-toplevel_page_formidable' ); |
|
| 811 | + if ( $permission_error !== false ) { |
|
| 812 | + $errors[] = $permission_error; |
|
| 813 | + return $errors; |
|
| 814 | + } |
|
| 815 | + |
|
| 816 | + if ( ! is_array( $ids ) ) { |
|
| 817 | + $ids = explode( ',', $ids ); |
|
| 818 | + } |
|
| 819 | + |
|
| 820 | + switch ( $bulkaction ) { |
|
| 821 | + case 'delete': |
|
| 822 | + $message = self::bulk_destroy( $ids ); |
|
| 823 | + break; |
|
| 824 | + case 'trash': |
|
| 825 | + $message = self::bulk_trash( $ids ); |
|
| 826 | + break; |
|
| 827 | + case 'untrash': |
|
| 828 | + $message = self::bulk_untrash( $ids ); |
|
| 829 | + break; |
|
| 830 | + case 'create_template': |
|
| 831 | + $message = self::bulk_create_template( $ids ); |
|
| 832 | + break; |
|
| 833 | + } |
|
| 834 | + |
|
| 835 | + if ( isset( $message ) && ! empty( $message ) ) { |
|
| 836 | 836 | echo '<div id="message" class="updated frm_msg_padding">' . FrmAppHelper::kses( $message, array( 'a' ) ) . '</div>'; |
| 837 | - } |
|
| 837 | + } |
|
| 838 | 838 | |
| 839 | - return $errors; |
|
| 840 | - } |
|
| 839 | + return $errors; |
|
| 840 | + } |
|
| 841 | 841 | |
| 842 | - public static function add_default_templates( $path, $default = true, $template = true ) { |
|
| 843 | - _deprecated_function( __FUNCTION__, '1.07.05', 'FrmXMLController::add_default_templates()' ); |
|
| 842 | + public static function add_default_templates( $path, $default = true, $template = true ) { |
|
| 843 | + _deprecated_function( __FUNCTION__, '1.07.05', 'FrmXMLController::add_default_templates()' ); |
|
| 844 | 844 | |
| 845 | - $path = untrailingslashit(trim($path)); |
|
| 845 | + $path = untrailingslashit(trim($path)); |
|
| 846 | 846 | $templates = glob( $path . '/*.php' ); |
| 847 | 847 | |
| 848 | 848 | for ( $i = count( $templates ) - 1; $i >= 0; $i-- ) { |
| 849 | 849 | $filename = str_replace( '.php', '', str_replace( $path . '/', '', $templates[ $i ] ) ); |
| 850 | 850 | $template_query = array( 'form_key' => $filename ); |
| 851 | - if ( $template ) { |
|
| 852 | - $template_query['is_template'] = 1; |
|
| 853 | - } |
|
| 854 | - if ( $default ) { |
|
| 855 | - $template_query['default_template'] = 1; |
|
| 856 | - } |
|
| 851 | + if ( $template ) { |
|
| 852 | + $template_query['is_template'] = 1; |
|
| 853 | + } |
|
| 854 | + if ( $default ) { |
|
| 855 | + $template_query['default_template'] = 1; |
|
| 856 | + } |
|
| 857 | 857 | $form = FrmForm::getAll( $template_query, '', 1 ); |
| 858 | 858 | |
| 859 | - $values = FrmFormsHelper::setup_new_vars(); |
|
| 860 | - $values['form_key'] = $filename; |
|
| 861 | - $values['is_template'] = $template; |
|
| 862 | - $values['status'] = 'published'; |
|
| 863 | - if ( $default ) { |
|
| 864 | - $values['default_template'] = 1; |
|
| 865 | - } |
|
| 866 | - |
|
| 867 | - include( $templates[ $i ] ); |
|
| 868 | - |
|
| 869 | - //get updated form |
|
| 870 | - if ( isset($form) && ! empty($form) ) { |
|
| 871 | - $old_id = $form->id; |
|
| 872 | - $form = FrmForm::getOne($form->id); |
|
| 873 | - } else { |
|
| 874 | - $old_id = false; |
|
| 859 | + $values = FrmFormsHelper::setup_new_vars(); |
|
| 860 | + $values['form_key'] = $filename; |
|
| 861 | + $values['is_template'] = $template; |
|
| 862 | + $values['status'] = 'published'; |
|
| 863 | + if ( $default ) { |
|
| 864 | + $values['default_template'] = 1; |
|
| 865 | + } |
|
| 866 | + |
|
| 867 | + include( $templates[ $i ] ); |
|
| 868 | + |
|
| 869 | + //get updated form |
|
| 870 | + if ( isset($form) && ! empty($form) ) { |
|
| 871 | + $old_id = $form->id; |
|
| 872 | + $form = FrmForm::getOne($form->id); |
|
| 873 | + } else { |
|
| 874 | + $old_id = false; |
|
| 875 | 875 | $form = FrmForm::getAll( $template_query, '', 1 ); |
| 876 | - } |
|
| 876 | + } |
|
| 877 | 877 | |
| 878 | - if ( $form ) { |
|
| 878 | + if ( $form ) { |
|
| 879 | 879 | do_action( 'frm_after_duplicate_form', $form->id, (array) $form, array( 'old_id' => $old_id ) ); |
| 880 | - } |
|
| 881 | - } |
|
| 882 | - } |
|
| 880 | + } |
|
| 881 | + } |
|
| 882 | + } |
|
| 883 | 883 | |
| 884 | - public static function route() { |
|
| 885 | - $action = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action'; |
|
| 886 | - $vars = array(); |
|
| 884 | + public static function route() { |
|
| 885 | + $action = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action'; |
|
| 886 | + $vars = array(); |
|
| 887 | 887 | if ( isset( $_POST['frm_compact_fields'] ) ) { |
| 888 | 888 | FrmAppHelper::permission_check( 'frm_edit_forms' ); |
| 889 | 889 | |
| 890 | - $json_vars = htmlspecialchars_decode(nl2br(stripslashes(str_replace('"', '\\\"', $_POST['frm_compact_fields'] )))); |
|
| 891 | - $json_vars = json_decode($json_vars, true); |
|
| 892 | - if ( empty($json_vars) ) { |
|
| 893 | - // json decoding failed so we should return an error message |
|
| 890 | + $json_vars = htmlspecialchars_decode(nl2br(stripslashes(str_replace('"', '\\\"', $_POST['frm_compact_fields'] )))); |
|
| 891 | + $json_vars = json_decode($json_vars, true); |
|
| 892 | + if ( empty($json_vars) ) { |
|
| 893 | + // json decoding failed so we should return an error message |
|
| 894 | 894 | $action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' ); |
| 895 | - if ( 'edit' == $action ) { |
|
| 896 | - $action = 'update'; |
|
| 897 | - } |
|
| 898 | - |
|
| 899 | - add_filter('frm_validate_form', 'FrmFormsController::json_error'); |
|
| 900 | - } else { |
|
| 901 | - $vars = FrmAppHelper::json_to_array($json_vars); |
|
| 902 | - $action = $vars[ $action ]; |
|
| 895 | + if ( 'edit' == $action ) { |
|
| 896 | + $action = 'update'; |
|
| 897 | + } |
|
| 898 | + |
|
| 899 | + add_filter('frm_validate_form', 'FrmFormsController::json_error'); |
|
| 900 | + } else { |
|
| 901 | + $vars = FrmAppHelper::json_to_array($json_vars); |
|
| 902 | + $action = $vars[ $action ]; |
|
| 903 | 903 | unset( $_REQUEST['frm_compact_fields'], $_POST['frm_compact_fields'] ); |
| 904 | 904 | $_REQUEST = array_merge( $_REQUEST, $vars ); |
| 905 | 905 | $_POST = array_merge( $_POST, $_REQUEST ); |
| 906 | - } |
|
| 907 | - } else { |
|
| 906 | + } |
|
| 907 | + } else { |
|
| 908 | 908 | $action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' ); |
| 909 | - if ( isset( $_REQUEST['delete_all'] ) ) { |
|
| 910 | - // override the action for this page |
|
| 911 | - $action = 'delete_all'; |
|
| 912 | - } |
|
| 913 | - } |
|
| 909 | + if ( isset( $_REQUEST['delete_all'] ) ) { |
|
| 910 | + // override the action for this page |
|
| 911 | + $action = 'delete_all'; |
|
| 912 | + } |
|
| 913 | + } |
|
| 914 | 914 | |
| 915 | 915 | add_action( 'frm_load_form_hooks', 'FrmHooksController::trigger_load_form_hooks' ); |
| 916 | - FrmAppHelper::trigger_hook_load( 'form' ); |
|
| 917 | - |
|
| 918 | - switch ( $action ) { |
|
| 919 | - case 'new': |
|
| 920 | - return self::new_form($vars); |
|
| 921 | - case 'create': |
|
| 922 | - case 'edit': |
|
| 923 | - case 'update': |
|
| 924 | - case 'duplicate': |
|
| 925 | - case 'trash': |
|
| 926 | - case 'untrash': |
|
| 927 | - case 'destroy': |
|
| 928 | - case 'delete_all': |
|
| 929 | - case 'settings': |
|
| 930 | - case 'update_settings': |
|
| 916 | + FrmAppHelper::trigger_hook_load( 'form' ); |
|
| 917 | + |
|
| 918 | + switch ( $action ) { |
|
| 919 | + case 'new': |
|
| 920 | + return self::new_form($vars); |
|
| 921 | + case 'create': |
|
| 922 | + case 'edit': |
|
| 923 | + case 'update': |
|
| 924 | + case 'duplicate': |
|
| 925 | + case 'trash': |
|
| 926 | + case 'untrash': |
|
| 927 | + case 'destroy': |
|
| 928 | + case 'delete_all': |
|
| 929 | + case 'settings': |
|
| 930 | + case 'update_settings': |
|
| 931 | 931 | return self::$action( $vars ); |
| 932 | - default: |
|
| 932 | + default: |
|
| 933 | 933 | do_action( 'frm_form_action_' . $action ); |
| 934 | 934 | if ( apply_filters( 'frm_form_stop_action_' . $action, false ) ) { |
| 935 | - return; |
|
| 936 | - } |
|
| 935 | + return; |
|
| 936 | + } |
|
| 937 | 937 | |
| 938 | 938 | $action = FrmAppHelper::get_param( 'action', '', 'get', 'sanitize_text_field' ); |
| 939 | - if ( $action == -1 ) { |
|
| 939 | + if ( $action == -1 ) { |
|
| 940 | 940 | $action = FrmAppHelper::get_param( 'action2', '', 'get', 'sanitize_title' ); |
| 941 | - } |
|
| 941 | + } |
|
| 942 | 942 | |
| 943 | - if ( strpos($action, 'bulk_') === 0 ) { |
|
| 944 | - FrmAppHelper::remove_get_action(); |
|
| 945 | - return self::list_form(); |
|
| 946 | - } |
|
| 943 | + if ( strpos($action, 'bulk_') === 0 ) { |
|
| 944 | + FrmAppHelper::remove_get_action(); |
|
| 945 | + return self::list_form(); |
|
| 946 | + } |
|
| 947 | 947 | |
| 948 | - return self::display_forms_list(); |
|
| 949 | - } |
|
| 950 | - } |
|
| 948 | + return self::display_forms_list(); |
|
| 949 | + } |
|
| 950 | + } |
|
| 951 | 951 | |
| 952 | - public static function json_error( $errors ) { |
|
| 953 | - $errors['json'] = __( 'Abnormal HTML characters prevented your form from saving correctly', 'formidable' ); |
|
| 954 | - return $errors; |
|
| 955 | - } |
|
| 952 | + public static function json_error( $errors ) { |
|
| 953 | + $errors['json'] = __( 'Abnormal HTML characters prevented your form from saving correctly', 'formidable' ); |
|
| 954 | + return $errors; |
|
| 955 | + } |
|
| 956 | 956 | |
| 957 | 957 | |
| 958 | - /* FRONT-END FORMS */ |
|
| 959 | - public static function admin_bar_css() { |
|
| 958 | + /* FRONT-END FORMS */ |
|
| 959 | + public static function admin_bar_css() { |
|
| 960 | 960 | if ( is_admin() || ! current_user_can( 'frm_edit_forms' ) ) { |
| 961 | - return; |
|
| 962 | - } |
|
| 961 | + return; |
|
| 962 | + } |
|
| 963 | 963 | |
| 964 | 964 | add_action( 'wp_before_admin_bar_render', 'FrmFormsController::admin_bar_configure' ); |
| 965 | 965 | FrmAppHelper::load_font_style(); |
| 966 | 966 | } |
| 967 | 967 | |
| 968 | 968 | public static function admin_bar_configure() { |
| 969 | - global $frm_vars; |
|
| 970 | - if ( empty($frm_vars['forms_loaded']) ) { |
|
| 971 | - return; |
|
| 972 | - } |
|
| 973 | - |
|
| 974 | - $actions = array(); |
|
| 975 | - foreach ( $frm_vars['forms_loaded'] as $form ) { |
|
| 976 | - if ( is_object($form) ) { |
|
| 977 | - $actions[ $form->id ] = $form->name; |
|
| 978 | - } |
|
| 979 | - unset($form); |
|
| 980 | - } |
|
| 981 | - |
|
| 982 | - if ( empty($actions) ) { |
|
| 983 | - return; |
|
| 984 | - } |
|
| 985 | - |
|
| 986 | - asort($actions); |
|
| 987 | - |
|
| 988 | - global $wp_admin_bar; |
|
| 989 | - |
|
| 990 | - if ( count($actions) == 1 ) { |
|
| 991 | - $wp_admin_bar->add_menu( array( |
|
| 992 | - 'title' => 'Edit Form', |
|
| 969 | + global $frm_vars; |
|
| 970 | + if ( empty($frm_vars['forms_loaded']) ) { |
|
| 971 | + return; |
|
| 972 | + } |
|
| 973 | + |
|
| 974 | + $actions = array(); |
|
| 975 | + foreach ( $frm_vars['forms_loaded'] as $form ) { |
|
| 976 | + if ( is_object($form) ) { |
|
| 977 | + $actions[ $form->id ] = $form->name; |
|
| 978 | + } |
|
| 979 | + unset($form); |
|
| 980 | + } |
|
| 981 | + |
|
| 982 | + if ( empty($actions) ) { |
|
| 983 | + return; |
|
| 984 | + } |
|
| 985 | + |
|
| 986 | + asort($actions); |
|
| 987 | + |
|
| 988 | + global $wp_admin_bar; |
|
| 989 | + |
|
| 990 | + if ( count($actions) == 1 ) { |
|
| 991 | + $wp_admin_bar->add_menu( array( |
|
| 992 | + 'title' => 'Edit Form', |
|
| 993 | 993 | 'href' => admin_url( 'admin.php?page=formidable&frm_action=edit&id=' . current( array_keys( $actions ) ) ), |
| 994 | - 'id' => 'frm-forms', |
|
| 995 | - ) ); |
|
| 996 | - } else { |
|
| 997 | - $wp_admin_bar->add_menu( array( |
|
| 998 | - 'id' => 'frm-forms', |
|
| 999 | - 'title' => '<span class="ab-icon"></span><span class="ab-label">' . __( 'Edit Forms', 'formidable' ) . '</span>', |
|
| 994 | + 'id' => 'frm-forms', |
|
| 995 | + ) ); |
|
| 996 | + } else { |
|
| 997 | + $wp_admin_bar->add_menu( array( |
|
| 998 | + 'id' => 'frm-forms', |
|
| 999 | + 'title' => '<span class="ab-icon"></span><span class="ab-label">' . __( 'Edit Forms', 'formidable' ) . '</span>', |
|
| 1000 | 1000 | 'href' => admin_url( 'admin.php?page=formidable&frm_action=edit&id=' . current( array_keys( $actions ) ) ), |
| 1001 | - 'meta' => array( |
|
| 1001 | + 'meta' => array( |
|
| 1002 | 1002 | 'title' => __( 'Edit Forms', 'formidable' ), |
| 1003 | - ), |
|
| 1004 | - ) ); |
|
| 1003 | + ), |
|
| 1004 | + ) ); |
|
| 1005 | 1005 | |
| 1006 | - foreach ( $actions as $form_id => $name ) { |
|
| 1006 | + foreach ( $actions as $form_id => $name ) { |
|
| 1007 | 1007 | |
| 1008 | - $wp_admin_bar->add_menu( array( |
|
| 1009 | - 'parent' => 'frm-forms', |
|
| 1008 | + $wp_admin_bar->add_menu( array( |
|
| 1009 | + 'parent' => 'frm-forms', |
|
| 1010 | 1010 | 'id' => 'edit_form_' . $form_id, |
| 1011 | - 'title' => empty($name) ? __( '(no title)') : $name, |
|
| 1011 | + 'title' => empty($name) ? __( '(no title)') : $name, |
|
| 1012 | 1012 | 'href' => admin_url( 'admin.php?page=formidable&frm_action=edit&id=' . $form_id ), |
| 1013 | - ) ); |
|
| 1014 | - } |
|
| 1015 | - } |
|
| 1016 | - } |
|
| 1013 | + ) ); |
|
| 1014 | + } |
|
| 1015 | + } |
|
| 1016 | + } |
|
| 1017 | 1017 | |
| 1018 | - //formidable shortcode |
|
| 1018 | + //formidable shortcode |
|
| 1019 | 1019 | public static function get_form_shortcode( $atts ) { |
| 1020 | - global $frm_vars; |
|
| 1021 | - if ( isset($frm_vars['skip_shortcode']) && $frm_vars['skip_shortcode'] ) { |
|
| 1022 | - $sc = '[formidable'; |
|
| 1020 | + global $frm_vars; |
|
| 1021 | + if ( isset($frm_vars['skip_shortcode']) && $frm_vars['skip_shortcode'] ) { |
|
| 1022 | + $sc = '[formidable'; |
|
| 1023 | 1023 | if ( ! empty( $atts ) ) { |
| 1024 | 1024 | foreach ( $atts as $k => $v ) { |
| 1025 | 1025 | $sc .= ' ' . $k . '="' . esc_attr( $v ) . '"'; |
| 1026 | 1026 | } |
| 1027 | 1027 | } |
| 1028 | 1028 | return $sc . ']'; |
| 1029 | - } |
|
| 1030 | - |
|
| 1031 | - $shortcode_atts = shortcode_atts( array( |
|
| 1032 | - 'id' => '', 'key' => '', 'title' => false, 'description' => false, |
|
| 1033 | - 'readonly' => false, 'entry_id' => false, 'fields' => array(), |
|
| 1034 | - 'exclude_fields' => array(), 'minimize' => false, |
|
| 1035 | - ), $atts); |
|
| 1036 | - do_action('formidable_shortcode_atts', $shortcode_atts, $atts); |
|
| 1037 | - |
|
| 1038 | - return self::show_form( |
|
| 1039 | - $shortcode_atts['id'], $shortcode_atts['key'], $shortcode_atts['title'], |
|
| 1040 | - $shortcode_atts['description'], $atts |
|
| 1041 | - ); |
|
| 1042 | - } |
|
| 1043 | - |
|
| 1044 | - public static function show_form( $id = '', $key = '', $title = false, $description = false, $atts = array() ) { |
|
| 1045 | - if ( empty( $id ) ) { |
|
| 1046 | - $id = $key; |
|
| 1047 | - } |
|
| 1048 | - |
|
| 1049 | - // no form id or key set |
|
| 1050 | - if ( empty( $id ) ) { |
|
| 1051 | - return __( 'Please select a valid form', 'formidable' ); |
|
| 1052 | - } |
|
| 1053 | - |
|
| 1054 | - $form = FrmForm::getOne( $id ); |
|
| 1055 | - if ( ! $form || $form->parent_form_id || $form->status == 'trash' ) { |
|
| 1056 | - return __( 'Please select a valid form', 'formidable' ); |
|
| 1057 | - } |
|
| 1029 | + } |
|
| 1030 | + |
|
| 1031 | + $shortcode_atts = shortcode_atts( array( |
|
| 1032 | + 'id' => '', 'key' => '', 'title' => false, 'description' => false, |
|
| 1033 | + 'readonly' => false, 'entry_id' => false, 'fields' => array(), |
|
| 1034 | + 'exclude_fields' => array(), 'minimize' => false, |
|
| 1035 | + ), $atts); |
|
| 1036 | + do_action('formidable_shortcode_atts', $shortcode_atts, $atts); |
|
| 1037 | + |
|
| 1038 | + return self::show_form( |
|
| 1039 | + $shortcode_atts['id'], $shortcode_atts['key'], $shortcode_atts['title'], |
|
| 1040 | + $shortcode_atts['description'], $atts |
|
| 1041 | + ); |
|
| 1042 | + } |
|
| 1043 | + |
|
| 1044 | + public static function show_form( $id = '', $key = '', $title = false, $description = false, $atts = array() ) { |
|
| 1045 | + if ( empty( $id ) ) { |
|
| 1046 | + $id = $key; |
|
| 1047 | + } |
|
| 1048 | + |
|
| 1049 | + // no form id or key set |
|
| 1050 | + if ( empty( $id ) ) { |
|
| 1051 | + return __( 'Please select a valid form', 'formidable' ); |
|
| 1052 | + } |
|
| 1053 | + |
|
| 1054 | + $form = FrmForm::getOne( $id ); |
|
| 1055 | + if ( ! $form || $form->parent_form_id || $form->status == 'trash' ) { |
|
| 1056 | + return __( 'Please select a valid form', 'formidable' ); |
|
| 1057 | + } |
|
| 1058 | 1058 | |
| 1059 | 1059 | add_action( 'frm_load_form_hooks', 'FrmHooksController::trigger_load_form_hooks' ); |
| 1060 | - FrmAppHelper::trigger_hook_load( 'form', $form ); |
|
| 1060 | + FrmAppHelper::trigger_hook_load( 'form', $form ); |
|
| 1061 | 1061 | |
| 1062 | - $form = apply_filters( 'frm_pre_display_form', $form ); |
|
| 1062 | + $form = apply_filters( 'frm_pre_display_form', $form ); |
|
| 1063 | 1063 | |
| 1064 | - $frm_settings = FrmAppHelper::get_settings(); |
|
| 1064 | + $frm_settings = FrmAppHelper::get_settings(); |
|
| 1065 | 1065 | |
| 1066 | 1066 | if ( self::is_viewable_draft_form( $form ) ) { |
| 1067 | 1067 | // don't show a draft form on a page |
@@ -1082,7 +1082,7 @@ discard block |
||
| 1082 | 1082 | } |
| 1083 | 1083 | |
| 1084 | 1084 | return $form; |
| 1085 | - } |
|
| 1085 | + } |
|
| 1086 | 1086 | |
| 1087 | 1087 | private static function is_viewable_draft_form( $form ) { |
| 1088 | 1088 | global $post; |
@@ -1098,98 +1098,98 @@ discard block |
||
| 1098 | 1098 | return $form->logged_in && get_current_user_id() && isset( $form->options['logged_in_role'] ) && $form->options['logged_in_role'] != '' && ! FrmAppHelper::user_has_permission( $form->options['logged_in_role'] ); |
| 1099 | 1099 | } |
| 1100 | 1100 | |
| 1101 | - public static function get_form( $form, $title, $description, $atts = array() ) { |
|
| 1102 | - ob_start(); |
|
| 1101 | + public static function get_form( $form, $title, $description, $atts = array() ) { |
|
| 1102 | + ob_start(); |
|
| 1103 | 1103 | |
| 1104 | - self::get_form_contents( $form, $title, $description, $atts ); |
|
| 1104 | + self::get_form_contents( $form, $title, $description, $atts ); |
|
| 1105 | 1105 | self::enqueue_scripts( FrmForm::get_params( $form ) ); |
| 1106 | 1106 | |
| 1107 | - $contents = ob_get_contents(); |
|
| 1108 | - ob_end_clean(); |
|
| 1107 | + $contents = ob_get_contents(); |
|
| 1108 | + ob_end_clean(); |
|
| 1109 | 1109 | |
| 1110 | 1110 | self::maybe_minimize_form( $atts, $contents ); |
| 1111 | 1111 | |
| 1112 | - return $contents; |
|
| 1113 | - } |
|
| 1112 | + return $contents; |
|
| 1113 | + } |
|
| 1114 | 1114 | |
| 1115 | 1115 | public static function enqueue_scripts( $params ) { |
| 1116 | 1116 | do_action( 'frm_enqueue_form_scripts', $params ); |
| 1117 | 1117 | } |
| 1118 | 1118 | |
| 1119 | 1119 | public static function get_form_contents( $form, $title, $description, $atts ) { |
| 1120 | - global $frm_vars; |
|
| 1120 | + global $frm_vars; |
|
| 1121 | 1121 | |
| 1122 | - $frm_settings = FrmAppHelper::get_settings(); |
|
| 1122 | + $frm_settings = FrmAppHelper::get_settings(); |
|
| 1123 | 1123 | |
| 1124 | - $submit = isset($form->options['submit_value']) ? $form->options['submit_value'] : $frm_settings->submit_value; |
|
| 1124 | + $submit = isset($form->options['submit_value']) ? $form->options['submit_value'] : $frm_settings->submit_value; |
|
| 1125 | 1125 | |
| 1126 | - $user_ID = get_current_user_id(); |
|
| 1126 | + $user_ID = get_current_user_id(); |
|
| 1127 | 1127 | $params = FrmForm::get_params( $form ); |
| 1128 | - $message = $errors = ''; |
|
| 1128 | + $message = $errors = ''; |
|
| 1129 | 1129 | |
| 1130 | - if ( $params['posted_form_id'] == $form->id && $_POST ) { |
|
| 1131 | - $errors = isset( $frm_vars['created_entries'][ $form->id ] ) ? $frm_vars['created_entries'][ $form->id ]['errors'] : array(); |
|
| 1132 | - } |
|
| 1130 | + if ( $params['posted_form_id'] == $form->id && $_POST ) { |
|
| 1131 | + $errors = isset( $frm_vars['created_entries'][ $form->id ] ) ? $frm_vars['created_entries'][ $form->id ]['errors'] : array(); |
|
| 1132 | + } |
|
| 1133 | 1133 | |
| 1134 | 1134 | $include_form_tag = apply_filters( 'frm_include_form_tag', true, $form ); |
| 1135 | - $fields = FrmFieldsHelper::get_form_fields( $form->id, ( isset( $errors ) && ! empty( $errors ) ) ); |
|
| 1135 | + $fields = FrmFieldsHelper::get_form_fields( $form->id, ( isset( $errors ) && ! empty( $errors ) ) ); |
|
| 1136 | 1136 | |
| 1137 | - if ( $params['action'] != 'create' || $params['posted_form_id'] != $form->id || ! $_POST ) { |
|
| 1138 | - do_action('frm_display_form_action', $params, $fields, $form, $title, $description); |
|
| 1139 | - if ( apply_filters('frm_continue_to_new', true, $form->id, $params['action']) ) { |
|
| 1140 | - $values = FrmEntriesHelper::setup_new_vars($fields, $form); |
|
| 1137 | + if ( $params['action'] != 'create' || $params['posted_form_id'] != $form->id || ! $_POST ) { |
|
| 1138 | + do_action('frm_display_form_action', $params, $fields, $form, $title, $description); |
|
| 1139 | + if ( apply_filters('frm_continue_to_new', true, $form->id, $params['action']) ) { |
|
| 1140 | + $values = FrmEntriesHelper::setup_new_vars($fields, $form); |
|
| 1141 | 1141 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/new.php' ); |
| 1142 | - } |
|
| 1143 | - return; |
|
| 1144 | - } |
|
| 1142 | + } |
|
| 1143 | + return; |
|
| 1144 | + } |
|
| 1145 | 1145 | |
| 1146 | - if ( ! empty($errors) ) { |
|
| 1147 | - $values = $fields ? FrmEntriesHelper::setup_new_vars($fields, $form) : array(); |
|
| 1146 | + if ( ! empty($errors) ) { |
|
| 1147 | + $values = $fields ? FrmEntriesHelper::setup_new_vars($fields, $form) : array(); |
|
| 1148 | 1148 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/new.php' ); |
| 1149 | - return; |
|
| 1150 | - } |
|
| 1149 | + return; |
|
| 1150 | + } |
|
| 1151 | 1151 | |
| 1152 | - do_action('frm_validate_form_creation', $params, $fields, $form, $title, $description); |
|
| 1153 | - if ( ! apply_filters('frm_continue_to_create', true, $form->id) ) { |
|
| 1154 | - return; |
|
| 1155 | - } |
|
| 1152 | + do_action('frm_validate_form_creation', $params, $fields, $form, $title, $description); |
|
| 1153 | + if ( ! apply_filters('frm_continue_to_create', true, $form->id) ) { |
|
| 1154 | + return; |
|
| 1155 | + } |
|
| 1156 | 1156 | |
| 1157 | - $values = FrmEntriesHelper::setup_new_vars($fields, $form, true); |
|
| 1158 | - $created = ( isset( $frm_vars['created_entries'] ) && isset( $frm_vars['created_entries'][ $form->id ] ) ) ? $frm_vars['created_entries'][ $form->id ]['entry_id'] : 0; |
|
| 1159 | - $conf_method = apply_filters('frm_success_filter', 'message', $form, $form->options, 'create'); |
|
| 1157 | + $values = FrmEntriesHelper::setup_new_vars($fields, $form, true); |
|
| 1158 | + $created = ( isset( $frm_vars['created_entries'] ) && isset( $frm_vars['created_entries'][ $form->id ] ) ) ? $frm_vars['created_entries'][ $form->id ]['entry_id'] : 0; |
|
| 1159 | + $conf_method = apply_filters('frm_success_filter', 'message', $form, $form->options, 'create'); |
|
| 1160 | 1160 | |
| 1161 | - if ( $created && is_numeric($created) && $conf_method != 'message' ) { |
|
| 1162 | - do_action('frm_success_action', $conf_method, $form, $form->options, $created); |
|
| 1161 | + if ( $created && is_numeric($created) && $conf_method != 'message' ) { |
|
| 1162 | + do_action('frm_success_action', $conf_method, $form, $form->options, $created); |
|
| 1163 | 1163 | do_action( 'frm_after_entry_processed', array( 'entry_id' => $created, 'form' => $form ) ); |
| 1164 | - return; |
|
| 1165 | - } |
|
| 1164 | + return; |
|
| 1165 | + } |
|
| 1166 | 1166 | |
| 1167 | - if ( $created && is_numeric($created) ) { |
|
| 1168 | - $message = isset($form->options['success_msg']) ? $form->options['success_msg'] : $frm_settings->success_msg; |
|
| 1169 | - $class = 'frm_message'; |
|
| 1170 | - } else { |
|
| 1171 | - $message = $frm_settings->failed_msg; |
|
| 1172 | - $class = 'frm_error_style'; |
|
| 1173 | - } |
|
| 1167 | + if ( $created && is_numeric($created) ) { |
|
| 1168 | + $message = isset($form->options['success_msg']) ? $form->options['success_msg'] : $frm_settings->success_msg; |
|
| 1169 | + $class = 'frm_message'; |
|
| 1170 | + } else { |
|
| 1171 | + $message = $frm_settings->failed_msg; |
|
| 1172 | + $class = 'frm_error_style'; |
|
| 1173 | + } |
|
| 1174 | 1174 | |
| 1175 | 1175 | $message = FrmFormsHelper::get_success_message( array( |
| 1176 | 1176 | 'message' => $message, 'form' => $form, |
| 1177 | 1177 | 'entry_id' => $created, 'class' => $class, |
| 1178 | 1178 | ) ); |
| 1179 | - $message = apply_filters('frm_main_feedback', $message, $form, $created); |
|
| 1179 | + $message = apply_filters('frm_main_feedback', $message, $form, $created); |
|
| 1180 | 1180 | |
| 1181 | - if ( ! isset($form->options['show_form']) || $form->options['show_form'] ) { |
|
| 1181 | + if ( ! isset($form->options['show_form']) || $form->options['show_form'] ) { |
|
| 1182 | 1182 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/new.php' ); |
| 1183 | - } else { |
|
| 1184 | - global $frm_vars; |
|
| 1183 | + } else { |
|
| 1184 | + global $frm_vars; |
|
| 1185 | 1185 | self::maybe_load_css( $form, $values['custom_style'], $frm_vars['load_css'] ); |
| 1186 | 1186 | |
| 1187 | 1187 | $include_extra_container = 'frm_forms' . FrmFormsHelper::get_form_style_class( $values ); |
| 1188 | 1188 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/errors.php' ); |
| 1189 | - } |
|
| 1189 | + } |
|
| 1190 | 1190 | |
| 1191 | 1191 | do_action( 'frm_after_entry_processed', array( 'entry_id' => $created, 'form' => $form ) ); |
| 1192 | - } |
|
| 1192 | + } |
|
| 1193 | 1193 | |
| 1194 | 1194 | public static function front_head() { |
| 1195 | 1195 | $version = FrmAppHelper::plugin_version(); |
@@ -1218,10 +1218,10 @@ discard block |
||
| 1218 | 1218 | } |
| 1219 | 1219 | |
| 1220 | 1220 | public static function defer_script_loading( $tag, $handle ) { |
| 1221 | - if ( 'recaptcha-api' == $handle && ! strpos( $tag, 'defer' ) ) { |
|
| 1222 | - $tag = str_replace( ' src', ' defer="defer" async="async" src', $tag ); |
|
| 1221 | + if ( 'recaptcha-api' == $handle && ! strpos( $tag, 'defer' ) ) { |
|
| 1222 | + $tag = str_replace( ' src', ' defer="defer" async="async" src', $tag ); |
|
| 1223 | 1223 | } |
| 1224 | - return $tag; |
|
| 1224 | + return $tag; |
|
| 1225 | 1225 | } |
| 1226 | 1226 | |
| 1227 | 1227 | public static function footer_js( $location = 'footer' ) { |
@@ -7,7 +7,7 @@ discard block |
||
| 7 | 7 | if ( ! FrmAppHelper::pro_is_installed() ) { |
| 8 | 8 | $menu_label .= ' (Lite)'; |
| 9 | 9 | } |
| 10 | - add_submenu_page('formidable', 'Formidable | ' . $menu_label, $menu_label, 'frm_view_forms', 'formidable', 'FrmFormsController::route' ); |
|
| 10 | + add_submenu_page( 'formidable', 'Formidable | ' . $menu_label, $menu_label, 'frm_view_forms', 'formidable', 'FrmFormsController::route' ); |
|
| 11 | 11 | |
| 12 | 12 | self::maybe_load_listing_hooks(); |
| 13 | 13 | } |
@@ -18,14 +18,14 @@ discard block |
||
| 18 | 18 | return; |
| 19 | 19 | } |
| 20 | 20 | |
| 21 | - add_filter('get_user_option_managetoplevel_page_formidablecolumnshidden', 'FrmFormsController::hidden_columns' ); |
|
| 21 | + add_filter( 'get_user_option_managetoplevel_page_formidablecolumnshidden', 'FrmFormsController::hidden_columns' ); |
|
| 22 | 22 | |
| 23 | - add_filter('manage_toplevel_page_formidable_columns', 'FrmFormsController::get_columns', 0 ); |
|
| 24 | - add_filter('manage_toplevel_page_formidable_sortable_columns', 'FrmFormsController::get_sortable_columns' ); |
|
| 23 | + add_filter( 'manage_toplevel_page_formidable_columns', 'FrmFormsController::get_columns', 0 ); |
|
| 24 | + add_filter( 'manage_toplevel_page_formidable_sortable_columns', 'FrmFormsController::get_sortable_columns' ); |
|
| 25 | 25 | } |
| 26 | 26 | |
| 27 | 27 | public static function head() { |
| 28 | - wp_enqueue_script('formidable-editinplace'); |
|
| 28 | + wp_enqueue_script( 'formidable-editinplace' ); |
|
| 29 | 29 | |
| 30 | 30 | if ( wp_is_mobile() ) { |
| 31 | 31 | wp_enqueue_script( 'jquery-touch-punch' ); |
@@ -33,39 +33,39 @@ discard block |
||
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | public static function register_widgets() { |
| 36 | - require_once(FrmAppHelper::plugin_path() . '/classes/widgets/FrmShowForm.php'); |
|
| 37 | - register_widget('FrmShowForm'); |
|
| 36 | + require_once( FrmAppHelper::plugin_path() . '/classes/widgets/FrmShowForm.php' ); |
|
| 37 | + register_widget( 'FrmShowForm' ); |
|
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | public static function list_form() { |
| 41 | - FrmAppHelper::permission_check('frm_view_forms'); |
|
| 41 | + FrmAppHelper::permission_check( 'frm_view_forms' ); |
|
| 42 | 42 | |
| 43 | 43 | $params = FrmForm::list_page_params(); |
| 44 | - $errors = self::process_bulk_form_actions( array()); |
|
| 45 | - $errors = apply_filters('frm_admin_list_form_action', $errors); |
|
| 44 | + $errors = self::process_bulk_form_actions( array() ); |
|
| 45 | + $errors = apply_filters( 'frm_admin_list_form_action', $errors ); |
|
| 46 | 46 | |
| 47 | 47 | return self::display_forms_list( $params, '', $errors ); |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | public static function new_form( $values = array() ) { |
| 51 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 51 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
| 52 | 52 | |
| 53 | 53 | global $frm_vars; |
| 54 | 54 | |
| 55 | - $action = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action'; |
|
| 56 | - $action = empty( $values ) ? FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' ) : $values[ $action ]; |
|
| 55 | + $action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action'; |
|
| 56 | + $action = empty( $values ) ? FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' ) : $values[$action]; |
|
| 57 | 57 | |
| 58 | 58 | if ( $action == 'create' ) { |
| 59 | - return self::create($values); |
|
| 59 | + return self::create( $values ); |
|
| 60 | 60 | } else if ( $action == 'new' ) { |
| 61 | 61 | $frm_field_selection = FrmField::field_selection(); |
| 62 | - $values = FrmFormsHelper::setup_new_vars($values); |
|
| 62 | + $values = FrmFormsHelper::setup_new_vars( $values ); |
|
| 63 | 63 | $id = FrmForm::create( $values ); |
| 64 | - $form = FrmForm::getOne($id); |
|
| 64 | + $form = FrmForm::getOne( $id ); |
|
| 65 | 65 | |
| 66 | 66 | // add default email notification |
| 67 | 67 | $action_control = FrmFormActionsController::get_form_actions( 'email' ); |
| 68 | - $action_control->create($form->id); |
|
| 68 | + $action_control->create( $form->id ); |
|
| 69 | 69 | |
| 70 | 70 | $all_templates = FrmForm::getAll( array( 'is_template' => 1 ), 'name' ); |
| 71 | 71 | |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | public static function create( $values = array() ) { |
| 78 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 78 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
| 79 | 79 | |
| 80 | 80 | global $frm_vars; |
| 81 | 81 | if ( empty( $values ) ) { |
@@ -87,22 +87,22 @@ discard block |
||
| 87 | 87 | $values = FrmProEntry::mod_other_vals( $values, 'back' ); |
| 88 | 88 | } |
| 89 | 89 | |
| 90 | - $id = isset($values['id']) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' ); |
|
| 90 | + $id = isset( $values['id'] ) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' ); |
|
| 91 | 91 | |
| 92 | 92 | if ( ! current_user_can( 'frm_edit_forms' ) || ( $_POST && ( ! isset( $values['frm_save_form'] ) || ! wp_verify_nonce( $values['frm_save_form'], 'frm_save_form_nonce' ) ) ) ) { |
| 93 | 93 | $frm_settings = FrmAppHelper::get_settings(); |
| 94 | 94 | $errors = array( 'form' => $frm_settings->admin_permission ); |
| 95 | 95 | } else { |
| 96 | - $errors = FrmForm::validate($values); |
|
| 96 | + $errors = FrmForm::validate( $values ); |
|
| 97 | 97 | } |
| 98 | 98 | |
| 99 | - if ( count($errors) > 0 ) { |
|
| 99 | + if ( count( $errors ) > 0 ) { |
|
| 100 | 100 | $hide_preview = true; |
| 101 | 101 | $frm_field_selection = FrmField::field_selection(); |
| 102 | 102 | $form = FrmForm::getOne( $id ); |
| 103 | - $fields = FrmField::get_all_for_form($id); |
|
| 103 | + $fields = FrmField::get_all_for_form( $id ); |
|
| 104 | 104 | |
| 105 | - $values = FrmAppHelper::setup_edit_vars($form, 'forms', $fields, true); |
|
| 105 | + $values = FrmAppHelper::setup_edit_vars( $form, 'forms', $fields, true ); |
|
| 106 | 106 | $all_templates = FrmForm::getAll( array( 'is_template' => 1 ), 'name' ); |
| 107 | 107 | |
| 108 | 108 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/new.php' ); |
@@ -114,32 +114,32 @@ discard block |
||
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | public static function edit( $values = false ) { |
| 117 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 117 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
| 118 | 118 | |
| 119 | 119 | $id = isset( $values['id'] ) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' ); |
| 120 | - return self::get_edit_vars($id); |
|
| 120 | + return self::get_edit_vars( $id ); |
|
| 121 | 121 | } |
| 122 | 122 | |
| 123 | 123 | public static function settings( $id = false, $message = '' ) { |
| 124 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 124 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
| 125 | 125 | |
| 126 | - if ( ! $id || ! is_numeric($id) ) { |
|
| 126 | + if ( ! $id || ! is_numeric( $id ) ) { |
|
| 127 | 127 | $id = FrmAppHelper::get_param( 'id', '', 'get', 'absint' ); |
| 128 | 128 | } |
| 129 | 129 | return self::get_settings_vars( $id, array(), $message ); |
| 130 | 130 | } |
| 131 | 131 | |
| 132 | 132 | public static function update_settings() { |
| 133 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 133 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
| 134 | 134 | |
| 135 | 135 | $id = FrmAppHelper::get_param( 'id', '', 'get', 'absint' ); |
| 136 | 136 | |
| 137 | - $errors = FrmForm::validate($_POST); |
|
| 138 | - if ( count($errors) > 0 ) { |
|
| 139 | - return self::get_settings_vars($id, $errors); |
|
| 137 | + $errors = FrmForm::validate( $_POST ); |
|
| 138 | + if ( count( $errors ) > 0 ) { |
|
| 139 | + return self::get_settings_vars( $id, $errors ); |
|
| 140 | 140 | } |
| 141 | 141 | |
| 142 | - do_action('frm_before_update_form_settings', $id); |
|
| 142 | + do_action( 'frm_before_update_form_settings', $id ); |
|
| 143 | 143 | |
| 144 | 144 | FrmForm::update( $id, $_POST ); |
| 145 | 145 | |
@@ -161,7 +161,7 @@ discard block |
||
| 161 | 161 | |
| 162 | 162 | private static function edit_in_place_value( $field ) { |
| 163 | 163 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 164 | - FrmAppHelper::permission_check('frm_edit_forms', 'hide'); |
|
| 164 | + FrmAppHelper::permission_check( 'frm_edit_forms', 'hide' ); |
|
| 165 | 165 | |
| 166 | 166 | $form_id = FrmAppHelper::get_post_param( 'form_id', '', 'absint' ); |
| 167 | 167 | $value = FrmAppHelper::get_post_param( 'update_value', '', 'wp_filter_post_kses' ); |
@@ -219,7 +219,7 @@ discard block |
||
| 219 | 219 | * @since 2.0 |
| 220 | 220 | */ |
| 221 | 221 | public static function _create_from_template() { |
| 222 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 222 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
| 223 | 223 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 224 | 224 | |
| 225 | 225 | $current_form = FrmAppHelper::get_param( 'this_form', '', 'get', 'absint' ); |
@@ -234,15 +234,15 @@ discard block |
||
| 234 | 234 | } |
| 235 | 235 | |
| 236 | 236 | public static function duplicate() { |
| 237 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 237 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
| 238 | 238 | |
| 239 | 239 | $params = FrmForm::list_page_params(); |
| 240 | 240 | $form = FrmForm::duplicate( $params['id'], $params['template'], true ); |
| 241 | - $message = ($params['template']) ? __( 'Form template was Successfully Created', 'formidable' ) : __( 'Form was Successfully Copied', 'formidable' ); |
|
| 241 | + $message = ( $params['template'] ) ? __( 'Form template was Successfully Created', 'formidable' ) : __( 'Form was Successfully Copied', 'formidable' ); |
|
| 242 | 242 | if ( $form ) { |
| 243 | 243 | return self::get_edit_vars( $form, array(), $message, true ); |
| 244 | 244 | } else { |
| 245 | - return self::display_forms_list($params, __( 'There was a problem creating the new template.', 'formidable' )); |
|
| 245 | + return self::display_forms_list( $params, __( 'There was a problem creating the new template.', 'formidable' ) ); |
|
| 246 | 246 | } |
| 247 | 247 | } |
| 248 | 248 | |
@@ -305,11 +305,11 @@ discard block |
||
| 305 | 305 | } |
| 306 | 306 | |
| 307 | 307 | public static function bulk_untrash( $ids ) { |
| 308 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 308 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
| 309 | 309 | |
| 310 | 310 | $count = FrmForm::set_status( $ids, 'published' ); |
| 311 | 311 | |
| 312 | - $message = sprintf(_n( '%1$s form restored from the Trash.', '%1$s forms restored from the Trash.', $count, 'formidable' ), 1 ); |
|
| 312 | + $message = sprintf( _n( '%1$s form restored from the Trash.', '%1$s forms restored from the Trash.', $count, 'formidable' ), 1 ); |
|
| 313 | 313 | return $message; |
| 314 | 314 | } |
| 315 | 315 | |
@@ -328,11 +328,11 @@ discard block |
||
| 328 | 328 | 'trash' => array( 'permission' => 'frm_delete_forms', 'new_status' => 'trash' ), |
| 329 | 329 | ); |
| 330 | 330 | |
| 331 | - if ( ! isset( $available_status[ $status ] ) ) { |
|
| 331 | + if ( ! isset( $available_status[$status] ) ) { |
|
| 332 | 332 | return; |
| 333 | 333 | } |
| 334 | 334 | |
| 335 | - FrmAppHelper::permission_check( $available_status[ $status ]['permission'] ); |
|
| 335 | + FrmAppHelper::permission_check( $available_status[$status]['permission'] ); |
|
| 336 | 336 | |
| 337 | 337 | $params = FrmForm::list_page_params(); |
| 338 | 338 | |
@@ -340,25 +340,25 @@ discard block |
||
| 340 | 340 | check_admin_referer( $status . '_form_' . $params['id'] ); |
| 341 | 341 | |
| 342 | 342 | $count = 0; |
| 343 | - if ( FrmForm::set_status( $params['id'], $available_status[ $status ]['new_status'] ) ) { |
|
| 344 | - $count++; |
|
| 343 | + if ( FrmForm::set_status( $params['id'], $available_status[$status]['new_status'] ) ) { |
|
| 344 | + $count ++; |
|
| 345 | 345 | } |
| 346 | 346 | |
| 347 | - $available_status['untrash']['message'] = sprintf(_n( '%1$s form restored from the Trash.', '%1$s forms restored from the Trash.', $count, 'formidable' ), $count ); |
|
| 347 | + $available_status['untrash']['message'] = sprintf( _n( '%1$s form restored from the Trash.', '%1$s forms restored from the Trash.', $count, 'formidable' ), $count ); |
|
| 348 | 348 | $available_status['trash']['message'] = sprintf( _n( '%1$s form moved to the Trash. %2$sUndo%3$s', '%1$s forms moved to the Trash. %2$sUndo%3$s', $count, 'formidable' ), $count, '<a href="' . esc_url( wp_nonce_url( '?page=formidable&frm_action=untrash&form_type=' . ( isset( $_REQUEST['form_type'] ) ? sanitize_title( $_REQUEST['form_type'] ) : '' ) . '&id=' . $params['id'], 'untrash_form_' . $params['id'] ) ) . '">', '</a>' ); |
| 349 | 349 | |
| 350 | - $message = $available_status[ $status ]['message']; |
|
| 350 | + $message = $available_status[$status]['message']; |
|
| 351 | 351 | |
| 352 | 352 | self::display_forms_list( $params, $message ); |
| 353 | 353 | } |
| 354 | 354 | |
| 355 | 355 | public static function bulk_trash( $ids ) { |
| 356 | - FrmAppHelper::permission_check('frm_delete_forms'); |
|
| 356 | + FrmAppHelper::permission_check( 'frm_delete_forms' ); |
|
| 357 | 357 | |
| 358 | 358 | $count = 0; |
| 359 | 359 | foreach ( $ids as $id ) { |
| 360 | 360 | if ( FrmForm::trash( $id ) ) { |
| 361 | - $count++; |
|
| 361 | + $count ++; |
|
| 362 | 362 | } |
| 363 | 363 | } |
| 364 | 364 | |
@@ -369,49 +369,49 @@ discard block |
||
| 369 | 369 | } |
| 370 | 370 | |
| 371 | 371 | public static function destroy() { |
| 372 | - FrmAppHelper::permission_check('frm_delete_forms'); |
|
| 372 | + FrmAppHelper::permission_check( 'frm_delete_forms' ); |
|
| 373 | 373 | |
| 374 | 374 | $params = FrmForm::list_page_params(); |
| 375 | 375 | |
| 376 | 376 | //check nonce url |
| 377 | - check_admin_referer('destroy_form_' . $params['id']); |
|
| 377 | + check_admin_referer( 'destroy_form_' . $params['id'] ); |
|
| 378 | 378 | |
| 379 | 379 | $count = 0; |
| 380 | 380 | if ( FrmForm::destroy( $params['id'] ) ) { |
| 381 | - $count++; |
|
| 381 | + $count ++; |
|
| 382 | 382 | } |
| 383 | 383 | |
| 384 | - $message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count); |
|
| 384 | + $message = sprintf( _n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count ); |
|
| 385 | 385 | |
| 386 | 386 | self::display_forms_list( $params, $message ); |
| 387 | 387 | } |
| 388 | 388 | |
| 389 | 389 | public static function bulk_destroy( $ids ) { |
| 390 | - FrmAppHelper::permission_check('frm_delete_forms'); |
|
| 390 | + FrmAppHelper::permission_check( 'frm_delete_forms' ); |
|
| 391 | 391 | |
| 392 | 392 | $count = 0; |
| 393 | 393 | foreach ( $ids as $id ) { |
| 394 | 394 | $d = FrmForm::destroy( $id ); |
| 395 | 395 | if ( $d ) { |
| 396 | - $count++; |
|
| 396 | + $count ++; |
|
| 397 | 397 | } |
| 398 | 398 | } |
| 399 | 399 | |
| 400 | - $message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count); |
|
| 400 | + $message = sprintf( _n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count ); |
|
| 401 | 401 | |
| 402 | 402 | return $message; |
| 403 | 403 | } |
| 404 | 404 | |
| 405 | 405 | private static function delete_all() { |
| 406 | 406 | //check nonce url |
| 407 | - $permission_error = FrmAppHelper::permission_nonce_error('frm_delete_forms', '_wpnonce', 'bulk-toplevel_page_formidable'); |
|
| 407 | + $permission_error = FrmAppHelper::permission_nonce_error( 'frm_delete_forms', '_wpnonce', 'bulk-toplevel_page_formidable' ); |
|
| 408 | 408 | if ( $permission_error !== false ) { |
| 409 | 409 | self::display_forms_list( array(), '', array( $permission_error ) ); |
| 410 | 410 | return; |
| 411 | 411 | } |
| 412 | 412 | |
| 413 | 413 | $count = FrmForm::scheduled_delete( time() ); |
| 414 | - $message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count); |
|
| 414 | + $message = sprintf( _n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count ); |
|
| 415 | 415 | |
| 416 | 416 | self::display_forms_list( array(), $message ); |
| 417 | 417 | } |
@@ -428,7 +428,7 @@ discard block |
||
| 428 | 428 | * @since 2.0.15 |
| 429 | 429 | */ |
| 430 | 430 | public static function insert_form_button() { |
| 431 | - if ( current_user_can('frm_view_forms') ) { |
|
| 431 | + if ( current_user_can( 'frm_view_forms' ) ) { |
|
| 432 | 432 | $menu_name = FrmAppHelper::get_menu_name(); |
| 433 | 433 | $content = '<a href="#TB_inline?width=50&height=50&inlineId=frm_insert_form" class="thickbox button add_media frm_insert_form" title="' . esc_attr__( 'Add forms and content', 'formidable' ) . '"> |
| 434 | 434 | <span class="frm-buttons-icon wp-media-buttons-icon"></span> ' . |
@@ -449,17 +449,17 @@ discard block |
||
| 449 | 449 | 'formidable' => array( 'name' => __( 'Form', 'formidable' ), 'label' => __( 'Insert a Form', 'formidable' ) ), |
| 450 | 450 | ); |
| 451 | 451 | |
| 452 | - $shortcodes = apply_filters('frm_popup_shortcodes', $shortcodes); |
|
| 452 | + $shortcodes = apply_filters( 'frm_popup_shortcodes', $shortcodes ); |
|
| 453 | 453 | |
| 454 | 454 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/insert_form_popup.php' ); |
| 455 | 455 | } |
| 456 | 456 | |
| 457 | 457 | public static function get_shortcode_opts() { |
| 458 | - FrmAppHelper::permission_check('frm_view_forms'); |
|
| 458 | + FrmAppHelper::permission_check( 'frm_view_forms' ); |
|
| 459 | 459 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 460 | 460 | |
| 461 | 461 | $shortcode = FrmAppHelper::get_post_param( 'shortcode', '', 'sanitize_text_field' ); |
| 462 | - if ( empty($shortcode) ) { |
|
| 462 | + if ( empty( $shortcode ) ) { |
|
| 463 | 463 | wp_die(); |
| 464 | 464 | } |
| 465 | 465 | |
@@ -479,7 +479,7 @@ discard block |
||
| 479 | 479 | ); |
| 480 | 480 | break; |
| 481 | 481 | } |
| 482 | - $opts = apply_filters('frm_sc_popup_opts', $opts, $shortcode); |
|
| 482 | + $opts = apply_filters( 'frm_sc_popup_opts', $opts, $shortcode ); |
|
| 483 | 483 | |
| 484 | 484 | if ( isset( $opts['form_id'] ) && is_string( $opts['form_id'] ) ) { |
| 485 | 485 | // allow other shortcodes to use the required form id option |
@@ -596,11 +596,11 @@ discard block |
||
| 596 | 596 | } |
| 597 | 597 | |
| 598 | 598 | if ( $form->parent_form_id ) { |
| 599 | - wp_die( sprintf( __( 'You are trying to edit a child form. Please edit from %1$shere%2$s', 'formidable' ), '<a href="' . esc_url( admin_url( 'admin.php?page=formidable&frm_action=edit&id=' . $form->parent_form_id ) ) . '">', '</a>' )); |
|
| 599 | + wp_die( sprintf( __( 'You are trying to edit a child form. Please edit from %1$shere%2$s', 'formidable' ), '<a href="' . esc_url( admin_url( 'admin.php?page=formidable&frm_action=edit&id=' . $form->parent_form_id ) ) . '">', '</a>' ) ); |
|
| 600 | 600 | } |
| 601 | 601 | |
| 602 | 602 | $frm_field_selection = FrmField::field_selection(); |
| 603 | - $fields = FrmField::get_all_for_form($form->id); |
|
| 603 | + $fields = FrmField::get_all_for_form( $form->id ); |
|
| 604 | 604 | |
| 605 | 605 | // Automatically add end section fields if they don't exist (2.0 migration) |
| 606 | 606 | $reset_fields = false; |
@@ -610,7 +610,7 @@ discard block |
||
| 610 | 610 | $fields = FrmField::get_all_for_form( $form->id, '', 'exclude' ); |
| 611 | 611 | } |
| 612 | 612 | |
| 613 | - unset($end_section_values, $last_order, $open, $reset_fields); |
|
| 613 | + unset( $end_section_values, $last_order, $open, $reset_fields ); |
|
| 614 | 614 | |
| 615 | 615 | $args = array( 'parent_form_id' => $form->id ); |
| 616 | 616 | $values = FrmAppHelper::setup_edit_vars( $form, 'forms', $fields, true, array(), $args ); |
@@ -623,8 +623,8 @@ discard block |
||
| 623 | 623 | $all_templates = FrmForm::getAll( array( 'is_template' => 1 ), 'name' ); |
| 624 | 624 | |
| 625 | 625 | if ( $form->default_template ) { |
| 626 | - wp_die(__( 'That template cannot be edited', 'formidable' )); |
|
| 627 | - } else if ( defined('DOING_AJAX') ) { |
|
| 626 | + wp_die( __( 'That template cannot be edited', 'formidable' ) ); |
|
| 627 | + } else if ( defined( 'DOING_AJAX' ) ) { |
|
| 628 | 628 | wp_die(); |
| 629 | 629 | } else if ( $create_link ) { |
| 630 | 630 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/new.php' ); |
@@ -640,28 +640,28 @@ discard block |
||
| 640 | 640 | |
| 641 | 641 | $form = FrmForm::getOne( $id ); |
| 642 | 642 | |
| 643 | - $fields = FrmField::get_all_for_form($id); |
|
| 644 | - $values = FrmAppHelper::setup_edit_vars($form, 'forms', $fields, true); |
|
| 643 | + $fields = FrmField::get_all_for_form( $id ); |
|
| 644 | + $values = FrmAppHelper::setup_edit_vars( $form, 'forms', $fields, true ); |
|
| 645 | 645 | |
| 646 | - if ( isset($values['default_template']) && $values['default_template'] ) { |
|
| 647 | - wp_die(__( 'That template cannot be edited', 'formidable' )); |
|
| 646 | + if ( isset( $values['default_template'] ) && $values['default_template'] ) { |
|
| 647 | + wp_die( __( 'That template cannot be edited', 'formidable' ) ); |
|
| 648 | 648 | } |
| 649 | 649 | |
| 650 | 650 | $action_controls = FrmFormActionsController::get_form_actions(); |
| 651 | 651 | |
| 652 | - $sections = apply_filters('frm_add_form_settings_section', array(), $values); |
|
| 652 | + $sections = apply_filters( 'frm_add_form_settings_section', array(), $values ); |
|
| 653 | 653 | $pro_feature = FrmAppHelper::pro_is_installed() ? '' : ' class="pro_feature"'; |
| 654 | 654 | |
| 655 | - $styles = apply_filters('frm_get_style_opts', array()); |
|
| 655 | + $styles = apply_filters( 'frm_get_style_opts', array() ); |
|
| 656 | 656 | |
| 657 | 657 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/settings.php' ); |
| 658 | 658 | } |
| 659 | 659 | |
| 660 | 660 | public static function mb_tags_box( $form_id, $class = '' ) { |
| 661 | - $fields = FrmField::get_all_for_form($form_id, '', 'include'); |
|
| 661 | + $fields = FrmField::get_all_for_form( $form_id, '', 'include' ); |
|
| 662 | 662 | $linked_forms = array(); |
| 663 | 663 | $col = 'one'; |
| 664 | - $settings_tab = FrmAppHelper::is_admin_page('formidable' ) ? true : false; |
|
| 664 | + $settings_tab = FrmAppHelper::is_admin_page( 'formidable' ) ? true : false; |
|
| 665 | 665 | |
| 666 | 666 | $cond_shortcodes = apply_filters( 'frm_conditional_shortcodes', array() ); |
| 667 | 667 | $adv_shortcodes = self::get_advanced_shortcodes(); |
@@ -739,13 +739,13 @@ discard block |
||
| 739 | 739 | |
| 740 | 740 | // Insert the form class setting into the form |
| 741 | 741 | public static function form_classes( $form ) { |
| 742 | - if ( isset($form->options['form_class']) ) { |
|
| 742 | + if ( isset( $form->options['form_class'] ) ) { |
|
| 743 | 743 | echo esc_attr( sanitize_text_field( $form->options['form_class'] ) ); |
| 744 | 744 | } |
| 745 | 745 | } |
| 746 | 746 | |
| 747 | 747 | public static function get_email_html() { |
| 748 | - FrmAppHelper::permission_check('frm_view_forms'); |
|
| 748 | + FrmAppHelper::permission_check( 'frm_view_forms' ); |
|
| 749 | 749 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 750 | 750 | echo FrmEntryFormat::show_entry( array( |
| 751 | 751 | 'form_id' => FrmAppHelper::get_post_param( 'form_id', '', 'absint' ), |
@@ -842,11 +842,11 @@ discard block |
||
| 842 | 842 | public static function add_default_templates( $path, $default = true, $template = true ) { |
| 843 | 843 | _deprecated_function( __FUNCTION__, '1.07.05', 'FrmXMLController::add_default_templates()' ); |
| 844 | 844 | |
| 845 | - $path = untrailingslashit(trim($path)); |
|
| 845 | + $path = untrailingslashit( trim( $path ) ); |
|
| 846 | 846 | $templates = glob( $path . '/*.php' ); |
| 847 | 847 | |
| 848 | - for ( $i = count( $templates ) - 1; $i >= 0; $i-- ) { |
|
| 849 | - $filename = str_replace( '.php', '', str_replace( $path . '/', '', $templates[ $i ] ) ); |
|
| 848 | + for ( $i = count( $templates ) - 1; $i >= 0; $i -- ) { |
|
| 849 | + $filename = str_replace( '.php', '', str_replace( $path . '/', '', $templates[$i] ) ); |
|
| 850 | 850 | $template_query = array( 'form_key' => $filename ); |
| 851 | 851 | if ( $template ) { |
| 852 | 852 | $template_query['is_template'] = 1; |
@@ -864,12 +864,12 @@ discard block |
||
| 864 | 864 | $values['default_template'] = 1; |
| 865 | 865 | } |
| 866 | 866 | |
| 867 | - include( $templates[ $i ] ); |
|
| 867 | + include( $templates[$i] ); |
|
| 868 | 868 | |
| 869 | 869 | //get updated form |
| 870 | - if ( isset($form) && ! empty($form) ) { |
|
| 870 | + if ( isset( $form ) && ! empty( $form ) ) { |
|
| 871 | 871 | $old_id = $form->id; |
| 872 | - $form = FrmForm::getOne($form->id); |
|
| 872 | + $form = FrmForm::getOne( $form->id ); |
|
| 873 | 873 | } else { |
| 874 | 874 | $old_id = false; |
| 875 | 875 | $form = FrmForm::getAll( $template_query, '', 1 ); |
@@ -882,24 +882,24 @@ discard block |
||
| 882 | 882 | } |
| 883 | 883 | |
| 884 | 884 | public static function route() { |
| 885 | - $action = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action'; |
|
| 885 | + $action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action'; |
|
| 886 | 886 | $vars = array(); |
| 887 | 887 | if ( isset( $_POST['frm_compact_fields'] ) ) { |
| 888 | 888 | FrmAppHelper::permission_check( 'frm_edit_forms' ); |
| 889 | 889 | |
| 890 | - $json_vars = htmlspecialchars_decode(nl2br(stripslashes(str_replace('"', '\\\"', $_POST['frm_compact_fields'] )))); |
|
| 891 | - $json_vars = json_decode($json_vars, true); |
|
| 892 | - if ( empty($json_vars) ) { |
|
| 890 | + $json_vars = htmlspecialchars_decode( nl2br( stripslashes( str_replace( '"', '\\\"', $_POST['frm_compact_fields'] ) ) ) ); |
|
| 891 | + $json_vars = json_decode( $json_vars, true ); |
|
| 892 | + if ( empty( $json_vars ) ) { |
|
| 893 | 893 | // json decoding failed so we should return an error message |
| 894 | 894 | $action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' ); |
| 895 | 895 | if ( 'edit' == $action ) { |
| 896 | 896 | $action = 'update'; |
| 897 | 897 | } |
| 898 | 898 | |
| 899 | - add_filter('frm_validate_form', 'FrmFormsController::json_error'); |
|
| 899 | + add_filter( 'frm_validate_form', 'FrmFormsController::json_error' ); |
|
| 900 | 900 | } else { |
| 901 | - $vars = FrmAppHelper::json_to_array($json_vars); |
|
| 902 | - $action = $vars[ $action ]; |
|
| 901 | + $vars = FrmAppHelper::json_to_array( $json_vars ); |
|
| 902 | + $action = $vars[$action]; |
|
| 903 | 903 | unset( $_REQUEST['frm_compact_fields'], $_POST['frm_compact_fields'] ); |
| 904 | 904 | $_REQUEST = array_merge( $_REQUEST, $vars ); |
| 905 | 905 | $_POST = array_merge( $_POST, $_REQUEST ); |
@@ -917,7 +917,7 @@ discard block |
||
| 917 | 917 | |
| 918 | 918 | switch ( $action ) { |
| 919 | 919 | case 'new': |
| 920 | - return self::new_form($vars); |
|
| 920 | + return self::new_form( $vars ); |
|
| 921 | 921 | case 'create': |
| 922 | 922 | case 'edit': |
| 923 | 923 | case 'update': |
@@ -940,7 +940,7 @@ discard block |
||
| 940 | 940 | $action = FrmAppHelper::get_param( 'action2', '', 'get', 'sanitize_title' ); |
| 941 | 941 | } |
| 942 | 942 | |
| 943 | - if ( strpos($action, 'bulk_') === 0 ) { |
|
| 943 | + if ( strpos( $action, 'bulk_' ) === 0 ) { |
|
| 944 | 944 | FrmAppHelper::remove_get_action(); |
| 945 | 945 | return self::list_form(); |
| 946 | 946 | } |
@@ -967,27 +967,27 @@ discard block |
||
| 967 | 967 | |
| 968 | 968 | public static function admin_bar_configure() { |
| 969 | 969 | global $frm_vars; |
| 970 | - if ( empty($frm_vars['forms_loaded']) ) { |
|
| 970 | + if ( empty( $frm_vars['forms_loaded'] ) ) { |
|
| 971 | 971 | return; |
| 972 | 972 | } |
| 973 | 973 | |
| 974 | 974 | $actions = array(); |
| 975 | 975 | foreach ( $frm_vars['forms_loaded'] as $form ) { |
| 976 | - if ( is_object($form) ) { |
|
| 977 | - $actions[ $form->id ] = $form->name; |
|
| 976 | + if ( is_object( $form ) ) { |
|
| 977 | + $actions[$form->id] = $form->name; |
|
| 978 | 978 | } |
| 979 | - unset($form); |
|
| 979 | + unset( $form ); |
|
| 980 | 980 | } |
| 981 | 981 | |
| 982 | - if ( empty($actions) ) { |
|
| 982 | + if ( empty( $actions ) ) { |
|
| 983 | 983 | return; |
| 984 | 984 | } |
| 985 | 985 | |
| 986 | - asort($actions); |
|
| 986 | + asort( $actions ); |
|
| 987 | 987 | |
| 988 | 988 | global $wp_admin_bar; |
| 989 | 989 | |
| 990 | - if ( count($actions) == 1 ) { |
|
| 990 | + if ( count( $actions ) == 1 ) { |
|
| 991 | 991 | $wp_admin_bar->add_menu( array( |
| 992 | 992 | 'title' => 'Edit Form', |
| 993 | 993 | 'href' => admin_url( 'admin.php?page=formidable&frm_action=edit&id=' . current( array_keys( $actions ) ) ), |
@@ -1008,7 +1008,7 @@ discard block |
||
| 1008 | 1008 | $wp_admin_bar->add_menu( array( |
| 1009 | 1009 | 'parent' => 'frm-forms', |
| 1010 | 1010 | 'id' => 'edit_form_' . $form_id, |
| 1011 | - 'title' => empty($name) ? __( '(no title)') : $name, |
|
| 1011 | + 'title' => empty( $name ) ? __( '(no title)' ) : $name, |
|
| 1012 | 1012 | 'href' => admin_url( 'admin.php?page=formidable&frm_action=edit&id=' . $form_id ), |
| 1013 | 1013 | ) ); |
| 1014 | 1014 | } |
@@ -1018,7 +1018,7 @@ discard block |
||
| 1018 | 1018 | //formidable shortcode |
| 1019 | 1019 | public static function get_form_shortcode( $atts ) { |
| 1020 | 1020 | global $frm_vars; |
| 1021 | - if ( isset($frm_vars['skip_shortcode']) && $frm_vars['skip_shortcode'] ) { |
|
| 1021 | + if ( isset( $frm_vars['skip_shortcode'] ) && $frm_vars['skip_shortcode'] ) { |
|
| 1022 | 1022 | $sc = '[formidable'; |
| 1023 | 1023 | if ( ! empty( $atts ) ) { |
| 1024 | 1024 | foreach ( $atts as $k => $v ) { |
@@ -1032,8 +1032,8 @@ discard block |
||
| 1032 | 1032 | 'id' => '', 'key' => '', 'title' => false, 'description' => false, |
| 1033 | 1033 | 'readonly' => false, 'entry_id' => false, 'fields' => array(), |
| 1034 | 1034 | 'exclude_fields' => array(), 'minimize' => false, |
| 1035 | - ), $atts); |
|
| 1036 | - do_action('formidable_shortcode_atts', $shortcode_atts, $atts); |
|
| 1035 | + ), $atts ); |
|
| 1036 | + do_action( 'formidable_shortcode_atts', $shortcode_atts, $atts ); |
|
| 1037 | 1037 | |
| 1038 | 1038 | return self::show_form( |
| 1039 | 1039 | $shortcode_atts['id'], $shortcode_atts['key'], $shortcode_atts['title'], |
@@ -1121,51 +1121,51 @@ discard block |
||
| 1121 | 1121 | |
| 1122 | 1122 | $frm_settings = FrmAppHelper::get_settings(); |
| 1123 | 1123 | |
| 1124 | - $submit = isset($form->options['submit_value']) ? $form->options['submit_value'] : $frm_settings->submit_value; |
|
| 1124 | + $submit = isset( $form->options['submit_value'] ) ? $form->options['submit_value'] : $frm_settings->submit_value; |
|
| 1125 | 1125 | |
| 1126 | 1126 | $user_ID = get_current_user_id(); |
| 1127 | 1127 | $params = FrmForm::get_params( $form ); |
| 1128 | 1128 | $message = $errors = ''; |
| 1129 | 1129 | |
| 1130 | 1130 | if ( $params['posted_form_id'] == $form->id && $_POST ) { |
| 1131 | - $errors = isset( $frm_vars['created_entries'][ $form->id ] ) ? $frm_vars['created_entries'][ $form->id ]['errors'] : array(); |
|
| 1131 | + $errors = isset( $frm_vars['created_entries'][$form->id] ) ? $frm_vars['created_entries'][$form->id]['errors'] : array(); |
|
| 1132 | 1132 | } |
| 1133 | 1133 | |
| 1134 | 1134 | $include_form_tag = apply_filters( 'frm_include_form_tag', true, $form ); |
| 1135 | 1135 | $fields = FrmFieldsHelper::get_form_fields( $form->id, ( isset( $errors ) && ! empty( $errors ) ) ); |
| 1136 | 1136 | |
| 1137 | 1137 | if ( $params['action'] != 'create' || $params['posted_form_id'] != $form->id || ! $_POST ) { |
| 1138 | - do_action('frm_display_form_action', $params, $fields, $form, $title, $description); |
|
| 1139 | - if ( apply_filters('frm_continue_to_new', true, $form->id, $params['action']) ) { |
|
| 1140 | - $values = FrmEntriesHelper::setup_new_vars($fields, $form); |
|
| 1138 | + do_action( 'frm_display_form_action', $params, $fields, $form, $title, $description ); |
|
| 1139 | + if ( apply_filters( 'frm_continue_to_new', true, $form->id, $params['action'] ) ) { |
|
| 1140 | + $values = FrmEntriesHelper::setup_new_vars( $fields, $form ); |
|
| 1141 | 1141 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/new.php' ); |
| 1142 | 1142 | } |
| 1143 | 1143 | return; |
| 1144 | 1144 | } |
| 1145 | 1145 | |
| 1146 | - if ( ! empty($errors) ) { |
|
| 1147 | - $values = $fields ? FrmEntriesHelper::setup_new_vars($fields, $form) : array(); |
|
| 1146 | + if ( ! empty( $errors ) ) { |
|
| 1147 | + $values = $fields ? FrmEntriesHelper::setup_new_vars( $fields, $form ) : array(); |
|
| 1148 | 1148 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/new.php' ); |
| 1149 | 1149 | return; |
| 1150 | 1150 | } |
| 1151 | 1151 | |
| 1152 | - do_action('frm_validate_form_creation', $params, $fields, $form, $title, $description); |
|
| 1153 | - if ( ! apply_filters('frm_continue_to_create', true, $form->id) ) { |
|
| 1152 | + do_action( 'frm_validate_form_creation', $params, $fields, $form, $title, $description ); |
|
| 1153 | + if ( ! apply_filters( 'frm_continue_to_create', true, $form->id ) ) { |
|
| 1154 | 1154 | return; |
| 1155 | 1155 | } |
| 1156 | 1156 | |
| 1157 | - $values = FrmEntriesHelper::setup_new_vars($fields, $form, true); |
|
| 1158 | - $created = ( isset( $frm_vars['created_entries'] ) && isset( $frm_vars['created_entries'][ $form->id ] ) ) ? $frm_vars['created_entries'][ $form->id ]['entry_id'] : 0; |
|
| 1159 | - $conf_method = apply_filters('frm_success_filter', 'message', $form, $form->options, 'create'); |
|
| 1157 | + $values = FrmEntriesHelper::setup_new_vars( $fields, $form, true ); |
|
| 1158 | + $created = ( isset( $frm_vars['created_entries'] ) && isset( $frm_vars['created_entries'][$form->id] ) ) ? $frm_vars['created_entries'][$form->id]['entry_id'] : 0; |
|
| 1159 | + $conf_method = apply_filters( 'frm_success_filter', 'message', $form, $form->options, 'create' ); |
|
| 1160 | 1160 | |
| 1161 | - if ( $created && is_numeric($created) && $conf_method != 'message' ) { |
|
| 1162 | - do_action('frm_success_action', $conf_method, $form, $form->options, $created); |
|
| 1161 | + if ( $created && is_numeric( $created ) && $conf_method != 'message' ) { |
|
| 1162 | + do_action( 'frm_success_action', $conf_method, $form, $form->options, $created ); |
|
| 1163 | 1163 | do_action( 'frm_after_entry_processed', array( 'entry_id' => $created, 'form' => $form ) ); |
| 1164 | 1164 | return; |
| 1165 | 1165 | } |
| 1166 | 1166 | |
| 1167 | - if ( $created && is_numeric($created) ) { |
|
| 1168 | - $message = isset($form->options['success_msg']) ? $form->options['success_msg'] : $frm_settings->success_msg; |
|
| 1167 | + if ( $created && is_numeric( $created ) ) { |
|
| 1168 | + $message = isset( $form->options['success_msg'] ) ? $form->options['success_msg'] : $frm_settings->success_msg; |
|
| 1169 | 1169 | $class = 'frm_message'; |
| 1170 | 1170 | } else { |
| 1171 | 1171 | $message = $frm_settings->failed_msg; |
@@ -1176,9 +1176,9 @@ discard block |
||
| 1176 | 1176 | 'message' => $message, 'form' => $form, |
| 1177 | 1177 | 'entry_id' => $created, 'class' => $class, |
| 1178 | 1178 | ) ); |
| 1179 | - $message = apply_filters('frm_main_feedback', $message, $form, $created); |
|
| 1179 | + $message = apply_filters( 'frm_main_feedback', $message, $form, $created ); |
|
| 1180 | 1180 | |
| 1181 | - if ( ! isset($form->options['show_form']) || $form->options['show_form'] ) { |
|
| 1181 | + if ( ! isset( $form->options['show_form'] ) || $form->options['show_form'] ) { |
|
| 1182 | 1182 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/new.php' ); |
| 1183 | 1183 | } else { |
| 1184 | 1184 | global $frm_vars; |