@@ -1,11 +1,11 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | $display = apply_filters('frm_display_field_options', array( |
| 4 | - 'type' => $field['type'], 'field_data' => $field, |
|
| 5 | - 'required' => true, 'unique' => false, 'read_only' => false, |
|
| 6 | - 'description' => true, 'options' => true, 'label_position' => true, |
|
| 7 | - 'invalid' => false, 'size' => false, 'clear_on_focus' => false, |
|
| 8 | - 'default_blank' => true, 'css' => true, 'conf_field' => false, |
|
| 4 | + 'type' => $field['type'], 'field_data' => $field, |
|
| 5 | + 'required' => true, 'unique' => false, 'read_only' => false, |
|
| 6 | + 'description' => true, 'options' => true, 'label_position' => true, |
|
| 7 | + 'invalid' => false, 'size' => false, 'clear_on_focus' => false, |
|
| 8 | + 'default_blank' => true, 'css' => true, 'conf_field' => false, |
|
| 9 | 9 | 'max' => true, 'captcha_size' => false, |
| 10 | 10 | )); |
| 11 | 11 | |
@@ -25,19 +25,19 @@ discard block |
||
| 25 | 25 | $frm_settings = FrmAppHelper::get_settings(); |
| 26 | 26 | |
| 27 | 27 | if ( ! isset( $frm_all_field_selection ) ) { |
| 28 | - if ( isset($frm_field_selection) && isset($pro_field_selection) ) { |
|
| 29 | - $frm_all_field_selection = array_merge($frm_field_selection, $pro_field_selection); |
|
| 30 | - } else { |
|
| 28 | + if ( isset($frm_field_selection) && isset($pro_field_selection) ) { |
|
| 29 | + $frm_all_field_selection = array_merge($frm_field_selection, $pro_field_selection); |
|
| 30 | + } else { |
|
| 31 | 31 | $pro_field_selection = FrmField::pro_field_selection(); |
| 32 | 32 | $frm_all_field_selection = array_merge( FrmField::field_selection(), $pro_field_selection ); |
| 33 | - } |
|
| 33 | + } |
|
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | $disabled_fields = FrmAppHelper::pro_is_installed() ? array() : $pro_field_selection; |
| 37 | 37 | |
| 38 | 38 | |
| 39 | 39 | if ( ! isset( $ajax ) ) { |
| 40 | - $li_classes .= ' ui-state-default widgets-holder-wrap'; ?> |
|
| 40 | + $li_classes .= ' ui-state-default widgets-holder-wrap'; ?> |
|
| 41 | 41 | <li id="frm_field_id_<?php echo esc_attr( $field['id'] ); ?>" class="<?php echo esc_attr( $li_classes ) ?>" data-fid="<?php echo esc_attr( $field['id'] ) ?>" data-formid="<?php echo ( 'divider' == $field['type'] ) ? esc_attr( $field['form_select'] ) : esc_attr( $field['form_id'] ); ?>"> |
| 42 | 42 | <?php |
| 43 | 43 | } |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | </span> |
| 60 | 60 | <?php } |
| 61 | 61 | |
| 62 | - ?> |
|
| 62 | + ?> |
|
| 63 | 63 | <label class="<?php echo ( $field['type'] == 'end_divider' ) ? '' : 'frm_ipe_field_label'; ?> frm_primary_label <?php echo ( $field['type'] == 'break' ) ? 'button': ''; ?>" id="field_label_<?php echo esc_attr( $field['id'] ); ?>"><?php echo ( $field['name'] == '' ) ? __( '(no label)', 'formidable' ) : force_balance_tags( $field['name'] ); ?></label> |
| 64 | 64 | |
| 65 | 65 | |
@@ -105,8 +105,8 @@ discard block |
||
| 105 | 105 | if ( in_array( $field['type'], array( 'select', 'radio', 'checkbox' ) ) ) { ?> |
| 106 | 106 | <div class="frm-show-click frm_small_top_margin"><?php |
| 107 | 107 | |
| 108 | - if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) { |
|
| 109 | - echo '<p class="howto">'. FrmFieldsHelper::get_term_link($field['taxonomy']) .'</p>'; |
|
| 108 | + if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) { |
|
| 109 | + echo '<p class="howto">'. FrmFieldsHelper::get_term_link($field['taxonomy']) .'</p>'; |
|
| 110 | 110 | } else if ( ! isset( $field['post_field'] ) || ! in_array( $field['post_field'], array( 'post_category' ) ) ) { |
| 111 | 111 | ?> |
| 112 | 112 | <div id="frm_add_field_<?php echo esc_attr( $field['id'] ); ?>"> |
@@ -117,14 +117,14 @@ discard block |
||
| 117 | 117 | <a href="javascript:void(0);" id="other_button_<?php echo esc_attr( $field['id'] ); ?>" data-opttype="other" data-ftype="<?php echo esc_attr( $field['type'] ) ?>" class="button frm_cb_button frm_add_opt<?php echo ( in_array( $field['type'], array( 'radio', 'select' ) ) && $field['other'] == true ? ' frm_hidden' : '' ); ?>"><?php _e( 'Add "Other"', 'formidable' ) ?></a> |
| 118 | 118 | <input type="hidden" value="<?php echo esc_attr( $field['other'] ); ?>" id="other_input_<?php echo esc_attr( $field['id'] ); ?>" name="field_options[other_<?php echo esc_attr( $field['id'] ); ?>]"> |
| 119 | 119 | <?php |
| 120 | - } |
|
| 120 | + } |
|
| 121 | 121 | |
| 122 | - if ( ! isset($field['post_field']) || $field['post_field'] != 'post_category' ) { ?> |
|
| 122 | + if ( ! isset($field['post_field']) || $field['post_field'] != 'post_category' ) { ?> |
|
| 123 | 123 | <a href="<?php echo esc_url(admin_url('admin-ajax.php') .'?action=frm_import_choices&field_id='. $field['id'] .'&TB_iframe=1') ?>" title="<?php echo FrmAppHelper::truncate(esc_attr(strip_tags(str_replace('"', '"', $field['name']))), 20) . ' '. __( 'Field Choices', 'formidable' ); ?>" class="thickbox frm_orange"><?php _e( 'Bulk Edit Options', 'formidable' ) ?></a> |
| 124 | 124 | <?php } ?> |
| 125 | 125 | </div> |
| 126 | 126 | <?php |
| 127 | - } |
|
| 127 | + } |
|
| 128 | 128 | ?> |
| 129 | 129 | </div> |
| 130 | 130 | <?php |
@@ -156,28 +156,28 @@ discard block |
||
| 156 | 156 | if ( $display['required'] ) { ?> |
| 157 | 157 | <label for="frm_req_field_<?php echo esc_attr( $field['id'] ) ?>" class="frm_inline_label"><input type="checkbox" id="frm_req_field_<?php echo esc_attr( $field['id'] ) ?>" class="frm_req_field" name="field_options[required_<?php echo esc_attr( $field['id'] ) ?>]" value="1" <?php echo $field['required'] ? 'checked="checked"': ''; ?> /> <?php _e( 'Required', 'formidable' ) ?></label> |
| 158 | 158 | <?php |
| 159 | - } |
|
| 159 | + } |
|
| 160 | 160 | |
| 161 | 161 | if ( $display['unique'] ) { |
| 162 | - if ( ! isset( $field['unique'] ) ) { |
|
| 163 | - $field['unique'] = false; |
|
| 164 | - } |
|
| 165 | - ?> |
|
| 162 | + if ( ! isset( $field['unique'] ) ) { |
|
| 163 | + $field['unique'] = false; |
|
| 164 | + } |
|
| 165 | + ?> |
|
| 166 | 166 | <label for="frm_uniq_field_<?php echo esc_attr( $field['id'] ) ?>" class="frm_inline_label frm_help" title="<?php esc_attr_e( 'Unique: Do not allow the same response multiple times. For example, if one user enters \'Joe\', then no one else will be allowed to enter the same name.', 'formidable' ) ?>"><input type="checkbox" name="field_options[unique_<?php echo esc_attr( $field['id'] ) ?>]" id="frm_uniq_field_<?php echo esc_attr( $field['id'] ) ?>" value="1" <?php checked( $field['unique'], 1 ); ?> class="frm_mark_unique" /> <?php _e( 'Unique', 'formidable' ) ?></label> |
| 167 | 167 | <?php |
| 168 | - } |
|
| 168 | + } |
|
| 169 | 169 | |
| 170 | 170 | if ( $display['read_only'] ) { |
| 171 | - if ( ! isset( $field['read_only'] ) ) { |
|
| 172 | - $field['read_only'] = false; |
|
| 171 | + if ( ! isset( $field['read_only'] ) ) { |
|
| 172 | + $field['read_only'] = false; |
|
| 173 | 173 | } |
| 174 | - ?> |
|
| 174 | + ?> |
|
| 175 | 175 | <label for="frm_read_only_field_<?php echo esc_attr( $field['id'] ) ?>" class="frm_inline_label frm_help" title="<?php esc_attr_e( 'Read Only: Show this field but do not allow the field value to be edited from the front-end.', 'formidable' ) ?>" ><input type="checkbox" id="frm_read_only_field_<?php echo esc_attr( $field['id'] ) ?>" name="field_options[read_only_<?php echo esc_attr( $field['id'] ) ?>]" value="1" <?php echo $field['read_only'] ? ' checked="checked"' : ''; ?>/> <?php _e( 'Read Only', 'formidable' ) ?></label> |
| 176 | 176 | <?php } |
| 177 | 177 | |
| 178 | - do_action('frm_field_options_form_top', $field, $display, $values); |
|
| 178 | + do_action('frm_field_options_form_top', $field, $display, $values); |
|
| 179 | 179 | |
| 180 | - ?> |
|
| 180 | + ?> |
|
| 181 | 181 | <?php |
| 182 | 182 | if ( $display['required'] ) { ?> |
| 183 | 183 | <div class="frm_required_details<?php echo esc_attr( $field['id'] . ( $field['required'] ? '' : ' frm_hidden' ) ); ?>"> |
@@ -233,14 +233,14 @@ discard block |
||
| 233 | 233 | <?php _e( 'automatic width', 'formidable' ) ?> |
| 234 | 234 | </label> |
| 235 | 235 | <?php |
| 236 | - } |
|
| 236 | + } |
|
| 237 | 237 | } else { ?> |
| 238 | 238 | <input type="text" name="field_options[size_<?php echo esc_attr( $field['id'] ) ?>]" value="<?php echo esc_attr( $field['size'] ); ?>" size="5" /> <span class="howto"><?php _e( 'pixels wide', 'formidable' ) ?></span> |
| 239 | 239 | |
| 240 | 240 | <?php if ( $display['max'] ) { ?> |
| 241 | 241 | <input type="text" name="field_options[max_<?php echo esc_attr( $field['id'] ) ?>]" value="<?php echo esc_attr( $field['max'] ); ?>" size="5" /> <span class="howto"><?php echo ( $field['type'] == 'textarea' || $field['type'] == 'rte' ) ? __( 'rows high', 'formidable' ) : __( 'characters maximum', 'formidable' ) ?></span> |
| 242 | 242 | <?php } |
| 243 | - } ?> |
|
| 243 | + } ?> |
|
| 244 | 244 | </td> |
| 245 | 245 | </tr> |
| 246 | 246 | <?php } |
@@ -258,7 +258,7 @@ discard block |
||
| 258 | 258 | } ?> |
| 259 | 259 | <?php do_action('frm_field_options_form', $field, $display, $values); |
| 260 | 260 | |
| 261 | - if ( $display['required'] || $display['invalid'] || $display['unique'] || $display['conf_field'] ) { ?> |
|
| 261 | + if ( $display['required'] || $display['invalid'] || $display['unique'] || $display['conf_field'] ) { ?> |
|
| 262 | 262 | <tr class="frm_validation_msg <?php echo ($display['invalid'] || $field['required'] || FrmField::is_option_true( $field, 'unique' ) || FrmField::is_option_true( $field, 'conf_field' ) ) ? '' : 'frm_hidden'; ?>"> |
| 263 | 263 | <td colspan="2"> |
| 264 | 264 | <div class="menu-settings"> |
@@ -271,7 +271,7 @@ discard block |
||
| 271 | 271 | <input type="text" name="field_options[blank_<?php echo esc_attr( $field['id'] ) ?>]" value="<?php echo esc_attr( $field['blank'] ); ?>" /> |
| 272 | 272 | </p> |
| 273 | 273 | <?php |
| 274 | - } |
|
| 274 | + } |
|
| 275 | 275 | |
| 276 | 276 | if ( $display['invalid'] ) { ?> |
| 277 | 277 | <p><label><?php _e( 'Invalid Format', 'formidable' ) ?></label> |
@@ -286,7 +286,7 @@ discard block |
||
| 286 | 286 | <input type="text" name="field_options[unique_msg_<?php echo esc_attr( $field['id'] ) ?>]" value="<?php echo esc_attr( $field['unique_msg'] ); ?>" /> |
| 287 | 287 | </p> |
| 288 | 288 | <?php |
| 289 | - } |
|
| 289 | + } |
|
| 290 | 290 | |
| 291 | 291 | if ( $display['conf_field'] ) { ?> |
| 292 | 292 | <p class="frm_conf_details<?php echo esc_attr( $field['id'] . ( $field['conf_field'] ? '' : ' frm_hidden' ) ); ?>"> |
@@ -294,7 +294,7 @@ discard block |
||
| 294 | 294 | <input type="text" name="field_options[conf_msg_<?php echo esc_attr( $field['id'] ) ?>]" value="<?php echo esc_attr( $field['conf_msg'] ); ?>" /> |
| 295 | 295 | </p> |
| 296 | 296 | <?php |
| 297 | - } ?> |
|
| 297 | + } ?> |
|
| 298 | 298 | </div> |
| 299 | 299 | </div> |
| 300 | 300 | </td> |
@@ -1,22 +1,22 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -$display = apply_filters('frm_display_field_options', array( |
|
| 3 | +$display = apply_filters( 'frm_display_field_options', array( |
|
| 4 | 4 | 'type' => $field['type'], 'field_data' => $field, |
| 5 | 5 | 'required' => true, 'unique' => false, 'read_only' => false, |
| 6 | 6 | 'description' => true, 'options' => true, 'label_position' => true, |
| 7 | 7 | 'invalid' => false, 'size' => false, 'clear_on_focus' => false, |
| 8 | 8 | 'default_blank' => true, 'css' => true, 'conf_field' => false, |
| 9 | 9 | 'max' => true, 'captcha_size' => false, |
| 10 | -)); |
|
| 10 | +) ); |
|
| 11 | 11 | |
| 12 | -$li_classes = 'form-field edit_form_item frm_field_box frm_top_container frm_not_divider edit_field_type_'. $display['type']; |
|
| 13 | -$li_classes = apply_filters('frm_build_field_class', $li_classes, $field ); |
|
| 12 | +$li_classes = 'form-field edit_form_item frm_field_box frm_top_container frm_not_divider edit_field_type_' . $display['type']; |
|
| 13 | +$li_classes = apply_filters( 'frm_build_field_class', $li_classes, $field ); |
|
| 14 | 14 | |
| 15 | 15 | if ( isset( $values ) && isset( $values['ajax_load'] ) && $values['ajax_load'] && isset( $count ) && $count > 10 && ! in_array( $field['type'], array( 'divider', 'end_divider' ) ) ) { |
| 16 | 16 | ?> |
| 17 | 17 | <li id="frm_field_id_<?php echo esc_attr( $field['id'] ); ?>" class="<?php echo esc_attr( $li_classes ) ?> frm_field_loading" data-fid="<?php echo esc_attr( $field['id'] ) ?>" data-formid="<?php echo esc_attr( 'divider' == $field['type'] ? $field['form_select'] : $field['form_id'] ); ?>" data-ftype="<?php echo esc_attr( $display['type'] ) ?>"> |
| 18 | 18 | <img src="<?php echo FrmAppHelper::plugin_url() ?>/images/ajax_loader.gif" alt="<?php esc_attr_e( 'Loading', 'formidable' ) ?>" /> |
| 19 | -<span class="frm_hidden_fdata frm_hidden"><?php echo htmlspecialchars(json_encode($field)) ?></span> |
|
| 19 | +<span class="frm_hidden_fdata frm_hidden"><?php echo htmlspecialchars( json_encode( $field ) ) ?></span> |
|
| 20 | 20 | </li> |
| 21 | 21 | <?php |
| 22 | 22 | return; |
@@ -25,8 +25,8 @@ discard block |
||
| 25 | 25 | $frm_settings = FrmAppHelper::get_settings(); |
| 26 | 26 | |
| 27 | 27 | if ( ! isset( $frm_all_field_selection ) ) { |
| 28 | - if ( isset($frm_field_selection) && isset($pro_field_selection) ) { |
|
| 29 | - $frm_all_field_selection = array_merge($frm_field_selection, $pro_field_selection); |
|
| 28 | + if ( isset( $frm_field_selection ) && isset( $pro_field_selection ) ) { |
|
| 29 | + $frm_all_field_selection = array_merge( $frm_field_selection, $pro_field_selection ); |
|
| 30 | 30 | } else { |
| 31 | 31 | $pro_field_selection = FrmField::pro_field_selection(); |
| 32 | 32 | $frm_all_field_selection = array_merge( FrmField::field_selection(), $pro_field_selection ); |
@@ -51,8 +51,8 @@ discard block |
||
| 51 | 51 | <a href="javascript:void(0);" class="frm_bstooltip alignright frm-show-hover frm-move frm-hover-icon frm_icon_font frm_move_icon" title="<?php esc_attr_e( 'Move Field', 'formidable' ) ?>"> </a> |
| 52 | 52 | <a href="#" class="frm_bstooltip alignright frm-show-hover frm-hover-icon frm_icon_font frm_delete_icon frm_delete_field" title="<?php esc_attr_e( 'Delete Field', 'formidable' ) ?>"> </a> |
| 53 | 53 | <a href="#" class="frm_bstooltip alignright frm-show-hover frm-hover-icon frm_icon_font frm_duplicate_icon" title="<?php ( $field['type'] == 'divider' ) ? esc_attr_e( 'Duplicate Section', 'formidable' ) : esc_attr_e( 'Duplicate Field', 'formidable' ) ?>"> </a> |
| 54 | - <input type="hidden" name="frm_fields_submitted[]" value="<?php echo esc_attr($field['id']) ?>" /> |
|
| 55 | - <?php do_action('frm_extra_field_actions', $field['id']); ?> |
|
| 54 | + <input type="hidden" name="frm_fields_submitted[]" value="<?php echo esc_attr( $field['id'] ) ?>" /> |
|
| 55 | + <?php do_action( 'frm_extra_field_actions', $field['id'] ); ?> |
|
| 56 | 56 | <?php if ( $display['required'] ) { ?> |
| 57 | 57 | <span id="require_field_<?php echo esc_attr( $field['id'] ); ?>"> |
| 58 | 58 | <a href="javascript:void(0);" class="frm_req_field frm_action_icon frm_required_icon frm_icon_font alignleft frm_required<?php echo (int) $field['required'] ?>" id="req_field_<?php echo esc_attr( $field['id'] ); ?>" title="Click to Mark as <?php echo FrmField::is_required( $field ) ? 'not ' : ''; ?>Required"></a> |
@@ -60,13 +60,13 @@ discard block |
||
| 60 | 60 | <?php } |
| 61 | 61 | |
| 62 | 62 | ?> |
| 63 | - <label class="<?php echo ( $field['type'] == 'end_divider' ) ? '' : 'frm_ipe_field_label'; ?> frm_primary_label <?php echo ( $field['type'] == 'break' ) ? 'button': ''; ?>" id="field_label_<?php echo esc_attr( $field['id'] ); ?>"><?php echo ( $field['name'] == '' ) ? __( '(no label)', 'formidable' ) : force_balance_tags( $field['name'] ); ?></label> |
|
| 63 | + <label class="<?php echo ( $field['type'] == 'end_divider' ) ? '' : 'frm_ipe_field_label'; ?> frm_primary_label <?php echo ( $field['type'] == 'break' ) ? 'button' : ''; ?>" id="field_label_<?php echo esc_attr( $field['id'] ); ?>"><?php echo ( $field['name'] == '' ) ? __( '(no label)', 'formidable' ) : force_balance_tags( $field['name'] ); ?></label> |
|
| 64 | 64 | |
| 65 | 65 | |
| 66 | 66 | <div id="field_<?php echo esc_attr( $field['id'] ) ?>_inner_container" class="frm_inner_field_container"> |
| 67 | 67 | <div class="frm_form_fields" data-ftype="<?php echo esc_attr( $display['type'] ) ?>"> |
| 68 | 68 | <?php |
| 69 | -include(FrmAppHelper::plugin_path() .'/classes/views/frm-fields/show-build.php'); |
|
| 69 | +include( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/show-build.php' ); |
|
| 70 | 70 | |
| 71 | 71 | if ( $display['clear_on_focus'] ) { |
| 72 | 72 | FrmFieldsHelper::clear_on_focus_html( $field, $display ); |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | </div> |
| 79 | 79 | <?php |
| 80 | 80 | if ( $display['description'] ) { ?> |
| 81 | - <div class="frm_ipe_field_desc description <?php echo ($field['description'] == '') ? 'frm-show-click' : '' ?>" id="field_description_<?php echo esc_attr( $field['id'] ); ?>"><?php echo ($field['description'] == '') ? __( '(Click to add description)', 'formidable' ) : force_balance_tags( $field['description'] ); ?></div> |
|
| 81 | + <div class="frm_ipe_field_desc description <?php echo ( $field['description'] == '' ) ? 'frm-show-click' : '' ?>" id="field_description_<?php echo esc_attr( $field['id'] ); ?>"><?php echo ( $field['description'] == '' ) ? __( '(Click to add description)', 'formidable' ) : force_balance_tags( $field['description'] ); ?></div> |
|
| 82 | 82 | <input type="hidden" name="field_options[description_<?php echo esc_attr( $field['id'] ) ?>]" value="<?php echo esc_attr( $field['description'] ); ?>" /> |
| 83 | 83 | |
| 84 | 84 | <?php } ?> |
@@ -88,9 +88,9 @@ discard block |
||
| 88 | 88 | <div id="frm_conf_field_<?php echo esc_attr( $field['id'] ) ?>_container" class="frm_conf_field_container frm_form_fields frm_conf_details<?php echo esc_attr( $field['id'] . ( $field['conf_field'] ? '' : ' frm_hidden' ) ); ?>"> |
| 89 | 89 | <div id="frm_conf_field_<?php echo esc_attr( $field['id'] ) ?>_inner_container" class="frm_inner_conf_container"> |
| 90 | 90 | <div class="frm_form_fields"> |
| 91 | - <input type="text" id="conf_field_<?php echo esc_attr( $field['field_key'] ) ?>" name="field_options[conf_input_<?php echo esc_attr( $field['id'] ) ?>]" value="<?php echo esc_attr( $field['conf_input'] ); ?>" <?php do_action('frm_field_input_html', $field) ?> /> |
|
| 91 | + <input type="text" id="conf_field_<?php echo esc_attr( $field['field_key'] ) ?>" name="field_options[conf_input_<?php echo esc_attr( $field['id'] ) ?>]" value="<?php echo esc_attr( $field['conf_input'] ); ?>" <?php do_action( 'frm_field_input_html', $field ) ?> /> |
|
| 92 | 92 | </div> |
| 93 | - <div class="frm_ipe_field_conf_desc description <?php echo ($field['conf_desc'] == '') ? 'frm-show-click' : '' ?>"><?php echo ($field['conf_desc'] == '') ? __( '(Click to add description)', 'formidable' ) : force_balance_tags($field['conf_desc']); ?></div> |
|
| 93 | + <div class="frm_ipe_field_conf_desc description <?php echo ( $field['conf_desc'] == '' ) ? 'frm-show-click' : '' ?>"><?php echo ( $field['conf_desc'] == '' ) ? __( '(Click to add description)', 'formidable' ) : force_balance_tags( $field['conf_desc'] ); ?></div> |
|
| 94 | 94 | <input type="hidden" name="field_options[conf_desc_<?php echo esc_attr( $field['id'] ) ?>]" value="<?php echo esc_attr( $field['conf_desc'] ); ?>" /> |
| 95 | 95 | </div> |
| 96 | 96 | <?php if ( $display['clear_on_focus'] ) { ?> |
@@ -105,8 +105,8 @@ discard block |
||
| 105 | 105 | if ( in_array( $field['type'], array( 'select', 'radio', 'checkbox' ) ) ) { ?> |
| 106 | 106 | <div class="frm-show-click frm_small_top_margin"><?php |
| 107 | 107 | |
| 108 | - if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) { |
|
| 109 | - echo '<p class="howto">'. FrmFieldsHelper::get_term_link($field['taxonomy']) .'</p>'; |
|
| 108 | + if ( isset( $field['post_field'] ) && $field['post_field'] == 'post_category' ) { |
|
| 109 | + echo '<p class="howto">' . FrmFieldsHelper::get_term_link( $field['taxonomy'] ) . '</p>'; |
|
| 110 | 110 | } else if ( ! isset( $field['post_field'] ) || ! in_array( $field['post_field'], array( 'post_category' ) ) ) { |
| 111 | 111 | ?> |
| 112 | 112 | <div id="frm_add_field_<?php echo esc_attr( $field['id'] ); ?>"> |
@@ -119,8 +119,8 @@ discard block |
||
| 119 | 119 | <?php |
| 120 | 120 | } |
| 121 | 121 | |
| 122 | - if ( ! isset($field['post_field']) || $field['post_field'] != 'post_category' ) { ?> |
|
| 123 | - <a href="<?php echo esc_url(admin_url('admin-ajax.php') .'?action=frm_import_choices&field_id='. $field['id'] .'&TB_iframe=1') ?>" title="<?php echo FrmAppHelper::truncate(esc_attr(strip_tags(str_replace('"', '"', $field['name']))), 20) . ' '. __( 'Field Choices', 'formidable' ); ?>" class="thickbox frm_orange"><?php _e( 'Bulk Edit Options', 'formidable' ) ?></a> |
|
| 122 | + if ( ! isset( $field['post_field'] ) || $field['post_field'] != 'post_category' ) { ?> |
|
| 123 | + <a href="<?php echo esc_url( admin_url( 'admin-ajax.php' ) . '?action=frm_import_choices&field_id=' . $field['id'] . '&TB_iframe=1' ) ?>" title="<?php echo FrmAppHelper::truncate( esc_attr( strip_tags( str_replace( '"', '"', $field['name'] ) ) ), 20 ) . ' ' . __( 'Field Choices', 'formidable' ); ?>" class="thickbox frm_orange"><?php _e( 'Bulk Edit Options', 'formidable' ) ?></a> |
|
| 124 | 124 | <?php } ?> |
| 125 | 125 | </div> |
| 126 | 126 | <?php |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | <?php |
| 131 | 131 | } |
| 132 | 132 | |
| 133 | -do_action('frm_before_field_options', $field); |
|
| 133 | +do_action( 'frm_before_field_options', $field ); |
|
| 134 | 134 | |
| 135 | 135 | if ( $display['options'] ) { ?> |
| 136 | 136 | <div class="widget"> |
@@ -140,13 +140,13 @@ discard block |
||
| 140 | 140 | </div> |
| 141 | 141 | <div class="widget-inside"> |
| 142 | 142 | <table class="form-table frm_clear_none"> |
| 143 | - <?php $field_types = FrmFieldsHelper::get_field_types($field['type']); ?> |
|
| 143 | + <?php $field_types = FrmFieldsHelper::get_field_types( $field['type'] ); ?> |
|
| 144 | 144 | <tr><td class="frm_150_width"><label><?php _e( 'Field Type', 'formidable' ) ?></label></td> |
| 145 | 145 | <td> |
| 146 | - <select <?php if ( count($field_types) == 1 ) { ?>disabled="disabled"<?php } else { ?>name="field_options[type_<?php echo esc_attr( $field['id'] ) ?>]"<?php } ?>> |
|
| 146 | + <select <?php if ( count( $field_types ) == 1 ) { ?>disabled="disabled"<?php } else { ?>name="field_options[type_<?php echo esc_attr( $field['id'] ) ?>]"<?php } ?>> |
|
| 147 | 147 | <?php |
| 148 | 148 | foreach ( $field_types as $fkey => $ftype ) { ?> |
| 149 | - <option value="<?php echo esc_attr( $fkey ) ?>" <?php echo ( $fkey == $field['type'] ) ? ' selected="selected"' : ''; ?> <?php echo array_key_exists($fkey, $disabled_fields ) ? 'disabled="disabled"' : ''; ?>><?php echo is_array($ftype) ? $ftype['name'] : $ftype ?> </option> |
|
| 149 | + <option value="<?php echo esc_attr( $fkey ) ?>" <?php echo ( $fkey == $field['type'] ) ? ' selected="selected"' : ''; ?> <?php echo array_key_exists( $fkey, $disabled_fields ) ? 'disabled="disabled"' : ''; ?>><?php echo is_array( $ftype ) ? $ftype['name'] : $ftype ?> </option> |
|
| 150 | 150 | <?php |
| 151 | 151 | unset( $fkey, $ftype ); |
| 152 | 152 | } ?> |
@@ -154,7 +154,7 @@ discard block |
||
| 154 | 154 | |
| 155 | 155 | <?php |
| 156 | 156 | if ( $display['required'] ) { ?> |
| 157 | - <label for="frm_req_field_<?php echo esc_attr( $field['id'] ) ?>" class="frm_inline_label"><input type="checkbox" id="frm_req_field_<?php echo esc_attr( $field['id'] ) ?>" class="frm_req_field" name="field_options[required_<?php echo esc_attr( $field['id'] ) ?>]" value="1" <?php echo $field['required'] ? 'checked="checked"': ''; ?> /> <?php _e( 'Required', 'formidable' ) ?></label> |
|
| 157 | + <label for="frm_req_field_<?php echo esc_attr( $field['id'] ) ?>" class="frm_inline_label"><input type="checkbox" id="frm_req_field_<?php echo esc_attr( $field['id'] ) ?>" class="frm_req_field" name="field_options[required_<?php echo esc_attr( $field['id'] ) ?>]" value="1" <?php echo $field['required'] ? 'checked="checked"' : ''; ?> /> <?php _e( 'Required', 'formidable' ) ?></label> |
|
| 158 | 158 | <?php |
| 159 | 159 | } |
| 160 | 160 | |
@@ -175,7 +175,7 @@ discard block |
||
| 175 | 175 | <label for="frm_read_only_field_<?php echo esc_attr( $field['id'] ) ?>" class="frm_inline_label frm_help" title="<?php esc_attr_e( 'Read Only: Show this field but do not allow the field value to be edited from the front-end.', 'formidable' ) ?>" ><input type="checkbox" id="frm_read_only_field_<?php echo esc_attr( $field['id'] ) ?>" name="field_options[read_only_<?php echo esc_attr( $field['id'] ) ?>]" value="1" <?php echo $field['read_only'] ? ' checked="checked"' : ''; ?>/> <?php _e( 'Read Only', 'formidable' ) ?></label> |
| 176 | 176 | <?php } |
| 177 | 177 | |
| 178 | - do_action('frm_field_options_form_top', $field, $display, $values); |
|
| 178 | + do_action( 'frm_field_options_form_top', $field, $display, $values ); |
|
| 179 | 179 | |
| 180 | 180 | ?> |
| 181 | 181 | <?php |
@@ -211,13 +211,13 @@ discard block |
||
| 211 | 211 | if ( $display['label_position'] ) { ?> |
| 212 | 212 | <tr><td class="frm_150_width"><label><?php _e( 'Label Position', 'formidable' ) ?></label></td> |
| 213 | 213 | <td><select name="field_options[label_<?php echo esc_attr( $field['id'] ) ?>]"> |
| 214 | - <option value=""<?php selected($field['label'], ''); ?>><?php _e( 'Default', 'formidable' ) ?></option> |
|
| 215 | - <option value="top"<?php selected($field['label'], 'top'); ?>><?php _e( 'Top', 'formidable' ) ?></option> |
|
| 216 | - <option value="left"<?php selected($field['label'], 'left'); ?>><?php _e( 'Left', 'formidable' ) ?></option> |
|
| 217 | - <option value="right"<?php selected($field['label'], 'right'); ?>><?php _e( 'Right', 'formidable' ) ?></option> |
|
| 218 | - <option value="inline"<?php selected($field['label'], 'inline'); ?>><?php _e( 'Inline (left without a set width)', 'formidable' ) ?></option> |
|
| 219 | - <option value="none"<?php selected($field['label'], 'none'); ?>><?php _e( 'None', 'formidable' ) ?></option> |
|
| 220 | - <option value="hidden"<?php selected($field['label'], 'hidden'); ?>><?php _e( 'Hidden (but leave the space)', 'formidable' ) ?></option> |
|
| 214 | + <option value=""<?php selected( $field['label'], '' ); ?>><?php _e( 'Default', 'formidable' ) ?></option> |
|
| 215 | + <option value="top"<?php selected( $field['label'], 'top' ); ?>><?php _e( 'Top', 'formidable' ) ?></option> |
|
| 216 | + <option value="left"<?php selected( $field['label'], 'left' ); ?>><?php _e( 'Left', 'formidable' ) ?></option> |
|
| 217 | + <option value="right"<?php selected( $field['label'], 'right' ); ?>><?php _e( 'Right', 'formidable' ) ?></option> |
|
| 218 | + <option value="inline"<?php selected( $field['label'], 'inline' ); ?>><?php _e( 'Inline (left without a set width)', 'formidable' ) ?></option> |
|
| 219 | + <option value="none"<?php selected( $field['label'], 'none' ); ?>><?php _e( 'None', 'formidable' ) ?></option> |
|
| 220 | + <option value="hidden"<?php selected( $field['label'], 'hidden' ); ?>><?php _e( 'Hidden (but leave the space)', 'formidable' ) ?></option> |
|
| 221 | 221 | </select> |
| 222 | 222 | </td> |
| 223 | 223 | </tr> |
@@ -249,17 +249,17 @@ discard block |
||
| 249 | 249 | <span class="frm_help frm_icon_font frm_tooltip_icon" title="<?php esc_attr_e( 'Set the size of the captcha field. The compact option is best if your form is in a small area.', 'formidable' ) ?>" ></span> |
| 250 | 250 | </td> |
| 251 | 251 | <td><select name="field_options[captcha_size_<?php echo esc_attr( $field['id'] ) ?>]"> |
| 252 | - <option value="default"<?php selected($field['captcha_size'], 'default'); ?>><?php _e( 'Default', 'formidable' ) ?></option> |
|
| 253 | - <option value="compact"<?php selected($field['captcha_size'], 'compact'); ?>><?php _e( 'Compact', 'formidable' ) ?></option> |
|
| 252 | + <option value="default"<?php selected( $field['captcha_size'], 'default' ); ?>><?php _e( 'Default', 'formidable' ) ?></option> |
|
| 253 | + <option value="compact"<?php selected( $field['captcha_size'], 'compact' ); ?>><?php _e( 'Compact', 'formidable' ) ?></option> |
|
| 254 | 254 | </select> |
| 255 | 255 | </td> |
| 256 | 256 | </tr> |
| 257 | 257 | <?php |
| 258 | 258 | } ?> |
| 259 | - <?php do_action('frm_field_options_form', $field, $display, $values); |
|
| 259 | + <?php do_action( 'frm_field_options_form', $field, $display, $values ); |
|
| 260 | 260 | |
| 261 | 261 | if ( $display['required'] || $display['invalid'] || $display['unique'] || $display['conf_field'] ) { ?> |
| 262 | - <tr class="frm_validation_msg <?php echo ($display['invalid'] || $field['required'] || FrmField::is_option_true( $field, 'unique' ) || FrmField::is_option_true( $field, 'conf_field' ) ) ? '' : 'frm_hidden'; ?>"> |
|
| 262 | + <tr class="frm_validation_msg <?php echo ( $display['invalid'] || $field['required'] || FrmField::is_option_true( $field, 'unique' ) || FrmField::is_option_true( $field, 'conf_field' ) ) ? '' : 'frm_hidden'; ?>"> |
|
| 263 | 263 | <td colspan="2"> |
| 264 | 264 | <div class="menu-settings"> |
| 265 | 265 | <h3 class="frm_no_bg"><?php _e( 'Validation', 'formidable' ) ?></h3> |
@@ -323,4 +323,4 @@ discard block |
||
| 323 | 323 | <?php |
| 324 | 324 | } |
| 325 | 325 | |
| 326 | -unset($display); |
|
| 326 | +unset( $display ); |
|
@@ -32,18 +32,18 @@ discard block |
||
| 32 | 32 | $field['value'] = ''; |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | - $field_name = 'item_meta['. $field_id .']'; |
|
| 36 | - $html_id = FrmFieldsHelper::get_html_id($field); |
|
| 35 | + $field_name = 'item_meta[' . $field_id . ']'; |
|
| 36 | + $html_id = FrmFieldsHelper::get_html_id( $field ); |
|
| 37 | 37 | |
| 38 | 38 | ob_start(); |
| 39 | - include($path .'/classes/views/frm-forms/add_field.php'); |
|
| 40 | - $field_html[ $field_id ] = ob_get_contents(); |
|
| 39 | + include( $path . '/classes/views/frm-forms/add_field.php' ); |
|
| 40 | + $field_html[$field_id] = ob_get_contents(); |
|
| 41 | 41 | ob_end_clean(); |
| 42 | 42 | } |
| 43 | 43 | |
| 44 | - unset($path); |
|
| 44 | + unset( $path ); |
|
| 45 | 45 | |
| 46 | - echo json_encode($field_html); |
|
| 46 | + echo json_encode( $field_html ); |
|
| 47 | 47 | |
| 48 | 48 | wp_die(); |
| 49 | 49 | } |
@@ -54,10 +54,10 @@ discard block |
||
| 54 | 54 | $field_type = FrmAppHelper::get_post_param( 'field', '', 'sanitize_text_field' ); |
| 55 | 55 | $form_id = FrmAppHelper::get_post_param( 'form_id', 0, 'absint' ); |
| 56 | 56 | |
| 57 | - $field = self::include_new_field($field_type, $form_id); |
|
| 57 | + $field = self::include_new_field( $field_type, $form_id ); |
|
| 58 | 58 | |
| 59 | 59 | // this hook will allow for multiple fields to be added at once |
| 60 | - do_action('frm_after_field_created', $field, $form_id); |
|
| 60 | + do_action( 'frm_after_field_created', $field, $form_id ); |
|
| 61 | 61 | |
| 62 | 62 | wp_die(); |
| 63 | 63 | } |
@@ -68,17 +68,17 @@ discard block |
||
| 68 | 68 | public static function include_new_field( $field_type, $form_id ) { |
| 69 | 69 | $values = array(); |
| 70 | 70 | if ( FrmAppHelper::pro_is_installed() ) { |
| 71 | - $values['post_type'] = FrmProFormsHelper::post_type($form_id); |
|
| 71 | + $values['post_type'] = FrmProFormsHelper::post_type( $form_id ); |
|
| 72 | 72 | } |
| 73 | 73 | |
| 74 | - $field_values = apply_filters('frm_before_field_created', FrmFieldsHelper::setup_new_vars($field_type, $form_id)); |
|
| 74 | + $field_values = apply_filters( 'frm_before_field_created', FrmFieldsHelper::setup_new_vars( $field_type, $form_id ) ); |
|
| 75 | 75 | $field_id = FrmField::create( $field_values ); |
| 76 | 76 | |
| 77 | 77 | if ( ! $field_id ) { |
| 78 | 78 | return false; |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | - $field = self::include_single_field($field_id, $values, $form_id); |
|
| 81 | + $field = self::include_single_field( $field_id, $values, $form_id ); |
|
| 82 | 82 | |
| 83 | 83 | return $field; |
| 84 | 84 | } |
@@ -102,18 +102,18 @@ discard block |
||
| 102 | 102 | public static function edit_name( $field = 'name', $id = '' ) { |
| 103 | 103 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 104 | 104 | |
| 105 | - if ( empty($field) ) { |
|
| 105 | + if ( empty( $field ) ) { |
|
| 106 | 106 | $field = 'name'; |
| 107 | 107 | } |
| 108 | 108 | |
| 109 | - if ( empty($id) ) { |
|
| 109 | + if ( empty( $id ) ) { |
|
| 110 | 110 | $id = FrmAppHelper::get_post_param( 'element_id', '', 'sanitize_title' ); |
| 111 | 111 | $id = str_replace( 'field_label_', '', $id ); |
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | $value = FrmAppHelper::get_post_param( 'update_value', '', 'wp_kses_post' ); |
| 115 | 115 | $value = trim( $value ); |
| 116 | - if ( trim(strip_tags($value)) == '' ) { |
|
| 116 | + if ( trim( strip_tags( $value ) ) == '' ) { |
|
| 117 | 117 | // set blank value if there is no content |
| 118 | 118 | $value = ''; |
| 119 | 119 | } |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | $field = FrmField::getOne( $field_id ); |
| 138 | 138 | |
| 139 | 139 | foreach ( array( 'clear_on_focus', 'separate_value', 'default_blank' ) as $val ) { |
| 140 | - if ( isset($_POST[ $val ]) ) { |
|
| 140 | + if ( isset( $_POST[$val] ) ) { |
|
| 141 | 141 | // all three of these options are boolean |
| 142 | 142 | $new_val = FrmAppHelper::get_post_param( $val, 0, 'absint' ); |
| 143 | 143 | |
@@ -145,10 +145,10 @@ discard block |
||
| 145 | 145 | $new_val = FrmField::is_option_true( $field, $val ) ? 0 : 1; |
| 146 | 146 | } |
| 147 | 147 | |
| 148 | - $field->field_options[ $val ] = $new_val; |
|
| 149 | - unset($new_val); |
|
| 148 | + $field->field_options[$val] = $new_val; |
|
| 149 | + unset( $new_val ); |
|
| 150 | 150 | } |
| 151 | - unset($val); |
|
| 151 | + unset( $val ); |
|
| 152 | 152 | } |
| 153 | 153 | |
| 154 | 154 | FrmField::update( $field_id, array( |
@@ -171,21 +171,21 @@ discard block |
||
| 171 | 171 | wp_die(); |
| 172 | 172 | } |
| 173 | 173 | |
| 174 | - do_action('frm_duplicate_field', $copy_field, $form_id); |
|
| 175 | - do_action('frm_duplicate_field_'. $copy_field->type, $copy_field, $form_id); |
|
| 174 | + do_action( 'frm_duplicate_field', $copy_field, $form_id ); |
|
| 175 | + do_action( 'frm_duplicate_field_' . $copy_field->type, $copy_field, $form_id ); |
|
| 176 | 176 | |
| 177 | 177 | $values = array( 'id' => $form_id ); |
| 178 | 178 | FrmFieldsHelper::fill_field( $values, $copy_field, $form_id ); |
| 179 | 179 | |
| 180 | - $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 ) ); |
|
| 180 | + $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 ) ); |
|
| 181 | 181 | |
| 182 | 182 | $values['field_order'] = $field_count + 1; |
| 183 | 183 | |
| 184 | - if ( ! $field_id = FrmField::create($values) ) { |
|
| 184 | + if ( ! $field_id = FrmField::create( $values ) ) { |
|
| 185 | 185 | wp_die(); |
| 186 | 186 | } |
| 187 | 187 | |
| 188 | - self::include_single_field($field_id, $values); |
|
| 188 | + self::include_single_field( $field_id, $values ); |
|
| 189 | 189 | |
| 190 | 190 | wp_die(); |
| 191 | 191 | } |
@@ -194,15 +194,15 @@ discard block |
||
| 194 | 194 | * Load a single field in the form builder along with all needed variables |
| 195 | 195 | */ |
| 196 | 196 | public static function include_single_field( $field_id, $values, $form_id = 0 ) { |
| 197 | - $field = FrmFieldsHelper::setup_edit_vars(FrmField::getOne($field_id)); |
|
| 198 | - $field_name = 'item_meta['. $field_id .']'; |
|
| 199 | - $html_id = FrmFieldsHelper::get_html_id($field); |
|
| 197 | + $field = FrmFieldsHelper::setup_edit_vars( FrmField::getOne( $field_id ) ); |
|
| 198 | + $field_name = 'item_meta[' . $field_id . ']'; |
|
| 199 | + $html_id = FrmFieldsHelper::get_html_id( $field ); |
|
| 200 | 200 | $id = $form_id ? $form_id : $field['form_id']; |
| 201 | 201 | if ( $field['type'] == 'html' ) { |
| 202 | 202 | $field['stop_filter'] = true; |
| 203 | 203 | } |
| 204 | 204 | |
| 205 | - require(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/add_field.php'); |
|
| 205 | + require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/add_field.php' ); |
|
| 206 | 206 | |
| 207 | 207 | return $field; |
| 208 | 208 | } |
@@ -225,7 +225,7 @@ discard block |
||
| 225 | 225 | $opt_type = FrmAppHelper::get_post_param( 'opt_type', '', 'sanitize_text_field' ); |
| 226 | 226 | |
| 227 | 227 | //Get the field |
| 228 | - $field = FrmField::getOne($id); |
|
| 228 | + $field = FrmField::getOne( $id ); |
|
| 229 | 229 | |
| 230 | 230 | if ( ! empty( $field->options ) ) { |
| 231 | 231 | $keys = array_keys( $field->options ); |
@@ -248,13 +248,13 @@ discard block |
||
| 248 | 248 | $first_opt = reset( $field->options ); |
| 249 | 249 | $next_opt = count( $field->options ); |
| 250 | 250 | if ( $first_opt != '' ) { |
| 251 | - $next_opt++; |
|
| 251 | + $next_opt ++; |
|
| 252 | 252 | } |
| 253 | - $opt = esc_html__( 'Option', 'formidable' ) .' '. $next_opt; |
|
| 254 | - unset($next_opt); |
|
| 253 | + $opt = esc_html__( 'Option', 'formidable' ) . ' ' . $next_opt; |
|
| 254 | + unset( $next_opt ); |
|
| 255 | 255 | } |
| 256 | 256 | $field_val = $opt; |
| 257 | - $field->options[ $opt_key ] = $opt; |
|
| 257 | + $field->options[$opt_key] = $opt; |
|
| 258 | 258 | |
| 259 | 259 | //Update options in DB |
| 260 | 260 | FrmField::update( $id, array( 'options' => $field->options ) ); |
@@ -263,19 +263,19 @@ discard block |
||
| 263 | 263 | $field = array( |
| 264 | 264 | 'type' => $field_data->type, |
| 265 | 265 | 'id' => $id, |
| 266 | - 'separate_value' => isset($field_data->field_options['separate_value']) ? $field_data->field_options['separate_value'] : 0, |
|
| 266 | + 'separate_value' => isset( $field_data->field_options['separate_value'] ) ? $field_data->field_options['separate_value'] : 0, |
|
| 267 | 267 | 'form_id' => $field_data->form_id, |
| 268 | 268 | 'field_key' => $field_data->field_key, |
| 269 | 269 | ); |
| 270 | 270 | |
| 271 | - $field_name = 'item_meta['. $id .']'; |
|
| 272 | - $html_id = FrmFieldsHelper::get_html_id($field); |
|
| 271 | + $field_name = 'item_meta[' . $id . ']'; |
|
| 272 | + $html_id = FrmFieldsHelper::get_html_id( $field ); |
|
| 273 | 273 | $checked = ''; |
| 274 | 274 | |
| 275 | 275 | if ( 'other' == $opt_type ) { |
| 276 | - require(FrmAppHelper::plugin_path() .'/pro/classes/views/frmpro-fields/other-option.php'); |
|
| 276 | + require( FrmAppHelper::plugin_path() . '/pro/classes/views/frmpro-fields/other-option.php' ); |
|
| 277 | 277 | } else { |
| 278 | - require(FrmAppHelper::plugin_path() .'/classes/views/frm-fields/single-option.php'); |
|
| 278 | + require( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/single-option.php' ); |
|
| 279 | 279 | } |
| 280 | 280 | wp_die(); |
| 281 | 281 | } |
@@ -294,28 +294,28 @@ discard block |
||
| 294 | 294 | $new_label = $update_value; |
| 295 | 295 | } |
| 296 | 296 | |
| 297 | - $field = FrmField::getOne($id); |
|
| 297 | + $field = FrmField::getOne( $id ); |
|
| 298 | 298 | $separate_values = FrmField::is_option_true( $field, 'separate_value' ); |
| 299 | 299 | |
| 300 | - $this_opt_id = end($ids); |
|
| 301 | - $this_opt = (array) $field->options[ $this_opt_id ]; |
|
| 302 | - $other_opt = ( $this_opt_id && strpos( $this_opt_id, 'other') !== false ? true : false ); |
|
| 300 | + $this_opt_id = end( $ids ); |
|
| 301 | + $this_opt = (array) $field->options[$this_opt_id]; |
|
| 302 | + $other_opt = ( $this_opt_id && strpos( $this_opt_id, 'other' ) !== false ? true : false ); |
|
| 303 | 303 | |
| 304 | - $label = isset($this_opt['label']) ? $this_opt['label'] : reset($this_opt); |
|
| 305 | - $value = isset($this_opt['value']) ? $this_opt['value'] : ''; |
|
| 304 | + $label = isset( $this_opt['label'] ) ? $this_opt['label'] : reset( $this_opt ); |
|
| 305 | + $value = isset( $this_opt['value'] ) ? $this_opt['value'] : ''; |
|
| 306 | 306 | |
| 307 | 307 | if ( ! isset( $new_label ) ) { |
| 308 | 308 | $new_label = $label; |
| 309 | 309 | } |
| 310 | 310 | |
| 311 | - if ( isset($new_value) || isset($value) ) { |
|
| 312 | - $update_value = isset($new_value) ? $new_value : $value; |
|
| 311 | + if ( isset( $new_value ) || isset( $value ) ) { |
|
| 312 | + $update_value = isset( $new_value ) ? $new_value : $value; |
|
| 313 | 313 | } |
| 314 | 314 | |
| 315 | 315 | if ( $update_value != $new_label && $other_opt === false && $separate_values ) { |
| 316 | - $field->options[ $this_opt_id ] = array( 'value' => $update_value, 'label' => $new_label ); |
|
| 316 | + $field->options[$this_opt_id] = array( 'value' => $update_value, 'label' => $new_label ); |
|
| 317 | 317 | } else { |
| 318 | - $field->options[ $this_opt_id ] = $orig_update_value; |
|
| 318 | + $field->options[$this_opt_id] = $orig_update_value; |
|
| 319 | 319 | } |
| 320 | 320 | |
| 321 | 321 | FrmField::update( $field->id, array( 'options' => $field->options ) ); |
@@ -332,7 +332,7 @@ discard block |
||
| 332 | 332 | $opt_key = FrmAppHelper::get_post_param( 'opt_key', 0, 'sanitize_title' ); |
| 333 | 333 | |
| 334 | 334 | $options = $field->options; |
| 335 | - unset( $options[ $opt_key ] ); |
|
| 335 | + unset( $options[$opt_key] ); |
|
| 336 | 336 | $response = array( 'other' => true ); |
| 337 | 337 | |
| 338 | 338 | //If the deleted option is an "other" option |
@@ -400,45 +400,45 @@ discard block |
||
| 400 | 400 | |
| 401 | 401 | $admin_body_class .= ' admin-color-' . sanitize_html_class( get_user_option( 'admin_color' ), 'fresh' ); |
| 402 | 402 | $prepop = array(); |
| 403 | - FrmFieldsHelper::get_bulk_prefilled_opts($prepop); |
|
| 403 | + FrmFieldsHelper::get_bulk_prefilled_opts( $prepop ); |
|
| 404 | 404 | |
| 405 | - $field = FrmField::getOne($field_id); |
|
| 405 | + $field = FrmField::getOne( $field_id ); |
|
| 406 | 406 | |
| 407 | 407 | wp_enqueue_script( 'utils' ); |
| 408 | - wp_enqueue_style( 'formidable-admin', FrmAppHelper::plugin_url(). '/css/frm_admin.css' ); |
|
| 408 | + wp_enqueue_style( 'formidable-admin', FrmAppHelper::plugin_url() . '/css/frm_admin.css' ); |
|
| 409 | 409 | FrmAppHelper::load_admin_wide_js(); |
| 410 | 410 | |
| 411 | - include(FrmAppHelper::plugin_path() .'/classes/views/frm-fields/import_choices.php'); |
|
| 411 | + include( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/import_choices.php' ); |
|
| 412 | 412 | wp_die(); |
| 413 | 413 | } |
| 414 | 414 | |
| 415 | 415 | public static function import_options() { |
| 416 | 416 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 417 | 417 | |
| 418 | - if ( ! is_admin() || ! current_user_can('frm_edit_forms') ) { |
|
| 418 | + if ( ! is_admin() || ! current_user_can( 'frm_edit_forms' ) ) { |
|
| 419 | 419 | return; |
| 420 | 420 | } |
| 421 | 421 | |
| 422 | 422 | $field_id = absint( $_POST['field_id'] ); |
| 423 | - $field = FrmField::getOne($field_id); |
|
| 423 | + $field = FrmField::getOne( $field_id ); |
|
| 424 | 424 | |
| 425 | 425 | if ( ! in_array( $field->type, array( 'radio', 'checkbox', 'select' ) ) ) { |
| 426 | 426 | return; |
| 427 | 427 | } |
| 428 | 428 | |
| 429 | - $field = FrmFieldsHelper::setup_edit_vars($field); |
|
| 430 | - $opts = stripslashes_deep($_POST['opts']); |
|
| 431 | - $opts = explode("\n", rtrim($opts, "\n")); |
|
| 429 | + $field = FrmFieldsHelper::setup_edit_vars( $field ); |
|
| 430 | + $opts = stripslashes_deep( $_POST['opts'] ); |
|
| 431 | + $opts = explode( "\n", rtrim( $opts, "\n" ) ); |
|
| 432 | 432 | if ( $field['separate_value'] ) { |
| 433 | 433 | foreach ( $opts as $opt_key => $opt ) { |
| 434 | - if ( strpos($opt, '|') !== false ) { |
|
| 435 | - $vals = explode('|', $opt); |
|
| 434 | + if ( strpos( $opt, '|' ) !== false ) { |
|
| 435 | + $vals = explode( '|', $opt ); |
|
| 436 | 436 | if ( $vals[0] != $vals[1] ) { |
| 437 | - $opts[ $opt_key ] = array( 'label' => trim( $vals[0] ), 'value' => trim( $vals[1] ) ); |
|
| 437 | + $opts[$opt_key] = array( 'label' => trim( $vals[0] ), 'value' => trim( $vals[1] ) ); |
|
| 438 | 438 | } |
| 439 | - unset($vals); |
|
| 439 | + unset( $vals ); |
|
| 440 | 440 | } |
| 441 | - unset($opt_key, $opt); |
|
| 441 | + unset( $opt_key, $opt ); |
|
| 442 | 442 | } |
| 443 | 443 | } |
| 444 | 444 | |
@@ -447,12 +447,12 @@ discard block |
||
| 447 | 447 | $other_array = array(); |
| 448 | 448 | foreach ( $field['options'] as $opt_key => $opt ) { |
| 449 | 449 | if ( $opt_key && strpos( $opt_key, 'other' ) !== false ) { |
| 450 | - $other_array[ $opt_key ] = $opt; |
|
| 450 | + $other_array[$opt_key] = $opt; |
|
| 451 | 451 | } |
| 452 | - unset($opt_key, $opt); |
|
| 452 | + unset( $opt_key, $opt ); |
|
| 453 | 453 | } |
| 454 | - if ( ! empty($other_array) ) { |
|
| 455 | - $opts = array_merge( $opts, $other_array); |
|
| 454 | + if ( ! empty( $other_array ) ) { |
|
| 455 | + $opts = array_merge( $opts, $other_array ); |
|
| 456 | 456 | } |
| 457 | 457 | } |
| 458 | 458 | |
@@ -465,9 +465,9 @@ discard block |
||
| 465 | 465 | $html_id = FrmFieldsHelper::get_html_id( $field ); |
| 466 | 466 | |
| 467 | 467 | if ( $field['type'] == 'radio' || $field['type'] == 'checkbox' ) { |
| 468 | - require(FrmAppHelper::plugin_path() .'/classes/views/frm-fields/radio.php'); |
|
| 468 | + require( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/radio.php' ); |
|
| 469 | 469 | } else { |
| 470 | - FrmFieldsHelper::show_single_option($field); |
|
| 470 | + FrmFieldsHelper::show_single_option( $field ); |
|
| 471 | 471 | } |
| 472 | 472 | |
| 473 | 473 | wp_die(); |
@@ -489,13 +489,13 @@ discard block |
||
| 489 | 489 | 'rte' => 'textarea', |
| 490 | 490 | 'website' => 'url', |
| 491 | 491 | ); |
| 492 | - if ( isset( $type_switch[ $type ] ) ) { |
|
| 493 | - $type = $type_switch[ $type ]; |
|
| 492 | + if ( isset( $type_switch[$type] ) ) { |
|
| 493 | + $type = $type_switch[$type]; |
|
| 494 | 494 | } |
| 495 | 495 | |
| 496 | 496 | $frm_field_selection = FrmField::field_selection(); |
| 497 | - $types = array_keys($frm_field_selection); |
|
| 498 | - if ( ! in_array($type, $types) && $type != 'captcha' ) { |
|
| 497 | + $types = array_keys( $frm_field_selection ); |
|
| 498 | + if ( ! in_array( $type, $types ) && $type != 'captcha' ) { |
|
| 499 | 499 | $type = 'text'; |
| 500 | 500 | } |
| 501 | 501 | |
@@ -534,19 +534,19 @@ discard block |
||
| 534 | 534 | |
| 535 | 535 | public static function input_html( $field, $echo = true ) { |
| 536 | 536 | $class = array(); //$field['type']; |
| 537 | - self::add_input_classes($field, $class); |
|
| 537 | + self::add_input_classes( $field, $class ); |
|
| 538 | 538 | |
| 539 | 539 | $add_html = array(); |
| 540 | - self::add_html_size($field, $add_html); |
|
| 541 | - self::add_html_length($field, $add_html); |
|
| 542 | - self::add_html_placeholder($field, $add_html, $class); |
|
| 540 | + self::add_html_size( $field, $add_html ); |
|
| 541 | + self::add_html_length( $field, $add_html ); |
|
| 542 | + self::add_html_placeholder( $field, $add_html, $class ); |
|
| 543 | 543 | self::add_validation_messages( $field, $add_html ); |
| 544 | 544 | |
| 545 | - $class = apply_filters('frm_field_classes', implode(' ', $class), $field); |
|
| 545 | + $class = apply_filters( 'frm_field_classes', implode( ' ', $class ), $field ); |
|
| 546 | 546 | |
| 547 | 547 | FrmFormsHelper::add_html_attr( $class, 'class', $add_html ); |
| 548 | 548 | |
| 549 | - self::add_shortcodes_to_html($field, $add_html); |
|
| 549 | + self::add_shortcodes_to_html( $field, $add_html ); |
|
| 550 | 550 | |
| 551 | 551 | $add_html = apply_filters( 'frm_field_extra_html', $add_html, $field ); |
| 552 | 552 | $add_html = ' ' . implode( ' ', $add_html ) . ' '; |
@@ -559,7 +559,7 @@ discard block |
||
| 559 | 559 | } |
| 560 | 560 | |
| 561 | 561 | private static function add_input_classes( $field, array &$class ) { |
| 562 | - if ( isset($field['input_class']) && ! empty($field['input_class']) ) { |
|
| 562 | + if ( isset( $field['input_class'] ) && ! empty( $field['input_class'] ) ) { |
|
| 563 | 563 | $class[] = $field['input_class']; |
| 564 | 564 | } |
| 565 | 565 | |
@@ -572,7 +572,7 @@ discard block |
||
| 572 | 572 | $class[] = 'dyn_default_value'; |
| 573 | 573 | } |
| 574 | 574 | |
| 575 | - if ( isset($field['size']) && $field['size'] > 0 ) { |
|
| 575 | + if ( isset( $field['size'] ) && $field['size'] > 0 ) { |
|
| 576 | 576 | $class[] = 'auto_width'; |
| 577 | 577 | } |
| 578 | 578 | } |
@@ -582,19 +582,19 @@ discard block |
||
| 582 | 582 | return; |
| 583 | 583 | } |
| 584 | 584 | |
| 585 | - if ( FrmAppHelper::is_admin_page('formidable' ) ) { |
|
| 585 | + if ( FrmAppHelper::is_admin_page( 'formidable' ) ) { |
|
| 586 | 586 | return; |
| 587 | 587 | } |
| 588 | 588 | |
| 589 | - if ( is_numeric($field['size']) ) { |
|
| 589 | + if ( is_numeric( $field['size'] ) ) { |
|
| 590 | 590 | $field['size'] .= 'px'; |
| 591 | 591 | } |
| 592 | 592 | |
| 593 | - $important = apply_filters('frm_use_important_width', 1, $field); |
|
| 593 | + $important = apply_filters( 'frm_use_important_width', 1, $field ); |
|
| 594 | 594 | // Note: This inline styling must stay since we cannot realistically set a class for every possible field size |
| 595 | - $add_html['style'] = 'style="width:'. esc_attr( $field['size'] ) . ( $important ? ' !important' : '' ) .'"'; |
|
| 595 | + $add_html['style'] = 'style="width:' . esc_attr( $field['size'] ) . ( $important ? ' !important' : '' ) . '"'; |
|
| 596 | 596 | |
| 597 | - self::add_html_cols($field, $add_html); |
|
| 597 | + self::add_html_cols( $field, $add_html ); |
|
| 598 | 598 | } |
| 599 | 599 | |
| 600 | 600 | private static function add_html_cols( $field, array &$add_html ) { |
@@ -611,13 +611,13 @@ discard block |
||
| 611 | 611 | ); |
| 612 | 612 | |
| 613 | 613 | // include "col" for valid html |
| 614 | - $unit = trim(preg_replace('/[0-9]+/', '', $field['size'])); |
|
| 614 | + $unit = trim( preg_replace( '/[0-9]+/', '', $field['size'] ) ); |
|
| 615 | 615 | |
| 616 | - if ( ! isset( $calc[ $unit ] ) ) { |
|
| 616 | + if ( ! isset( $calc[$unit] ) ) { |
|
| 617 | 617 | return; |
| 618 | 618 | } |
| 619 | 619 | |
| 620 | - $size = (float) str_replace( $unit, '', $field['size'] ) / $calc[ $unit ]; |
|
| 620 | + $size = (float) str_replace( $unit, '', $field['size'] ) / $calc[$unit]; |
|
| 621 | 621 | |
| 622 | 622 | $add_html['cols'] = 'cols="' . absint( $size ) . '"'; |
| 623 | 623 | } |
@@ -628,7 +628,7 @@ discard block |
||
| 628 | 628 | return; |
| 629 | 629 | } |
| 630 | 630 | |
| 631 | - if ( FrmAppHelper::is_admin_page('formidable' ) ) { |
|
| 631 | + if ( FrmAppHelper::is_admin_page( 'formidable' ) ) { |
|
| 632 | 632 | // don't load on form builder page |
| 633 | 633 | return; |
| 634 | 634 | } |
@@ -653,11 +653,11 @@ discard block |
||
| 653 | 653 | |
| 654 | 654 | if ( $frm_settings->use_html && ! in_array( $field['type'], array( 'select', 'radio', 'checkbox', 'hidden' ) ) ) { |
| 655 | 655 | // use HMTL5 placeholder with js fallback |
| 656 | - $add_html['placeholder'] = 'placeholder="'. esc_attr($field['default_value']) .'"'; |
|
| 657 | - wp_enqueue_script('jquery-placeholder'); |
|
| 656 | + $add_html['placeholder'] = 'placeholder="' . esc_attr( $field['default_value'] ) . '"'; |
|
| 657 | + wp_enqueue_script( 'jquery-placeholder' ); |
|
| 658 | 658 | } else if ( ! $frm_settings->use_html ) { |
| 659 | 659 | $val = str_replace( array( "\r\n", "\n" ), '\r', addslashes( str_replace( ''', "'", esc_attr( $field['default_value'] ) ) ) ); |
| 660 | - $add_html['data-frmval'] = 'data-frmval="'. esc_attr($val) .'"'; |
|
| 660 | + $add_html['data-frmval'] = 'data-frmval="' . esc_attr( $val ) . '"'; |
|
| 661 | 661 | $class[] = 'frm_toggle_default'; |
| 662 | 662 | |
| 663 | 663 | if ( $field['value'] == $field['default_value'] ) { |
@@ -681,7 +681,7 @@ discard block |
||
| 681 | 681 | $format = FrmEntryValidate::phone_format( $field ); |
| 682 | 682 | $format = substr( $format, 2, -2 ); |
| 683 | 683 | $key = 'pattern'; |
| 684 | - $add_html[ $key ] = $key . '="' . esc_attr( $format ) . '"'; |
|
| 684 | + $add_html[$key] = $key . '="' . esc_attr( $format ) . '"'; |
|
| 685 | 685 | } |
| 686 | 686 | } |
| 687 | 687 | |
@@ -695,15 +695,15 @@ discard block |
||
| 695 | 695 | continue; |
| 696 | 696 | } |
| 697 | 697 | |
| 698 | - if ( is_numeric($k) && strpos($v, '=') ) { |
|
| 698 | + if ( is_numeric( $k ) && strpos( $v, '=' ) ) { |
|
| 699 | 699 | $add_html[] = $v; |
| 700 | - } else if ( ! empty( $k ) && isset( $add_html[ $k ] ) ) { |
|
| 701 | - $add_html[ $k ] = str_replace( $k .'="', $k .'="'. $v, $add_html[ $k ] ); |
|
| 700 | + } else if ( ! empty( $k ) && isset( $add_html[$k] ) ) { |
|
| 701 | + $add_html[$k] = str_replace( $k . '="', $k . '="' . $v, $add_html[$k] ); |
|
| 702 | 702 | } else { |
| 703 | - $add_html[ $k ] = $k . '="' . esc_attr( $v ) . '"'; |
|
| 703 | + $add_html[$k] = $k . '="' . esc_attr( $v ) . '"'; |
|
| 704 | 704 | } |
| 705 | 705 | |
| 706 | - unset($k, $v); |
|
| 706 | + unset( $k, $v ); |
|
| 707 | 707 | } |
| 708 | 708 | } |
| 709 | 709 | |
@@ -719,8 +719,8 @@ discard block |
||
| 719 | 719 | } |
| 720 | 720 | |
| 721 | 721 | public static function check_label( $opt ) { |
| 722 | - if ( is_array($opt) ) { |
|
| 723 | - $opt = (isset($opt['label']) ? $opt['label'] : reset($opt)); |
|
| 722 | + if ( is_array( $opt ) ) { |
|
| 723 | + $opt = ( isset( $opt['label'] ) ? $opt['label'] : reset( $opt ) ); |
|
| 724 | 724 | } |
| 725 | 725 | |
| 726 | 726 | return $opt; |
@@ -2,132 +2,132 @@ discard block |
||
| 2 | 2 | |
| 3 | 3 | class FrmFieldsController { |
| 4 | 4 | |
| 5 | - public static function load_field() { |
|
| 6 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 5 | + public static function load_field() { |
|
| 6 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 7 | 7 | |
| 8 | - $fields = $_POST['field']; |
|
| 9 | - if ( empty( $fields ) ) { |
|
| 10 | - wp_die(); |
|
| 11 | - } |
|
| 8 | + $fields = $_POST['field']; |
|
| 9 | + if ( empty( $fields ) ) { |
|
| 10 | + wp_die(); |
|
| 11 | + } |
|
| 12 | 12 | |
| 13 | - $_GET['page'] = 'formidable'; |
|
| 14 | - $fields = stripslashes_deep( $fields ); |
|
| 13 | + $_GET['page'] = 'formidable'; |
|
| 14 | + $fields = stripslashes_deep( $fields ); |
|
| 15 | 15 | |
| 16 | - $ajax = true; |
|
| 16 | + $ajax = true; |
|
| 17 | 17 | $values = array( 'id' => FrmAppHelper::get_post_param( 'form_id', '', 'absint' ) ); |
| 18 | - $path = FrmAppHelper::plugin_path(); |
|
| 19 | - $field_html = array(); |
|
| 20 | - |
|
| 21 | - foreach ( $fields as $field ) { |
|
| 22 | - $field = htmlspecialchars_decode( nl2br( $field ) ); |
|
| 23 | - $field = json_decode( $field, true ); |
|
| 24 | - if ( ! isset( $field['id'] ) ) { |
|
| 25 | - // this field may have already been loaded |
|
| 26 | - continue; |
|
| 27 | - } |
|
| 18 | + $path = FrmAppHelper::plugin_path(); |
|
| 19 | + $field_html = array(); |
|
| 20 | + |
|
| 21 | + foreach ( $fields as $field ) { |
|
| 22 | + $field = htmlspecialchars_decode( nl2br( $field ) ); |
|
| 23 | + $field = json_decode( $field, true ); |
|
| 24 | + if ( ! isset( $field['id'] ) ) { |
|
| 25 | + // this field may have already been loaded |
|
| 26 | + continue; |
|
| 27 | + } |
|
| 28 | 28 | |
| 29 | - $field_id = absint( $field['id'] ); |
|
| 29 | + $field_id = absint( $field['id'] ); |
|
| 30 | 30 | |
| 31 | - if ( ! isset( $field['value'] ) ) { |
|
| 32 | - $field['value'] = ''; |
|
| 33 | - } |
|
| 31 | + if ( ! isset( $field['value'] ) ) { |
|
| 32 | + $field['value'] = ''; |
|
| 33 | + } |
|
| 34 | 34 | |
| 35 | - $field_name = 'item_meta['. $field_id .']'; |
|
| 36 | - $html_id = FrmFieldsHelper::get_html_id($field); |
|
| 35 | + $field_name = 'item_meta['. $field_id .']'; |
|
| 36 | + $html_id = FrmFieldsHelper::get_html_id($field); |
|
| 37 | 37 | |
| 38 | - ob_start(); |
|
| 39 | - include($path .'/classes/views/frm-forms/add_field.php'); |
|
| 40 | - $field_html[ $field_id ] = ob_get_contents(); |
|
| 41 | - ob_end_clean(); |
|
| 42 | - } |
|
| 38 | + ob_start(); |
|
| 39 | + include($path .'/classes/views/frm-forms/add_field.php'); |
|
| 40 | + $field_html[ $field_id ] = ob_get_contents(); |
|
| 41 | + ob_end_clean(); |
|
| 42 | + } |
|
| 43 | 43 | |
| 44 | - unset($path); |
|
| 44 | + unset($path); |
|
| 45 | 45 | |
| 46 | - echo json_encode($field_html); |
|
| 46 | + echo json_encode($field_html); |
|
| 47 | 47 | |
| 48 | - wp_die(); |
|
| 49 | - } |
|
| 48 | + wp_die(); |
|
| 49 | + } |
|
| 50 | 50 | |
| 51 | - public static function create() { |
|
| 52 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 51 | + public static function create() { |
|
| 52 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 53 | 53 | |
| 54 | 54 | $field_type = FrmAppHelper::get_post_param( 'field', '', 'sanitize_text_field' ); |
| 55 | 55 | $form_id = FrmAppHelper::get_post_param( 'form_id', 0, 'absint' ); |
| 56 | 56 | |
| 57 | - $field = self::include_new_field($field_type, $form_id); |
|
| 57 | + $field = self::include_new_field($field_type, $form_id); |
|
| 58 | 58 | |
| 59 | - // this hook will allow for multiple fields to be added at once |
|
| 60 | - do_action('frm_after_field_created', $field, $form_id); |
|
| 59 | + // this hook will allow for multiple fields to be added at once |
|
| 60 | + do_action('frm_after_field_created', $field, $form_id); |
|
| 61 | 61 | |
| 62 | - wp_die(); |
|
| 63 | - } |
|
| 62 | + wp_die(); |
|
| 63 | + } |
|
| 64 | 64 | |
| 65 | - /** |
|
| 66 | - * @param integer $form_id |
|
| 67 | - */ |
|
| 65 | + /** |
|
| 66 | + * @param integer $form_id |
|
| 67 | + */ |
|
| 68 | 68 | public static function include_new_field( $field_type, $form_id ) { |
| 69 | - $values = array(); |
|
| 70 | - if ( FrmAppHelper::pro_is_installed() ) { |
|
| 71 | - $values['post_type'] = FrmProFormsHelper::post_type($form_id); |
|
| 72 | - } |
|
| 69 | + $values = array(); |
|
| 70 | + if ( FrmAppHelper::pro_is_installed() ) { |
|
| 71 | + $values['post_type'] = FrmProFormsHelper::post_type($form_id); |
|
| 72 | + } |
|
| 73 | 73 | |
| 74 | - $field_values = apply_filters('frm_before_field_created', FrmFieldsHelper::setup_new_vars($field_type, $form_id)); |
|
| 75 | - $field_id = FrmField::create( $field_values ); |
|
| 74 | + $field_values = apply_filters('frm_before_field_created', FrmFieldsHelper::setup_new_vars($field_type, $form_id)); |
|
| 75 | + $field_id = FrmField::create( $field_values ); |
|
| 76 | 76 | |
| 77 | - if ( ! $field_id ) { |
|
| 78 | - return false; |
|
| 79 | - } |
|
| 77 | + if ( ! $field_id ) { |
|
| 78 | + return false; |
|
| 79 | + } |
|
| 80 | 80 | |
| 81 | - $field = self::include_single_field($field_id, $values, $form_id); |
|
| 81 | + $field = self::include_single_field($field_id, $values, $form_id); |
|
| 82 | 82 | |
| 83 | - return $field; |
|
| 84 | - } |
|
| 83 | + return $field; |
|
| 84 | + } |
|
| 85 | 85 | |
| 86 | - public static function update_form_id() { |
|
| 87 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 86 | + public static function update_form_id() { |
|
| 87 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 88 | 88 | |
| 89 | 89 | $field_id = FrmAppHelper::get_post_param( 'field', 0, 'absint' ); |
| 90 | 90 | $form_id = FrmAppHelper::get_post_param( 'form_id', 0, 'absint' ); |
| 91 | 91 | |
| 92 | - if ( ! $field_id || ! $form_id ) { |
|
| 93 | - wp_die(); |
|
| 94 | - } |
|
| 92 | + if ( ! $field_id || ! $form_id ) { |
|
| 93 | + wp_die(); |
|
| 94 | + } |
|
| 95 | 95 | |
| 96 | 96 | $updated = FrmField::update( $field_id, compact( 'form_id' ) ); |
| 97 | 97 | echo absint( $updated ); |
| 98 | 98 | |
| 99 | - wp_die(); |
|
| 100 | - } |
|
| 99 | + wp_die(); |
|
| 100 | + } |
|
| 101 | 101 | |
| 102 | 102 | public static function edit_name( $field = 'name', $id = '' ) { |
| 103 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 103 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 104 | 104 | |
| 105 | - if ( empty($field) ) { |
|
| 106 | - $field = 'name'; |
|
| 107 | - } |
|
| 105 | + if ( empty($field) ) { |
|
| 106 | + $field = 'name'; |
|
| 107 | + } |
|
| 108 | 108 | |
| 109 | - if ( empty($id) ) { |
|
| 109 | + if ( empty($id) ) { |
|
| 110 | 110 | $id = FrmAppHelper::get_post_param( 'element_id', '', 'sanitize_title' ); |
| 111 | 111 | $id = str_replace( 'field_label_', '', $id ); |
| 112 | - } |
|
| 112 | + } |
|
| 113 | 113 | |
| 114 | 114 | $value = FrmAppHelper::get_post_param( 'update_value', '', 'wp_kses_post' ); |
| 115 | 115 | $value = trim( $value ); |
| 116 | - if ( trim(strip_tags($value)) == '' ) { |
|
| 117 | - // set blank value if there is no content |
|
| 118 | - $value = ''; |
|
| 119 | - } |
|
| 116 | + if ( trim(strip_tags($value)) == '' ) { |
|
| 117 | + // set blank value if there is no content |
|
| 118 | + $value = ''; |
|
| 119 | + } |
|
| 120 | 120 | |
| 121 | 121 | FrmField::update( $id, array( $field => $value ) ); |
| 122 | 122 | |
| 123 | 123 | do_action( 'frm_after_update_field_' . $field, compact( 'id', 'value' ) ); |
| 124 | 124 | |
| 125 | 125 | echo stripslashes( wp_kses_post( $value ) ); |
| 126 | - wp_die(); |
|
| 127 | - } |
|
| 126 | + wp_die(); |
|
| 127 | + } |
|
| 128 | 128 | |
| 129 | - public static function update_ajax_option() { |
|
| 130 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 129 | + public static function update_ajax_option() { |
|
| 130 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 131 | 131 | |
| 132 | 132 | $field_id = FrmAppHelper::get_post_param( 'field', 0, 'absint' ); |
| 133 | 133 | if ( ! $field_id ) { |
@@ -137,151 +137,151 @@ discard block |
||
| 137 | 137 | $field = FrmField::getOne( $field_id ); |
| 138 | 138 | |
| 139 | 139 | foreach ( array( 'clear_on_focus', 'separate_value', 'default_blank' ) as $val ) { |
| 140 | - if ( isset($_POST[ $val ]) ) { |
|
| 140 | + if ( isset($_POST[ $val ]) ) { |
|
| 141 | 141 | // all three of these options are boolean |
| 142 | 142 | $new_val = FrmAppHelper::get_post_param( $val, 0, 'absint' ); |
| 143 | 143 | |
| 144 | - if ( $val == 'separate_value' ) { |
|
| 144 | + if ( $val == 'separate_value' ) { |
|
| 145 | 145 | $new_val = FrmField::is_option_true( $field, $val ) ? 0 : 1; |
| 146 | - } |
|
| 146 | + } |
|
| 147 | 147 | |
| 148 | - $field->field_options[ $val ] = $new_val; |
|
| 149 | - unset($new_val); |
|
| 150 | - } |
|
| 151 | - unset($val); |
|
| 152 | - } |
|
| 148 | + $field->field_options[ $val ] = $new_val; |
|
| 149 | + unset($new_val); |
|
| 150 | + } |
|
| 151 | + unset($val); |
|
| 152 | + } |
|
| 153 | 153 | |
| 154 | - FrmField::update( $field_id, array( |
|
| 155 | - 'field_options' => $field->field_options, |
|
| 154 | + FrmField::update( $field_id, array( |
|
| 155 | + 'field_options' => $field->field_options, |
|
| 156 | 156 | 'form_id' => $field->form_id, |
| 157 | - ) ); |
|
| 158 | - wp_die(); |
|
| 159 | - } |
|
| 157 | + ) ); |
|
| 158 | + wp_die(); |
|
| 159 | + } |
|
| 160 | 160 | |
| 161 | - public static function duplicate() { |
|
| 162 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 161 | + public static function duplicate() { |
|
| 162 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 163 | 163 | |
| 164 | - global $wpdb; |
|
| 164 | + global $wpdb; |
|
| 165 | 165 | |
| 166 | 166 | $field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' ); |
| 167 | 167 | $form_id = FrmAppHelper::get_post_param( 'form_id', 0, 'absint' ); |
| 168 | 168 | |
| 169 | 169 | $copy_field = FrmField::getOne( $field_id ); |
| 170 | - if ( ! $copy_field ) { |
|
| 171 | - wp_die(); |
|
| 172 | - } |
|
| 170 | + if ( ! $copy_field ) { |
|
| 171 | + wp_die(); |
|
| 172 | + } |
|
| 173 | 173 | |
| 174 | - do_action('frm_duplicate_field', $copy_field, $form_id); |
|
| 175 | - do_action('frm_duplicate_field_'. $copy_field->type, $copy_field, $form_id); |
|
| 174 | + do_action('frm_duplicate_field', $copy_field, $form_id); |
|
| 175 | + do_action('frm_duplicate_field_'. $copy_field->type, $copy_field, $form_id); |
|
| 176 | 176 | |
| 177 | - $values = array( 'id' => $form_id ); |
|
| 178 | - FrmFieldsHelper::fill_field( $values, $copy_field, $form_id ); |
|
| 177 | + $values = array( 'id' => $form_id ); |
|
| 178 | + FrmFieldsHelper::fill_field( $values, $copy_field, $form_id ); |
|
| 179 | 179 | |
| 180 | 180 | $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 ) ); |
| 181 | 181 | |
| 182 | - $values['field_order'] = $field_count + 1; |
|
| 182 | + $values['field_order'] = $field_count + 1; |
|
| 183 | 183 | |
| 184 | - if ( ! $field_id = FrmField::create($values) ) { |
|
| 185 | - wp_die(); |
|
| 186 | - } |
|
| 184 | + if ( ! $field_id = FrmField::create($values) ) { |
|
| 185 | + wp_die(); |
|
| 186 | + } |
|
| 187 | 187 | |
| 188 | - self::include_single_field($field_id, $values); |
|
| 188 | + self::include_single_field($field_id, $values); |
|
| 189 | 189 | |
| 190 | - wp_die(); |
|
| 191 | - } |
|
| 190 | + wp_die(); |
|
| 191 | + } |
|
| 192 | 192 | |
| 193 | - /** |
|
| 194 | - * Load a single field in the form builder along with all needed variables |
|
| 195 | - */ |
|
| 196 | - public static function include_single_field( $field_id, $values, $form_id = 0 ) { |
|
| 197 | - $field = FrmFieldsHelper::setup_edit_vars(FrmField::getOne($field_id)); |
|
| 198 | - $field_name = 'item_meta['. $field_id .']'; |
|
| 199 | - $html_id = FrmFieldsHelper::get_html_id($field); |
|
| 200 | - $id = $form_id ? $form_id : $field['form_id']; |
|
| 201 | - if ( $field['type'] == 'html' ) { |
|
| 202 | - $field['stop_filter'] = true; |
|
| 203 | - } |
|
| 193 | + /** |
|
| 194 | + * Load a single field in the form builder along with all needed variables |
|
| 195 | + */ |
|
| 196 | + public static function include_single_field( $field_id, $values, $form_id = 0 ) { |
|
| 197 | + $field = FrmFieldsHelper::setup_edit_vars(FrmField::getOne($field_id)); |
|
| 198 | + $field_name = 'item_meta['. $field_id .']'; |
|
| 199 | + $html_id = FrmFieldsHelper::get_html_id($field); |
|
| 200 | + $id = $form_id ? $form_id : $field['form_id']; |
|
| 201 | + if ( $field['type'] == 'html' ) { |
|
| 202 | + $field['stop_filter'] = true; |
|
| 203 | + } |
|
| 204 | 204 | |
| 205 | - require(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/add_field.php'); |
|
| 205 | + require(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/add_field.php'); |
|
| 206 | 206 | |
| 207 | - return $field; |
|
| 208 | - } |
|
| 207 | + return $field; |
|
| 208 | + } |
|
| 209 | 209 | |
| 210 | - public static function destroy() { |
|
| 211 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 210 | + public static function destroy() { |
|
| 211 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 212 | 212 | |
| 213 | 213 | $field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' ); |
| 214 | 214 | FrmField::destroy( $field_id ); |
| 215 | - wp_die(); |
|
| 216 | - } |
|
| 215 | + wp_die(); |
|
| 216 | + } |
|
| 217 | 217 | |
| 218 | - /* Field Options */ |
|
| 218 | + /* Field Options */ |
|
| 219 | 219 | |
| 220 | - //Add Single Option or Other Option |
|
| 221 | - public static function add_option() { |
|
| 222 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 220 | + //Add Single Option or Other Option |
|
| 221 | + public static function add_option() { |
|
| 222 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 223 | 223 | |
| 224 | 224 | $id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' ); |
| 225 | 225 | $opt_type = FrmAppHelper::get_post_param( 'opt_type', '', 'sanitize_text_field' ); |
| 226 | 226 | |
| 227 | - //Get the field |
|
| 228 | - $field = FrmField::getOne($id); |
|
| 227 | + //Get the field |
|
| 228 | + $field = FrmField::getOne($id); |
|
| 229 | 229 | |
| 230 | 230 | if ( ! empty( $field->options ) ) { |
| 231 | 231 | $keys = array_keys( $field->options ); |
| 232 | - $last = str_replace( 'other_', '', end( $keys ) ); |
|
| 233 | - } else { |
|
| 234 | - $last = 0; |
|
| 235 | - } |
|
| 236 | - $opt_key = $last + 1; |
|
| 232 | + $last = str_replace( 'other_', '', end( $keys ) ); |
|
| 233 | + } else { |
|
| 234 | + $last = 0; |
|
| 235 | + } |
|
| 236 | + $opt_key = $last + 1; |
|
| 237 | 237 | |
| 238 | - if ( 'other' == $opt_type ) { |
|
| 238 | + if ( 'other' == $opt_type ) { |
|
| 239 | 239 | $opt = esc_html__( 'Other', 'formidable' ); |
| 240 | - $other_val = ''; |
|
| 241 | - $opt_key = 'other_' . $opt_key; |
|
| 242 | - |
|
| 243 | - //Update value of "other" in DB |
|
| 244 | - $field_options = maybe_unserialize( $field->field_options ); |
|
| 245 | - $field_options['other'] = 1; |
|
| 246 | - FrmField::update( $id, array( 'field_options' => maybe_serialize( $field_options ) ) ); |
|
| 247 | - } else { |
|
| 240 | + $other_val = ''; |
|
| 241 | + $opt_key = 'other_' . $opt_key; |
|
| 242 | + |
|
| 243 | + //Update value of "other" in DB |
|
| 244 | + $field_options = maybe_unserialize( $field->field_options ); |
|
| 245 | + $field_options['other'] = 1; |
|
| 246 | + FrmField::update( $id, array( 'field_options' => maybe_serialize( $field_options ) ) ); |
|
| 247 | + } else { |
|
| 248 | 248 | $first_opt = reset( $field->options ); |
| 249 | 249 | $next_opt = count( $field->options ); |
| 250 | - if ( $first_opt != '' ) { |
|
| 251 | - $next_opt++; |
|
| 252 | - } |
|
| 253 | - $opt = esc_html__( 'Option', 'formidable' ) .' '. $next_opt; |
|
| 254 | - unset($next_opt); |
|
| 255 | - } |
|
| 256 | - $field_val = $opt; |
|
| 250 | + if ( $first_opt != '' ) { |
|
| 251 | + $next_opt++; |
|
| 252 | + } |
|
| 253 | + $opt = esc_html__( 'Option', 'formidable' ) .' '. $next_opt; |
|
| 254 | + unset($next_opt); |
|
| 255 | + } |
|
| 256 | + $field_val = $opt; |
|
| 257 | 257 | $field->options[ $opt_key ] = $opt; |
| 258 | 258 | |
| 259 | - //Update options in DB |
|
| 259 | + //Update options in DB |
|
| 260 | 260 | FrmField::update( $id, array( 'options' => $field->options ) ); |
| 261 | 261 | |
| 262 | - $field_data = $field; |
|
| 263 | - $field = array( |
|
| 264 | - 'type' => $field_data->type, |
|
| 265 | - 'id' => $id, |
|
| 266 | - 'separate_value' => isset($field_data->field_options['separate_value']) ? $field_data->field_options['separate_value'] : 0, |
|
| 267 | - 'form_id' => $field_data->form_id, |
|
| 268 | - 'field_key' => $field_data->field_key, |
|
| 269 | - ); |
|
| 270 | - |
|
| 271 | - $field_name = 'item_meta['. $id .']'; |
|
| 272 | - $html_id = FrmFieldsHelper::get_html_id($field); |
|
| 273 | - $checked = ''; |
|
| 274 | - |
|
| 275 | - if ( 'other' == $opt_type ) { |
|
| 276 | - require(FrmAppHelper::plugin_path() .'/pro/classes/views/frmpro-fields/other-option.php'); |
|
| 277 | - } else { |
|
| 278 | - require(FrmAppHelper::plugin_path() .'/classes/views/frm-fields/single-option.php'); |
|
| 279 | - } |
|
| 280 | - wp_die(); |
|
| 281 | - } |
|
| 282 | - |
|
| 283 | - public static function edit_option() { |
|
| 284 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 262 | + $field_data = $field; |
|
| 263 | + $field = array( |
|
| 264 | + 'type' => $field_data->type, |
|
| 265 | + 'id' => $id, |
|
| 266 | + 'separate_value' => isset($field_data->field_options['separate_value']) ? $field_data->field_options['separate_value'] : 0, |
|
| 267 | + 'form_id' => $field_data->form_id, |
|
| 268 | + 'field_key' => $field_data->field_key, |
|
| 269 | + ); |
|
| 270 | + |
|
| 271 | + $field_name = 'item_meta['. $id .']'; |
|
| 272 | + $html_id = FrmFieldsHelper::get_html_id($field); |
|
| 273 | + $checked = ''; |
|
| 274 | + |
|
| 275 | + if ( 'other' == $opt_type ) { |
|
| 276 | + require(FrmAppHelper::plugin_path() .'/pro/classes/views/frmpro-fields/other-option.php'); |
|
| 277 | + } else { |
|
| 278 | + require(FrmAppHelper::plugin_path() .'/classes/views/frm-fields/single-option.php'); |
|
| 279 | + } |
|
| 280 | + wp_die(); |
|
| 281 | + } |
|
| 282 | + |
|
| 283 | + public static function edit_option() { |
|
| 284 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 285 | 285 | |
| 286 | 286 | $element_id = FrmAppHelper::get_post_param( 'element_id', '', 'sanitize_title' ); |
| 287 | 287 | $ids = explode( '-', $element_id ); |
@@ -289,42 +289,42 @@ discard block |
||
| 289 | 289 | |
| 290 | 290 | $orig_update_value = $update_value = trim( FrmAppHelper::get_post_param( 'update_value' ) ); |
| 291 | 291 | if ( strpos( $element_id, 'key_' ) ) { |
| 292 | - $new_value = $update_value; |
|
| 293 | - } else { |
|
| 294 | - $new_label = $update_value; |
|
| 295 | - } |
|
| 292 | + $new_value = $update_value; |
|
| 293 | + } else { |
|
| 294 | + $new_label = $update_value; |
|
| 295 | + } |
|
| 296 | 296 | |
| 297 | - $field = FrmField::getOne($id); |
|
| 298 | - $separate_values = FrmField::is_option_true( $field, 'separate_value' ); |
|
| 297 | + $field = FrmField::getOne($id); |
|
| 298 | + $separate_values = FrmField::is_option_true( $field, 'separate_value' ); |
|
| 299 | 299 | |
| 300 | - $this_opt_id = end($ids); |
|
| 300 | + $this_opt_id = end($ids); |
|
| 301 | 301 | $this_opt = (array) $field->options[ $this_opt_id ]; |
| 302 | - $other_opt = ( $this_opt_id && strpos( $this_opt_id, 'other') !== false ? true : false ); |
|
| 302 | + $other_opt = ( $this_opt_id && strpos( $this_opt_id, 'other') !== false ? true : false ); |
|
| 303 | 303 | |
| 304 | - $label = isset($this_opt['label']) ? $this_opt['label'] : reset($this_opt); |
|
| 305 | - $value = isset($this_opt['value']) ? $this_opt['value'] : ''; |
|
| 304 | + $label = isset($this_opt['label']) ? $this_opt['label'] : reset($this_opt); |
|
| 305 | + $value = isset($this_opt['value']) ? $this_opt['value'] : ''; |
|
| 306 | 306 | |
| 307 | - if ( ! isset( $new_label ) ) { |
|
| 308 | - $new_label = $label; |
|
| 309 | - } |
|
| 307 | + if ( ! isset( $new_label ) ) { |
|
| 308 | + $new_label = $label; |
|
| 309 | + } |
|
| 310 | 310 | |
| 311 | - if ( isset($new_value) || isset($value) ) { |
|
| 312 | - $update_value = isset($new_value) ? $new_value : $value; |
|
| 313 | - } |
|
| 311 | + if ( isset($new_value) || isset($value) ) { |
|
| 312 | + $update_value = isset($new_value) ? $new_value : $value; |
|
| 313 | + } |
|
| 314 | 314 | |
| 315 | 315 | if ( $update_value != $new_label && $other_opt === false && $separate_values ) { |
| 316 | 316 | $field->options[ $this_opt_id ] = array( 'value' => $update_value, 'label' => $new_label ); |
| 317 | - } else { |
|
| 317 | + } else { |
|
| 318 | 318 | $field->options[ $this_opt_id ] = $orig_update_value; |
| 319 | - } |
|
| 319 | + } |
|
| 320 | 320 | |
| 321 | 321 | FrmField::update( $field->id, array( 'options' => $field->options ) ); |
| 322 | 322 | echo ( $orig_update_value == '' ) ? esc_html__( '(Blank)', 'formidable' ) : stripslashes( $orig_update_value ); |
| 323 | - wp_die(); |
|
| 324 | - } |
|
| 323 | + wp_die(); |
|
| 324 | + } |
|
| 325 | 325 | |
| 326 | - public static function delete_option() { |
|
| 327 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 326 | + public static function delete_option() { |
|
| 327 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 328 | 328 | |
| 329 | 329 | $field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' ); |
| 330 | 330 | $field = FrmField::getOne( $field_id ); |
@@ -332,339 +332,339 @@ discard block |
||
| 332 | 332 | $opt_key = FrmAppHelper::get_post_param( 'opt_key', 0, 'sanitize_title' ); |
| 333 | 333 | |
| 334 | 334 | $options = $field->options; |
| 335 | - unset( $options[ $opt_key ] ); |
|
| 336 | - $response = array( 'other' => true ); |
|
| 335 | + unset( $options[ $opt_key ] ); |
|
| 336 | + $response = array( 'other' => true ); |
|
| 337 | 337 | |
| 338 | - //If the deleted option is an "other" option |
|
| 338 | + //If the deleted option is an "other" option |
|
| 339 | 339 | if ( FrmFieldsHelper::is_other_opt( $opt_key ) ) { |
| 340 | - //Assume all other options are gone, unless proven otherwise |
|
| 341 | - $other = false; |
|
| 340 | + //Assume all other options are gone, unless proven otherwise |
|
| 341 | + $other = false; |
|
| 342 | 342 | |
| 343 | - //Check if all other options are really gone |
|
| 344 | - foreach ( $options as $o_key => $o_val ) { |
|
| 345 | - //If there is still an other option in the field, set other to true |
|
| 343 | + //Check if all other options are really gone |
|
| 344 | + foreach ( $options as $o_key => $o_val ) { |
|
| 345 | + //If there is still an other option in the field, set other to true |
|
| 346 | 346 | if ( FrmFieldsHelper::is_other_opt( $o_key ) ) { |
| 347 | - $other = true; |
|
| 348 | - break; |
|
| 349 | - } |
|
| 350 | - unset( $o_key, $o_val ); |
|
| 351 | - } |
|
| 352 | - |
|
| 353 | - //If all other options are gone |
|
| 354 | - if ( false === $other ) { |
|
| 355 | - $field_options = maybe_unserialize( $field->field_options ); |
|
| 356 | - $field_options['other'] = 0; |
|
| 347 | + $other = true; |
|
| 348 | + break; |
|
| 349 | + } |
|
| 350 | + unset( $o_key, $o_val ); |
|
| 351 | + } |
|
| 352 | + |
|
| 353 | + //If all other options are gone |
|
| 354 | + if ( false === $other ) { |
|
| 355 | + $field_options = maybe_unserialize( $field->field_options ); |
|
| 356 | + $field_options['other'] = 0; |
|
| 357 | 357 | FrmField::update( $field_id, array( 'field_options' => maybe_serialize( $field_options ) ) ); |
| 358 | - $response = array( 'other' => false ); |
|
| 359 | - } |
|
| 360 | - } |
|
| 361 | - echo json_encode( $response ); |
|
| 358 | + $response = array( 'other' => false ); |
|
| 359 | + } |
|
| 360 | + } |
|
| 361 | + echo json_encode( $response ); |
|
| 362 | 362 | |
| 363 | 363 | FrmField::update( $field_id, array( 'options' => maybe_serialize( $options ) ) ); |
| 364 | 364 | |
| 365 | - wp_die(); |
|
| 366 | - } |
|
| 365 | + wp_die(); |
|
| 366 | + } |
|
| 367 | 367 | |
| 368 | - public static function import_choices() { |
|
| 369 | - if ( ! current_user_can( 'frm_edit_forms' ) ) { |
|
| 370 | - wp_die(); |
|
| 371 | - } |
|
| 368 | + public static function import_choices() { |
|
| 369 | + if ( ! current_user_can( 'frm_edit_forms' ) ) { |
|
| 370 | + wp_die(); |
|
| 371 | + } |
|
| 372 | 372 | |
| 373 | 373 | $field_id = absint( $_REQUEST['field_id'] ); |
| 374 | 374 | |
| 375 | - global $current_screen, $hook_suffix; |
|
| 375 | + global $current_screen, $hook_suffix; |
|
| 376 | 376 | |
| 377 | - // Catch plugins that include admin-header.php before admin.php completes. |
|
| 378 | - if ( empty( $current_screen ) && function_exists( 'set_current_screen' ) ) { |
|
| 379 | - $hook_suffix = ''; |
|
| 380 | - set_current_screen(); |
|
| 381 | - } |
|
| 377 | + // Catch plugins that include admin-header.php before admin.php completes. |
|
| 378 | + if ( empty( $current_screen ) && function_exists( 'set_current_screen' ) ) { |
|
| 379 | + $hook_suffix = ''; |
|
| 380 | + set_current_screen(); |
|
| 381 | + } |
|
| 382 | 382 | |
| 383 | - if ( function_exists( 'register_admin_color_schemes' ) ) { |
|
| 384 | - register_admin_color_schemes(); |
|
| 385 | - } |
|
| 383 | + if ( function_exists( 'register_admin_color_schemes' ) ) { |
|
| 384 | + register_admin_color_schemes(); |
|
| 385 | + } |
|
| 386 | 386 | |
| 387 | - $hook_suffix = $admin_body_class = ''; |
|
| 387 | + $hook_suffix = $admin_body_class = ''; |
|
| 388 | 388 | |
| 389 | - if ( get_user_setting( 'mfold' ) == 'f' ) { |
|
| 390 | - $admin_body_class .= ' folded'; |
|
| 391 | - } |
|
| 389 | + if ( get_user_setting( 'mfold' ) == 'f' ) { |
|
| 390 | + $admin_body_class .= ' folded'; |
|
| 391 | + } |
|
| 392 | 392 | |
| 393 | - if ( function_exists( 'is_admin_bar_showing' ) && is_admin_bar_showing() ) { |
|
| 394 | - $admin_body_class .= ' admin-bar'; |
|
| 395 | - } |
|
| 393 | + if ( function_exists( 'is_admin_bar_showing' ) && is_admin_bar_showing() ) { |
|
| 394 | + $admin_body_class .= ' admin-bar'; |
|
| 395 | + } |
|
| 396 | 396 | |
| 397 | - if ( is_rtl() ) { |
|
| 398 | - $admin_body_class .= ' rtl'; |
|
| 399 | - } |
|
| 397 | + if ( is_rtl() ) { |
|
| 398 | + $admin_body_class .= ' rtl'; |
|
| 399 | + } |
|
| 400 | 400 | |
| 401 | - $admin_body_class .= ' admin-color-' . sanitize_html_class( get_user_option( 'admin_color' ), 'fresh' ); |
|
| 402 | - $prepop = array(); |
|
| 403 | - FrmFieldsHelper::get_bulk_prefilled_opts($prepop); |
|
| 401 | + $admin_body_class .= ' admin-color-' . sanitize_html_class( get_user_option( 'admin_color' ), 'fresh' ); |
|
| 402 | + $prepop = array(); |
|
| 403 | + FrmFieldsHelper::get_bulk_prefilled_opts($prepop); |
|
| 404 | 404 | |
| 405 | - $field = FrmField::getOne($field_id); |
|
| 405 | + $field = FrmField::getOne($field_id); |
|
| 406 | 406 | |
| 407 | - wp_enqueue_script( 'utils' ); |
|
| 408 | - wp_enqueue_style( 'formidable-admin', FrmAppHelper::plugin_url(). '/css/frm_admin.css' ); |
|
| 409 | - FrmAppHelper::load_admin_wide_js(); |
|
| 407 | + wp_enqueue_script( 'utils' ); |
|
| 408 | + wp_enqueue_style( 'formidable-admin', FrmAppHelper::plugin_url(). '/css/frm_admin.css' ); |
|
| 409 | + FrmAppHelper::load_admin_wide_js(); |
|
| 410 | 410 | |
| 411 | - include(FrmAppHelper::plugin_path() .'/classes/views/frm-fields/import_choices.php'); |
|
| 412 | - wp_die(); |
|
| 413 | - } |
|
| 411 | + include(FrmAppHelper::plugin_path() .'/classes/views/frm-fields/import_choices.php'); |
|
| 412 | + wp_die(); |
|
| 413 | + } |
|
| 414 | 414 | |
| 415 | - public static function import_options() { |
|
| 416 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 415 | + public static function import_options() { |
|
| 416 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 417 | 417 | |
| 418 | - if ( ! is_admin() || ! current_user_can('frm_edit_forms') ) { |
|
| 419 | - return; |
|
| 420 | - } |
|
| 418 | + if ( ! is_admin() || ! current_user_can('frm_edit_forms') ) { |
|
| 419 | + return; |
|
| 420 | + } |
|
| 421 | 421 | |
| 422 | 422 | $field_id = absint( $_POST['field_id'] ); |
| 423 | - $field = FrmField::getOne($field_id); |
|
| 423 | + $field = FrmField::getOne($field_id); |
|
| 424 | 424 | |
| 425 | 425 | if ( ! in_array( $field->type, array( 'radio', 'checkbox', 'select' ) ) ) { |
| 426 | - return; |
|
| 427 | - } |
|
| 428 | - |
|
| 429 | - $field = FrmFieldsHelper::setup_edit_vars($field); |
|
| 430 | - $opts = stripslashes_deep($_POST['opts']); |
|
| 431 | - $opts = explode("\n", rtrim($opts, "\n")); |
|
| 432 | - if ( $field['separate_value'] ) { |
|
| 433 | - foreach ( $opts as $opt_key => $opt ) { |
|
| 434 | - if ( strpos($opt, '|') !== false ) { |
|
| 435 | - $vals = explode('|', $opt); |
|
| 436 | - if ( $vals[0] != $vals[1] ) { |
|
| 437 | - $opts[ $opt_key ] = array( 'label' => trim( $vals[0] ), 'value' => trim( $vals[1] ) ); |
|
| 438 | - } |
|
| 439 | - unset($vals); |
|
| 440 | - } |
|
| 441 | - unset($opt_key, $opt); |
|
| 442 | - } |
|
| 443 | - } |
|
| 444 | - |
|
| 445 | - //Keep other options after bulk update |
|
| 446 | - if ( isset( $field['field_options']['other'] ) && $field['field_options']['other'] == true ) { |
|
| 447 | - $other_array = array(); |
|
| 448 | - foreach ( $field['options'] as $opt_key => $opt ) { |
|
| 449 | - if ( $opt_key && strpos( $opt_key, 'other' ) !== false ) { |
|
| 450 | - $other_array[ $opt_key ] = $opt; |
|
| 451 | - } |
|
| 452 | - unset($opt_key, $opt); |
|
| 453 | - } |
|
| 454 | - if ( ! empty($other_array) ) { |
|
| 455 | - $opts = array_merge( $opts, $other_array); |
|
| 456 | - } |
|
| 457 | - } |
|
| 458 | - |
|
| 459 | - FrmField::update( $field_id, array( 'options' => maybe_serialize( $opts ) ) ); |
|
| 460 | - |
|
| 461 | - $field['options'] = $opts; |
|
| 462 | - $field_name = $field['name']; |
|
| 463 | - |
|
| 464 | - // Get html_id which will be used in single-option.php |
|
| 465 | - $html_id = FrmFieldsHelper::get_html_id( $field ); |
|
| 466 | - |
|
| 467 | - if ( $field['type'] == 'radio' || $field['type'] == 'checkbox' ) { |
|
| 468 | - require(FrmAppHelper::plugin_path() .'/classes/views/frm-fields/radio.php'); |
|
| 469 | - } else { |
|
| 470 | - FrmFieldsHelper::show_single_option($field); |
|
| 471 | - } |
|
| 472 | - |
|
| 473 | - wp_die(); |
|
| 474 | - } |
|
| 475 | - |
|
| 476 | - public static function update_order() { |
|
| 477 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 426 | + return; |
|
| 427 | + } |
|
| 428 | + |
|
| 429 | + $field = FrmFieldsHelper::setup_edit_vars($field); |
|
| 430 | + $opts = stripslashes_deep($_POST['opts']); |
|
| 431 | + $opts = explode("\n", rtrim($opts, "\n")); |
|
| 432 | + if ( $field['separate_value'] ) { |
|
| 433 | + foreach ( $opts as $opt_key => $opt ) { |
|
| 434 | + if ( strpos($opt, '|') !== false ) { |
|
| 435 | + $vals = explode('|', $opt); |
|
| 436 | + if ( $vals[0] != $vals[1] ) { |
|
| 437 | + $opts[ $opt_key ] = array( 'label' => trim( $vals[0] ), 'value' => trim( $vals[1] ) ); |
|
| 438 | + } |
|
| 439 | + unset($vals); |
|
| 440 | + } |
|
| 441 | + unset($opt_key, $opt); |
|
| 442 | + } |
|
| 443 | + } |
|
| 444 | + |
|
| 445 | + //Keep other options after bulk update |
|
| 446 | + if ( isset( $field['field_options']['other'] ) && $field['field_options']['other'] == true ) { |
|
| 447 | + $other_array = array(); |
|
| 448 | + foreach ( $field['options'] as $opt_key => $opt ) { |
|
| 449 | + if ( $opt_key && strpos( $opt_key, 'other' ) !== false ) { |
|
| 450 | + $other_array[ $opt_key ] = $opt; |
|
| 451 | + } |
|
| 452 | + unset($opt_key, $opt); |
|
| 453 | + } |
|
| 454 | + if ( ! empty($other_array) ) { |
|
| 455 | + $opts = array_merge( $opts, $other_array); |
|
| 456 | + } |
|
| 457 | + } |
|
| 458 | + |
|
| 459 | + FrmField::update( $field_id, array( 'options' => maybe_serialize( $opts ) ) ); |
|
| 460 | + |
|
| 461 | + $field['options'] = $opts; |
|
| 462 | + $field_name = $field['name']; |
|
| 463 | + |
|
| 464 | + // Get html_id which will be used in single-option.php |
|
| 465 | + $html_id = FrmFieldsHelper::get_html_id( $field ); |
|
| 466 | + |
|
| 467 | + if ( $field['type'] == 'radio' || $field['type'] == 'checkbox' ) { |
|
| 468 | + require(FrmAppHelper::plugin_path() .'/classes/views/frm-fields/radio.php'); |
|
| 469 | + } else { |
|
| 470 | + FrmFieldsHelper::show_single_option($field); |
|
| 471 | + } |
|
| 472 | + |
|
| 473 | + wp_die(); |
|
| 474 | + } |
|
| 475 | + |
|
| 476 | + public static function update_order() { |
|
| 477 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 478 | 478 | $fields = FrmAppHelper::get_post_param( 'frm_field_id' ); |
| 479 | 479 | foreach ( (array) $fields as $position => $item ) { |
| 480 | 480 | FrmField::update( absint( $item ), array( 'field_order' => absint( $position ) ) ); |
| 481 | 481 | } |
| 482 | - wp_die(); |
|
| 483 | - } |
|
| 482 | + wp_die(); |
|
| 483 | + } |
|
| 484 | 484 | |
| 485 | 485 | public static function change_type( $type ) { |
| 486 | - $type_switch = array( |
|
| 487 | - 'scale' => 'radio', |
|
| 488 | - '10radio' => 'radio', |
|
| 489 | - 'rte' => 'textarea', |
|
| 490 | - 'website' => 'url', |
|
| 491 | - ); |
|
| 492 | - if ( isset( $type_switch[ $type ] ) ) { |
|
| 493 | - $type = $type_switch[ $type ]; |
|
| 494 | - } |
|
| 486 | + $type_switch = array( |
|
| 487 | + 'scale' => 'radio', |
|
| 488 | + '10radio' => 'radio', |
|
| 489 | + 'rte' => 'textarea', |
|
| 490 | + 'website' => 'url', |
|
| 491 | + ); |
|
| 492 | + if ( isset( $type_switch[ $type ] ) ) { |
|
| 493 | + $type = $type_switch[ $type ]; |
|
| 494 | + } |
|
| 495 | 495 | |
| 496 | 496 | $frm_field_selection = FrmField::field_selection(); |
| 497 | - $types = array_keys($frm_field_selection); |
|
| 498 | - if ( ! in_array($type, $types) && $type != 'captcha' ) { |
|
| 499 | - $type = 'text'; |
|
| 500 | - } |
|
| 497 | + $types = array_keys($frm_field_selection); |
|
| 498 | + if ( ! in_array($type, $types) && $type != 'captcha' ) { |
|
| 499 | + $type = 'text'; |
|
| 500 | + } |
|
| 501 | 501 | |
| 502 | - return $type; |
|
| 503 | - } |
|
| 502 | + return $type; |
|
| 503 | + } |
|
| 504 | 504 | |
| 505 | 505 | public static function display_field_options( $display ) { |
| 506 | 506 | switch ( $display['type'] ) { |
| 507 | - case 'captcha': |
|
| 508 | - $display['required'] = false; |
|
| 509 | - $display['invalid'] = true; |
|
| 510 | - $display['default_blank'] = false; |
|
| 507 | + case 'captcha': |
|
| 508 | + $display['required'] = false; |
|
| 509 | + $display['invalid'] = true; |
|
| 510 | + $display['default_blank'] = false; |
|
| 511 | 511 | $display['captcha_size'] = true; |
| 512 | - break; |
|
| 513 | - case 'radio': |
|
| 514 | - $display['default_blank'] = false; |
|
| 515 | - break; |
|
| 516 | - case 'text': |
|
| 517 | - case 'textarea': |
|
| 518 | - $display['size'] = true; |
|
| 519 | - $display['clear_on_focus'] = true; |
|
| 520 | - break; |
|
| 521 | - case 'select': |
|
| 522 | - $display['size'] = true; |
|
| 523 | - break; |
|
| 524 | - case 'url': |
|
| 525 | - case 'website': |
|
| 526 | - case 'email': |
|
| 527 | - $display['size'] = true; |
|
| 528 | - $display['clear_on_focus'] = true; |
|
| 529 | - $display['invalid'] = true; |
|
| 530 | - } |
|
| 531 | - |
|
| 532 | - return $display; |
|
| 533 | - } |
|
| 534 | - |
|
| 535 | - public static function input_html( $field, $echo = true ) { |
|
| 536 | - $class = array(); //$field['type']; |
|
| 537 | - self::add_input_classes($field, $class); |
|
| 538 | - |
|
| 539 | - $add_html = array(); |
|
| 540 | - self::add_html_size($field, $add_html); |
|
| 541 | - self::add_html_length($field, $add_html); |
|
| 542 | - self::add_html_placeholder($field, $add_html, $class); |
|
| 512 | + break; |
|
| 513 | + case 'radio': |
|
| 514 | + $display['default_blank'] = false; |
|
| 515 | + break; |
|
| 516 | + case 'text': |
|
| 517 | + case 'textarea': |
|
| 518 | + $display['size'] = true; |
|
| 519 | + $display['clear_on_focus'] = true; |
|
| 520 | + break; |
|
| 521 | + case 'select': |
|
| 522 | + $display['size'] = true; |
|
| 523 | + break; |
|
| 524 | + case 'url': |
|
| 525 | + case 'website': |
|
| 526 | + case 'email': |
|
| 527 | + $display['size'] = true; |
|
| 528 | + $display['clear_on_focus'] = true; |
|
| 529 | + $display['invalid'] = true; |
|
| 530 | + } |
|
| 531 | + |
|
| 532 | + return $display; |
|
| 533 | + } |
|
| 534 | + |
|
| 535 | + public static function input_html( $field, $echo = true ) { |
|
| 536 | + $class = array(); //$field['type']; |
|
| 537 | + self::add_input_classes($field, $class); |
|
| 538 | + |
|
| 539 | + $add_html = array(); |
|
| 540 | + self::add_html_size($field, $add_html); |
|
| 541 | + self::add_html_length($field, $add_html); |
|
| 542 | + self::add_html_placeholder($field, $add_html, $class); |
|
| 543 | 543 | //self::add_validation_messages( $field, $add_html ); uncomment this when the js validation is complete |
| 544 | 544 | |
| 545 | - $class = apply_filters('frm_field_classes', implode(' ', $class), $field); |
|
| 545 | + $class = apply_filters('frm_field_classes', implode(' ', $class), $field); |
|
| 546 | 546 | |
| 547 | 547 | FrmFormsHelper::add_html_attr( $class, 'class', $add_html ); |
| 548 | 548 | |
| 549 | - self::add_shortcodes_to_html($field, $add_html); |
|
| 549 | + self::add_shortcodes_to_html($field, $add_html); |
|
| 550 | 550 | |
| 551 | 551 | $add_html = apply_filters( 'frm_field_extra_html', $add_html, $field ); |
| 552 | 552 | $add_html = ' ' . implode( ' ', $add_html ) . ' '; |
| 553 | 553 | |
| 554 | - if ( $echo ) { |
|
| 555 | - echo $add_html; |
|
| 556 | - } |
|
| 554 | + if ( $echo ) { |
|
| 555 | + echo $add_html; |
|
| 556 | + } |
|
| 557 | 557 | |
| 558 | - return $add_html; |
|
| 559 | - } |
|
| 558 | + return $add_html; |
|
| 559 | + } |
|
| 560 | 560 | |
| 561 | 561 | private static function add_input_classes( $field, array &$class ) { |
| 562 | - if ( isset($field['input_class']) && ! empty($field['input_class']) ) { |
|
| 563 | - $class[] = $field['input_class']; |
|
| 564 | - } |
|
| 562 | + if ( isset($field['input_class']) && ! empty($field['input_class']) ) { |
|
| 563 | + $class[] = $field['input_class']; |
|
| 564 | + } |
|
| 565 | 565 | |
| 566 | - if ( $field['type'] == 'hidden' || $field['type'] == 'user_id' ) { |
|
| 567 | - return; |
|
| 568 | - } |
|
| 566 | + if ( $field['type'] == 'hidden' || $field['type'] == 'user_id' ) { |
|
| 567 | + return; |
|
| 568 | + } |
|
| 569 | 569 | |
| 570 | - global $frm_vars; |
|
| 570 | + global $frm_vars; |
|
| 571 | 571 | if ( is_admin() && ! FrmAppHelper::is_preview_page() && ! in_array( $field['type'], array( 'scale', 'radio', 'checkbox', 'data' ) ) ) { |
| 572 | - $class[] = 'dyn_default_value'; |
|
| 573 | - } |
|
| 572 | + $class[] = 'dyn_default_value'; |
|
| 573 | + } |
|
| 574 | 574 | |
| 575 | - if ( isset($field['size']) && $field['size'] > 0 ) { |
|
| 576 | - $class[] = 'auto_width'; |
|
| 577 | - } |
|
| 578 | - } |
|
| 575 | + if ( isset($field['size']) && $field['size'] > 0 ) { |
|
| 576 | + $class[] = 'auto_width'; |
|
| 577 | + } |
|
| 578 | + } |
|
| 579 | 579 | |
| 580 | 580 | private static function add_html_size( $field, array &$add_html ) { |
| 581 | 581 | if ( ! isset( $field['size'] ) || $field['size'] <= 0 || in_array( $field['type'], array( 'select', 'data', 'time', 'hidden' ) ) ) { |
| 582 | - return; |
|
| 583 | - } |
|
| 582 | + return; |
|
| 583 | + } |
|
| 584 | 584 | |
| 585 | - if ( FrmAppHelper::is_admin_page('formidable' ) ) { |
|
| 586 | - return; |
|
| 587 | - } |
|
| 585 | + if ( FrmAppHelper::is_admin_page('formidable' ) ) { |
|
| 586 | + return; |
|
| 587 | + } |
|
| 588 | 588 | |
| 589 | - if ( is_numeric($field['size']) ) { |
|
| 590 | - $field['size'] .= 'px'; |
|
| 591 | - } |
|
| 589 | + if ( is_numeric($field['size']) ) { |
|
| 590 | + $field['size'] .= 'px'; |
|
| 591 | + } |
|
| 592 | 592 | |
| 593 | - $important = apply_filters('frm_use_important_width', 1, $field); |
|
| 594 | - // Note: This inline styling must stay since we cannot realistically set a class for every possible field size |
|
| 595 | - $add_html['style'] = 'style="width:'. esc_attr( $field['size'] ) . ( $important ? ' !important' : '' ) .'"'; |
|
| 593 | + $important = apply_filters('frm_use_important_width', 1, $field); |
|
| 594 | + // Note: This inline styling must stay since we cannot realistically set a class for every possible field size |
|
| 595 | + $add_html['style'] = 'style="width:'. esc_attr( $field['size'] ) . ( $important ? ' !important' : '' ) .'"'; |
|
| 596 | 596 | |
| 597 | - self::add_html_cols($field, $add_html); |
|
| 598 | - } |
|
| 597 | + self::add_html_cols($field, $add_html); |
|
| 598 | + } |
|
| 599 | 599 | |
| 600 | 600 | private static function add_html_cols( $field, array &$add_html ) { |
| 601 | 601 | if ( ! in_array( $field['type'], array( 'textarea', 'rte' ) ) ) { |
| 602 | - return; |
|
| 603 | - } |
|
| 602 | + return; |
|
| 603 | + } |
|
| 604 | 604 | |
| 605 | - // convert to cols for textareas |
|
| 606 | - $calc = array( |
|
| 607 | - '' => 9, |
|
| 608 | - 'px' => 9, |
|
| 609 | - 'rem' => 0.444, |
|
| 610 | - 'em' => 0.544, |
|
| 611 | - ); |
|
| 605 | + // convert to cols for textareas |
|
| 606 | + $calc = array( |
|
| 607 | + '' => 9, |
|
| 608 | + 'px' => 9, |
|
| 609 | + 'rem' => 0.444, |
|
| 610 | + 'em' => 0.544, |
|
| 611 | + ); |
|
| 612 | 612 | |
| 613 | - // include "col" for valid html |
|
| 614 | - $unit = trim(preg_replace('/[0-9]+/', '', $field['size'])); |
|
| 613 | + // include "col" for valid html |
|
| 614 | + $unit = trim(preg_replace('/[0-9]+/', '', $field['size'])); |
|
| 615 | 615 | |
| 616 | - if ( ! isset( $calc[ $unit ] ) ) { |
|
| 617 | - return; |
|
| 618 | - } |
|
| 616 | + if ( ! isset( $calc[ $unit ] ) ) { |
|
| 617 | + return; |
|
| 618 | + } |
|
| 619 | 619 | |
| 620 | - $size = (float) str_replace( $unit, '', $field['size'] ) / $calc[ $unit ]; |
|
| 620 | + $size = (float) str_replace( $unit, '', $field['size'] ) / $calc[ $unit ]; |
|
| 621 | 621 | |
| 622 | 622 | $add_html['cols'] = 'cols="' . absint( $size ) . '"'; |
| 623 | - } |
|
| 623 | + } |
|
| 624 | 624 | |
| 625 | 625 | private static function add_html_length( $field, array &$add_html ) { |
| 626 | - // check for max setting and if this field accepts maxlength |
|
| 626 | + // check for max setting and if this field accepts maxlength |
|
| 627 | 627 | if ( FrmField::is_option_empty( $field, 'max' ) || in_array( $field['type'], array( 'textarea', 'rte', 'hidden' ) ) ) { |
| 628 | - return; |
|
| 629 | - } |
|
| 628 | + return; |
|
| 629 | + } |
|
| 630 | 630 | |
| 631 | - if ( FrmAppHelper::is_admin_page('formidable' ) ) { |
|
| 632 | - // don't load on form builder page |
|
| 633 | - return; |
|
| 634 | - } |
|
| 631 | + if ( FrmAppHelper::is_admin_page('formidable' ) ) { |
|
| 632 | + // don't load on form builder page |
|
| 633 | + return; |
|
| 634 | + } |
|
| 635 | 635 | |
| 636 | 636 | $add_html['maxlength'] = 'maxlength="' . esc_attr( $field['max'] ) . '"'; |
| 637 | - } |
|
| 637 | + } |
|
| 638 | 638 | |
| 639 | 639 | private static function add_html_placeholder( $field, array &$add_html, array &$class ) { |
| 640 | 640 | if ( empty( $field['default_value'] ) || FrmAppHelper::is_admin_page( 'formidable' ) ) { |
| 641 | 641 | return; |
| 642 | 642 | } |
| 643 | 643 | |
| 644 | - if ( ! FrmField::is_option_true( $field, 'clear_on_focus' ) ) { |
|
| 644 | + if ( ! FrmField::is_option_true( $field, 'clear_on_focus' ) ) { |
|
| 645 | 645 | if ( is_array( $field['default_value'] ) ) { |
| 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 | - $frm_settings = FrmAppHelper::get_settings(); |
|
| 652 | + $frm_settings = FrmAppHelper::get_settings(); |
|
| 653 | 653 | |
| 654 | 654 | if ( $frm_settings->use_html && ! in_array( $field['type'], array( 'select', 'radio', 'checkbox', 'hidden' ) ) ) { |
| 655 | - // use HMTL5 placeholder with js fallback |
|
| 656 | - $add_html['placeholder'] = 'placeholder="'. esc_attr($field['default_value']) .'"'; |
|
| 657 | - wp_enqueue_script('jquery-placeholder'); |
|
| 658 | - } else if ( ! $frm_settings->use_html ) { |
|
| 655 | + // use HMTL5 placeholder with js fallback |
|
| 656 | + $add_html['placeholder'] = 'placeholder="'. esc_attr($field['default_value']) .'"'; |
|
| 657 | + wp_enqueue_script('jquery-placeholder'); |
|
| 658 | + } else if ( ! $frm_settings->use_html ) { |
|
| 659 | 659 | $val = str_replace( array( "\r\n", "\n" ), '\r', addslashes( str_replace( ''', "'", esc_attr( $field['default_value'] ) ) ) ); |
| 660 | - $add_html['data-frmval'] = 'data-frmval="'. esc_attr($val) .'"'; |
|
| 661 | - $class[] = 'frm_toggle_default'; |
|
| 660 | + $add_html['data-frmval'] = 'data-frmval="'. esc_attr($val) .'"'; |
|
| 661 | + $class[] = 'frm_toggle_default'; |
|
| 662 | 662 | |
| 663 | - if ( $field['value'] == $field['default_value'] ) { |
|
| 664 | - $class[] = 'frm_default'; |
|
| 665 | - } |
|
| 666 | - } |
|
| 667 | - } |
|
| 663 | + if ( $field['value'] == $field['default_value'] ) { |
|
| 664 | + $class[] = 'frm_default'; |
|
| 665 | + } |
|
| 666 | + } |
|
| 667 | + } |
|
| 668 | 668 | |
| 669 | 669 | private static function add_validation_messages( $field, array &$add_html ) { |
| 670 | 670 | if ( FrmField::is_required( $field ) ) { |
@@ -685,44 +685,44 @@ discard block |
||
| 685 | 685 | } |
| 686 | 686 | } |
| 687 | 687 | |
| 688 | - private static function add_shortcodes_to_html( $field, array &$add_html ) { |
|
| 689 | - if ( FrmField::is_option_empty( $field, 'shortcodes' ) ) { |
|
| 690 | - return; |
|
| 691 | - } |
|
| 692 | - |
|
| 693 | - foreach ( $field['shortcodes'] as $k => $v ) { |
|
| 694 | - if ( 'opt' === $k ) { |
|
| 695 | - continue; |
|
| 696 | - } |
|
| 697 | - |
|
| 698 | - if ( is_numeric($k) && strpos($v, '=') ) { |
|
| 699 | - $add_html[] = $v; |
|
| 700 | - } else if ( ! empty( $k ) && isset( $add_html[ $k ] ) ) { |
|
| 701 | - $add_html[ $k ] = str_replace( $k .'="', $k .'="'. $v, $add_html[ $k ] ); |
|
| 702 | - } else { |
|
| 688 | + private static function add_shortcodes_to_html( $field, array &$add_html ) { |
|
| 689 | + if ( FrmField::is_option_empty( $field, 'shortcodes' ) ) { |
|
| 690 | + return; |
|
| 691 | + } |
|
| 692 | + |
|
| 693 | + foreach ( $field['shortcodes'] as $k => $v ) { |
|
| 694 | + if ( 'opt' === $k ) { |
|
| 695 | + continue; |
|
| 696 | + } |
|
| 697 | + |
|
| 698 | + if ( is_numeric($k) && strpos($v, '=') ) { |
|
| 699 | + $add_html[] = $v; |
|
| 700 | + } else if ( ! empty( $k ) && isset( $add_html[ $k ] ) ) { |
|
| 701 | + $add_html[ $k ] = str_replace( $k .'="', $k .'="'. $v, $add_html[ $k ] ); |
|
| 702 | + } else { |
|
| 703 | 703 | $add_html[ $k ] = $k . '="' . esc_attr( $v ) . '"'; |
| 704 | - } |
|
| 705 | - |
|
| 706 | - unset($k, $v); |
|
| 707 | - } |
|
| 708 | - } |
|
| 709 | - |
|
| 710 | - public static function check_value( $opt, $opt_key, $field ) { |
|
| 711 | - if ( is_array( $opt ) ) { |
|
| 712 | - if ( FrmField::is_option_true( $field, 'separate_value' ) ) { |
|
| 713 | - $opt = isset( $opt['value'] ) ? $opt['value'] : ( isset( $opt['label'] ) ? $opt['label'] : reset( $opt ) ); |
|
| 714 | - } else { |
|
| 715 | - $opt = isset( $opt['label'] ) ? $opt['label'] : reset( $opt ); |
|
| 716 | - } |
|
| 717 | - } |
|
| 718 | - return $opt; |
|
| 719 | - } |
|
| 704 | + } |
|
| 705 | + |
|
| 706 | + unset($k, $v); |
|
| 707 | + } |
|
| 708 | + } |
|
| 709 | + |
|
| 710 | + public static function check_value( $opt, $opt_key, $field ) { |
|
| 711 | + if ( is_array( $opt ) ) { |
|
| 712 | + if ( FrmField::is_option_true( $field, 'separate_value' ) ) { |
|
| 713 | + $opt = isset( $opt['value'] ) ? $opt['value'] : ( isset( $opt['label'] ) ? $opt['label'] : reset( $opt ) ); |
|
| 714 | + } else { |
|
| 715 | + $opt = isset( $opt['label'] ) ? $opt['label'] : reset( $opt ); |
|
| 716 | + } |
|
| 717 | + } |
|
| 718 | + return $opt; |
|
| 719 | + } |
|
| 720 | 720 | |
| 721 | 721 | public static function check_label( $opt ) { |
| 722 | - if ( is_array($opt) ) { |
|
| 723 | - $opt = (isset($opt['label']) ? $opt['label'] : reset($opt)); |
|
| 724 | - } |
|
| 722 | + if ( is_array($opt) ) { |
|
| 723 | + $opt = (isset($opt['label']) ? $opt['label'] : reset($opt)); |
|
| 724 | + } |
|
| 725 | 725 | |
| 726 | - return $opt; |
|
| 727 | - } |
|
| 726 | + return $opt; |
|
| 727 | + } |
|
| 728 | 728 | } |
@@ -64,8 +64,8 @@ |
||
| 64 | 64 | <a href="<?php echo esc_url( admin_url( 'admin.php?page=formidable-styles&frm_action=destroy&id=' . $style->ID ) ); ?>" id="frm_delete_style" class="submitdelete deletion" onclick="return confirm('<?php esc_attr_e( 'Are you sure you want to delete that style?', 'formidable' ) ?>')"><?php _e( 'Delete Style', 'formidable' ) ?></a> |
| 65 | 65 | <?php } ?> |
| 66 | 66 | <?php |
| 67 | - if ( $style->ID ) { |
|
| 68 | - echo '<span class="howto"><span>.frm_style_'. esc_attr( $style->post_name ) .'</span></span>'; |
|
| 67 | + if ( $style->ID ) { |
|
| 68 | + echo '<span class="howto"><span>.frm_style_'. esc_attr( $style->post_name ) .'</span></span>'; |
|
| 69 | 69 | } ?> |
| 70 | 70 | <div class="publishing-action"> |
| 71 | 71 | <input type="button" value="<?php esc_attr_e( 'Reset to Default', 'formidable' ) ?>" class="button-secondary frm_reset_style" /> |
@@ -2,14 +2,14 @@ discard block |
||
| 2 | 2 | <div class="wrap"> |
| 3 | 3 | <?php FrmStylesHelper::style_menu(); ?> |
| 4 | 4 | |
| 5 | - <?php include(FrmAppHelper::plugin_path() .'/classes/views/shared/errors.php'); ?> |
|
| 5 | + <?php include( FrmAppHelper::plugin_path() . '/classes/views/shared/errors.php' ); ?> |
|
| 6 | 6 | |
| 7 | 7 | <?php do_action( 'frm_style_switcher', $style, $styles ) ?> |
| 8 | 8 | |
| 9 | 9 | <form id="frm_styling_form" action="" name="frm_styling_form" method="post"> |
| 10 | 10 | <input type="hidden" name="ID" value="<?php echo esc_attr( $style->ID ) ?>" /> |
| 11 | 11 | <input type="hidden" name="frm_action" value="save" /> |
| 12 | - <textarea name="<?php echo esc_attr( $frm_style->get_field_name('custom_css') ) ?>" class="frm_hidden"><?php echo FrmAppHelper::esc_textarea( $style->post_content['custom_css'] ) ?></textarea> |
|
| 12 | + <textarea name="<?php echo esc_attr( $frm_style->get_field_name( 'custom_css' ) ) ?>" class="frm_hidden"><?php echo FrmAppHelper::esc_textarea( $style->post_content['custom_css'] ) ?></textarea> |
|
| 13 | 13 | <?php wp_nonce_field( 'frm_style_nonce', 'frm_style' ); ?> |
| 14 | 14 | |
| 15 | 15 | <div id="nav-menus-frame"> |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | |
| 19 | 19 | <div class="styling_settings"> |
| 20 | 20 | <input type="hidden" name="style_name" value="frm_style_<?php echo esc_attr( $style->post_name ) ?>" /> |
| 21 | - <?php FrmStylesController::do_accordion_sections( FrmStylesController::$screen, 'side', compact('style', 'frm_style') ); ?> |
|
| 21 | + <?php FrmStylesController::do_accordion_sections( FrmStylesController::$screen, 'side', compact( 'style', 'frm_style' ) ); ?> |
|
| 22 | 22 | </div> |
| 23 | 23 | |
| 24 | 24 | </div><!-- /#menu-settings-column --> |
@@ -31,17 +31,17 @@ discard block |
||
| 31 | 31 | <div class="major-publishing-actions"> |
| 32 | 32 | <label class="menu-name-label howto open-label" for="menu-name"> |
| 33 | 33 | <span><?php _e( 'Style Name', 'formidable' ) ?></span> |
| 34 | - <input id="menu-name" name="<?php echo esc_attr( $frm_style->get_field_name('post_title', '') ); ?>" type="text" class="menu-name regular-text menu-item-textbox" title="<?php esc_attr_e( 'Enter style name here', 'formidable' ) ?>" value="<?php echo esc_attr( $style->post_title ) ?>" /> |
|
| 34 | + <input id="menu-name" name="<?php echo esc_attr( $frm_style->get_field_name( 'post_title', '' ) ); ?>" type="text" class="menu-name regular-text menu-item-textbox" title="<?php esc_attr_e( 'Enter style name here', 'formidable' ) ?>" value="<?php echo esc_attr( $style->post_title ) ?>" /> |
|
| 35 | 35 | </label> |
| 36 | 36 | |
| 37 | - <input name="prev_menu_order" type="hidden" value="<?php echo esc_attr($style->menu_order) ?>" /> |
|
| 37 | + <input name="prev_menu_order" type="hidden" value="<?php echo esc_attr( $style->menu_order ) ?>" /> |
|
| 38 | 38 | <label class="menu-name-label howto open-label default-style-box" for="menu_order"> |
| 39 | 39 | <span> |
| 40 | 40 | <?php if ( $style->menu_order ) { ?> |
| 41 | - <input name="<?php echo esc_attr( $frm_style->get_field_name('menu_order', '') ); ?>" type="hidden" value="1" /> |
|
| 42 | - <input id="menu_order" disabled="disabled" type="checkbox" value="1" <?php checked($style->menu_order, 1) ?> /> |
|
| 41 | + <input name="<?php echo esc_attr( $frm_style->get_field_name( 'menu_order', '' ) ); ?>" type="hidden" value="1" /> |
|
| 42 | + <input id="menu_order" disabled="disabled" type="checkbox" value="1" <?php checked( $style->menu_order, 1 ) ?> /> |
|
| 43 | 43 | <?php } else { ?> |
| 44 | - <input id="menu_order" name="<?php echo esc_attr( $frm_style->get_field_name('menu_order', '') ); ?>" type="checkbox" value="1" <?php checked($style->menu_order, 1) ?> /> |
|
| 44 | + <input id="menu_order" name="<?php echo esc_attr( $frm_style->get_field_name( 'menu_order', '' ) ); ?>" type="checkbox" value="1" <?php checked( $style->menu_order, 1 ) ?> /> |
|
| 45 | 45 | <?php } ?> |
| 46 | 46 | <?php _e( 'Make default style', 'formidable' ) ?></span> |
| 47 | 47 | </label> |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | <div id="post-body"> |
| 55 | 55 | <div id="post-body-content"> |
| 56 | 56 | |
| 57 | - <?php include( dirname(__FILE__) .'/_sample_form.php') ?> |
|
| 57 | + <?php include( dirname( __FILE__ ) . '/_sample_form.php' ) ?> |
|
| 58 | 58 | |
| 59 | 59 | </div><!-- /#post-body-content --> |
| 60 | 60 | </div><!-- /#post-body --> |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | <?php } ?> |
| 66 | 66 | <?php |
| 67 | 67 | if ( $style->ID ) { |
| 68 | - echo '<span class="howto"><span>.frm_style_'. esc_attr( $style->post_name ) .'</span></span>'; |
|
| 68 | + echo '<span class="howto"><span>.frm_style_' . esc_attr( $style->post_name ) . '</span></span>'; |
|
| 69 | 69 | } ?> |
| 70 | 70 | <div class="publishing-action"> |
| 71 | 71 | <input type="button" value="<?php esc_attr_e( 'Reset to Default', 'formidable' ) ?>" class="button-secondary frm_reset_style" /> |
@@ -67,10 +67,10 @@ discard block |
||
| 67 | 67 | protected $modes = array(); |
| 68 | 68 | |
| 69 | 69 | /** |
| 70 | - * |
|
| 71 | - * @var array |
|
| 72 | - */ |
|
| 73 | - protected $params; |
|
| 70 | + * |
|
| 71 | + * @var array |
|
| 72 | + */ |
|
| 73 | + protected $params; |
|
| 74 | 74 | |
| 75 | 75 | /** |
| 76 | 76 | * Stores the value returned by ->get_column_info() |
@@ -87,10 +87,10 @@ discard block |
||
| 87 | 87 | 'single_row_columns' ); |
| 88 | 88 | |
| 89 | 89 | /** |
| 90 | - * Construct the table object |
|
| 91 | - */ |
|
| 90 | + * Construct the table object |
|
| 91 | + */ |
|
| 92 | 92 | public function __construct( $args ) { |
| 93 | - $args = wp_parse_args( $args, array( |
|
| 93 | + $args = wp_parse_args( $args, array( |
|
| 94 | 94 | 'params' => array(), |
| 95 | 95 | 'plural' => '', |
| 96 | 96 | 'singular' => '', |
@@ -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 | |
@@ -275,8 +275,8 @@ discard block |
||
| 275 | 275 | return $this->get_pagenum(); |
| 276 | 276 | } |
| 277 | 277 | |
| 278 | - if ( isset( $this->_pagination_args[ $key ] ) ) { |
|
| 279 | - return $this->_pagination_args[ $key ]; |
|
| 278 | + if ( isset( $this->_pagination_args[$key] ) ) { |
|
| 279 | + return $this->_pagination_args[$key]; |
|
| 280 | 280 | } |
| 281 | 281 | } |
| 282 | 282 | |
@@ -331,8 +331,8 @@ discard block |
||
| 331 | 331 | } |
| 332 | 332 | |
| 333 | 333 | private function hidden_search_inputs( $param_name ) { |
| 334 | - if ( ! empty( $_REQUEST[ $param_name ] ) ) { |
|
| 335 | - echo '<input type="hidden" name="' . esc_attr( $param_name ) . '" value="' . esc_attr( $_REQUEST[ $param_name ] ) . '" />'; |
|
| 334 | + if ( ! empty( $_REQUEST[$param_name] ) ) { |
|
| 335 | + echo '<input type="hidden" name="' . esc_attr( $param_name ) . '" value="' . esc_attr( $_REQUEST[$param_name] ) . '" />'; |
|
| 336 | 336 | } |
| 337 | 337 | } |
| 338 | 338 | |
@@ -375,7 +375,7 @@ discard block |
||
| 375 | 375 | |
| 376 | 376 | echo "<ul class='subsubsub'>\n"; |
| 377 | 377 | foreach ( $views as $class => $view ) { |
| 378 | - $views[ $class ] = "\t<li class='$class'>$view"; |
|
| 378 | + $views[$class] = "\t<li class='$class'>$view"; |
|
| 379 | 379 | } |
| 380 | 380 | echo implode( " |</li>\n", $views ) . "</li>\n"; |
| 381 | 381 | echo '</ul>'; |
@@ -436,7 +436,7 @@ discard block |
||
| 436 | 436 | foreach ( $this->_actions as $name => $title ) { |
| 437 | 437 | $class = 'edit' == $name ? ' class="hide-if-no-js"' : ''; |
| 438 | 438 | |
| 439 | - echo "\t<option value='". esc_attr( $name ) ."'$class>$title</option>\n"; |
|
| 439 | + echo "\t<option value='" . esc_attr( $name ) . "'$class>$title</option>\n"; |
|
| 440 | 440 | } |
| 441 | 441 | |
| 442 | 442 | echo "</select>\n"; |
@@ -468,8 +468,8 @@ discard block |
||
| 468 | 468 | |
| 469 | 469 | private static function get_bulk_action( $action_name ) { |
| 470 | 470 | $action = false; |
| 471 | - if ( isset( $_REQUEST[ $action_name ] ) && -1 != sanitize_text_field( $_REQUEST[ $action_name ] ) ) { |
|
| 472 | - $action = sanitize_text_field( $_REQUEST[ $action_name ] ); |
|
| 471 | + if ( isset( $_REQUEST[$action_name] ) && -1 != sanitize_text_field( $_REQUEST[$action_name] ) ) { |
|
| 472 | + $action = sanitize_text_field( $_REQUEST[$action_name] ); |
|
| 473 | 473 | } |
| 474 | 474 | return $action; |
| 475 | 475 | } |
@@ -494,7 +494,7 @@ discard block |
||
| 494 | 494 | |
| 495 | 495 | $out = '<div class="' . ( $always_visible ? 'row-actions visible' : 'row-actions' ) . '">'; |
| 496 | 496 | foreach ( $actions as $action => $link ) { |
| 497 | - ++$i; |
|
| 497 | + ++ $i; |
|
| 498 | 498 | ( $i == $action_count ) ? $sep = '' : $sep = ' | '; |
| 499 | 499 | $out .= "<span class='$action'>$link$sep</span>"; |
| 500 | 500 | } |
@@ -760,7 +760,7 @@ discard block |
||
| 760 | 760 | |
| 761 | 761 | // If the primary column doesn't exist fall back to the |
| 762 | 762 | // first non-checkbox column. |
| 763 | - if ( ! isset( $columns[ $default ] ) ) { |
|
| 763 | + if ( ! isset( $columns[$default] ) ) { |
|
| 764 | 764 | $default = FrmListHelper::get_default_primary_column_name(); |
| 765 | 765 | } |
| 766 | 766 | |
@@ -774,7 +774,7 @@ discard block |
||
| 774 | 774 | */ |
| 775 | 775 | $column = apply_filters( 'list_table_primary_column', $default, $this->screen->id ); |
| 776 | 776 | |
| 777 | - if ( empty( $column ) || ! isset( $columns[ $column ] ) ) { |
|
| 777 | + if ( empty( $column ) || ! isset( $columns[$column] ) ) { |
|
| 778 | 778 | $column = $default; |
| 779 | 779 | } |
| 780 | 780 | |
@@ -796,7 +796,7 @@ discard block |
||
| 796 | 796 | // In 4.3, we added a fourth argument for primary column. |
| 797 | 797 | $column_headers = array( array(), array(), array(), $this->get_primary_column_name() ); |
| 798 | 798 | foreach ( $this->_column_headers as $key => $value ) { |
| 799 | - $column_headers[ $key ] = $value; |
|
| 799 | + $column_headers[$key] = $value; |
|
| 800 | 800 | } |
| 801 | 801 | |
| 802 | 802 | return $column_headers; |
@@ -829,7 +829,7 @@ discard block |
||
| 829 | 829 | $data[1] = false; |
| 830 | 830 | } |
| 831 | 831 | |
| 832 | - $sortable[ $id ] = $data; |
|
| 832 | + $sortable[$id] = $data; |
|
| 833 | 833 | } |
| 834 | 834 | |
| 835 | 835 | $primary = $this->get_primary_column_name(); |
@@ -884,7 +884,7 @@ discard block |
||
| 884 | 884 | static $cb_counter = 1; |
| 885 | 885 | $columns['cb'] = '<label class="screen-reader-text" for="cb-select-all-' . $cb_counter . '">' . __( 'Select All' ) . '</label>' |
| 886 | 886 | . '<input id="cb-select-all-' . esc_attr( $cb_counter ) . '" type="checkbox" />'; |
| 887 | - $cb_counter++; |
|
| 887 | + $cb_counter ++; |
|
| 888 | 888 | } |
| 889 | 889 | |
| 890 | 890 | foreach ( $columns as $column_key => $column_display_name ) { |
@@ -904,8 +904,8 @@ discard block |
||
| 904 | 904 | $class[] = 'column-primary'; |
| 905 | 905 | } |
| 906 | 906 | |
| 907 | - if ( isset( $sortable[ $column_key ] ) ) { |
|
| 908 | - list( $orderby, $desc_first ) = $sortable[ $column_key ]; |
|
| 907 | + if ( isset( $sortable[$column_key] ) ) { |
|
| 908 | + list( $orderby, $desc_first ) = $sortable[$column_key]; |
|
| 909 | 909 | |
| 910 | 910 | if ( $current_orderby == $orderby ) { |
| 911 | 911 | $order = 'asc' == $current_order ? 'desc' : 'asc'; |
@@ -520,8 +520,9 @@ |
||
| 520 | 520 | <?php |
| 521 | 521 | foreach ( $this->modes as $mode => $title ) { |
| 522 | 522 | $classes = array( 'view-' . $mode ); |
| 523 | - if ( $current_mode == $mode ) |
|
| 524 | - $classes[] = 'current'; |
|
| 523 | + if ( $current_mode == $mode ) { |
|
| 524 | + $classes[] = 'current'; |
|
| 525 | + } |
|
| 525 | 526 | printf( |
| 526 | 527 | "<a href='%s' class='%s' id='view-switch-$mode'><span class='screen-reader-text'>%s</span></a>\n", |
| 527 | 528 | esc_url( add_query_arg( 'mode', $mode ) ), |
@@ -253,6 +253,9 @@ discard block |
||
| 253 | 253 | <?php |
| 254 | 254 | } |
| 255 | 255 | |
| 256 | + /** |
|
| 257 | + * @param string $param_name |
|
| 258 | + */ |
|
| 256 | 259 | private function hidden_search_inputs( $param_name ) { |
| 257 | 260 | if ( ! empty( $_REQUEST[ $param_name ] ) ) { |
| 258 | 261 | echo '<input type="hidden" name="' . esc_attr( $param_name ) . '" value="' . esc_attr( $_REQUEST[ $param_name ] ) . '" />'; |
@@ -389,6 +392,9 @@ discard block |
||
| 389 | 392 | return $action; |
| 390 | 393 | } |
| 391 | 394 | |
| 395 | + /** |
|
| 396 | + * @param string $action_name |
|
| 397 | + */ |
|
| 392 | 398 | private static function get_bulk_action( $action_name ) { |
| 393 | 399 | $action = false; |
| 394 | 400 | if ( isset( $_REQUEST[ $action_name ] ) && -1 != sanitize_text_field( $_REQUEST[ $action_name ] ) ) { |
@@ -1,26 +1,26 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | class FrmEntryValidate { |
| 4 | - public static function validate( $values, $exclude = false ) { |
|
| 5 | - global $wpdb; |
|
| 4 | + public static function validate( $values, $exclude = false ) { |
|
| 5 | + global $wpdb; |
|
| 6 | 6 | |
| 7 | - FrmEntry::sanitize_entry_post( $values ); |
|
| 8 | - $errors = array(); |
|
| 7 | + FrmEntry::sanitize_entry_post( $values ); |
|
| 8 | + $errors = array(); |
|
| 9 | 9 | |
| 10 | - if ( ! isset($values['form_id']) || ! isset($values['item_meta']) ) { |
|
| 11 | - $errors['form'] = __( 'There was a problem with your submission. Please try again.', 'formidable' ); |
|
| 12 | - return $errors; |
|
| 13 | - } |
|
| 10 | + if ( ! isset($values['form_id']) || ! isset($values['item_meta']) ) { |
|
| 11 | + $errors['form'] = __( 'There was a problem with your submission. Please try again.', 'formidable' ); |
|
| 12 | + return $errors; |
|
| 13 | + } |
|
| 14 | 14 | |
| 15 | 15 | if ( FrmAppHelper::is_admin() && is_user_logged_in() && ( ! isset( $values[ 'frm_submit_entry_' . $values['form_id'] ] ) || ! wp_verify_nonce( $values[ 'frm_submit_entry_' . $values['form_id'] ], 'frm_submit_entry_nonce' ) ) ) { |
| 16 | - $errors['form'] = __( 'You do not have permission to do that', 'formidable' ); |
|
| 17 | - } |
|
| 16 | + $errors['form'] = __( 'You do not have permission to do that', 'formidable' ); |
|
| 17 | + } |
|
| 18 | 18 | |
| 19 | - if ( ! isset($values['item_key']) || $values['item_key'] == '' ) { |
|
| 20 | - $_POST['item_key'] = $values['item_key'] = FrmAppHelper::get_unique_key('', $wpdb->prefix .'frm_items', 'item_key'); |
|
| 21 | - } |
|
| 19 | + if ( ! isset($values['item_key']) || $values['item_key'] == '' ) { |
|
| 20 | + $_POST['item_key'] = $values['item_key'] = FrmAppHelper::get_unique_key('', $wpdb->prefix .'frm_items', 'item_key'); |
|
| 21 | + } |
|
| 22 | 22 | |
| 23 | - $where = apply_filters('frm_posted_field_ids', array( 'fi.form_id' => $values['form_id'] ) ); |
|
| 23 | + $where = apply_filters('frm_posted_field_ids', array( 'fi.form_id' => $values['form_id'] ) ); |
|
| 24 | 24 | // Don't get subfields |
| 25 | 25 | $where['fr.parent_form_id'] = array( null, 0 ); |
| 26 | 26 | // Don't get excluded fields (like file upload fields in the ajax validation) |
@@ -28,46 +28,46 @@ discard block |
||
| 28 | 28 | $where['fi.type not'] = $exclude; |
| 29 | 29 | } |
| 30 | 30 | |
| 31 | - $posted_fields = FrmField::getAll($where, 'field_order'); |
|
| 31 | + $posted_fields = FrmField::getAll($where, 'field_order'); |
|
| 32 | 32 | |
| 33 | - // Pass exclude value to validate_field function so it can be used for repeating sections |
|
| 34 | - $args = array( 'exclude' => $exclude ); |
|
| 33 | + // Pass exclude value to validate_field function so it can be used for repeating sections |
|
| 34 | + $args = array( 'exclude' => $exclude ); |
|
| 35 | 35 | |
| 36 | - foreach ( $posted_fields as $posted_field ) { |
|
| 37 | - self::validate_field($posted_field, $errors, $values, $args); |
|
| 38 | - unset($posted_field); |
|
| 39 | - } |
|
| 36 | + foreach ( $posted_fields as $posted_field ) { |
|
| 37 | + self::validate_field($posted_field, $errors, $values, $args); |
|
| 38 | + unset($posted_field); |
|
| 39 | + } |
|
| 40 | 40 | |
| 41 | - // check for spam |
|
| 42 | - self::spam_check( $exclude, $values, $errors ); |
|
| 41 | + // check for spam |
|
| 42 | + self::spam_check( $exclude, $values, $errors ); |
|
| 43 | 43 | |
| 44 | - $errors = apply_filters( 'frm_validate_entry', $errors, $values, compact('exclude') ); |
|
| 44 | + $errors = apply_filters( 'frm_validate_entry', $errors, $values, compact('exclude') ); |
|
| 45 | 45 | |
| 46 | - return $errors; |
|
| 47 | - } |
|
| 46 | + return $errors; |
|
| 47 | + } |
|
| 48 | 48 | |
| 49 | - public static function validate_field( $posted_field, &$errors, $values, $args = array() ) { |
|
| 50 | - $defaults = array( |
|
| 51 | - 'id' => $posted_field->id, |
|
| 52 | - 'parent_field_id' => '', // the id of the repeat or embed form |
|
| 53 | - 'key_pointer' => '', // the pointer in the posted array |
|
| 54 | - 'exclude' => array(), // exclude these field types from validation |
|
| 55 | - ); |
|
| 56 | - $args = wp_parse_args( $args, $defaults ); |
|
| 49 | + public static function validate_field( $posted_field, &$errors, $values, $args = array() ) { |
|
| 50 | + $defaults = array( |
|
| 51 | + 'id' => $posted_field->id, |
|
| 52 | + 'parent_field_id' => '', // the id of the repeat or embed form |
|
| 53 | + 'key_pointer' => '', // the pointer in the posted array |
|
| 54 | + 'exclude' => array(), // exclude these field types from validation |
|
| 55 | + ); |
|
| 56 | + $args = wp_parse_args( $args, $defaults ); |
|
| 57 | 57 | |
| 58 | - if ( empty($args['parent_field_id']) ) { |
|
| 58 | + if ( empty($args['parent_field_id']) ) { |
|
| 59 | 59 | $value = isset( $values['item_meta'][ $args['id'] ] ) ? $values['item_meta'][ $args['id'] ] : ''; |
| 60 | - } else { |
|
| 61 | - // value is from a nested form |
|
| 62 | - $value = $values; |
|
| 63 | - } |
|
| 60 | + } else { |
|
| 61 | + // value is from a nested form |
|
| 62 | + $value = $values; |
|
| 63 | + } |
|
| 64 | 64 | |
| 65 | - // Check for values in "Other" fields |
|
| 66 | - FrmEntriesHelper::maybe_set_other_validation( $posted_field, $value, $args ); |
|
| 65 | + // Check for values in "Other" fields |
|
| 66 | + FrmEntriesHelper::maybe_set_other_validation( $posted_field, $value, $args ); |
|
| 67 | 67 | |
| 68 | - if ( isset($posted_field->field_options['default_blank']) && $posted_field->field_options['default_blank'] && $value == $posted_field->default_value ) { |
|
| 69 | - $value = ''; |
|
| 70 | - } |
|
| 68 | + if ( isset($posted_field->field_options['default_blank']) && $posted_field->field_options['default_blank'] && $value == $posted_field->default_value ) { |
|
| 69 | + $value = ''; |
|
| 70 | + } |
|
| 71 | 71 | |
| 72 | 72 | // Check for an array with only one value |
| 73 | 73 | // Don't reset values in "Other" fields because array keys need to be preserved |
@@ -75,11 +75,11 @@ discard block |
||
| 75 | 75 | $value = reset($value); |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | - if ( $posted_field->required == '1' && ! is_array( $value ) && trim( $value ) == '' ) { |
|
| 78 | + if ( $posted_field->required == '1' && ! is_array( $value ) && trim( $value ) == '' ) { |
|
| 79 | 79 | $errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $posted_field, 'blank' ); |
| 80 | - } else if ( $posted_field->type == 'text' && ! isset( $_POST['item_name'] ) ) { |
|
| 81 | - $_POST['item_name'] = $value; |
|
| 82 | - } |
|
| 80 | + } else if ( $posted_field->type == 'text' && ! isset( $_POST['item_name'] ) ) { |
|
| 81 | + $_POST['item_name'] = $value; |
|
| 82 | + } |
|
| 83 | 83 | |
| 84 | 84 | if ( $value != '' ) { |
| 85 | 85 | self::validate_url_field( $errors, $posted_field, $value, $args ); |
@@ -88,41 +88,41 @@ discard block |
||
| 88 | 88 | self::validate_phone_field( $errors, $posted_field, $value, $args ); |
| 89 | 89 | } |
| 90 | 90 | |
| 91 | - FrmEntriesHelper::set_posted_value($posted_field, $value, $args); |
|
| 91 | + FrmEntriesHelper::set_posted_value($posted_field, $value, $args); |
|
| 92 | 92 | |
| 93 | - self::validate_recaptcha($errors, $posted_field, $args); |
|
| 93 | + self::validate_recaptcha($errors, $posted_field, $args); |
|
| 94 | 94 | |
| 95 | - $errors = apply_filters('frm_validate_field_entry', $errors, $posted_field, $value, $args); |
|
| 96 | - } |
|
| 95 | + $errors = apply_filters('frm_validate_field_entry', $errors, $posted_field, $value, $args); |
|
| 96 | + } |
|
| 97 | 97 | |
| 98 | 98 | public static function validate_url_field( &$errors, $field, &$value, $args ) { |
| 99 | 99 | if ( $value == '' || ! in_array( $field->type, array( 'website', 'url', 'image' ) ) ) { |
| 100 | - return; |
|
| 101 | - } |
|
| 102 | - |
|
| 103 | - if ( trim($value) == 'http://' ) { |
|
| 104 | - $value = ''; |
|
| 105 | - } else { |
|
| 106 | - $value = esc_url_raw( $value ); |
|
| 107 | - $value = preg_match('/^(https?|ftps?|mailto|news|feed|telnet):/is', $value) ? $value : 'http://'. $value; |
|
| 108 | - } |
|
| 109 | - |
|
| 110 | - //validate the url format |
|
| 111 | - if ( ! preg_match('/^http(s)?:\/\/([\da-z\.-]+)\.([\da-z\.-]+)/i', $value) ) { |
|
| 100 | + return; |
|
| 101 | + } |
|
| 102 | + |
|
| 103 | + if ( trim($value) == 'http://' ) { |
|
| 104 | + $value = ''; |
|
| 105 | + } else { |
|
| 106 | + $value = esc_url_raw( $value ); |
|
| 107 | + $value = preg_match('/^(https?|ftps?|mailto|news|feed|telnet):/is', $value) ? $value : 'http://'. $value; |
|
| 108 | + } |
|
| 109 | + |
|
| 110 | + //validate the url format |
|
| 111 | + if ( ! preg_match('/^http(s)?:\/\/([\da-z\.-]+)\.([\da-z\.-]+)/i', $value) ) { |
|
| 112 | 112 | $errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $field, 'invalid' ); |
| 113 | - } |
|
| 114 | - } |
|
| 113 | + } |
|
| 114 | + } |
|
| 115 | 115 | |
| 116 | 116 | public static function validate_email_field( &$errors, $field, $value, $args ) { |
| 117 | - if ( $value == '' || $field->type != 'email' ) { |
|
| 118 | - return; |
|
| 119 | - } |
|
| 117 | + if ( $value == '' || $field->type != 'email' ) { |
|
| 118 | + return; |
|
| 119 | + } |
|
| 120 | 120 | |
| 121 | - //validate the email format |
|
| 122 | - if ( ! is_email($value) ) { |
|
| 121 | + //validate the email format |
|
| 122 | + if ( ! is_email($value) ) { |
|
| 123 | 123 | $errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $field, 'invalid' ); |
| 124 | - } |
|
| 125 | - } |
|
| 124 | + } |
|
| 125 | + } |
|
| 126 | 126 | |
| 127 | 127 | public static function validate_number_field( &$errors, $field, $value, $args ) { |
| 128 | 128 | //validate the number format |
@@ -199,9 +199,9 @@ discard block |
||
| 199 | 199 | } |
| 200 | 200 | |
| 201 | 201 | public static function validate_recaptcha( &$errors, $field, $args ) { |
| 202 | - if ( $field->type != 'captcha' || FrmAppHelper::is_admin() || apply_filters( 'frm_is_field_hidden', false, $field, stripslashes_deep( $_POST ) ) ) { |
|
| 203 | - return; |
|
| 204 | - } |
|
| 202 | + if ( $field->type != 'captcha' || FrmAppHelper::is_admin() || apply_filters( 'frm_is_field_hidden', false, $field, stripslashes_deep( $_POST ) ) ) { |
|
| 203 | + return; |
|
| 204 | + } |
|
| 205 | 205 | |
| 206 | 206 | $frm_settings = FrmAppHelper::get_settings(); |
| 207 | 207 | if ( empty( $frm_settings->pubkey ) ) { |
@@ -209,53 +209,53 @@ discard block |
||
| 209 | 209 | return; |
| 210 | 210 | } |
| 211 | 211 | |
| 212 | - if ( ! isset($_POST['g-recaptcha-response']) ) { |
|
| 213 | - // If captcha is missing, check if it was already verified |
|
| 212 | + if ( ! isset($_POST['g-recaptcha-response']) ) { |
|
| 213 | + // If captcha is missing, check if it was already verified |
|
| 214 | 214 | if ( ! isset( $_POST['recaptcha_checked'] ) || ! wp_verify_nonce( $_POST['recaptcha_checked'], 'frm_ajax' ) ) { |
| 215 | - // There was no captcha submitted |
|
| 215 | + // There was no captcha submitted |
|
| 216 | 216 | $errors[ 'field' . $args['id'] ] = __( 'The captcha is missing from this form', 'formidable' ); |
| 217 | - } |
|
| 218 | - return; |
|
| 219 | - } |
|
| 217 | + } |
|
| 218 | + return; |
|
| 219 | + } |
|
| 220 | 220 | |
| 221 | - $arg_array = array( |
|
| 222 | - 'body' => array( |
|
| 221 | + $arg_array = array( |
|
| 222 | + 'body' => array( |
|
| 223 | 223 | 'secret' => $frm_settings->privkey, |
| 224 | 224 | 'response' => $_POST['g-recaptcha-response'], |
| 225 | 225 | 'remoteip' => FrmAppHelper::get_ip_address(), |
| 226 | 226 | ), |
| 227 | 227 | ); |
| 228 | - $resp = wp_remote_post( 'https://www.google.com/recaptcha/api/siteverify', $arg_array ); |
|
| 229 | - $response = json_decode(wp_remote_retrieve_body( $resp ), true); |
|
| 228 | + $resp = wp_remote_post( 'https://www.google.com/recaptcha/api/siteverify', $arg_array ); |
|
| 229 | + $response = json_decode(wp_remote_retrieve_body( $resp ), true); |
|
| 230 | 230 | |
| 231 | - if ( isset( $response['success'] ) && ! $response['success'] ) { |
|
| 232 | - // What happens when the CAPTCHA was entered incorrectly |
|
| 231 | + if ( isset( $response['success'] ) && ! $response['success'] ) { |
|
| 232 | + // What happens when the CAPTCHA was entered incorrectly |
|
| 233 | 233 | $errors[ 'field' . $args['id'] ] = ( ! isset( $field->field_options['invalid'] ) || $field->field_options['invalid'] == '' ) ? $frm_settings->re_msg : $field->field_options['invalid']; |
| 234 | - } |
|
| 235 | - } |
|
| 236 | - |
|
| 237 | - /** |
|
| 238 | - * check for spam |
|
| 239 | - * @param boolean $exclude |
|
| 240 | - * @param array $values |
|
| 241 | - * @param array $errors by reference |
|
| 242 | - */ |
|
| 243 | - public static function spam_check( $exclude, $values, &$errors ) { |
|
| 244 | - if ( ! empty( $exclude ) || ! isset( $values['item_meta'] ) || empty( $values['item_meta'] ) || ! empty( $errors ) ) { |
|
| 245 | - // only check spam if there are no other errors |
|
| 246 | - return; |
|
| 247 | - } |
|
| 248 | - |
|
| 249 | - if ( self::is_akismet_spam( $values ) ) { |
|
| 234 | + } |
|
| 235 | + } |
|
| 236 | + |
|
| 237 | + /** |
|
| 238 | + * check for spam |
|
| 239 | + * @param boolean $exclude |
|
| 240 | + * @param array $values |
|
| 241 | + * @param array $errors by reference |
|
| 242 | + */ |
|
| 243 | + public static function spam_check( $exclude, $values, &$errors ) { |
|
| 244 | + if ( ! empty( $exclude ) || ! isset( $values['item_meta'] ) || empty( $values['item_meta'] ) || ! empty( $errors ) ) { |
|
| 245 | + // only check spam if there are no other errors |
|
| 246 | + return; |
|
| 247 | + } |
|
| 248 | + |
|
| 249 | + if ( self::is_akismet_spam( $values ) ) { |
|
| 250 | 250 | if ( self::is_akismet_enabled_for_user( $values['form_id'] ) ) { |
| 251 | 251 | $errors['spam'] = __( 'Your entry appears to be spam!', 'formidable' ); |
| 252 | 252 | } |
| 253 | - } |
|
| 253 | + } |
|
| 254 | 254 | |
| 255 | - if ( self::blacklist_check( $values ) ) { |
|
| 256 | - $errors['spam'] = __( 'Your entry appears to be spam!', 'formidable' ); |
|
| 257 | - } |
|
| 258 | - } |
|
| 255 | + if ( self::blacklist_check( $values ) ) { |
|
| 256 | + $errors['spam'] = __( 'Your entry appears to be spam!', 'formidable' ); |
|
| 257 | + } |
|
| 258 | + } |
|
| 259 | 259 | |
| 260 | 260 | private static function is_akismet_spam( $values ) { |
| 261 | 261 | global $wpcom_api_key; |
@@ -267,54 +267,54 @@ discard block |
||
| 267 | 267 | return ( isset( $form->options['akismet'] ) && ! empty( $form->options['akismet'] ) && ( $form->options['akismet'] != 'logged' || ! is_user_logged_in() ) ); |
| 268 | 268 | } |
| 269 | 269 | |
| 270 | - public static function blacklist_check( $values ) { |
|
| 271 | - if ( ! apply_filters('frm_check_blacklist', true, $values) ) { |
|
| 272 | - return false; |
|
| 273 | - } |
|
| 270 | + public static function blacklist_check( $values ) { |
|
| 271 | + if ( ! apply_filters('frm_check_blacklist', true, $values) ) { |
|
| 272 | + return false; |
|
| 273 | + } |
|
| 274 | 274 | |
| 275 | - $mod_keys = trim( get_option( 'blacklist_keys' ) ); |
|
| 275 | + $mod_keys = trim( get_option( 'blacklist_keys' ) ); |
|
| 276 | 276 | |
| 277 | - if ( empty( $mod_keys ) ) { |
|
| 278 | - return false; |
|
| 279 | - } |
|
| 277 | + if ( empty( $mod_keys ) ) { |
|
| 278 | + return false; |
|
| 279 | + } |
|
| 280 | 280 | |
| 281 | - $content = FrmEntriesHelper::entry_array_to_string($values); |
|
| 281 | + $content = FrmEntriesHelper::entry_array_to_string($values); |
|
| 282 | 282 | |
| 283 | 283 | if ( empty($content) ) { |
| 284 | - return false; |
|
| 284 | + return false; |
|
| 285 | 285 | } |
| 286 | 286 | |
| 287 | - $words = explode( "\n", $mod_keys ); |
|
| 287 | + $words = explode( "\n", $mod_keys ); |
|
| 288 | 288 | |
| 289 | - foreach ( (array) $words as $word ) { |
|
| 290 | - $word = trim( $word ); |
|
| 289 | + foreach ( (array) $words as $word ) { |
|
| 290 | + $word = trim( $word ); |
|
| 291 | 291 | |
| 292 | - if ( empty($word) ) { |
|
| 293 | - continue; |
|
| 294 | - } |
|
| 292 | + if ( empty($word) ) { |
|
| 293 | + continue; |
|
| 294 | + } |
|
| 295 | 295 | |
| 296 | - if ( preg_match('#' . preg_quote( $word, '#' ) . '#', $content) ) { |
|
| 297 | - return true; |
|
| 298 | - } |
|
| 299 | - } |
|
| 296 | + if ( preg_match('#' . preg_quote( $word, '#' ) . '#', $content) ) { |
|
| 297 | + return true; |
|
| 298 | + } |
|
| 299 | + } |
|
| 300 | 300 | |
| 301 | - return false; |
|
| 302 | - } |
|
| 301 | + return false; |
|
| 302 | + } |
|
| 303 | 303 | |
| 304 | - /** |
|
| 305 | - * Check entries for spam |
|
| 306 | - * |
|
| 307 | - * @return boolean true if is spam |
|
| 308 | - */ |
|
| 309 | - public static function akismet( $values ) { |
|
| 310 | - $content = FrmEntriesHelper::entry_array_to_string( $values ); |
|
| 304 | + /** |
|
| 305 | + * Check entries for spam |
|
| 306 | + * |
|
| 307 | + * @return boolean true if is spam |
|
| 308 | + */ |
|
| 309 | + public static function akismet( $values ) { |
|
| 310 | + $content = FrmEntriesHelper::entry_array_to_string( $values ); |
|
| 311 | 311 | |
| 312 | 312 | if ( empty( $content ) ) { |
| 313 | - return false; |
|
| 313 | + return false; |
|
| 314 | 314 | } |
| 315 | 315 | |
| 316 | - $datas = array(); |
|
| 317 | - self::parse_akismet_array( $datas, $content ); |
|
| 316 | + $datas = array(); |
|
| 317 | + self::parse_akismet_array( $datas, $content ); |
|
| 318 | 318 | |
| 319 | 319 | $query_string = ''; |
| 320 | 320 | foreach ( $datas as $key => $data ) { |
@@ -322,35 +322,35 @@ discard block |
||
| 322 | 322 | unset( $key, $data ); |
| 323 | 323 | } |
| 324 | 324 | |
| 325 | - $response = Akismet::http_post($query_string, 'comment-check'); |
|
| 325 | + $response = Akismet::http_post($query_string, 'comment-check'); |
|
| 326 | 326 | |
| 327 | 327 | return ( is_array( $response ) && $response[1] == 'true' ); |
| 328 | - } |
|
| 329 | - |
|
| 330 | - /** |
|
| 331 | - * @since 2.0 |
|
| 332 | - * @param string $content |
|
| 333 | - */ |
|
| 334 | - private static function parse_akismet_array( &$datas, $content ) { |
|
| 335 | - $datas['blog'] = FrmAppHelper::site_url(); |
|
| 336 | - $datas['user_ip'] = preg_replace( '/[^0-9., ]/', '', FrmAppHelper::get_ip_address() ); |
|
| 328 | + } |
|
| 329 | + |
|
| 330 | + /** |
|
| 331 | + * @since 2.0 |
|
| 332 | + * @param string $content |
|
| 333 | + */ |
|
| 334 | + private static function parse_akismet_array( &$datas, $content ) { |
|
| 335 | + $datas['blog'] = FrmAppHelper::site_url(); |
|
| 336 | + $datas['user_ip'] = preg_replace( '/[^0-9., ]/', '', FrmAppHelper::get_ip_address() ); |
|
| 337 | 337 | $datas['user_agent'] = FrmAppHelper::get_server_value( 'HTTP_USER_AGENT' ); |
| 338 | 338 | $datas['referrer'] = isset( $_SERVER['HTTP_REFERER'] ) ? FrmAppHelper::get_server_value( 'HTTP_REFERER' ) : false; |
| 339 | - $datas['comment_type'] = 'formidable'; |
|
| 340 | - $datas['comment_content'] = $content; |
|
| 339 | + $datas['comment_type'] = 'formidable'; |
|
| 340 | + $datas['comment_content'] = $content; |
|
| 341 | 341 | |
| 342 | - if ( $permalink = get_permalink() ) { |
|
| 343 | - $datas['permalink'] = $permalink; |
|
| 344 | - } |
|
| 342 | + if ( $permalink = get_permalink() ) { |
|
| 343 | + $datas['permalink'] = $permalink; |
|
| 344 | + } |
|
| 345 | 345 | |
| 346 | - foreach ( $_SERVER as $key => $value ) { |
|
| 346 | + foreach ( $_SERVER as $key => $value ) { |
|
| 347 | 347 | if ( ! in_array( $key, array( 'HTTP_COOKIE', 'HTTP_COOKIE2', 'PHP_AUTH_PW' ) ) && is_string( $value ) ) { |
| 348 | 348 | $datas[ $key ] = wp_strip_all_tags( $value ); |
| 349 | - } else { |
|
| 349 | + } else { |
|
| 350 | 350 | $datas[ $key ] = ''; |
| 351 | - } |
|
| 351 | + } |
|
| 352 | 352 | |
| 353 | - unset($key, $value); |
|
| 354 | - } |
|
| 355 | - } |
|
| 353 | + unset($key, $value); |
|
| 354 | + } |
|
| 355 | + } |
|
| 356 | 356 | } |
@@ -7,20 +7,20 @@ discard block |
||
| 7 | 7 | FrmEntry::sanitize_entry_post( $values ); |
| 8 | 8 | $errors = array(); |
| 9 | 9 | |
| 10 | - if ( ! isset($values['form_id']) || ! isset($values['item_meta']) ) { |
|
| 10 | + if ( ! isset( $values['form_id'] ) || ! isset( $values['item_meta'] ) ) { |
|
| 11 | 11 | $errors['form'] = __( 'There was a problem with your submission. Please try again.', 'formidable' ); |
| 12 | 12 | return $errors; |
| 13 | 13 | } |
| 14 | 14 | |
| 15 | - if ( FrmAppHelper::is_admin() && is_user_logged_in() && ( ! isset( $values[ 'frm_submit_entry_' . $values['form_id'] ] ) || ! wp_verify_nonce( $values[ 'frm_submit_entry_' . $values['form_id'] ], 'frm_submit_entry_nonce' ) ) ) { |
|
| 15 | + if ( FrmAppHelper::is_admin() && is_user_logged_in() && ( ! isset( $values['frm_submit_entry_' . $values['form_id']] ) || ! wp_verify_nonce( $values['frm_submit_entry_' . $values['form_id']], 'frm_submit_entry_nonce' ) ) ) { |
|
| 16 | 16 | $errors['form'] = __( 'You do not have permission to do that', 'formidable' ); |
| 17 | 17 | } |
| 18 | 18 | |
| 19 | - if ( ! isset($values['item_key']) || $values['item_key'] == '' ) { |
|
| 20 | - $_POST['item_key'] = $values['item_key'] = FrmAppHelper::get_unique_key('', $wpdb->prefix .'frm_items', 'item_key'); |
|
| 19 | + if ( ! isset( $values['item_key'] ) || $values['item_key'] == '' ) { |
|
| 20 | + $_POST['item_key'] = $values['item_key'] = FrmAppHelper::get_unique_key( '', $wpdb->prefix . 'frm_items', 'item_key' ); |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | - $where = apply_filters('frm_posted_field_ids', array( 'fi.form_id' => $values['form_id'] ) ); |
|
| 23 | + $where = apply_filters( 'frm_posted_field_ids', array( 'fi.form_id' => $values['form_id'] ) ); |
|
| 24 | 24 | // Don't get subfields |
| 25 | 25 | $where['fr.parent_form_id'] = array( null, 0 ); |
| 26 | 26 | // Don't get excluded fields (like file upload fields in the ajax validation) |
@@ -28,20 +28,20 @@ discard block |
||
| 28 | 28 | $where['fi.type not'] = $exclude; |
| 29 | 29 | } |
| 30 | 30 | |
| 31 | - $posted_fields = FrmField::getAll($where, 'field_order'); |
|
| 31 | + $posted_fields = FrmField::getAll( $where, 'field_order' ); |
|
| 32 | 32 | |
| 33 | 33 | // Pass exclude value to validate_field function so it can be used for repeating sections |
| 34 | 34 | $args = array( 'exclude' => $exclude ); |
| 35 | 35 | |
| 36 | 36 | foreach ( $posted_fields as $posted_field ) { |
| 37 | - self::validate_field($posted_field, $errors, $values, $args); |
|
| 38 | - unset($posted_field); |
|
| 37 | + self::validate_field( $posted_field, $errors, $values, $args ); |
|
| 38 | + unset( $posted_field ); |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | // check for spam |
| 42 | 42 | self::spam_check( $exclude, $values, $errors ); |
| 43 | 43 | |
| 44 | - $errors = apply_filters( 'frm_validate_entry', $errors, $values, compact('exclude') ); |
|
| 44 | + $errors = apply_filters( 'frm_validate_entry', $errors, $values, compact( 'exclude' ) ); |
|
| 45 | 45 | |
| 46 | 46 | return $errors; |
| 47 | 47 | } |
@@ -55,8 +55,8 @@ discard block |
||
| 55 | 55 | ); |
| 56 | 56 | $args = wp_parse_args( $args, $defaults ); |
| 57 | 57 | |
| 58 | - if ( empty($args['parent_field_id']) ) { |
|
| 59 | - $value = isset( $values['item_meta'][ $args['id'] ] ) ? $values['item_meta'][ $args['id'] ] : ''; |
|
| 58 | + if ( empty( $args['parent_field_id'] ) ) { |
|
| 59 | + $value = isset( $values['item_meta'][$args['id']] ) ? $values['item_meta'][$args['id']] : ''; |
|
| 60 | 60 | } else { |
| 61 | 61 | // value is from a nested form |
| 62 | 62 | $value = $values; |
@@ -65,18 +65,18 @@ discard block |
||
| 65 | 65 | // Check for values in "Other" fields |
| 66 | 66 | FrmEntriesHelper::maybe_set_other_validation( $posted_field, $value, $args ); |
| 67 | 67 | |
| 68 | - if ( isset($posted_field->field_options['default_blank']) && $posted_field->field_options['default_blank'] && $value == $posted_field->default_value ) { |
|
| 68 | + if ( isset( $posted_field->field_options['default_blank'] ) && $posted_field->field_options['default_blank'] && $value == $posted_field->default_value ) { |
|
| 69 | 69 | $value = ''; |
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | // Check for an array with only one value |
| 73 | 73 | // Don't reset values in "Other" fields because array keys need to be preserved |
| 74 | - if ( is_array($value) && count( $value ) == 1 && $args['other'] !== true ) { |
|
| 75 | - $value = reset($value); |
|
| 74 | + if ( is_array( $value ) && count( $value ) == 1 && $args['other'] !== true ) { |
|
| 75 | + $value = reset( $value ); |
|
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | if ( $posted_field->required == '1' && ! is_array( $value ) && trim( $value ) == '' ) { |
| 79 | - $errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $posted_field, 'blank' ); |
|
| 79 | + $errors['field' . $args['id']] = FrmFieldsHelper::get_error_msg( $posted_field, 'blank' ); |
|
| 80 | 80 | } else if ( $posted_field->type == 'text' && ! isset( $_POST['item_name'] ) ) { |
| 81 | 81 | $_POST['item_name'] = $value; |
| 82 | 82 | } |
@@ -88,11 +88,11 @@ discard block |
||
| 88 | 88 | self::validate_phone_field( $errors, $posted_field, $value, $args ); |
| 89 | 89 | } |
| 90 | 90 | |
| 91 | - FrmEntriesHelper::set_posted_value($posted_field, $value, $args); |
|
| 91 | + FrmEntriesHelper::set_posted_value( $posted_field, $value, $args ); |
|
| 92 | 92 | |
| 93 | - self::validate_recaptcha($errors, $posted_field, $args); |
|
| 93 | + self::validate_recaptcha( $errors, $posted_field, $args ); |
|
| 94 | 94 | |
| 95 | - $errors = apply_filters('frm_validate_field_entry', $errors, $posted_field, $value, $args); |
|
| 95 | + $errors = apply_filters( 'frm_validate_field_entry', $errors, $posted_field, $value, $args ); |
|
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | public static function validate_url_field( &$errors, $field, &$value, $args ) { |
@@ -100,16 +100,16 @@ discard block |
||
| 100 | 100 | return; |
| 101 | 101 | } |
| 102 | 102 | |
| 103 | - if ( trim($value) == 'http://' ) { |
|
| 103 | + if ( trim( $value ) == 'http://' ) { |
|
| 104 | 104 | $value = ''; |
| 105 | 105 | } else { |
| 106 | 106 | $value = esc_url_raw( $value ); |
| 107 | - $value = preg_match('/^(https?|ftps?|mailto|news|feed|telnet):/is', $value) ? $value : 'http://'. $value; |
|
| 107 | + $value = preg_match( '/^(https?|ftps?|mailto|news|feed|telnet):/is', $value ) ? $value : 'http://' . $value; |
|
| 108 | 108 | } |
| 109 | 109 | |
| 110 | 110 | //validate the url format |
| 111 | - if ( ! preg_match('/^http(s)?:\/\/([\da-z\.-]+)\.([\da-z\.-]+)/i', $value) ) { |
|
| 112 | - $errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $field, 'invalid' ); |
|
| 111 | + if ( ! preg_match( '/^http(s)?:\/\/([\da-z\.-]+)\.([\da-z\.-]+)/i', $value ) ) { |
|
| 112 | + $errors['field' . $args['id']] = FrmFieldsHelper::get_error_msg( $field, 'invalid' ); |
|
| 113 | 113 | } |
| 114 | 114 | } |
| 115 | 115 | |
@@ -119,8 +119,8 @@ discard block |
||
| 119 | 119 | } |
| 120 | 120 | |
| 121 | 121 | //validate the email format |
| 122 | - if ( ! is_email($value) ) { |
|
| 123 | - $errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $field, 'invalid' ); |
|
| 122 | + if ( ! is_email( $value ) ) { |
|
| 123 | + $errors['field' . $args['id']] = FrmFieldsHelper::get_error_msg( $field, 'invalid' ); |
|
| 124 | 124 | } |
| 125 | 125 | } |
| 126 | 126 | |
@@ -130,8 +130,8 @@ discard block |
||
| 130 | 130 | return; |
| 131 | 131 | } |
| 132 | 132 | |
| 133 | - if ( ! is_numeric( $value) ) { |
|
| 134 | - $errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $field, 'invalid' ); |
|
| 133 | + if ( ! is_numeric( $value ) ) { |
|
| 134 | + $errors['field' . $args['id']] = FrmFieldsHelper::get_error_msg( $field, 'invalid' ); |
|
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | // validate number settings |
@@ -141,9 +141,9 @@ discard block |
||
| 141 | 141 | if ( $frm_settings->use_html && isset( $field->field_options['minnum'] ) && isset( $field->field_options['maxnum'] ) ) { |
| 142 | 142 | //minnum maxnum |
| 143 | 143 | if ( (float) $value < $field->field_options['minnum'] ) { |
| 144 | - $errors[ 'field' . $args['id'] ] = __( 'Please select a higher number', 'formidable' ); |
|
| 144 | + $errors['field' . $args['id']] = __( 'Please select a higher number', 'formidable' ); |
|
| 145 | 145 | } else if ( (float) $value > $field->field_options['maxnum'] ) { |
| 146 | - $errors[ 'field' . $args['id'] ] = __( 'Please select a lower number', 'formidable' ); |
|
| 146 | + $errors['field' . $args['id']] = __( 'Please select a lower number', 'formidable' ); |
|
| 147 | 147 | } |
| 148 | 148 | } |
| 149 | 149 | } |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | $pattern = self::phone_format( $field ); |
| 158 | 158 | |
| 159 | 159 | if ( ! preg_match( $pattern, $value ) ) { |
| 160 | - $errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $field, 'invalid' ); |
|
| 160 | + $errors['field' . $args['id']] = FrmFieldsHelper::get_error_msg( $field, 'invalid' ); |
|
| 161 | 161 | } |
| 162 | 162 | } |
| 163 | 163 | |
@@ -209,11 +209,11 @@ discard block |
||
| 209 | 209 | return; |
| 210 | 210 | } |
| 211 | 211 | |
| 212 | - if ( ! isset($_POST['g-recaptcha-response']) ) { |
|
| 212 | + if ( ! isset( $_POST['g-recaptcha-response'] ) ) { |
|
| 213 | 213 | // If captcha is missing, check if it was already verified |
| 214 | 214 | if ( ! isset( $_POST['recaptcha_checked'] ) || ! wp_verify_nonce( $_POST['recaptcha_checked'], 'frm_ajax' ) ) { |
| 215 | 215 | // There was no captcha submitted |
| 216 | - $errors[ 'field' . $args['id'] ] = __( 'The captcha is missing from this form', 'formidable' ); |
|
| 216 | + $errors['field' . $args['id']] = __( 'The captcha is missing from this form', 'formidable' ); |
|
| 217 | 217 | } |
| 218 | 218 | return; |
| 219 | 219 | } |
@@ -226,11 +226,11 @@ discard block |
||
| 226 | 226 | ), |
| 227 | 227 | ); |
| 228 | 228 | $resp = wp_remote_post( 'https://www.google.com/recaptcha/api/siteverify', $arg_array ); |
| 229 | - $response = json_decode(wp_remote_retrieve_body( $resp ), true); |
|
| 229 | + $response = json_decode( wp_remote_retrieve_body( $resp ), true ); |
|
| 230 | 230 | |
| 231 | 231 | if ( isset( $response['success'] ) && ! $response['success'] ) { |
| 232 | 232 | // What happens when the CAPTCHA was entered incorrectly |
| 233 | - $errors[ 'field' . $args['id'] ] = ( ! isset( $field->field_options['invalid'] ) || $field->field_options['invalid'] == '' ) ? $frm_settings->re_msg : $field->field_options['invalid']; |
|
| 233 | + $errors['field' . $args['id']] = ( ! isset( $field->field_options['invalid'] ) || $field->field_options['invalid'] == '' ) ? $frm_settings->re_msg : $field->field_options['invalid']; |
|
| 234 | 234 | } |
| 235 | 235 | } |
| 236 | 236 | |
@@ -259,7 +259,7 @@ discard block |
||
| 259 | 259 | |
| 260 | 260 | private static function is_akismet_spam( $values ) { |
| 261 | 261 | global $wpcom_api_key; |
| 262 | - return ( is_callable('Akismet::http_post') && ( get_option('wordpress_api_key') || $wpcom_api_key ) && self::akismet( $values ) ); |
|
| 262 | + return ( is_callable( 'Akismet::http_post' ) && ( get_option( 'wordpress_api_key' ) || $wpcom_api_key ) && self::akismet( $values ) ); |
|
| 263 | 263 | } |
| 264 | 264 | |
| 265 | 265 | private static function is_akismet_enabled_for_user( $form_id ) { |
@@ -268,7 +268,7 @@ discard block |
||
| 268 | 268 | } |
| 269 | 269 | |
| 270 | 270 | public static function blacklist_check( $values ) { |
| 271 | - if ( ! apply_filters('frm_check_blacklist', true, $values) ) { |
|
| 271 | + if ( ! apply_filters( 'frm_check_blacklist', true, $values ) ) { |
|
| 272 | 272 | return false; |
| 273 | 273 | } |
| 274 | 274 | |
@@ -278,9 +278,9 @@ discard block |
||
| 278 | 278 | return false; |
| 279 | 279 | } |
| 280 | 280 | |
| 281 | - $content = FrmEntriesHelper::entry_array_to_string($values); |
|
| 281 | + $content = FrmEntriesHelper::entry_array_to_string( $values ); |
|
| 282 | 282 | |
| 283 | - if ( empty($content) ) { |
|
| 283 | + if ( empty( $content ) ) { |
|
| 284 | 284 | return false; |
| 285 | 285 | } |
| 286 | 286 | |
@@ -289,11 +289,11 @@ discard block |
||
| 289 | 289 | foreach ( (array) $words as $word ) { |
| 290 | 290 | $word = trim( $word ); |
| 291 | 291 | |
| 292 | - if ( empty($word) ) { |
|
| 292 | + if ( empty( $word ) ) { |
|
| 293 | 293 | continue; |
| 294 | 294 | } |
| 295 | 295 | |
| 296 | - if ( preg_match('#' . preg_quote( $word, '#' ) . '#', $content) ) { |
|
| 296 | + if ( preg_match( '#' . preg_quote( $word, '#' ) . '#', $content ) ) { |
|
| 297 | 297 | return true; |
| 298 | 298 | } |
| 299 | 299 | } |
@@ -322,7 +322,7 @@ discard block |
||
| 322 | 322 | unset( $key, $data ); |
| 323 | 323 | } |
| 324 | 324 | |
| 325 | - $response = Akismet::http_post($query_string, 'comment-check'); |
|
| 325 | + $response = Akismet::http_post( $query_string, 'comment-check' ); |
|
| 326 | 326 | |
| 327 | 327 | return ( is_array( $response ) && $response[1] == 'true' ); |
| 328 | 328 | } |
@@ -345,12 +345,12 @@ discard block |
||
| 345 | 345 | |
| 346 | 346 | foreach ( $_SERVER as $key => $value ) { |
| 347 | 347 | if ( ! in_array( $key, array( 'HTTP_COOKIE', 'HTTP_COOKIE2', 'PHP_AUTH_PW' ) ) && is_string( $value ) ) { |
| 348 | - $datas[ $key ] = wp_strip_all_tags( $value ); |
|
| 348 | + $datas[$key] = wp_strip_all_tags( $value ); |
|
| 349 | 349 | } else { |
| 350 | - $datas[ $key ] = ''; |
|
| 350 | + $datas[$key] = ''; |
|
| 351 | 351 | } |
| 352 | 352 | |
| 353 | - unset($key, $value); |
|
| 353 | + unset( $key, $value ); |
|
| 354 | 354 | } |
| 355 | 355 | } |
| 356 | 356 | } |
@@ -272,7 +272,7 @@ |
||
| 272 | 272 | return $message; |
| 273 | 273 | } |
| 274 | 274 | |
| 275 | - public function manually_queue_update(){ |
|
| 276 | - set_site_transient( 'update_plugins', null ); |
|
| 277 | - } |
|
| 275 | + public function manually_queue_update(){ |
|
| 276 | + set_site_transient( 'update_plugins', null ); |
|
| 277 | + } |
|
| 278 | 278 | } |
@@ -272,7 +272,7 @@ |
||
| 272 | 272 | return $message; |
| 273 | 273 | } |
| 274 | 274 | |
| 275 | - public function manually_queue_update(){ |
|
| 275 | + public function manually_queue_update() { |
|
| 276 | 276 | set_site_transient( 'update_plugins', null ); |
| 277 | 277 | } |
| 278 | 278 | } |
@@ -38,15 +38,15 @@ discard block |
||
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | public function insert_installed_addon( $plugins ) { |
| 41 | - $plugins[ $this->plugin_slug ] = $this; |
|
| 41 | + $plugins[$this->plugin_slug] = $this; |
|
| 42 | 42 | return $plugins; |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | public static function get_addon( $plugin_slug ) { |
| 46 | 46 | $plugins = apply_filters( 'frm_installed_addons', array() ); |
| 47 | 47 | $plugin = false; |
| 48 | - if ( isset( $plugins[ $plugin_slug ] ) ) { |
|
| 49 | - $plugin = $plugins[ $plugin_slug ]; |
|
| 48 | + if ( isset( $plugins[$plugin_slug] ) ) { |
|
| 49 | + $plugin = $plugins[$plugin_slug]; |
|
| 50 | 50 | } |
| 51 | 51 | return $plugin; |
| 52 | 52 | } |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | public function show_license_message( $file, $plugin ) { |
| 96 | 96 | $wp_list_table = _get_list_table( 'WP_Plugins_List_Table' ); |
| 97 | 97 | echo '<tr class="plugin-update-tr active"><td colspan="' . esc_attr( $wp_list_table->get_column_count() ) . '" class="plugin-update colspanchange"><div class="update-message">'; |
| 98 | - echo sprintf( __( 'Your %1$s license key is missing. Please add it on the %2$slicenses page%3$s.', 'formidable' ), $this->plugin_name, '<a href="' . esc_url( admin_url('admin.php?page=formidable-settings&t=licenses_settings' ) ) . '">', '</a>' ); |
|
| 98 | + echo sprintf( __( 'Your %1$s license key is missing. Please add it on the %2$slicenses page%3$s.', 'formidable' ), $this->plugin_name, '<a href="' . esc_url( admin_url( 'admin.php?page=formidable-settings&t=licenses_settings' ) ) . '">', '</a>' ); |
|
| 99 | 99 | $id = sanitize_title( $plugin['Name'] ); |
| 100 | 100 | echo '<script type="text/javascript">var d = document.getElementById("' . esc_attr( $id ) . '");if ( d !== null ){ d.className = d.className + " update"; }</script>'; |
| 101 | 101 | echo '</div></td></tr>'; |
@@ -108,14 +108,14 @@ discard block |
||
| 108 | 108 | |
| 109 | 109 | if ( $this->is_current_version( $transient ) ) { |
| 110 | 110 | //make sure it doesn't show there is an update if plugin is up-to-date |
| 111 | - if ( isset( $transient->response[ $this->plugin_folder ] ) ) { |
|
| 112 | - unset( $transient->response[ $this->plugin_folder ] ); |
|
| 111 | + if ( isset( $transient->response[$this->plugin_folder] ) ) { |
|
| 112 | + unset( $transient->response[$this->plugin_folder] ); |
|
| 113 | 113 | } |
| 114 | - } else if ( isset( $transient->response ) && isset( $transient->response[ $this->plugin_folder ] ) ) { |
|
| 114 | + } else if ( isset( $transient->response ) && isset( $transient->response[$this->plugin_folder] ) ) { |
|
| 115 | 115 | $cache_key = 'edd_plugin_' . md5( sanitize_key( $this->license . $this->version ) . '_get_version' ); |
| 116 | 116 | $version_info = get_transient( $cache_key ); |
| 117 | 117 | if ( $version_info !== false ) { |
| 118 | - $transient->response[ $this->plugin_folder ] = $version_info; |
|
| 118 | + $transient->response[$this->plugin_folder] = $version_info; |
|
| 119 | 119 | } else { |
| 120 | 120 | if ( ! $this->has_been_cleared() ) { |
| 121 | 121 | // if the transient has expired, clear the update and trigger it again |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | $this->manually_queue_update(); |
| 124 | 124 | } |
| 125 | 125 | |
| 126 | - unset( $transient->response[ $this->plugin_folder ] ); |
|
| 126 | + unset( $transient->response[$this->plugin_folder] ); |
|
| 127 | 127 | } |
| 128 | 128 | } |
| 129 | 129 | |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | private function is_current_version( $transient ) { |
| 134 | - if ( empty( $transient->checked ) || ! isset( $transient->checked[ $this->plugin_folder ] ) ) { |
|
| 134 | + if ( empty( $transient->checked ) || ! isset( $transient->checked[$this->plugin_folder] ) ) { |
|
| 135 | 135 | return false; |
| 136 | 136 | } |
| 137 | 137 | |
@@ -140,16 +140,16 @@ discard block |
||
| 140 | 140 | return true; |
| 141 | 141 | } |
| 142 | 142 | |
| 143 | - return isset( $transient->response ) && isset( $transient->response[ $this->plugin_folder ] ) && $transient->checked[ $this->plugin_folder ] == $transient->response[ $this->plugin_folder ]->new_version; |
|
| 143 | + return isset( $transient->response ) && isset( $transient->response[$this->plugin_folder] ) && $transient->checked[$this->plugin_folder] == $transient->response[$this->plugin_folder]->new_version; |
|
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | private function has_been_cleared() { |
| 147 | 147 | $last_cleared = get_option( 'frm_last_cleared' ); |
| 148 | - return ( $last_cleared < date( 'Y-m-d H:i:s', strtotime('-5 minutes') ) ); |
|
| 148 | + return ( $last_cleared < date( 'Y-m-d H:i:s', strtotime( '-5 minutes' ) ) ); |
|
| 149 | 149 | } |
| 150 | 150 | |
| 151 | 151 | private function cleared_plugins() { |
| 152 | - update_option( 'frm_last_cleared', date('Y-m-d H:i:s') ); |
|
| 152 | + update_option( 'frm_last_cleared', date( 'Y-m-d H:i:s' ) ); |
|
| 153 | 153 | } |
| 154 | 154 | |
| 155 | 155 | public static function activate() { |
@@ -249,9 +249,9 @@ discard block |
||
| 249 | 249 | |
| 250 | 250 | $message = __( 'Your License Key was invalid', 'formidable' ); |
| 251 | 251 | if ( is_wp_error( $resp ) ) { |
| 252 | - $message = sprintf( __( 'You had an error communicating with Formidable Pro\'s API. %1$sClick here%2$s for more information.', 'formidable' ), '<a href="http://formidablepro.com/knowledgebase/why-cant-i-activate-formidable-pro/" target="_blank">', '</a>'); |
|
| 252 | + $message = sprintf( __( 'You had an error communicating with Formidable Pro\'s API. %1$sClick here%2$s for more information.', 'formidable' ), '<a href="http://formidablepro.com/knowledgebase/why-cant-i-activate-formidable-pro/" target="_blank">', '</a>' ); |
|
| 253 | 253 | if ( is_wp_error( $resp ) ) { |
| 254 | - $message .= ' '. $resp->get_error_message(); |
|
| 254 | + $message .= ' ' . $resp->get_error_message(); |
|
| 255 | 255 | } |
| 256 | 256 | } else if ( $body == 'error' || is_wp_error( $body ) ) { |
| 257 | 257 | $message = __( 'You had an HTTP error connecting to Formidable Pro\'s API', 'formidable' ); |
@@ -264,14 +264,14 @@ discard block |
||
| 264 | 264 | $message = $json_res; |
| 265 | 265 | } |
| 266 | 266 | } else if ( isset( $resp['response'] ) && isset( $resp['response']['code'] ) ) { |
| 267 | - $message = sprintf( __( 'There was a %1$s error: %2$s', 'formidable' ), $resp['response']['code'], $resp['response']['message'] .' '. $resp['body'] ); |
|
| 267 | + $message = sprintf( __( 'There was a %1$s error: %2$s', 'formidable' ), $resp['response']['code'], $resp['response']['message'] . ' ' . $resp['body'] ); |
|
| 268 | 268 | } |
| 269 | 269 | } |
| 270 | 270 | |
| 271 | 271 | return $message; |
| 272 | 272 | } |
| 273 | 273 | |
| 274 | - public function manually_queue_update(){ |
|
| 274 | + public function manually_queue_update() { |
|
| 275 | 275 | set_site_transient( 'update_plugins', null ); |
| 276 | 276 | } |
| 277 | 277 | } |
@@ -69,7 +69,7 @@ |
||
| 69 | 69 | * @uses api_request() |
| 70 | 70 | * |
| 71 | 71 | * @param array $_transient_data Update array build by WordPress. |
| 72 | - * @return array Modified update array with custom plugin data. |
|
| 72 | + * @return stdClass Modified update array with custom plugin data. |
|
| 73 | 73 | */ |
| 74 | 74 | public function check_update( $_transient_data ) { |
| 75 | 75 | |
@@ -15,184 +15,184 @@ discard block |
||
| 15 | 15 | * @version 1.6 |
| 16 | 16 | */ |
| 17 | 17 | class EDD_SL_Plugin_Updater { |
| 18 | - private $api_url = ''; |
|
| 19 | - private $api_data = array(); |
|
| 20 | - private $name = ''; |
|
| 21 | - private $slug = ''; |
|
| 22 | - private $version = ''; |
|
| 23 | - |
|
| 24 | - /** |
|
| 25 | - * Class constructor. |
|
| 26 | - * |
|
| 27 | - * @uses plugin_basename() |
|
| 28 | - * @uses hook() |
|
| 29 | - * |
|
| 30 | - * @param string $_api_url The URL pointing to the custom API endpoint. |
|
| 31 | - * @param string $_plugin_file Path to the plugin file. |
|
| 32 | - * @param array $_api_data Optional data to send with API calls. |
|
| 33 | - */ |
|
| 34 | - public function __construct( $_api_url, $_plugin_file, $_api_data = null ) { |
|
| 35 | - $this->api_url = trailingslashit( $_api_url ); |
|
| 36 | - $this->api_data = $_api_data; |
|
| 37 | - $this->name = plugin_basename( $_plugin_file ); |
|
| 38 | - $this->slug = basename( $_plugin_file, '.php' ); |
|
| 39 | - $this->version = $_api_data['version']; |
|
| 40 | - |
|
| 41 | - // Set up hooks. |
|
| 42 | - $this->init(); |
|
| 43 | - add_action( 'admin_init', array( $this, 'show_changelog' ) ); |
|
| 44 | - } |
|
| 45 | - |
|
| 46 | - /** |
|
| 47 | - * Set up WordPress filters to hook into WP's update process. |
|
| 48 | - * |
|
| 49 | - * @uses add_filter() |
|
| 50 | - * |
|
| 51 | - * @return void |
|
| 52 | - */ |
|
| 53 | - public function init() { |
|
| 54 | - add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ) ); |
|
| 55 | - add_filter( 'plugins_api', array( $this, 'plugins_api_filter' ), 10, 3 ); |
|
| 56 | - } |
|
| 57 | - |
|
| 58 | - /** |
|
| 59 | - * Check for Updates at the defined API endpoint and modify the update array. |
|
| 60 | - * |
|
| 61 | - * This function dives into the update API just when WordPress creates its update array, |
|
| 62 | - * then adds a custom API call and injects the custom plugin data retrieved from the API. |
|
| 63 | - * It is reassembled from parts of the native WordPress plugin update code. |
|
| 64 | - * See wp-includes/update.php line 121 for the original wp_update_plugins() function. |
|
| 65 | - * |
|
| 66 | - * @uses api_request() |
|
| 67 | - * |
|
| 68 | - * @param array $_transient_data Update array build by WordPress. |
|
| 69 | - * @return array Modified update array with custom plugin data. |
|
| 70 | - */ |
|
| 71 | - public function check_update( $_transient_data ) { |
|
| 72 | - |
|
| 73 | - global $pagenow; |
|
| 74 | - |
|
| 75 | - if ( ! is_object( $_transient_data ) ) { |
|
| 76 | - $_transient_data = new stdClass; |
|
| 77 | - } |
|
| 78 | - |
|
| 79 | - if ( empty( $_transient_data->response ) || empty( $_transient_data->response[ $this->name ] ) ) { |
|
| 80 | - |
|
| 81 | - $version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug ) ); |
|
| 82 | - |
|
| 83 | - if ( false !== $version_info && is_object( $version_info ) && isset( $version_info->new_version ) ) { |
|
| 84 | - |
|
| 85 | - if ( version_compare( $this->version, $version_info->new_version, '<' ) ) { |
|
| 86 | - |
|
| 87 | - if ( empty( $version_info->plugin ) ) { |
|
| 88 | - $version_info->plugin = $this->name; |
|
| 89 | - } |
|
| 18 | + private $api_url = ''; |
|
| 19 | + private $api_data = array(); |
|
| 20 | + private $name = ''; |
|
| 21 | + private $slug = ''; |
|
| 22 | + private $version = ''; |
|
| 23 | + |
|
| 24 | + /** |
|
| 25 | + * Class constructor. |
|
| 26 | + * |
|
| 27 | + * @uses plugin_basename() |
|
| 28 | + * @uses hook() |
|
| 29 | + * |
|
| 30 | + * @param string $_api_url The URL pointing to the custom API endpoint. |
|
| 31 | + * @param string $_plugin_file Path to the plugin file. |
|
| 32 | + * @param array $_api_data Optional data to send with API calls. |
|
| 33 | + */ |
|
| 34 | + public function __construct( $_api_url, $_plugin_file, $_api_data = null ) { |
|
| 35 | + $this->api_url = trailingslashit( $_api_url ); |
|
| 36 | + $this->api_data = $_api_data; |
|
| 37 | + $this->name = plugin_basename( $_plugin_file ); |
|
| 38 | + $this->slug = basename( $_plugin_file, '.php' ); |
|
| 39 | + $this->version = $_api_data['version']; |
|
| 40 | + |
|
| 41 | + // Set up hooks. |
|
| 42 | + $this->init(); |
|
| 43 | + add_action( 'admin_init', array( $this, 'show_changelog' ) ); |
|
| 44 | + } |
|
| 45 | + |
|
| 46 | + /** |
|
| 47 | + * Set up WordPress filters to hook into WP's update process. |
|
| 48 | + * |
|
| 49 | + * @uses add_filter() |
|
| 50 | + * |
|
| 51 | + * @return void |
|
| 52 | + */ |
|
| 53 | + public function init() { |
|
| 54 | + add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ) ); |
|
| 55 | + add_filter( 'plugins_api', array( $this, 'plugins_api_filter' ), 10, 3 ); |
|
| 56 | + } |
|
| 57 | + |
|
| 58 | + /** |
|
| 59 | + * Check for Updates at the defined API endpoint and modify the update array. |
|
| 60 | + * |
|
| 61 | + * This function dives into the update API just when WordPress creates its update array, |
|
| 62 | + * then adds a custom API call and injects the custom plugin data retrieved from the API. |
|
| 63 | + * It is reassembled from parts of the native WordPress plugin update code. |
|
| 64 | + * See wp-includes/update.php line 121 for the original wp_update_plugins() function. |
|
| 65 | + * |
|
| 66 | + * @uses api_request() |
|
| 67 | + * |
|
| 68 | + * @param array $_transient_data Update array build by WordPress. |
|
| 69 | + * @return array Modified update array with custom plugin data. |
|
| 70 | + */ |
|
| 71 | + public function check_update( $_transient_data ) { |
|
| 72 | + |
|
| 73 | + global $pagenow; |
|
| 74 | + |
|
| 75 | + if ( ! is_object( $_transient_data ) ) { |
|
| 76 | + $_transient_data = new stdClass; |
|
| 77 | + } |
|
| 90 | 78 | |
| 91 | - $_transient_data->response[ $this->name ] = $version_info; |
|
| 79 | + if ( empty( $_transient_data->response ) || empty( $_transient_data->response[ $this->name ] ) ) { |
|
| 92 | 80 | |
| 93 | - } |
|
| 94 | - |
|
| 95 | - $_transient_data->last_checked = time(); |
|
| 96 | - $_transient_data->checked[ $this->name ] = $this->version; |
|
| 81 | + $version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug ) ); |
|
| 97 | 82 | |
| 98 | - } |
|
| 99 | - } |
|
| 83 | + if ( false !== $version_info && is_object( $version_info ) && isset( $version_info->new_version ) ) { |
|
| 100 | 84 | |
| 101 | - return $_transient_data; |
|
| 102 | - } |
|
| 85 | + if ( version_compare( $this->version, $version_info->new_version, '<' ) ) { |
|
| 103 | 86 | |
| 104 | - /** |
|
| 105 | - * Updates information on the "View version x.x details" page with custom data. |
|
| 106 | - * |
|
| 107 | - * @uses api_request() |
|
| 108 | - * |
|
| 109 | - * @param mixed $_data |
|
| 110 | - * @param string $_action |
|
| 111 | - * @param object $_args |
|
| 112 | - * @return object $_data |
|
| 113 | - */ |
|
| 114 | - public function plugins_api_filter( $_data, $_action = '', $_args = null ) { |
|
| 87 | + if ( empty( $version_info->plugin ) ) { |
|
| 88 | + $version_info->plugin = $this->name; |
|
| 89 | + } |
|
| 115 | 90 | |
| 116 | - if ( $_action != 'plugin_information' ) { |
|
| 91 | + $_transient_data->response[ $this->name ] = $version_info; |
|
| 117 | 92 | |
| 118 | - return $_data; |
|
| 93 | + } |
|
| 119 | 94 | |
| 120 | - } |
|
| 95 | + $_transient_data->last_checked = time(); |
|
| 96 | + $_transient_data->checked[ $this->name ] = $this->version; |
|
| 121 | 97 | |
| 122 | - if ( ! isset( $_args->slug ) || ( $_args->slug != $this->slug ) ) { |
|
| 98 | + } |
|
| 99 | + } |
|
| 123 | 100 | |
| 124 | - return $_data; |
|
| 101 | + return $_transient_data; |
|
| 102 | + } |
|
| 125 | 103 | |
| 126 | - } |
|
| 104 | + /** |
|
| 105 | + * Updates information on the "View version x.x details" page with custom data. |
|
| 106 | + * |
|
| 107 | + * @uses api_request() |
|
| 108 | + * |
|
| 109 | + * @param mixed $_data |
|
| 110 | + * @param string $_action |
|
| 111 | + * @param object $_args |
|
| 112 | + * @return object $_data |
|
| 113 | + */ |
|
| 114 | + public function plugins_api_filter( $_data, $_action = '', $_args = null ) { |
|
| 127 | 115 | |
| 128 | - $to_send = array( |
|
| 129 | - 'slug' => $this->slug, |
|
| 130 | - 'is_ssl' => is_ssl(), |
|
| 131 | - 'fields' => array( |
|
| 132 | - 'banners' => false, // These will be supported soon hopefully |
|
| 133 | - 'reviews' => false, |
|
| 134 | - ), |
|
| 135 | - ); |
|
| 116 | + if ( $_action != 'plugin_information' ) { |
|
| 136 | 117 | |
| 137 | - $api_response = $this->api_request( 'plugin_information', $to_send ); |
|
| 118 | + return $_data; |
|
| 138 | 119 | |
| 139 | - if ( false !== $api_response ) { |
|
| 140 | - $_data = $api_response; |
|
| 141 | - } |
|
| 120 | + } |
|
| 142 | 121 | |
| 143 | - return $_data; |
|
| 144 | - } |
|
| 122 | + if ( ! isset( $_args->slug ) || ( $_args->slug != $this->slug ) ) { |
|
| 145 | 123 | |
| 124 | + return $_data; |
|
| 146 | 125 | |
| 147 | - /** |
|
| 148 | - * Disable SSL verification in order to prevent download update failures |
|
| 149 | - * |
|
| 150 | - * @param array $args |
|
| 151 | - * @param string $url |
|
| 152 | - * @return object $array |
|
| 153 | - */ |
|
| 154 | - public function http_request_args( $args, $url ) { |
|
| 155 | - // If it is an https request and we are performing a package download, disable ssl verification |
|
| 156 | - if ( strpos( $url, 'https://' ) !== false && strpos( $url, 'edd_action=package_download' ) ) { |
|
| 157 | - $args['sslverify'] = false; |
|
| 158 | - } |
|
| 159 | - return $args; |
|
| 160 | - } |
|
| 126 | + } |
|
| 161 | 127 | |
| 162 | - /** |
|
| 163 | - * Calls the API and, if successfull, returns the object delivered by the API. |
|
| 164 | - * |
|
| 165 | - * @uses get_bloginfo() |
|
| 166 | - * @uses wp_remote_post() |
|
| 167 | - * @uses is_wp_error() |
|
| 168 | - * |
|
| 169 | - * @param string $_action The requested action. |
|
| 170 | - * @param array $_data Parameters for the API action. |
|
| 171 | - * @return false|object |
|
| 172 | - */ |
|
| 173 | - private function api_request( $_action, $_data ) { |
|
| 128 | + $to_send = array( |
|
| 129 | + 'slug' => $this->slug, |
|
| 130 | + 'is_ssl' => is_ssl(), |
|
| 131 | + 'fields' => array( |
|
| 132 | + 'banners' => false, // These will be supported soon hopefully |
|
| 133 | + 'reviews' => false, |
|
| 134 | + ), |
|
| 135 | + ); |
|
| 174 | 136 | |
| 175 | - global $wp_version; |
|
| 137 | + $api_response = $this->api_request( 'plugin_information', $to_send ); |
|
| 176 | 138 | |
| 177 | - $data = array_merge( $this->api_data, $_data ); |
|
| 139 | + if ( false !== $api_response ) { |
|
| 140 | + $_data = $api_response; |
|
| 141 | + } |
|
| 178 | 142 | |
| 179 | - if ( $data['slug'] != $this->slug ) { |
|
| 180 | - return; |
|
| 143 | + return $_data; |
|
| 144 | + } |
|
| 145 | + |
|
| 146 | + |
|
| 147 | + /** |
|
| 148 | + * Disable SSL verification in order to prevent download update failures |
|
| 149 | + * |
|
| 150 | + * @param array $args |
|
| 151 | + * @param string $url |
|
| 152 | + * @return object $array |
|
| 153 | + */ |
|
| 154 | + public function http_request_args( $args, $url ) { |
|
| 155 | + // If it is an https request and we are performing a package download, disable ssl verification |
|
| 156 | + if ( strpos( $url, 'https://' ) !== false && strpos( $url, 'edd_action=package_download' ) ) { |
|
| 157 | + $args['sslverify'] = false; |
|
| 158 | + } |
|
| 159 | + return $args; |
|
| 160 | + } |
|
| 161 | + |
|
| 162 | + /** |
|
| 163 | + * Calls the API and, if successfull, returns the object delivered by the API. |
|
| 164 | + * |
|
| 165 | + * @uses get_bloginfo() |
|
| 166 | + * @uses wp_remote_post() |
|
| 167 | + * @uses is_wp_error() |
|
| 168 | + * |
|
| 169 | + * @param string $_action The requested action. |
|
| 170 | + * @param array $_data Parameters for the API action. |
|
| 171 | + * @return false|object |
|
| 172 | + */ |
|
| 173 | + private function api_request( $_action, $_data ) { |
|
| 174 | + |
|
| 175 | + global $wp_version; |
|
| 176 | + |
|
| 177 | + $data = array_merge( $this->api_data, $_data ); |
|
| 178 | + |
|
| 179 | + if ( $data['slug'] != $this->slug ) { |
|
| 180 | + return; |
|
| 181 | 181 | } |
| 182 | 182 | |
| 183 | - if ( $this->api_url == home_url() ) { |
|
| 184 | - return false; // Don't allow a plugin to ping itself |
|
| 185 | - } |
|
| 183 | + if ( $this->api_url == home_url() ) { |
|
| 184 | + return false; // Don't allow a plugin to ping itself |
|
| 185 | + } |
|
| 186 | 186 | |
| 187 | - $api_params = array( |
|
| 188 | - 'edd_action' => 'get_version', |
|
| 189 | - 'license' => ! empty( $data['license'] ) ? $data['license'] : '', |
|
| 190 | - 'item_name' => isset( $data['item_name'] ) ? $data['item_name'] : false, |
|
| 191 | - 'item_id' => isset( $data['item_id'] ) ? $data['item_id'] : false, |
|
| 192 | - 'slug' => $data['slug'], |
|
| 193 | - 'author' => $data['author'], |
|
| 194 | - 'url' => home_url(), |
|
| 195 | - ); |
|
| 187 | + $api_params = array( |
|
| 188 | + 'edd_action' => 'get_version', |
|
| 189 | + 'license' => ! empty( $data['license'] ) ? $data['license'] : '', |
|
| 190 | + 'item_name' => isset( $data['item_name'] ) ? $data['item_name'] : false, |
|
| 191 | + 'item_id' => isset( $data['item_id'] ) ? $data['item_id'] : false, |
|
| 192 | + 'slug' => $data['slug'], |
|
| 193 | + 'author' => $data['author'], |
|
| 194 | + 'url' => home_url(), |
|
| 195 | + ); |
|
| 196 | 196 | |
| 197 | 197 | $cache_key = 'edd_plugin_' . md5( sanitize_key( $api_params['license'] . $this->version ) . '_' . $api_params['edd_action'] ); |
| 198 | 198 | $cached_response = get_transient( $cache_key ); |
@@ -201,47 +201,47 @@ discard block |
||
| 201 | 201 | return $cached_response; |
| 202 | 202 | } |
| 203 | 203 | |
| 204 | - $request = wp_remote_post( $this->api_url, array( 'timeout' => 15, 'sslverify' => false, 'body' => $api_params ) ); |
|
| 204 | + $request = wp_remote_post( $this->api_url, array( 'timeout' => 15, 'sslverify' => false, 'body' => $api_params ) ); |
|
| 205 | 205 | |
| 206 | - if ( ! is_wp_error( $request ) ) { |
|
| 207 | - $request = json_decode( wp_remote_retrieve_body( $request ) ); |
|
| 208 | - } |
|
| 206 | + if ( ! is_wp_error( $request ) ) { |
|
| 207 | + $request = json_decode( wp_remote_retrieve_body( $request ) ); |
|
| 208 | + } |
|
| 209 | 209 | |
| 210 | - if ( $request && isset( $request->sections ) ) { |
|
| 211 | - $request->sections = maybe_unserialize( $request->sections ); |
|
| 210 | + if ( $request && isset( $request->sections ) ) { |
|
| 211 | + $request->sections = maybe_unserialize( $request->sections ); |
|
| 212 | 212 | set_transient( $cache_key, $request, DAY_IN_SECONDS ); |
| 213 | - } else { |
|
| 214 | - $request = false; |
|
| 213 | + } else { |
|
| 214 | + $request = false; |
|
| 215 | 215 | set_transient( $cache_key, 0, DAY_IN_SECONDS ); |
| 216 | - } |
|
| 216 | + } |
|
| 217 | 217 | |
| 218 | - return $request; |
|
| 219 | - } |
|
| 218 | + return $request; |
|
| 219 | + } |
|
| 220 | 220 | |
| 221 | - public function show_changelog() { |
|
| 221 | + public function show_changelog() { |
|
| 222 | 222 | |
| 223 | - if ( empty( $_REQUEST['edd_sl_action'] ) || 'view_plugin_changelog' != $_REQUEST['edd_sl_action'] ) { |
|
| 224 | - return; |
|
| 225 | - } |
|
| 223 | + if ( empty( $_REQUEST['edd_sl_action'] ) || 'view_plugin_changelog' != $_REQUEST['edd_sl_action'] ) { |
|
| 224 | + return; |
|
| 225 | + } |
|
| 226 | 226 | |
| 227 | - if ( empty( $_REQUEST['plugin'] ) ) { |
|
| 228 | - return; |
|
| 229 | - } |
|
| 227 | + if ( empty( $_REQUEST['plugin'] ) ) { |
|
| 228 | + return; |
|
| 229 | + } |
|
| 230 | 230 | |
| 231 | - if ( empty( $_REQUEST['slug'] ) ) { |
|
| 232 | - return; |
|
| 233 | - } |
|
| 231 | + if ( empty( $_REQUEST['slug'] ) ) { |
|
| 232 | + return; |
|
| 233 | + } |
|
| 234 | 234 | |
| 235 | - if ( ! current_user_can( 'update_plugins' ) ) { |
|
| 236 | - wp_die( __( 'You do not have permission to install plugin updates', 'edd' ), __( 'Error', 'edd' ), array( 'response' => 403 ) ); |
|
| 237 | - } |
|
| 235 | + if ( ! current_user_can( 'update_plugins' ) ) { |
|
| 236 | + wp_die( __( 'You do not have permission to install plugin updates', 'edd' ), __( 'Error', 'edd' ), array( 'response' => 403 ) ); |
|
| 237 | + } |
|
| 238 | 238 | |
| 239 | - $response = $this->api_request( 'plugin_latest_version', array( 'slug' => $_REQUEST['slug'] ) ); |
|
| 239 | + $response = $this->api_request( 'plugin_latest_version', array( 'slug' => $_REQUEST['slug'] ) ); |
|
| 240 | 240 | |
| 241 | - if ( $response && isset( $response->sections['changelog'] ) ) { |
|
| 242 | - echo '<div style="background:#fff;padding:10px;">' . $response->sections['changelog'] . '</div>'; |
|
| 243 | - } |
|
| 241 | + if ( $response && isset( $response->sections['changelog'] ) ) { |
|
| 242 | + echo '<div style="background:#fff;padding:10px;">' . $response->sections['changelog'] . '</div>'; |
|
| 243 | + } |
|
| 244 | 244 | |
| 245 | - exit; |
|
| 246 | - } |
|
| 245 | + exit; |
|
| 246 | + } |
|
| 247 | 247 | } |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | $_transient_data = new stdClass; |
| 77 | 77 | } |
| 78 | 78 | |
| 79 | - if ( empty( $_transient_data->response ) || empty( $_transient_data->response[ $this->name ] ) ) { |
|
| 79 | + if ( empty( $_transient_data->response ) || empty( $_transient_data->response[$this->name] ) ) { |
|
| 80 | 80 | |
| 81 | 81 | $version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug ) ); |
| 82 | 82 | |
@@ -88,12 +88,12 @@ discard block |
||
| 88 | 88 | $version_info->plugin = $this->name; |
| 89 | 89 | } |
| 90 | 90 | |
| 91 | - $_transient_data->response[ $this->name ] = $version_info; |
|
| 91 | + $_transient_data->response[$this->name] = $version_info; |
|
| 92 | 92 | |
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | $_transient_data->last_checked = time(); |
| 96 | - $_transient_data->checked[ $this->name ] = $this->version; |
|
| 96 | + $_transient_data->checked[$this->name] = $this->version; |
|
| 97 | 97 | |
| 98 | 98 | } |
| 99 | 99 | } |
@@ -17,6 +17,6 @@ |
||
| 17 | 17 | </ul> |
| 18 | 18 | |
| 19 | 19 | <?php if ( $form && $title == 'show' ) { ?> |
| 20 | - <input id="title" type="text" value="<?php echo esc_attr( $form->name == '' ? __( '(no title)') : $form->name ) ?>" readonly="readonly" disabled="disabled" /> |
|
| 20 | + <input id="title" type="text" value="<?php echo esc_attr( $form->name == '' ? __( '(no title)' ) : $form->name ) ?>" readonly="readonly" disabled="disabled" /> |
|
| 21 | 21 | <?php } ?> |
| 22 | 22 | </div> |
@@ -7,16 +7,16 @@ |
||
| 7 | 7 | continue; |
| 8 | 8 | } |
| 9 | 9 | |
| 10 | - if ( isset( $plugin_names[ $addon['info']['slug'] ] ) ) { |
|
| 11 | - $installed = is_dir( WP_PLUGIN_DIR . '/' . $plugin_names[ $addon['info']['slug'] ] ); |
|
| 10 | + if ( isset( $plugin_names[$addon['info']['slug']] ) ) { |
|
| 11 | + $installed = is_dir( WP_PLUGIN_DIR . '/' . $plugin_names[$addon['info']['slug']] ); |
|
| 12 | 12 | } else { |
| 13 | - $installed = isset( $installed_addons[ $addon['info']['slug'] ] ) || is_dir( WP_PLUGIN_DIR . '/formidable-' . $addon['info']['slug'] ); |
|
| 13 | + $installed = isset( $installed_addons[$addon['info']['slug']] ) || is_dir( WP_PLUGIN_DIR . '/formidable-' . $addon['info']['slug'] ); |
|
| 14 | 14 | } |
| 15 | 15 | $has_thumbnail = ! empty( $addon['info']['thumbnail'] ); |
| 16 | 16 | $addon['info']['link'] = $addon['info']['link'] . $append_affiliate; |
| 17 | 17 | |
| 18 | 18 | ?> |
| 19 | - <div class="plugin-card <?php echo esc_attr( $has_thumbnail ? '' : 'frm-no-thumb') ?>"> |
|
| 19 | + <div class="plugin-card <?php echo esc_attr( $has_thumbnail ? '' : 'frm-no-thumb' ) ?>"> |
|
| 20 | 20 | <div class="plugin-card-top"> |
| 21 | 21 | <div class="name column-name"> |
| 22 | 22 | <h3> |