@@ -2,129 +2,129 @@ discard block |
||
| 2 | 2 | |
| 3 | 3 | class FrmFieldsController { |
| 4 | 4 | |
| 5 | - public static function load_field() { |
|
| 5 | + public static function load_field() { |
|
| 6 | 6 | FrmAppHelper::permission_check('frm_edit_forms'); |
| 7 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 7 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 8 | 8 | |
| 9 | - $fields = $_POST['field']; |
|
| 10 | - if ( empty( $fields ) ) { |
|
| 11 | - wp_die(); |
|
| 12 | - } |
|
| 9 | + $fields = $_POST['field']; |
|
| 10 | + if ( empty( $fields ) ) { |
|
| 11 | + wp_die(); |
|
| 12 | + } |
|
| 13 | 13 | |
| 14 | - $_GET['page'] = 'formidable'; |
|
| 15 | - $fields = stripslashes_deep( $fields ); |
|
| 14 | + $_GET['page'] = 'formidable'; |
|
| 15 | + $fields = stripslashes_deep( $fields ); |
|
| 16 | 16 | |
| 17 | - $ajax = true; |
|
| 17 | + $ajax = true; |
|
| 18 | 18 | $values = array( 'id' => FrmAppHelper::get_post_param( 'form_id', '', 'absint' ) ); |
| 19 | - $path = FrmAppHelper::plugin_path(); |
|
| 20 | - $field_html = array(); |
|
| 21 | - |
|
| 22 | - foreach ( $fields as $field ) { |
|
| 23 | - $field = htmlspecialchars_decode( nl2br( $field ) ); |
|
| 24 | - $field = json_decode( $field, true ); |
|
| 25 | - if ( ! isset( $field['id'] ) ) { |
|
| 26 | - // this field may have already been loaded |
|
| 27 | - continue; |
|
| 28 | - } |
|
| 19 | + $path = FrmAppHelper::plugin_path(); |
|
| 20 | + $field_html = array(); |
|
| 21 | + |
|
| 22 | + foreach ( $fields as $field ) { |
|
| 23 | + $field = htmlspecialchars_decode( nl2br( $field ) ); |
|
| 24 | + $field = json_decode( $field, true ); |
|
| 25 | + if ( ! isset( $field['id'] ) ) { |
|
| 26 | + // this field may have already been loaded |
|
| 27 | + continue; |
|
| 28 | + } |
|
| 29 | 29 | |
| 30 | - $field_id = absint( $field['id'] ); |
|
| 30 | + $field_id = absint( $field['id'] ); |
|
| 31 | 31 | |
| 32 | - if ( ! isset( $field['value'] ) ) { |
|
| 33 | - $field['value'] = ''; |
|
| 34 | - } |
|
| 32 | + if ( ! isset( $field['value'] ) ) { |
|
| 33 | + $field['value'] = ''; |
|
| 34 | + } |
|
| 35 | 35 | |
| 36 | 36 | $field_name = 'item_meta[' . $field_id . ']'; |
| 37 | - $html_id = FrmFieldsHelper::get_html_id($field); |
|
| 37 | + $html_id = FrmFieldsHelper::get_html_id($field); |
|
| 38 | 38 | |
| 39 | - ob_start(); |
|
| 39 | + ob_start(); |
|
| 40 | 40 | include( $path . '/classes/views/frm-forms/add_field.php' ); |
| 41 | - $field_html[ $field_id ] = ob_get_contents(); |
|
| 42 | - ob_end_clean(); |
|
| 43 | - } |
|
| 41 | + $field_html[ $field_id ] = ob_get_contents(); |
|
| 42 | + ob_end_clean(); |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | - unset($path); |
|
| 45 | + unset($path); |
|
| 46 | 46 | |
| 47 | - echo json_encode($field_html); |
|
| 47 | + echo json_encode($field_html); |
|
| 48 | 48 | |
| 49 | - wp_die(); |
|
| 50 | - } |
|
| 49 | + wp_die(); |
|
| 50 | + } |
|
| 51 | 51 | |
| 52 | 52 | /** |
| 53 | 53 | * Create a new field with ajax |
| 54 | 54 | */ |
| 55 | - public static function create() { |
|
| 55 | + public static function create() { |
|
| 56 | 56 | FrmAppHelper::permission_check('frm_edit_forms'); |
| 57 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 57 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 58 | 58 | |
| 59 | 59 | $field_type = FrmAppHelper::get_post_param( 'field_type', '', 'sanitize_text_field' ); |
| 60 | 60 | $form_id = FrmAppHelper::get_post_param( 'form_id', 0, 'absint' ); |
| 61 | 61 | |
| 62 | 62 | $field = self::include_new_field( $field_type, $form_id ); |
| 63 | 63 | |
| 64 | - // this hook will allow for multiple fields to be added at once |
|
| 65 | - do_action('frm_after_field_created', $field, $form_id); |
|
| 64 | + // this hook will allow for multiple fields to be added at once |
|
| 65 | + do_action('frm_after_field_created', $field, $form_id); |
|
| 66 | 66 | |
| 67 | - wp_die(); |
|
| 68 | - } |
|
| 67 | + wp_die(); |
|
| 68 | + } |
|
| 69 | 69 | |
| 70 | - /** |
|
| 71 | - * Set up and create a new field |
|
| 72 | - * |
|
| 73 | - * @param string $field_type |
|
| 74 | - * @param integer $form_id |
|
| 75 | - * @return array|bool |
|
| 76 | - */ |
|
| 70 | + /** |
|
| 71 | + * Set up and create a new field |
|
| 72 | + * |
|
| 73 | + * @param string $field_type |
|
| 74 | + * @param integer $form_id |
|
| 75 | + * @return array|bool |
|
| 76 | + */ |
|
| 77 | 77 | public static function include_new_field( $field_type, $form_id ) { |
| 78 | - $values = array(); |
|
| 79 | - if ( FrmAppHelper::pro_is_installed() ) { |
|
| 80 | - $values['post_type'] = FrmProFormsHelper::post_type($form_id); |
|
| 81 | - } |
|
| 78 | + $values = array(); |
|
| 79 | + if ( FrmAppHelper::pro_is_installed() ) { |
|
| 80 | + $values['post_type'] = FrmProFormsHelper::post_type($form_id); |
|
| 81 | + } |
|
| 82 | 82 | |
| 83 | 83 | $field_values = FrmFieldsHelper::setup_new_vars( $field_type, $form_id ); |
| 84 | - $field_values = apply_filters( 'frm_before_field_created', $field_values ); |
|
| 84 | + $field_values = apply_filters( 'frm_before_field_created', $field_values ); |
|
| 85 | 85 | |
| 86 | - $field_id = FrmField::create( $field_values ); |
|
| 86 | + $field_id = FrmField::create( $field_values ); |
|
| 87 | 87 | |
| 88 | - if ( ! $field_id ) { |
|
| 89 | - return false; |
|
| 90 | - } |
|
| 88 | + if ( ! $field_id ) { |
|
| 89 | + return false; |
|
| 90 | + } |
|
| 91 | 91 | |
| 92 | - $field = self::include_single_field($field_id, $values, $form_id); |
|
| 92 | + $field = self::include_single_field($field_id, $values, $form_id); |
|
| 93 | 93 | |
| 94 | - return $field; |
|
| 95 | - } |
|
| 94 | + return $field; |
|
| 95 | + } |
|
| 96 | 96 | |
| 97 | 97 | public static function edit_name( $field = 'name', $id = '' ) { |
| 98 | 98 | FrmAppHelper::permission_check('frm_edit_forms'); |
| 99 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 99 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 100 | 100 | |
| 101 | - if ( empty($field) ) { |
|
| 102 | - $field = 'name'; |
|
| 103 | - } |
|
| 101 | + if ( empty($field) ) { |
|
| 102 | + $field = 'name'; |
|
| 103 | + } |
|
| 104 | 104 | |
| 105 | - if ( empty($id) ) { |
|
| 105 | + if ( empty($id) ) { |
|
| 106 | 106 | $id = FrmAppHelper::get_post_param( 'element_id', '', 'sanitize_title' ); |
| 107 | 107 | $id = str_replace( 'field_label_', '', $id ); |
| 108 | - } |
|
| 108 | + } |
|
| 109 | 109 | |
| 110 | 110 | $value = FrmAppHelper::get_post_param( 'update_value', '', 'wp_kses_post' ); |
| 111 | 111 | $value = trim( $value ); |
| 112 | - if ( trim(strip_tags($value)) == '' ) { |
|
| 113 | - // set blank value if there is no content |
|
| 114 | - $value = ''; |
|
| 115 | - } |
|
| 112 | + if ( trim(strip_tags($value)) == '' ) { |
|
| 113 | + // set blank value if there is no content |
|
| 114 | + $value = ''; |
|
| 115 | + } |
|
| 116 | 116 | |
| 117 | 117 | FrmField::update( $id, array( $field => $value ) ); |
| 118 | 118 | |
| 119 | 119 | do_action( 'frm_after_update_field_' . $field, compact( 'id', 'value' ) ); |
| 120 | 120 | |
| 121 | 121 | echo stripslashes( wp_kses_post( $value ) ); |
| 122 | - wp_die(); |
|
| 123 | - } |
|
| 122 | + wp_die(); |
|
| 123 | + } |
|
| 124 | 124 | |
| 125 | - public static function update_ajax_option() { |
|
| 125 | + public static function update_ajax_option() { |
|
| 126 | 126 | FrmAppHelper::permission_check('frm_edit_forms'); |
| 127 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 127 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 128 | 128 | |
| 129 | 129 | $field_id = FrmAppHelper::get_post_param( 'field', 0, 'absint' ); |
| 130 | 130 | if ( ! $field_id ) { |
@@ -139,143 +139,143 @@ discard block |
||
| 139 | 139 | unset($new_val); |
| 140 | 140 | } |
| 141 | 141 | |
| 142 | - FrmField::update( $field_id, array( |
|
| 143 | - 'field_options' => $field->field_options, |
|
| 142 | + FrmField::update( $field_id, array( |
|
| 143 | + 'field_options' => $field->field_options, |
|
| 144 | 144 | 'form_id' => $field->form_id, |
| 145 | - ) ); |
|
| 146 | - wp_die(); |
|
| 147 | - } |
|
| 145 | + ) ); |
|
| 146 | + wp_die(); |
|
| 147 | + } |
|
| 148 | 148 | |
| 149 | - public static function duplicate() { |
|
| 149 | + public static function duplicate() { |
|
| 150 | 150 | FrmAppHelper::permission_check('frm_edit_forms'); |
| 151 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 151 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 152 | 152 | |
| 153 | - global $wpdb; |
|
| 153 | + global $wpdb; |
|
| 154 | 154 | |
| 155 | 155 | $field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' ); |
| 156 | 156 | $form_id = FrmAppHelper::get_post_param( 'form_id', 0, 'absint' ); |
| 157 | 157 | |
| 158 | 158 | $copy_field = FrmField::getOne( $field_id ); |
| 159 | - if ( ! $copy_field ) { |
|
| 160 | - wp_die(); |
|
| 161 | - } |
|
| 159 | + if ( ! $copy_field ) { |
|
| 160 | + wp_die(); |
|
| 161 | + } |
|
| 162 | 162 | |
| 163 | 163 | do_action( 'frm_duplicate_field', $copy_field, $form_id ); |
| 164 | 164 | do_action( 'frm_duplicate_field_' . $copy_field->type, $copy_field, $form_id ); |
| 165 | 165 | |
| 166 | 166 | $values = array(); |
| 167 | - FrmFieldsHelper::fill_field( $values, $copy_field, $form_id ); |
|
| 167 | + FrmFieldsHelper::fill_field( $values, $copy_field, $form_id ); |
|
| 168 | 168 | |
| 169 | 169 | $field_count = FrmDb::get_count( $wpdb->prefix . 'frm_fields fi LEFT JOIN ' . $wpdb->prefix . 'frm_forms fr ON (fi.form_id = fr.id)', array( 'or' => 1, 'fr.id' => $form_id, 'fr.parent_form_id' => $form_id ) ); |
| 170 | 170 | |
| 171 | - $values['field_order'] = $field_count + 1; |
|
| 171 | + $values['field_order'] = $field_count + 1; |
|
| 172 | 172 | |
| 173 | - $values = apply_filters( 'frm_prepare_single_field_for_duplication', $values ); |
|
| 173 | + $values = apply_filters( 'frm_prepare_single_field_for_duplication', $values ); |
|
| 174 | 174 | |
| 175 | - if ( ! $field_id = FrmField::create($values) ) { |
|
| 176 | - wp_die(); |
|
| 177 | - } |
|
| 175 | + if ( ! $field_id = FrmField::create($values) ) { |
|
| 176 | + wp_die(); |
|
| 177 | + } |
|
| 178 | 178 | |
| 179 | - self::include_single_field($field_id, $values); |
|
| 179 | + self::include_single_field($field_id, $values); |
|
| 180 | 180 | |
| 181 | - wp_die(); |
|
| 182 | - } |
|
| 181 | + wp_die(); |
|
| 182 | + } |
|
| 183 | 183 | |
| 184 | - /** |
|
| 185 | - * Load a single field in the form builder along with all needed variables |
|
| 186 | - */ |
|
| 187 | - public static function include_single_field( $field_id, $values, $form_id = 0 ) { |
|
| 188 | - $field = FrmFieldsHelper::setup_edit_vars(FrmField::getOne($field_id)); |
|
| 184 | + /** |
|
| 185 | + * Load a single field in the form builder along with all needed variables |
|
| 186 | + */ |
|
| 187 | + public static function include_single_field( $field_id, $values, $form_id = 0 ) { |
|
| 188 | + $field = FrmFieldsHelper::setup_edit_vars(FrmField::getOne($field_id)); |
|
| 189 | 189 | $field_name = 'item_meta[' . $field_id . ']'; |
| 190 | - $html_id = FrmFieldsHelper::get_html_id($field); |
|
| 191 | - $id = $form_id ? $form_id : $field['form_id']; |
|
| 192 | - if ( $field['type'] == 'html' ) { |
|
| 193 | - $field['stop_filter'] = true; |
|
| 194 | - } |
|
| 190 | + $html_id = FrmFieldsHelper::get_html_id($field); |
|
| 191 | + $id = $form_id ? $form_id : $field['form_id']; |
|
| 192 | + if ( $field['type'] == 'html' ) { |
|
| 193 | + $field['stop_filter'] = true; |
|
| 194 | + } |
|
| 195 | 195 | |
| 196 | 196 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/add_field.php' ); |
| 197 | 197 | |
| 198 | - return $field; |
|
| 199 | - } |
|
| 198 | + return $field; |
|
| 199 | + } |
|
| 200 | 200 | |
| 201 | - public static function destroy() { |
|
| 201 | + public static function destroy() { |
|
| 202 | 202 | FrmAppHelper::permission_check('frm_edit_forms'); |
| 203 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 203 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 204 | 204 | |
| 205 | 205 | $field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' ); |
| 206 | 206 | FrmField::destroy( $field_id ); |
| 207 | - wp_die(); |
|
| 208 | - } |
|
| 207 | + wp_die(); |
|
| 208 | + } |
|
| 209 | 209 | |
| 210 | - /* Field Options */ |
|
| 210 | + /* Field Options */ |
|
| 211 | 211 | |
| 212 | - //Add Single Option or Other Option |
|
| 213 | - public static function add_option() { |
|
| 212 | + //Add Single Option or Other Option |
|
| 213 | + public static function add_option() { |
|
| 214 | 214 | FrmAppHelper::permission_check('frm_edit_forms'); |
| 215 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 215 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 216 | 216 | |
| 217 | 217 | $id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' ); |
| 218 | 218 | $opt_type = FrmAppHelper::get_post_param( 'opt_type', '', 'sanitize_text_field' ); |
| 219 | 219 | |
| 220 | - //Get the field |
|
| 221 | - $field = FrmField::getOne($id); |
|
| 220 | + //Get the field |
|
| 221 | + $field = FrmField::getOne($id); |
|
| 222 | 222 | |
| 223 | 223 | if ( ! empty( $field->options ) ) { |
| 224 | 224 | $keys = array_keys( $field->options ); |
| 225 | - $last = str_replace( 'other_', '', end( $keys ) ); |
|
| 226 | - } else { |
|
| 227 | - $last = 0; |
|
| 228 | - } |
|
| 229 | - $opt_key = $last + 1; |
|
| 225 | + $last = str_replace( 'other_', '', end( $keys ) ); |
|
| 226 | + } else { |
|
| 227 | + $last = 0; |
|
| 228 | + } |
|
| 229 | + $opt_key = $last + 1; |
|
| 230 | 230 | |
| 231 | - if ( 'other' == $opt_type ) { |
|
| 231 | + if ( 'other' == $opt_type ) { |
|
| 232 | 232 | $opt = esc_html__( 'Other', 'formidable' ); |
| 233 | - $other_val = ''; |
|
| 234 | - $opt_key = 'other_' . $opt_key; |
|
| 235 | - |
|
| 236 | - //Update value of "other" in DB |
|
| 237 | - $field_options = maybe_unserialize( $field->field_options ); |
|
| 238 | - $field_options['other'] = 1; |
|
| 239 | - FrmField::update( $id, array( 'field_options' => maybe_serialize( $field_options ) ) ); |
|
| 240 | - } else { |
|
| 233 | + $other_val = ''; |
|
| 234 | + $opt_key = 'other_' . $opt_key; |
|
| 235 | + |
|
| 236 | + //Update value of "other" in DB |
|
| 237 | + $field_options = maybe_unserialize( $field->field_options ); |
|
| 238 | + $field_options['other'] = 1; |
|
| 239 | + FrmField::update( $id, array( 'field_options' => maybe_serialize( $field_options ) ) ); |
|
| 240 | + } else { |
|
| 241 | 241 | $first_opt = reset( $field->options ); |
| 242 | 242 | $next_opt = count( $field->options ); |
| 243 | - if ( $first_opt != '' ) { |
|
| 244 | - $next_opt++; |
|
| 245 | - } |
|
| 243 | + if ( $first_opt != '' ) { |
|
| 244 | + $next_opt++; |
|
| 245 | + } |
|
| 246 | 246 | $opt = esc_html__( 'Option', 'formidable' ) . ' ' . $next_opt; |
| 247 | - unset($next_opt); |
|
| 248 | - } |
|
| 249 | - $field_val = $opt; |
|
| 247 | + unset($next_opt); |
|
| 248 | + } |
|
| 249 | + $field_val = $opt; |
|
| 250 | 250 | $field->options[ $opt_key ] = $opt; |
| 251 | 251 | |
| 252 | - //Update options in DB |
|
| 252 | + //Update options in DB |
|
| 253 | 253 | FrmField::update( $id, array( 'options' => $field->options ) ); |
| 254 | 254 | |
| 255 | - $field_data = $field; |
|
| 256 | - $field = array( |
|
| 257 | - 'type' => $field_data->type, |
|
| 258 | - 'id' => $id, |
|
| 259 | - 'separate_value' => isset($field_data->field_options['separate_value']) ? $field_data->field_options['separate_value'] : 0, |
|
| 260 | - 'form_id' => $field_data->form_id, |
|
| 261 | - 'field_key' => $field_data->field_key, |
|
| 262 | - ); |
|
| 255 | + $field_data = $field; |
|
| 256 | + $field = array( |
|
| 257 | + 'type' => $field_data->type, |
|
| 258 | + 'id' => $id, |
|
| 259 | + 'separate_value' => isset($field_data->field_options['separate_value']) ? $field_data->field_options['separate_value'] : 0, |
|
| 260 | + 'form_id' => $field_data->form_id, |
|
| 261 | + 'field_key' => $field_data->field_key, |
|
| 262 | + ); |
|
| 263 | 263 | |
| 264 | 264 | $field_name = 'item_meta[' . $id . ']'; |
| 265 | - $html_id = FrmFieldsHelper::get_html_id($field); |
|
| 266 | - $checked = ''; |
|
| 265 | + $html_id = FrmFieldsHelper::get_html_id($field); |
|
| 266 | + $checked = ''; |
|
| 267 | 267 | |
| 268 | - if ( 'other' == $opt_type ) { |
|
| 268 | + if ( 'other' == $opt_type ) { |
|
| 269 | 269 | require( FrmAppHelper::plugin_path() . '/pro/classes/views/frmpro-fields/other-option.php' ); |
| 270 | - } else { |
|
| 270 | + } else { |
|
| 271 | 271 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/single-option.php' ); |
| 272 | - } |
|
| 273 | - wp_die(); |
|
| 274 | - } |
|
| 272 | + } |
|
| 273 | + wp_die(); |
|
| 274 | + } |
|
| 275 | 275 | |
| 276 | - public static function edit_option() { |
|
| 276 | + public static function edit_option() { |
|
| 277 | 277 | FrmAppHelper::permission_check('frm_edit_forms'); |
| 278 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 278 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 279 | 279 | |
| 280 | 280 | $element_id = FrmAppHelper::get_post_param( 'element_id', '', 'sanitize_title' ); |
| 281 | 281 | $ids = explode( '-', $element_id ); |
@@ -283,43 +283,43 @@ discard block |
||
| 283 | 283 | |
| 284 | 284 | $orig_update_value = $update_value = trim( FrmAppHelper::get_post_param( 'update_value', '', 'wp_kses_post' ) ); |
| 285 | 285 | if ( strpos( $element_id, 'key_' ) ) { |
| 286 | - $new_value = $update_value; |
|
| 287 | - } else { |
|
| 288 | - $new_label = $update_value; |
|
| 289 | - } |
|
| 286 | + $new_value = $update_value; |
|
| 287 | + } else { |
|
| 288 | + $new_label = $update_value; |
|
| 289 | + } |
|
| 290 | 290 | |
| 291 | - $field = FrmField::getOne($id); |
|
| 292 | - $separate_values = FrmField::is_option_true( $field, 'separate_value' ); |
|
| 291 | + $field = FrmField::getOne($id); |
|
| 292 | + $separate_values = FrmField::is_option_true( $field, 'separate_value' ); |
|
| 293 | 293 | |
| 294 | - $this_opt_id = end($ids); |
|
| 294 | + $this_opt_id = end($ids); |
|
| 295 | 295 | $this_opt = (array) $field->options[ $this_opt_id ]; |
| 296 | 296 | $other_opt = ( $this_opt_id && strpos( $this_opt_id, 'other') !== false ); |
| 297 | 297 | |
| 298 | - $label = isset($this_opt['label']) ? $this_opt['label'] : reset($this_opt); |
|
| 299 | - $value = isset($this_opt['value']) ? $this_opt['value'] : ''; |
|
| 298 | + $label = isset($this_opt['label']) ? $this_opt['label'] : reset($this_opt); |
|
| 299 | + $value = isset($this_opt['value']) ? $this_opt['value'] : ''; |
|
| 300 | 300 | |
| 301 | - if ( ! isset( $new_label ) ) { |
|
| 302 | - $new_label = $label; |
|
| 303 | - } |
|
| 301 | + if ( ! isset( $new_label ) ) { |
|
| 302 | + $new_label = $label; |
|
| 303 | + } |
|
| 304 | 304 | |
| 305 | - if ( isset($new_value) || isset($value) ) { |
|
| 306 | - $update_value = isset($new_value) ? $new_value : $value; |
|
| 307 | - } |
|
| 305 | + if ( isset($new_value) || isset($value) ) { |
|
| 306 | + $update_value = isset($new_value) ? $new_value : $value; |
|
| 307 | + } |
|
| 308 | 308 | |
| 309 | 309 | if ( $update_value != $new_label && $other_opt === false && $separate_values ) { |
| 310 | 310 | $field->options[ $this_opt_id ] = array( 'value' => $update_value, 'label' => $new_label ); |
| 311 | - } else { |
|
| 311 | + } else { |
|
| 312 | 312 | $field->options[ $this_opt_id ] = $orig_update_value; |
| 313 | - } |
|
| 313 | + } |
|
| 314 | 314 | |
| 315 | 315 | FrmField::update( $field->id, array( 'options' => $field->options ) ); |
| 316 | 316 | echo ( $orig_update_value == '' ) ? esc_html__( '(Blank)', 'formidable' ) : stripslashes( $orig_update_value ); |
| 317 | - wp_die(); |
|
| 318 | - } |
|
| 317 | + wp_die(); |
|
| 318 | + } |
|
| 319 | 319 | |
| 320 | - public static function delete_option() { |
|
| 320 | + public static function delete_option() { |
|
| 321 | 321 | FrmAppHelper::permission_check('frm_edit_forms'); |
| 322 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 322 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 323 | 323 | |
| 324 | 324 | $field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' ); |
| 325 | 325 | $field = FrmField::getOne( $field_id ); |
@@ -327,313 +327,313 @@ discard block |
||
| 327 | 327 | $opt_key = FrmAppHelper::get_post_param( 'opt_key', 0, 'sanitize_title' ); |
| 328 | 328 | |
| 329 | 329 | $options = $field->options; |
| 330 | - unset( $options[ $opt_key ] ); |
|
| 331 | - $response = array( 'other' => true ); |
|
| 330 | + unset( $options[ $opt_key ] ); |
|
| 331 | + $response = array( 'other' => true ); |
|
| 332 | 332 | |
| 333 | - //If the deleted option is an "other" option |
|
| 333 | + //If the deleted option is an "other" option |
|
| 334 | 334 | if ( FrmFieldsHelper::is_other_opt( $opt_key ) ) { |
| 335 | - //Assume all other options are gone, unless proven otherwise |
|
| 336 | - $other = false; |
|
| 335 | + //Assume all other options are gone, unless proven otherwise |
|
| 336 | + $other = false; |
|
| 337 | 337 | |
| 338 | - //Check if all other options are really gone |
|
| 339 | - foreach ( $options as $o_key => $o_val ) { |
|
| 340 | - //If there is still an other option in the field, set other to true |
|
| 338 | + //Check if all other options are really gone |
|
| 339 | + foreach ( $options as $o_key => $o_val ) { |
|
| 340 | + //If there is still an other option in the field, set other to true |
|
| 341 | 341 | if ( FrmFieldsHelper::is_other_opt( $o_key ) ) { |
| 342 | - $other = true; |
|
| 343 | - break; |
|
| 344 | - } |
|
| 345 | - unset( $o_key, $o_val ); |
|
| 346 | - } |
|
| 347 | - |
|
| 348 | - //If all other options are gone |
|
| 349 | - if ( false === $other ) { |
|
| 350 | - $field_options = maybe_unserialize( $field->field_options ); |
|
| 351 | - $field_options['other'] = 0; |
|
| 342 | + $other = true; |
|
| 343 | + break; |
|
| 344 | + } |
|
| 345 | + unset( $o_key, $o_val ); |
|
| 346 | + } |
|
| 347 | + |
|
| 348 | + //If all other options are gone |
|
| 349 | + if ( false === $other ) { |
|
| 350 | + $field_options = maybe_unserialize( $field->field_options ); |
|
| 351 | + $field_options['other'] = 0; |
|
| 352 | 352 | FrmField::update( $field_id, array( 'field_options' => maybe_serialize( $field_options ) ) ); |
| 353 | - $response = array( 'other' => false ); |
|
| 354 | - } |
|
| 355 | - } |
|
| 356 | - echo json_encode( $response ); |
|
| 353 | + $response = array( 'other' => false ); |
|
| 354 | + } |
|
| 355 | + } |
|
| 356 | + echo json_encode( $response ); |
|
| 357 | 357 | |
| 358 | 358 | FrmField::update( $field_id, array( 'options' => maybe_serialize( $options ) ) ); |
| 359 | 359 | |
| 360 | - wp_die(); |
|
| 361 | - } |
|
| 360 | + wp_die(); |
|
| 361 | + } |
|
| 362 | 362 | |
| 363 | - public static function import_choices() { |
|
| 364 | - FrmAppHelper::permission_check( 'frm_edit_forms', 'hide' ); |
|
| 363 | + public static function import_choices() { |
|
| 364 | + FrmAppHelper::permission_check( 'frm_edit_forms', 'hide' ); |
|
| 365 | 365 | |
| 366 | 366 | $field_id = absint( $_REQUEST['field_id'] ); |
| 367 | 367 | |
| 368 | - global $current_screen, $hook_suffix; |
|
| 368 | + global $current_screen, $hook_suffix; |
|
| 369 | 369 | |
| 370 | - // Catch plugins that include admin-header.php before admin.php completes. |
|
| 371 | - if ( empty( $current_screen ) && function_exists( 'set_current_screen' ) ) { |
|
| 372 | - $hook_suffix = ''; |
|
| 373 | - set_current_screen(); |
|
| 374 | - } |
|
| 370 | + // Catch plugins that include admin-header.php before admin.php completes. |
|
| 371 | + if ( empty( $current_screen ) && function_exists( 'set_current_screen' ) ) { |
|
| 372 | + $hook_suffix = ''; |
|
| 373 | + set_current_screen(); |
|
| 374 | + } |
|
| 375 | 375 | |
| 376 | - if ( function_exists( 'register_admin_color_schemes' ) ) { |
|
| 377 | - register_admin_color_schemes(); |
|
| 378 | - } |
|
| 376 | + if ( function_exists( 'register_admin_color_schemes' ) ) { |
|
| 377 | + register_admin_color_schemes(); |
|
| 378 | + } |
|
| 379 | 379 | |
| 380 | - $hook_suffix = $admin_body_class = ''; |
|
| 380 | + $hook_suffix = $admin_body_class = ''; |
|
| 381 | 381 | |
| 382 | - if ( get_user_setting( 'mfold' ) == 'f' ) { |
|
| 383 | - $admin_body_class .= ' folded'; |
|
| 384 | - } |
|
| 382 | + if ( get_user_setting( 'mfold' ) == 'f' ) { |
|
| 383 | + $admin_body_class .= ' folded'; |
|
| 384 | + } |
|
| 385 | 385 | |
| 386 | - if ( function_exists( 'is_admin_bar_showing' ) && is_admin_bar_showing() ) { |
|
| 387 | - $admin_body_class .= ' admin-bar'; |
|
| 388 | - } |
|
| 386 | + if ( function_exists( 'is_admin_bar_showing' ) && is_admin_bar_showing() ) { |
|
| 387 | + $admin_body_class .= ' admin-bar'; |
|
| 388 | + } |
|
| 389 | 389 | |
| 390 | - if ( is_rtl() ) { |
|
| 391 | - $admin_body_class .= ' rtl'; |
|
| 392 | - } |
|
| 390 | + if ( is_rtl() ) { |
|
| 391 | + $admin_body_class .= ' rtl'; |
|
| 392 | + } |
|
| 393 | 393 | |
| 394 | - $admin_body_class .= ' admin-color-' . sanitize_html_class( get_user_option( 'admin_color' ), 'fresh' ); |
|
| 395 | - $prepop = array(); |
|
| 396 | - FrmFieldsHelper::get_bulk_prefilled_opts($prepop); |
|
| 394 | + $admin_body_class .= ' admin-color-' . sanitize_html_class( get_user_option( 'admin_color' ), 'fresh' ); |
|
| 395 | + $prepop = array(); |
|
| 396 | + FrmFieldsHelper::get_bulk_prefilled_opts($prepop); |
|
| 397 | 397 | |
| 398 | - $field = FrmField::getOne($field_id); |
|
| 398 | + $field = FrmField::getOne($field_id); |
|
| 399 | 399 | |
| 400 | - wp_enqueue_script( 'utils' ); |
|
| 400 | + wp_enqueue_script( 'utils' ); |
|
| 401 | 401 | wp_enqueue_style( 'formidable-admin', FrmAppHelper::plugin_url() . '/css/frm_admin.css' ); |
| 402 | - FrmAppHelper::load_admin_wide_js(); |
|
| 402 | + FrmAppHelper::load_admin_wide_js(); |
|
| 403 | 403 | |
| 404 | 404 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/import_choices.php' ); |
| 405 | - wp_die(); |
|
| 406 | - } |
|
| 405 | + wp_die(); |
|
| 406 | + } |
|
| 407 | 407 | |
| 408 | - public static function import_options() { |
|
| 408 | + public static function import_options() { |
|
| 409 | 409 | FrmAppHelper::permission_check('frm_edit_forms'); |
| 410 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 410 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 411 | 411 | |
| 412 | - if ( ! is_admin() || ! current_user_can('frm_edit_forms') ) { |
|
| 413 | - return; |
|
| 414 | - } |
|
| 412 | + if ( ! is_admin() || ! current_user_can('frm_edit_forms') ) { |
|
| 413 | + return; |
|
| 414 | + } |
|
| 415 | 415 | |
| 416 | 416 | $field_id = absint( $_POST['field_id'] ); |
| 417 | - $field = FrmField::getOne($field_id); |
|
| 417 | + $field = FrmField::getOne($field_id); |
|
| 418 | 418 | |
| 419 | 419 | if ( ! in_array( $field->type, array( 'radio', 'checkbox', 'select' ) ) ) { |
| 420 | - return; |
|
| 421 | - } |
|
| 420 | + return; |
|
| 421 | + } |
|
| 422 | 422 | |
| 423 | - $field = FrmFieldsHelper::setup_edit_vars($field); |
|
| 423 | + $field = FrmFieldsHelper::setup_edit_vars($field); |
|
| 424 | 424 | $opts = FrmAppHelper::get_param( 'opts', '', 'post', 'wp_kses_post' ); |
| 425 | 425 | $opts = explode( "\n", rtrim( $opts, "\n" ) ); |
| 426 | 426 | $opts = array_map( 'trim', $opts ); |
| 427 | 427 | |
| 428 | - if ( $field['separate_value'] ) { |
|
| 429 | - foreach ( $opts as $opt_key => $opt ) { |
|
| 430 | - if ( strpos($opt, '|') !== false ) { |
|
| 431 | - $vals = explode('|', $opt); |
|
| 432 | - if ( $vals[0] != $vals[1] ) { |
|
| 433 | - $opts[ $opt_key ] = array( 'label' => trim( $vals[0] ), 'value' => trim( $vals[1] ) ); |
|
| 434 | - } |
|
| 435 | - unset($vals); |
|
| 436 | - } |
|
| 437 | - unset($opt_key, $opt); |
|
| 438 | - } |
|
| 439 | - } |
|
| 440 | - |
|
| 441 | - //Keep other options after bulk update |
|
| 442 | - if ( isset( $field['field_options']['other'] ) && $field['field_options']['other'] == true ) { |
|
| 443 | - $other_array = array(); |
|
| 444 | - foreach ( $field['options'] as $opt_key => $opt ) { |
|
| 445 | - if ( $opt_key && strpos( $opt_key, 'other' ) !== false ) { |
|
| 446 | - $other_array[ $opt_key ] = $opt; |
|
| 447 | - } |
|
| 448 | - unset($opt_key, $opt); |
|
| 449 | - } |
|
| 450 | - if ( ! empty($other_array) ) { |
|
| 451 | - $opts = array_merge( $opts, $other_array); |
|
| 452 | - } |
|
| 453 | - } |
|
| 454 | - |
|
| 455 | - FrmField::update( $field_id, array( 'options' => maybe_serialize( $opts ) ) ); |
|
| 456 | - |
|
| 457 | - $field['options'] = $opts; |
|
| 458 | - $field_name = $field['name']; |
|
| 459 | - |
|
| 460 | - // Get html_id which will be used in single-option.php |
|
| 461 | - $html_id = FrmFieldsHelper::get_html_id( $field ); |
|
| 462 | - |
|
| 463 | - if ( $field['type'] == 'radio' || $field['type'] == 'checkbox' ) { |
|
| 428 | + if ( $field['separate_value'] ) { |
|
| 429 | + foreach ( $opts as $opt_key => $opt ) { |
|
| 430 | + if ( strpos($opt, '|') !== false ) { |
|
| 431 | + $vals = explode('|', $opt); |
|
| 432 | + if ( $vals[0] != $vals[1] ) { |
|
| 433 | + $opts[ $opt_key ] = array( 'label' => trim( $vals[0] ), 'value' => trim( $vals[1] ) ); |
|
| 434 | + } |
|
| 435 | + unset($vals); |
|
| 436 | + } |
|
| 437 | + unset($opt_key, $opt); |
|
| 438 | + } |
|
| 439 | + } |
|
| 440 | + |
|
| 441 | + //Keep other options after bulk update |
|
| 442 | + if ( isset( $field['field_options']['other'] ) && $field['field_options']['other'] == true ) { |
|
| 443 | + $other_array = array(); |
|
| 444 | + foreach ( $field['options'] as $opt_key => $opt ) { |
|
| 445 | + if ( $opt_key && strpos( $opt_key, 'other' ) !== false ) { |
|
| 446 | + $other_array[ $opt_key ] = $opt; |
|
| 447 | + } |
|
| 448 | + unset($opt_key, $opt); |
|
| 449 | + } |
|
| 450 | + if ( ! empty($other_array) ) { |
|
| 451 | + $opts = array_merge( $opts, $other_array); |
|
| 452 | + } |
|
| 453 | + } |
|
| 454 | + |
|
| 455 | + FrmField::update( $field_id, array( 'options' => maybe_serialize( $opts ) ) ); |
|
| 456 | + |
|
| 457 | + $field['options'] = $opts; |
|
| 458 | + $field_name = $field['name']; |
|
| 459 | + |
|
| 460 | + // Get html_id which will be used in single-option.php |
|
| 461 | + $html_id = FrmFieldsHelper::get_html_id( $field ); |
|
| 462 | + |
|
| 463 | + if ( $field['type'] == 'radio' || $field['type'] == 'checkbox' ) { |
|
| 464 | 464 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/radio.php' ); |
| 465 | - } else { |
|
| 466 | - FrmFieldsHelper::show_single_option($field); |
|
| 467 | - } |
|
| 465 | + } else { |
|
| 466 | + FrmFieldsHelper::show_single_option($field); |
|
| 467 | + } |
|
| 468 | 468 | |
| 469 | - wp_die(); |
|
| 470 | - } |
|
| 469 | + wp_die(); |
|
| 470 | + } |
|
| 471 | 471 | |
| 472 | - public static function update_order() { |
|
| 472 | + public static function update_order() { |
|
| 473 | 473 | FrmAppHelper::permission_check('frm_edit_forms'); |
| 474 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 474 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 475 | 475 | |
| 476 | 476 | $fields = FrmAppHelper::get_post_param( 'frm_field_id' ); |
| 477 | 477 | foreach ( (array) $fields as $position => $item ) { |
| 478 | 478 | FrmField::update( absint( $item ), array( 'field_order' => absint( $position ) ) ); |
| 479 | 479 | } |
| 480 | - wp_die(); |
|
| 481 | - } |
|
| 480 | + wp_die(); |
|
| 481 | + } |
|
| 482 | 482 | |
| 483 | 483 | public static function change_type( $type ) { |
| 484 | - $type_switch = array( |
|
| 485 | - 'scale' => 'radio', |
|
| 486 | - '10radio' => 'radio', |
|
| 487 | - 'rte' => 'textarea', |
|
| 488 | - 'website' => 'url', |
|
| 489 | - ); |
|
| 490 | - if ( isset( $type_switch[ $type ] ) ) { |
|
| 491 | - $type = $type_switch[ $type ]; |
|
| 492 | - } |
|
| 484 | + $type_switch = array( |
|
| 485 | + 'scale' => 'radio', |
|
| 486 | + '10radio' => 'radio', |
|
| 487 | + 'rte' => 'textarea', |
|
| 488 | + 'website' => 'url', |
|
| 489 | + ); |
|
| 490 | + if ( isset( $type_switch[ $type ] ) ) { |
|
| 491 | + $type = $type_switch[ $type ]; |
|
| 492 | + } |
|
| 493 | 493 | |
| 494 | 494 | $frm_field_selection = FrmField::field_selection(); |
| 495 | - $types = array_keys($frm_field_selection); |
|
| 496 | - if ( ! in_array($type, $types) && $type != 'captcha' ) { |
|
| 497 | - $type = 'text'; |
|
| 498 | - } |
|
| 495 | + $types = array_keys($frm_field_selection); |
|
| 496 | + if ( ! in_array($type, $types) && $type != 'captcha' ) { |
|
| 497 | + $type = 'text'; |
|
| 498 | + } |
|
| 499 | 499 | |
| 500 | - return $type; |
|
| 501 | - } |
|
| 500 | + return $type; |
|
| 501 | + } |
|
| 502 | 502 | |
| 503 | 503 | public static function display_field_options( $display ) { |
| 504 | 504 | switch ( $display['type'] ) { |
| 505 | - case 'captcha': |
|
| 506 | - $display['required'] = false; |
|
| 507 | - $display['invalid'] = true; |
|
| 508 | - $display['default_blank'] = false; |
|
| 505 | + case 'captcha': |
|
| 506 | + $display['required'] = false; |
|
| 507 | + $display['invalid'] = true; |
|
| 508 | + $display['default_blank'] = false; |
|
| 509 | 509 | $display['captcha_size'] = true; |
| 510 | - break; |
|
| 511 | - case 'radio': |
|
| 512 | - $display['default_blank'] = false; |
|
| 513 | - break; |
|
| 514 | - case 'text': |
|
| 515 | - case 'textarea': |
|
| 516 | - $display['size'] = true; |
|
| 517 | - $display['clear_on_focus'] = true; |
|
| 518 | - break; |
|
| 519 | - case 'select': |
|
| 520 | - $display['size'] = true; |
|
| 521 | - break; |
|
| 522 | - case 'url': |
|
| 523 | - case 'website': |
|
| 524 | - case 'email': |
|
| 525 | - $display['size'] = true; |
|
| 526 | - $display['clear_on_focus'] = true; |
|
| 527 | - $display['invalid'] = true; |
|
| 528 | - } |
|
| 529 | - |
|
| 530 | - return $display; |
|
| 531 | - } |
|
| 532 | - |
|
| 533 | - public static function input_html( $field, $echo = true ) { |
|
| 534 | - $class = array(); //$field['type']; |
|
| 535 | - self::add_input_classes($field, $class); |
|
| 536 | - |
|
| 537 | - $add_html = array(); |
|
| 538 | - self::add_html_size($field, $add_html); |
|
| 539 | - self::add_html_length($field, $add_html); |
|
| 540 | - self::add_html_placeholder($field, $add_html, $class); |
|
| 510 | + break; |
|
| 511 | + case 'radio': |
|
| 512 | + $display['default_blank'] = false; |
|
| 513 | + break; |
|
| 514 | + case 'text': |
|
| 515 | + case 'textarea': |
|
| 516 | + $display['size'] = true; |
|
| 517 | + $display['clear_on_focus'] = true; |
|
| 518 | + break; |
|
| 519 | + case 'select': |
|
| 520 | + $display['size'] = true; |
|
| 521 | + break; |
|
| 522 | + case 'url': |
|
| 523 | + case 'website': |
|
| 524 | + case 'email': |
|
| 525 | + $display['size'] = true; |
|
| 526 | + $display['clear_on_focus'] = true; |
|
| 527 | + $display['invalid'] = true; |
|
| 528 | + } |
|
| 529 | + |
|
| 530 | + return $display; |
|
| 531 | + } |
|
| 532 | + |
|
| 533 | + public static function input_html( $field, $echo = true ) { |
|
| 534 | + $class = array(); //$field['type']; |
|
| 535 | + self::add_input_classes($field, $class); |
|
| 536 | + |
|
| 537 | + $add_html = array(); |
|
| 538 | + self::add_html_size($field, $add_html); |
|
| 539 | + self::add_html_length($field, $add_html); |
|
| 540 | + self::add_html_placeholder($field, $add_html, $class); |
|
| 541 | 541 | self::add_validation_messages( $field, $add_html ); |
| 542 | 542 | |
| 543 | - $class = apply_filters('frm_field_classes', implode(' ', $class), $field); |
|
| 543 | + $class = apply_filters('frm_field_classes', implode(' ', $class), $field); |
|
| 544 | 544 | |
| 545 | 545 | FrmFormsHelper::add_html_attr( $class, 'class', $add_html ); |
| 546 | 546 | |
| 547 | - self::add_shortcodes_to_html($field, $add_html); |
|
| 547 | + self::add_shortcodes_to_html($field, $add_html); |
|
| 548 | 548 | |
| 549 | 549 | $add_html = apply_filters( 'frm_field_extra_html', $add_html, $field ); |
| 550 | 550 | $add_html = ' ' . implode( ' ', $add_html ) . ' '; |
| 551 | 551 | |
| 552 | - if ( $echo ) { |
|
| 553 | - echo $add_html; |
|
| 554 | - } |
|
| 552 | + if ( $echo ) { |
|
| 553 | + echo $add_html; |
|
| 554 | + } |
|
| 555 | 555 | |
| 556 | - return $add_html; |
|
| 557 | - } |
|
| 556 | + return $add_html; |
|
| 557 | + } |
|
| 558 | 558 | |
| 559 | 559 | private static function add_input_classes( $field, array &$class ) { |
| 560 | - if ( isset($field['input_class']) && ! empty($field['input_class']) ) { |
|
| 561 | - $class[] = $field['input_class']; |
|
| 562 | - } |
|
| 560 | + if ( isset($field['input_class']) && ! empty($field['input_class']) ) { |
|
| 561 | + $class[] = $field['input_class']; |
|
| 562 | + } |
|
| 563 | 563 | |
| 564 | - if ( $field['type'] == 'hidden' || $field['type'] == 'user_id' ) { |
|
| 565 | - return; |
|
| 566 | - } |
|
| 564 | + if ( $field['type'] == 'hidden' || $field['type'] == 'user_id' ) { |
|
| 565 | + return; |
|
| 566 | + } |
|
| 567 | 567 | |
| 568 | - global $frm_vars; |
|
| 568 | + global $frm_vars; |
|
| 569 | 569 | if ( is_admin() && ! FrmAppHelper::is_preview_page() && ! in_array( $field['type'], array( 'scale', 'radio', 'checkbox', 'data', 'lookup' ) ) ) { |
| 570 | 570 | // Add the dyn_default_value class to some field inputs on form builder page |
| 571 | - $class[] = 'dyn_default_value'; |
|
| 572 | - } |
|
| 571 | + $class[] = 'dyn_default_value'; |
|
| 572 | + } |
|
| 573 | 573 | |
| 574 | - if ( isset($field['size']) && $field['size'] > 0 ) { |
|
| 575 | - $class[] = 'auto_width'; |
|
| 576 | - } |
|
| 577 | - } |
|
| 574 | + if ( isset($field['size']) && $field['size'] > 0 ) { |
|
| 575 | + $class[] = 'auto_width'; |
|
| 576 | + } |
|
| 577 | + } |
|
| 578 | 578 | |
| 579 | 579 | private static function add_html_size( $field, array &$add_html ) { |
| 580 | 580 | if ( ! isset( $field['size'] ) || $field['size'] <= 0 || in_array( $field['type'], array( 'select', 'data', 'time', 'hidden', 'lookup' ) ) ) { |
| 581 | - return; |
|
| 582 | - } |
|
| 581 | + return; |
|
| 582 | + } |
|
| 583 | 583 | |
| 584 | - if ( FrmAppHelper::is_admin_page('formidable' ) ) { |
|
| 585 | - return; |
|
| 586 | - } |
|
| 584 | + if ( FrmAppHelper::is_admin_page('formidable' ) ) { |
|
| 585 | + return; |
|
| 586 | + } |
|
| 587 | 587 | |
| 588 | - if ( is_numeric($field['size']) ) { |
|
| 589 | - $field['size'] .= 'px'; |
|
| 590 | - } |
|
| 588 | + if ( is_numeric($field['size']) ) { |
|
| 589 | + $field['size'] .= 'px'; |
|
| 590 | + } |
|
| 591 | 591 | |
| 592 | - $important = apply_filters('frm_use_important_width', 1, $field); |
|
| 593 | - // Note: This inline styling must stay since we cannot realistically set a class for every possible field size |
|
| 592 | + $important = apply_filters('frm_use_important_width', 1, $field); |
|
| 593 | + // Note: This inline styling must stay since we cannot realistically set a class for every possible field size |
|
| 594 | 594 | $add_html['style'] = 'style="width:' . esc_attr( $field['size'] ) . ( $important ? ' !important' : '' ) . '"'; |
| 595 | 595 | |
| 596 | - self::add_html_cols($field, $add_html); |
|
| 597 | - } |
|
| 596 | + self::add_html_cols($field, $add_html); |
|
| 597 | + } |
|
| 598 | 598 | |
| 599 | 599 | private static function add_html_cols( $field, array &$add_html ) { |
| 600 | 600 | if ( ! in_array( $field['type'], array( 'textarea', 'rte' ) ) ) { |
| 601 | - return; |
|
| 602 | - } |
|
| 601 | + return; |
|
| 602 | + } |
|
| 603 | 603 | |
| 604 | - // convert to cols for textareas |
|
| 605 | - $calc = array( |
|
| 606 | - '' => 9, |
|
| 607 | - 'px' => 9, |
|
| 608 | - 'rem' => 0.444, |
|
| 609 | - 'em' => 0.544, |
|
| 610 | - ); |
|
| 604 | + // convert to cols for textareas |
|
| 605 | + $calc = array( |
|
| 606 | + '' => 9, |
|
| 607 | + 'px' => 9, |
|
| 608 | + 'rem' => 0.444, |
|
| 609 | + 'em' => 0.544, |
|
| 610 | + ); |
|
| 611 | 611 | |
| 612 | - // include "col" for valid html |
|
| 613 | - $unit = trim(preg_replace('/[0-9]+/', '', $field['size'])); |
|
| 612 | + // include "col" for valid html |
|
| 613 | + $unit = trim(preg_replace('/[0-9]+/', '', $field['size'])); |
|
| 614 | 614 | |
| 615 | - if ( ! isset( $calc[ $unit ] ) ) { |
|
| 616 | - return; |
|
| 617 | - } |
|
| 615 | + if ( ! isset( $calc[ $unit ] ) ) { |
|
| 616 | + return; |
|
| 617 | + } |
|
| 618 | 618 | |
| 619 | - $size = (float) str_replace( $unit, '', $field['size'] ) / $calc[ $unit ]; |
|
| 619 | + $size = (float) str_replace( $unit, '', $field['size'] ) / $calc[ $unit ]; |
|
| 620 | 620 | |
| 621 | 621 | $add_html['cols'] = 'cols="' . absint( $size ) . '"'; |
| 622 | - } |
|
| 622 | + } |
|
| 623 | 623 | |
| 624 | 624 | private static function add_html_length( $field, array &$add_html ) { |
| 625 | - // check for max setting and if this field accepts maxlength |
|
| 625 | + // check for max setting and if this field accepts maxlength |
|
| 626 | 626 | if ( FrmField::is_option_empty( $field, 'max' ) || in_array( $field['type'], array( 'textarea', 'rte', 'hidden' ) ) ) { |
| 627 | - return; |
|
| 628 | - } |
|
| 627 | + return; |
|
| 628 | + } |
|
| 629 | 629 | |
| 630 | - if ( FrmAppHelper::is_admin_page('formidable' ) ) { |
|
| 631 | - // don't load on form builder page |
|
| 632 | - return; |
|
| 633 | - } |
|
| 630 | + if ( FrmAppHelper::is_admin_page('formidable' ) ) { |
|
| 631 | + // don't load on form builder page |
|
| 632 | + return; |
|
| 633 | + } |
|
| 634 | 634 | |
| 635 | 635 | $add_html['maxlength'] = 'maxlength="' . esc_attr( $field['max'] ) . '"'; |
| 636 | - } |
|
| 636 | + } |
|
| 637 | 637 | |
| 638 | 638 | private static function add_html_placeholder( $field, array &$add_html, array &$class ) { |
| 639 | 639 | if ( empty( $field['default_value'] ) || FrmAppHelper::is_admin_page( 'formidable' ) ) { |
@@ -641,35 +641,35 @@ discard block |
||
| 641 | 641 | } |
| 642 | 642 | |
| 643 | 643 | $default_value_array = is_array( $field['default_value'] ); |
| 644 | - if ( ! FrmField::is_option_true( $field, 'clear_on_focus' ) ) { |
|
| 644 | + if ( ! FrmField::is_option_true( $field, 'clear_on_focus' ) ) { |
|
| 645 | 645 | if ( $default_value_array ) { |
| 646 | 646 | $field['default_value'] = json_encode( $field['default_value'] ); |
| 647 | 647 | } |
| 648 | 648 | $add_html['data-frmval'] = 'data-frmval="' . esc_attr( $field['default_value'] ) . '"'; |
| 649 | - return; |
|
| 650 | - } |
|
| 649 | + return; |
|
| 650 | + } |
|
| 651 | 651 | |
| 652 | 652 | if ( $default_value_array ) { |
| 653 | 653 | // don't include a json placeholder |
| 654 | 654 | return; |
| 655 | 655 | } |
| 656 | 656 | |
| 657 | - $frm_settings = FrmAppHelper::get_settings(); |
|
| 657 | + $frm_settings = FrmAppHelper::get_settings(); |
|
| 658 | 658 | |
| 659 | 659 | if ( $frm_settings->use_html && ! in_array( $field['type'], array( 'select', 'radio', 'checkbox', 'hidden' ) ) ) { |
| 660 | - // use HMTL5 placeholder with js fallback |
|
| 660 | + // use HMTL5 placeholder with js fallback |
|
| 661 | 661 | $add_html['placeholder'] = 'placeholder="' . esc_attr( $field['default_value'] ) . '"'; |
| 662 | - wp_enqueue_script('jquery-placeholder'); |
|
| 663 | - } else if ( ! $frm_settings->use_html ) { |
|
| 662 | + wp_enqueue_script('jquery-placeholder'); |
|
| 663 | + } else if ( ! $frm_settings->use_html ) { |
|
| 664 | 664 | $val = str_replace( array( "\r\n", "\n" ), '\r', addslashes( str_replace( ''', "'", esc_attr( $field['default_value'] ) ) ) ); |
| 665 | 665 | $add_html['data-frmval'] = 'data-frmval="' . esc_attr( $val ) . '"'; |
| 666 | - $class[] = 'frm_toggle_default'; |
|
| 666 | + $class[] = 'frm_toggle_default'; |
|
| 667 | 667 | |
| 668 | - if ( $field['value'] == $field['default_value'] ) { |
|
| 669 | - $class[] = 'frm_default'; |
|
| 670 | - } |
|
| 671 | - } |
|
| 672 | - } |
|
| 668 | + if ( $field['value'] == $field['default_value'] ) { |
|
| 669 | + $class[] = 'frm_default'; |
|
| 670 | + } |
|
| 671 | + } |
|
| 672 | + } |
|
| 673 | 673 | |
| 674 | 674 | private static function add_validation_messages( $field, array &$add_html ) { |
| 675 | 675 | if ( FrmField::is_required( $field ) ) { |
@@ -690,44 +690,44 @@ discard block |
||
| 690 | 690 | } |
| 691 | 691 | } |
| 692 | 692 | |
| 693 | - private static function add_shortcodes_to_html( $field, array &$add_html ) { |
|
| 694 | - if ( FrmField::is_option_empty( $field, 'shortcodes' ) ) { |
|
| 695 | - return; |
|
| 696 | - } |
|
| 693 | + private static function add_shortcodes_to_html( $field, array &$add_html ) { |
|
| 694 | + if ( FrmField::is_option_empty( $field, 'shortcodes' ) ) { |
|
| 695 | + return; |
|
| 696 | + } |
|
| 697 | 697 | |
| 698 | - foreach ( $field['shortcodes'] as $k => $v ) { |
|
| 699 | - if ( 'opt' === $k ) { |
|
| 700 | - continue; |
|
| 701 | - } |
|
| 698 | + foreach ( $field['shortcodes'] as $k => $v ) { |
|
| 699 | + if ( 'opt' === $k ) { |
|
| 700 | + continue; |
|
| 701 | + } |
|
| 702 | 702 | |
| 703 | - if ( is_numeric($k) && strpos($v, '=') ) { |
|
| 704 | - $add_html[] = $v; |
|
| 705 | - } else if ( ! empty( $k ) && isset( $add_html[ $k ] ) ) { |
|
| 703 | + if ( is_numeric($k) && strpos($v, '=') ) { |
|
| 704 | + $add_html[] = $v; |
|
| 705 | + } else if ( ! empty( $k ) && isset( $add_html[ $k ] ) ) { |
|
| 706 | 706 | $add_html[ $k ] = str_replace( $k . '="', $k . '="' . $v, $add_html[ $k ] ); |
| 707 | - } else { |
|
| 707 | + } else { |
|
| 708 | 708 | $add_html[ $k ] = $k . '="' . esc_attr( $v ) . '"'; |
| 709 | - } |
|
| 710 | - |
|
| 711 | - unset($k, $v); |
|
| 712 | - } |
|
| 713 | - } |
|
| 714 | - |
|
| 715 | - public static function check_value( $opt, $opt_key, $field ) { |
|
| 716 | - if ( is_array( $opt ) ) { |
|
| 717 | - if ( FrmField::is_option_true( $field, 'separate_value' ) ) { |
|
| 718 | - $opt = isset( $opt['value'] ) ? $opt['value'] : ( isset( $opt['label'] ) ? $opt['label'] : reset( $opt ) ); |
|
| 719 | - } else { |
|
| 720 | - $opt = isset( $opt['label'] ) ? $opt['label'] : reset( $opt ); |
|
| 721 | - } |
|
| 722 | - } |
|
| 723 | - return $opt; |
|
| 724 | - } |
|
| 709 | + } |
|
| 710 | + |
|
| 711 | + unset($k, $v); |
|
| 712 | + } |
|
| 713 | + } |
|
| 714 | + |
|
| 715 | + public static function check_value( $opt, $opt_key, $field ) { |
|
| 716 | + if ( is_array( $opt ) ) { |
|
| 717 | + if ( FrmField::is_option_true( $field, 'separate_value' ) ) { |
|
| 718 | + $opt = isset( $opt['value'] ) ? $opt['value'] : ( isset( $opt['label'] ) ? $opt['label'] : reset( $opt ) ); |
|
| 719 | + } else { |
|
| 720 | + $opt = isset( $opt['label'] ) ? $opt['label'] : reset( $opt ); |
|
| 721 | + } |
|
| 722 | + } |
|
| 723 | + return $opt; |
|
| 724 | + } |
|
| 725 | 725 | |
| 726 | 726 | public static function check_label( $opt ) { |
| 727 | - if ( is_array($opt) ) { |
|
| 728 | - $opt = (isset($opt['label']) ? $opt['label'] : reset($opt)); |
|
| 729 | - } |
|
| 727 | + if ( is_array($opt) ) { |
|
| 728 | + $opt = (isset($opt['label']) ? $opt['label'] : reset($opt)); |
|
| 729 | + } |
|
| 730 | 730 | |
| 731 | - return $opt; |
|
| 732 | - } |
|
| 731 | + return $opt; |
|
| 732 | + } |
|
| 733 | 733 | } |
@@ -3,7 +3,7 @@ discard block |
||
| 3 | 3 | class FrmFieldsController { |
| 4 | 4 | |
| 5 | 5 | public static function load_field() { |
| 6 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 6 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
| 7 | 7 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 8 | 8 | |
| 9 | 9 | $fields = $_POST['field']; |
@@ -34,17 +34,17 @@ discard block |
||
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | $field_name = 'item_meta[' . $field_id . ']'; |
| 37 | - $html_id = FrmFieldsHelper::get_html_id($field); |
|
| 37 | + $html_id = FrmFieldsHelper::get_html_id( $field ); |
|
| 38 | 38 | |
| 39 | 39 | ob_start(); |
| 40 | 40 | include( $path . '/classes/views/frm-forms/add_field.php' ); |
| 41 | - $field_html[ $field_id ] = ob_get_contents(); |
|
| 41 | + $field_html[$field_id] = ob_get_contents(); |
|
| 42 | 42 | ob_end_clean(); |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | - unset($path); |
|
| 45 | + unset( $path ); |
|
| 46 | 46 | |
| 47 | - echo json_encode($field_html); |
|
| 47 | + echo json_encode( $field_html ); |
|
| 48 | 48 | |
| 49 | 49 | wp_die(); |
| 50 | 50 | } |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | * Create a new field with ajax |
| 54 | 54 | */ |
| 55 | 55 | public static function create() { |
| 56 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 56 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
| 57 | 57 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 58 | 58 | |
| 59 | 59 | $field_type = FrmAppHelper::get_post_param( 'field_type', '', 'sanitize_text_field' ); |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | $field = self::include_new_field( $field_type, $form_id ); |
| 63 | 63 | |
| 64 | 64 | // this hook will allow for multiple fields to be added at once |
| 65 | - do_action('frm_after_field_created', $field, $form_id); |
|
| 65 | + do_action( 'frm_after_field_created', $field, $form_id ); |
|
| 66 | 66 | |
| 67 | 67 | wp_die(); |
| 68 | 68 | } |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | public static function include_new_field( $field_type, $form_id ) { |
| 78 | 78 | $values = array(); |
| 79 | 79 | if ( FrmAppHelper::pro_is_installed() ) { |
| 80 | - $values['post_type'] = FrmProFormsHelper::post_type($form_id); |
|
| 80 | + $values['post_type'] = FrmProFormsHelper::post_type( $form_id ); |
|
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | $field_values = FrmFieldsHelper::setup_new_vars( $field_type, $form_id ); |
@@ -89,27 +89,27 @@ discard block |
||
| 89 | 89 | return false; |
| 90 | 90 | } |
| 91 | 91 | |
| 92 | - $field = self::include_single_field($field_id, $values, $form_id); |
|
| 92 | + $field = self::include_single_field( $field_id, $values, $form_id ); |
|
| 93 | 93 | |
| 94 | 94 | return $field; |
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | public static function edit_name( $field = 'name', $id = '' ) { |
| 98 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 98 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
| 99 | 99 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 100 | 100 | |
| 101 | - if ( empty($field) ) { |
|
| 101 | + if ( empty( $field ) ) { |
|
| 102 | 102 | $field = 'name'; |
| 103 | 103 | } |
| 104 | 104 | |
| 105 | - if ( empty($id) ) { |
|
| 105 | + if ( empty( $id ) ) { |
|
| 106 | 106 | $id = FrmAppHelper::get_post_param( 'element_id', '', 'sanitize_title' ); |
| 107 | 107 | $id = str_replace( 'field_label_', '', $id ); |
| 108 | 108 | } |
| 109 | 109 | |
| 110 | 110 | $value = FrmAppHelper::get_post_param( 'update_value', '', 'wp_kses_post' ); |
| 111 | 111 | $value = trim( $value ); |
| 112 | - if ( trim(strip_tags($value)) == '' ) { |
|
| 112 | + if ( trim( strip_tags( $value ) ) == '' ) { |
|
| 113 | 113 | // set blank value if there is no content |
| 114 | 114 | $value = ''; |
| 115 | 115 | } |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | public static function update_ajax_option() { |
| 126 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 126 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
| 127 | 127 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 128 | 128 | |
| 129 | 129 | $field_id = FrmAppHelper::get_post_param( 'field', 0, 'absint' ); |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | if ( isset( $_POST['separate_value'] ) ) { |
| 137 | 137 | $new_val = FrmField::is_option_true( $field, 'separate_value' ) ? 0 : 1; |
| 138 | 138 | $field->field_options['separate_value'] = $new_val; |
| 139 | - unset($new_val); |
|
| 139 | + unset( $new_val ); |
|
| 140 | 140 | } |
| 141 | 141 | |
| 142 | 142 | FrmField::update( $field_id, array( |
@@ -147,7 +147,7 @@ discard block |
||
| 147 | 147 | } |
| 148 | 148 | |
| 149 | 149 | public static function duplicate() { |
| 150 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 150 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
| 151 | 151 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 152 | 152 | |
| 153 | 153 | global $wpdb; |
@@ -172,11 +172,11 @@ discard block |
||
| 172 | 172 | |
| 173 | 173 | $values = apply_filters( 'frm_prepare_single_field_for_duplication', $values ); |
| 174 | 174 | |
| 175 | - if ( ! $field_id = FrmField::create($values) ) { |
|
| 175 | + if ( ! $field_id = FrmField::create( $values ) ) { |
|
| 176 | 176 | wp_die(); |
| 177 | 177 | } |
| 178 | 178 | |
| 179 | - self::include_single_field($field_id, $values); |
|
| 179 | + self::include_single_field( $field_id, $values ); |
|
| 180 | 180 | |
| 181 | 181 | wp_die(); |
| 182 | 182 | } |
@@ -185,9 +185,9 @@ discard block |
||
| 185 | 185 | * Load a single field in the form builder along with all needed variables |
| 186 | 186 | */ |
| 187 | 187 | public static function include_single_field( $field_id, $values, $form_id = 0 ) { |
| 188 | - $field = FrmFieldsHelper::setup_edit_vars(FrmField::getOne($field_id)); |
|
| 188 | + $field = FrmFieldsHelper::setup_edit_vars( FrmField::getOne( $field_id ) ); |
|
| 189 | 189 | $field_name = 'item_meta[' . $field_id . ']'; |
| 190 | - $html_id = FrmFieldsHelper::get_html_id($field); |
|
| 190 | + $html_id = FrmFieldsHelper::get_html_id( $field ); |
|
| 191 | 191 | $id = $form_id ? $form_id : $field['form_id']; |
| 192 | 192 | if ( $field['type'] == 'html' ) { |
| 193 | 193 | $field['stop_filter'] = true; |
@@ -199,7 +199,7 @@ discard block |
||
| 199 | 199 | } |
| 200 | 200 | |
| 201 | 201 | public static function destroy() { |
| 202 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 202 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
| 203 | 203 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 204 | 204 | |
| 205 | 205 | $field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' ); |
@@ -211,14 +211,14 @@ discard block |
||
| 211 | 211 | |
| 212 | 212 | //Add Single Option or Other Option |
| 213 | 213 | public static function add_option() { |
| 214 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 214 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
| 215 | 215 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 216 | 216 | |
| 217 | 217 | $id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' ); |
| 218 | 218 | $opt_type = FrmAppHelper::get_post_param( 'opt_type', '', 'sanitize_text_field' ); |
| 219 | 219 | |
| 220 | 220 | //Get the field |
| 221 | - $field = FrmField::getOne($id); |
|
| 221 | + $field = FrmField::getOne( $id ); |
|
| 222 | 222 | |
| 223 | 223 | if ( ! empty( $field->options ) ) { |
| 224 | 224 | $keys = array_keys( $field->options ); |
@@ -241,13 +241,13 @@ discard block |
||
| 241 | 241 | $first_opt = reset( $field->options ); |
| 242 | 242 | $next_opt = count( $field->options ); |
| 243 | 243 | if ( $first_opt != '' ) { |
| 244 | - $next_opt++; |
|
| 244 | + $next_opt ++; |
|
| 245 | 245 | } |
| 246 | 246 | $opt = esc_html__( 'Option', 'formidable' ) . ' ' . $next_opt; |
| 247 | - unset($next_opt); |
|
| 247 | + unset( $next_opt ); |
|
| 248 | 248 | } |
| 249 | 249 | $field_val = $opt; |
| 250 | - $field->options[ $opt_key ] = $opt; |
|
| 250 | + $field->options[$opt_key] = $opt; |
|
| 251 | 251 | |
| 252 | 252 | //Update options in DB |
| 253 | 253 | FrmField::update( $id, array( 'options' => $field->options ) ); |
@@ -256,13 +256,13 @@ discard block |
||
| 256 | 256 | $field = array( |
| 257 | 257 | 'type' => $field_data->type, |
| 258 | 258 | 'id' => $id, |
| 259 | - 'separate_value' => isset($field_data->field_options['separate_value']) ? $field_data->field_options['separate_value'] : 0, |
|
| 259 | + 'separate_value' => isset( $field_data->field_options['separate_value'] ) ? $field_data->field_options['separate_value'] : 0, |
|
| 260 | 260 | 'form_id' => $field_data->form_id, |
| 261 | 261 | 'field_key' => $field_data->field_key, |
| 262 | 262 | ); |
| 263 | 263 | |
| 264 | 264 | $field_name = 'item_meta[' . $id . ']'; |
| 265 | - $html_id = FrmFieldsHelper::get_html_id($field); |
|
| 265 | + $html_id = FrmFieldsHelper::get_html_id( $field ); |
|
| 266 | 266 | $checked = ''; |
| 267 | 267 | |
| 268 | 268 | if ( 'other' == $opt_type ) { |
@@ -274,7 +274,7 @@ discard block |
||
| 274 | 274 | } |
| 275 | 275 | |
| 276 | 276 | public static function edit_option() { |
| 277 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 277 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
| 278 | 278 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 279 | 279 | |
| 280 | 280 | $element_id = FrmAppHelper::get_post_param( 'element_id', '', 'sanitize_title' ); |
@@ -288,28 +288,28 @@ discard block |
||
| 288 | 288 | $new_label = $update_value; |
| 289 | 289 | } |
| 290 | 290 | |
| 291 | - $field = FrmField::getOne($id); |
|
| 291 | + $field = FrmField::getOne( $id ); |
|
| 292 | 292 | $separate_values = FrmField::is_option_true( $field, 'separate_value' ); |
| 293 | 293 | |
| 294 | - $this_opt_id = end($ids); |
|
| 295 | - $this_opt = (array) $field->options[ $this_opt_id ]; |
|
| 296 | - $other_opt = ( $this_opt_id && strpos( $this_opt_id, 'other') !== false ); |
|
| 294 | + $this_opt_id = end( $ids ); |
|
| 295 | + $this_opt = (array) $field->options[$this_opt_id]; |
|
| 296 | + $other_opt = ( $this_opt_id && strpos( $this_opt_id, 'other' ) !== false ); |
|
| 297 | 297 | |
| 298 | - $label = isset($this_opt['label']) ? $this_opt['label'] : reset($this_opt); |
|
| 299 | - $value = isset($this_opt['value']) ? $this_opt['value'] : ''; |
|
| 298 | + $label = isset( $this_opt['label'] ) ? $this_opt['label'] : reset( $this_opt ); |
|
| 299 | + $value = isset( $this_opt['value'] ) ? $this_opt['value'] : ''; |
|
| 300 | 300 | |
| 301 | 301 | if ( ! isset( $new_label ) ) { |
| 302 | 302 | $new_label = $label; |
| 303 | 303 | } |
| 304 | 304 | |
| 305 | - if ( isset($new_value) || isset($value) ) { |
|
| 306 | - $update_value = isset($new_value) ? $new_value : $value; |
|
| 305 | + if ( isset( $new_value ) || isset( $value ) ) { |
|
| 306 | + $update_value = isset( $new_value ) ? $new_value : $value; |
|
| 307 | 307 | } |
| 308 | 308 | |
| 309 | 309 | if ( $update_value != $new_label && $other_opt === false && $separate_values ) { |
| 310 | - $field->options[ $this_opt_id ] = array( 'value' => $update_value, 'label' => $new_label ); |
|
| 310 | + $field->options[$this_opt_id] = array( 'value' => $update_value, 'label' => $new_label ); |
|
| 311 | 311 | } else { |
| 312 | - $field->options[ $this_opt_id ] = $orig_update_value; |
|
| 312 | + $field->options[$this_opt_id] = $orig_update_value; |
|
| 313 | 313 | } |
| 314 | 314 | |
| 315 | 315 | FrmField::update( $field->id, array( 'options' => $field->options ) ); |
@@ -318,7 +318,7 @@ discard block |
||
| 318 | 318 | } |
| 319 | 319 | |
| 320 | 320 | public static function delete_option() { |
| 321 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 321 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
| 322 | 322 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 323 | 323 | |
| 324 | 324 | $field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' ); |
@@ -327,7 +327,7 @@ discard block |
||
| 327 | 327 | $opt_key = FrmAppHelper::get_post_param( 'opt_key', 0, 'sanitize_title' ); |
| 328 | 328 | |
| 329 | 329 | $options = $field->options; |
| 330 | - unset( $options[ $opt_key ] ); |
|
| 330 | + unset( $options[$opt_key] ); |
|
| 331 | 331 | $response = array( 'other' => true ); |
| 332 | 332 | |
| 333 | 333 | //If the deleted option is an "other" option |
@@ -393,9 +393,9 @@ discard block |
||
| 393 | 393 | |
| 394 | 394 | $admin_body_class .= ' admin-color-' . sanitize_html_class( get_user_option( 'admin_color' ), 'fresh' ); |
| 395 | 395 | $prepop = array(); |
| 396 | - FrmFieldsHelper::get_bulk_prefilled_opts($prepop); |
|
| 396 | + FrmFieldsHelper::get_bulk_prefilled_opts( $prepop ); |
|
| 397 | 397 | |
| 398 | - $field = FrmField::getOne($field_id); |
|
| 398 | + $field = FrmField::getOne( $field_id ); |
|
| 399 | 399 | |
| 400 | 400 | wp_enqueue_script( 'utils' ); |
| 401 | 401 | wp_enqueue_style( 'formidable-admin', FrmAppHelper::plugin_url() . '/css/frm_admin.css' ); |
@@ -406,35 +406,35 @@ discard block |
||
| 406 | 406 | } |
| 407 | 407 | |
| 408 | 408 | public static function import_options() { |
| 409 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 409 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
| 410 | 410 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 411 | 411 | |
| 412 | - if ( ! is_admin() || ! current_user_can('frm_edit_forms') ) { |
|
| 412 | + if ( ! is_admin() || ! current_user_can( 'frm_edit_forms' ) ) { |
|
| 413 | 413 | return; |
| 414 | 414 | } |
| 415 | 415 | |
| 416 | 416 | $field_id = absint( $_POST['field_id'] ); |
| 417 | - $field = FrmField::getOne($field_id); |
|
| 417 | + $field = FrmField::getOne( $field_id ); |
|
| 418 | 418 | |
| 419 | 419 | if ( ! in_array( $field->type, array( 'radio', 'checkbox', 'select' ) ) ) { |
| 420 | 420 | return; |
| 421 | 421 | } |
| 422 | 422 | |
| 423 | - $field = FrmFieldsHelper::setup_edit_vars($field); |
|
| 423 | + $field = FrmFieldsHelper::setup_edit_vars( $field ); |
|
| 424 | 424 | $opts = FrmAppHelper::get_param( 'opts', '', 'post', 'wp_kses_post' ); |
| 425 | 425 | $opts = explode( "\n", rtrim( $opts, "\n" ) ); |
| 426 | 426 | $opts = array_map( 'trim', $opts ); |
| 427 | 427 | |
| 428 | 428 | if ( $field['separate_value'] ) { |
| 429 | 429 | foreach ( $opts as $opt_key => $opt ) { |
| 430 | - if ( strpos($opt, '|') !== false ) { |
|
| 431 | - $vals = explode('|', $opt); |
|
| 430 | + if ( strpos( $opt, '|' ) !== false ) { |
|
| 431 | + $vals = explode( '|', $opt ); |
|
| 432 | 432 | if ( $vals[0] != $vals[1] ) { |
| 433 | - $opts[ $opt_key ] = array( 'label' => trim( $vals[0] ), 'value' => trim( $vals[1] ) ); |
|
| 433 | + $opts[$opt_key] = array( 'label' => trim( $vals[0] ), 'value' => trim( $vals[1] ) ); |
|
| 434 | 434 | } |
| 435 | - unset($vals); |
|
| 435 | + unset( $vals ); |
|
| 436 | 436 | } |
| 437 | - unset($opt_key, $opt); |
|
| 437 | + unset( $opt_key, $opt ); |
|
| 438 | 438 | } |
| 439 | 439 | } |
| 440 | 440 | |
@@ -443,12 +443,12 @@ discard block |
||
| 443 | 443 | $other_array = array(); |
| 444 | 444 | foreach ( $field['options'] as $opt_key => $opt ) { |
| 445 | 445 | if ( $opt_key && strpos( $opt_key, 'other' ) !== false ) { |
| 446 | - $other_array[ $opt_key ] = $opt; |
|
| 446 | + $other_array[$opt_key] = $opt; |
|
| 447 | 447 | } |
| 448 | - unset($opt_key, $opt); |
|
| 448 | + unset( $opt_key, $opt ); |
|
| 449 | 449 | } |
| 450 | - if ( ! empty($other_array) ) { |
|
| 451 | - $opts = array_merge( $opts, $other_array); |
|
| 450 | + if ( ! empty( $other_array ) ) { |
|
| 451 | + $opts = array_merge( $opts, $other_array ); |
|
| 452 | 452 | } |
| 453 | 453 | } |
| 454 | 454 | |
@@ -463,14 +463,14 @@ discard block |
||
| 463 | 463 | if ( $field['type'] == 'radio' || $field['type'] == 'checkbox' ) { |
| 464 | 464 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/radio.php' ); |
| 465 | 465 | } else { |
| 466 | - FrmFieldsHelper::show_single_option($field); |
|
| 466 | + FrmFieldsHelper::show_single_option( $field ); |
|
| 467 | 467 | } |
| 468 | 468 | |
| 469 | 469 | wp_die(); |
| 470 | 470 | } |
| 471 | 471 | |
| 472 | 472 | public static function update_order() { |
| 473 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 473 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
| 474 | 474 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 475 | 475 | |
| 476 | 476 | $fields = FrmAppHelper::get_post_param( 'frm_field_id' ); |
@@ -487,13 +487,13 @@ discard block |
||
| 487 | 487 | 'rte' => 'textarea', |
| 488 | 488 | 'website' => 'url', |
| 489 | 489 | ); |
| 490 | - if ( isset( $type_switch[ $type ] ) ) { |
|
| 491 | - $type = $type_switch[ $type ]; |
|
| 490 | + if ( isset( $type_switch[$type] ) ) { |
|
| 491 | + $type = $type_switch[$type]; |
|
| 492 | 492 | } |
| 493 | 493 | |
| 494 | 494 | $frm_field_selection = FrmField::field_selection(); |
| 495 | - $types = array_keys($frm_field_selection); |
|
| 496 | - if ( ! in_array($type, $types) && $type != 'captcha' ) { |
|
| 495 | + $types = array_keys( $frm_field_selection ); |
|
| 496 | + if ( ! in_array( $type, $types ) && $type != 'captcha' ) { |
|
| 497 | 497 | $type = 'text'; |
| 498 | 498 | } |
| 499 | 499 | |
@@ -532,19 +532,19 @@ discard block |
||
| 532 | 532 | |
| 533 | 533 | public static function input_html( $field, $echo = true ) { |
| 534 | 534 | $class = array(); //$field['type']; |
| 535 | - self::add_input_classes($field, $class); |
|
| 535 | + self::add_input_classes( $field, $class ); |
|
| 536 | 536 | |
| 537 | 537 | $add_html = array(); |
| 538 | - self::add_html_size($field, $add_html); |
|
| 539 | - self::add_html_length($field, $add_html); |
|
| 540 | - self::add_html_placeholder($field, $add_html, $class); |
|
| 538 | + self::add_html_size( $field, $add_html ); |
|
| 539 | + self::add_html_length( $field, $add_html ); |
|
| 540 | + self::add_html_placeholder( $field, $add_html, $class ); |
|
| 541 | 541 | self::add_validation_messages( $field, $add_html ); |
| 542 | 542 | |
| 543 | - $class = apply_filters('frm_field_classes', implode(' ', $class), $field); |
|
| 543 | + $class = apply_filters( 'frm_field_classes', implode( ' ', $class ), $field ); |
|
| 544 | 544 | |
| 545 | 545 | FrmFormsHelper::add_html_attr( $class, 'class', $add_html ); |
| 546 | 546 | |
| 547 | - self::add_shortcodes_to_html($field, $add_html); |
|
| 547 | + self::add_shortcodes_to_html( $field, $add_html ); |
|
| 548 | 548 | |
| 549 | 549 | $add_html = apply_filters( 'frm_field_extra_html', $add_html, $field ); |
| 550 | 550 | $add_html = ' ' . implode( ' ', $add_html ) . ' '; |
@@ -557,7 +557,7 @@ discard block |
||
| 557 | 557 | } |
| 558 | 558 | |
| 559 | 559 | private static function add_input_classes( $field, array &$class ) { |
| 560 | - if ( isset($field['input_class']) && ! empty($field['input_class']) ) { |
|
| 560 | + if ( isset( $field['input_class'] ) && ! empty( $field['input_class'] ) ) { |
|
| 561 | 561 | $class[] = $field['input_class']; |
| 562 | 562 | } |
| 563 | 563 | |
@@ -571,7 +571,7 @@ discard block |
||
| 571 | 571 | $class[] = 'dyn_default_value'; |
| 572 | 572 | } |
| 573 | 573 | |
| 574 | - if ( isset($field['size']) && $field['size'] > 0 ) { |
|
| 574 | + if ( isset( $field['size'] ) && $field['size'] > 0 ) { |
|
| 575 | 575 | $class[] = 'auto_width'; |
| 576 | 576 | } |
| 577 | 577 | } |
@@ -581,19 +581,19 @@ discard block |
||
| 581 | 581 | return; |
| 582 | 582 | } |
| 583 | 583 | |
| 584 | - if ( FrmAppHelper::is_admin_page('formidable' ) ) { |
|
| 584 | + if ( FrmAppHelper::is_admin_page( 'formidable' ) ) { |
|
| 585 | 585 | return; |
| 586 | 586 | } |
| 587 | 587 | |
| 588 | - if ( is_numeric($field['size']) ) { |
|
| 588 | + if ( is_numeric( $field['size'] ) ) { |
|
| 589 | 589 | $field['size'] .= 'px'; |
| 590 | 590 | } |
| 591 | 591 | |
| 592 | - $important = apply_filters('frm_use_important_width', 1, $field); |
|
| 592 | + $important = apply_filters( 'frm_use_important_width', 1, $field ); |
|
| 593 | 593 | // Note: This inline styling must stay since we cannot realistically set a class for every possible field size |
| 594 | 594 | $add_html['style'] = 'style="width:' . esc_attr( $field['size'] ) . ( $important ? ' !important' : '' ) . '"'; |
| 595 | 595 | |
| 596 | - self::add_html_cols($field, $add_html); |
|
| 596 | + self::add_html_cols( $field, $add_html ); |
|
| 597 | 597 | } |
| 598 | 598 | |
| 599 | 599 | private static function add_html_cols( $field, array &$add_html ) { |
@@ -610,13 +610,13 @@ discard block |
||
| 610 | 610 | ); |
| 611 | 611 | |
| 612 | 612 | // include "col" for valid html |
| 613 | - $unit = trim(preg_replace('/[0-9]+/', '', $field['size'])); |
|
| 613 | + $unit = trim( preg_replace( '/[0-9]+/', '', $field['size'] ) ); |
|
| 614 | 614 | |
| 615 | - if ( ! isset( $calc[ $unit ] ) ) { |
|
| 615 | + if ( ! isset( $calc[$unit] ) ) { |
|
| 616 | 616 | return; |
| 617 | 617 | } |
| 618 | 618 | |
| 619 | - $size = (float) str_replace( $unit, '', $field['size'] ) / $calc[ $unit ]; |
|
| 619 | + $size = (float) str_replace( $unit, '', $field['size'] ) / $calc[$unit]; |
|
| 620 | 620 | |
| 621 | 621 | $add_html['cols'] = 'cols="' . absint( $size ) . '"'; |
| 622 | 622 | } |
@@ -627,7 +627,7 @@ discard block |
||
| 627 | 627 | return; |
| 628 | 628 | } |
| 629 | 629 | |
| 630 | - if ( FrmAppHelper::is_admin_page('formidable' ) ) { |
|
| 630 | + if ( FrmAppHelper::is_admin_page( 'formidable' ) ) { |
|
| 631 | 631 | // don't load on form builder page |
| 632 | 632 | return; |
| 633 | 633 | } |
@@ -659,7 +659,7 @@ discard block |
||
| 659 | 659 | if ( $frm_settings->use_html && ! in_array( $field['type'], array( 'select', 'radio', 'checkbox', 'hidden' ) ) ) { |
| 660 | 660 | // use HMTL5 placeholder with js fallback |
| 661 | 661 | $add_html['placeholder'] = 'placeholder="' . esc_attr( $field['default_value'] ) . '"'; |
| 662 | - wp_enqueue_script('jquery-placeholder'); |
|
| 662 | + wp_enqueue_script( 'jquery-placeholder' ); |
|
| 663 | 663 | } else if ( ! $frm_settings->use_html ) { |
| 664 | 664 | $val = str_replace( array( "\r\n", "\n" ), '\r', addslashes( str_replace( ''', "'", esc_attr( $field['default_value'] ) ) ) ); |
| 665 | 665 | $add_html['data-frmval'] = 'data-frmval="' . esc_attr( $val ) . '"'; |
@@ -693,15 +693,15 @@ discard block |
||
| 693 | 693 | continue; |
| 694 | 694 | } |
| 695 | 695 | |
| 696 | - if ( is_numeric($k) && strpos($v, '=') ) { |
|
| 696 | + if ( is_numeric( $k ) && strpos( $v, '=' ) ) { |
|
| 697 | 697 | $add_html[] = $v; |
| 698 | - } else if ( ! empty( $k ) && isset( $add_html[ $k ] ) ) { |
|
| 699 | - $add_html[ $k ] = str_replace( $k . '="', $k . '="' . $v, $add_html[ $k ] ); |
|
| 698 | + } else if ( ! empty( $k ) && isset( $add_html[$k] ) ) { |
|
| 699 | + $add_html[$k] = str_replace( $k . '="', $k . '="' . $v, $add_html[$k] ); |
|
| 700 | 700 | } else { |
| 701 | - $add_html[ $k ] = $k . '="' . esc_attr( $v ) . '"'; |
|
| 701 | + $add_html[$k] = $k . '="' . esc_attr( $v ) . '"'; |
|
| 702 | 702 | } |
| 703 | 703 | |
| 704 | - unset($k, $v); |
|
| 704 | + unset( $k, $v ); |
|
| 705 | 705 | } |
| 706 | 706 | } |
| 707 | 707 | |
@@ -717,8 +717,8 @@ discard block |
||
| 717 | 717 | } |
| 718 | 718 | |
| 719 | 719 | public static function check_label( $opt ) { |
| 720 | - if ( is_array($opt) ) { |
|
| 721 | - $opt = (isset($opt['label']) ? $opt['label'] : reset($opt)); |
|
| 720 | + if ( is_array( $opt ) ) { |
|
| 721 | + $opt = ( isset( $opt['label'] ) ? $opt['label'] : reset( $opt ) ); |
|
| 722 | 722 | } |
| 723 | 723 | |
| 724 | 724 | return $opt; |
@@ -4,7 +4,7 @@ discard block |
||
| 4 | 4 | public $id = 0; // the id of the post |
| 5 | 5 | |
| 6 | 6 | /** |
| 7 | - * @param int|string $id The id of the stylsheet or 'default' |
|
| 7 | + * @param integer $id The id of the stylsheet or 'default' |
|
| 8 | 8 | */ |
| 9 | 9 | public function __construct( $id = 0 ) { |
| 10 | 10 | $this->id = $id; |
@@ -120,6 +120,9 @@ discard block |
||
| 120 | 120 | set_transient('frmpro_css', $css); |
| 121 | 121 | } |
| 122 | 122 | |
| 123 | + /** |
|
| 124 | + * @param string $filename |
|
| 125 | + */ |
|
| 123 | 126 | private function get_css_content( $filename ) { |
| 124 | 127 | $css = '/* ' . __( 'WARNING: Any changes made to this file will be lost when your Formidable settings are updated', 'formidable' ) . ' */' . "\n"; |
| 125 | 128 | |
@@ -1,52 +1,52 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | class FrmStyle { |
| 3 | - public $number = false; // Unique ID number of the current instance. |
|
| 3 | + public $number = false; // Unique ID number of the current instance. |
|
| 4 | 4 | public $id = 0; // the id of the post |
| 5 | 5 | |
| 6 | 6 | /** |
| 7 | 7 | * @param int|string $id The id of the stylsheet or 'default' |
| 8 | 8 | */ |
| 9 | 9 | public function __construct( $id = 0 ) { |
| 10 | - $this->id = $id; |
|
| 11 | - } |
|
| 10 | + $this->id = $id; |
|
| 11 | + } |
|
| 12 | 12 | |
| 13 | - public function get_new() { |
|
| 13 | + public function get_new() { |
|
| 14 | 14 | $this->id = 0; |
| 15 | 15 | |
| 16 | - $max_slug_value = pow(36, 6); |
|
| 17 | - $min_slug_value = 37; // we want to have at least 2 characters in the slug |
|
| 18 | - $key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 ); |
|
| 19 | - |
|
| 20 | - $style = array( |
|
| 21 | - 'post_type' => FrmStylesController::$post_type, |
|
| 22 | - 'ID' => '', |
|
| 23 | - 'post_title' => __( 'New Style', 'formidable' ), |
|
| 24 | - 'post_name' => $key, |
|
| 25 | - 'post_content' => $this->get_defaults(), |
|
| 26 | - 'menu_order' => '', |
|
| 27 | - 'post_status' => 'publish', |
|
| 28 | - ); |
|
| 16 | + $max_slug_value = pow(36, 6); |
|
| 17 | + $min_slug_value = 37; // we want to have at least 2 characters in the slug |
|
| 18 | + $key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 ); |
|
| 19 | + |
|
| 20 | + $style = array( |
|
| 21 | + 'post_type' => FrmStylesController::$post_type, |
|
| 22 | + 'ID' => '', |
|
| 23 | + 'post_title' => __( 'New Style', 'formidable' ), |
|
| 24 | + 'post_name' => $key, |
|
| 25 | + 'post_content' => $this->get_defaults(), |
|
| 26 | + 'menu_order' => '', |
|
| 27 | + 'post_status' => 'publish', |
|
| 28 | + ); |
|
| 29 | 29 | |
| 30 | - return (object) $style; |
|
| 31 | - } |
|
| 30 | + return (object) $style; |
|
| 31 | + } |
|
| 32 | 32 | |
| 33 | 33 | public function save( $settings ) { |
| 34 | 34 | return FrmAppHelper::save_settings( $settings, 'frm_styles' ); |
| 35 | - } |
|
| 35 | + } |
|
| 36 | 36 | |
| 37 | 37 | public function duplicate( $id ) { |
| 38 | - // duplicating is a pro feature |
|
| 39 | - } |
|
| 38 | + // duplicating is a pro feature |
|
| 39 | + } |
|
| 40 | 40 | |
| 41 | - public function update( $id = 'default' ) { |
|
| 41 | + public function update( $id = 'default' ) { |
|
| 42 | 42 | $all_instances = $this->get_all(); |
| 43 | 43 | |
| 44 | 44 | if ( empty($id) ) { |
| 45 | - $new_style = (array) $this->get_new(); |
|
| 46 | - $all_instances[] = $new_style; |
|
| 45 | + $new_style = (array) $this->get_new(); |
|
| 46 | + $all_instances[] = $new_style; |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | - $action_ids = array(); |
|
| 49 | + $action_ids = array(); |
|
| 50 | 50 | |
| 51 | 51 | foreach ( $all_instances as $number => $new_instance ) { |
| 52 | 52 | $new_instance = stripslashes_deep( (array) $new_instance); |
@@ -54,42 +54,42 @@ discard block |
||
| 54 | 54 | if ( $id != $this->id || ! $_POST || ! isset($_POST['frm_style_setting']) ) { |
| 55 | 55 | $all_instances[ $number ] = $new_instance; |
| 56 | 56 | |
| 57 | - if ( $new_instance['menu_order'] && $_POST && empty($_POST['prev_menu_order']) && isset($_POST['frm_style_setting']['menu_order']) ) { |
|
| 58 | - // this style was set to default, so remove default setting on previous default style |
|
| 59 | - $new_instance['menu_order'] = 0; |
|
| 60 | - $action_ids[] = $this->save($new_instance); |
|
| 61 | - } |
|
| 57 | + if ( $new_instance['menu_order'] && $_POST && empty($_POST['prev_menu_order']) && isset($_POST['frm_style_setting']['menu_order']) ) { |
|
| 58 | + // this style was set to default, so remove default setting on previous default style |
|
| 59 | + $new_instance['menu_order'] = 0; |
|
| 60 | + $action_ids[] = $this->save($new_instance); |
|
| 61 | + } |
|
| 62 | 62 | |
| 63 | - // don't continue if not saving this style |
|
| 64 | - continue; |
|
| 63 | + // don't continue if not saving this style |
|
| 64 | + continue; |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | $new_instance['post_title'] = sanitize_text_field( $_POST['frm_style_setting']['post_title'] ); |
| 68 | 68 | $new_instance['post_content'] = $_POST['frm_style_setting']['post_content']; |
| 69 | 69 | $new_instance['post_type'] = FrmStylesController::$post_type; |
| 70 | - $new_instance['post_status'] = 'publish'; |
|
| 70 | + $new_instance['post_status'] = 'publish'; |
|
| 71 | 71 | $new_instance['menu_order'] = isset( $_POST['frm_style_setting']['menu_order'] ) ? absint( $_POST['frm_style_setting']['menu_order'] ) : 0; |
| 72 | 72 | |
| 73 | - if ( empty($id) ) { |
|
| 74 | - $new_instance['post_name'] = $new_instance['post_title']; |
|
| 75 | - } |
|
| 73 | + if ( empty($id) ) { |
|
| 74 | + $new_instance['post_name'] = $new_instance['post_title']; |
|
| 75 | + } |
|
| 76 | 76 | |
| 77 | - $default_settings = $this->get_defaults(); |
|
| 77 | + $default_settings = $this->get_defaults(); |
|
| 78 | 78 | |
| 79 | - foreach ( $default_settings as $setting => $default ) { |
|
| 79 | + foreach ( $default_settings as $setting => $default ) { |
|
| 80 | 80 | if ( strpos( $setting, 'color' ) !== false || in_array( $setting, array( 'error_bg', 'error_border', 'error_text' ) ) ) { |
| 81 | - //if is a color |
|
| 81 | + //if is a color |
|
| 82 | 82 | $new_instance['post_content'][ $setting ] = str_replace( '#', '', $new_instance['post_content'][ $setting ] ); |
| 83 | 83 | } else if ( in_array( $setting, array( 'submit_style', 'important_style', 'auto_width' ) ) && ! isset( $new_instance['post_content'][ $setting ] ) ) { |
| 84 | 84 | $new_instance['post_content'][ $setting ] = 0; |
| 85 | - } else if ( $setting == 'font' ) { |
|
| 86 | - $new_instance['post_content'][ $setting ] = $this->force_balanced_quotation( $new_instance['post_content'][ $setting ] ); |
|
| 87 | - } |
|
| 88 | - } |
|
| 85 | + } else if ( $setting == 'font' ) { |
|
| 86 | + $new_instance['post_content'][ $setting ] = $this->force_balanced_quotation( $new_instance['post_content'][ $setting ] ); |
|
| 87 | + } |
|
| 88 | + } |
|
| 89 | 89 | |
| 90 | 90 | $all_instances[ $number ] = $new_instance; |
| 91 | 91 | |
| 92 | - $action_ids[] = $this->save($new_instance); |
|
| 92 | + $action_ids[] = $this->save($new_instance); |
|
| 93 | 93 | |
| 94 | 94 | } |
| 95 | 95 | |
@@ -98,27 +98,27 @@ discard block |
||
| 98 | 98 | return $action_ids; |
| 99 | 99 | } |
| 100 | 100 | |
| 101 | - /** |
|
| 102 | - * Create static css file |
|
| 103 | - */ |
|
| 101 | + /** |
|
| 102 | + * Create static css file |
|
| 103 | + */ |
|
| 104 | 104 | public function save_settings() { |
| 105 | 105 | $filename = FrmAppHelper::plugin_path() . '/css/custom_theme.css.php'; |
| 106 | 106 | update_option( 'frm_last_style_update', date('njGi') ); |
| 107 | 107 | |
| 108 | - if ( ! is_file($filename) ) { |
|
| 109 | - return; |
|
| 110 | - } |
|
| 108 | + if ( ! is_file($filename) ) { |
|
| 109 | + return; |
|
| 110 | + } |
|
| 111 | 111 | |
| 112 | 112 | $css = $this->get_css_content( $filename ); |
| 113 | 113 | |
| 114 | 114 | $create_file = new FrmCreateFile( array( 'folder_name' => 'formidable/css', 'file_name' => 'formidablepro.css' ) ); |
| 115 | 115 | $create_file->create_file( $css ); |
| 116 | 116 | |
| 117 | - update_option('frmpro_css', $css); |
|
| 117 | + update_option('frmpro_css', $css); |
|
| 118 | 118 | |
| 119 | 119 | $this->clear_cache(); |
| 120 | 120 | |
| 121 | - set_transient('frmpro_css', $css); |
|
| 121 | + set_transient('frmpro_css', $css); |
|
| 122 | 122 | } |
| 123 | 123 | |
| 124 | 124 | private function get_css_content( $filename ) { |
@@ -127,10 +127,10 @@ discard block |
||
| 127 | 127 | $saving = true; |
| 128 | 128 | $frm_style = $this; |
| 129 | 129 | |
| 130 | - ob_start(); |
|
| 131 | - include( $filename ); |
|
| 130 | + ob_start(); |
|
| 131 | + include( $filename ); |
|
| 132 | 132 | $css .= preg_replace( '/\/\*(.|\s)*?\*\//', '', str_replace( array( "\r\n", "\r", "\n", "\t", ' ' ), '', ob_get_contents() ) ); |
| 133 | - ob_end_clean(); |
|
| 133 | + ob_end_clean(); |
|
| 134 | 134 | |
| 135 | 135 | return $css; |
| 136 | 136 | } |
@@ -150,272 +150,272 @@ discard block |
||
| 150 | 150 | } |
| 151 | 151 | |
| 152 | 152 | public function destroy( $id ) { |
| 153 | - return wp_delete_post($id); |
|
| 154 | - } |
|
| 153 | + return wp_delete_post($id); |
|
| 154 | + } |
|
| 155 | 155 | |
| 156 | - public function get_one() { |
|
| 157 | - if ( 'default' == $this->id ) { |
|
| 158 | - $style = $this->get_default_style(); |
|
| 159 | - if ( $style ) { |
|
| 160 | - $this->id = $style->ID; |
|
| 161 | - } else { |
|
| 162 | - $this->id = 0; |
|
| 163 | - } |
|
| 164 | - return $style; |
|
| 165 | - } |
|
| 156 | + public function get_one() { |
|
| 157 | + if ( 'default' == $this->id ) { |
|
| 158 | + $style = $this->get_default_style(); |
|
| 159 | + if ( $style ) { |
|
| 160 | + $this->id = $style->ID; |
|
| 161 | + } else { |
|
| 162 | + $this->id = 0; |
|
| 163 | + } |
|
| 164 | + return $style; |
|
| 165 | + } |
|
| 166 | 166 | |
| 167 | - $style = get_post($this->id); |
|
| 167 | + $style = get_post($this->id); |
|
| 168 | 168 | |
| 169 | - if ( ! $style ) { |
|
| 170 | - return $style; |
|
| 171 | - } |
|
| 169 | + if ( ! $style ) { |
|
| 170 | + return $style; |
|
| 171 | + } |
|
| 172 | 172 | |
| 173 | - $style->post_content = FrmAppHelper::maybe_json_decode($style->post_content); |
|
| 173 | + $style->post_content = FrmAppHelper::maybe_json_decode($style->post_content); |
|
| 174 | 174 | |
| 175 | - $default_values = $this->get_defaults(); |
|
| 175 | + $default_values = $this->get_defaults(); |
|
| 176 | 176 | |
| 177 | - // fill default values |
|
| 178 | - $style->post_content = $this->override_defaults($style->post_content); |
|
| 179 | - $style->post_content = wp_parse_args( $style->post_content, $default_values); |
|
| 177 | + // fill default values |
|
| 178 | + $style->post_content = $this->override_defaults($style->post_content); |
|
| 179 | + $style->post_content = wp_parse_args( $style->post_content, $default_values); |
|
| 180 | 180 | |
| 181 | - return $style; |
|
| 182 | - } |
|
| 181 | + return $style; |
|
| 182 | + } |
|
| 183 | 183 | |
| 184 | - public function get_all( $orderby = 'title', $order = 'ASC', $limit = 99 ) { |
|
| 185 | - $post_atts = array( |
|
| 184 | + public function get_all( $orderby = 'title', $order = 'ASC', $limit = 99 ) { |
|
| 185 | + $post_atts = array( |
|
| 186 | 186 | 'post_type' => FrmStylesController::$post_type, |
| 187 | 187 | 'post_status' => 'publish', |
| 188 | 188 | 'numberposts' => $limit, |
| 189 | 189 | 'orderby' => $orderby, |
| 190 | 190 | 'order' => $order, |
| 191 | - ); |
|
| 191 | + ); |
|
| 192 | 192 | |
| 193 | - $temp_styles = FrmAppHelper::check_cache(serialize($post_atts), 'frm_styles', $post_atts, 'get_posts'); |
|
| 193 | + $temp_styles = FrmAppHelper::check_cache(serialize($post_atts), 'frm_styles', $post_atts, 'get_posts'); |
|
| 194 | 194 | |
| 195 | - if ( empty($temp_styles) ) { |
|
| 196 | - global $wpdb; |
|
| 197 | - // make sure there wasn't a conflict with the query |
|
| 195 | + if ( empty($temp_styles) ) { |
|
| 196 | + global $wpdb; |
|
| 197 | + // make sure there wasn't a conflict with the query |
|
| 198 | 198 | $query = $wpdb->prepare( 'SELECT * FROM ' . $wpdb->posts . ' WHERE post_type=%s AND post_status=%s ORDER BY post_title ASC LIMIT 99', FrmStylesController::$post_type, 'publish' ); |
| 199 | - $temp_styles = FrmAppHelper::check_cache('frm_backup_style_check', 'frm_styles', $query, 'get_results'); |
|
| 200 | - |
|
| 201 | - if ( empty($temp_styles) ) { |
|
| 202 | - // create a new style if there are none |
|
| 203 | - $new = $this->get_new(); |
|
| 204 | - $new->post_title = $new->post_name = __( 'Formidable Style', 'formidable' ); |
|
| 205 | - $new->menu_order = 1; |
|
| 206 | - $new = $this->save( (array) $new); |
|
| 207 | - $this->update('default'); |
|
| 208 | - |
|
| 209 | - $post_atts['include'] = $new; |
|
| 210 | - |
|
| 211 | - $temp_styles = get_posts( $post_atts ); |
|
| 212 | - } |
|
| 213 | - } |
|
| 214 | - |
|
| 215 | - $default_values = $this->get_defaults(); |
|
| 216 | - $default_style = false; |
|
| 217 | - |
|
| 218 | - $styles = array(); |
|
| 219 | - foreach ( $temp_styles as $style ) { |
|
| 220 | - $this->id = $style->ID; |
|
| 221 | - if ( $style->menu_order ) { |
|
| 222 | - if ( $default_style ) { |
|
| 223 | - // only return one default |
|
| 224 | - $style->menu_order = 0; |
|
| 225 | - } else { |
|
| 226 | - // check for a default style |
|
| 227 | - $default_style = $style->ID; |
|
| 228 | - } |
|
| 229 | - } |
|
| 230 | - |
|
| 231 | - $style->post_content = FrmAppHelper::maybe_json_decode($style->post_content); |
|
| 232 | - |
|
| 233 | - // fill default values |
|
| 234 | - $style->post_content = $this->override_defaults($style->post_content); |
|
| 235 | - $style->post_content = wp_parse_args( $style->post_content, $default_values); |
|
| 199 | + $temp_styles = FrmAppHelper::check_cache('frm_backup_style_check', 'frm_styles', $query, 'get_results'); |
|
| 200 | + |
|
| 201 | + if ( empty($temp_styles) ) { |
|
| 202 | + // create a new style if there are none |
|
| 203 | + $new = $this->get_new(); |
|
| 204 | + $new->post_title = $new->post_name = __( 'Formidable Style', 'formidable' ); |
|
| 205 | + $new->menu_order = 1; |
|
| 206 | + $new = $this->save( (array) $new); |
|
| 207 | + $this->update('default'); |
|
| 208 | + |
|
| 209 | + $post_atts['include'] = $new; |
|
| 210 | + |
|
| 211 | + $temp_styles = get_posts( $post_atts ); |
|
| 212 | + } |
|
| 213 | + } |
|
| 214 | + |
|
| 215 | + $default_values = $this->get_defaults(); |
|
| 216 | + $default_style = false; |
|
| 217 | + |
|
| 218 | + $styles = array(); |
|
| 219 | + foreach ( $temp_styles as $style ) { |
|
| 220 | + $this->id = $style->ID; |
|
| 221 | + if ( $style->menu_order ) { |
|
| 222 | + if ( $default_style ) { |
|
| 223 | + // only return one default |
|
| 224 | + $style->menu_order = 0; |
|
| 225 | + } else { |
|
| 226 | + // check for a default style |
|
| 227 | + $default_style = $style->ID; |
|
| 228 | + } |
|
| 229 | + } |
|
| 230 | + |
|
| 231 | + $style->post_content = FrmAppHelper::maybe_json_decode($style->post_content); |
|
| 232 | + |
|
| 233 | + // fill default values |
|
| 234 | + $style->post_content = $this->override_defaults($style->post_content); |
|
| 235 | + $style->post_content = wp_parse_args( $style->post_content, $default_values); |
|
| 236 | 236 | |
| 237 | 237 | $styles[ $style->ID ] = $style; |
| 238 | - } |
|
| 238 | + } |
|
| 239 | 239 | |
| 240 | - if ( ! $default_style ) { |
|
| 241 | - $default_style = reset($styles); |
|
| 240 | + if ( ! $default_style ) { |
|
| 241 | + $default_style = reset($styles); |
|
| 242 | 242 | $styles[ $default_style->ID ]->menu_order = 1; |
| 243 | - } |
|
| 243 | + } |
|
| 244 | 244 | |
| 245 | - return $styles; |
|
| 246 | - } |
|
| 245 | + return $styles; |
|
| 246 | + } |
|
| 247 | 247 | |
| 248 | 248 | public function get_default_style( $styles = null ) { |
| 249 | - if ( ! isset($styles) ) { |
|
| 249 | + if ( ! isset($styles) ) { |
|
| 250 | 250 | $styles = $this->get_all( 'menu_order', 'DESC', 1 ); |
| 251 | - } |
|
| 251 | + } |
|
| 252 | 252 | |
| 253 | - foreach ( $styles as $style ) { |
|
| 254 | - if ( $style->menu_order ) { |
|
| 255 | - return $style; |
|
| 256 | - } |
|
| 257 | - } |
|
| 258 | - } |
|
| 253 | + foreach ( $styles as $style ) { |
|
| 254 | + if ( $style->menu_order ) { |
|
| 255 | + return $style; |
|
| 256 | + } |
|
| 257 | + } |
|
| 258 | + } |
|
| 259 | 259 | |
| 260 | 260 | public function override_defaults( $settings ) { |
| 261 | - if ( ! is_array($settings) ) { |
|
| 262 | - return $settings; |
|
| 263 | - } |
|
| 264 | - |
|
| 265 | - $settings['line_height'] = ( ! isset($settings['field_height']) || $settings['field_height'] == '' || $settings['field_height'] == 'auto') ? 'normal' : $settings['field_height']; |
|
| 266 | - |
|
| 267 | - if ( ! isset($settings['form_desc_size']) && isset($settings['description_font_size']) ) { |
|
| 268 | - $settings['form_desc_size'] = $settings['description_font_size']; |
|
| 269 | - $settings['form_desc_color'] = $settings['description_color']; |
|
| 270 | - $settings['title_color'] = $settings['label_color']; |
|
| 271 | - } |
|
| 272 | - |
|
| 273 | - if ( ! isset($settings['section_color']) && isset($settings['label_color']) ) { |
|
| 274 | - $settings['section_color'] = $settings['label_color']; |
|
| 275 | - $settings['section_border_color'] = $settings['border_color']; |
|
| 276 | - } |
|
| 277 | - |
|
| 278 | - if ( ! isset($settings['submit_hover_bg_color']) && isset($settings['submit_bg_color']) ) { |
|
| 279 | - $settings['submit_hover_bg_color'] = $settings['submit_bg_color']; |
|
| 280 | - $settings['submit_hover_color'] = $settings['submit_text_color']; |
|
| 281 | - $settings['submit_hover_border_color'] = $settings['submit_border_color']; |
|
| 282 | - |
|
| 283 | - $settings['submit_active_bg_color'] = $settings['submit_bg_color']; |
|
| 284 | - $settings['submit_active_color'] = $settings['submit_text_color']; |
|
| 285 | - $settings['submit_active_border_color'] = $settings['submit_border_color']; |
|
| 286 | - } |
|
| 287 | - |
|
| 288 | - return $settings; |
|
| 261 | + if ( ! is_array($settings) ) { |
|
| 262 | + return $settings; |
|
| 263 | + } |
|
| 264 | + |
|
| 265 | + $settings['line_height'] = ( ! isset($settings['field_height']) || $settings['field_height'] == '' || $settings['field_height'] == 'auto') ? 'normal' : $settings['field_height']; |
|
| 266 | + |
|
| 267 | + if ( ! isset($settings['form_desc_size']) && isset($settings['description_font_size']) ) { |
|
| 268 | + $settings['form_desc_size'] = $settings['description_font_size']; |
|
| 269 | + $settings['form_desc_color'] = $settings['description_color']; |
|
| 270 | + $settings['title_color'] = $settings['label_color']; |
|
| 271 | + } |
|
| 272 | + |
|
| 273 | + if ( ! isset($settings['section_color']) && isset($settings['label_color']) ) { |
|
| 274 | + $settings['section_color'] = $settings['label_color']; |
|
| 275 | + $settings['section_border_color'] = $settings['border_color']; |
|
| 276 | + } |
|
| 277 | + |
|
| 278 | + if ( ! isset($settings['submit_hover_bg_color']) && isset($settings['submit_bg_color']) ) { |
|
| 279 | + $settings['submit_hover_bg_color'] = $settings['submit_bg_color']; |
|
| 280 | + $settings['submit_hover_color'] = $settings['submit_text_color']; |
|
| 281 | + $settings['submit_hover_border_color'] = $settings['submit_border_color']; |
|
| 282 | + |
|
| 283 | + $settings['submit_active_bg_color'] = $settings['submit_bg_color']; |
|
| 284 | + $settings['submit_active_color'] = $settings['submit_text_color']; |
|
| 285 | + $settings['submit_active_border_color'] = $settings['submit_border_color']; |
|
| 286 | + } |
|
| 287 | + |
|
| 288 | + return $settings; |
|
| 289 | 289 | } |
| 290 | 290 | |
| 291 | 291 | public function get_defaults() { |
| 292 | - return array( |
|
| 293 | - 'theme_css' => 'ui-lightness', |
|
| 294 | - 'theme_name' => 'UI Lightness', |
|
| 292 | + return array( |
|
| 293 | + 'theme_css' => 'ui-lightness', |
|
| 294 | + 'theme_name' => 'UI Lightness', |
|
| 295 | 295 | |
| 296 | 296 | 'center_form' => '', |
| 297 | - 'form_width' => '100%', |
|
| 298 | - 'form_align' => 'left', |
|
| 299 | - 'direction' => is_rtl() ? 'rtl' : 'ltr', |
|
| 300 | - 'fieldset' => '0px', |
|
| 301 | - 'fieldset_color' => '000000', |
|
| 302 | - 'fieldset_padding' => '0 0 15px 0', |
|
| 303 | - 'fieldset_bg_color' => '', |
|
| 304 | - |
|
| 305 | - 'title_size' => '20px', |
|
| 306 | - 'title_color' => '444444', |
|
| 297 | + 'form_width' => '100%', |
|
| 298 | + 'form_align' => 'left', |
|
| 299 | + 'direction' => is_rtl() ? 'rtl' : 'ltr', |
|
| 300 | + 'fieldset' => '0px', |
|
| 301 | + 'fieldset_color' => '000000', |
|
| 302 | + 'fieldset_padding' => '0 0 15px 0', |
|
| 303 | + 'fieldset_bg_color' => '', |
|
| 304 | + |
|
| 305 | + 'title_size' => '20px', |
|
| 306 | + 'title_color' => '444444', |
|
| 307 | 307 | 'title_margin_top' => '10px', |
| 308 | 308 | 'title_margin_bottom' => '10px', |
| 309 | - 'form_desc_size' => '14px', |
|
| 310 | - 'form_desc_color' => '666666', |
|
| 309 | + 'form_desc_size' => '14px', |
|
| 310 | + 'form_desc_color' => '666666', |
|
| 311 | 311 | 'form_desc_margin_top' => '10px', |
| 312 | 312 | 'form_desc_margin_bottom' => '25px', |
| 313 | 313 | |
| 314 | - 'font' => '"Lucida Grande","Lucida Sans Unicode",Tahoma,sans-serif', |
|
| 315 | - 'font_size' => '14px', |
|
| 316 | - 'label_color' => '444444', |
|
| 317 | - 'weight' => 'bold', |
|
| 318 | - 'position' => 'none', |
|
| 319 | - 'align' => 'left', |
|
| 320 | - 'width' => '150px', |
|
| 321 | - 'required_color' => 'B94A48', |
|
| 322 | - 'required_weight' => 'bold', |
|
| 323 | - 'label_padding' => '0 0 3px 0', |
|
| 324 | - |
|
| 325 | - 'description_font_size' => '12px', |
|
| 326 | - 'description_color' => '666666', |
|
| 327 | - 'description_weight' => 'normal', |
|
| 328 | - 'description_style' => 'normal', |
|
| 329 | - 'description_align' => 'left', |
|
| 314 | + 'font' => '"Lucida Grande","Lucida Sans Unicode",Tahoma,sans-serif', |
|
| 315 | + 'font_size' => '14px', |
|
| 316 | + 'label_color' => '444444', |
|
| 317 | + 'weight' => 'bold', |
|
| 318 | + 'position' => 'none', |
|
| 319 | + 'align' => 'left', |
|
| 320 | + 'width' => '150px', |
|
| 321 | + 'required_color' => 'B94A48', |
|
| 322 | + 'required_weight' => 'bold', |
|
| 323 | + 'label_padding' => '0 0 3px 0', |
|
| 324 | + |
|
| 325 | + 'description_font_size' => '12px', |
|
| 326 | + 'description_color' => '666666', |
|
| 327 | + 'description_weight' => 'normal', |
|
| 328 | + 'description_style' => 'normal', |
|
| 329 | + 'description_align' => 'left', |
|
| 330 | 330 | 'description_margin' => '0', |
| 331 | 331 | |
| 332 | - 'field_font_size' => '14px', |
|
| 333 | - 'field_height' => '32px', |
|
| 334 | - 'line_height' => 'normal', |
|
| 335 | - 'field_width' => '100%', |
|
| 336 | - 'auto_width' => false, |
|
| 337 | - 'field_pad' => '6px 10px', |
|
| 338 | - 'field_margin' => '20px', |
|
| 332 | + 'field_font_size' => '14px', |
|
| 333 | + 'field_height' => '32px', |
|
| 334 | + 'line_height' => 'normal', |
|
| 335 | + 'field_width' => '100%', |
|
| 336 | + 'auto_width' => false, |
|
| 337 | + 'field_pad' => '6px 10px', |
|
| 338 | + 'field_margin' => '20px', |
|
| 339 | 339 | 'field_weight' => 'normal', |
| 340 | - 'text_color' => '555555', |
|
| 341 | - //'border_color_hv' => 'cccccc', |
|
| 342 | - 'border_color' => 'cccccc', |
|
| 343 | - 'field_border_width' => '1px', |
|
| 344 | - 'field_border_style' => 'solid', |
|
| 345 | - |
|
| 346 | - 'bg_color' => 'ffffff', |
|
| 347 | - //'bg_color_hv' => 'ffffff', |
|
| 340 | + 'text_color' => '555555', |
|
| 341 | + //'border_color_hv' => 'cccccc', |
|
| 342 | + 'border_color' => 'cccccc', |
|
| 343 | + 'field_border_width' => '1px', |
|
| 344 | + 'field_border_style' => 'solid', |
|
| 345 | + |
|
| 346 | + 'bg_color' => 'ffffff', |
|
| 347 | + //'bg_color_hv' => 'ffffff', |
|
| 348 | 348 | 'remove_box_shadow' => '', |
| 349 | - 'bg_color_active' => 'ffffff', |
|
| 349 | + 'bg_color_active' => 'ffffff', |
|
| 350 | 350 | 'border_color_active' => '66afe9', |
| 351 | 351 | 'remove_box_shadow_active' => '', |
| 352 | - 'text_color_error' => '444444', |
|
| 353 | - 'bg_color_error' => 'ffffff', |
|
| 352 | + 'text_color_error' => '444444', |
|
| 353 | + 'bg_color_error' => 'ffffff', |
|
| 354 | 354 | 'border_color_error' => 'B94A48', |
| 355 | 355 | 'border_width_error' => '1px', |
| 356 | 356 | 'border_style_error' => 'solid', |
| 357 | - 'bg_color_disabled' => 'ffffff', |
|
| 358 | - 'border_color_disabled' => 'E5E5E5', |
|
| 359 | - 'text_color_disabled' => 'A1A1A1', |
|
| 360 | - |
|
| 361 | - 'radio_align' => 'block', |
|
| 362 | - 'check_align' => 'block', |
|
| 363 | - 'check_font_size' => '13px', |
|
| 364 | - 'check_label_color' => '444444', |
|
| 365 | - 'check_weight' => 'normal', |
|
| 366 | - |
|
| 367 | - 'section_font_size' => '18px', |
|
| 368 | - 'section_color' => '444444', |
|
| 369 | - 'section_weight' => 'bold', |
|
| 370 | - 'section_pad' => '15px 0 3px 0', |
|
| 371 | - 'section_mar_top' => '15px', |
|
| 357 | + 'bg_color_disabled' => 'ffffff', |
|
| 358 | + 'border_color_disabled' => 'E5E5E5', |
|
| 359 | + 'text_color_disabled' => 'A1A1A1', |
|
| 360 | + |
|
| 361 | + 'radio_align' => 'block', |
|
| 362 | + 'check_align' => 'block', |
|
| 363 | + 'check_font_size' => '13px', |
|
| 364 | + 'check_label_color' => '444444', |
|
| 365 | + 'check_weight' => 'normal', |
|
| 366 | + |
|
| 367 | + 'section_font_size' => '18px', |
|
| 368 | + 'section_color' => '444444', |
|
| 369 | + 'section_weight' => 'bold', |
|
| 370 | + 'section_pad' => '15px 0 3px 0', |
|
| 371 | + 'section_mar_top' => '15px', |
|
| 372 | 372 | 'section_mar_bottom' => '12px', |
| 373 | - 'section_bg_color' => '', |
|
| 374 | - 'section_border_color' => 'e8e8e8', |
|
| 375 | - 'section_border_width' => '2px', |
|
| 376 | - 'section_border_style' => 'solid', |
|
| 377 | - 'section_border_loc' => '-top', |
|
| 378 | - 'collapse_icon' => '6', |
|
| 379 | - 'collapse_pos' => 'after', |
|
| 380 | - 'repeat_icon' => '1', |
|
| 381 | - |
|
| 382 | - 'submit_style' => false, |
|
| 383 | - 'submit_font_size' => '14px', |
|
| 384 | - 'submit_width' => 'auto', |
|
| 385 | - 'submit_height' => 'auto', |
|
| 386 | - 'submit_bg_color' => 'ffffff', |
|
| 387 | - 'submit_border_color' => 'cccccc', |
|
| 388 | - 'submit_border_width' => '1px', |
|
| 389 | - 'submit_text_color' => '444444', |
|
| 390 | - 'submit_weight' => 'normal', |
|
| 391 | - 'submit_border_radius' => '4px', |
|
| 392 | - 'submit_bg_img' => '', |
|
| 393 | - 'submit_margin' => '10px', |
|
| 394 | - 'submit_padding' => '6px 11px', |
|
| 395 | - 'submit_shadow_color' => 'eeeeee', |
|
| 396 | - 'submit_hover_bg_color' => 'efefef', |
|
| 397 | - 'submit_hover_color' => '444444', |
|
| 398 | - 'submit_hover_border_color' => 'cccccc', |
|
| 399 | - 'submit_active_bg_color' => 'efefef', |
|
| 400 | - 'submit_active_color' => '444444', |
|
| 401 | - 'submit_active_border_color' => 'cccccc', |
|
| 402 | - |
|
| 403 | - 'border_radius' => '4px', |
|
| 404 | - 'error_bg' => 'F2DEDE', |
|
| 405 | - 'error_border' => 'EBCCD1', |
|
| 406 | - 'error_text' => 'B94A48', |
|
| 407 | - 'error_font_size' => '14px', |
|
| 408 | - |
|
| 409 | - 'success_bg_color' => 'DFF0D8', |
|
| 410 | - 'success_border_color' => 'D6E9C6', |
|
| 411 | - 'success_text_color' => '468847', |
|
| 412 | - 'success_font_size' => '14px', |
|
| 413 | - |
|
| 414 | - 'important_style' => false, |
|
| 415 | - |
|
| 416 | - 'custom_css' => '', |
|
| 417 | - ); |
|
| 418 | - } |
|
| 373 | + 'section_bg_color' => '', |
|
| 374 | + 'section_border_color' => 'e8e8e8', |
|
| 375 | + 'section_border_width' => '2px', |
|
| 376 | + 'section_border_style' => 'solid', |
|
| 377 | + 'section_border_loc' => '-top', |
|
| 378 | + 'collapse_icon' => '6', |
|
| 379 | + 'collapse_pos' => 'after', |
|
| 380 | + 'repeat_icon' => '1', |
|
| 381 | + |
|
| 382 | + 'submit_style' => false, |
|
| 383 | + 'submit_font_size' => '14px', |
|
| 384 | + 'submit_width' => 'auto', |
|
| 385 | + 'submit_height' => 'auto', |
|
| 386 | + 'submit_bg_color' => 'ffffff', |
|
| 387 | + 'submit_border_color' => 'cccccc', |
|
| 388 | + 'submit_border_width' => '1px', |
|
| 389 | + 'submit_text_color' => '444444', |
|
| 390 | + 'submit_weight' => 'normal', |
|
| 391 | + 'submit_border_radius' => '4px', |
|
| 392 | + 'submit_bg_img' => '', |
|
| 393 | + 'submit_margin' => '10px', |
|
| 394 | + 'submit_padding' => '6px 11px', |
|
| 395 | + 'submit_shadow_color' => 'eeeeee', |
|
| 396 | + 'submit_hover_bg_color' => 'efefef', |
|
| 397 | + 'submit_hover_color' => '444444', |
|
| 398 | + 'submit_hover_border_color' => 'cccccc', |
|
| 399 | + 'submit_active_bg_color' => 'efefef', |
|
| 400 | + 'submit_active_color' => '444444', |
|
| 401 | + 'submit_active_border_color' => 'cccccc', |
|
| 402 | + |
|
| 403 | + 'border_radius' => '4px', |
|
| 404 | + 'error_bg' => 'F2DEDE', |
|
| 405 | + 'error_border' => 'EBCCD1', |
|
| 406 | + 'error_text' => 'B94A48', |
|
| 407 | + 'error_font_size' => '14px', |
|
| 408 | + |
|
| 409 | + 'success_bg_color' => 'DFF0D8', |
|
| 410 | + 'success_border_color' => 'D6E9C6', |
|
| 411 | + 'success_text_color' => '468847', |
|
| 412 | + 'success_font_size' => '14px', |
|
| 413 | + |
|
| 414 | + 'important_style' => false, |
|
| 415 | + |
|
| 416 | + 'custom_css' => '', |
|
| 417 | + ); |
|
| 418 | + } |
|
| 419 | 419 | |
| 420 | 420 | public function get_field_name( $field_name, $post_field = 'post_content' ) { |
| 421 | 421 | return 'frm_style_setting' . ( empty( $post_field ) ? '' : '[' . $post_field . ']' ) . '[' . $field_name . ']'; |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | class FrmStyle { |
| 3 | - public $number = false; // Unique ID number of the current instance. |
|
| 3 | + public $number = false; // Unique ID number of the current instance. |
|
| 4 | 4 | public $id = 0; // the id of the post |
| 5 | 5 | |
| 6 | 6 | /** |
@@ -13,9 +13,9 @@ discard block |
||
| 13 | 13 | public function get_new() { |
| 14 | 14 | $this->id = 0; |
| 15 | 15 | |
| 16 | - $max_slug_value = pow(36, 6); |
|
| 16 | + $max_slug_value = pow( 36, 6 ); |
|
| 17 | 17 | $min_slug_value = 37; // we want to have at least 2 characters in the slug |
| 18 | - $key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 ); |
|
| 18 | + $key = base_convert( rand( $min_slug_value, $max_slug_value ), 10, 36 ); |
|
| 19 | 19 | |
| 20 | 20 | $style = array( |
| 21 | 21 | 'post_type' => FrmStylesController::$post_type, |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | public function update( $id = 'default' ) { |
| 42 | 42 | $all_instances = $this->get_all(); |
| 43 | 43 | |
| 44 | - if ( empty($id) ) { |
|
| 44 | + if ( empty( $id ) ) { |
|
| 45 | 45 | $new_style = (array) $this->get_new(); |
| 46 | 46 | $all_instances[] = $new_style; |
| 47 | 47 | } |
@@ -49,15 +49,15 @@ discard block |
||
| 49 | 49 | $action_ids = array(); |
| 50 | 50 | |
| 51 | 51 | foreach ( $all_instances as $number => $new_instance ) { |
| 52 | - $new_instance = stripslashes_deep( (array) $new_instance); |
|
| 52 | + $new_instance = stripslashes_deep( (array) $new_instance ); |
|
| 53 | 53 | $this->id = $new_instance['ID']; |
| 54 | - if ( $id != $this->id || ! $_POST || ! isset($_POST['frm_style_setting']) ) { |
|
| 55 | - $all_instances[ $number ] = $new_instance; |
|
| 54 | + if ( $id != $this->id || ! $_POST || ! isset( $_POST['frm_style_setting'] ) ) { |
|
| 55 | + $all_instances[$number] = $new_instance; |
|
| 56 | 56 | |
| 57 | - if ( $new_instance['menu_order'] && $_POST && empty($_POST['prev_menu_order']) && isset($_POST['frm_style_setting']['menu_order']) ) { |
|
| 57 | + if ( $new_instance['menu_order'] && $_POST && empty( $_POST['prev_menu_order'] ) && isset( $_POST['frm_style_setting']['menu_order'] ) ) { |
|
| 58 | 58 | // this style was set to default, so remove default setting on previous default style |
| 59 | 59 | $new_instance['menu_order'] = 0; |
| 60 | - $action_ids[] = $this->save($new_instance); |
|
| 60 | + $action_ids[] = $this->save( $new_instance ); |
|
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | // don't continue if not saving this style |
@@ -67,10 +67,10 @@ discard block |
||
| 67 | 67 | $new_instance['post_title'] = sanitize_text_field( $_POST['frm_style_setting']['post_title'] ); |
| 68 | 68 | $new_instance['post_content'] = $_POST['frm_style_setting']['post_content']; |
| 69 | 69 | $new_instance['post_type'] = FrmStylesController::$post_type; |
| 70 | - $new_instance['post_status'] = 'publish'; |
|
| 70 | + $new_instance['post_status'] = 'publish'; |
|
| 71 | 71 | $new_instance['menu_order'] = isset( $_POST['frm_style_setting']['menu_order'] ) ? absint( $_POST['frm_style_setting']['menu_order'] ) : 0; |
| 72 | 72 | |
| 73 | - if ( empty($id) ) { |
|
| 73 | + if ( empty( $id ) ) { |
|
| 74 | 74 | $new_instance['post_name'] = $new_instance['post_title']; |
| 75 | 75 | } |
| 76 | 76 | |
@@ -79,17 +79,17 @@ discard block |
||
| 79 | 79 | foreach ( $default_settings as $setting => $default ) { |
| 80 | 80 | if ( strpos( $setting, 'color' ) !== false || in_array( $setting, array( 'error_bg', 'error_border', 'error_text' ) ) ) { |
| 81 | 81 | //if is a color |
| 82 | - $new_instance['post_content'][ $setting ] = str_replace( '#', '', $new_instance['post_content'][ $setting ] ); |
|
| 83 | - } else if ( in_array( $setting, array( 'submit_style', 'important_style', 'auto_width' ) ) && ! isset( $new_instance['post_content'][ $setting ] ) ) { |
|
| 84 | - $new_instance['post_content'][ $setting ] = 0; |
|
| 82 | + $new_instance['post_content'][$setting] = str_replace( '#', '', $new_instance['post_content'][$setting] ); |
|
| 83 | + } else if ( in_array( $setting, array( 'submit_style', 'important_style', 'auto_width' ) ) && ! isset( $new_instance['post_content'][$setting] ) ) { |
|
| 84 | + $new_instance['post_content'][$setting] = 0; |
|
| 85 | 85 | } else if ( $setting == 'font' ) { |
| 86 | - $new_instance['post_content'][ $setting ] = $this->force_balanced_quotation( $new_instance['post_content'][ $setting ] ); |
|
| 86 | + $new_instance['post_content'][$setting] = $this->force_balanced_quotation( $new_instance['post_content'][$setting] ); |
|
| 87 | 87 | } |
| 88 | 88 | } |
| 89 | 89 | |
| 90 | - $all_instances[ $number ] = $new_instance; |
|
| 90 | + $all_instances[$number] = $new_instance; |
|
| 91 | 91 | |
| 92 | - $action_ids[] = $this->save($new_instance); |
|
| 92 | + $action_ids[] = $this->save( $new_instance ); |
|
| 93 | 93 | |
| 94 | 94 | } |
| 95 | 95 | |
@@ -103,9 +103,9 @@ discard block |
||
| 103 | 103 | */ |
| 104 | 104 | public function save_settings() { |
| 105 | 105 | $filename = FrmAppHelper::plugin_path() . '/css/custom_theme.css.php'; |
| 106 | - update_option( 'frm_last_style_update', date('njGi') ); |
|
| 106 | + update_option( 'frm_last_style_update', date( 'njGi' ) ); |
|
| 107 | 107 | |
| 108 | - if ( ! is_file($filename) ) { |
|
| 108 | + if ( ! is_file( $filename ) ) { |
|
| 109 | 109 | return; |
| 110 | 110 | } |
| 111 | 111 | |
@@ -114,11 +114,11 @@ discard block |
||
| 114 | 114 | $create_file = new FrmCreateFile( array( 'folder_name' => 'formidable/css', 'file_name' => 'formidablepro.css' ) ); |
| 115 | 115 | $create_file->create_file( $css ); |
| 116 | 116 | |
| 117 | - update_option('frmpro_css', $css); |
|
| 117 | + update_option( 'frmpro_css', $css ); |
|
| 118 | 118 | |
| 119 | 119 | $this->clear_cache(); |
| 120 | 120 | |
| 121 | - set_transient('frmpro_css', $css); |
|
| 121 | + set_transient( 'frmpro_css', $css ); |
|
| 122 | 122 | } |
| 123 | 123 | |
| 124 | 124 | private function get_css_content( $filename ) { |
@@ -150,7 +150,7 @@ discard block |
||
| 150 | 150 | } |
| 151 | 151 | |
| 152 | 152 | public function destroy( $id ) { |
| 153 | - return wp_delete_post($id); |
|
| 153 | + return wp_delete_post( $id ); |
|
| 154 | 154 | } |
| 155 | 155 | |
| 156 | 156 | public function get_one() { |
@@ -164,19 +164,19 @@ discard block |
||
| 164 | 164 | return $style; |
| 165 | 165 | } |
| 166 | 166 | |
| 167 | - $style = get_post($this->id); |
|
| 167 | + $style = get_post( $this->id ); |
|
| 168 | 168 | |
| 169 | 169 | if ( ! $style ) { |
| 170 | 170 | return $style; |
| 171 | 171 | } |
| 172 | 172 | |
| 173 | - $style->post_content = FrmAppHelper::maybe_json_decode($style->post_content); |
|
| 173 | + $style->post_content = FrmAppHelper::maybe_json_decode( $style->post_content ); |
|
| 174 | 174 | |
| 175 | 175 | $default_values = $this->get_defaults(); |
| 176 | 176 | |
| 177 | 177 | // fill default values |
| 178 | - $style->post_content = $this->override_defaults($style->post_content); |
|
| 179 | - $style->post_content = wp_parse_args( $style->post_content, $default_values); |
|
| 178 | + $style->post_content = $this->override_defaults( $style->post_content ); |
|
| 179 | + $style->post_content = wp_parse_args( $style->post_content, $default_values ); |
|
| 180 | 180 | |
| 181 | 181 | return $style; |
| 182 | 182 | } |
@@ -190,21 +190,21 @@ discard block |
||
| 190 | 190 | 'order' => $order, |
| 191 | 191 | ); |
| 192 | 192 | |
| 193 | - $temp_styles = FrmAppHelper::check_cache(serialize($post_atts), 'frm_styles', $post_atts, 'get_posts'); |
|
| 193 | + $temp_styles = FrmAppHelper::check_cache( serialize( $post_atts ), 'frm_styles', $post_atts, 'get_posts' ); |
|
| 194 | 194 | |
| 195 | - if ( empty($temp_styles) ) { |
|
| 195 | + if ( empty( $temp_styles ) ) { |
|
| 196 | 196 | global $wpdb; |
| 197 | 197 | // make sure there wasn't a conflict with the query |
| 198 | 198 | $query = $wpdb->prepare( 'SELECT * FROM ' . $wpdb->posts . ' WHERE post_type=%s AND post_status=%s ORDER BY post_title ASC LIMIT 99', FrmStylesController::$post_type, 'publish' ); |
| 199 | - $temp_styles = FrmAppHelper::check_cache('frm_backup_style_check', 'frm_styles', $query, 'get_results'); |
|
| 199 | + $temp_styles = FrmAppHelper::check_cache( 'frm_backup_style_check', 'frm_styles', $query, 'get_results' ); |
|
| 200 | 200 | |
| 201 | - if ( empty($temp_styles) ) { |
|
| 201 | + if ( empty( $temp_styles ) ) { |
|
| 202 | 202 | // create a new style if there are none |
| 203 | 203 | $new = $this->get_new(); |
| 204 | 204 | $new->post_title = $new->post_name = __( 'Formidable Style', 'formidable' ); |
| 205 | 205 | $new->menu_order = 1; |
| 206 | - $new = $this->save( (array) $new); |
|
| 207 | - $this->update('default'); |
|
| 206 | + $new = $this->save( (array) $new ); |
|
| 207 | + $this->update( 'default' ); |
|
| 208 | 208 | |
| 209 | 209 | $post_atts['include'] = $new; |
| 210 | 210 | |
@@ -228,25 +228,25 @@ discard block |
||
| 228 | 228 | } |
| 229 | 229 | } |
| 230 | 230 | |
| 231 | - $style->post_content = FrmAppHelper::maybe_json_decode($style->post_content); |
|
| 231 | + $style->post_content = FrmAppHelper::maybe_json_decode( $style->post_content ); |
|
| 232 | 232 | |
| 233 | 233 | // fill default values |
| 234 | - $style->post_content = $this->override_defaults($style->post_content); |
|
| 235 | - $style->post_content = wp_parse_args( $style->post_content, $default_values); |
|
| 234 | + $style->post_content = $this->override_defaults( $style->post_content ); |
|
| 235 | + $style->post_content = wp_parse_args( $style->post_content, $default_values ); |
|
| 236 | 236 | |
| 237 | - $styles[ $style->ID ] = $style; |
|
| 237 | + $styles[$style->ID] = $style; |
|
| 238 | 238 | } |
| 239 | 239 | |
| 240 | 240 | if ( ! $default_style ) { |
| 241 | - $default_style = reset($styles); |
|
| 242 | - $styles[ $default_style->ID ]->menu_order = 1; |
|
| 241 | + $default_style = reset( $styles ); |
|
| 242 | + $styles[$default_style->ID]->menu_order = 1; |
|
| 243 | 243 | } |
| 244 | 244 | |
| 245 | 245 | return $styles; |
| 246 | 246 | } |
| 247 | 247 | |
| 248 | 248 | public function get_default_style( $styles = null ) { |
| 249 | - if ( ! isset($styles) ) { |
|
| 249 | + if ( ! isset( $styles ) ) { |
|
| 250 | 250 | $styles = $this->get_all( 'menu_order', 'DESC', 1 ); |
| 251 | 251 | } |
| 252 | 252 | |
@@ -258,24 +258,24 @@ discard block |
||
| 258 | 258 | } |
| 259 | 259 | |
| 260 | 260 | public function override_defaults( $settings ) { |
| 261 | - if ( ! is_array($settings) ) { |
|
| 261 | + if ( ! is_array( $settings ) ) { |
|
| 262 | 262 | return $settings; |
| 263 | 263 | } |
| 264 | 264 | |
| 265 | - $settings['line_height'] = ( ! isset($settings['field_height']) || $settings['field_height'] == '' || $settings['field_height'] == 'auto') ? 'normal' : $settings['field_height']; |
|
| 265 | + $settings['line_height'] = ( ! isset( $settings['field_height'] ) || $settings['field_height'] == '' || $settings['field_height'] == 'auto' ) ? 'normal' : $settings['field_height']; |
|
| 266 | 266 | |
| 267 | - if ( ! isset($settings['form_desc_size']) && isset($settings['description_font_size']) ) { |
|
| 267 | + if ( ! isset( $settings['form_desc_size'] ) && isset( $settings['description_font_size'] ) ) { |
|
| 268 | 268 | $settings['form_desc_size'] = $settings['description_font_size']; |
| 269 | 269 | $settings['form_desc_color'] = $settings['description_color']; |
| 270 | 270 | $settings['title_color'] = $settings['label_color']; |
| 271 | 271 | } |
| 272 | 272 | |
| 273 | - if ( ! isset($settings['section_color']) && isset($settings['label_color']) ) { |
|
| 273 | + if ( ! isset( $settings['section_color'] ) && isset( $settings['label_color'] ) ) { |
|
| 274 | 274 | $settings['section_color'] = $settings['label_color']; |
| 275 | 275 | $settings['section_border_color'] = $settings['border_color']; |
| 276 | 276 | } |
| 277 | 277 | |
| 278 | - if ( ! isset($settings['submit_hover_bg_color']) && isset($settings['submit_bg_color']) ) { |
|
| 278 | + if ( ! isset( $settings['submit_hover_bg_color'] ) && isset( $settings['submit_bg_color'] ) ) { |
|
| 279 | 279 | $settings['submit_hover_bg_color'] = $settings['submit_bg_color']; |
| 280 | 280 | $settings['submit_hover_color'] = $settings['submit_text_color']; |
| 281 | 281 | $settings['submit_hover_border_color'] = $settings['submit_border_color']; |
@@ -18,8 +18,8 @@ discard block |
||
| 18 | 18 | $this->file_name = $atts['file_name']; |
| 19 | 19 | $this->error_message = isset( $atts['error_message'] ) ? $atts['error_message'] : ''; |
| 20 | 20 | $this->uploads = wp_upload_dir(); |
| 21 | - $this->chmod_dir = defined('FS_CHMOD_DIR') ? FS_CHMOD_DIR : ( fileperms( ABSPATH ) & 0777 | 0755 ); |
|
| 22 | - $this->chmod_file = defined('FS_CHMOD_FILE') ? FS_CHMOD_FILE : ( fileperms( ABSPATH . 'index.php' ) & 0777 | 0644 ); |
|
| 21 | + $this->chmod_dir = defined( 'FS_CHMOD_DIR' ) ? FS_CHMOD_DIR : ( fileperms( ABSPATH ) & 0777 | 0755 ); |
|
| 22 | + $this->chmod_file = defined( 'FS_CHMOD_FILE' ) ? FS_CHMOD_FILE : ( fileperms( ABSPATH . 'index.php' ) & 0777 | 0644 ); |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | public function create_file( $file_content ) { |
@@ -85,13 +85,13 @@ discard block |
||
| 85 | 85 | private function get_ftp_creds( $type ) { |
| 86 | 86 | $credentials = get_option( 'ftp_credentials', array( 'hostname' => '', 'username' => '' ) ); |
| 87 | 87 | |
| 88 | - $credentials['hostname'] = defined('FTP_HOST') ? FTP_HOST : $credentials['hostname']; |
|
| 89 | - $credentials['username'] = defined('FTP_USER') ? FTP_USER : $credentials['username']; |
|
| 90 | - $credentials['password'] = defined('FTP_PASS') ? FTP_PASS : ''; |
|
| 88 | + $credentials['hostname'] = defined( 'FTP_HOST' ) ? FTP_HOST : $credentials['hostname']; |
|
| 89 | + $credentials['username'] = defined( 'FTP_USER' ) ? FTP_USER : $credentials['username']; |
|
| 90 | + $credentials['password'] = defined( 'FTP_PASS' ) ? FTP_PASS : ''; |
|
| 91 | 91 | |
| 92 | 92 | // Check to see if we are setting the public/private keys for ssh |
| 93 | - $credentials['public_key'] = defined('FTP_PUBKEY') ? FTP_PUBKEY : ''; |
|
| 94 | - $credentials['private_key'] = defined('FTP_PRIKEY') ? FTP_PRIKEY : ''; |
|
| 93 | + $credentials['public_key'] = defined( 'FTP_PUBKEY' ) ? FTP_PUBKEY : ''; |
|
| 94 | + $credentials['private_key'] = defined( 'FTP_PRIKEY' ) ? FTP_PRIKEY : ''; |
|
| 95 | 95 | |
| 96 | 96 | // Sanitize the hostname, Some people might pass in odd-data: |
| 97 | 97 | $credentials['hostname'] = preg_replace( '|\w+://|', '', $credentials['hostname'] ); //Strip any schemes off |
@@ -1,12 +1,12 @@ |
||
| 1 | 1 | <li id="frm_delete_field_<?php echo esc_attr( $field['id'] ); ?>-<?php echo esc_attr( $opt_key ) ?>_container" class="frm_single_option"> |
| 2 | 2 | <a href="javascript:void(0)" class="frm_single_visible_hover frm_icon_font frm_delete_icon" data-fid="<?php echo esc_attr( $field['id'] ); ?>"> </a> |
| 3 | 3 | <?php if ( $field['type'] != 'select' ) { ?> |
| 4 | - <input type="<?php echo esc_attr( $field['type'] ) ?>" name="<?php echo esc_attr( $field_name ) ?><?php echo ( $field['type'] == 'checkbox' ) ? '[]' : ''; ?>" value="<?php echo esc_attr($field_val) ?>"<?php echo isset( $checked ) ? $checked : ''; ?>/> |
|
| 4 | + <input type="<?php echo esc_attr( $field['type'] ) ?>" name="<?php echo esc_attr( $field_name ) ?><?php echo ( $field['type'] == 'checkbox' ) ? '[]' : ''; ?>" value="<?php echo esc_attr( $field_val ) ?>"<?php echo isset( $checked ) ? $checked : ''; ?>/> |
|
| 5 | 5 | <?php } ?> |
| 6 | - <label class="frm_ipe_field_option field_<?php echo esc_attr( $field['id'] ) ?>_option <?php echo esc_attr( $field['separate_value'] ? 'frm_with_key' : '' ); ?>" id="<?php echo esc_attr( $html_id . '-' . $opt_key ) ?>"><?php echo ($opt == '') ? __( '(Blank)', 'formidable' ) : $opt ?></label> |
|
| 6 | + <label class="frm_ipe_field_option field_<?php echo esc_attr( $field['id'] ) ?>_option <?php echo esc_attr( $field['separate_value'] ? 'frm_with_key' : '' ); ?>" id="<?php echo esc_attr( $html_id . '-' . $opt_key ) ?>"><?php echo ( $opt == '' ) ? __( '(Blank)', 'formidable' ) : $opt ?></label> |
|
| 7 | 7 | <span class="frm_option_key field_<?php echo esc_attr( $field['id'] ) ?>_option_key<?php echo esc_attr( $field['separate_value'] ? '' : ' frm_hidden' ); ?>"> |
| 8 | 8 | <label class="frm-show-click frm_ipe_field_option_key" id="field_key_<?php echo esc_attr( $field['id'] . '-' . $opt_key ) ?>"><?php echo ( $field_val == '' ) ? esc_html__( '(Blank)', 'formidable' ) : $field_val ?></label> |
| 9 | 9 | </span> |
| 10 | 10 | </li> |
| 11 | 11 | <?php |
| 12 | -unset($field_val, $opt, $opt_key); |
|
| 12 | +unset( $field_val, $opt, $opt_key ); |
|
@@ -1,10 +1,10 @@ discard block |
||
| 1 | 1 | <div class="field-group field-group-background clearfix frm-first-row"> |
| 2 | 2 | <label><?php _e( 'Color', 'formidable' ) ?></label> |
| 3 | - <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('label_color') ) ?>" id="frm_label_color" class="hex" value="<?php echo esc_attr( $style->post_content['label_color'] ) ?>" /> |
|
| 3 | + <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'label_color' ) ) ?>" id="frm_label_color" class="hex" value="<?php echo esc_attr( $style->post_content['label_color'] ) ?>" /> |
|
| 4 | 4 | </div> |
| 5 | 5 | <div class="field-group clearfix frm-first-row"> |
| 6 | 6 | <label><?php _e( 'Weight', 'formidable' ) ?></label> |
| 7 | - <select name="<?php echo esc_attr( $frm_style->get_field_name('weight') ) ?>" id="frm_weight"> |
|
| 7 | + <select name="<?php echo esc_attr( $frm_style->get_field_name( 'weight' ) ) ?>" id="frm_weight"> |
|
| 8 | 8 | <?php foreach ( FrmStyle::get_bold_options() as $value => $name ) { ?> |
| 9 | 9 | <option value="<?php echo esc_attr( $value ) ?>" <?php selected( $style->post_content['weight'], $value ) ?>><?php echo esc_html( $name ) ?></option> |
| 10 | 10 | <?php } ?> |
@@ -12,45 +12,45 @@ discard block |
||
| 12 | 12 | </div> |
| 13 | 13 | <div class="field-group clearfix frm-first-row"> |
| 14 | 14 | <label><?php _e( 'Size', 'formidable' ) ?></label> |
| 15 | - <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('font_size') ) ?>" id="frm_font_size" value="<?php echo esc_attr($style->post_content['font_size']) ?>" size="3" /> |
|
| 15 | + <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'font_size' ) ) ?>" id="frm_font_size" value="<?php echo esc_attr( $style->post_content['font_size'] ) ?>" size="3" /> |
|
| 16 | 16 | </div> |
| 17 | 17 | |
| 18 | 18 | <div class="field-group clearfix frm_clear"> |
| 19 | 19 | <label><?php _e( 'Position', 'formidable' ) ?></label> |
| 20 | - <select name="<?php echo esc_attr( $frm_style->get_field_name('position') ) ?>" id="frm_position"> |
|
| 20 | + <select name="<?php echo esc_attr( $frm_style->get_field_name( 'position' ) ) ?>" id="frm_position"> |
|
| 21 | 21 | <?php foreach ( array( 'none' => __( 'top', 'formidable' ), 'left' => __( 'left', 'formidable' ), 'right' => __( 'right', 'formidable' ), 'no_label' => __( 'none', 'formidable' ) ) as $pos => $pos_label ) { ?> |
| 22 | - <option value="<?php echo esc_attr( $pos ) ?>" <?php selected($style->post_content['position'], $pos) ?>><?php echo esc_html( $pos_label ) ?></option> |
|
| 22 | + <option value="<?php echo esc_attr( $pos ) ?>" <?php selected( $style->post_content['position'], $pos ) ?>><?php echo esc_html( $pos_label ) ?></option> |
|
| 23 | 23 | <?php } ?> |
| 24 | 24 | </select> |
| 25 | 25 | </div> |
| 26 | 26 | |
| 27 | 27 | <div class="field-group clearfix"> |
| 28 | 28 | <label><?php _e( 'Align', 'formidable' ) ?></label> |
| 29 | - <select name="<?php echo esc_attr( $frm_style->get_field_name('align') ) ?>" id="frm_align"> |
|
| 30 | - <option value="left" <?php selected($style->post_content['align'], 'left') ?>><?php _e( 'left', 'formidable' ) ?></option> |
|
| 31 | - <option value="right" <?php selected($style->post_content['align'], 'right') ?>><?php _e( 'right', 'formidable' ) ?></option> |
|
| 29 | + <select name="<?php echo esc_attr( $frm_style->get_field_name( 'align' ) ) ?>" id="frm_align"> |
|
| 30 | + <option value="left" <?php selected( $style->post_content['align'], 'left' ) ?>><?php _e( 'left', 'formidable' ) ?></option> |
|
| 31 | + <option value="right" <?php selected( $style->post_content['align'], 'right' ) ?>><?php _e( 'right', 'formidable' ) ?></option> |
|
| 32 | 32 | </select> |
| 33 | 33 | </div> |
| 34 | 34 | |
| 35 | 35 | <div class="field-group clearfix"> |
| 36 | 36 | <label><?php _e( 'Width', 'formidable' ) ?></label> |
| 37 | - <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('width') ) ?>" id="frm_width" value="<?php echo esc_attr( $style->post_content['width'] ) ?>" /> |
|
| 37 | + <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'width' ) ) ?>" id="frm_width" value="<?php echo esc_attr( $style->post_content['width'] ) ?>" /> |
|
| 38 | 38 | </div> |
| 39 | 39 | |
| 40 | 40 | <div class="field-group clearfix frm_clear"> |
| 41 | 41 | <label><?php _e( 'Padding', 'formidable' ) ?></label> |
| 42 | - <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('label_padding') ) ?>" id="frm_label_padding" value="<?php echo esc_attr( $style->post_content['label_padding'] ) ?>" /> |
|
| 42 | + <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'label_padding' ) ) ?>" id="frm_label_padding" value="<?php echo esc_attr( $style->post_content['label_padding'] ) ?>" /> |
|
| 43 | 43 | </div> |
| 44 | 44 | |
| 45 | 45 | <div class="clear"></div> |
| 46 | 46 | <h3><?php _e( 'Required Indicator', 'formidable' ) ?></h3> |
| 47 | 47 | <div class="field-group field-group-border clearfix after-h3"> |
| 48 | 48 | <label class="background"><?php _e( 'Color', 'formidable' ) ?></label> |
| 49 | - <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('required_color') ) ?>" id="frm_required_color" class="hex" value="<?php echo esc_attr( $style->post_content['required_color'] ) ?>" /> |
|
| 49 | + <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'required_color' ) ) ?>" id="frm_required_color" class="hex" value="<?php echo esc_attr( $style->post_content['required_color'] ) ?>" /> |
|
| 50 | 50 | </div> |
| 51 | 51 | <div class="field-group clearfix after-h3"> |
| 52 | 52 | <label><?php _e( 'Weight', 'formidable' ) ?></label> |
| 53 | - <select name="<?php echo esc_attr( $frm_style->get_field_name('required_weight') ) ?>" id="frm_required_weight"> |
|
| 53 | + <select name="<?php echo esc_attr( $frm_style->get_field_name( 'required_weight' ) ) ?>" id="frm_required_weight"> |
|
| 54 | 54 | <?php foreach ( FrmStyle::get_bold_options() as $value => $name ) { ?> |
| 55 | 55 | <option value="<?php echo esc_attr( $value ) ?>" <?php selected( $style->post_content['required_weight'], $value ) ?>><?php echo esc_html( $name ) ?></option> |
| 56 | 56 | <?php } ?> |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <p class="frm_no_top_margin"> |
| 2 | 2 | <label for="frm_submit_style"> |
| 3 | - <input type="checkbox" name="<?php echo esc_attr( $frm_style->get_field_name('submit_style') ) ?>" id="frm_submit_style" <?php checked( $style->post_content['submit_style'], 1 ) ?> value="1" /> |
|
| 3 | + <input type="checkbox" name="<?php echo esc_attr( $frm_style->get_field_name( 'submit_style' ) ) ?>" id="frm_submit_style" <?php checked( $style->post_content['submit_style'], 1 ) ?> value="1" /> |
|
| 4 | 4 | <?php esc_html_e( 'Disable submit button styling', 'formidable' ); ?> |
| 5 | 5 | <span class="frm_help frm_icon_font frm_tooltip_icon" title="<?php esc_attr_e( 'Note: If disabled, you may not see the change take effect until you make 2 more styling changes or click "Update Options".', 'formidable' ) ?>"></span> |
| 6 | 6 | </label> |
@@ -9,10 +9,10 @@ discard block |
||
| 9 | 9 | <div class="posttypediv"> |
| 10 | 10 | <ul class="posttype-tabs add-menu-item-tabs"> |
| 11 | 11 | <li <?php echo ( 'default' == $current_tab ? ' class="tabs"' : '' ); ?>> |
| 12 | - <a href="<?php echo esc_url('?page=formidable-styles&page-tab=default#tabs-panel-button-default') ?>" class="nav-tab-link" data-type="tabs-panel-button-default" ><?php _e( 'Default', 'formidable' ) ?></a> |
|
| 12 | + <a href="<?php echo esc_url( '?page=formidable-styles&page-tab=default#tabs-panel-button-default' ) ?>" class="nav-tab-link" data-type="tabs-panel-button-default" ><?php _e( 'Default', 'formidable' ) ?></a> |
|
| 13 | 13 | </li> |
| 14 | 14 | <li <?php echo ( 'button-hover' == $current_tab ? ' class="tabs"' : '' ); ?>> |
| 15 | - <a href="<?php echo esc_url('?page=formidable-styles&page-tab=button-hover#page-button-hover') ?>" class="nav-tab-link" data-type="tabs-panel-button-hover" ><?php _e( 'Hover', 'formidable' ) ?></a> |
|
| 15 | + <a href="<?php echo esc_url( '?page=formidable-styles&page-tab=button-hover#page-button-hover' ) ?>" class="nav-tab-link" data-type="tabs-panel-button-hover" ><?php _e( 'Hover', 'formidable' ) ?></a> |
|
| 16 | 16 | </li> |
| 17 | 17 | <li <?php echo ( 'button-click' == $current_tab ? ' class="tabs"' : '' ); ?>> |
| 18 | 18 | <a href="?page=formidable-styles&page-tab=button-click#tabs-panel-button-click" class="nav-tab-link" data-type="tabs-panel-button-click"><?php _e( 'Click', 'formidable' ) ?></a> |
@@ -24,22 +24,22 @@ discard block |
||
| 24 | 24 | ?>"> |
| 25 | 25 | <div class="field-group field-group-border clearfix"> |
| 26 | 26 | <label><?php _e( 'Size', 'formidable' ) ?></label> |
| 27 | - <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('submit_font_size') ) ?>" id="frm_submit_font_size" value="<?php echo esc_attr( $style->post_content['submit_font_size'] ) ?>" size="3" /> |
|
| 27 | + <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'submit_font_size' ) ) ?>" id="frm_submit_font_size" value="<?php echo esc_attr( $style->post_content['submit_font_size'] ) ?>" size="3" /> |
|
| 28 | 28 | </div> |
| 29 | 29 | |
| 30 | 30 | <div class="field-group clearfix"> |
| 31 | 31 | <label><?php _e( 'Width', 'formidable' ) ?></label> |
| 32 | - <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('submit_width') ) ?>" id="frm_submit_width" value="<?php echo esc_attr( $style->post_content['submit_width'] ) ?>" size="5" /> |
|
| 32 | + <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'submit_width' ) ) ?>" id="frm_submit_width" value="<?php echo esc_attr( $style->post_content['submit_width'] ) ?>" size="5" /> |
|
| 33 | 33 | </div> |
| 34 | 34 | |
| 35 | 35 | <div class="field-group clearfix"> |
| 36 | 36 | <label><?php _e( 'Height', 'formidable' ) ?></label> |
| 37 | - <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('submit_height') ) ?>" id="frm_submit_height" value="<?php echo esc_attr( $style->post_content['submit_height'] ) ?>" size="5" /> |
|
| 37 | + <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'submit_height' ) ) ?>" id="frm_submit_height" value="<?php echo esc_attr( $style->post_content['submit_height'] ) ?>" size="5" /> |
|
| 38 | 38 | </div> |
| 39 | 39 | |
| 40 | 40 | <div class="field-group clearfix"> |
| 41 | 41 | <label><?php _e( 'Weight', 'formidable' ) ?></label> |
| 42 | - <select name="<?php echo esc_attr( $frm_style->get_field_name('submit_weight') ) ?>" id="frm_submit_weight"> |
|
| 42 | + <select name="<?php echo esc_attr( $frm_style->get_field_name( 'submit_weight' ) ) ?>" id="frm_submit_weight"> |
|
| 43 | 43 | <?php foreach ( FrmStyle::get_bold_options() as $value => $name ) { ?> |
| 44 | 44 | <option value="<?php echo esc_attr( $value ) ?>" <?php selected( $style->post_content['submit_weight'], $value ) ?>><?php echo esc_html( $name ) ?></option> |
| 45 | 45 | <?php } ?> |
@@ -48,48 +48,48 @@ discard block |
||
| 48 | 48 | |
| 49 | 49 | <div class="field-group clearfix"> |
| 50 | 50 | <label><?php _e( 'Corners', 'formidable' ) ?></label> |
| 51 | - <input type="text" value="<?php echo esc_attr( $style->post_content['submit_border_radius'] ) ?>" name="<?php echo esc_attr( $frm_style->get_field_name('submit_border_radius') ) ?>" id="frm_submit_border_radius" size="4"/> |
|
| 51 | + <input type="text" value="<?php echo esc_attr( $style->post_content['submit_border_radius'] ) ?>" name="<?php echo esc_attr( $frm_style->get_field_name( 'submit_border_radius' ) ) ?>" id="frm_submit_border_radius" size="4"/> |
|
| 52 | 52 | </div> |
| 53 | 53 | |
| 54 | 54 | <div class="field-group field-group-border clearfix"> |
| 55 | 55 | <label><?php _e( 'BG Color', 'formidable' ) ?></label> |
| 56 | - <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('submit_bg_color') ) ?>" id="frm_submit_bg_color" class="hex" value="<?php echo esc_attr( $style->post_content['submit_bg_color'] ) ?>" /> |
|
| 56 | + <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'submit_bg_color' ) ) ?>" id="frm_submit_bg_color" class="hex" value="<?php echo esc_attr( $style->post_content['submit_bg_color'] ) ?>" /> |
|
| 57 | 57 | </div> |
| 58 | 58 | |
| 59 | 59 | <div class="field-group clearfix"> |
| 60 | 60 | <label><?php _e( 'Text', 'formidable' ) ?></label> |
| 61 | - <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('submit_text_color') ) ?>" id="frm_submit_text_color" class="hex" value="<?php echo esc_attr( $style->post_content['submit_text_color'] ) ?>" /> |
|
| 61 | + <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'submit_text_color' ) ) ?>" id="frm_submit_text_color" class="hex" value="<?php echo esc_attr( $style->post_content['submit_text_color'] ) ?>" /> |
|
| 62 | 62 | </div> |
| 63 | 63 | |
| 64 | 64 | <div class="field-group field-group-border clearfix"> |
| 65 | 65 | <label><?php _e( 'Border', 'formidable' ) ?></label> |
| 66 | - <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('submit_border_color') ) ?>" id="frm_submit_border_color" class="hex" value="<?php echo esc_attr( $style->post_content['submit_border_color'] ) ?>" /> |
|
| 66 | + <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'submit_border_color' ) ) ?>" id="frm_submit_border_color" class="hex" value="<?php echo esc_attr( $style->post_content['submit_border_color'] ) ?>" /> |
|
| 67 | 67 | </div> |
| 68 | 68 | |
| 69 | 69 | <div class="field-group clearfix"> |
| 70 | 70 | <label><?php _e( 'Thickness', 'formidable' ) ?></label> |
| 71 | - <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('submit_border_width') ) ?>" id="frm_submit_border_width" value="<?php echo esc_attr( $style->post_content['submit_border_width'] ) ?>" size="4" /> |
|
| 71 | + <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'submit_border_width' ) ) ?>" id="frm_submit_border_width" value="<?php echo esc_attr( $style->post_content['submit_border_width'] ) ?>" size="4" /> |
|
| 72 | 72 | </div> |
| 73 | 73 | |
| 74 | 74 | <div class="field-group clearfix"> |
| 75 | 75 | <label><?php _e( 'Shadow', 'formidable' ) ?></label> |
| 76 | - <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('submit_shadow_color') ) ?>" id="frm_submit_shadow_color" class="hex" value="<?php echo esc_attr( $style->post_content['submit_shadow_color'] ) ?>" /> |
|
| 76 | + <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'submit_shadow_color' ) ) ?>" id="frm_submit_shadow_color" class="hex" value="<?php echo esc_attr( $style->post_content['submit_shadow_color'] ) ?>" /> |
|
| 77 | 77 | </div> |
| 78 | 78 | |
| 79 | 79 | <div class="clear"></div> |
| 80 | 80 | <div class="field-group field-group-border frm-full"> |
| 81 | 81 | <label><?php _e( 'BG Image', 'formidable' ) ?></label> |
| 82 | - <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('submit_bg_img') ) ?>" id="frm_submit_bg_img" value="<?php echo esc_attr( $style->post_content['submit_bg_img'] ) ?>" /> |
|
| 82 | + <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'submit_bg_img' ) ) ?>" id="frm_submit_bg_img" value="<?php echo esc_attr( $style->post_content['submit_bg_img'] ) ?>" /> |
|
| 83 | 83 | </div> |
| 84 | 84 | |
| 85 | 85 | <div class="field-group field-group-border clearfix"> |
| 86 | 86 | <label><?php _e( 'Margin', 'formidable' ) ?></label> |
| 87 | - <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('submit_margin') ) ?>" id="frm_submit_margin" value="<?php echo esc_attr( $style->post_content['submit_margin'] ) ?>" size="6" /> |
|
| 87 | + <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'submit_margin' ) ) ?>" id="frm_submit_margin" value="<?php echo esc_attr( $style->post_content['submit_margin'] ) ?>" size="6" /> |
|
| 88 | 88 | </div> |
| 89 | 89 | |
| 90 | 90 | <div class="field-group clearfix"> |
| 91 | 91 | <label><?php _e( 'Padding', 'formidable' ) ?></label> |
| 92 | - <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('submit_padding') ) ?>" id="frm_submit_padding" value="<?php echo esc_attr( $style->post_content['submit_padding'] ) ?>" size="6" /> |
|
| 92 | + <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'submit_padding' ) ) ?>" id="frm_submit_padding" value="<?php echo esc_attr( $style->post_content['submit_padding'] ) ?>" size="6" /> |
|
| 93 | 93 | </div> |
| 94 | 94 | <div class="clear"></div> |
| 95 | 95 | </div><!-- /.tabs-panel --> |
@@ -99,17 +99,17 @@ discard block |
||
| 99 | 99 | ?>"> |
| 100 | 100 | <div class="field-group clearfix"> |
| 101 | 101 | <label><?php _e( 'BG Color', 'formidable' ) ?></label> |
| 102 | - <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('submit_hover_bg_color') ) ?>" id="frm_submit_hover_bg_color" class="hex" value="<?php echo esc_attr( $style->post_content['submit_hover_bg_color'] ) ?>" /> |
|
| 102 | + <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'submit_hover_bg_color' ) ) ?>" id="frm_submit_hover_bg_color" class="hex" value="<?php echo esc_attr( $style->post_content['submit_hover_bg_color'] ) ?>" /> |
|
| 103 | 103 | </div> |
| 104 | 104 | |
| 105 | 105 | <div class="field-group clearfix"> |
| 106 | 106 | <label><?php _e( 'Text', 'formidable' ) ?></label> |
| 107 | - <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('submit_hover_color') ) ?>" id="frm_submit_hover_color" class="hex" value="<?php echo esc_attr( $style->post_content['submit_hover_color'] ) ?>" /> |
|
| 107 | + <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'submit_hover_color' ) ) ?>" id="frm_submit_hover_color" class="hex" value="<?php echo esc_attr( $style->post_content['submit_hover_color'] ) ?>" /> |
|
| 108 | 108 | </div> |
| 109 | 109 | |
| 110 | 110 | <div class="field-group clearfix"> |
| 111 | 111 | <label><?php _e( 'Border', 'formidable' ) ?></label> |
| 112 | - <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('submit_hover_border_color') ) ?>" id="frm_submit_hover_border_color" class="hex" value="<?php echo esc_attr( $style->post_content['submit_hover_border_color'] ) ?>" /> |
|
| 112 | + <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'submit_hover_border_color' ) ) ?>" id="frm_submit_hover_border_color" class="hex" value="<?php echo esc_attr( $style->post_content['submit_hover_border_color'] ) ?>" /> |
|
| 113 | 113 | </div> |
| 114 | 114 | |
| 115 | 115 | <div class="clear"></div> |
@@ -120,17 +120,17 @@ discard block |
||
| 120 | 120 | ?>"> |
| 121 | 121 | <div class="field-group clearfix"> |
| 122 | 122 | <label><?php _e( 'BG Color', 'formidable' ) ?></label> |
| 123 | - <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('submit_active_bg_color') ) ?>" id="frm_submit_active_bg_color" class="hex" value="<?php echo esc_attr( $style->post_content['submit_active_bg_color'] ) ?>" /> |
|
| 123 | + <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'submit_active_bg_color' ) ) ?>" id="frm_submit_active_bg_color" class="hex" value="<?php echo esc_attr( $style->post_content['submit_active_bg_color'] ) ?>" /> |
|
| 124 | 124 | </div> |
| 125 | 125 | |
| 126 | 126 | <div class="field-group clearfix"> |
| 127 | 127 | <label><?php _e( 'Text', 'formidable' ) ?></label> |
| 128 | - <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('submit_active_color') ) ?>" id="frm_submit_active_color" class="hex" value="<?php echo esc_attr( $style->post_content['submit_active_color'] ) ?>" /> |
|
| 128 | + <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'submit_active_color' ) ) ?>" id="frm_submit_active_color" class="hex" value="<?php echo esc_attr( $style->post_content['submit_active_color'] ) ?>" /> |
|
| 129 | 129 | </div> |
| 130 | 130 | |
| 131 | 131 | <div class="field-group clearfix"> |
| 132 | 132 | <label><?php _e( 'Border', 'formidable' ) ?></label> |
| 133 | - <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('submit_active_border_color') ) ?>" id="frm_submit_active_border_color" class="hex" value="<?php echo esc_attr( $style->post_content['submit_active_border_color'] ) ?>" /> |
|
| 133 | + <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'submit_active_border_color' ) ) ?>" id="frm_submit_active_border_color" class="hex" value="<?php echo esc_attr( $style->post_content['submit_active_border_color'] ) ?>" /> |
|
| 134 | 134 | </div> |
| 135 | 135 | |
| 136 | 136 | <div class="clear"></div> |
@@ -2,26 +2,26 @@ discard block |
||
| 2 | 2 | |
| 3 | 3 | class FrmSettingsController { |
| 4 | 4 | |
| 5 | - public static function menu() { |
|
| 5 | + public static function menu() { |
|
| 6 | 6 | // Make sure admins can see the menu items |
| 7 | 7 | FrmAppHelper::force_capability( 'frm_change_settings' ); |
| 8 | 8 | |
| 9 | - add_submenu_page( 'formidable', 'Formidable | ' . __( 'Global Settings', 'formidable' ), __( 'Global Settings', 'formidable' ), 'frm_change_settings', 'formidable-settings', 'FrmSettingsController::route' ); |
|
| 10 | - } |
|
| 9 | + add_submenu_page( 'formidable', 'Formidable | ' . __( 'Global Settings', 'formidable' ), __( 'Global Settings', 'formidable' ), 'frm_change_settings', 'formidable-settings', 'FrmSettingsController::route' ); |
|
| 10 | + } |
|
| 11 | 11 | |
| 12 | - public static function license_box() { |
|
| 12 | + public static function license_box() { |
|
| 13 | 13 | $a = FrmAppHelper::simple_get( 't', 'sanitize_title', 'general_settings' ); |
| 14 | - include( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/license_box.php' ); |
|
| 15 | - } |
|
| 14 | + include( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/license_box.php' ); |
|
| 15 | + } |
|
| 16 | 16 | |
| 17 | - public static function display_form( $errors = array(), $message = '' ) { |
|
| 18 | - global $frm_vars; |
|
| 17 | + public static function display_form( $errors = array(), $message = '' ) { |
|
| 18 | + global $frm_vars; |
|
| 19 | 19 | |
| 20 | - $frm_settings = FrmAppHelper::get_settings(); |
|
| 21 | - $frm_roles = FrmAppHelper::frm_capabilities(); |
|
| 20 | + $frm_settings = FrmAppHelper::get_settings(); |
|
| 21 | + $frm_roles = FrmAppHelper::frm_capabilities(); |
|
| 22 | 22 | |
| 23 | - $uploads = wp_upload_dir(); |
|
| 24 | - $target_path = $uploads['basedir'] . '/formidable/css'; |
|
| 23 | + $uploads = wp_upload_dir(); |
|
| 24 | + $target_path = $uploads['basedir'] . '/formidable/css'; |
|
| 25 | 25 | |
| 26 | 26 | $sections = array(); |
| 27 | 27 | if ( apply_filters( 'frm_include_addon_page', false ) ) { |
@@ -30,53 +30,53 @@ discard block |
||
| 30 | 30 | 'name' => __( 'Plugin Licenses', 'formidable' ), |
| 31 | 31 | ); |
| 32 | 32 | } |
| 33 | - $sections = apply_filters( 'frm_add_settings_section', $sections ); |
|
| 33 | + $sections = apply_filters( 'frm_add_settings_section', $sections ); |
|
| 34 | 34 | |
| 35 | - $captcha_lang = FrmAppHelper::locales( 'captcha' ); |
|
| 35 | + $captcha_lang = FrmAppHelper::locales( 'captcha' ); |
|
| 36 | 36 | |
| 37 | - require( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/form.php' ); |
|
| 38 | - } |
|
| 37 | + require( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/form.php' ); |
|
| 38 | + } |
|
| 39 | 39 | |
| 40 | - public static function process_form( $stop_load = false ) { |
|
| 41 | - global $frm_vars; |
|
| 40 | + public static function process_form( $stop_load = false ) { |
|
| 41 | + global $frm_vars; |
|
| 42 | 42 | |
| 43 | - $frm_settings = FrmAppHelper::get_settings(); |
|
| 43 | + $frm_settings = FrmAppHelper::get_settings(); |
|
| 44 | 44 | |
| 45 | 45 | $process_form = FrmAppHelper::get_post_param( 'process_form', '', 'sanitize_text_field' ); |
| 46 | 46 | if ( ! wp_verify_nonce( $process_form, 'process_form_nonce' ) ) { |
| 47 | - wp_die( $frm_settings->admin_permission ); |
|
| 48 | - } |
|
| 47 | + wp_die( $frm_settings->admin_permission ); |
|
| 48 | + } |
|
| 49 | 49 | |
| 50 | - $errors = array(); |
|
| 51 | - $message = ''; |
|
| 50 | + $errors = array(); |
|
| 51 | + $message = ''; |
|
| 52 | 52 | |
| 53 | - if ( ! isset( $frm_vars['settings_routed'] ) || ! $frm_vars['settings_routed'] ) { |
|
| 54 | - //$errors = $frm_settings->validate($_POST,array()); |
|
| 55 | - $frm_settings->update( stripslashes_deep( $_POST ) ); |
|
| 53 | + if ( ! isset( $frm_vars['settings_routed'] ) || ! $frm_vars['settings_routed'] ) { |
|
| 54 | + //$errors = $frm_settings->validate($_POST,array()); |
|
| 55 | + $frm_settings->update( stripslashes_deep( $_POST ) ); |
|
| 56 | 56 | |
| 57 | - if ( empty( $errors ) ) { |
|
| 58 | - $frm_settings->store(); |
|
| 59 | - $message = __( 'Settings Saved', 'formidable' ); |
|
| 60 | - } |
|
| 61 | - } else { |
|
| 62 | - $message = __( 'Settings Saved', 'formidable' ); |
|
| 63 | - } |
|
| 57 | + if ( empty( $errors ) ) { |
|
| 58 | + $frm_settings->store(); |
|
| 59 | + $message = __( 'Settings Saved', 'formidable' ); |
|
| 60 | + } |
|
| 61 | + } else { |
|
| 62 | + $message = __( 'Settings Saved', 'formidable' ); |
|
| 63 | + } |
|
| 64 | 64 | |
| 65 | 65 | if ( $stop_load == 'stop_load' ) { |
| 66 | - $frm_vars['settings_routed'] = true; |
|
| 67 | - return; |
|
| 68 | - } |
|
| 66 | + $frm_vars['settings_routed'] = true; |
|
| 67 | + return; |
|
| 68 | + } |
|
| 69 | 69 | |
| 70 | - self::display_form( $errors, $message ); |
|
| 71 | - } |
|
| 70 | + self::display_form( $errors, $message ); |
|
| 71 | + } |
|
| 72 | 72 | |
| 73 | - public static function route( $stop_load = false ) { |
|
| 74 | - $action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action'; |
|
| 73 | + public static function route( $stop_load = false ) { |
|
| 74 | + $action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action'; |
|
| 75 | 75 | $action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' ); |
| 76 | - if ( $action == 'process-form' ) { |
|
| 76 | + if ( $action == 'process-form' ) { |
|
| 77 | 77 | self::process_form( $stop_load ); |
| 78 | - } else if ( $stop_load != 'stop_load' ) { |
|
| 78 | + } else if ( $stop_load != 'stop_load' ) { |
|
| 79 | 79 | self::display_form(); |
| 80 | - } |
|
| 81 | - } |
|
| 80 | + } |
|
| 81 | + } |
|
| 82 | 82 | } |
@@ -1,10 +1,10 @@ discard block |
||
| 1 | 1 | <div class="field-group field-group-background clearfix frm-first-row"> |
| 2 | 2 | <label><?php _e( 'Color', 'formidable' ) ?></label> |
| 3 | - <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('description_color') ) ?>" id="frm_description_color" class="hex" value="<?php echo esc_attr( $style->post_content['description_color'] ) ?>" /> |
|
| 3 | + <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'description_color' ) ) ?>" id="frm_description_color" class="hex" value="<?php echo esc_attr( $style->post_content['description_color'] ) ?>" /> |
|
| 4 | 4 | </div> |
| 5 | 5 | <div class="field-group clearfix frm-first-row"> |
| 6 | 6 | <label><?php _e( 'Weight', 'formidable' ) ?></label> |
| 7 | - <select name="<?php echo esc_attr( $frm_style->get_field_name('description_weight') ) ?>" id="frm_description_weight"> |
|
| 7 | + <select name="<?php echo esc_attr( $frm_style->get_field_name( 'description_weight' ) ) ?>" id="frm_description_weight"> |
|
| 8 | 8 | <?php foreach ( FrmStyle::get_bold_options() as $value => $name ) { ?> |
| 9 | 9 | <option value="<?php echo esc_attr( $value ) ?>" <?php selected( $style->post_content['description_weight'], $value ) ?>><?php echo esc_html( $name ) ?></option> |
| 10 | 10 | <?php } ?> |
@@ -12,25 +12,25 @@ discard block |
||
| 12 | 12 | </div> |
| 13 | 13 | <div class="field-group clearfix frm-first-row"> |
| 14 | 14 | <label><?php _e( 'Style', 'formidable' ) ?></label> |
| 15 | - <select name="<?php echo esc_attr( $frm_style->get_field_name('description_style') ) ?>" id="frm_description_style"> |
|
| 16 | - <option value="normal" <?php selected($style->post_content['description_style'], 'normal') ?>><?php _e( 'normal', 'formidable' ) ?></option> |
|
| 17 | - <option value="italic" <?php selected($style->post_content['description_style'], 'italic') ?>><?php _e( 'italic', 'formidable' ) ?></option> |
|
| 15 | + <select name="<?php echo esc_attr( $frm_style->get_field_name( 'description_style' ) ) ?>" id="frm_description_style"> |
|
| 16 | + <option value="normal" <?php selected( $style->post_content['description_style'], 'normal' ) ?>><?php _e( 'normal', 'formidable' ) ?></option> |
|
| 17 | + <option value="italic" <?php selected( $style->post_content['description_style'], 'italic' ) ?>><?php _e( 'italic', 'formidable' ) ?></option> |
|
| 18 | 18 | </select> |
| 19 | 19 | </div> |
| 20 | 20 | |
| 21 | 21 | <div class="field-group clearfix"> |
| 22 | 22 | <label><?php _e( 'Size', 'formidable' ) ?></label> |
| 23 | - <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('description_font_size') ) ?>" id="frm_description_font_size" value="<?php echo esc_attr( $style->post_content['description_font_size'] ) ?>" size="3" /> |
|
| 23 | + <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'description_font_size' ) ) ?>" id="frm_description_font_size" value="<?php echo esc_attr( $style->post_content['description_font_size'] ) ?>" size="3" /> |
|
| 24 | 24 | </div> |
| 25 | 25 | <div class="field-group clearfix"> |
| 26 | 26 | <label><?php _e( 'Align', 'formidable' ) ?></label> |
| 27 | - <select name="<?php echo esc_attr( $frm_style->get_field_name('description_align') ) ?>" id="frm_description_align"> |
|
| 28 | - <option value="left" <?php selected($style->post_content['description_align'], 'left') ?>><?php _e( 'left', 'formidable' ) ?></option> |
|
| 29 | - <option value="right" <?php selected($style->post_content['description_align'], 'right') ?>><?php _e( 'right', 'formidable' ) ?></option> |
|
| 27 | + <select name="<?php echo esc_attr( $frm_style->get_field_name( 'description_align' ) ) ?>" id="frm_description_align"> |
|
| 28 | + <option value="left" <?php selected( $style->post_content['description_align'], 'left' ) ?>><?php _e( 'left', 'formidable' ) ?></option> |
|
| 29 | + <option value="right" <?php selected( $style->post_content['description_align'], 'right' ) ?>><?php _e( 'right', 'formidable' ) ?></option> |
|
| 30 | 30 | </select> |
| 31 | 31 | </div> |
| 32 | 32 | <div class="field-group clearfix"> |
| 33 | 33 | <label><?php _e( 'Margin', 'formidable' ) ?></label> |
| 34 | - <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('description_margin') ) ?>" id="frm_description_margin" value="<?php echo esc_attr( $style->post_content['description_margin'] ) ?>" size="3" /> |
|
| 34 | + <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'description_margin' ) ) ?>" id="frm_description_margin" value="<?php echo esc_attr( $style->post_content['description_margin'] ) ?>" size="3" /> |
|
| 35 | 35 | </div> |
| 36 | 36 | <div class="clear"></div> |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if ( ! defined('ABSPATH') ) { |
|
| 2 | +if ( ! defined( 'ABSPATH' ) ) { |
|
| 3 | 3 | die( 'You are not allowed to call this page directly.' ); |
| 4 | 4 | } |
| 5 | 5 | |
@@ -23,11 +23,11 @@ discard block |
||
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | public static function plugin_folder() { |
| 26 | - return basename(self::plugin_path()); |
|
| 26 | + return basename( self::plugin_path() ); |
|
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | public static function plugin_path() { |
| 30 | - return dirname(dirname(dirname(__FILE__))); |
|
| 30 | + return dirname( dirname( dirname( __FILE__ ) ) ); |
|
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | public static function plugin_url() { |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | * @return string |
| 55 | 55 | */ |
| 56 | 56 | public static function site_name() { |
| 57 | - return get_option('blogname'); |
|
| 57 | + return get_option( 'blogname' ); |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | public static function make_affiliate_url( $url ) { |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | public static function get_affiliate() { |
| 69 | - $affiliate_id = apply_filters( 'frm_affiliate_link', get_option('frm_aff') ); |
|
| 69 | + $affiliate_id = apply_filters( 'frm_affiliate_link', get_option( 'frm_aff' ) ); |
|
| 70 | 70 | $affiliate_id = strtolower( $affiliate_id ); |
| 71 | 71 | $allowed_affiliates = array( 'mojo' ); |
| 72 | 72 | if ( ! in_array( $affiliate_id, $allowed_affiliates ) ) { |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | */ |
| 86 | 86 | public static function get_settings() { |
| 87 | 87 | global $frm_settings; |
| 88 | - if ( empty($frm_settings) ) { |
|
| 88 | + if ( empty( $frm_settings ) ) { |
|
| 89 | 89 | $frm_settings = new FrmSettings(); |
| 90 | 90 | } |
| 91 | 91 | return $frm_settings; |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | } |
| 107 | 107 | |
| 108 | 108 | public static function pro_is_installed() { |
| 109 | - return apply_filters('frm_pro_installed', false); |
|
| 109 | + return apply_filters( 'frm_pro_installed', false ); |
|
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | /** |
@@ -150,7 +150,7 @@ discard block |
||
| 150 | 150 | * @return boolean |
| 151 | 151 | */ |
| 152 | 152 | public static function doing_ajax() { |
| 153 | - return defined('DOING_AJAX') && DOING_AJAX && ! self::is_preview_page(); |
|
| 153 | + return defined( 'DOING_AJAX' ) && DOING_AJAX && ! self::is_preview_page(); |
|
| 154 | 154 | } |
| 155 | 155 | |
| 156 | 156 | /** |
@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | * @return boolean |
| 171 | 171 | */ |
| 172 | 172 | public static function is_admin() { |
| 173 | - return is_admin() && ( ! defined('DOING_AJAX') || ! DOING_AJAX ); |
|
| 173 | + return is_admin() && ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX ); |
|
| 174 | 174 | } |
| 175 | 175 | |
| 176 | 176 | /** |
@@ -196,7 +196,7 @@ discard block |
||
| 196 | 196 | * @return string |
| 197 | 197 | */ |
| 198 | 198 | public static function get_server_value( $value ) { |
| 199 | - return isset( $_SERVER[ $value ] ) ? wp_strip_all_tags( $_SERVER[ $value ] ) : ''; |
|
| 199 | + return isset( $_SERVER[$value] ) ? wp_strip_all_tags( $_SERVER[$value] ) : ''; |
|
| 200 | 200 | } |
| 201 | 201 | |
| 202 | 202 | /** |
@@ -211,14 +211,14 @@ discard block |
||
| 211 | 211 | 'HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP', |
| 212 | 212 | 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR', |
| 213 | 213 | ) as $key ) { |
| 214 | - if ( ! isset( $_SERVER[ $key ] ) ) { |
|
| 214 | + if ( ! isset( $_SERVER[$key] ) ) { |
|
| 215 | 215 | continue; |
| 216 | 216 | } |
| 217 | 217 | |
| 218 | - foreach ( explode( ',', $_SERVER[ $key ] ) as $ip ) { |
|
| 219 | - $ip = trim($ip); // just to be safe |
|
| 218 | + foreach ( explode( ',', $_SERVER[$key] ) as $ip ) { |
|
| 219 | + $ip = trim( $ip ); // just to be safe |
|
| 220 | 220 | |
| 221 | - if ( filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) !== false ) { |
|
| 221 | + if ( filter_var( $ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE ) !== false ) { |
|
| 222 | 222 | return $ip; |
| 223 | 223 | } |
| 224 | 224 | } |
@@ -228,15 +228,15 @@ discard block |
||
| 228 | 228 | } |
| 229 | 229 | |
| 230 | 230 | public static function get_param( $param, $default = '', $src = 'get', $sanitize = '' ) { |
| 231 | - if ( strpos($param, '[') ) { |
|
| 232 | - $params = explode('[', $param); |
|
| 231 | + if ( strpos( $param, '[' ) ) { |
|
| 232 | + $params = explode( '[', $param ); |
|
| 233 | 233 | $param = $params[0]; |
| 234 | 234 | } |
| 235 | 235 | |
| 236 | 236 | if ( $src == 'get' ) { |
| 237 | - $value = isset( $_POST[ $param ] ) ? stripslashes_deep( $_POST[ $param ] ) : ( isset( $_GET[ $param ] ) ? stripslashes_deep( $_GET[ $param ] ) : $default ); |
|
| 238 | - if ( ! isset( $_POST[ $param ] ) && isset( $_GET[ $param ] ) && ! is_array( $value ) ) { |
|
| 239 | - $value = stripslashes_deep( htmlspecialchars_decode( urldecode( $_GET[ $param ] ) ) ); |
|
| 237 | + $value = isset( $_POST[$param] ) ? stripslashes_deep( $_POST[$param] ) : ( isset( $_GET[$param] ) ? stripslashes_deep( $_GET[$param] ) : $default ); |
|
| 238 | + if ( ! isset( $_POST[$param] ) && isset( $_GET[$param] ) && ! is_array( $value ) ) { |
|
| 239 | + $value = stripslashes_deep( htmlspecialchars_decode( urldecode( $_GET[$param] ) ) ); |
|
| 240 | 240 | } |
| 241 | 241 | self::sanitize_value( $sanitize, $value ); |
| 242 | 242 | } else { |
@@ -245,12 +245,12 @@ discard block |
||
| 245 | 245 | |
| 246 | 246 | if ( isset( $params ) && is_array( $value ) && ! empty( $value ) ) { |
| 247 | 247 | foreach ( $params as $k => $p ) { |
| 248 | - if ( ! $k || ! is_array($value) ) { |
|
| 248 | + if ( ! $k || ! is_array( $value ) ) { |
|
| 249 | 249 | continue; |
| 250 | 250 | } |
| 251 | 251 | |
| 252 | - $p = trim($p, ']'); |
|
| 253 | - $value = isset( $value[ $p ] ) ? $value[ $p ] : $default; |
|
| 252 | + $p = trim( $p, ']' ); |
|
| 253 | + $value = isset( $value[$p] ) ? $value[$p] : $default; |
|
| 254 | 254 | } |
| 255 | 255 | } |
| 256 | 256 | |
@@ -292,16 +292,16 @@ discard block |
||
| 292 | 292 | |
| 293 | 293 | $value = $args['default']; |
| 294 | 294 | if ( $args['type'] == 'get' ) { |
| 295 | - if ( $_GET && isset( $_GET[ $args['param'] ] ) ) { |
|
| 296 | - $value = $_GET[ $args['param'] ]; |
|
| 295 | + if ( $_GET && isset( $_GET[$args['param']] ) ) { |
|
| 296 | + $value = $_GET[$args['param']]; |
|
| 297 | 297 | } |
| 298 | 298 | } else if ( $args['type'] == 'post' ) { |
| 299 | - if ( isset( $_POST[ $args['param'] ] ) ) { |
|
| 300 | - $value = stripslashes_deep( maybe_unserialize( $_POST[ $args['param'] ] ) ); |
|
| 299 | + if ( isset( $_POST[$args['param']] ) ) { |
|
| 300 | + $value = stripslashes_deep( maybe_unserialize( $_POST[$args['param']] ) ); |
|
| 301 | 301 | } |
| 302 | 302 | } else { |
| 303 | - if ( isset( $_REQUEST[ $args['param'] ] ) ) { |
|
| 304 | - $value = $_REQUEST[ $args['param'] ]; |
|
| 303 | + if ( isset( $_REQUEST[$args['param']] ) ) { |
|
| 304 | + $value = $_REQUEST[$args['param']]; |
|
| 305 | 305 | } |
| 306 | 306 | } |
| 307 | 307 | |
@@ -329,7 +329,7 @@ discard block |
||
| 329 | 329 | if ( is_array( $value ) ) { |
| 330 | 330 | $temp_values = $value; |
| 331 | 331 | foreach ( $temp_values as $k => $v ) { |
| 332 | - FrmAppHelper::sanitize_value( $sanitize, $value[ $k ] ); |
|
| 332 | + FrmAppHelper::sanitize_value( $sanitize, $value[$k] ); |
|
| 333 | 333 | } |
| 334 | 334 | } else { |
| 335 | 335 | $value = call_user_func( $sanitize, $value ); |
@@ -340,8 +340,8 @@ discard block |
||
| 340 | 340 | public static function sanitize_request( $sanitize_method, &$values ) { |
| 341 | 341 | $temp_values = $values; |
| 342 | 342 | foreach ( $temp_values as $k => $val ) { |
| 343 | - if ( isset( $sanitize_method[ $k ] ) ) { |
|
| 344 | - $values[ $k ] = call_user_func( $sanitize_method[ $k ], $val ); |
|
| 343 | + if ( isset( $sanitize_method[$k] ) ) { |
|
| 344 | + $values[$k] = call_user_func( $sanitize_method[$k], $val ); |
|
| 345 | 345 | } |
| 346 | 346 | } |
| 347 | 347 | } |
@@ -349,7 +349,7 @@ discard block |
||
| 349 | 349 | public static function sanitize_array( &$values ) { |
| 350 | 350 | $temp_values = $values; |
| 351 | 351 | foreach ( $temp_values as $k => $val ) { |
| 352 | - $values[ $k ] = wp_kses_post( $val ); |
|
| 352 | + $values[$k] = wp_kses_post( $val ); |
|
| 353 | 353 | } |
| 354 | 354 | } |
| 355 | 355 | |
@@ -369,7 +369,7 @@ discard block |
||
| 369 | 369 | |
| 370 | 370 | $allowed_html = array(); |
| 371 | 371 | foreach ( $allowed as $a ) { |
| 372 | - $allowed_html[ $a ] = isset( $html[ $a ] ) ? $html[ $a ] : array(); |
|
| 372 | + $allowed_html[$a] = isset( $html[$a] ) ? $html[$a] : array(); |
|
| 373 | 373 | } |
| 374 | 374 | |
| 375 | 375 | return wp_kses( $value, $allowed_html ); |
@@ -380,7 +380,7 @@ discard block |
||
| 380 | 380 | * @since 2.0 |
| 381 | 381 | */ |
| 382 | 382 | public static function remove_get_action() { |
| 383 | - if ( ! isset($_GET) ) { |
|
| 383 | + if ( ! isset( $_GET ) ) { |
|
| 384 | 384 | return; |
| 385 | 385 | } |
| 386 | 386 | |
@@ -402,8 +402,8 @@ discard block |
||
| 402 | 402 | } |
| 403 | 403 | |
| 404 | 404 | global $wp_query; |
| 405 | - if ( isset( $wp_query->query_vars[ $param ] ) ) { |
|
| 406 | - $value = $wp_query->query_vars[ $param ]; |
|
| 405 | + if ( isset( $wp_query->query_vars[$param] ) ) { |
|
| 406 | + $value = $wp_query->query_vars[$param]; |
|
| 407 | 407 | } |
| 408 | 408 | |
| 409 | 409 | return $value; |
@@ -432,16 +432,16 @@ discard block |
||
| 432 | 432 | * @return mixed $results The cache or query results |
| 433 | 433 | */ |
| 434 | 434 | public static function check_cache( $cache_key, $group = '', $query = '', $type = 'get_var', $time = 300 ) { |
| 435 | - $results = wp_cache_get($cache_key, $group); |
|
| 436 | - if ( ! self::is_empty_value( $results, false ) || empty($query) ) { |
|
| 435 | + $results = wp_cache_get( $cache_key, $group ); |
|
| 436 | + if ( ! self::is_empty_value( $results, false ) || empty( $query ) ) { |
|
| 437 | 437 | return $results; |
| 438 | 438 | } |
| 439 | 439 | |
| 440 | 440 | if ( 'get_posts' == $type ) { |
| 441 | - $results = get_posts($query); |
|
| 441 | + $results = get_posts( $query ); |
|
| 442 | 442 | } else { |
| 443 | 443 | global $wpdb; |
| 444 | - $results = $wpdb->{$type}($query); |
|
| 444 | + $results = $wpdb->{$type}( $query ); |
|
| 445 | 445 | } |
| 446 | 446 | |
| 447 | 447 | if ( ! self::prevent_caching() ) { |
@@ -465,9 +465,9 @@ discard block |
||
| 465 | 465 | } |
| 466 | 466 | |
| 467 | 467 | // then check the transient |
| 468 | - $results = get_transient($cache_key); |
|
| 468 | + $results = get_transient( $cache_key ); |
|
| 469 | 469 | if ( $results ) { |
| 470 | - wp_cache_set($cache_key, $results); |
|
| 470 | + wp_cache_set( $cache_key, $results ); |
|
| 471 | 471 | } |
| 472 | 472 | |
| 473 | 473 | return $results; |
@@ -478,7 +478,7 @@ discard block |
||
| 478 | 478 | * @param string $cache_key |
| 479 | 479 | */ |
| 480 | 480 | public static function delete_cache_and_transient( $cache_key, $group = 'default' ) { |
| 481 | - delete_transient($cache_key); |
|
| 481 | + delete_transient( $cache_key ); |
|
| 482 | 482 | wp_cache_delete( $cache_key, $group ); |
| 483 | 483 | } |
| 484 | 484 | |
@@ -494,7 +494,7 @@ discard block |
||
| 494 | 494 | global $wp_object_cache; |
| 495 | 495 | |
| 496 | 496 | if ( is_callable( array( $wp_object_cache, '__get' ) ) ) { |
| 497 | - $group_cache = $wp_object_cache->__get('cache'); |
|
| 497 | + $group_cache = $wp_object_cache->__get( 'cache' ); |
|
| 498 | 498 | } elseif ( is_callable( array( $wp_object_cache, 'redis_status' ) ) && $wp_object_cache->redis_status() ) { |
| 499 | 499 | // check if the object cache is overridden by Redis |
| 500 | 500 | $wp_object_cache->flush(); |
@@ -504,8 +504,8 @@ discard block |
||
| 504 | 504 | $group_cache = $wp_object_cache->cache; |
| 505 | 505 | } |
| 506 | 506 | |
| 507 | - if ( isset( $group_cache[ $group ] ) ) { |
|
| 508 | - foreach ( $group_cache[ $group ] as $k => $v ) { |
|
| 507 | + if ( isset( $group_cache[$group] ) ) { |
|
| 508 | + foreach ( $group_cache[$group] as $k => $v ) { |
|
| 509 | 509 | wp_cache_delete( $k, $group ); |
| 510 | 510 | } |
| 511 | 511 | return true; |
@@ -535,17 +535,17 @@ discard block |
||
| 535 | 535 | } |
| 536 | 536 | |
| 537 | 537 | public static function get_pages() { |
| 538 | - return get_posts( array( 'post_type' => 'page', 'post_status' => array( 'publish', 'private' ), 'numberposts' => -1, 'orderby' => 'title', 'order' => 'ASC' ) ); |
|
| 538 | + return get_posts( array( 'post_type' => 'page', 'post_status' => array( 'publish', 'private' ), 'numberposts' => - 1, 'orderby' => 'title', 'order' => 'ASC' ) ); |
|
| 539 | 539 | } |
| 540 | 540 | |
| 541 | 541 | public static function wp_pages_dropdown( $field_name, $page_id, $truncate = false ) { |
| 542 | 542 | $pages = self::get_pages(); |
| 543 | 543 | $selected = self::get_post_param( $field_name, $page_id, 'absint' ); |
| 544 | 544 | ?> |
| 545 | - <select name="<?php echo esc_attr($field_name); ?>" id="<?php echo esc_attr($field_name); ?>" class="frm-pages-dropdown"> |
|
| 545 | + <select name="<?php echo esc_attr( $field_name ); ?>" id="<?php echo esc_attr( $field_name ); ?>" class="frm-pages-dropdown"> |
|
| 546 | 546 | <option value=""> </option> |
| 547 | 547 | <?php foreach ( $pages as $page ) { ?> |
| 548 | - <option value="<?php echo esc_attr($page->ID); ?>" <?php selected( $selected, $page->ID ) ?>> |
|
| 548 | + <option value="<?php echo esc_attr( $page->ID ); ?>" <?php selected( $selected, $page->ID ) ?>> |
|
| 549 | 549 | <?php echo esc_html( $truncate ? self::truncate( $page->post_title, $truncate ) : $page->post_title ); ?> |
| 550 | 550 | </option> |
| 551 | 551 | <?php } ?> |
@@ -554,7 +554,7 @@ discard block |
||
| 554 | 554 | } |
| 555 | 555 | |
| 556 | 556 | public static function post_edit_link( $post_id ) { |
| 557 | - $post = get_post($post_id); |
|
| 557 | + $post = get_post( $post_id ); |
|
| 558 | 558 | if ( $post ) { |
| 559 | 559 | $post_url = admin_url( 'post.php?post=' . $post_id . '&action=edit' ); |
| 560 | 560 | return '<a href="' . esc_url( $post_url ) . '">' . self::truncate( $post->post_title, 50 ) . '</a>'; |
@@ -564,17 +564,17 @@ discard block |
||
| 564 | 564 | |
| 565 | 565 | public static function wp_roles_dropdown( $field_name, $capability, $multiple = 'single' ) { |
| 566 | 566 | ?> |
| 567 | - <select name="<?php echo esc_attr($field_name); ?>" id="<?php echo esc_attr($field_name); ?>" <?php |
|
| 567 | + <select name="<?php echo esc_attr( $field_name ); ?>" id="<?php echo esc_attr( $field_name ); ?>" <?php |
|
| 568 | 568 | echo ( 'multiple' == $multiple ) ? 'multiple="multiple"' : ''; |
| 569 | 569 | ?> class="frm_multiselect"> |
| 570 | - <?php self::roles_options($capability); ?> |
|
| 570 | + <?php self::roles_options( $capability ); ?> |
|
| 571 | 571 | </select> |
| 572 | 572 | <?php |
| 573 | 573 | } |
| 574 | 574 | |
| 575 | 575 | public static function roles_options( $capability ) { |
| 576 | 576 | global $frm_vars; |
| 577 | - if ( isset($frm_vars['editable_roles']) ) { |
|
| 577 | + if ( isset( $frm_vars['editable_roles'] ) ) { |
|
| 578 | 578 | $editable_roles = $frm_vars['editable_roles']; |
| 579 | 579 | } else { |
| 580 | 580 | $editable_roles = get_editable_roles(); |
@@ -582,10 +582,10 @@ discard block |
||
| 582 | 582 | } |
| 583 | 583 | |
| 584 | 584 | foreach ( $editable_roles as $role => $details ) { |
| 585 | - $name = translate_user_role($details['name'] ); ?> |
|
| 586 | - <option value="<?php echo esc_attr($role) ?>" <?php echo in_array($role, (array) $capability) ? ' selected="selected"' : ''; ?>><?php echo esc_attr($name) ?> </option> |
|
| 585 | + $name = translate_user_role( $details['name'] ); ?> |
|
| 586 | + <option value="<?php echo esc_attr( $role ) ?>" <?php echo in_array( $role, (array) $capability ) ? ' selected="selected"' : ''; ?>><?php echo esc_attr( $name ) ?> </option> |
|
| 587 | 587 | <?php |
| 588 | - unset($role, $details); |
|
| 588 | + unset( $role, $details ); |
|
| 589 | 589 | } |
| 590 | 590 | } |
| 591 | 591 | |
@@ -641,7 +641,7 @@ discard block |
||
| 641 | 641 | public static function maybe_add_permissions() { |
| 642 | 642 | self::force_capability( 'frm_view_entries' ); |
| 643 | 643 | |
| 644 | - if ( ! current_user_can('administrator') || current_user_can('frm_view_forms') ) { |
|
| 644 | + if ( ! current_user_can( 'administrator' ) || current_user_can( 'frm_view_forms' ) ) { |
|
| 645 | 645 | return; |
| 646 | 646 | } |
| 647 | 647 | |
@@ -650,7 +650,7 @@ discard block |
||
| 650 | 650 | $frm_roles = self::frm_capabilities(); |
| 651 | 651 | foreach ( $frm_roles as $frm_role => $frm_role_description ) { |
| 652 | 652 | $user->add_cap( $frm_role ); |
| 653 | - unset($frm_role, $frm_role_description); |
|
| 653 | + unset( $frm_role, $frm_role_description ); |
|
| 654 | 654 | } |
| 655 | 655 | } |
| 656 | 656 | |
@@ -675,12 +675,12 @@ discard block |
||
| 675 | 675 | * @param string $permission |
| 676 | 676 | */ |
| 677 | 677 | public static function permission_check( $permission, $show_message = 'show' ) { |
| 678 | - $permission_error = self::permission_nonce_error($permission); |
|
| 678 | + $permission_error = self::permission_nonce_error( $permission ); |
|
| 679 | 679 | if ( $permission_error !== false ) { |
| 680 | 680 | if ( 'hide' == $show_message ) { |
| 681 | 681 | $permission_error = ''; |
| 682 | 682 | } |
| 683 | - wp_die($permission_error); |
|
| 683 | + wp_die( $permission_error ); |
|
| 684 | 684 | } |
| 685 | 685 | } |
| 686 | 686 | |
@@ -697,11 +697,11 @@ discard block |
||
| 697 | 697 | } |
| 698 | 698 | |
| 699 | 699 | $error = false; |
| 700 | - if ( empty($nonce_name) ) { |
|
| 700 | + if ( empty( $nonce_name ) ) { |
|
| 701 | 701 | return $error; |
| 702 | 702 | } |
| 703 | 703 | |
| 704 | - if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $_REQUEST[ $nonce_name ], $nonce ) ) ) { |
|
| 704 | + if ( $_REQUEST && ( ! isset( $_REQUEST[$nonce_name] ) || ! wp_verify_nonce( $_REQUEST[$nonce_name], $nonce ) ) ) { |
|
| 705 | 705 | $frm_settings = self::get_settings(); |
| 706 | 706 | $error = $frm_settings->admin_permission; |
| 707 | 707 | } |
@@ -781,7 +781,7 @@ discard block |
||
| 781 | 781 | } else { |
| 782 | 782 | foreach ( $value as $k => $v ) { |
| 783 | 783 | if ( ! is_array( $v ) ) { |
| 784 | - $value[ $k ] = call_user_func( $original_function, $v ); |
|
| 784 | + $value[$k] = call_user_func( $original_function, $v ); |
|
| 785 | 785 | } |
| 786 | 786 | } |
| 787 | 787 | } |
@@ -802,11 +802,11 @@ discard block |
||
| 802 | 802 | public static function array_flatten( $array, $keys = 'keep' ) { |
| 803 | 803 | $return = array(); |
| 804 | 804 | foreach ( $array as $key => $value ) { |
| 805 | - if ( is_array($value) ) { |
|
| 805 | + if ( is_array( $value ) ) { |
|
| 806 | 806 | $return = array_merge( $return, self::array_flatten( $value, $keys ) ); |
| 807 | 807 | } else { |
| 808 | 808 | if ( $keys == 'keep' ) { |
| 809 | - $return[ $key ] = $value; |
|
| 809 | + $return[$key] = $value; |
|
| 810 | 810 | } else { |
| 811 | 811 | $return[] = $value; |
| 812 | 812 | } |
@@ -829,8 +829,8 @@ discard block |
||
| 829 | 829 | * @since 2.0 |
| 830 | 830 | */ |
| 831 | 831 | public static function use_wpautop( $content ) { |
| 832 | - if ( apply_filters('frm_use_wpautop', true) ) { |
|
| 833 | - $content = wpautop(str_replace( '<br>', '<br />', $content)); |
|
| 832 | + if ( apply_filters( 'frm_use_wpautop', true ) ) { |
|
| 833 | + $content = wpautop( str_replace( '<br>', '<br />', $content ) ); |
|
| 834 | 834 | } |
| 835 | 835 | return $content; |
| 836 | 836 | } |
@@ -848,8 +848,8 @@ discard block |
||
| 848 | 848 | * @return string The base Google APIS url for the current version of jQuery UI |
| 849 | 849 | */ |
| 850 | 850 | public static function jquery_ui_base_url() { |
| 851 | - $url = 'http' . ( is_ssl() ? 's' : '' ) . '://ajax.googleapis.com/ajax/libs/jqueryui/' . self::script_version('jquery-ui-core'); |
|
| 852 | - $url = apply_filters('frm_jquery_ui_base_url', $url); |
|
| 851 | + $url = 'http' . ( is_ssl() ? 's' : '' ) . '://ajax.googleapis.com/ajax/libs/jqueryui/' . self::script_version( 'jquery-ui-core' ); |
|
| 852 | + $url = apply_filters( 'frm_jquery_ui_base_url', $url ); |
|
| 853 | 853 | return $url; |
| 854 | 854 | } |
| 855 | 855 | |
@@ -864,11 +864,11 @@ discard block |
||
| 864 | 864 | |
| 865 | 865 | $ver = 0; |
| 866 | 866 | |
| 867 | - if ( ! isset( $wp_scripts->registered[ $handle ] ) ) { |
|
| 867 | + if ( ! isset( $wp_scripts->registered[$handle] ) ) { |
|
| 868 | 868 | return $ver; |
| 869 | 869 | } |
| 870 | 870 | |
| 871 | - $query = $wp_scripts->registered[ $handle ]; |
|
| 871 | + $query = $wp_scripts->registered[$handle]; |
|
| 872 | 872 | if ( is_object( $query ) ) { |
| 873 | 873 | $ver = $query->ver; |
| 874 | 874 | } |
@@ -881,36 +881,36 @@ discard block |
||
| 881 | 881 | } |
| 882 | 882 | |
| 883 | 883 | public static function get_user_id_param( $user_id ) { |
| 884 | - if ( ! $user_id || empty($user_id) || is_numeric($user_id) ) { |
|
| 884 | + if ( ! $user_id || empty( $user_id ) || is_numeric( $user_id ) ) { |
|
| 885 | 885 | return $user_id; |
| 886 | 886 | } |
| 887 | 887 | |
| 888 | 888 | if ( $user_id == 'current' ) { |
| 889 | 889 | $user_id = get_current_user_id(); |
| 890 | 890 | } else { |
| 891 | - if ( is_email($user_id) ) { |
|
| 892 | - $user = get_user_by('email', $user_id); |
|
| 891 | + if ( is_email( $user_id ) ) { |
|
| 892 | + $user = get_user_by( 'email', $user_id ); |
|
| 893 | 893 | } else { |
| 894 | - $user = get_user_by('login', $user_id); |
|
| 894 | + $user = get_user_by( 'login', $user_id ); |
|
| 895 | 895 | } |
| 896 | 896 | |
| 897 | 897 | if ( $user ) { |
| 898 | 898 | $user_id = $user->ID; |
| 899 | 899 | } |
| 900 | - unset($user); |
|
| 900 | + unset( $user ); |
|
| 901 | 901 | } |
| 902 | 902 | |
| 903 | 903 | return $user_id; |
| 904 | 904 | } |
| 905 | 905 | |
| 906 | 906 | public static function get_file_contents( $filename, $atts = array() ) { |
| 907 | - if ( ! is_file($filename) ) { |
|
| 907 | + if ( ! is_file( $filename ) ) { |
|
| 908 | 908 | return false; |
| 909 | 909 | } |
| 910 | 910 | |
| 911 | - extract($atts); |
|
| 911 | + extract( $atts ); |
|
| 912 | 912 | ob_start(); |
| 913 | - include($filename); |
|
| 913 | + include( $filename ); |
|
| 914 | 914 | $contents = ob_get_contents(); |
| 915 | 915 | ob_end_clean(); |
| 916 | 916 | return $contents; |
@@ -926,28 +926,28 @@ discard block |
||
| 926 | 926 | $key = ''; |
| 927 | 927 | |
| 928 | 928 | if ( ! empty( $name ) ) { |
| 929 | - $key = sanitize_key($name); |
|
| 929 | + $key = sanitize_key( $name ); |
|
| 930 | 930 | } |
| 931 | 931 | |
| 932 | 932 | if ( empty( $key ) ) { |
| 933 | - $max_slug_value = pow(36, $num_chars); |
|
| 933 | + $max_slug_value = pow( 36, $num_chars ); |
|
| 934 | 934 | $min_slug_value = 37; // we want to have at least 2 characters in the slug |
| 935 | - $key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 ); |
|
| 935 | + $key = base_convert( rand( $min_slug_value, $max_slug_value ), 10, 36 ); |
|
| 936 | 936 | } |
| 937 | 937 | |
| 938 | - if ( is_numeric($key) || in_array( $key, array( 'id', 'key', 'created-at', 'detaillink', 'editlink', 'siteurl', 'evenodd' ) ) ) { |
|
| 938 | + if ( is_numeric( $key ) || in_array( $key, array( 'id', 'key', 'created-at', 'detaillink', 'editlink', 'siteurl', 'evenodd' ) ) ) { |
|
| 939 | 939 | $key = $key . 'a'; |
| 940 | 940 | } |
| 941 | 941 | |
| 942 | 942 | $key_check = FrmDb::get_var( $table_name, array( $column => $key, 'ID !' => $id ), $column ); |
| 943 | 943 | |
| 944 | - if ( $key_check || is_numeric($key_check) ) { |
|
| 944 | + if ( $key_check || is_numeric( $key_check ) ) { |
|
| 945 | 945 | $suffix = 2; |
| 946 | 946 | do { |
| 947 | 947 | $alt_post_name = substr( $key, 0, 200 - ( strlen( $suffix ) + 1 ) ) . $suffix; |
| 948 | 948 | $key_check = FrmDb::get_var( $table_name, array( $column => $alt_post_name, 'ID !' => $id ), $column ); |
| 949 | - $suffix++; |
|
| 950 | - } while ($key_check || is_numeric($key_check)); |
|
| 949 | + $suffix ++; |
|
| 950 | + } while ( $key_check || is_numeric( $key_check ) ); |
|
| 951 | 951 | $key = $alt_post_name; |
| 952 | 952 | } |
| 953 | 953 | return $key; |
@@ -963,32 +963,32 @@ discard block |
||
| 963 | 963 | return false; |
| 964 | 964 | } |
| 965 | 965 | |
| 966 | - if ( empty($post_values) ) { |
|
| 967 | - $post_values = stripslashes_deep($_POST); |
|
| 966 | + if ( empty( $post_values ) ) { |
|
| 967 | + $post_values = stripslashes_deep( $_POST ); |
|
| 968 | 968 | } |
| 969 | 969 | |
| 970 | 970 | $values = array( 'id' => $record->id, 'fields' => array() ); |
| 971 | 971 | |
| 972 | 972 | foreach ( array( 'name', 'description' ) as $var ) { |
| 973 | - $default_val = isset($record->{$var}) ? $record->{$var} : ''; |
|
| 974 | - $values[ $var ] = self::get_param( $var, $default_val, 'get', 'wp_kses_post' ); |
|
| 975 | - unset($var, $default_val); |
|
| 973 | + $default_val = isset( $record->{$var}) ? $record->{$var} : ''; |
|
| 974 | + $values[$var] = self::get_param( $var, $default_val, 'get', 'wp_kses_post' ); |
|
| 975 | + unset( $var, $default_val ); |
|
| 976 | 976 | } |
| 977 | 977 | |
| 978 | - $values['description'] = self::use_wpautop($values['description']); |
|
| 978 | + $values['description'] = self::use_wpautop( $values['description'] ); |
|
| 979 | 979 | $frm_settings = self::get_settings(); |
| 980 | - $is_form_builder = self::is_admin_page('formidable' ); |
|
| 980 | + $is_form_builder = self::is_admin_page( 'formidable' ); |
|
| 981 | 981 | |
| 982 | 982 | foreach ( (array) $fields as $field ) { |
| 983 | 983 | // Make sure to filter default values (for placeholder text), but not on the form builder page |
| 984 | 984 | if ( ! $is_form_builder ) { |
| 985 | - $field->default_value = apply_filters('frm_get_default_value', $field->default_value, $field, true ); |
|
| 985 | + $field->default_value = apply_filters( 'frm_get_default_value', $field->default_value, $field, true ); |
|
| 986 | 986 | } |
| 987 | 987 | $parent_form_id = isset( $args['parent_form_id'] ) ? $args['parent_form_id'] : $field->form_id; |
| 988 | - self::fill_field_defaults($field, $record, $values, compact('default', 'post_values', 'frm_settings', 'parent_form_id' ) ); |
|
| 988 | + self::fill_field_defaults( $field, $record, $values, compact( 'default', 'post_values', 'frm_settings', 'parent_form_id' ) ); |
|
| 989 | 989 | } |
| 990 | 990 | |
| 991 | - self::fill_form_opts($record, $table, $post_values, $values); |
|
| 991 | + self::fill_form_opts( $record, $table, $post_values, $values ); |
|
| 992 | 992 | |
| 993 | 993 | if ( $table == 'entries' ) { |
| 994 | 994 | $values = FrmEntriesHelper::setup_edit_vars( $values, $record ); |
@@ -1005,8 +1005,8 @@ discard block |
||
| 1005 | 1005 | if ( $args['default'] ) { |
| 1006 | 1006 | $meta_value = $field->default_value; |
| 1007 | 1007 | } else { |
| 1008 | - if ( $record->post_id && self::pro_is_installed() && isset($field->field_options['post_field']) && $field->field_options['post_field'] ) { |
|
| 1009 | - if ( ! isset($field->field_options['custom_field']) ) { |
|
| 1008 | + if ( $record->post_id && self::pro_is_installed() && isset( $field->field_options['post_field'] ) && $field->field_options['post_field'] ) { |
|
| 1009 | + if ( ! isset( $field->field_options['custom_field'] ) ) { |
|
| 1010 | 1010 | $field->field_options['custom_field'] = ''; |
| 1011 | 1011 | } |
| 1012 | 1012 | $meta_value = FrmProEntryMetaHelper::get_post_value( $record->post_id, $field->field_options['post_field'], $field->field_options['custom_field'], array( 'truncate' => false, 'type' => $field->type, 'form_id' => $field->form_id, 'field' => $field ) ); |
@@ -1015,8 +1015,8 @@ discard block |
||
| 1015 | 1015 | } |
| 1016 | 1016 | } |
| 1017 | 1017 | |
| 1018 | - $field_type = isset( $post_values['field_options'][ 'type_' . $field->id ] ) ? $post_values['field_options'][ 'type_' . $field->id ] : $field->type; |
|
| 1019 | - $new_value = isset( $post_values['item_meta'][ $field->id ] ) ? maybe_unserialize( $post_values['item_meta'][ $field->id ] ) : $meta_value; |
|
| 1018 | + $field_type = isset( $post_values['field_options']['type_' . $field->id] ) ? $post_values['field_options']['type_' . $field->id] : $field->type; |
|
| 1019 | + $new_value = isset( $post_values['item_meta'][$field->id] ) ? maybe_unserialize( $post_values['item_meta'][$field->id] ) : $meta_value; |
|
| 1020 | 1020 | |
| 1021 | 1021 | $field_array = array( |
| 1022 | 1022 | 'id' => $field->id, |
@@ -1024,7 +1024,7 @@ discard block |
||
| 1024 | 1024 | 'default_value' => $field->default_value, |
| 1025 | 1025 | 'name' => $field->name, |
| 1026 | 1026 | 'description' => $field->description, |
| 1027 | - 'type' => apply_filters('frm_field_type', $field_type, $field, $new_value), |
|
| 1027 | + 'type' => apply_filters( 'frm_field_type', $field_type, $field, $new_value ), |
|
| 1028 | 1028 | 'options' => $field->options, |
| 1029 | 1029 | 'required' => $field->required, |
| 1030 | 1030 | 'field_key' => $field->field_key, |
@@ -1034,40 +1034,40 @@ discard block |
||
| 1034 | 1034 | ); |
| 1035 | 1035 | |
| 1036 | 1036 | $args['field_type'] = $field_type; |
| 1037 | - self::fill_field_opts($field, $field_array, $args); |
|
| 1037 | + self::fill_field_opts( $field, $field_array, $args ); |
|
| 1038 | 1038 | // Track the original field's type |
| 1039 | 1039 | $field_array['original_type'] = isset( $field->field_options['original_type'] ) ? $field->field_options['original_type'] : $field->type; |
| 1040 | 1040 | |
| 1041 | 1041 | $field_array = apply_filters( 'frm_setup_edit_fields_vars', $field_array, $field, $values['id'], array() ); |
| 1042 | 1042 | |
| 1043 | - if ( ! isset($field_array['unique']) || ! $field_array['unique'] ) { |
|
| 1043 | + if ( ! isset( $field_array['unique'] ) || ! $field_array['unique'] ) { |
|
| 1044 | 1044 | $field_array['unique_msg'] = ''; |
| 1045 | 1045 | } |
| 1046 | 1046 | |
| 1047 | 1047 | $field_array = array_merge( $field->field_options, $field_array ); |
| 1048 | 1048 | |
| 1049 | - $values['fields'][ $field->id ] = $field_array; |
|
| 1049 | + $values['fields'][$field->id] = $field_array; |
|
| 1050 | 1050 | } |
| 1051 | 1051 | |
| 1052 | 1052 | private static function fill_field_opts( $field, array &$field_array, $args ) { |
| 1053 | 1053 | $post_values = $args['post_values']; |
| 1054 | - $opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true); |
|
| 1054 | + $opt_defaults = FrmFieldsHelper::get_default_field_opts( $field_array['type'], $field, true ); |
|
| 1055 | 1055 | |
| 1056 | 1056 | foreach ( $opt_defaults as $opt => $default_opt ) { |
| 1057 | - $field_array[ $opt ] = ( $post_values && isset( $post_values['field_options'][ $opt . '_' . $field->id ] ) ) ? maybe_unserialize( $post_values['field_options'][ $opt . '_' . $field->id ] ) : ( isset( $field->field_options[ $opt ] ) ? $field->field_options[ $opt ] : $default_opt ); |
|
| 1058 | - if ( $opt == 'blank' && $field_array[ $opt ] == '' ) { |
|
| 1059 | - $field_array[ $opt ] = $args['frm_settings']->blank_msg; |
|
| 1060 | - } else if ( $opt == 'invalid' && $field_array[ $opt ] == '' ) { |
|
| 1057 | + $field_array[$opt] = ( $post_values && isset( $post_values['field_options'][$opt . '_' . $field->id] ) ) ? maybe_unserialize( $post_values['field_options'][$opt . '_' . $field->id] ) : ( isset( $field->field_options[$opt] ) ? $field->field_options[$opt] : $default_opt ); |
|
| 1058 | + if ( $opt == 'blank' && $field_array[$opt] == '' ) { |
|
| 1059 | + $field_array[$opt] = $args['frm_settings']->blank_msg; |
|
| 1060 | + } else if ( $opt == 'invalid' && $field_array[$opt] == '' ) { |
|
| 1061 | 1061 | if ( $args['field_type'] == 'captcha' ) { |
| 1062 | - $field_array[ $opt ] = $args['frm_settings']->re_msg; |
|
| 1062 | + $field_array[$opt] = $args['frm_settings']->re_msg; |
|
| 1063 | 1063 | } else { |
| 1064 | - $field_array[ $opt ] = sprintf( __( '%s is invalid', 'formidable' ), $field_array['name'] ); |
|
| 1064 | + $field_array[$opt] = sprintf( __( '%s is invalid', 'formidable' ), $field_array['name'] ); |
|
| 1065 | 1065 | } |
| 1066 | 1066 | } |
| 1067 | 1067 | } |
| 1068 | 1068 | |
| 1069 | 1069 | if ( $field_array['custom_html'] == '' ) { |
| 1070 | - $field_array['custom_html'] = FrmFieldsHelper::get_default_html($args['field_type']); |
|
| 1070 | + $field_array['custom_html'] = FrmFieldsHelper::get_default_html( $args['field_type'] ); |
|
| 1071 | 1071 | } |
| 1072 | 1072 | } |
| 1073 | 1073 | |
@@ -1086,18 +1086,18 @@ discard block |
||
| 1086 | 1086 | return; |
| 1087 | 1087 | } |
| 1088 | 1088 | |
| 1089 | - $values['form_name'] = isset($record->form_id) ? $form->name : ''; |
|
| 1089 | + $values['form_name'] = isset( $record->form_id ) ? $form->name : ''; |
|
| 1090 | 1090 | $values['parent_form_id'] = isset( $record->form_id ) ? $form->parent_form_id : 0; |
| 1091 | 1091 | |
| 1092 | - if ( ! is_array($form->options) ) { |
|
| 1092 | + if ( ! is_array( $form->options ) ) { |
|
| 1093 | 1093 | return; |
| 1094 | 1094 | } |
| 1095 | 1095 | |
| 1096 | 1096 | foreach ( $form->options as $opt => $value ) { |
| 1097 | - $values[ $opt ] = isset( $post_values[ $opt ] ) ? maybe_unserialize( $post_values[ $opt ] ) : $value; |
|
| 1097 | + $values[$opt] = isset( $post_values[$opt] ) ? maybe_unserialize( $post_values[$opt] ) : $value; |
|
| 1098 | 1098 | } |
| 1099 | 1099 | |
| 1100 | - self::fill_form_defaults($post_values, $values); |
|
| 1100 | + self::fill_form_defaults( $post_values, $values ); |
|
| 1101 | 1101 | } |
| 1102 | 1102 | |
| 1103 | 1103 | /** |
@@ -1107,23 +1107,23 @@ discard block |
||
| 1107 | 1107 | $form_defaults = FrmFormsHelper::get_default_opts(); |
| 1108 | 1108 | |
| 1109 | 1109 | foreach ( $form_defaults as $opt => $default ) { |
| 1110 | - if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) { |
|
| 1111 | - $values[ $opt ] = ( $post_values && isset( $post_values['options'][ $opt ] ) ) ? $post_values['options'][ $opt ] : $default; |
|
| 1110 | + if ( ! isset( $values[$opt] ) || $values[$opt] == '' ) { |
|
| 1111 | + $values[$opt] = ( $post_values && isset( $post_values['options'][$opt] ) ) ? $post_values['options'][$opt] : $default; |
|
| 1112 | 1112 | } |
| 1113 | 1113 | |
| 1114 | - unset($opt, $defaut); |
|
| 1114 | + unset( $opt, $defaut ); |
|
| 1115 | 1115 | } |
| 1116 | 1116 | |
| 1117 | - if ( ! isset($values['custom_style']) ) { |
|
| 1117 | + if ( ! isset( $values['custom_style'] ) ) { |
|
| 1118 | 1118 | $frm_settings = self::get_settings(); |
| 1119 | 1119 | $values['custom_style'] = ( $post_values && isset( $post_values['options']['custom_style'] ) ) ? absint( $_POST['options']['custom_style'] ) : ( $frm_settings->load_style != 'none' ); |
| 1120 | 1120 | } |
| 1121 | 1121 | |
| 1122 | 1122 | foreach ( array( 'before', 'after', 'submit' ) as $h ) { |
| 1123 | - if ( ! isset( $values[ $h . '_html' ] ) ) { |
|
| 1124 | - $values[ $h . '_html' ] = ( isset( $post_values['options'][ $h . '_html' ] ) ? $post_values['options'][ $h . '_html' ] : FrmFormsHelper::get_default_html( $h ) ); |
|
| 1123 | + if ( ! isset( $values[$h . '_html'] ) ) { |
|
| 1124 | + $values[$h . '_html'] = ( isset( $post_values['options'][$h . '_html'] ) ? $post_values['options'][$h . '_html'] : FrmFormsHelper::get_default_html( $h ) ); |
|
| 1125 | 1125 | } |
| 1126 | - unset($h); |
|
| 1126 | + unset( $h ); |
|
| 1127 | 1127 | } |
| 1128 | 1128 | } |
| 1129 | 1129 | |
@@ -1139,9 +1139,9 @@ discard block |
||
| 1139 | 1139 | } |
| 1140 | 1140 | ?> |
| 1141 | 1141 | <li> |
| 1142 | - <a href="javascript:void(0)" class="frmids frm_insert_code alignright <?php echo esc_attr($class) ?>" data-code="<?php echo esc_attr($args['id']) ?>" >[<?php echo esc_attr( $args['id'] ) ?>]</a> |
|
| 1143 | - <a href="javascript:void(0)" class="frmkeys frm_insert_code alignright <?php echo esc_attr($class) ?>" data-code="<?php echo esc_attr($args['key']) ?>" >[<?php echo esc_attr( self::truncate($args['key'], 10) ) ?>]</a> |
|
| 1144 | - <a href="javascript:void(0)" class="frm_insert_code <?php echo esc_attr( $class ) ?>" data-code="<?php echo esc_attr($args['id']) ?>" ><?php echo esc_attr( self::truncate($args['name'], 60) ) ?></a> |
|
| 1142 | + <a href="javascript:void(0)" class="frmids frm_insert_code alignright <?php echo esc_attr( $class ) ?>" data-code="<?php echo esc_attr( $args['id'] ) ?>" >[<?php echo esc_attr( $args['id'] ) ?>]</a> |
|
| 1143 | + <a href="javascript:void(0)" class="frmkeys frm_insert_code alignright <?php echo esc_attr( $class ) ?>" data-code="<?php echo esc_attr( $args['key'] ) ?>" >[<?php echo esc_attr( self::truncate( $args['key'], 10 ) ) ?>]</a> |
|
| 1144 | + <a href="javascript:void(0)" class="frm_insert_code <?php echo esc_attr( $class ) ?>" data-code="<?php echo esc_attr( $args['id'] ) ?>" ><?php echo esc_attr( self::truncate( $args['name'], 60 ) ) ?></a> |
|
| 1145 | 1145 | </li> |
| 1146 | 1146 | <?php |
| 1147 | 1147 | } |
@@ -1159,7 +1159,7 @@ discard block |
||
| 1159 | 1159 | return ''; |
| 1160 | 1160 | } else if ( $length <= 10 ) { |
| 1161 | 1161 | $sub = self::mb_function( array( 'mb_substr', 'substr' ), array( $str, 0, $length ) ); |
| 1162 | - return $sub . (($length < $original_len) ? $continue : ''); |
|
| 1162 | + return $sub . ( ( $length < $original_len ) ? $continue : '' ); |
|
| 1163 | 1163 | } |
| 1164 | 1164 | |
| 1165 | 1165 | $sub = ''; |
@@ -1168,23 +1168,23 @@ discard block |
||
| 1168 | 1168 | $words = self::mb_function( array( 'mb_split', 'explode' ), array( ' ', $str ) ); |
| 1169 | 1169 | |
| 1170 | 1170 | foreach ( $words as $word ) { |
| 1171 | - $part = (($sub != '') ? ' ' : '') . $word; |
|
| 1171 | + $part = ( ( $sub != '' ) ? ' ' : '' ) . $word; |
|
| 1172 | 1172 | $total_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $sub . $part ) ); |
| 1173 | - if ( $total_len > $length && str_word_count($sub) ) { |
|
| 1173 | + if ( $total_len > $length && str_word_count( $sub ) ) { |
|
| 1174 | 1174 | break; |
| 1175 | 1175 | } |
| 1176 | 1176 | |
| 1177 | 1177 | $sub .= $part; |
| 1178 | 1178 | $len += self::mb_function( array( 'mb_strlen', 'strlen' ), array( $part ) ); |
| 1179 | 1179 | |
| 1180 | - if ( str_word_count($sub) > $minword && $total_len >= $length ) { |
|
| 1180 | + if ( str_word_count( $sub ) > $minword && $total_len >= $length ) { |
|
| 1181 | 1181 | break; |
| 1182 | 1182 | } |
| 1183 | 1183 | |
| 1184 | - unset($total_len, $word); |
|
| 1184 | + unset( $total_len, $word ); |
|
| 1185 | 1185 | } |
| 1186 | 1186 | |
| 1187 | - return $sub . (($len < $original_len) ? $continue : ''); |
|
| 1187 | + return $sub . ( ( $len < $original_len ) ? $continue : '' ); |
|
| 1188 | 1188 | } |
| 1189 | 1189 | |
| 1190 | 1190 | public static function mb_function( $function_names, $args ) { |
@@ -1197,17 +1197,17 @@ discard block |
||
| 1197 | 1197 | } |
| 1198 | 1198 | |
| 1199 | 1199 | public static function get_formatted_time( $date, $date_format = '', $time_format = '' ) { |
| 1200 | - if ( empty($date) ) { |
|
| 1200 | + if ( empty( $date ) ) { |
|
| 1201 | 1201 | return $date; |
| 1202 | 1202 | } |
| 1203 | 1203 | |
| 1204 | - if ( empty($date_format) ) { |
|
| 1205 | - $date_format = get_option('date_format'); |
|
| 1204 | + if ( empty( $date_format ) ) { |
|
| 1205 | + $date_format = get_option( 'date_format' ); |
|
| 1206 | 1206 | } |
| 1207 | 1207 | |
| 1208 | - if ( preg_match('/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date) && self::pro_is_installed() ) { |
|
| 1208 | + if ( preg_match( '/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date ) && self::pro_is_installed() ) { |
|
| 1209 | 1209 | $frmpro_settings = new FrmProSettings(); |
| 1210 | - $date = FrmProAppHelper::convert_date($date, $frmpro_settings->date_format, 'Y-m-d'); |
|
| 1210 | + $date = FrmProAppHelper::convert_date( $date, $frmpro_settings->date_format, 'Y-m-d' ); |
|
| 1211 | 1211 | } |
| 1212 | 1212 | |
| 1213 | 1213 | $formatted = self::get_localized_date( $date_format, $date ); |
@@ -1222,7 +1222,7 @@ discard block |
||
| 1222 | 1222 | |
| 1223 | 1223 | private static function add_time_to_date( $time_format, $date ) { |
| 1224 | 1224 | if ( empty( $time_format ) ) { |
| 1225 | - $time_format = get_option('time_format'); |
|
| 1225 | + $time_format = get_option( 'time_format' ); |
|
| 1226 | 1226 | } |
| 1227 | 1227 | |
| 1228 | 1228 | $trimmed_format = trim( $time_format ); |
@@ -1268,10 +1268,10 @@ discard block |
||
| 1268 | 1268 | $time_strings = self::get_time_strings(); |
| 1269 | 1269 | |
| 1270 | 1270 | foreach ( $time_strings as $k => $v ) { |
| 1271 | - if ( $diff[ $k ] ) { |
|
| 1272 | - $time_strings[ $k ] = $diff[ $k ] . ' ' . ( $diff[ $k ] > 1 ? $v[1] : $v[0] ); |
|
| 1271 | + if ( $diff[$k] ) { |
|
| 1272 | + $time_strings[$k] = $diff[$k] . ' ' . ( $diff[$k] > 1 ? $v[1] : $v[0] ); |
|
| 1273 | 1273 | } else { |
| 1274 | - unset( $time_strings[ $k ] ); |
|
| 1274 | + unset( $time_strings[$k] ); |
|
| 1275 | 1275 | } |
| 1276 | 1276 | } |
| 1277 | 1277 | |
@@ -1309,7 +1309,7 @@ discard block |
||
| 1309 | 1309 | */ |
| 1310 | 1310 | public static function esc_like( $term ) { |
| 1311 | 1311 | global $wpdb; |
| 1312 | - if ( method_exists($wpdb, 'esc_like') ) { |
|
| 1312 | + if ( method_exists( $wpdb, 'esc_like' ) ) { |
|
| 1313 | 1313 | // WP 4.0 |
| 1314 | 1314 | $term = $wpdb->esc_like( $term ); |
| 1315 | 1315 | } else { |
@@ -1323,17 +1323,17 @@ discard block |
||
| 1323 | 1323 | * @param string $order_query |
| 1324 | 1324 | */ |
| 1325 | 1325 | public static function esc_order( $order_query ) { |
| 1326 | - if ( empty($order_query) ) { |
|
| 1326 | + if ( empty( $order_query ) ) { |
|
| 1327 | 1327 | return ''; |
| 1328 | 1328 | } |
| 1329 | 1329 | |
| 1330 | 1330 | // remove ORDER BY before santizing |
| 1331 | - $order_query = strtolower($order_query); |
|
| 1332 | - if ( strpos($order_query, 'order by') !== false ) { |
|
| 1333 | - $order_query = str_replace('order by', '', $order_query); |
|
| 1331 | + $order_query = strtolower( $order_query ); |
|
| 1332 | + if ( strpos( $order_query, 'order by' ) !== false ) { |
|
| 1333 | + $order_query = str_replace( 'order by', '', $order_query ); |
|
| 1334 | 1334 | } |
| 1335 | 1335 | |
| 1336 | - $order_query = explode(' ', trim($order_query)); |
|
| 1336 | + $order_query = explode( ' ', trim( $order_query ) ); |
|
| 1337 | 1337 | |
| 1338 | 1338 | $order_fields = array( |
| 1339 | 1339 | 'id', 'form_key', 'name', 'description', |
@@ -1341,13 +1341,13 @@ discard block |
||
| 1341 | 1341 | 'default_template', 'status', 'created_at', |
| 1342 | 1342 | ); |
| 1343 | 1343 | |
| 1344 | - $order = trim(trim(reset($order_query), ',')); |
|
| 1345 | - if ( ! in_array($order, $order_fields) ) { |
|
| 1344 | + $order = trim( trim( reset( $order_query ), ',' ) ); |
|
| 1345 | + if ( ! in_array( $order, $order_fields ) ) { |
|
| 1346 | 1346 | return ''; |
| 1347 | 1347 | } |
| 1348 | 1348 | |
| 1349 | 1349 | $order_by = ''; |
| 1350 | - if ( count($order_query) > 1 ) { |
|
| 1350 | + if ( count( $order_query ) > 1 ) { |
|
| 1351 | 1351 | $order_by = end( $order_query ); |
| 1352 | 1352 | self::esc_order_by( $order_by ); |
| 1353 | 1353 | } |
@@ -1369,23 +1369,23 @@ discard block |
||
| 1369 | 1369 | * @param string $limit |
| 1370 | 1370 | */ |
| 1371 | 1371 | public static function esc_limit( $limit ) { |
| 1372 | - if ( empty($limit) ) { |
|
| 1372 | + if ( empty( $limit ) ) { |
|
| 1373 | 1373 | return ''; |
| 1374 | 1374 | } |
| 1375 | 1375 | |
| 1376 | - $limit = trim(str_replace(' limit', '', strtolower($limit))); |
|
| 1377 | - if ( is_numeric($limit) ) { |
|
| 1376 | + $limit = trim( str_replace( ' limit', '', strtolower( $limit ) ) ); |
|
| 1377 | + if ( is_numeric( $limit ) ) { |
|
| 1378 | 1378 | return ' LIMIT ' . $limit; |
| 1379 | 1379 | } |
| 1380 | 1380 | |
| 1381 | - $limit = explode(',', trim($limit)); |
|
| 1381 | + $limit = explode( ',', trim( $limit ) ); |
|
| 1382 | 1382 | foreach ( $limit as $k => $l ) { |
| 1383 | 1383 | if ( is_numeric( $l ) ) { |
| 1384 | - $limit[ $k ] = $l; |
|
| 1384 | + $limit[$k] = $l; |
|
| 1385 | 1385 | } |
| 1386 | 1386 | } |
| 1387 | 1387 | |
| 1388 | - $limit = implode(',', $limit); |
|
| 1388 | + $limit = implode( ',', $limit ); |
|
| 1389 | 1389 | return ' LIMIT ' . $limit; |
| 1390 | 1390 | } |
| 1391 | 1391 | |
@@ -1394,12 +1394,12 @@ discard block |
||
| 1394 | 1394 | * @since 2.0 |
| 1395 | 1395 | */ |
| 1396 | 1396 | public static function prepare_array_values( $array, $type = '%s' ) { |
| 1397 | - $placeholders = array_fill(0, count($array), $type); |
|
| 1398 | - return implode(', ', $placeholders); |
|
| 1397 | + $placeholders = array_fill( 0, count( $array ), $type ); |
|
| 1398 | + return implode( ', ', $placeholders ); |
|
| 1399 | 1399 | } |
| 1400 | 1400 | |
| 1401 | 1401 | public static function prepend_and_or_where( $starts_with = ' WHERE ', $where = '' ) { |
| 1402 | - if ( empty($where) ) { |
|
| 1402 | + if ( empty( $where ) ) { |
|
| 1403 | 1403 | return ''; |
| 1404 | 1404 | } |
| 1405 | 1405 | |
@@ -1440,19 +1440,19 @@ discard block |
||
| 1440 | 1440 | public static function json_to_array( $json_vars ) { |
| 1441 | 1441 | $vars = array(); |
| 1442 | 1442 | foreach ( $json_vars as $jv ) { |
| 1443 | - $jv_name = explode('[', $jv['name']); |
|
| 1444 | - $last = count($jv_name) - 1; |
|
| 1443 | + $jv_name = explode( '[', $jv['name'] ); |
|
| 1444 | + $last = count( $jv_name ) - 1; |
|
| 1445 | 1445 | foreach ( $jv_name as $p => $n ) { |
| 1446 | - $name = trim($n, ']'); |
|
| 1447 | - if ( ! isset($l1) ) { |
|
| 1446 | + $name = trim( $n, ']' ); |
|
| 1447 | + if ( ! isset( $l1 ) ) { |
|
| 1448 | 1448 | $l1 = $name; |
| 1449 | 1449 | } |
| 1450 | 1450 | |
| 1451 | - if ( ! isset($l2) ) { |
|
| 1451 | + if ( ! isset( $l2 ) ) { |
|
| 1452 | 1452 | $l2 = $name; |
| 1453 | 1453 | } |
| 1454 | 1454 | |
| 1455 | - if ( ! isset($l3) ) { |
|
| 1455 | + if ( ! isset( $l3 ) ) { |
|
| 1456 | 1456 | $l3 = $name; |
| 1457 | 1457 | } |
| 1458 | 1458 | |
@@ -1466,24 +1466,24 @@ discard block |
||
| 1466 | 1466 | |
| 1467 | 1467 | case 1: |
| 1468 | 1468 | $l2 = $name; |
| 1469 | - self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] ); |
|
| 1469 | + self::add_value_to_array( $name, $l2, $this_val, $vars[$l1] ); |
|
| 1470 | 1470 | break; |
| 1471 | 1471 | |
| 1472 | 1472 | case 2: |
| 1473 | 1473 | $l3 = $name; |
| 1474 | - self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] ); |
|
| 1474 | + self::add_value_to_array( $name, $l3, $this_val, $vars[$l1][$l2] ); |
|
| 1475 | 1475 | break; |
| 1476 | 1476 | |
| 1477 | 1477 | case 3: |
| 1478 | 1478 | $l4 = $name; |
| 1479 | - self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] ); |
|
| 1479 | + self::add_value_to_array( $name, $l4, $this_val, $vars[$l1][$l2][$l3] ); |
|
| 1480 | 1480 | break; |
| 1481 | 1481 | } |
| 1482 | 1482 | |
| 1483 | - unset($this_val, $n); |
|
| 1483 | + unset( $this_val, $n ); |
|
| 1484 | 1484 | } |
| 1485 | 1485 | |
| 1486 | - unset($last, $jv); |
|
| 1486 | + unset( $last, $jv ); |
|
| 1487 | 1487 | } |
| 1488 | 1488 | |
| 1489 | 1489 | return $vars; |
@@ -1496,8 +1496,8 @@ discard block |
||
| 1496 | 1496 | public static function add_value_to_array( $name, $l1, $val, &$vars ) { |
| 1497 | 1497 | if ( $name == '' ) { |
| 1498 | 1498 | $vars[] = $val; |
| 1499 | - } else if ( ! isset( $vars[ $l1 ] ) ) { |
|
| 1500 | - $vars[ $l1 ] = $val; |
|
| 1499 | + } else if ( ! isset( $vars[$l1] ) ) { |
|
| 1500 | + $vars[$l1] = $val; |
|
| 1501 | 1501 | } |
| 1502 | 1502 | } |
| 1503 | 1503 | |
@@ -1512,7 +1512,7 @@ discard block |
||
| 1512 | 1512 | 'email_subject' => esc_attr( sprintf( __( 'If you leave the subject blank, the default will be used: %1$s Form submitted on %2$s', 'formidable' ), $form_name, self::site_name() ) ), |
| 1513 | 1513 | ); |
| 1514 | 1514 | |
| 1515 | - if ( ! isset( $tooltips[ $name ] ) ) { |
|
| 1515 | + if ( ! isset( $tooltips[$name] ) ) { |
|
| 1516 | 1516 | return; |
| 1517 | 1517 | } |
| 1518 | 1518 | |
@@ -1522,7 +1522,7 @@ discard block |
||
| 1522 | 1522 | echo ' class="frm_help"'; |
| 1523 | 1523 | } |
| 1524 | 1524 | |
| 1525 | - echo ' title="' . esc_attr( $tooltips[ $name ] ); |
|
| 1525 | + echo ' title="' . esc_attr( $tooltips[$name] ); |
|
| 1526 | 1526 | |
| 1527 | 1527 | if ( 'open' != $class ) { |
| 1528 | 1528 | echo '"'; |
@@ -1574,13 +1574,13 @@ discard block |
||
| 1574 | 1574 | } |
| 1575 | 1575 | |
| 1576 | 1576 | private static function prepare_action_slashes( $val, $key, &$post_content ) { |
| 1577 | - if ( ! isset( $post_content[ $key ] ) ) { |
|
| 1577 | + if ( ! isset( $post_content[$key] ) ) { |
|
| 1578 | 1578 | return; |
| 1579 | 1579 | } |
| 1580 | 1580 | |
| 1581 | 1581 | if ( is_array( $val ) ) { |
| 1582 | 1582 | foreach ( $val as $k1 => $v1 ) { |
| 1583 | - self::prepare_action_slashes( $v1, $k1, $post_content[ $key ] ); |
|
| 1583 | + self::prepare_action_slashes( $v1, $k1, $post_content[$key] ); |
|
| 1584 | 1584 | unset( $k1, $v1 ); |
| 1585 | 1585 | } |
| 1586 | 1586 | } else { |
@@ -1588,7 +1588,7 @@ discard block |
||
| 1588 | 1588 | $val = stripslashes( $val ); |
| 1589 | 1589 | |
| 1590 | 1590 | // Add backslashes before double quotes and forward slashes only |
| 1591 | - $post_content[ $key ] = addcslashes( $val, '"\\/' ); |
|
| 1591 | + $post_content[$key] = addcslashes( $val, '"\\/' ); |
|
| 1592 | 1592 | } |
| 1593 | 1593 | } |
| 1594 | 1594 | |
@@ -1605,7 +1605,7 @@ discard block |
||
| 1605 | 1605 | $settings['post_content'] = FrmAppHelper::prepare_and_encode( $settings['post_content'] ); |
| 1606 | 1606 | |
| 1607 | 1607 | if ( empty( $settings['ID'] ) ) { |
| 1608 | - unset( $settings['ID']); |
|
| 1608 | + unset( $settings['ID'] ); |
|
| 1609 | 1609 | } |
| 1610 | 1610 | |
| 1611 | 1611 | // delete all caches for this group |
@@ -1639,17 +1639,17 @@ discard block |
||
| 1639 | 1639 | } |
| 1640 | 1640 | |
| 1641 | 1641 | public static function maybe_json_decode( $string ) { |
| 1642 | - if ( is_array($string) ) { |
|
| 1642 | + if ( is_array( $string ) ) { |
|
| 1643 | 1643 | return $string; |
| 1644 | 1644 | } |
| 1645 | 1645 | |
| 1646 | - $new_string = json_decode($string, true); |
|
| 1647 | - if ( function_exists('json_last_error') ) { |
|
| 1646 | + $new_string = json_decode( $string, true ); |
|
| 1647 | + if ( function_exists( 'json_last_error' ) ) { |
|
| 1648 | 1648 | // php 5.3+ |
| 1649 | 1649 | if ( json_last_error() == JSON_ERROR_NONE ) { |
| 1650 | 1650 | $string = $new_string; |
| 1651 | 1651 | } |
| 1652 | - } else if ( isset($new_string) ) { |
|
| 1652 | + } else if ( isset( $new_string ) ) { |
|
| 1653 | 1653 | // php < 5.3 fallback |
| 1654 | 1654 | $string = $new_string; |
| 1655 | 1655 | } |
@@ -1665,11 +1665,11 @@ discard block |
||
| 1665 | 1665 | public static function maybe_highlight_menu( $post_type ) { |
| 1666 | 1666 | global $post; |
| 1667 | 1667 | |
| 1668 | - if ( isset($_REQUEST['post_type']) && $_REQUEST['post_type'] != $post_type ) { |
|
| 1668 | + if ( isset( $_REQUEST['post_type'] ) && $_REQUEST['post_type'] != $post_type ) { |
|
| 1669 | 1669 | return; |
| 1670 | 1670 | } |
| 1671 | 1671 | |
| 1672 | - if ( is_object($post) && $post->post_type != $post_type ) { |
|
| 1672 | + if ( is_object( $post ) && $post->post_type != $post_type ) { |
|
| 1673 | 1673 | return; |
| 1674 | 1674 | } |
| 1675 | 1675 | |
@@ -1768,11 +1768,11 @@ discard block |
||
| 1768 | 1768 | $frm_version = self::plugin_version(); |
| 1769 | 1769 | |
| 1770 | 1770 | // check if Formidable meets minimum requirements |
| 1771 | - if ( version_compare($frm_version, $min_version, '>=') ) { |
|
| 1771 | + if ( version_compare( $frm_version, $min_version, '>=' ) ) { |
|
| 1772 | 1772 | return; |
| 1773 | 1773 | } |
| 1774 | 1774 | |
| 1775 | - $wp_list_table = _get_list_table('WP_Plugins_List_Table'); |
|
| 1775 | + $wp_list_table = _get_list_table( 'WP_Plugins_List_Table' ); |
|
| 1776 | 1776 | echo '<tr class="plugin-update-tr active"><th colspan="' . absint( $wp_list_table->get_column_count() ) . '" class="check-column plugin-update colspanchange"><div class="update-message">' . |
| 1777 | 1777 | __( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) . |
| 1778 | 1778 | '</div></td></tr>'; |
@@ -1780,38 +1780,38 @@ discard block |
||
| 1780 | 1780 | |
| 1781 | 1781 | public static function locales( $type = 'date' ) { |
| 1782 | 1782 | $locales = array( |
| 1783 | - 'en' => __( 'English', 'formidable' ), '' => __( 'English/Western', 'formidable' ), |
|
| 1784 | - 'af' => __( 'Afrikaans', 'formidable' ), 'sq' => __( 'Albanian', 'formidable' ), |
|
| 1785 | - 'ar' => __( 'Arabic', 'formidable' ), 'hy' => __( 'Armenian', 'formidable' ), |
|
| 1783 | + 'en' => __( 'English', 'formidable' ), '' => __( 'English/Western', 'formidable' ), |
|
| 1784 | + 'af' => __( 'Afrikaans', 'formidable' ), 'sq' => __( 'Albanian', 'formidable' ), |
|
| 1785 | + 'ar' => __( 'Arabic', 'formidable' ), 'hy' => __( 'Armenian', 'formidable' ), |
|
| 1786 | 1786 | 'az' => __( 'Azerbaijani', 'formidable' ), 'eu' => __( 'Basque', 'formidable' ), |
| 1787 | - 'bs' => __( 'Bosnian', 'formidable' ), 'bg' => __( 'Bulgarian', 'formidable' ), |
|
| 1788 | - 'ca' => __( 'Catalan', 'formidable' ), 'zh-HK' => __( 'Chinese Hong Kong', 'formidable' ), |
|
| 1787 | + 'bs' => __( 'Bosnian', 'formidable' ), 'bg' => __( 'Bulgarian', 'formidable' ), |
|
| 1788 | + 'ca' => __( 'Catalan', 'formidable' ), 'zh-HK' => __( 'Chinese Hong Kong', 'formidable' ), |
|
| 1789 | 1789 | 'zh-CN' => __( 'Chinese Simplified', 'formidable' ), 'zh-TW' => __( 'Chinese Traditional', 'formidable' ), |
| 1790 | - 'hr' => __( 'Croatian', 'formidable' ), 'cs' => __( 'Czech', 'formidable' ), |
|
| 1791 | - 'da' => __( 'Danish', 'formidable' ), 'nl' => __( 'Dutch', 'formidable' ), |
|
| 1790 | + 'hr' => __( 'Croatian', 'formidable' ), 'cs' => __( 'Czech', 'formidable' ), |
|
| 1791 | + 'da' => __( 'Danish', 'formidable' ), 'nl' => __( 'Dutch', 'formidable' ), |
|
| 1792 | 1792 | 'en-GB' => __( 'English/UK', 'formidable' ), 'eo' => __( 'Esperanto', 'formidable' ), |
| 1793 | - 'et' => __( 'Estonian', 'formidable' ), 'fo' => __( 'Faroese', 'formidable' ), |
|
| 1793 | + 'et' => __( 'Estonian', 'formidable' ), 'fo' => __( 'Faroese', 'formidable' ), |
|
| 1794 | 1794 | 'fa' => __( 'Farsi/Persian', 'formidable' ), 'fil' => __( 'Filipino', 'formidable' ), |
| 1795 | - 'fi' => __( 'Finnish', 'formidable' ), 'fr' => __( 'French', 'formidable' ), |
|
| 1795 | + 'fi' => __( 'Finnish', 'formidable' ), 'fr' => __( 'French', 'formidable' ), |
|
| 1796 | 1796 | 'fr-CA' => __( 'French/Canadian', 'formidable' ), 'fr-CH' => __( 'French/Swiss', 'formidable' ), |
| 1797 | - 'de' => __( 'German', 'formidable' ), 'de-AT' => __( 'German/Austria', 'formidable' ), |
|
| 1797 | + 'de' => __( 'German', 'formidable' ), 'de-AT' => __( 'German/Austria', 'formidable' ), |
|
| 1798 | 1798 | 'de-CH' => __( 'German/Switzerland', 'formidable' ), 'el' => __( 'Greek', 'formidable' ), |
| 1799 | - 'he' => __( 'Hebrew', 'formidable' ), 'iw' => __( 'Hebrew', 'formidable' ), |
|
| 1800 | - 'hi' => __( 'Hindi', 'formidable' ), 'hu' => __( 'Hungarian', 'formidable' ), |
|
| 1801 | - 'is' => __( 'Icelandic', 'formidable' ), 'id' => __( 'Indonesian', 'formidable' ), |
|
| 1802 | - 'it' => __( 'Italian', 'formidable' ), 'ja' => __( 'Japanese', 'formidable' ), |
|
| 1803 | - 'ko' => __( 'Korean', 'formidable' ), 'lv' => __( 'Latvian', 'formidable' ), |
|
| 1799 | + 'he' => __( 'Hebrew', 'formidable' ), 'iw' => __( 'Hebrew', 'formidable' ), |
|
| 1800 | + 'hi' => __( 'Hindi', 'formidable' ), 'hu' => __( 'Hungarian', 'formidable' ), |
|
| 1801 | + 'is' => __( 'Icelandic', 'formidable' ), 'id' => __( 'Indonesian', 'formidable' ), |
|
| 1802 | + 'it' => __( 'Italian', 'formidable' ), 'ja' => __( 'Japanese', 'formidable' ), |
|
| 1803 | + 'ko' => __( 'Korean', 'formidable' ), 'lv' => __( 'Latvian', 'formidable' ), |
|
| 1804 | 1804 | 'lt' => __( 'Lithuanian', 'formidable' ), 'ms' => __( 'Malaysian', 'formidable' ), |
| 1805 | - 'no' => __( 'Norwegian', 'formidable' ), 'pl' => __( 'Polish', 'formidable' ), |
|
| 1805 | + 'no' => __( 'Norwegian', 'formidable' ), 'pl' => __( 'Polish', 'formidable' ), |
|
| 1806 | 1806 | 'pt' => __( 'Portuguese', 'formidable' ), 'pt-BR' => __( 'Portuguese/Brazilian', 'formidable' ), |
| 1807 | 1807 | 'pt-PT' => __( 'Portuguese/Portugal', 'formidable' ), 'ro' => __( 'Romanian', 'formidable' ), |
| 1808 | - 'ru' => __( 'Russian', 'formidable' ), 'sr' => __( 'Serbian', 'formidable' ), |
|
| 1808 | + 'ru' => __( 'Russian', 'formidable' ), 'sr' => __( 'Serbian', 'formidable' ), |
|
| 1809 | 1809 | 'sr-SR' => __( 'Serbian', 'formidable' ), 'sk' => __( 'Slovak', 'formidable' ), |
| 1810 | - 'sl' => __( 'Slovenian', 'formidable' ), 'es' => __( 'Spanish', 'formidable' ), |
|
| 1810 | + 'sl' => __( 'Slovenian', 'formidable' ), 'es' => __( 'Spanish', 'formidable' ), |
|
| 1811 | 1811 | 'es-419' => __( 'Spanish/Latin America', 'formidable' ), 'sv' => __( 'Swedish', 'formidable' ), |
| 1812 | - 'ta' => __( 'Tamil', 'formidable' ), 'th' => __( 'Thai', 'formidable' ), |
|
| 1813 | - 'tu' => __( 'Turkish', 'formidable' ), 'tr' => __( 'Turkish', 'formidable' ), |
|
| 1814 | - 'uk' => __( 'Ukranian', 'formidable' ), 'vi' => __( 'Vietnamese', 'formidable' ), |
|
| 1812 | + 'ta' => __( 'Tamil', 'formidable' ), 'th' => __( 'Thai', 'formidable' ), |
|
| 1813 | + 'tu' => __( 'Turkish', 'formidable' ), 'tr' => __( 'Turkish', 'formidable' ), |
|
| 1814 | + 'uk' => __( 'Ukranian', 'formidable' ), 'vi' => __( 'Vietnamese', 'formidable' ), |
|
| 1815 | 1815 | ); |
| 1816 | 1816 | |
| 1817 | 1817 | if ( $type == 'captcha' ) { |
@@ -1830,8 +1830,8 @@ discard block |
||
| 1830 | 1830 | ); |
| 1831 | 1831 | } |
| 1832 | 1832 | |
| 1833 | - $locales = array_diff_key($locales, array_flip($unset)); |
|
| 1834 | - $locales = apply_filters('frm_locales', $locales); |
|
| 1833 | + $locales = array_diff_key( $locales, array_flip( $unset ) ); |
|
| 1834 | + $locales = apply_filters( 'frm_locales', $locales ); |
|
| 1835 | 1835 | |
| 1836 | 1836 | return $locales; |
| 1837 | 1837 | } |
@@ -362,7 +362,7 @@ discard block |
||
| 362 | 362 | * Sanitize the value, and allow some HTML |
| 363 | 363 | * @since 2.0 |
| 364 | 364 | * @param string $value |
| 365 | - * @param array $allowed |
|
| 365 | + * @param string[] $allowed |
|
| 366 | 366 | * @return string |
| 367 | 367 | */ |
| 368 | 368 | public static function kses( $value, $allowed = array() ) { |
@@ -779,6 +779,9 @@ discard block |
||
| 779 | 779 | return FrmFieldsHelper::prepare_other_input( $args, $other_opt, $checked ); |
| 780 | 780 | } |
| 781 | 781 | |
| 782 | + /** |
|
| 783 | + * @param string $function |
|
| 784 | + */ |
|
| 782 | 785 | public static function recursive_function_map( $value, $function ) { |
| 783 | 786 | if ( is_array( $value ) ) { |
| 784 | 787 | $original_function = $function; |
@@ -1198,6 +1201,9 @@ discard block |
||
| 1198 | 1201 | return $sub . (($len < $original_len) ? $continue : ''); |
| 1199 | 1202 | } |
| 1200 | 1203 | |
| 1204 | + /** |
|
| 1205 | + * @param string[] $function_names |
|
| 1206 | + */ |
|
| 1201 | 1207 | public static function mb_function( $function_names, $args ) { |
| 1202 | 1208 | $mb_function_name = $function_names[0]; |
| 1203 | 1209 | $function_name = $function_names[1]; |
@@ -1231,6 +1237,9 @@ discard block |
||
| 1231 | 1237 | return $formatted; |
| 1232 | 1238 | } |
| 1233 | 1239 | |
| 1240 | + /** |
|
| 1241 | + * @param string $time_format |
|
| 1242 | + */ |
|
| 1234 | 1243 | private static function add_time_to_date( $time_format, $date ) { |
| 1235 | 1244 | if ( empty( $time_format ) ) { |
| 1236 | 1245 | $time_format = get_option('time_format'); |
@@ -12,50 +12,50 @@ discard block |
||
| 12 | 12 | */ |
| 13 | 13 | public static $plug_version = '2.02.06'; |
| 14 | 14 | |
| 15 | - /** |
|
| 16 | - * @since 1.07.02 |
|
| 17 | - * |
|
| 18 | - * @param none |
|
| 19 | - * @return string The version of this plugin |
|
| 20 | - */ |
|
| 21 | - public static function plugin_version() { |
|
| 22 | - return self::$plug_version; |
|
| 23 | - } |
|
| 24 | - |
|
| 25 | - public static function plugin_folder() { |
|
| 26 | - return basename(self::plugin_path()); |
|
| 27 | - } |
|
| 28 | - |
|
| 29 | - public static function plugin_path() { |
|
| 30 | - return dirname(dirname(dirname(__FILE__))); |
|
| 31 | - } |
|
| 32 | - |
|
| 33 | - public static function plugin_url() { |
|
| 34 | - //prevously FRM_URL constant |
|
| 15 | + /** |
|
| 16 | + * @since 1.07.02 |
|
| 17 | + * |
|
| 18 | + * @param none |
|
| 19 | + * @return string The version of this plugin |
|
| 20 | + */ |
|
| 21 | + public static function plugin_version() { |
|
| 22 | + return self::$plug_version; |
|
| 23 | + } |
|
| 24 | + |
|
| 25 | + public static function plugin_folder() { |
|
| 26 | + return basename(self::plugin_path()); |
|
| 27 | + } |
|
| 28 | + |
|
| 29 | + public static function plugin_path() { |
|
| 30 | + return dirname(dirname(dirname(__FILE__))); |
|
| 31 | + } |
|
| 32 | + |
|
| 33 | + public static function plugin_url() { |
|
| 34 | + //prevously FRM_URL constant |
|
| 35 | 35 | return plugins_url( '', self::plugin_path() . '/formidable.php' ); |
| 36 | - } |
|
| 36 | + } |
|
| 37 | 37 | |
| 38 | 38 | public static function relative_plugin_url() { |
| 39 | 39 | return str_replace( array( 'https:', 'http:' ), '', self::plugin_url() ); |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | - /** |
|
| 43 | - * @return string Site URL |
|
| 44 | - */ |
|
| 45 | - public static function site_url() { |
|
| 46 | - return site_url(); |
|
| 47 | - } |
|
| 48 | - |
|
| 49 | - /** |
|
| 50 | - * Get the name of this site |
|
| 51 | - * Used for [sitename] shortcode |
|
| 52 | - * |
|
| 53 | - * @since 2.0 |
|
| 54 | - * @return string |
|
| 55 | - */ |
|
| 56 | - public static function site_name() { |
|
| 57 | - return get_option('blogname'); |
|
| 58 | - } |
|
| 42 | + /** |
|
| 43 | + * @return string Site URL |
|
| 44 | + */ |
|
| 45 | + public static function site_url() { |
|
| 46 | + return site_url(); |
|
| 47 | + } |
|
| 48 | + |
|
| 49 | + /** |
|
| 50 | + * Get the name of this site |
|
| 51 | + * Used for [sitename] shortcode |
|
| 52 | + * |
|
| 53 | + * @since 2.0 |
|
| 54 | + * @return string |
|
| 55 | + */ |
|
| 56 | + public static function site_name() { |
|
| 57 | + return get_option('blogname'); |
|
| 58 | + } |
|
| 59 | 59 | |
| 60 | 60 | public static function make_affiliate_url( $url ) { |
| 61 | 61 | $affiliate_id = self::get_affiliate(); |
@@ -75,83 +75,83 @@ discard block |
||
| 75 | 75 | return $affiliate_id; |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | - /** |
|
| 79 | - * Get the Formidable settings |
|
| 80 | - * |
|
| 81 | - * @since 2.0 |
|
| 82 | - * |
|
| 83 | - * @param None |
|
| 84 | - * @return FrmSettings $frm_setings |
|
| 85 | - */ |
|
| 86 | - public static function get_settings() { |
|
| 87 | - global $frm_settings; |
|
| 88 | - if ( empty($frm_settings) ) { |
|
| 89 | - $frm_settings = new FrmSettings(); |
|
| 90 | - } |
|
| 91 | - return $frm_settings; |
|
| 92 | - } |
|
| 78 | + /** |
|
| 79 | + * Get the Formidable settings |
|
| 80 | + * |
|
| 81 | + * @since 2.0 |
|
| 82 | + * |
|
| 83 | + * @param None |
|
| 84 | + * @return FrmSettings $frm_setings |
|
| 85 | + */ |
|
| 86 | + public static function get_settings() { |
|
| 87 | + global $frm_settings; |
|
| 88 | + if ( empty($frm_settings) ) { |
|
| 89 | + $frm_settings = new FrmSettings(); |
|
| 90 | + } |
|
| 91 | + return $frm_settings; |
|
| 92 | + } |
|
| 93 | 93 | |
| 94 | 94 | public static function get_menu_name() { |
| 95 | 95 | $frm_settings = FrmAppHelper::get_settings(); |
| 96 | 96 | return $frm_settings->menu; |
| 97 | 97 | } |
| 98 | 98 | |
| 99 | - /** |
|
| 100 | - * Show a message in place of pro features |
|
| 101 | - * |
|
| 102 | - * @since 2.0 |
|
| 103 | - */ |
|
| 99 | + /** |
|
| 100 | + * Show a message in place of pro features |
|
| 101 | + * |
|
| 102 | + * @since 2.0 |
|
| 103 | + */ |
|
| 104 | 104 | public static function update_message() { |
| 105 | 105 | _deprecated_function( __FUNCTION__, '2.0.19' ); |
| 106 | - } |
|
| 107 | - |
|
| 108 | - public static function pro_is_installed() { |
|
| 109 | - return apply_filters('frm_pro_installed', false); |
|
| 110 | - } |
|
| 111 | - |
|
| 112 | - /** |
|
| 113 | - * Check for certain page in Formidable settings |
|
| 114 | - * |
|
| 115 | - * @since 2.0 |
|
| 116 | - * |
|
| 117 | - * @param string $page The name of the page to check |
|
| 118 | - * @return boolean |
|
| 119 | - */ |
|
| 106 | + } |
|
| 107 | + |
|
| 108 | + public static function pro_is_installed() { |
|
| 109 | + return apply_filters('frm_pro_installed', false); |
|
| 110 | + } |
|
| 111 | + |
|
| 112 | + /** |
|
| 113 | + * Check for certain page in Formidable settings |
|
| 114 | + * |
|
| 115 | + * @since 2.0 |
|
| 116 | + * |
|
| 117 | + * @param string $page The name of the page to check |
|
| 118 | + * @return boolean |
|
| 119 | + */ |
|
| 120 | 120 | public static function is_admin_page( $page = 'formidable' ) { |
| 121 | - global $pagenow; |
|
| 121 | + global $pagenow; |
|
| 122 | 122 | $get_page = self::simple_get( 'page', 'sanitize_title' ); |
| 123 | - if ( $pagenow ) { |
|
| 123 | + if ( $pagenow ) { |
|
| 124 | 124 | return $pagenow == 'admin.php' && $get_page == $page; |
| 125 | - } |
|
| 125 | + } |
|
| 126 | 126 | |
| 127 | 127 | return is_admin() && $get_page == $page; |
| 128 | - } |
|
| 129 | - |
|
| 130 | - /** |
|
| 131 | - * Check for the form preview page |
|
| 132 | - * |
|
| 133 | - * @since 2.0 |
|
| 134 | - * |
|
| 135 | - * @param None |
|
| 136 | - * @return boolean |
|
| 137 | - */ |
|
| 138 | - public static function is_preview_page() { |
|
| 139 | - global $pagenow; |
|
| 128 | + } |
|
| 129 | + |
|
| 130 | + /** |
|
| 131 | + * Check for the form preview page |
|
| 132 | + * |
|
| 133 | + * @since 2.0 |
|
| 134 | + * |
|
| 135 | + * @param None |
|
| 136 | + * @return boolean |
|
| 137 | + */ |
|
| 138 | + public static function is_preview_page() { |
|
| 139 | + global $pagenow; |
|
| 140 | 140 | $action = FrmAppHelper::simple_get( 'action', 'sanitize_title' ); |
| 141 | 141 | return $pagenow && $pagenow == 'admin-ajax.php' && $action == 'frm_forms_preview'; |
| 142 | - } |
|
| 142 | + } |
|
| 143 | 143 | |
| 144 | - /** |
|
| 145 | - * Check for ajax except the form preview page |
|
| 146 | - * |
|
| 147 | - * @since 2.0 |
|
| 148 | - * |
|
| 149 | - * @param None |
|
| 150 | - * @return boolean |
|
| 151 | - */ |
|
| 152 | - public static function doing_ajax() { |
|
| 153 | - return defined('DOING_AJAX') && DOING_AJAX && ! self::is_preview_page(); |
|
| 154 | - } |
|
| 144 | + /** |
|
| 145 | + * Check for ajax except the form preview page |
|
| 146 | + * |
|
| 147 | + * @since 2.0 |
|
| 148 | + * |
|
| 149 | + * @param None |
|
| 150 | + * @return boolean |
|
| 151 | + */ |
|
| 152 | + public static function doing_ajax() { |
|
| 153 | + return defined('DOING_AJAX') && DOING_AJAX && ! self::is_preview_page(); |
|
| 154 | + } |
|
| 155 | 155 | |
| 156 | 156 | /** |
| 157 | 157 | * @since 2.0.8 |
@@ -161,102 +161,102 @@ discard block |
||
| 161 | 161 | return isset( $frm_vars['prevent_caching'] ) && $frm_vars['prevent_caching']; |
| 162 | 162 | } |
| 163 | 163 | |
| 164 | - /** |
|
| 165 | - * Check if on an admin page |
|
| 166 | - * |
|
| 167 | - * @since 2.0 |
|
| 168 | - * |
|
| 169 | - * @param None |
|
| 170 | - * @return boolean |
|
| 171 | - */ |
|
| 172 | - public static function is_admin() { |
|
| 173 | - return is_admin() && ( ! defined('DOING_AJAX') || ! DOING_AJAX ); |
|
| 174 | - } |
|
| 175 | - |
|
| 176 | - /** |
|
| 177 | - * Check if value contains blank value or empty array |
|
| 178 | - * |
|
| 179 | - * @since 2.0 |
|
| 180 | - * @param mixed $value - value to check |
|
| 164 | + /** |
|
| 165 | + * Check if on an admin page |
|
| 166 | + * |
|
| 167 | + * @since 2.0 |
|
| 168 | + * |
|
| 169 | + * @param None |
|
| 170 | + * @return boolean |
|
| 171 | + */ |
|
| 172 | + public static function is_admin() { |
|
| 173 | + return is_admin() && ( ! defined('DOING_AJAX') || ! DOING_AJAX ); |
|
| 174 | + } |
|
| 175 | + |
|
| 176 | + /** |
|
| 177 | + * Check if value contains blank value or empty array |
|
| 178 | + * |
|
| 179 | + * @since 2.0 |
|
| 180 | + * @param mixed $value - value to check |
|
| 181 | 181 | * @param string |
| 182 | - * @return boolean |
|
| 183 | - */ |
|
| 184 | - public static function is_empty_value( $value, $empty = '' ) { |
|
| 185 | - return ( is_array( $value ) && empty( $value ) ) || $value == $empty; |
|
| 186 | - } |
|
| 187 | - |
|
| 188 | - public static function is_not_empty_value( $value, $empty = '' ) { |
|
| 189 | - return ! self::is_empty_value( $value, $empty ); |
|
| 190 | - } |
|
| 191 | - |
|
| 192 | - /** |
|
| 193 | - * Get any value from the $_SERVER |
|
| 194 | - * |
|
| 195 | - * @since 2.0 |
|
| 196 | - * @param string $value |
|
| 197 | - * @return string |
|
| 198 | - */ |
|
| 182 | + * @return boolean |
|
| 183 | + */ |
|
| 184 | + public static function is_empty_value( $value, $empty = '' ) { |
|
| 185 | + return ( is_array( $value ) && empty( $value ) ) || $value == $empty; |
|
| 186 | + } |
|
| 187 | + |
|
| 188 | + public static function is_not_empty_value( $value, $empty = '' ) { |
|
| 189 | + return ! self::is_empty_value( $value, $empty ); |
|
| 190 | + } |
|
| 191 | + |
|
| 192 | + /** |
|
| 193 | + * Get any value from the $_SERVER |
|
| 194 | + * |
|
| 195 | + * @since 2.0 |
|
| 196 | + * @param string $value |
|
| 197 | + * @return string |
|
| 198 | + */ |
|
| 199 | 199 | public static function get_server_value( $value ) { |
| 200 | - return isset( $_SERVER[ $value ] ) ? wp_strip_all_tags( $_SERVER[ $value ] ) : ''; |
|
| 201 | - } |
|
| 202 | - |
|
| 203 | - /** |
|
| 204 | - * Check for the IP address in several places |
|
| 205 | - * Used by [ip] shortcode |
|
| 206 | - * |
|
| 207 | - * @return string The IP address of the current user |
|
| 208 | - */ |
|
| 209 | - public static function get_ip_address() { |
|
| 200 | + return isset( $_SERVER[ $value ] ) ? wp_strip_all_tags( $_SERVER[ $value ] ) : ''; |
|
| 201 | + } |
|
| 202 | + |
|
| 203 | + /** |
|
| 204 | + * Check for the IP address in several places |
|
| 205 | + * Used by [ip] shortcode |
|
| 206 | + * |
|
| 207 | + * @return string The IP address of the current user |
|
| 208 | + */ |
|
| 209 | + public static function get_ip_address() { |
|
| 210 | 210 | $ip = ''; |
| 211 | - foreach ( array( |
|
| 212 | - 'HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP', |
|
| 213 | - 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR', |
|
| 214 | - ) as $key ) { |
|
| 215 | - if ( ! isset( $_SERVER[ $key ] ) ) { |
|
| 216 | - continue; |
|
| 217 | - } |
|
| 218 | - |
|
| 219 | - foreach ( explode( ',', $_SERVER[ $key ] ) as $ip ) { |
|
| 220 | - $ip = trim($ip); // just to be safe |
|
| 221 | - |
|
| 222 | - if ( filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) !== false ) { |
|
| 223 | - return $ip; |
|
| 224 | - } |
|
| 225 | - } |
|
| 226 | - } |
|
| 211 | + foreach ( array( |
|
| 212 | + 'HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP', |
|
| 213 | + 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR', |
|
| 214 | + ) as $key ) { |
|
| 215 | + if ( ! isset( $_SERVER[ $key ] ) ) { |
|
| 216 | + continue; |
|
| 217 | + } |
|
| 218 | + |
|
| 219 | + foreach ( explode( ',', $_SERVER[ $key ] ) as $ip ) { |
|
| 220 | + $ip = trim($ip); // just to be safe |
|
| 221 | + |
|
| 222 | + if ( filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) !== false ) { |
|
| 223 | + return $ip; |
|
| 224 | + } |
|
| 225 | + } |
|
| 226 | + } |
|
| 227 | 227 | |
| 228 | 228 | return sanitize_text_field( $ip ); |
| 229 | - } |
|
| 229 | + } |
|
| 230 | 230 | |
| 231 | - public static function get_param( $param, $default = '', $src = 'get', $sanitize = '' ) { |
|
| 232 | - if ( strpos($param, '[') ) { |
|
| 233 | - $params = explode('[', $param); |
|
| 234 | - $param = $params[0]; |
|
| 235 | - } |
|
| 231 | + public static function get_param( $param, $default = '', $src = 'get', $sanitize = '' ) { |
|
| 232 | + if ( strpos($param, '[') ) { |
|
| 233 | + $params = explode('[', $param); |
|
| 234 | + $param = $params[0]; |
|
| 235 | + } |
|
| 236 | 236 | |
| 237 | 237 | if ( $src == 'get' ) { |
| 238 | - $value = isset( $_POST[ $param ] ) ? stripslashes_deep( $_POST[ $param ] ) : ( isset( $_GET[ $param ] ) ? stripslashes_deep( $_GET[ $param ] ) : $default ); |
|
| 239 | - if ( ! isset( $_POST[ $param ] ) && isset( $_GET[ $param ] ) && ! is_array( $value ) ) { |
|
| 240 | - $value = stripslashes_deep( htmlspecialchars_decode( urldecode( $_GET[ $param ] ) ) ); |
|
| 241 | - } |
|
| 238 | + $value = isset( $_POST[ $param ] ) ? stripslashes_deep( $_POST[ $param ] ) : ( isset( $_GET[ $param ] ) ? stripslashes_deep( $_GET[ $param ] ) : $default ); |
|
| 239 | + if ( ! isset( $_POST[ $param ] ) && isset( $_GET[ $param ] ) && ! is_array( $value ) ) { |
|
| 240 | + $value = stripslashes_deep( htmlspecialchars_decode( urldecode( $_GET[ $param ] ) ) ); |
|
| 241 | + } |
|
| 242 | 242 | self::sanitize_value( $sanitize, $value ); |
| 243 | 243 | } else { |
| 244 | - $value = self::get_simple_request( array( 'type' => $src, 'param' => $param, 'default' => $default, 'sanitize' => $sanitize ) ); |
|
| 245 | - } |
|
| 244 | + $value = self::get_simple_request( array( 'type' => $src, 'param' => $param, 'default' => $default, 'sanitize' => $sanitize ) ); |
|
| 245 | + } |
|
| 246 | 246 | |
| 247 | 247 | if ( isset( $params ) && is_array( $value ) && ! empty( $value ) ) { |
| 248 | - foreach ( $params as $k => $p ) { |
|
| 249 | - if ( ! $k || ! is_array($value) ) { |
|
| 250 | - continue; |
|
| 251 | - } |
|
| 248 | + foreach ( $params as $k => $p ) { |
|
| 249 | + if ( ! $k || ! is_array($value) ) { |
|
| 250 | + continue; |
|
| 251 | + } |
|
| 252 | 252 | |
| 253 | - $p = trim($p, ']'); |
|
| 254 | - $value = isset( $value[ $p ] ) ? $value[ $p ] : $default; |
|
| 255 | - } |
|
| 256 | - } |
|
| 253 | + $p = trim($p, ']'); |
|
| 254 | + $value = isset( $value[ $p ] ) ? $value[ $p ] : $default; |
|
| 255 | + } |
|
| 256 | + } |
|
| 257 | 257 | |
| 258 | - return $value; |
|
| 259 | - } |
|
| 258 | + return $value; |
|
| 259 | + } |
|
| 260 | 260 | |
| 261 | 261 | /** |
| 262 | 262 | * |
@@ -279,7 +279,7 @@ discard block |
||
| 279 | 279 | */ |
| 280 | 280 | public static function simple_get( $param, $sanitize = 'sanitize_text_field', $default = '' ) { |
| 281 | 281 | return self::get_simple_request( array( 'type' => 'get', 'param' => $param, 'default' => $default, 'sanitize' => $sanitize ) ); |
| 282 | - } |
|
| 282 | + } |
|
| 283 | 283 | |
| 284 | 284 | /** |
| 285 | 285 | * Get a GET/POST/REQUEST value and sanitize it |
@@ -315,12 +315,12 @@ discard block |
||
| 315 | 315 | } |
| 316 | 316 | |
| 317 | 317 | /** |
| 318 | - * Preserve backslashes in a value, but make sure value doesn't get compounding slashes |
|
| 319 | - * |
|
| 320 | - * @since 2.0.8 |
|
| 321 | - * @param string $value |
|
| 322 | - * @return string $value |
|
| 323 | - */ |
|
| 318 | + * Preserve backslashes in a value, but make sure value doesn't get compounding slashes |
|
| 319 | + * |
|
| 320 | + * @since 2.0.8 |
|
| 321 | + * @param string $value |
|
| 322 | + * @return string $value |
|
| 323 | + */ |
|
| 324 | 324 | public static function preserve_backslashes( $value ) { |
| 325 | 325 | // If backslashes have already been added, don't add them again |
| 326 | 326 | if ( strpos( $value, '\\\\' ) === false ) { |
@@ -342,14 +342,14 @@ discard block |
||
| 342 | 342 | } |
| 343 | 343 | } |
| 344 | 344 | |
| 345 | - public static function sanitize_request( $sanitize_method, &$values ) { |
|
| 346 | - $temp_values = $values; |
|
| 347 | - foreach ( $temp_values as $k => $val ) { |
|
| 348 | - if ( isset( $sanitize_method[ $k ] ) ) { |
|
| 345 | + public static function sanitize_request( $sanitize_method, &$values ) { |
|
| 346 | + $temp_values = $values; |
|
| 347 | + foreach ( $temp_values as $k => $val ) { |
|
| 348 | + if ( isset( $sanitize_method[ $k ] ) ) { |
|
| 349 | 349 | $values[ $k ] = call_user_func( $sanitize_method[ $k ], $val ); |
| 350 | - } |
|
| 351 | - } |
|
| 352 | - } |
|
| 350 | + } |
|
| 351 | + } |
|
| 352 | + } |
|
| 353 | 353 | |
| 354 | 354 | public static function sanitize_array( &$values ) { |
| 355 | 355 | $temp_values = $values; |
@@ -367,12 +367,12 @@ discard block |
||
| 367 | 367 | */ |
| 368 | 368 | public static function kses( $value, $allowed = array() ) { |
| 369 | 369 | $html = array( |
| 370 | - 'a' => array( |
|
| 370 | + 'a' => array( |
|
| 371 | 371 | 'href' => array(), |
| 372 | 372 | 'title' => array(), |
| 373 | 373 | 'id' => array(), |
| 374 | 374 | 'class' => array(), |
| 375 | - ), |
|
| 375 | + ), |
|
| 376 | 376 | ); |
| 377 | 377 | |
| 378 | 378 | $allowed_html = array(); |
@@ -383,126 +383,126 @@ discard block |
||
| 383 | 383 | return wp_kses( $value, $allowed_html ); |
| 384 | 384 | } |
| 385 | 385 | |
| 386 | - /** |
|
| 387 | - * Used when switching the action for a bulk action |
|
| 388 | - * @since 2.0 |
|
| 389 | - */ |
|
| 390 | - public static function remove_get_action() { |
|
| 391 | - if ( ! isset($_GET) ) { |
|
| 392 | - return; |
|
| 393 | - } |
|
| 386 | + /** |
|
| 387 | + * Used when switching the action for a bulk action |
|
| 388 | + * @since 2.0 |
|
| 389 | + */ |
|
| 390 | + public static function remove_get_action() { |
|
| 391 | + if ( ! isset($_GET) ) { |
|
| 392 | + return; |
|
| 393 | + } |
|
| 394 | 394 | |
| 395 | - $new_action = isset( $_GET['action'] ) ? sanitize_text_field( $_GET['action'] ) : ( isset( $_GET['action2'] ) ? sanitize_text_field( $_GET['action2'] ) : '' ); |
|
| 396 | - if ( ! empty( $new_action ) ) { |
|
| 395 | + $new_action = isset( $_GET['action'] ) ? sanitize_text_field( $_GET['action'] ) : ( isset( $_GET['action2'] ) ? sanitize_text_field( $_GET['action2'] ) : '' ); |
|
| 396 | + if ( ! empty( $new_action ) ) { |
|
| 397 | 397 | $_SERVER['REQUEST_URI'] = str_replace( '&action=' . $new_action, '', FrmAppHelper::get_server_value( 'REQUEST_URI' ) ); |
| 398 | - } |
|
| 399 | - } |
|
| 400 | - |
|
| 401 | - /** |
|
| 402 | - * Check the WP query for a parameter |
|
| 403 | - * |
|
| 404 | - * @since 2.0 |
|
| 405 | - * @return string|array |
|
| 406 | - */ |
|
| 407 | - public static function get_query_var( $value, $param ) { |
|
| 408 | - if ( $value != '' ) { |
|
| 409 | - return $value; |
|
| 410 | - } |
|
| 411 | - |
|
| 412 | - global $wp_query; |
|
| 413 | - if ( isset( $wp_query->query_vars[ $param ] ) ) { |
|
| 414 | - $value = $wp_query->query_vars[ $param ]; |
|
| 415 | - } |
|
| 416 | - |
|
| 417 | - return $value; |
|
| 418 | - } |
|
| 419 | - |
|
| 420 | - /** |
|
| 421 | - * @param string $type |
|
| 422 | - */ |
|
| 423 | - public static function trigger_hook_load( $type, $object = null ) { |
|
| 424 | - // only load the form hooks once |
|
| 398 | + } |
|
| 399 | + } |
|
| 400 | + |
|
| 401 | + /** |
|
| 402 | + * Check the WP query for a parameter |
|
| 403 | + * |
|
| 404 | + * @since 2.0 |
|
| 405 | + * @return string|array |
|
| 406 | + */ |
|
| 407 | + public static function get_query_var( $value, $param ) { |
|
| 408 | + if ( $value != '' ) { |
|
| 409 | + return $value; |
|
| 410 | + } |
|
| 411 | + |
|
| 412 | + global $wp_query; |
|
| 413 | + if ( isset( $wp_query->query_vars[ $param ] ) ) { |
|
| 414 | + $value = $wp_query->query_vars[ $param ]; |
|
| 415 | + } |
|
| 416 | + |
|
| 417 | + return $value; |
|
| 418 | + } |
|
| 419 | + |
|
| 420 | + /** |
|
| 421 | + * @param string $type |
|
| 422 | + */ |
|
| 423 | + public static function trigger_hook_load( $type, $object = null ) { |
|
| 424 | + // only load the form hooks once |
|
| 425 | 425 | $hooks_loaded = apply_filters( 'frm_' . $type . '_hooks_loaded', false, $object ); |
| 426 | - if ( ! $hooks_loaded ) { |
|
| 426 | + if ( ! $hooks_loaded ) { |
|
| 427 | 427 | do_action( 'frm_load_' . $type . '_hooks' ); |
| 428 | - } |
|
| 429 | - } |
|
| 430 | - |
|
| 431 | - /** |
|
| 432 | - * Check cache before fetching values and saving to cache |
|
| 433 | - * |
|
| 434 | - * @since 2.0 |
|
| 435 | - * |
|
| 436 | - * @param string $cache_key The unique name for this cache |
|
| 437 | - * @param string $group The name of the cache group |
|
| 438 | - * @param string $query If blank, don't run a db call |
|
| 439 | - * @param string $type The wpdb function to use with this query |
|
| 440 | - * @return mixed $results The cache or query results |
|
| 441 | - */ |
|
| 442 | - public static function check_cache( $cache_key, $group = '', $query = '', $type = 'get_var', $time = 300 ) { |
|
| 443 | - $results = wp_cache_get($cache_key, $group); |
|
| 444 | - if ( ! self::is_empty_value( $results, false ) || empty($query) ) { |
|
| 445 | - return $results; |
|
| 446 | - } |
|
| 447 | - |
|
| 448 | - if ( 'get_posts' == $type ) { |
|
| 449 | - $results = get_posts($query); |
|
| 428 | + } |
|
| 429 | + } |
|
| 430 | + |
|
| 431 | + /** |
|
| 432 | + * Check cache before fetching values and saving to cache |
|
| 433 | + * |
|
| 434 | + * @since 2.0 |
|
| 435 | + * |
|
| 436 | + * @param string $cache_key The unique name for this cache |
|
| 437 | + * @param string $group The name of the cache group |
|
| 438 | + * @param string $query If blank, don't run a db call |
|
| 439 | + * @param string $type The wpdb function to use with this query |
|
| 440 | + * @return mixed $results The cache or query results |
|
| 441 | + */ |
|
| 442 | + public static function check_cache( $cache_key, $group = '', $query = '', $type = 'get_var', $time = 300 ) { |
|
| 443 | + $results = wp_cache_get($cache_key, $group); |
|
| 444 | + if ( ! self::is_empty_value( $results, false ) || empty($query) ) { |
|
| 445 | + return $results; |
|
| 446 | + } |
|
| 447 | + |
|
| 448 | + if ( 'get_posts' == $type ) { |
|
| 449 | + $results = get_posts($query); |
|
| 450 | 450 | } else if ( 'get_associative_results' == $type ) { |
| 451 | 451 | global $wpdb; |
| 452 | 452 | $results = $wpdb->get_results( $query, OBJECT_K ); |
| 453 | - } else { |
|
| 454 | - global $wpdb; |
|
| 455 | - $results = $wpdb->{$type}($query); |
|
| 456 | - } |
|
| 453 | + } else { |
|
| 454 | + global $wpdb; |
|
| 455 | + $results = $wpdb->{$type}($query); |
|
| 456 | + } |
|
| 457 | 457 | |
| 458 | 458 | if ( ! self::prevent_caching() ) { |
| 459 | 459 | wp_cache_set( $cache_key, $results, $group, $time ); |
| 460 | 460 | } |
| 461 | 461 | |
| 462 | - return $results; |
|
| 463 | - } |
|
| 462 | + return $results; |
|
| 463 | + } |
|
| 464 | 464 | |
| 465 | - /** |
|
| 466 | - * Data that should be stored for a long time can be stored in a transient. |
|
| 467 | - * First check the cache, then check the transient |
|
| 468 | - * @since 2.0 |
|
| 469 | - * @return mixed The cached value or false |
|
| 470 | - */ |
|
| 465 | + /** |
|
| 466 | + * Data that should be stored for a long time can be stored in a transient. |
|
| 467 | + * First check the cache, then check the transient |
|
| 468 | + * @since 2.0 |
|
| 469 | + * @return mixed The cached value or false |
|
| 470 | + */ |
|
| 471 | 471 | public static function check_cache_and_transient( $cache_key ) { |
| 472 | - // check caching layer first |
|
| 473 | - $results = self::check_cache( $cache_key ); |
|
| 474 | - if ( $results ) { |
|
| 475 | - return $results; |
|
| 476 | - } |
|
| 477 | - |
|
| 478 | - // then check the transient |
|
| 479 | - $results = get_transient($cache_key); |
|
| 480 | - if ( $results ) { |
|
| 481 | - wp_cache_set($cache_key, $results); |
|
| 482 | - } |
|
| 483 | - |
|
| 484 | - return $results; |
|
| 485 | - } |
|
| 486 | - |
|
| 487 | - /** |
|
| 488 | - * @since 2.0 |
|
| 489 | - * @param string $cache_key |
|
| 490 | - */ |
|
| 472 | + // check caching layer first |
|
| 473 | + $results = self::check_cache( $cache_key ); |
|
| 474 | + if ( $results ) { |
|
| 475 | + return $results; |
|
| 476 | + } |
|
| 477 | + |
|
| 478 | + // then check the transient |
|
| 479 | + $results = get_transient($cache_key); |
|
| 480 | + if ( $results ) { |
|
| 481 | + wp_cache_set($cache_key, $results); |
|
| 482 | + } |
|
| 483 | + |
|
| 484 | + return $results; |
|
| 485 | + } |
|
| 486 | + |
|
| 487 | + /** |
|
| 488 | + * @since 2.0 |
|
| 489 | + * @param string $cache_key |
|
| 490 | + */ |
|
| 491 | 491 | public static function delete_cache_and_transient( $cache_key, $group = 'default' ) { |
| 492 | 492 | delete_transient($cache_key); |
| 493 | 493 | wp_cache_delete( $cache_key, $group ); |
| 494 | 494 | } |
| 495 | 495 | |
| 496 | - /** |
|
| 497 | - * Delete all caching in a single group |
|
| 498 | - * |
|
| 499 | - * @since 2.0 |
|
| 500 | - * |
|
| 501 | - * @param string $group The name of the cache group |
|
| 502 | - * @return boolean True or False |
|
| 503 | - */ |
|
| 496 | + /** |
|
| 497 | + * Delete all caching in a single group |
|
| 498 | + * |
|
| 499 | + * @since 2.0 |
|
| 500 | + * |
|
| 501 | + * @param string $group The name of the cache group |
|
| 502 | + * @return boolean True or False |
|
| 503 | + */ |
|
| 504 | 504 | public static function cache_delete_group( $group ) { |
| 505 | - global $wp_object_cache; |
|
| 505 | + global $wp_object_cache; |
|
| 506 | 506 | |
| 507 | 507 | if ( is_callable( array( $wp_object_cache, '__get' ) ) ) { |
| 508 | 508 | $group_cache = $wp_object_cache->__get('cache'); |
@@ -522,37 +522,37 @@ discard block |
||
| 522 | 522 | return true; |
| 523 | 523 | } |
| 524 | 524 | |
| 525 | - return false; |
|
| 526 | - } |
|
| 525 | + return false; |
|
| 526 | + } |
|
| 527 | 527 | |
| 528 | - /** |
|
| 529 | - * Check a value from a shortcode to see if true or false. |
|
| 530 | - * True when value is 1, true, 'true', 'yes' |
|
| 531 | - * |
|
| 532 | - * @since 1.07.10 |
|
| 533 | - * |
|
| 534 | - * @param string $value The value to compare |
|
| 535 | - * @return boolean True or False |
|
| 536 | - */ |
|
| 528 | + /** |
|
| 529 | + * Check a value from a shortcode to see if true or false. |
|
| 530 | + * True when value is 1, true, 'true', 'yes' |
|
| 531 | + * |
|
| 532 | + * @since 1.07.10 |
|
| 533 | + * |
|
| 534 | + * @param string $value The value to compare |
|
| 535 | + * @return boolean True or False |
|
| 536 | + */ |
|
| 537 | 537 | public static function is_true( $value ) { |
| 538 | - return ( true === $value || 1 == $value || 'true' == $value || 'yes' == $value ); |
|
| 539 | - } |
|
| 538 | + return ( true === $value || 1 == $value || 'true' == $value || 'yes' == $value ); |
|
| 539 | + } |
|
| 540 | 540 | |
| 541 | - /** |
|
| 542 | - * Used to filter shortcode in text widgets |
|
| 543 | - */ |
|
| 544 | - public static function widget_text_filter_callback( $matches ) { |
|
| 545 | - return do_shortcode( $matches[0] ); |
|
| 546 | - } |
|
| 541 | + /** |
|
| 542 | + * Used to filter shortcode in text widgets |
|
| 543 | + */ |
|
| 544 | + public static function widget_text_filter_callback( $matches ) { |
|
| 545 | + return do_shortcode( $matches[0] ); |
|
| 546 | + } |
|
| 547 | 547 | |
| 548 | - public static function get_pages() { |
|
| 548 | + public static function get_pages() { |
|
| 549 | 549 | return get_posts( array( 'post_type' => 'page', 'post_status' => array( 'publish', 'private' ), 'numberposts' => -1, 'orderby' => 'title', 'order' => 'ASC' ) ); |
| 550 | - } |
|
| 550 | + } |
|
| 551 | 551 | |
| 552 | - public static function wp_pages_dropdown( $field_name, $page_id, $truncate = false ) { |
|
| 553 | - $pages = self::get_pages(); |
|
| 552 | + public static function wp_pages_dropdown( $field_name, $page_id, $truncate = false ) { |
|
| 553 | + $pages = self::get_pages(); |
|
| 554 | 554 | $selected = self::get_post_param( $field_name, $page_id, 'absint' ); |
| 555 | - ?> |
|
| 555 | + ?> |
|
| 556 | 556 | <select name="<?php echo esc_attr($field_name); ?>" id="<?php echo esc_attr($field_name); ?>" class="frm-pages-dropdown"> |
| 557 | 557 | <option value=""> </option> |
| 558 | 558 | <?php foreach ( $pages as $page ) { ?> |
@@ -562,108 +562,108 @@ discard block |
||
| 562 | 562 | <?php } ?> |
| 563 | 563 | </select> |
| 564 | 564 | <?php |
| 565 | - } |
|
| 565 | + } |
|
| 566 | 566 | |
| 567 | 567 | public static function post_edit_link( $post_id ) { |
| 568 | - $post = get_post($post_id); |
|
| 569 | - if ( $post ) { |
|
| 568 | + $post = get_post($post_id); |
|
| 569 | + if ( $post ) { |
|
| 570 | 570 | $post_url = admin_url( 'post.php?post=' . $post_id . '&action=edit' ); |
| 571 | 571 | return '<a href="' . esc_url( $post_url ) . '">' . self::truncate( $post->post_title, 50 ) . '</a>'; |
| 572 | - } |
|
| 573 | - return ''; |
|
| 574 | - } |
|
| 572 | + } |
|
| 573 | + return ''; |
|
| 574 | + } |
|
| 575 | 575 | |
| 576 | 576 | public static function wp_roles_dropdown( $field_name, $capability, $multiple = 'single' ) { |
| 577 | - ?> |
|
| 577 | + ?> |
|
| 578 | 578 | <select name="<?php echo esc_attr($field_name); ?>" id="<?php echo esc_attr($field_name); ?>" <?php |
| 579 | - echo ( 'multiple' == $multiple ) ? 'multiple="multiple"' : ''; |
|
| 580 | - ?> class="frm_multiselect"> |
|
| 579 | + echo ( 'multiple' == $multiple ) ? 'multiple="multiple"' : ''; |
|
| 580 | + ?> class="frm_multiselect"> |
|
| 581 | 581 | <?php self::roles_options($capability); ?> |
| 582 | 582 | </select> |
| 583 | 583 | <?php |
| 584 | - } |
|
| 584 | + } |
|
| 585 | 585 | |
| 586 | 586 | public static function roles_options( $capability ) { |
| 587 | - global $frm_vars; |
|
| 588 | - if ( isset($frm_vars['editable_roles']) ) { |
|
| 589 | - $editable_roles = $frm_vars['editable_roles']; |
|
| 590 | - } else { |
|
| 591 | - $editable_roles = get_editable_roles(); |
|
| 592 | - $frm_vars['editable_roles'] = $editable_roles; |
|
| 593 | - } |
|
| 594 | - |
|
| 595 | - foreach ( $editable_roles as $role => $details ) { |
|
| 596 | - $name = translate_user_role($details['name'] ); ?> |
|
| 587 | + global $frm_vars; |
|
| 588 | + if ( isset($frm_vars['editable_roles']) ) { |
|
| 589 | + $editable_roles = $frm_vars['editable_roles']; |
|
| 590 | + } else { |
|
| 591 | + $editable_roles = get_editable_roles(); |
|
| 592 | + $frm_vars['editable_roles'] = $editable_roles; |
|
| 593 | + } |
|
| 594 | + |
|
| 595 | + foreach ( $editable_roles as $role => $details ) { |
|
| 596 | + $name = translate_user_role($details['name'] ); ?> |
|
| 597 | 597 | <option value="<?php echo esc_attr($role) ?>" <?php echo in_array($role, (array) $capability) ? ' selected="selected"' : ''; ?>><?php echo esc_attr($name) ?> </option> |
| 598 | 598 | <?php |
| 599 | - unset($role, $details); |
|
| 600 | - } |
|
| 601 | - } |
|
| 599 | + unset($role, $details); |
|
| 600 | + } |
|
| 601 | + } |
|
| 602 | 602 | |
| 603 | 603 | public static function frm_capabilities( $type = 'auto' ) { |
| 604 | - $cap = array( |
|
| 605 | - 'frm_view_forms' => __( 'View Forms and Templates', 'formidable' ), |
|
| 606 | - 'frm_edit_forms' => __( 'Add/Edit Forms and Templates', 'formidable' ), |
|
| 607 | - 'frm_delete_forms' => __( 'Delete Forms and Templates', 'formidable' ), |
|
| 608 | - 'frm_change_settings' => __( 'Access this Settings Page', 'formidable' ), |
|
| 609 | - 'frm_view_entries' => __( 'View Entries from Admin Area', 'formidable' ), |
|
| 610 | - 'frm_delete_entries' => __( 'Delete Entries from Admin Area', 'formidable' ), |
|
| 611 | - ); |
|
| 604 | + $cap = array( |
|
| 605 | + 'frm_view_forms' => __( 'View Forms and Templates', 'formidable' ), |
|
| 606 | + 'frm_edit_forms' => __( 'Add/Edit Forms and Templates', 'formidable' ), |
|
| 607 | + 'frm_delete_forms' => __( 'Delete Forms and Templates', 'formidable' ), |
|
| 608 | + 'frm_change_settings' => __( 'Access this Settings Page', 'formidable' ), |
|
| 609 | + 'frm_view_entries' => __( 'View Entries from Admin Area', 'formidable' ), |
|
| 610 | + 'frm_delete_entries' => __( 'Delete Entries from Admin Area', 'formidable' ), |
|
| 611 | + ); |
|
| 612 | 612 | |
| 613 | 613 | if ( ! self::pro_is_installed() && 'pro' != $type ) { |
| 614 | - return $cap; |
|
| 615 | - } |
|
| 614 | + return $cap; |
|
| 615 | + } |
|
| 616 | 616 | |
| 617 | - $cap['frm_create_entries'] = __( 'Add Entries from Admin Area', 'formidable' ); |
|
| 618 | - $cap['frm_edit_entries'] = __( 'Edit Entries from Admin Area', 'formidable' ); |
|
| 619 | - $cap['frm_view_reports'] = __( 'View Reports', 'formidable' ); |
|
| 620 | - $cap['frm_edit_displays'] = __( 'Add/Edit Views', 'formidable' ); |
|
| 617 | + $cap['frm_create_entries'] = __( 'Add Entries from Admin Area', 'formidable' ); |
|
| 618 | + $cap['frm_edit_entries'] = __( 'Edit Entries from Admin Area', 'formidable' ); |
|
| 619 | + $cap['frm_view_reports'] = __( 'View Reports', 'formidable' ); |
|
| 620 | + $cap['frm_edit_displays'] = __( 'Add/Edit Views', 'formidable' ); |
|
| 621 | 621 | |
| 622 | - return $cap; |
|
| 623 | - } |
|
| 622 | + return $cap; |
|
| 623 | + } |
|
| 624 | 624 | |
| 625 | 625 | public static function user_has_permission( $needed_role ) { |
| 626 | - if ( $needed_role == '-1' ) { |
|
| 627 | - return false; |
|
| 626 | + if ( $needed_role == '-1' ) { |
|
| 627 | + return false; |
|
| 628 | 628 | } |
| 629 | 629 | |
| 630 | - // $needed_role will be equal to blank if "Logged-in users" is selected |
|
| 631 | - if ( ( $needed_role == '' && is_user_logged_in() ) || current_user_can( $needed_role ) ) { |
|
| 632 | - return true; |
|
| 633 | - } |
|
| 630 | + // $needed_role will be equal to blank if "Logged-in users" is selected |
|
| 631 | + if ( ( $needed_role == '' && is_user_logged_in() ) || current_user_can( $needed_role ) ) { |
|
| 632 | + return true; |
|
| 633 | + } |
|
| 634 | 634 | |
| 635 | - $roles = array( 'administrator', 'editor', 'author', 'contributor', 'subscriber' ); |
|
| 636 | - foreach ( $roles as $role ) { |
|
| 635 | + $roles = array( 'administrator', 'editor', 'author', 'contributor', 'subscriber' ); |
|
| 636 | + foreach ( $roles as $role ) { |
|
| 637 | 637 | if ( current_user_can( $role ) ) { |
| 638 | - return true; |
|
| 638 | + return true; |
|
| 639 | 639 | } |
| 640 | - if ( $role == $needed_role ) { |
|
| 641 | - break; |
|
| 640 | + if ( $role == $needed_role ) { |
|
| 641 | + break; |
|
| 642 | 642 | } |
| 643 | - } |
|
| 644 | - return false; |
|
| 645 | - } |
|
| 646 | - |
|
| 647 | - /** |
|
| 648 | - * Make sure administrators can see Formidable menu |
|
| 649 | - * |
|
| 650 | - * @since 2.0 |
|
| 651 | - */ |
|
| 652 | - public static function maybe_add_permissions() { |
|
| 643 | + } |
|
| 644 | + return false; |
|
| 645 | + } |
|
| 646 | + |
|
| 647 | + /** |
|
| 648 | + * Make sure administrators can see Formidable menu |
|
| 649 | + * |
|
| 650 | + * @since 2.0 |
|
| 651 | + */ |
|
| 652 | + public static function maybe_add_permissions() { |
|
| 653 | 653 | self::force_capability( 'frm_view_entries' ); |
| 654 | 654 | |
| 655 | - if ( ! current_user_can('administrator') || current_user_can('frm_view_forms') ) { |
|
| 656 | - return; |
|
| 657 | - } |
|
| 655 | + if ( ! current_user_can('administrator') || current_user_can('frm_view_forms') ) { |
|
| 656 | + return; |
|
| 657 | + } |
|
| 658 | 658 | |
| 659 | 659 | $user_id = get_current_user_id(); |
| 660 | 660 | $user = new WP_User( $user_id ); |
| 661 | - $frm_roles = self::frm_capabilities(); |
|
| 662 | - foreach ( $frm_roles as $frm_role => $frm_role_description ) { |
|
| 661 | + $frm_roles = self::frm_capabilities(); |
|
| 662 | + foreach ( $frm_roles as $frm_role => $frm_role_description ) { |
|
| 663 | 663 | $user->add_cap( $frm_role ); |
| 664 | - unset($frm_role, $frm_role_description); |
|
| 665 | - } |
|
| 666 | - } |
|
| 664 | + unset($frm_role, $frm_role_description); |
|
| 665 | + } |
|
| 666 | + } |
|
| 667 | 667 | |
| 668 | 668 | /** |
| 669 | 669 | * Make sure admins have permission to see the menu items |
@@ -679,28 +679,28 @@ discard block |
||
| 679 | 679 | } |
| 680 | 680 | } |
| 681 | 681 | |
| 682 | - /** |
|
| 683 | - * Check if the user has permision for action. |
|
| 684 | - * Return permission message and stop the action if no permission |
|
| 685 | - * @since 2.0 |
|
| 686 | - * @param string $permission |
|
| 687 | - */ |
|
| 682 | + /** |
|
| 683 | + * Check if the user has permision for action. |
|
| 684 | + * Return permission message and stop the action if no permission |
|
| 685 | + * @since 2.0 |
|
| 686 | + * @param string $permission |
|
| 687 | + */ |
|
| 688 | 688 | public static function permission_check( $permission, $show_message = 'show' ) { |
| 689 | - $permission_error = self::permission_nonce_error($permission); |
|
| 690 | - if ( $permission_error !== false ) { |
|
| 691 | - if ( 'hide' == $show_message ) { |
|
| 692 | - $permission_error = ''; |
|
| 693 | - } |
|
| 694 | - wp_die($permission_error); |
|
| 695 | - } |
|
| 696 | - } |
|
| 697 | - |
|
| 698 | - /** |
|
| 699 | - * Check user permission and nonce |
|
| 700 | - * @since 2.0 |
|
| 701 | - * @param string $permission |
|
| 702 | - * @return false|string The permission message or false if allowed |
|
| 703 | - */ |
|
| 689 | + $permission_error = self::permission_nonce_error($permission); |
|
| 690 | + if ( $permission_error !== false ) { |
|
| 691 | + if ( 'hide' == $show_message ) { |
|
| 692 | + $permission_error = ''; |
|
| 693 | + } |
|
| 694 | + wp_die($permission_error); |
|
| 695 | + } |
|
| 696 | + } |
|
| 697 | + |
|
| 698 | + /** |
|
| 699 | + * Check user permission and nonce |
|
| 700 | + * @since 2.0 |
|
| 701 | + * @param string $permission |
|
| 702 | + * @return false|string The permission message or false if allowed |
|
| 703 | + */ |
|
| 704 | 704 | public static function permission_nonce_error( $permission, $nonce_name = '', $nonce = '' ) { |
| 705 | 705 | if ( ! empty( $permission ) && ! current_user_can( $permission ) && ! current_user_can( 'administrator' ) ) { |
| 706 | 706 | $frm_settings = self::get_settings(); |
@@ -708,23 +708,23 @@ discard block |
||
| 708 | 708 | } |
| 709 | 709 | |
| 710 | 710 | $error = false; |
| 711 | - if ( empty($nonce_name) ) { |
|
| 712 | - return $error; |
|
| 713 | - } |
|
| 711 | + if ( empty($nonce_name) ) { |
|
| 712 | + return $error; |
|
| 713 | + } |
|
| 714 | 714 | |
| 715 | - if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $_REQUEST[ $nonce_name ], $nonce ) ) ) { |
|
| 716 | - $frm_settings = self::get_settings(); |
|
| 717 | - $error = $frm_settings->admin_permission; |
|
| 718 | - } |
|
| 715 | + if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $_REQUEST[ $nonce_name ], $nonce ) ) ) { |
|
| 716 | + $frm_settings = self::get_settings(); |
|
| 717 | + $error = $frm_settings->admin_permission; |
|
| 718 | + } |
|
| 719 | 719 | |
| 720 | - return $error; |
|
| 721 | - } |
|
| 720 | + return $error; |
|
| 721 | + } |
|
| 722 | 722 | |
| 723 | - public static function checked( $values, $current ) { |
|
| 723 | + public static function checked( $values, $current ) { |
|
| 724 | 724 | if ( self::check_selected( $values, $current ) ) { |
| 725 | - echo ' checked="checked"'; |
|
| 725 | + echo ' checked="checked"'; |
|
| 726 | 726 | } |
| 727 | - } |
|
| 727 | + } |
|
| 728 | 728 | |
| 729 | 729 | public static function check_selected( $values, $current ) { |
| 730 | 730 | $values = self::recursive_function_map( $values, 'trim' ); |
@@ -734,50 +734,50 @@ discard block |
||
| 734 | 734 | return ( is_array( $values ) && in_array( $current, $values ) ) || ( ! is_array( $values ) && $values == $current ); |
| 735 | 735 | } |
| 736 | 736 | |
| 737 | - /** |
|
| 738 | - * Check if current field option is an "other" option |
|
| 739 | - * |
|
| 740 | - * @since 2.0 |
|
| 741 | - * |
|
| 742 | - * @param string $opt_key |
|
| 743 | - * @return boolean Returns true if current field option is an "Other" option |
|
| 744 | - */ |
|
| 745 | - public static function is_other_opt( $opt_key ) { |
|
| 746 | - _deprecated_function( __FUNCTION__, '2.0.6', 'FrmFieldsHelper::is_other_opt' ); |
|
| 747 | - return FrmFieldsHelper::is_other_opt( $opt_key ); |
|
| 748 | - } |
|
| 749 | - |
|
| 750 | - /** |
|
| 751 | - * Get value that belongs in "Other" text box |
|
| 752 | - * |
|
| 753 | - * @since 2.0 |
|
| 754 | - * |
|
| 755 | - * @param string $opt_key |
|
| 756 | - * @param array $field |
|
| 757 | - * @return string $other_val |
|
| 758 | - */ |
|
| 759 | - public static function get_other_val( $opt_key, $field, $parent = false, $pointer = false ) { |
|
| 737 | + /** |
|
| 738 | + * Check if current field option is an "other" option |
|
| 739 | + * |
|
| 740 | + * @since 2.0 |
|
| 741 | + * |
|
| 742 | + * @param string $opt_key |
|
| 743 | + * @return boolean Returns true if current field option is an "Other" option |
|
| 744 | + */ |
|
| 745 | + public static function is_other_opt( $opt_key ) { |
|
| 746 | + _deprecated_function( __FUNCTION__, '2.0.6', 'FrmFieldsHelper::is_other_opt' ); |
|
| 747 | + return FrmFieldsHelper::is_other_opt( $opt_key ); |
|
| 748 | + } |
|
| 749 | + |
|
| 750 | + /** |
|
| 751 | + * Get value that belongs in "Other" text box |
|
| 752 | + * |
|
| 753 | + * @since 2.0 |
|
| 754 | + * |
|
| 755 | + * @param string $opt_key |
|
| 756 | + * @param array $field |
|
| 757 | + * @return string $other_val |
|
| 758 | + */ |
|
| 759 | + public static function get_other_val( $opt_key, $field, $parent = false, $pointer = false ) { |
|
| 760 | 760 | _deprecated_function( __FUNCTION__, '2.0.6', 'FrmFieldsHelper::get_other_val' ); |
| 761 | 761 | return FrmFieldsHelper::get_other_val( compact( 'opt_key', 'field', 'parent', 'pointer' ) ); |
| 762 | - } |
|
| 763 | - |
|
| 764 | - /** |
|
| 765 | - * Check if there is a saved value for the "Other" text field. If so, set it as the $other_val. |
|
| 766 | - * Intended for front-end use |
|
| 767 | - * |
|
| 768 | - * @since 2.0 |
|
| 769 | - * |
|
| 770 | - * @param array $field |
|
| 771 | - * @param boolean $other_opt |
|
| 772 | - * @param string $checked |
|
| 773 | - * @param array $args should include opt_key and field name |
|
| 774 | - * @return string $other_val |
|
| 775 | - */ |
|
| 776 | - public static function prepare_other_input( $field, &$other_opt, &$checked, $args = array() ) { |
|
| 762 | + } |
|
| 763 | + |
|
| 764 | + /** |
|
| 765 | + * Check if there is a saved value for the "Other" text field. If so, set it as the $other_val. |
|
| 766 | + * Intended for front-end use |
|
| 767 | + * |
|
| 768 | + * @since 2.0 |
|
| 769 | + * |
|
| 770 | + * @param array $field |
|
| 771 | + * @param boolean $other_opt |
|
| 772 | + * @param string $checked |
|
| 773 | + * @param array $args should include opt_key and field name |
|
| 774 | + * @return string $other_val |
|
| 775 | + */ |
|
| 776 | + public static function prepare_other_input( $field, &$other_opt, &$checked, $args = array() ) { |
|
| 777 | 777 | _deprecated_function( __FUNCTION__, '2.0.6', 'FrmFieldsHelper::prepare_other_input' ); |
| 778 | 778 | $args['field'] = $field; |
| 779 | 779 | return FrmFieldsHelper::prepare_other_input( $args, $other_opt, $checked ); |
| 780 | - } |
|
| 780 | + } |
|
| 781 | 781 | |
| 782 | 782 | public static function recursive_function_map( $value, $function ) { |
| 783 | 783 | if ( is_array( $value ) ) { |
@@ -807,24 +807,24 @@ discard block |
||
| 807 | 807 | return (bool) count( array_filter( array_keys( $array ), 'is_string' ) ); |
| 808 | 808 | } |
| 809 | 809 | |
| 810 | - /** |
|
| 811 | - * Flatten a multi-dimensional array |
|
| 812 | - */ |
|
| 810 | + /** |
|
| 811 | + * Flatten a multi-dimensional array |
|
| 812 | + */ |
|
| 813 | 813 | public static function array_flatten( $array, $keys = 'keep' ) { |
| 814 | - $return = array(); |
|
| 815 | - foreach ( $array as $key => $value ) { |
|
| 816 | - if ( is_array($value) ) { |
|
| 814 | + $return = array(); |
|
| 815 | + foreach ( $array as $key => $value ) { |
|
| 816 | + if ( is_array($value) ) { |
|
| 817 | 817 | $return = array_merge( $return, self::array_flatten( $value, $keys ) ); |
| 818 | - } else { |
|
| 818 | + } else { |
|
| 819 | 819 | if ( $keys == 'keep' ) { |
| 820 | 820 | $return[ $key ] = $value; |
| 821 | 821 | } else { |
| 822 | 822 | $return[] = $value; |
| 823 | 823 | } |
| 824 | - } |
|
| 825 | - } |
|
| 826 | - return $return; |
|
| 827 | - } |
|
| 824 | + } |
|
| 825 | + } |
|
| 826 | + return $return; |
|
| 827 | + } |
|
| 828 | 828 | |
| 829 | 829 | public static function esc_textarea( $text, $is_rich_text = false ) { |
| 830 | 830 | $safe_text = str_replace( '"', '"', $text ); |
@@ -835,308 +835,308 @@ discard block |
||
| 835 | 835 | return apply_filters( 'esc_textarea', $safe_text, $text ); |
| 836 | 836 | } |
| 837 | 837 | |
| 838 | - /** |
|
| 839 | - * Add auto paragraphs to text areas |
|
| 840 | - * @since 2.0 |
|
| 841 | - */ |
|
| 838 | + /** |
|
| 839 | + * Add auto paragraphs to text areas |
|
| 840 | + * @since 2.0 |
|
| 841 | + */ |
|
| 842 | 842 | public static function use_wpautop( $content ) { |
| 843 | - if ( apply_filters('frm_use_wpautop', true) ) { |
|
| 844 | - $content = wpautop(str_replace( '<br>', '<br />', $content)); |
|
| 845 | - } |
|
| 846 | - return $content; |
|
| 847 | - } |
|
| 843 | + if ( apply_filters('frm_use_wpautop', true) ) { |
|
| 844 | + $content = wpautop(str_replace( '<br>', '<br />', $content)); |
|
| 845 | + } |
|
| 846 | + return $content; |
|
| 847 | + } |
|
| 848 | 848 | |
| 849 | 849 | public static function replace_quotes( $val ) { |
| 850 | - //Replace double quotes |
|
| 850 | + //Replace double quotes |
|
| 851 | 851 | $val = str_replace( array( '“', '”', '″' ), '"', $val ); |
| 852 | - //Replace single quotes |
|
| 853 | - $val = str_replace( array( '‘', '’', '′', '′', '’', '‘' ), "'", $val ); |
|
| 854 | - return $val; |
|
| 855 | - } |
|
| 856 | - |
|
| 857 | - /** |
|
| 858 | - * @since 2.0 |
|
| 859 | - * @return string The base Google APIS url for the current version of jQuery UI |
|
| 860 | - */ |
|
| 861 | - public static function jquery_ui_base_url() { |
|
| 852 | + //Replace single quotes |
|
| 853 | + $val = str_replace( array( '‘', '’', '′', '′', '’', '‘' ), "'", $val ); |
|
| 854 | + return $val; |
|
| 855 | + } |
|
| 856 | + |
|
| 857 | + /** |
|
| 858 | + * @since 2.0 |
|
| 859 | + * @return string The base Google APIS url for the current version of jQuery UI |
|
| 860 | + */ |
|
| 861 | + public static function jquery_ui_base_url() { |
|
| 862 | 862 | $url = 'http' . ( is_ssl() ? 's' : '' ) . '://ajax.googleapis.com/ajax/libs/jqueryui/' . self::script_version('jquery-ui-core'); |
| 863 | - $url = apply_filters('frm_jquery_ui_base_url', $url); |
|
| 864 | - return $url; |
|
| 865 | - } |
|
| 863 | + $url = apply_filters('frm_jquery_ui_base_url', $url); |
|
| 864 | + return $url; |
|
| 865 | + } |
|
| 866 | 866 | |
| 867 | - /** |
|
| 868 | - * @param string $handle |
|
| 869 | - */ |
|
| 867 | + /** |
|
| 868 | + * @param string $handle |
|
| 869 | + */ |
|
| 870 | 870 | public static function script_version( $handle ) { |
| 871 | - global $wp_scripts; |
|
| 872 | - if ( ! $wp_scripts ) { |
|
| 873 | - return false; |
|
| 874 | - } |
|
| 871 | + global $wp_scripts; |
|
| 872 | + if ( ! $wp_scripts ) { |
|
| 873 | + return false; |
|
| 874 | + } |
|
| 875 | 875 | |
| 876 | - $ver = 0; |
|
| 876 | + $ver = 0; |
|
| 877 | 877 | |
| 878 | - if ( ! isset( $wp_scripts->registered[ $handle ] ) ) { |
|
| 879 | - return $ver; |
|
| 880 | - } |
|
| 878 | + if ( ! isset( $wp_scripts->registered[ $handle ] ) ) { |
|
| 879 | + return $ver; |
|
| 880 | + } |
|
| 881 | 881 | |
| 882 | - $query = $wp_scripts->registered[ $handle ]; |
|
| 883 | - if ( is_object( $query ) ) { |
|
| 884 | - $ver = $query->ver; |
|
| 885 | - } |
|
| 882 | + $query = $wp_scripts->registered[ $handle ]; |
|
| 883 | + if ( is_object( $query ) ) { |
|
| 884 | + $ver = $query->ver; |
|
| 885 | + } |
|
| 886 | 886 | |
| 887 | - return $ver; |
|
| 888 | - } |
|
| 887 | + return $ver; |
|
| 888 | + } |
|
| 889 | 889 | |
| 890 | 890 | public static function js_redirect( $url ) { |
| 891 | 891 | return '<script type="text/javascript">window.location="' . esc_url_raw( $url ) . '"</script>'; |
| 892 | - } |
|
| 892 | + } |
|
| 893 | 893 | |
| 894 | 894 | public static function get_user_id_param( $user_id ) { |
| 895 | - if ( ! $user_id || empty($user_id) || is_numeric($user_id) ) { |
|
| 896 | - return $user_id; |
|
| 897 | - } |
|
| 895 | + if ( ! $user_id || empty($user_id) || is_numeric($user_id) ) { |
|
| 896 | + return $user_id; |
|
| 897 | + } |
|
| 898 | 898 | |
| 899 | 899 | if ( $user_id == 'current' ) { |
| 900 | 900 | $user_id = get_current_user_id(); |
| 901 | 901 | } else { |
| 902 | - if ( is_email($user_id) ) { |
|
| 903 | - $user = get_user_by('email', $user_id); |
|
| 904 | - } else { |
|
| 905 | - $user = get_user_by('login', $user_id); |
|
| 906 | - } |
|
| 902 | + if ( is_email($user_id) ) { |
|
| 903 | + $user = get_user_by('email', $user_id); |
|
| 904 | + } else { |
|
| 905 | + $user = get_user_by('login', $user_id); |
|
| 906 | + } |
|
| 907 | 907 | |
| 908 | - if ( $user ) { |
|
| 909 | - $user_id = $user->ID; |
|
| 910 | - } |
|
| 911 | - unset($user); |
|
| 912 | - } |
|
| 908 | + if ( $user ) { |
|
| 909 | + $user_id = $user->ID; |
|
| 910 | + } |
|
| 911 | + unset($user); |
|
| 912 | + } |
|
| 913 | 913 | |
| 914 | - return $user_id; |
|
| 915 | - } |
|
| 914 | + return $user_id; |
|
| 915 | + } |
|
| 916 | 916 | |
| 917 | 917 | public static function get_file_contents( $filename, $atts = array() ) { |
| 918 | - if ( ! is_file($filename) ) { |
|
| 919 | - return false; |
|
| 920 | - } |
|
| 921 | - |
|
| 922 | - extract($atts); |
|
| 923 | - ob_start(); |
|
| 924 | - include($filename); |
|
| 925 | - $contents = ob_get_contents(); |
|
| 926 | - ob_end_clean(); |
|
| 927 | - return $contents; |
|
| 928 | - } |
|
| 929 | - |
|
| 930 | - /** |
|
| 931 | - * @param string $table_name |
|
| 932 | - * @param string $column |
|
| 918 | + if ( ! is_file($filename) ) { |
|
| 919 | + return false; |
|
| 920 | + } |
|
| 921 | + |
|
| 922 | + extract($atts); |
|
| 923 | + ob_start(); |
|
| 924 | + include($filename); |
|
| 925 | + $contents = ob_get_contents(); |
|
| 926 | + ob_end_clean(); |
|
| 927 | + return $contents; |
|
| 928 | + } |
|
| 929 | + |
|
| 930 | + /** |
|
| 931 | + * @param string $table_name |
|
| 932 | + * @param string $column |
|
| 933 | 933 | * @param int $id |
| 934 | 934 | * @param int $num_chars |
| 935 | - */ |
|
| 936 | - public static function get_unique_key( $name = '', $table_name, $column, $id = 0, $num_chars = 5 ) { |
|
| 937 | - $key = ''; |
|
| 935 | + */ |
|
| 936 | + public static function get_unique_key( $name = '', $table_name, $column, $id = 0, $num_chars = 5 ) { |
|
| 937 | + $key = ''; |
|
| 938 | 938 | |
| 939 | - if ( ! empty( $name ) ) { |
|
| 940 | - $key = sanitize_key($name); |
|
| 941 | - } |
|
| 939 | + if ( ! empty( $name ) ) { |
|
| 940 | + $key = sanitize_key($name); |
|
| 941 | + } |
|
| 942 | 942 | |
| 943 | 943 | if ( empty( $key ) ) { |
| 944 | - $max_slug_value = pow(36, $num_chars); |
|
| 945 | - $min_slug_value = 37; // we want to have at least 2 characters in the slug |
|
| 946 | - $key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 ); |
|
| 947 | - } |
|
| 944 | + $max_slug_value = pow(36, $num_chars); |
|
| 945 | + $min_slug_value = 37; // we want to have at least 2 characters in the slug |
|
| 946 | + $key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 ); |
|
| 947 | + } |
|
| 948 | 948 | |
| 949 | 949 | if ( is_numeric($key) || in_array( $key, array( 'id', 'key', 'created-at', 'detaillink', 'editlink', 'siteurl', 'evenodd' ) ) ) { |
| 950 | 950 | $key = $key . 'a'; |
| 951 | - } |
|
| 951 | + } |
|
| 952 | 952 | |
| 953 | 953 | $key_check = FrmDb::get_var( $table_name, array( $column => $key, 'ID !' => $id ), $column ); |
| 954 | 954 | |
| 955 | - if ( $key_check || is_numeric($key_check) ) { |
|
| 956 | - $suffix = 2; |
|
| 955 | + if ( $key_check || is_numeric($key_check) ) { |
|
| 956 | + $suffix = 2; |
|
| 957 | 957 | do { |
| 958 | 958 | $alt_post_name = substr( $key, 0, 200 - ( strlen( $suffix ) + 1 ) ) . $suffix; |
| 959 | 959 | $key_check = FrmDb::get_var( $table_name, array( $column => $alt_post_name, 'ID !' => $id ), $column ); |
| 960 | 960 | $suffix++; |
| 961 | 961 | } while ($key_check || is_numeric($key_check)); |
| 962 | 962 | $key = $alt_post_name; |
| 963 | - } |
|
| 964 | - return $key; |
|
| 965 | - } |
|
| 966 | - |
|
| 967 | - /** |
|
| 968 | - * Editing a Form or Entry |
|
| 969 | - * @param string $table |
|
| 970 | - * @return bool|array |
|
| 971 | - */ |
|
| 972 | - public static function setup_edit_vars( $record, $table, $fields = '', $default = false, $post_values = array(), $args = array() ) { |
|
| 973 | - if ( ! $record ) { |
|
| 974 | - return false; |
|
| 975 | - } |
|
| 976 | - |
|
| 977 | - if ( empty($post_values) ) { |
|
| 978 | - $post_values = stripslashes_deep($_POST); |
|
| 979 | - } |
|
| 963 | + } |
|
| 964 | + return $key; |
|
| 965 | + } |
|
| 966 | + |
|
| 967 | + /** |
|
| 968 | + * Editing a Form or Entry |
|
| 969 | + * @param string $table |
|
| 970 | + * @return bool|array |
|
| 971 | + */ |
|
| 972 | + public static function setup_edit_vars( $record, $table, $fields = '', $default = false, $post_values = array(), $args = array() ) { |
|
| 973 | + if ( ! $record ) { |
|
| 974 | + return false; |
|
| 975 | + } |
|
| 976 | + |
|
| 977 | + if ( empty($post_values) ) { |
|
| 978 | + $post_values = stripslashes_deep($_POST); |
|
| 979 | + } |
|
| 980 | 980 | |
| 981 | 981 | $values = array( 'id' => $record->id, 'fields' => array() ); |
| 982 | 982 | |
| 983 | 983 | foreach ( array( 'name', 'description' ) as $var ) { |
| 984 | - $default_val = isset($record->{$var}) ? $record->{$var} : ''; |
|
| 984 | + $default_val = isset($record->{$var}) ? $record->{$var} : ''; |
|
| 985 | 985 | $values[ $var ] = self::get_param( $var, $default_val, 'get', 'wp_kses_post' ); |
| 986 | - unset($var, $default_val); |
|
| 987 | - } |
|
| 988 | - |
|
| 989 | - $values['description'] = self::use_wpautop($values['description']); |
|
| 990 | - $frm_settings = self::get_settings(); |
|
| 991 | - $is_form_builder = self::is_admin_page('formidable' ); |
|
| 992 | - |
|
| 993 | - foreach ( (array) $fields as $field ) { |
|
| 994 | - // Make sure to filter default values (for placeholder text), but not on the form builder page |
|
| 995 | - if ( ! $is_form_builder ) { |
|
| 996 | - $field->default_value = apply_filters('frm_get_default_value', $field->default_value, $field, true ); |
|
| 997 | - } |
|
| 986 | + unset($var, $default_val); |
|
| 987 | + } |
|
| 988 | + |
|
| 989 | + $values['description'] = self::use_wpautop($values['description']); |
|
| 990 | + $frm_settings = self::get_settings(); |
|
| 991 | + $is_form_builder = self::is_admin_page('formidable' ); |
|
| 992 | + |
|
| 993 | + foreach ( (array) $fields as $field ) { |
|
| 994 | + // Make sure to filter default values (for placeholder text), but not on the form builder page |
|
| 995 | + if ( ! $is_form_builder ) { |
|
| 996 | + $field->default_value = apply_filters('frm_get_default_value', $field->default_value, $field, true ); |
|
| 997 | + } |
|
| 998 | 998 | $parent_form_id = isset( $args['parent_form_id'] ) ? $args['parent_form_id'] : $field->form_id; |
| 999 | 999 | self::fill_field_defaults($field, $record, $values, compact('default', 'post_values', 'frm_settings', 'parent_form_id' ) ); |
| 1000 | - } |
|
| 1000 | + } |
|
| 1001 | 1001 | |
| 1002 | - self::fill_form_opts($record, $table, $post_values, $values); |
|
| 1002 | + self::fill_form_opts($record, $table, $post_values, $values); |
|
| 1003 | 1003 | |
| 1004 | - if ( $table == 'entries' ) { |
|
| 1005 | - $values = FrmEntriesHelper::setup_edit_vars( $values, $record ); |
|
| 1006 | - } else if ( $table == 'forms' ) { |
|
| 1007 | - $values = FrmFormsHelper::setup_edit_vars( $values, $record, $post_values ); |
|
| 1008 | - } |
|
| 1004 | + if ( $table == 'entries' ) { |
|
| 1005 | + $values = FrmEntriesHelper::setup_edit_vars( $values, $record ); |
|
| 1006 | + } else if ( $table == 'forms' ) { |
|
| 1007 | + $values = FrmFormsHelper::setup_edit_vars( $values, $record, $post_values ); |
|
| 1008 | + } |
|
| 1009 | 1009 | |
| 1010 | - return $values; |
|
| 1011 | - } |
|
| 1010 | + return $values; |
|
| 1011 | + } |
|
| 1012 | 1012 | |
| 1013 | 1013 | private static function fill_field_defaults( $field, $record, array &$values, $args ) { |
| 1014 | - $post_values = $args['post_values']; |
|
| 1015 | - |
|
| 1016 | - if ( $args['default'] ) { |
|
| 1017 | - $meta_value = $field->default_value; |
|
| 1018 | - } else { |
|
| 1019 | - if ( $record->post_id && self::pro_is_installed() && isset($field->field_options['post_field']) && $field->field_options['post_field'] ) { |
|
| 1020 | - if ( ! isset($field->field_options['custom_field']) ) { |
|
| 1021 | - $field->field_options['custom_field'] = ''; |
|
| 1022 | - } |
|
| 1014 | + $post_values = $args['post_values']; |
|
| 1015 | + |
|
| 1016 | + if ( $args['default'] ) { |
|
| 1017 | + $meta_value = $field->default_value; |
|
| 1018 | + } else { |
|
| 1019 | + if ( $record->post_id && self::pro_is_installed() && isset($field->field_options['post_field']) && $field->field_options['post_field'] ) { |
|
| 1020 | + if ( ! isset($field->field_options['custom_field']) ) { |
|
| 1021 | + $field->field_options['custom_field'] = ''; |
|
| 1022 | + } |
|
| 1023 | 1023 | $meta_value = FrmProEntryMetaHelper::get_post_value( $record->post_id, $field->field_options['post_field'], $field->field_options['custom_field'], array( 'truncate' => false, 'type' => $field->type, 'form_id' => $field->form_id, 'field' => $field ) ); |
| 1024 | - } else { |
|
| 1024 | + } else { |
|
| 1025 | 1025 | $meta_value = FrmEntryMeta::get_meta_value( $record, $field->id ); |
| 1026 | - } |
|
| 1027 | - } |
|
| 1026 | + } |
|
| 1027 | + } |
|
| 1028 | 1028 | |
| 1029 | 1029 | $field_type = isset( $post_values['field_options'][ 'type_' . $field->id ] ) ? $post_values['field_options'][ 'type_' . $field->id ] : $field->type; |
| 1030 | - $new_value = isset( $post_values['item_meta'][ $field->id ] ) ? maybe_unserialize( $post_values['item_meta'][ $field->id ] ) : $meta_value; |
|
| 1031 | - |
|
| 1032 | - $field_array = array( |
|
| 1033 | - 'id' => $field->id, |
|
| 1034 | - 'value' => $new_value, |
|
| 1035 | - 'default_value' => $field->default_value, |
|
| 1036 | - 'name' => $field->name, |
|
| 1037 | - 'description' => $field->description, |
|
| 1038 | - 'type' => apply_filters('frm_field_type', $field_type, $field, $new_value), |
|
| 1039 | - 'options' => $field->options, |
|
| 1040 | - 'required' => $field->required, |
|
| 1041 | - 'field_key' => $field->field_key, |
|
| 1042 | - 'field_order' => $field->field_order, |
|
| 1043 | - 'form_id' => $field->form_id, |
|
| 1030 | + $new_value = isset( $post_values['item_meta'][ $field->id ] ) ? maybe_unserialize( $post_values['item_meta'][ $field->id ] ) : $meta_value; |
|
| 1031 | + |
|
| 1032 | + $field_array = array( |
|
| 1033 | + 'id' => $field->id, |
|
| 1034 | + 'value' => $new_value, |
|
| 1035 | + 'default_value' => $field->default_value, |
|
| 1036 | + 'name' => $field->name, |
|
| 1037 | + 'description' => $field->description, |
|
| 1038 | + 'type' => apply_filters('frm_field_type', $field_type, $field, $new_value), |
|
| 1039 | + 'options' => $field->options, |
|
| 1040 | + 'required' => $field->required, |
|
| 1041 | + 'field_key' => $field->field_key, |
|
| 1042 | + 'field_order' => $field->field_order, |
|
| 1043 | + 'form_id' => $field->form_id, |
|
| 1044 | 1044 | 'parent_form_id' => $args['parent_form_id'], |
| 1045 | - ); |
|
| 1045 | + ); |
|
| 1046 | 1046 | |
| 1047 | - $args['field_type'] = $field_type; |
|
| 1048 | - self::fill_field_opts($field, $field_array, $args); |
|
| 1047 | + $args['field_type'] = $field_type; |
|
| 1048 | + self::fill_field_opts($field, $field_array, $args); |
|
| 1049 | 1049 | // Track the original field's type |
| 1050 | 1050 | $field_array['original_type'] = isset( $field->field_options['original_type'] ) ? $field->field_options['original_type'] : $field->type; |
| 1051 | 1051 | |
| 1052 | - $field_array = apply_filters( 'frm_setup_edit_fields_vars', $field_array, $field, $values['id'], array() ); |
|
| 1052 | + $field_array = apply_filters( 'frm_setup_edit_fields_vars', $field_array, $field, $values['id'], array() ); |
|
| 1053 | 1053 | |
| 1054 | - if ( ! isset($field_array['unique']) || ! $field_array['unique'] ) { |
|
| 1055 | - $field_array['unique_msg'] = ''; |
|
| 1056 | - } |
|
| 1054 | + if ( ! isset($field_array['unique']) || ! $field_array['unique'] ) { |
|
| 1055 | + $field_array['unique_msg'] = ''; |
|
| 1056 | + } |
|
| 1057 | 1057 | |
| 1058 | - $field_array = array_merge( $field->field_options, $field_array ); |
|
| 1058 | + $field_array = array_merge( $field->field_options, $field_array ); |
|
| 1059 | 1059 | |
| 1060 | - $values['fields'][ $field->id ] = $field_array; |
|
| 1061 | - } |
|
| 1060 | + $values['fields'][ $field->id ] = $field_array; |
|
| 1061 | + } |
|
| 1062 | 1062 | |
| 1063 | 1063 | private static function fill_field_opts( $field, array &$field_array, $args ) { |
| 1064 | - $post_values = $args['post_values']; |
|
| 1065 | - $opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true); |
|
| 1064 | + $post_values = $args['post_values']; |
|
| 1065 | + $opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true); |
|
| 1066 | 1066 | |
| 1067 | - foreach ( $opt_defaults as $opt => $default_opt ) { |
|
| 1067 | + foreach ( $opt_defaults as $opt => $default_opt ) { |
|
| 1068 | 1068 | $field_array[ $opt ] = ( $post_values && isset( $post_values['field_options'][ $opt . '_' . $field->id ] ) ) ? maybe_unserialize( $post_values['field_options'][ $opt . '_' . $field->id ] ) : ( isset( $field->field_options[ $opt ] ) ? $field->field_options[ $opt ] : $default_opt ); |
| 1069 | - if ( $opt == 'blank' && $field_array[ $opt ] == '' ) { |
|
| 1070 | - $field_array[ $opt ] = $args['frm_settings']->blank_msg; |
|
| 1071 | - } else if ( $opt == 'invalid' && $field_array[ $opt ] == '' ) { |
|
| 1072 | - if ( $args['field_type'] == 'captcha' ) { |
|
| 1073 | - $field_array[ $opt ] = $args['frm_settings']->re_msg; |
|
| 1074 | - } else { |
|
| 1075 | - $field_array[ $opt ] = sprintf( __( '%s is invalid', 'formidable' ), $field_array['name'] ); |
|
| 1076 | - } |
|
| 1077 | - } |
|
| 1078 | - } |
|
| 1079 | - |
|
| 1080 | - if ( $field_array['custom_html'] == '' ) { |
|
| 1081 | - $field_array['custom_html'] = FrmFieldsHelper::get_default_html($args['field_type']); |
|
| 1082 | - } |
|
| 1083 | - } |
|
| 1084 | - |
|
| 1085 | - /** |
|
| 1086 | - * @param string $table |
|
| 1087 | - */ |
|
| 1069 | + if ( $opt == 'blank' && $field_array[ $opt ] == '' ) { |
|
| 1070 | + $field_array[ $opt ] = $args['frm_settings']->blank_msg; |
|
| 1071 | + } else if ( $opt == 'invalid' && $field_array[ $opt ] == '' ) { |
|
| 1072 | + if ( $args['field_type'] == 'captcha' ) { |
|
| 1073 | + $field_array[ $opt ] = $args['frm_settings']->re_msg; |
|
| 1074 | + } else { |
|
| 1075 | + $field_array[ $opt ] = sprintf( __( '%s is invalid', 'formidable' ), $field_array['name'] ); |
|
| 1076 | + } |
|
| 1077 | + } |
|
| 1078 | + } |
|
| 1079 | + |
|
| 1080 | + if ( $field_array['custom_html'] == '' ) { |
|
| 1081 | + $field_array['custom_html'] = FrmFieldsHelper::get_default_html($args['field_type']); |
|
| 1082 | + } |
|
| 1083 | + } |
|
| 1084 | + |
|
| 1085 | + /** |
|
| 1086 | + * @param string $table |
|
| 1087 | + */ |
|
| 1088 | 1088 | private static function fill_form_opts( $record, $table, $post_values, array &$values ) { |
| 1089 | - if ( $table == 'entries' ) { |
|
| 1090 | - $form = $record->form_id; |
|
| 1089 | + if ( $table == 'entries' ) { |
|
| 1090 | + $form = $record->form_id; |
|
| 1091 | 1091 | FrmForm::maybe_get_form( $form ); |
| 1092 | - } else { |
|
| 1093 | - $form = $record; |
|
| 1094 | - } |
|
| 1092 | + } else { |
|
| 1093 | + $form = $record; |
|
| 1094 | + } |
|
| 1095 | 1095 | |
| 1096 | - if ( ! $form ) { |
|
| 1097 | - return; |
|
| 1098 | - } |
|
| 1096 | + if ( ! $form ) { |
|
| 1097 | + return; |
|
| 1098 | + } |
|
| 1099 | 1099 | |
| 1100 | - $values['form_name'] = isset($record->form_id) ? $form->name : ''; |
|
| 1100 | + $values['form_name'] = isset($record->form_id) ? $form->name : ''; |
|
| 1101 | 1101 | $values['parent_form_id'] = isset( $record->form_id ) ? $form->parent_form_id : 0; |
| 1102 | 1102 | |
| 1103 | - if ( ! is_array($form->options) ) { |
|
| 1104 | - return; |
|
| 1105 | - } |
|
| 1103 | + if ( ! is_array($form->options) ) { |
|
| 1104 | + return; |
|
| 1105 | + } |
|
| 1106 | 1106 | |
| 1107 | - foreach ( $form->options as $opt => $value ) { |
|
| 1108 | - $values[ $opt ] = isset( $post_values[ $opt ] ) ? maybe_unserialize( $post_values[ $opt ] ) : $value; |
|
| 1109 | - } |
|
| 1107 | + foreach ( $form->options as $opt => $value ) { |
|
| 1108 | + $values[ $opt ] = isset( $post_values[ $opt ] ) ? maybe_unserialize( $post_values[ $opt ] ) : $value; |
|
| 1109 | + } |
|
| 1110 | 1110 | |
| 1111 | - self::fill_form_defaults($post_values, $values); |
|
| 1112 | - } |
|
| 1111 | + self::fill_form_defaults($post_values, $values); |
|
| 1112 | + } |
|
| 1113 | 1113 | |
| 1114 | - /** |
|
| 1115 | - * Set to POST value or default |
|
| 1116 | - */ |
|
| 1114 | + /** |
|
| 1115 | + * Set to POST value or default |
|
| 1116 | + */ |
|
| 1117 | 1117 | private static function fill_form_defaults( $post_values, array &$values ) { |
| 1118 | - $form_defaults = FrmFormsHelper::get_default_opts(); |
|
| 1118 | + $form_defaults = FrmFormsHelper::get_default_opts(); |
|
| 1119 | 1119 | |
| 1120 | - foreach ( $form_defaults as $opt => $default ) { |
|
| 1121 | - if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) { |
|
| 1120 | + foreach ( $form_defaults as $opt => $default ) { |
|
| 1121 | + if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) { |
|
| 1122 | 1122 | $values[ $opt ] = ( $post_values && isset( $post_values['options'][ $opt ] ) ) ? $post_values['options'][ $opt ] : $default; |
| 1123 | - } |
|
| 1123 | + } |
|
| 1124 | 1124 | |
| 1125 | - unset($opt, $defaut); |
|
| 1126 | - } |
|
| 1125 | + unset($opt, $defaut); |
|
| 1126 | + } |
|
| 1127 | 1127 | |
| 1128 | - if ( ! isset($values['custom_style']) ) { |
|
| 1129 | - $frm_settings = self::get_settings(); |
|
| 1128 | + if ( ! isset($values['custom_style']) ) { |
|
| 1129 | + $frm_settings = self::get_settings(); |
|
| 1130 | 1130 | $values['custom_style'] = ( $post_values && isset( $post_values['options']['custom_style'] ) ) ? absint( $_POST['options']['custom_style'] ) : ( $frm_settings->load_style != 'none' ); |
| 1131 | - } |
|
| 1131 | + } |
|
| 1132 | 1132 | |
| 1133 | 1133 | foreach ( array( 'before', 'after', 'submit' ) as $h ) { |
| 1134 | 1134 | if ( ! isset( $values[ $h . '_html' ] ) ) { |
| 1135 | 1135 | $values[ $h . '_html' ] = ( isset( $post_values['options'][ $h . '_html' ] ) ? $post_values['options'][ $h . '_html' ] : FrmFormsHelper::get_default_html( $h ) ); |
| 1136 | - } |
|
| 1137 | - unset($h); |
|
| 1138 | - } |
|
| 1139 | - } |
|
| 1136 | + } |
|
| 1137 | + unset($h); |
|
| 1138 | + } |
|
| 1139 | + } |
|
| 1140 | 1140 | |
| 1141 | 1141 | public static function get_meta_value( $field_id, $entry ) { |
| 1142 | 1142 | _deprecated_function( __FUNCTION__, '2.0.9', 'FrmEntryMeta::get_meta_value' ); |
@@ -1144,59 +1144,59 @@ discard block |
||
| 1144 | 1144 | } |
| 1145 | 1145 | |
| 1146 | 1146 | public static function insert_opt_html( $args ) { |
| 1147 | - $class = ''; |
|
| 1148 | - if ( in_array( $args['type'], array( 'email', 'user_id', 'hidden', 'select', 'radio', 'checkbox', 'phone', 'text' ) ) ) { |
|
| 1149 | - $class .= 'show_frm_not_email_to'; |
|
| 1150 | - } |
|
| 1151 | - ?> |
|
| 1147 | + $class = ''; |
|
| 1148 | + if ( in_array( $args['type'], array( 'email', 'user_id', 'hidden', 'select', 'radio', 'checkbox', 'phone', 'text' ) ) ) { |
|
| 1149 | + $class .= 'show_frm_not_email_to'; |
|
| 1150 | + } |
|
| 1151 | + ?> |
|
| 1152 | 1152 | <li> |
| 1153 | 1153 | <a href="javascript:void(0)" class="frmids frm_insert_code alignright <?php echo esc_attr($class) ?>" data-code="<?php echo esc_attr($args['id']) ?>" >[<?php echo esc_attr( $args['id'] ) ?>]</a> |
| 1154 | 1154 | <a href="javascript:void(0)" class="frmkeys frm_insert_code alignright <?php echo esc_attr($class) ?>" data-code="<?php echo esc_attr($args['key']) ?>" >[<?php echo esc_attr( self::truncate($args['key'], 10) ) ?>]</a> |
| 1155 | 1155 | <a href="javascript:void(0)" class="frm_insert_code <?php echo esc_attr( $class ) ?>" data-code="<?php echo esc_attr($args['id']) ?>" ><?php echo esc_attr( self::truncate($args['name'], 60) ) ?></a> |
| 1156 | 1156 | </li> |
| 1157 | 1157 | <?php |
| 1158 | - } |
|
| 1158 | + } |
|
| 1159 | 1159 | |
| 1160 | 1160 | public static function truncate( $str, $length, $minword = 3, $continue = '...' ) { |
| 1161 | - if ( is_array( $str ) ) { |
|
| 1162 | - return ''; |
|
| 1161 | + if ( is_array( $str ) ) { |
|
| 1162 | + return ''; |
|
| 1163 | 1163 | } |
| 1164 | 1164 | |
| 1165 | - $length = (int) $length; |
|
| 1165 | + $length = (int) $length; |
|
| 1166 | 1166 | $str = wp_strip_all_tags( $str ); |
| 1167 | 1167 | $original_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $str ) ); |
| 1168 | 1168 | |
| 1169 | 1169 | if ( $length == 0 ) { |
| 1170 | - return ''; |
|
| 1171 | - } else if ( $length <= 10 ) { |
|
| 1170 | + return ''; |
|
| 1171 | + } else if ( $length <= 10 ) { |
|
| 1172 | 1172 | $sub = self::mb_function( array( 'mb_substr', 'substr' ), array( $str, 0, $length ) ); |
| 1173 | - return $sub . (($length < $original_len) ? $continue : ''); |
|
| 1174 | - } |
|
| 1173 | + return $sub . (($length < $original_len) ? $continue : ''); |
|
| 1174 | + } |
|
| 1175 | 1175 | |
| 1176 | - $sub = ''; |
|
| 1177 | - $len = 0; |
|
| 1176 | + $sub = ''; |
|
| 1177 | + $len = 0; |
|
| 1178 | 1178 | |
| 1179 | 1179 | $words = self::mb_function( array( 'mb_split', 'explode' ), array( ' ', $str ) ); |
| 1180 | 1180 | |
| 1181 | 1181 | foreach ( $words as $word ) { |
| 1182 | - $part = (($sub != '') ? ' ' : '') . $word; |
|
| 1182 | + $part = (($sub != '') ? ' ' : '') . $word; |
|
| 1183 | 1183 | $total_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $sub . $part ) ); |
| 1184 | - if ( $total_len > $length && str_word_count($sub) ) { |
|
| 1185 | - break; |
|
| 1186 | - } |
|
| 1184 | + if ( $total_len > $length && str_word_count($sub) ) { |
|
| 1185 | + break; |
|
| 1186 | + } |
|
| 1187 | 1187 | |
| 1188 | - $sub .= $part; |
|
| 1188 | + $sub .= $part; |
|
| 1189 | 1189 | $len += self::mb_function( array( 'mb_strlen', 'strlen' ), array( $part ) ); |
| 1190 | 1190 | |
| 1191 | - if ( str_word_count($sub) > $minword && $total_len >= $length ) { |
|
| 1192 | - break; |
|
| 1193 | - } |
|
| 1191 | + if ( str_word_count($sub) > $minword && $total_len >= $length ) { |
|
| 1192 | + break; |
|
| 1193 | + } |
|
| 1194 | 1194 | |
| 1195 | - unset($total_len, $word); |
|
| 1196 | - } |
|
| 1195 | + unset($total_len, $word); |
|
| 1196 | + } |
|
| 1197 | 1197 | |
| 1198 | - return $sub . (($len < $original_len) ? $continue : ''); |
|
| 1199 | - } |
|
| 1198 | + return $sub . (($len < $original_len) ? $continue : ''); |
|
| 1199 | + } |
|
| 1200 | 1200 | |
| 1201 | 1201 | public static function mb_function( $function_names, $args ) { |
| 1202 | 1202 | $mb_function_name = $function_names[0]; |
@@ -1208,18 +1208,18 @@ discard block |
||
| 1208 | 1208 | } |
| 1209 | 1209 | |
| 1210 | 1210 | public static function get_formatted_time( $date, $date_format = '', $time_format = '' ) { |
| 1211 | - if ( empty($date) ) { |
|
| 1212 | - return $date; |
|
| 1213 | - } |
|
| 1211 | + if ( empty($date) ) { |
|
| 1212 | + return $date; |
|
| 1213 | + } |
|
| 1214 | 1214 | |
| 1215 | - if ( empty($date_format) ) { |
|
| 1216 | - $date_format = get_option('date_format'); |
|
| 1217 | - } |
|
| 1215 | + if ( empty($date_format) ) { |
|
| 1216 | + $date_format = get_option('date_format'); |
|
| 1217 | + } |
|
| 1218 | 1218 | |
| 1219 | - if ( preg_match('/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date) && self::pro_is_installed() ) { |
|
| 1220 | - $frmpro_settings = new FrmProSettings(); |
|
| 1221 | - $date = FrmProAppHelper::convert_date($date, $frmpro_settings->date_format, 'Y-m-d'); |
|
| 1222 | - } |
|
| 1219 | + if ( preg_match('/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date) && self::pro_is_installed() ) { |
|
| 1220 | + $frmpro_settings = new FrmProSettings(); |
|
| 1221 | + $date = FrmProAppHelper::convert_date($date, $frmpro_settings->date_format, 'Y-m-d'); |
|
| 1222 | + } |
|
| 1223 | 1223 | |
| 1224 | 1224 | $formatted = self::get_localized_date( $date_format, $date ); |
| 1225 | 1225 | |
@@ -1228,8 +1228,8 @@ discard block |
||
| 1228 | 1228 | $formatted .= self::add_time_to_date( $time_format, $date ); |
| 1229 | 1229 | } |
| 1230 | 1230 | |
| 1231 | - return $formatted; |
|
| 1232 | - } |
|
| 1231 | + return $formatted; |
|
| 1232 | + } |
|
| 1233 | 1233 | |
| 1234 | 1234 | private static function add_time_to_date( $time_format, $date ) { |
| 1235 | 1235 | if ( empty( $time_format ) ) { |
@@ -1310,61 +1310,61 @@ discard block |
||
| 1310 | 1310 | ); |
| 1311 | 1311 | } |
| 1312 | 1312 | |
| 1313 | - /** |
|
| 1314 | - * Added for < WP 4.0 compatability |
|
| 1315 | - * |
|
| 1316 | - * @since 1.07.10 |
|
| 1317 | - * |
|
| 1318 | - * @param string $term The value to escape |
|
| 1319 | - * @return string The escaped value |
|
| 1320 | - */ |
|
| 1313 | + /** |
|
| 1314 | + * Added for < WP 4.0 compatability |
|
| 1315 | + * |
|
| 1316 | + * @since 1.07.10 |
|
| 1317 | + * |
|
| 1318 | + * @param string $term The value to escape |
|
| 1319 | + * @return string The escaped value |
|
| 1320 | + */ |
|
| 1321 | 1321 | public static function esc_like( $term ) { |
| 1322 | - global $wpdb; |
|
| 1323 | - if ( method_exists($wpdb, 'esc_like') ) { |
|
| 1322 | + global $wpdb; |
|
| 1323 | + if ( method_exists($wpdb, 'esc_like') ) { |
|
| 1324 | 1324 | // WP 4.0 |
| 1325 | - $term = $wpdb->esc_like( $term ); |
|
| 1326 | - } else { |
|
| 1327 | - $term = like_escape( $term ); |
|
| 1328 | - } |
|
| 1325 | + $term = $wpdb->esc_like( $term ); |
|
| 1326 | + } else { |
|
| 1327 | + $term = like_escape( $term ); |
|
| 1328 | + } |
|
| 1329 | 1329 | |
| 1330 | - return $term; |
|
| 1331 | - } |
|
| 1330 | + return $term; |
|
| 1331 | + } |
|
| 1332 | 1332 | |
| 1333 | - /** |
|
| 1334 | - * @param string $order_query |
|
| 1335 | - */ |
|
| 1333 | + /** |
|
| 1334 | + * @param string $order_query |
|
| 1335 | + */ |
|
| 1336 | 1336 | public static function esc_order( $order_query ) { |
| 1337 | - if ( empty($order_query) ) { |
|
| 1338 | - return ''; |
|
| 1339 | - } |
|
| 1340 | - |
|
| 1341 | - // remove ORDER BY before santizing |
|
| 1342 | - $order_query = strtolower($order_query); |
|
| 1343 | - if ( strpos($order_query, 'order by') !== false ) { |
|
| 1344 | - $order_query = str_replace('order by', '', $order_query); |
|
| 1345 | - } |
|
| 1346 | - |
|
| 1347 | - $order_query = explode(' ', trim($order_query)); |
|
| 1348 | - |
|
| 1349 | - $order_fields = array( |
|
| 1350 | - 'id', 'form_key', 'name', 'description', |
|
| 1351 | - 'parent_form_id', 'logged_in', 'is_template', |
|
| 1352 | - 'default_template', 'status', 'created_at', |
|
| 1353 | - ); |
|
| 1354 | - |
|
| 1355 | - $order = trim(trim(reset($order_query), ',')); |
|
| 1356 | - if ( ! in_array($order, $order_fields) ) { |
|
| 1357 | - return ''; |
|
| 1358 | - } |
|
| 1359 | - |
|
| 1360 | - $order_by = ''; |
|
| 1361 | - if ( count($order_query) > 1 ) { |
|
| 1337 | + if ( empty($order_query) ) { |
|
| 1338 | + return ''; |
|
| 1339 | + } |
|
| 1340 | + |
|
| 1341 | + // remove ORDER BY before santizing |
|
| 1342 | + $order_query = strtolower($order_query); |
|
| 1343 | + if ( strpos($order_query, 'order by') !== false ) { |
|
| 1344 | + $order_query = str_replace('order by', '', $order_query); |
|
| 1345 | + } |
|
| 1346 | + |
|
| 1347 | + $order_query = explode(' ', trim($order_query)); |
|
| 1348 | + |
|
| 1349 | + $order_fields = array( |
|
| 1350 | + 'id', 'form_key', 'name', 'description', |
|
| 1351 | + 'parent_form_id', 'logged_in', 'is_template', |
|
| 1352 | + 'default_template', 'status', 'created_at', |
|
| 1353 | + ); |
|
| 1354 | + |
|
| 1355 | + $order = trim(trim(reset($order_query), ',')); |
|
| 1356 | + if ( ! in_array($order, $order_fields) ) { |
|
| 1357 | + return ''; |
|
| 1358 | + } |
|
| 1359 | + |
|
| 1360 | + $order_by = ''; |
|
| 1361 | + if ( count($order_query) > 1 ) { |
|
| 1362 | 1362 | $order_by = end( $order_query ); |
| 1363 | 1363 | self::esc_order_by( $order_by ); |
| 1364 | - } |
|
| 1364 | + } |
|
| 1365 | 1365 | |
| 1366 | 1366 | return ' ORDER BY ' . $order . ' ' . $order_by; |
| 1367 | - } |
|
| 1367 | + } |
|
| 1368 | 1368 | |
| 1369 | 1369 | /** |
| 1370 | 1370 | * Make sure this is ordering by either ASC or DESC |
@@ -1376,169 +1376,169 @@ discard block |
||
| 1376 | 1376 | } |
| 1377 | 1377 | } |
| 1378 | 1378 | |
| 1379 | - /** |
|
| 1380 | - * @param string $limit |
|
| 1381 | - */ |
|
| 1379 | + /** |
|
| 1380 | + * @param string $limit |
|
| 1381 | + */ |
|
| 1382 | 1382 | public static function esc_limit( $limit ) { |
| 1383 | - if ( empty($limit) ) { |
|
| 1384 | - return ''; |
|
| 1385 | - } |
|
| 1383 | + if ( empty($limit) ) { |
|
| 1384 | + return ''; |
|
| 1385 | + } |
|
| 1386 | 1386 | |
| 1387 | - $limit = trim(str_replace(' limit', '', strtolower($limit))); |
|
| 1388 | - if ( is_numeric($limit) ) { |
|
| 1387 | + $limit = trim(str_replace(' limit', '', strtolower($limit))); |
|
| 1388 | + if ( is_numeric($limit) ) { |
|
| 1389 | 1389 | return ' LIMIT ' . $limit; |
| 1390 | - } |
|
| 1390 | + } |
|
| 1391 | 1391 | |
| 1392 | - $limit = explode(',', trim($limit)); |
|
| 1393 | - foreach ( $limit as $k => $l ) { |
|
| 1394 | - if ( is_numeric( $l ) ) { |
|
| 1395 | - $limit[ $k ] = $l; |
|
| 1396 | - } |
|
| 1397 | - } |
|
| 1392 | + $limit = explode(',', trim($limit)); |
|
| 1393 | + foreach ( $limit as $k => $l ) { |
|
| 1394 | + if ( is_numeric( $l ) ) { |
|
| 1395 | + $limit[ $k ] = $l; |
|
| 1396 | + } |
|
| 1397 | + } |
|
| 1398 | 1398 | |
| 1399 | - $limit = implode(',', $limit); |
|
| 1399 | + $limit = implode(',', $limit); |
|
| 1400 | 1400 | return ' LIMIT ' . $limit; |
| 1401 | - } |
|
| 1402 | - |
|
| 1403 | - /** |
|
| 1404 | - * Get an array of values ready to go through $wpdb->prepare |
|
| 1405 | - * @since 2.0 |
|
| 1406 | - */ |
|
| 1407 | - public static function prepare_array_values( $array, $type = '%s' ) { |
|
| 1408 | - $placeholders = array_fill(0, count($array), $type); |
|
| 1409 | - return implode(', ', $placeholders); |
|
| 1410 | - } |
|
| 1411 | - |
|
| 1412 | - public static function prepend_and_or_where( $starts_with = ' WHERE ', $where = '' ) { |
|
| 1413 | - if ( empty($where) ) { |
|
| 1414 | - return ''; |
|
| 1415 | - } |
|
| 1401 | + } |
|
| 1402 | + |
|
| 1403 | + /** |
|
| 1404 | + * Get an array of values ready to go through $wpdb->prepare |
|
| 1405 | + * @since 2.0 |
|
| 1406 | + */ |
|
| 1407 | + public static function prepare_array_values( $array, $type = '%s' ) { |
|
| 1408 | + $placeholders = array_fill(0, count($array), $type); |
|
| 1409 | + return implode(', ', $placeholders); |
|
| 1410 | + } |
|
| 1411 | + |
|
| 1412 | + public static function prepend_and_or_where( $starts_with = ' WHERE ', $where = '' ) { |
|
| 1413 | + if ( empty($where) ) { |
|
| 1414 | + return ''; |
|
| 1415 | + } |
|
| 1416 | 1416 | |
| 1417 | 1417 | if ( is_array( $where ) ) { |
| 1418 | - global $wpdb; |
|
| 1419 | - FrmDb::get_where_clause_and_values( $where, $starts_with ); |
|
| 1418 | + global $wpdb; |
|
| 1419 | + FrmDb::get_where_clause_and_values( $where, $starts_with ); |
|
| 1420 | 1420 | $where = $wpdb->prepare( $where['where'], $where['values'] ); |
| 1421 | 1421 | } else { |
| 1422 | - $where = $starts_with . $where; |
|
| 1423 | - } |
|
| 1422 | + $where = $starts_with . $where; |
|
| 1423 | + } |
|
| 1424 | 1424 | |
| 1425 | - return $where; |
|
| 1426 | - } |
|
| 1425 | + return $where; |
|
| 1426 | + } |
|
| 1427 | 1427 | |
| 1428 | - // Pagination Methods |
|
| 1428 | + // Pagination Methods |
|
| 1429 | 1429 | |
| 1430 | - /** |
|
| 1431 | - * @param integer $current_p |
|
| 1432 | - */ |
|
| 1430 | + /** |
|
| 1431 | + * @param integer $current_p |
|
| 1432 | + */ |
|
| 1433 | 1433 | public static function get_last_record_num( $r_count, $current_p, $p_size ) { |
| 1434 | 1434 | return ( ( $r_count < ( $current_p * $p_size ) ) ? $r_count : ( $current_p * $p_size ) ); |
| 1435 | 1435 | } |
| 1436 | 1436 | |
| 1437 | - /** |
|
| 1438 | - * @param integer $current_p |
|
| 1439 | - */ |
|
| 1440 | - public static function get_first_record_num( $r_count, $current_p, $p_size ) { |
|
| 1441 | - if ( $current_p == 1 ) { |
|
| 1442 | - return 1; |
|
| 1443 | - } else { |
|
| 1444 | - return ( self::get_last_record_num( $r_count, ( $current_p - 1 ), $p_size ) + 1 ); |
|
| 1445 | - } |
|
| 1446 | - } |
|
| 1437 | + /** |
|
| 1438 | + * @param integer $current_p |
|
| 1439 | + */ |
|
| 1440 | + public static function get_first_record_num( $r_count, $current_p, $p_size ) { |
|
| 1441 | + if ( $current_p == 1 ) { |
|
| 1442 | + return 1; |
|
| 1443 | + } else { |
|
| 1444 | + return ( self::get_last_record_num( $r_count, ( $current_p - 1 ), $p_size ) + 1 ); |
|
| 1445 | + } |
|
| 1446 | + } |
|
| 1447 | 1447 | |
| 1448 | 1448 | /** |
| 1449 | 1449 | * @return array |
| 1450 | 1450 | */ |
| 1451 | 1451 | public static function json_to_array( $json_vars ) { |
| 1452 | - $vars = array(); |
|
| 1453 | - foreach ( $json_vars as $jv ) { |
|
| 1454 | - $jv_name = explode('[', $jv['name']); |
|
| 1455 | - $last = count($jv_name) - 1; |
|
| 1456 | - foreach ( $jv_name as $p => $n ) { |
|
| 1457 | - $name = trim($n, ']'); |
|
| 1458 | - if ( ! isset($l1) ) { |
|
| 1459 | - $l1 = $name; |
|
| 1460 | - } |
|
| 1461 | - |
|
| 1462 | - if ( ! isset($l2) ) { |
|
| 1463 | - $l2 = $name; |
|
| 1464 | - } |
|
| 1465 | - |
|
| 1466 | - if ( ! isset($l3) ) { |
|
| 1467 | - $l3 = $name; |
|
| 1468 | - } |
|
| 1469 | - |
|
| 1470 | - $this_val = ( $p == $last ) ? $jv['value'] : array(); |
|
| 1471 | - |
|
| 1472 | - switch ( $p ) { |
|
| 1473 | - case 0: |
|
| 1474 | - $l1 = $name; |
|
| 1475 | - self::add_value_to_array( $name, $l1, $this_val, $vars ); |
|
| 1476 | - break; |
|
| 1477 | - |
|
| 1478 | - case 1: |
|
| 1479 | - $l2 = $name; |
|
| 1480 | - self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] ); |
|
| 1481 | - break; |
|
| 1482 | - |
|
| 1483 | - case 2: |
|
| 1484 | - $l3 = $name; |
|
| 1485 | - self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] ); |
|
| 1486 | - break; |
|
| 1487 | - |
|
| 1488 | - case 3: |
|
| 1489 | - $l4 = $name; |
|
| 1490 | - self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] ); |
|
| 1491 | - break; |
|
| 1492 | - } |
|
| 1493 | - |
|
| 1494 | - unset($this_val, $n); |
|
| 1495 | - } |
|
| 1496 | - |
|
| 1497 | - unset($last, $jv); |
|
| 1498 | - } |
|
| 1499 | - |
|
| 1500 | - return $vars; |
|
| 1501 | - } |
|
| 1502 | - |
|
| 1503 | - /** |
|
| 1504 | - * @param string $name |
|
| 1505 | - * @param string $l1 |
|
| 1506 | - */ |
|
| 1507 | - public static function add_value_to_array( $name, $l1, $val, &$vars ) { |
|
| 1508 | - if ( $name == '' ) { |
|
| 1509 | - $vars[] = $val; |
|
| 1510 | - } else if ( ! isset( $vars[ $l1 ] ) ) { |
|
| 1511 | - $vars[ $l1 ] = $val; |
|
| 1512 | - } |
|
| 1513 | - } |
|
| 1452 | + $vars = array(); |
|
| 1453 | + foreach ( $json_vars as $jv ) { |
|
| 1454 | + $jv_name = explode('[', $jv['name']); |
|
| 1455 | + $last = count($jv_name) - 1; |
|
| 1456 | + foreach ( $jv_name as $p => $n ) { |
|
| 1457 | + $name = trim($n, ']'); |
|
| 1458 | + if ( ! isset($l1) ) { |
|
| 1459 | + $l1 = $name; |
|
| 1460 | + } |
|
| 1461 | + |
|
| 1462 | + if ( ! isset($l2) ) { |
|
| 1463 | + $l2 = $name; |
|
| 1464 | + } |
|
| 1465 | + |
|
| 1466 | + if ( ! isset($l3) ) { |
|
| 1467 | + $l3 = $name; |
|
| 1468 | + } |
|
| 1469 | + |
|
| 1470 | + $this_val = ( $p == $last ) ? $jv['value'] : array(); |
|
| 1471 | + |
|
| 1472 | + switch ( $p ) { |
|
| 1473 | + case 0: |
|
| 1474 | + $l1 = $name; |
|
| 1475 | + self::add_value_to_array( $name, $l1, $this_val, $vars ); |
|
| 1476 | + break; |
|
| 1477 | + |
|
| 1478 | + case 1: |
|
| 1479 | + $l2 = $name; |
|
| 1480 | + self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] ); |
|
| 1481 | + break; |
|
| 1482 | + |
|
| 1483 | + case 2: |
|
| 1484 | + $l3 = $name; |
|
| 1485 | + self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] ); |
|
| 1486 | + break; |
|
| 1487 | + |
|
| 1488 | + case 3: |
|
| 1489 | + $l4 = $name; |
|
| 1490 | + self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] ); |
|
| 1491 | + break; |
|
| 1492 | + } |
|
| 1493 | + |
|
| 1494 | + unset($this_val, $n); |
|
| 1495 | + } |
|
| 1496 | + |
|
| 1497 | + unset($last, $jv); |
|
| 1498 | + } |
|
| 1499 | + |
|
| 1500 | + return $vars; |
|
| 1501 | + } |
|
| 1502 | + |
|
| 1503 | + /** |
|
| 1504 | + * @param string $name |
|
| 1505 | + * @param string $l1 |
|
| 1506 | + */ |
|
| 1507 | + public static function add_value_to_array( $name, $l1, $val, &$vars ) { |
|
| 1508 | + if ( $name == '' ) { |
|
| 1509 | + $vars[] = $val; |
|
| 1510 | + } else if ( ! isset( $vars[ $l1 ] ) ) { |
|
| 1511 | + $vars[ $l1 ] = $val; |
|
| 1512 | + } |
|
| 1513 | + } |
|
| 1514 | 1514 | |
| 1515 | 1515 | public static function maybe_add_tooltip( $name, $class = 'closed', $form_name = '' ) { |
| 1516 | - $tooltips = array( |
|
| 1517 | - 'action_title' => __( 'Give this action a label for easy reference.', 'formidable' ), |
|
| 1518 | - 'email_to' => __( 'Add one or more recipient addresses separated by a ",". FORMAT: Name <[email protected]> or [email protected]. [admin_email] is the address set in WP General Settings.', 'formidable' ), |
|
| 1519 | - 'cc' => __( 'Add CC addresses separated by a ",". FORMAT: Name <[email protected]> or [email protected].', 'formidable' ), |
|
| 1520 | - 'bcc' => __( 'Add BCC addresses separated by a ",". FORMAT: Name <[email protected]> or [email protected].', 'formidable' ), |
|
| 1521 | - 'reply_to' => __( 'If you would like a different reply to address than the "from" address, add a single address here. FORMAT: Name <[email protected]> or [email protected].', 'formidable' ), |
|
| 1522 | - 'from' => __( 'Enter the name and/or email address of the sender. FORMAT: John Bates <[email protected]> or [email protected].', 'formidable' ), |
|
| 1523 | - 'email_subject' => esc_attr( sprintf( __( 'If you leave the subject blank, the default will be used: %1$s Form submitted on %2$s', 'formidable' ), $form_name, self::site_name() ) ), |
|
| 1524 | - ); |
|
| 1525 | - |
|
| 1526 | - if ( ! isset( $tooltips[ $name ] ) ) { |
|
| 1527 | - return; |
|
| 1528 | - } |
|
| 1529 | - |
|
| 1530 | - if ( 'open' == $class ) { |
|
| 1531 | - echo ' frm_help"'; |
|
| 1532 | - } else { |
|
| 1533 | - echo ' class="frm_help"'; |
|
| 1534 | - } |
|
| 1516 | + $tooltips = array( |
|
| 1517 | + 'action_title' => __( 'Give this action a label for easy reference.', 'formidable' ), |
|
| 1518 | + 'email_to' => __( 'Add one or more recipient addresses separated by a ",". FORMAT: Name <[email protected]> or [email protected]. [admin_email] is the address set in WP General Settings.', 'formidable' ), |
|
| 1519 | + 'cc' => __( 'Add CC addresses separated by a ",". FORMAT: Name <[email protected]> or [email protected].', 'formidable' ), |
|
| 1520 | + 'bcc' => __( 'Add BCC addresses separated by a ",". FORMAT: Name <[email protected]> or [email protected].', 'formidable' ), |
|
| 1521 | + 'reply_to' => __( 'If you would like a different reply to address than the "from" address, add a single address here. FORMAT: Name <[email protected]> or [email protected].', 'formidable' ), |
|
| 1522 | + 'from' => __( 'Enter the name and/or email address of the sender. FORMAT: John Bates <[email protected]> or [email protected].', 'formidable' ), |
|
| 1523 | + 'email_subject' => esc_attr( sprintf( __( 'If you leave the subject blank, the default will be used: %1$s Form submitted on %2$s', 'formidable' ), $form_name, self::site_name() ) ), |
|
| 1524 | + ); |
|
| 1525 | + |
|
| 1526 | + if ( ! isset( $tooltips[ $name ] ) ) { |
|
| 1527 | + return; |
|
| 1528 | + } |
|
| 1529 | + |
|
| 1530 | + if ( 'open' == $class ) { |
|
| 1531 | + echo ' frm_help"'; |
|
| 1532 | + } else { |
|
| 1533 | + echo ' class="frm_help"'; |
|
| 1534 | + } |
|
| 1535 | 1535 | |
| 1536 | 1536 | echo ' title="' . esc_attr( $tooltips[ $name ] ); |
| 1537 | 1537 | |
| 1538 | - if ( 'open' != $class ) { |
|
| 1539 | - echo '"'; |
|
| 1540 | - } |
|
| 1541 | - } |
|
| 1538 | + if ( 'open' != $class ) { |
|
| 1539 | + echo '"'; |
|
| 1540 | + } |
|
| 1541 | + } |
|
| 1542 | 1542 | |
| 1543 | 1543 | /** |
| 1544 | 1544 | * Add the current_page class to that page in the form nav |
@@ -1554,35 +1554,35 @@ discard block |
||
| 1554 | 1554 | } |
| 1555 | 1555 | } |
| 1556 | 1556 | |
| 1557 | - /** |
|
| 1558 | - * Prepare and json_encode post content |
|
| 1559 | - * |
|
| 1560 | - * @since 2.0 |
|
| 1561 | - * |
|
| 1562 | - * @param array $post_content |
|
| 1563 | - * @return string $post_content ( json encoded array ) |
|
| 1564 | - */ |
|
| 1565 | - public static function prepare_and_encode( $post_content ) { |
|
| 1566 | - //Loop through array to strip slashes and add only the needed ones |
|
| 1557 | + /** |
|
| 1558 | + * Prepare and json_encode post content |
|
| 1559 | + * |
|
| 1560 | + * @since 2.0 |
|
| 1561 | + * |
|
| 1562 | + * @param array $post_content |
|
| 1563 | + * @return string $post_content ( json encoded array ) |
|
| 1564 | + */ |
|
| 1565 | + public static function prepare_and_encode( $post_content ) { |
|
| 1566 | + //Loop through array to strip slashes and add only the needed ones |
|
| 1567 | 1567 | foreach ( $post_content as $key => $val ) { |
| 1568 | 1568 | // Replace problematic characters (like ") |
| 1569 | 1569 | $val = str_replace( '"', '"', $val ); |
| 1570 | 1570 | |
| 1571 | 1571 | self::prepare_action_slashes( $val, $key, $post_content ); |
| 1572 | - unset( $key, $val ); |
|
| 1573 | - } |
|
| 1572 | + unset( $key, $val ); |
|
| 1573 | + } |
|
| 1574 | 1574 | |
| 1575 | - // json_encode the array |
|
| 1576 | - $post_content = json_encode( $post_content ); |
|
| 1575 | + // json_encode the array |
|
| 1576 | + $post_content = json_encode( $post_content ); |
|
| 1577 | 1577 | |
| 1578 | - // add extra slashes for \r\n since WP strips them |
|
| 1578 | + // add extra slashes for \r\n since WP strips them |
|
| 1579 | 1579 | $post_content = str_replace( array( '\\r', '\\n', '\\u', '\\t' ), array( '\\\\r', '\\\\n', '\\\\u', '\\\\t' ), $post_content ); |
| 1580 | 1580 | |
| 1581 | - // allow for " |
|
| 1582 | - $post_content = str_replace( '"', '\\"', $post_content ); |
|
| 1581 | + // allow for " |
|
| 1582 | + $post_content = str_replace( '"', '\\"', $post_content ); |
|
| 1583 | 1583 | |
| 1584 | - return $post_content; |
|
| 1585 | - } |
|
| 1584 | + return $post_content; |
|
| 1585 | + } |
|
| 1586 | 1586 | |
| 1587 | 1587 | private static function prepare_action_slashes( $val, $key, &$post_content ) { |
| 1588 | 1588 | if ( ! isset( $post_content[ $key ] ) ) { |
@@ -1650,64 +1650,64 @@ discard block |
||
| 1650 | 1650 | } |
| 1651 | 1651 | |
| 1652 | 1652 | public static function maybe_json_decode( $string ) { |
| 1653 | - if ( is_array($string) ) { |
|
| 1654 | - return $string; |
|
| 1655 | - } |
|
| 1653 | + if ( is_array($string) ) { |
|
| 1654 | + return $string; |
|
| 1655 | + } |
|
| 1656 | 1656 | |
| 1657 | - $new_string = json_decode($string, true); |
|
| 1658 | - if ( function_exists('json_last_error') ) { |
|
| 1657 | + $new_string = json_decode($string, true); |
|
| 1658 | + if ( function_exists('json_last_error') ) { |
|
| 1659 | 1659 | // php 5.3+ |
| 1660 | - if ( json_last_error() == JSON_ERROR_NONE ) { |
|
| 1661 | - $string = $new_string; |
|
| 1662 | - } |
|
| 1663 | - } else if ( isset($new_string) ) { |
|
| 1660 | + if ( json_last_error() == JSON_ERROR_NONE ) { |
|
| 1661 | + $string = $new_string; |
|
| 1662 | + } |
|
| 1663 | + } else if ( isset($new_string) ) { |
|
| 1664 | 1664 | // php < 5.3 fallback |
| 1665 | - $string = $new_string; |
|
| 1666 | - } |
|
| 1667 | - return $string; |
|
| 1668 | - } |
|
| 1669 | - |
|
| 1670 | - /** |
|
| 1671 | - * @since 1.07.10 |
|
| 1672 | - * |
|
| 1673 | - * @param string $post_type The name of the post type that may need to be highlighted |
|
| 1674 | - * echo The javascript to open and highlight the Formidable menu |
|
| 1675 | - */ |
|
| 1665 | + $string = $new_string; |
|
| 1666 | + } |
|
| 1667 | + return $string; |
|
| 1668 | + } |
|
| 1669 | + |
|
| 1670 | + /** |
|
| 1671 | + * @since 1.07.10 |
|
| 1672 | + * |
|
| 1673 | + * @param string $post_type The name of the post type that may need to be highlighted |
|
| 1674 | + * echo The javascript to open and highlight the Formidable menu |
|
| 1675 | + */ |
|
| 1676 | 1676 | public static function maybe_highlight_menu( $post_type ) { |
| 1677 | - global $post; |
|
| 1677 | + global $post; |
|
| 1678 | 1678 | |
| 1679 | - if ( isset($_REQUEST['post_type']) && $_REQUEST['post_type'] != $post_type ) { |
|
| 1680 | - return; |
|
| 1681 | - } |
|
| 1679 | + if ( isset($_REQUEST['post_type']) && $_REQUEST['post_type'] != $post_type ) { |
|
| 1680 | + return; |
|
| 1681 | + } |
|
| 1682 | 1682 | |
| 1683 | - if ( is_object($post) && $post->post_type != $post_type ) { |
|
| 1684 | - return; |
|
| 1685 | - } |
|
| 1683 | + if ( is_object($post) && $post->post_type != $post_type ) { |
|
| 1684 | + return; |
|
| 1685 | + } |
|
| 1686 | 1686 | |
| 1687 | - self::load_admin_wide_js(); |
|
| 1688 | - echo '<script type="text/javascript">jQuery(document).ready(function(){frmSelectSubnav();});</script>'; |
|
| 1689 | - } |
|
| 1687 | + self::load_admin_wide_js(); |
|
| 1688 | + echo '<script type="text/javascript">jQuery(document).ready(function(){frmSelectSubnav();});</script>'; |
|
| 1689 | + } |
|
| 1690 | 1690 | |
| 1691 | - /** |
|
| 1692 | - * Load the JS file on non-Formidable pages in the admin area |
|
| 1693 | - * @since 2.0 |
|
| 1694 | - */ |
|
| 1691 | + /** |
|
| 1692 | + * Load the JS file on non-Formidable pages in the admin area |
|
| 1693 | + * @since 2.0 |
|
| 1694 | + */ |
|
| 1695 | 1695 | public static function load_admin_wide_js( $load = true ) { |
| 1696 | - $version = FrmAppHelper::plugin_version(); |
|
| 1696 | + $version = FrmAppHelper::plugin_version(); |
|
| 1697 | 1697 | wp_register_script( 'formidable_admin_global', FrmAppHelper::plugin_url() . '/js/formidable_admin_global.js', array( 'jquery' ), $version ); |
| 1698 | 1698 | |
| 1699 | - wp_localize_script( 'formidable_admin_global', 'frmGlobal', array( |
|
| 1699 | + wp_localize_script( 'formidable_admin_global', 'frmGlobal', array( |
|
| 1700 | 1700 | 'updating_msg' => __( 'Please wait while your site updates.', 'formidable' ), |
| 1701 | - 'deauthorize' => __( 'Are you sure you want to deauthorize Formidable Forms on this site?', 'formidable' ), |
|
| 1701 | + 'deauthorize' => __( 'Are you sure you want to deauthorize Formidable Forms on this site?', 'formidable' ), |
|
| 1702 | 1702 | 'url' => FrmAppHelper::plugin_url(), |
| 1703 | 1703 | 'loading' => __( 'Loading…' ), |
| 1704 | 1704 | 'nonce' => wp_create_nonce( 'frm_ajax' ), |
| 1705 | - ) ); |
|
| 1705 | + ) ); |
|
| 1706 | 1706 | |
| 1707 | 1707 | if ( $load ) { |
| 1708 | 1708 | wp_enqueue_script( 'formidable_admin_global' ); |
| 1709 | 1709 | } |
| 1710 | - } |
|
| 1710 | + } |
|
| 1711 | 1711 | |
| 1712 | 1712 | /** |
| 1713 | 1713 | * @since 2.0.9 |
@@ -1716,9 +1716,9 @@ discard block |
||
| 1716 | 1716 | wp_enqueue_style( 'frm_fonts', self::plugin_url() . '/css/frm_fonts.css', array(), self::plugin_version() ); |
| 1717 | 1717 | } |
| 1718 | 1718 | |
| 1719 | - /** |
|
| 1720 | - * @param string $location |
|
| 1721 | - */ |
|
| 1719 | + /** |
|
| 1720 | + * @param string $location |
|
| 1721 | + */ |
|
| 1722 | 1722 | public static function localize_script( $location ) { |
| 1723 | 1723 | $ajax_url = admin_url( 'admin-ajax.php', is_ssl() ? 'admin' : 'http' ); |
| 1724 | 1724 | $ajax_url = apply_filters( 'frm_ajax_url', $ajax_url ); |
@@ -1770,81 +1770,81 @@ discard block |
||
| 1770 | 1770 | } |
| 1771 | 1771 | } |
| 1772 | 1772 | |
| 1773 | - /** |
|
| 1773 | + /** |
|
| 1774 | 1774 | * echo the message on the plugins listing page |
| 1775 | - * @since 1.07.10 |
|
| 1776 | - * |
|
| 1777 | - * @param float $min_version The version the add-on requires |
|
| 1778 | - */ |
|
| 1775 | + * @since 1.07.10 |
|
| 1776 | + * |
|
| 1777 | + * @param float $min_version The version the add-on requires |
|
| 1778 | + */ |
|
| 1779 | 1779 | public static function min_version_notice( $min_version ) { |
| 1780 | - $frm_version = self::plugin_version(); |
|
| 1780 | + $frm_version = self::plugin_version(); |
|
| 1781 | 1781 | |
| 1782 | - // check if Formidable meets minimum requirements |
|
| 1783 | - if ( version_compare($frm_version, $min_version, '>=') ) { |
|
| 1784 | - return; |
|
| 1785 | - } |
|
| 1782 | + // check if Formidable meets minimum requirements |
|
| 1783 | + if ( version_compare($frm_version, $min_version, '>=') ) { |
|
| 1784 | + return; |
|
| 1785 | + } |
|
| 1786 | 1786 | |
| 1787 | - $wp_list_table = _get_list_table('WP_Plugins_List_Table'); |
|
| 1787 | + $wp_list_table = _get_list_table('WP_Plugins_List_Table'); |
|
| 1788 | 1788 | echo '<tr class="plugin-update-tr active"><th colspan="' . absint( $wp_list_table->get_column_count() ) . '" class="check-column plugin-update colspanchange"><div class="update-message">' . |
| 1789 | - __( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) . |
|
| 1790 | - '</div></td></tr>'; |
|
| 1791 | - } |
|
| 1792 | - |
|
| 1793 | - public static function locales( $type = 'date' ) { |
|
| 1794 | - $locales = array( |
|
| 1795 | - 'en' => __( 'English', 'formidable' ), '' => __( 'English/Western', 'formidable' ), |
|
| 1796 | - 'af' => __( 'Afrikaans', 'formidable' ), 'sq' => __( 'Albanian', 'formidable' ), |
|
| 1797 | - 'ar' => __( 'Arabic', 'formidable' ), 'hy' => __( 'Armenian', 'formidable' ), |
|
| 1798 | - 'az' => __( 'Azerbaijani', 'formidable' ), 'eu' => __( 'Basque', 'formidable' ), |
|
| 1799 | - 'bs' => __( 'Bosnian', 'formidable' ), 'bg' => __( 'Bulgarian', 'formidable' ), |
|
| 1800 | - 'ca' => __( 'Catalan', 'formidable' ), 'zh-HK' => __( 'Chinese Hong Kong', 'formidable' ), |
|
| 1801 | - 'zh-CN' => __( 'Chinese Simplified', 'formidable' ), 'zh-TW' => __( 'Chinese Traditional', 'formidable' ), |
|
| 1802 | - 'hr' => __( 'Croatian', 'formidable' ), 'cs' => __( 'Czech', 'formidable' ), |
|
| 1803 | - 'da' => __( 'Danish', 'formidable' ), 'nl' => __( 'Dutch', 'formidable' ), |
|
| 1804 | - 'en-GB' => __( 'English/UK', 'formidable' ), 'eo' => __( 'Esperanto', 'formidable' ), |
|
| 1805 | - 'et' => __( 'Estonian', 'formidable' ), 'fo' => __( 'Faroese', 'formidable' ), |
|
| 1806 | - 'fa' => __( 'Farsi/Persian', 'formidable' ), 'fil' => __( 'Filipino', 'formidable' ), |
|
| 1807 | - 'fi' => __( 'Finnish', 'formidable' ), 'fr' => __( 'French', 'formidable' ), |
|
| 1808 | - 'fr-CA' => __( 'French/Canadian', 'formidable' ), 'fr-CH' => __( 'French/Swiss', 'formidable' ), |
|
| 1809 | - 'de' => __( 'German', 'formidable' ), 'de-AT' => __( 'German/Austria', 'formidable' ), |
|
| 1810 | - 'de-CH' => __( 'German/Switzerland', 'formidable' ), 'el' => __( 'Greek', 'formidable' ), |
|
| 1811 | - 'he' => __( 'Hebrew', 'formidable' ), 'iw' => __( 'Hebrew', 'formidable' ), |
|
| 1812 | - 'hi' => __( 'Hindi', 'formidable' ), 'hu' => __( 'Hungarian', 'formidable' ), |
|
| 1813 | - 'is' => __( 'Icelandic', 'formidable' ), 'id' => __( 'Indonesian', 'formidable' ), |
|
| 1814 | - 'it' => __( 'Italian', 'formidable' ), 'ja' => __( 'Japanese', 'formidable' ), |
|
| 1815 | - 'ko' => __( 'Korean', 'formidable' ), 'lv' => __( 'Latvian', 'formidable' ), |
|
| 1816 | - 'lt' => __( 'Lithuanian', 'formidable' ), 'ms' => __( 'Malaysian', 'formidable' ), |
|
| 1817 | - 'no' => __( 'Norwegian', 'formidable' ), 'pl' => __( 'Polish', 'formidable' ), |
|
| 1818 | - 'pt' => __( 'Portuguese', 'formidable' ), 'pt-BR' => __( 'Portuguese/Brazilian', 'formidable' ), |
|
| 1819 | - 'pt-PT' => __( 'Portuguese/Portugal', 'formidable' ), 'ro' => __( 'Romanian', 'formidable' ), |
|
| 1820 | - 'ru' => __( 'Russian', 'formidable' ), 'sr' => __( 'Serbian', 'formidable' ), |
|
| 1821 | - 'sr-SR' => __( 'Serbian', 'formidable' ), 'sk' => __( 'Slovak', 'formidable' ), |
|
| 1822 | - 'sl' => __( 'Slovenian', 'formidable' ), 'es' => __( 'Spanish', 'formidable' ), |
|
| 1823 | - 'es-419' => __( 'Spanish/Latin America', 'formidable' ), 'sv' => __( 'Swedish', 'formidable' ), |
|
| 1824 | - 'ta' => __( 'Tamil', 'formidable' ), 'th' => __( 'Thai', 'formidable' ), |
|
| 1825 | - 'tu' => __( 'Turkish', 'formidable' ), 'tr' => __( 'Turkish', 'formidable' ), |
|
| 1826 | - 'uk' => __( 'Ukranian', 'formidable' ), 'vi' => __( 'Vietnamese', 'formidable' ), |
|
| 1827 | - ); |
|
| 1828 | - |
|
| 1829 | - if ( $type == 'captcha' ) { |
|
| 1830 | - // remove the languages unavailable for the captcha |
|
| 1831 | - $unset = array( |
|
| 1832 | - '', 'af', 'sq', 'hy', 'az', 'eu', 'bs', |
|
| 1833 | - 'zh-HK', 'eo', 'et', 'fo', 'fr-CH', |
|
| 1834 | - 'he', 'is', 'ms', 'sr-SR', 'ta', 'tu', |
|
| 1835 | - ); |
|
| 1836 | - } else { |
|
| 1837 | - // remove the languages unavailable for the datepicker |
|
| 1838 | - $unset = array( |
|
| 1839 | - 'en', 'fil', 'fr-CA', 'de-AT', 'de-AT', |
|
| 1840 | - 'de-CH', 'iw', 'hi', 'pt', 'pt-PT', |
|
| 1841 | - 'es-419', 'tr', |
|
| 1842 | - ); |
|
| 1843 | - } |
|
| 1844 | - |
|
| 1845 | - $locales = array_diff_key($locales, array_flip($unset)); |
|
| 1846 | - $locales = apply_filters('frm_locales', $locales); |
|
| 1847 | - |
|
| 1848 | - return $locales; |
|
| 1849 | - } |
|
| 1789 | + __( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) . |
|
| 1790 | + '</div></td></tr>'; |
|
| 1791 | + } |
|
| 1792 | + |
|
| 1793 | + public static function locales( $type = 'date' ) { |
|
| 1794 | + $locales = array( |
|
| 1795 | + 'en' => __( 'English', 'formidable' ), '' => __( 'English/Western', 'formidable' ), |
|
| 1796 | + 'af' => __( 'Afrikaans', 'formidable' ), 'sq' => __( 'Albanian', 'formidable' ), |
|
| 1797 | + 'ar' => __( 'Arabic', 'formidable' ), 'hy' => __( 'Armenian', 'formidable' ), |
|
| 1798 | + 'az' => __( 'Azerbaijani', 'formidable' ), 'eu' => __( 'Basque', 'formidable' ), |
|
| 1799 | + 'bs' => __( 'Bosnian', 'formidable' ), 'bg' => __( 'Bulgarian', 'formidable' ), |
|
| 1800 | + 'ca' => __( 'Catalan', 'formidable' ), 'zh-HK' => __( 'Chinese Hong Kong', 'formidable' ), |
|
| 1801 | + 'zh-CN' => __( 'Chinese Simplified', 'formidable' ), 'zh-TW' => __( 'Chinese Traditional', 'formidable' ), |
|
| 1802 | + 'hr' => __( 'Croatian', 'formidable' ), 'cs' => __( 'Czech', 'formidable' ), |
|
| 1803 | + 'da' => __( 'Danish', 'formidable' ), 'nl' => __( 'Dutch', 'formidable' ), |
|
| 1804 | + 'en-GB' => __( 'English/UK', 'formidable' ), 'eo' => __( 'Esperanto', 'formidable' ), |
|
| 1805 | + 'et' => __( 'Estonian', 'formidable' ), 'fo' => __( 'Faroese', 'formidable' ), |
|
| 1806 | + 'fa' => __( 'Farsi/Persian', 'formidable' ), 'fil' => __( 'Filipino', 'formidable' ), |
|
| 1807 | + 'fi' => __( 'Finnish', 'formidable' ), 'fr' => __( 'French', 'formidable' ), |
|
| 1808 | + 'fr-CA' => __( 'French/Canadian', 'formidable' ), 'fr-CH' => __( 'French/Swiss', 'formidable' ), |
|
| 1809 | + 'de' => __( 'German', 'formidable' ), 'de-AT' => __( 'German/Austria', 'formidable' ), |
|
| 1810 | + 'de-CH' => __( 'German/Switzerland', 'formidable' ), 'el' => __( 'Greek', 'formidable' ), |
|
| 1811 | + 'he' => __( 'Hebrew', 'formidable' ), 'iw' => __( 'Hebrew', 'formidable' ), |
|
| 1812 | + 'hi' => __( 'Hindi', 'formidable' ), 'hu' => __( 'Hungarian', 'formidable' ), |
|
| 1813 | + 'is' => __( 'Icelandic', 'formidable' ), 'id' => __( 'Indonesian', 'formidable' ), |
|
| 1814 | + 'it' => __( 'Italian', 'formidable' ), 'ja' => __( 'Japanese', 'formidable' ), |
|
| 1815 | + 'ko' => __( 'Korean', 'formidable' ), 'lv' => __( 'Latvian', 'formidable' ), |
|
| 1816 | + 'lt' => __( 'Lithuanian', 'formidable' ), 'ms' => __( 'Malaysian', 'formidable' ), |
|
| 1817 | + 'no' => __( 'Norwegian', 'formidable' ), 'pl' => __( 'Polish', 'formidable' ), |
|
| 1818 | + 'pt' => __( 'Portuguese', 'formidable' ), 'pt-BR' => __( 'Portuguese/Brazilian', 'formidable' ), |
|
| 1819 | + 'pt-PT' => __( 'Portuguese/Portugal', 'formidable' ), 'ro' => __( 'Romanian', 'formidable' ), |
|
| 1820 | + 'ru' => __( 'Russian', 'formidable' ), 'sr' => __( 'Serbian', 'formidable' ), |
|
| 1821 | + 'sr-SR' => __( 'Serbian', 'formidable' ), 'sk' => __( 'Slovak', 'formidable' ), |
|
| 1822 | + 'sl' => __( 'Slovenian', 'formidable' ), 'es' => __( 'Spanish', 'formidable' ), |
|
| 1823 | + 'es-419' => __( 'Spanish/Latin America', 'formidable' ), 'sv' => __( 'Swedish', 'formidable' ), |
|
| 1824 | + 'ta' => __( 'Tamil', 'formidable' ), 'th' => __( 'Thai', 'formidable' ), |
|
| 1825 | + 'tu' => __( 'Turkish', 'formidable' ), 'tr' => __( 'Turkish', 'formidable' ), |
|
| 1826 | + 'uk' => __( 'Ukranian', 'formidable' ), 'vi' => __( 'Vietnamese', 'formidable' ), |
|
| 1827 | + ); |
|
| 1828 | + |
|
| 1829 | + if ( $type == 'captcha' ) { |
|
| 1830 | + // remove the languages unavailable for the captcha |
|
| 1831 | + $unset = array( |
|
| 1832 | + '', 'af', 'sq', 'hy', 'az', 'eu', 'bs', |
|
| 1833 | + 'zh-HK', 'eo', 'et', 'fo', 'fr-CH', |
|
| 1834 | + 'he', 'is', 'ms', 'sr-SR', 'ta', 'tu', |
|
| 1835 | + ); |
|
| 1836 | + } else { |
|
| 1837 | + // remove the languages unavailable for the datepicker |
|
| 1838 | + $unset = array( |
|
| 1839 | + 'en', 'fil', 'fr-CA', 'de-AT', 'de-AT', |
|
| 1840 | + 'de-CH', 'iw', 'hi', 'pt', 'pt-PT', |
|
| 1841 | + 'es-419', 'tr', |
|
| 1842 | + ); |
|
| 1843 | + } |
|
| 1844 | + |
|
| 1845 | + $locales = array_diff_key($locales, array_flip($unset)); |
|
| 1846 | + $locales = apply_filters('frm_locales', $locales); |
|
| 1847 | + |
|
| 1848 | + return $locales; |
|
| 1849 | + } |
|
| 1850 | 1850 | } |