@@ -180,6 +180,7 @@ |
||
| 180 | 180 | * |
| 181 | 181 | * @param int $id |
| 182 | 182 | * @param array $values |
| 183 | + * @param string $update_type |
|
| 183 | 184 | * @return boolean|int $query_results |
| 184 | 185 | */ |
| 185 | 186 | private static function update_entry( $id, $values, $update_type ) { |
@@ -6,11 +6,11 @@ discard block |
||
| 6 | 6 | class FrmEntry { |
| 7 | 7 | |
| 8 | 8 | /** |
| 9 | - * Create a new entry |
|
| 10 | - * |
|
| 11 | - * @param array $values |
|
| 12 | - * @return int | boolean $entry_id |
|
| 13 | - */ |
|
| 9 | + * Create a new entry |
|
| 10 | + * |
|
| 11 | + * @param array $values |
|
| 12 | + * @return int | boolean $entry_id |
|
| 13 | + */ |
|
| 14 | 14 | public static function create( $values ) { |
| 15 | 15 | $entry_id = self::create_entry( $values, 'standard' ); |
| 16 | 16 | |
@@ -18,12 +18,12 @@ discard block |
||
| 18 | 18 | } |
| 19 | 19 | |
| 20 | 20 | /** |
| 21 | - * Create a new entry with some differences depending on type |
|
| 22 | - * |
|
| 23 | - * @param array $values |
|
| 24 | - * @param string $type |
|
| 25 | - * @return int | boolean $entry_id |
|
| 26 | - */ |
|
| 21 | + * Create a new entry with some differences depending on type |
|
| 22 | + * |
|
| 23 | + * @param array $values |
|
| 24 | + * @param string $type |
|
| 25 | + * @return int | boolean $entry_id |
|
| 26 | + */ |
|
| 27 | 27 | private static function create_entry( $values, $type ) { |
| 28 | 28 | $new_values = self::before_insert_entry_in_database( $values, $type ); |
| 29 | 29 | |
@@ -37,10 +37,10 @@ discard block |
||
| 37 | 37 | return $entry_id; |
| 38 | 38 | } |
| 39 | 39 | |
| 40 | - /** |
|
| 41 | - * check for duplicate entries created in the last minute |
|
| 42 | - * @return boolean |
|
| 43 | - */ |
|
| 40 | + /** |
|
| 41 | + * check for duplicate entries created in the last minute |
|
| 42 | + * @return boolean |
|
| 43 | + */ |
|
| 44 | 44 | public static function is_duplicate( $new_values, $values ) { |
| 45 | 45 | $duplicate_entry_time = apply_filters( 'frm_time_to_check_duplicates', 60, $new_values ); |
| 46 | 46 | |
@@ -48,55 +48,55 @@ discard block |
||
| 48 | 48 | return false; |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | - $check_val = $new_values; |
|
| 51 | + $check_val = $new_values; |
|
| 52 | 52 | $check_val['created_at >'] = date( 'Y-m-d H:i:s', ( strtotime( $new_values['created_at'] ) - absint( $duplicate_entry_time ) ) ); |
| 53 | 53 | |
| 54 | 54 | unset( $check_val['created_at'], $check_val['updated_at'] ); |
| 55 | 55 | unset( $check_val['is_draft'], $check_val['id'], $check_val['item_key'] ); |
| 56 | 56 | |
| 57 | - if ( $new_values['item_key'] == $new_values['name'] ) { |
|
| 58 | - unset($check_val['name']); |
|
| 59 | - } |
|
| 57 | + if ( $new_values['item_key'] == $new_values['name'] ) { |
|
| 58 | + unset($check_val['name']); |
|
| 59 | + } |
|
| 60 | 60 | |
| 61 | - global $wpdb; |
|
| 61 | + global $wpdb; |
|
| 62 | 62 | $entry_exists = FrmDb::get_col( $wpdb->prefix . 'frm_items', $check_val, 'id', array( 'order_by' => 'created_at DESC' ) ); |
| 63 | 63 | |
| 64 | - if ( ! $entry_exists || empty($entry_exists) || ! isset($values['item_meta']) ) { |
|
| 65 | - return false; |
|
| 66 | - } |
|
| 64 | + if ( ! $entry_exists || empty($entry_exists) || ! isset($values['item_meta']) ) { |
|
| 65 | + return false; |
|
| 66 | + } |
|
| 67 | 67 | |
| 68 | - $is_duplicate = false; |
|
| 69 | - foreach ( $entry_exists as $entry_exist ) { |
|
| 70 | - $is_duplicate = true; |
|
| 68 | + $is_duplicate = false; |
|
| 69 | + foreach ( $entry_exists as $entry_exist ) { |
|
| 70 | + $is_duplicate = true; |
|
| 71 | 71 | |
| 72 | - //add more checks here to make sure it's a duplicate |
|
| 73 | - $metas = FrmEntryMeta::get_entry_meta_info($entry_exist); |
|
| 74 | - $field_metas = array(); |
|
| 75 | - foreach ( $metas as $meta ) { |
|
| 72 | + //add more checks here to make sure it's a duplicate |
|
| 73 | + $metas = FrmEntryMeta::get_entry_meta_info($entry_exist); |
|
| 74 | + $field_metas = array(); |
|
| 75 | + foreach ( $metas as $meta ) { |
|
| 76 | 76 | $field_metas[ $meta->field_id ] = $meta->meta_value; |
| 77 | - } |
|
| 78 | - |
|
| 79 | - // If prev entry is empty and current entry is not, they are not duplicates |
|
| 80 | - $filtered_vals = array_filter( $values['item_meta'] ); |
|
| 81 | - if ( empty( $field_metas ) && ! empty( $filtered_vals ) ) { |
|
| 82 | - return false; |
|
| 83 | - } |
|
| 84 | - |
|
| 85 | - $diff = array_diff_assoc($field_metas, array_map('maybe_serialize', $values['item_meta'])); |
|
| 86 | - foreach ( $diff as $field_id => $meta_value ) { |
|
| 87 | - if ( ! empty($meta_value) ) { |
|
| 88 | - $is_duplicate = false; |
|
| 89 | - continue; |
|
| 90 | - } |
|
| 91 | - } |
|
| 92 | - |
|
| 93 | - if ( $is_duplicate ) { |
|
| 77 | + } |
|
| 78 | + |
|
| 79 | + // If prev entry is empty and current entry is not, they are not duplicates |
|
| 80 | + $filtered_vals = array_filter( $values['item_meta'] ); |
|
| 81 | + if ( empty( $field_metas ) && ! empty( $filtered_vals ) ) { |
|
| 82 | + return false; |
|
| 83 | + } |
|
| 84 | + |
|
| 85 | + $diff = array_diff_assoc($field_metas, array_map('maybe_serialize', $values['item_meta'])); |
|
| 86 | + foreach ( $diff as $field_id => $meta_value ) { |
|
| 87 | + if ( ! empty($meta_value) ) { |
|
| 88 | + $is_duplicate = false; |
|
| 89 | + continue; |
|
| 90 | + } |
|
| 91 | + } |
|
| 92 | + |
|
| 93 | + if ( $is_duplicate ) { |
|
| 94 | 94 | break; |
| 95 | - } |
|
| 96 | - } |
|
| 95 | + } |
|
| 96 | + } |
|
| 97 | 97 | |
| 98 | - return $is_duplicate; |
|
| 99 | - } |
|
| 98 | + return $is_duplicate; |
|
| 99 | + } |
|
| 100 | 100 | |
| 101 | 101 | /** |
| 102 | 102 | * Determine if an entry needs to be checked as a possible duplicate |
@@ -125,46 +125,46 @@ discard block |
||
| 125 | 125 | return true; |
| 126 | 126 | } |
| 127 | 127 | |
| 128 | - public static function duplicate( $id ) { |
|
| 129 | - global $wpdb; |
|
| 128 | + public static function duplicate( $id ) { |
|
| 129 | + global $wpdb; |
|
| 130 | 130 | |
| 131 | - $values = self::getOne( $id ); |
|
| 131 | + $values = self::getOne( $id ); |
|
| 132 | 132 | |
| 133 | - $new_values = array(); |
|
| 133 | + $new_values = array(); |
|
| 134 | 134 | $new_values['item_key'] = FrmAppHelper::get_unique_key( '', $wpdb->prefix . 'frm_items', 'item_key' ); |
| 135 | - $new_values['name'] = $values->name; |
|
| 136 | - $new_values['is_draft'] = $values->is_draft; |
|
| 137 | - $new_values['user_id'] = $new_values['updated_by'] = (int) $values->user_id; |
|
| 138 | - $new_values['form_id'] = $values->form_id ? (int) $values->form_id: null; |
|
| 139 | - $new_values['created_at'] = $new_values['updated_at'] = current_time('mysql', 1); |
|
| 135 | + $new_values['name'] = $values->name; |
|
| 136 | + $new_values['is_draft'] = $values->is_draft; |
|
| 137 | + $new_values['user_id'] = $new_values['updated_by'] = (int) $values->user_id; |
|
| 138 | + $new_values['form_id'] = $values->form_id ? (int) $values->form_id: null; |
|
| 139 | + $new_values['created_at'] = $new_values['updated_at'] = current_time('mysql', 1); |
|
| 140 | 140 | |
| 141 | 141 | $query_results = $wpdb->insert( $wpdb->prefix . 'frm_items', $new_values ); |
| 142 | - if ( ! $query_results ) { |
|
| 143 | - return false; |
|
| 144 | - } |
|
| 142 | + if ( ! $query_results ) { |
|
| 143 | + return false; |
|
| 144 | + } |
|
| 145 | 145 | |
| 146 | - $entry_id = $wpdb->insert_id; |
|
| 146 | + $entry_id = $wpdb->insert_id; |
|
| 147 | 147 | |
| 148 | - global $frm_vars; |
|
| 149 | - if ( ! isset($frm_vars['saved_entries']) ) { |
|
| 150 | - $frm_vars['saved_entries'] = array(); |
|
| 151 | - } |
|
| 152 | - $frm_vars['saved_entries'][] = (int) $entry_id; |
|
| 148 | + global $frm_vars; |
|
| 149 | + if ( ! isset($frm_vars['saved_entries']) ) { |
|
| 150 | + $frm_vars['saved_entries'] = array(); |
|
| 151 | + } |
|
| 152 | + $frm_vars['saved_entries'][] = (int) $entry_id; |
|
| 153 | 153 | |
| 154 | - FrmEntryMeta::duplicate_entry_metas($id, $entry_id); |
|
| 154 | + FrmEntryMeta::duplicate_entry_metas($id, $entry_id); |
|
| 155 | 155 | self::clear_cache(); |
| 156 | 156 | |
| 157 | 157 | do_action( 'frm_after_duplicate_entry', $entry_id, $new_values['form_id'], array( 'old_id' => $id ) ); |
| 158 | - return $entry_id; |
|
| 159 | - } |
|
| 158 | + return $entry_id; |
|
| 159 | + } |
|
| 160 | 160 | |
| 161 | 161 | /** |
| 162 | - * Update an entry (not via XML) |
|
| 163 | - * |
|
| 164 | - * @param int $id |
|
| 165 | - * @param array $values |
|
| 166 | - * @return boolean|int $update_results |
|
| 167 | - */ |
|
| 162 | + * Update an entry (not via XML) |
|
| 163 | + * |
|
| 164 | + * @param int $id |
|
| 165 | + * @param array $values |
|
| 166 | + * @return boolean|int $update_results |
|
| 167 | + */ |
|
| 168 | 168 | public static function update( $id, $values ) { |
| 169 | 169 | $update_results = self::update_entry( $id, $values, 'standard' ); |
| 170 | 170 | |
@@ -172,14 +172,14 @@ discard block |
||
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 174 | /** |
| 175 | - * Update an entry with some differences depending on the update type |
|
| 176 | - * |
|
| 177 | - * @since 2.0.16 |
|
| 178 | - * |
|
| 179 | - * @param int $id |
|
| 180 | - * @param array $values |
|
| 181 | - * @return boolean|int $query_results |
|
| 182 | - */ |
|
| 175 | + * Update an entry with some differences depending on the update type |
|
| 176 | + * |
|
| 177 | + * @since 2.0.16 |
|
| 178 | + * |
|
| 179 | + * @param int $id |
|
| 180 | + * @param array $values |
|
| 181 | + * @return boolean|int $query_results |
|
| 182 | + */ |
|
| 183 | 183 | private static function update_entry( $id, $values, $update_type ) { |
| 184 | 184 | global $wpdb; |
| 185 | 185 | |
@@ -198,34 +198,34 @@ discard block |
||
| 198 | 198 | } |
| 199 | 199 | |
| 200 | 200 | public static function &destroy( $id ) { |
| 201 | - global $wpdb; |
|
| 202 | - $id = (int) $id; |
|
| 201 | + global $wpdb; |
|
| 202 | + $id = (int) $id; |
|
| 203 | 203 | |
| 204 | 204 | $entry = self::getOne( $id ); |
| 205 | - if ( ! $entry ) { |
|
| 206 | - $result = false; |
|
| 207 | - return $result; |
|
| 208 | - } |
|
| 205 | + if ( ! $entry ) { |
|
| 206 | + $result = false; |
|
| 207 | + return $result; |
|
| 208 | + } |
|
| 209 | 209 | |
| 210 | - do_action('frm_before_destroy_entry', $id, $entry); |
|
| 210 | + do_action('frm_before_destroy_entry', $id, $entry); |
|
| 211 | 211 | |
| 212 | 212 | $wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->prefix . 'frm_item_metas WHERE item_id=%d', $id ) ); |
| 213 | 213 | $result = $wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->prefix . 'frm_items WHERE id=%d', $id ) ); |
| 214 | 214 | |
| 215 | 215 | self::clear_cache(); |
| 216 | 216 | |
| 217 | - return $result; |
|
| 218 | - } |
|
| 217 | + return $result; |
|
| 218 | + } |
|
| 219 | 219 | |
| 220 | 220 | public static function &update_form( $id, $value, $form_id ) { |
| 221 | - global $wpdb; |
|
| 222 | - $form_id = isset($value) ? $form_id : null; |
|
| 221 | + global $wpdb; |
|
| 222 | + $form_id = isset($value) ? $form_id : null; |
|
| 223 | 223 | $result = $wpdb->update( $wpdb->prefix . 'frm_items', array( 'form_id' => $form_id ), array( 'id' => $id ) ); |
| 224 | 224 | if ( $result ) { |
| 225 | 225 | self::clear_cache(); |
| 226 | 226 | } |
| 227 | - return $result; |
|
| 228 | - } |
|
| 227 | + return $result; |
|
| 228 | + } |
|
| 229 | 229 | |
| 230 | 230 | /** |
| 231 | 231 | * Clear entry caching |
@@ -261,161 +261,161 @@ discard block |
||
| 261 | 261 | } |
| 262 | 262 | |
| 263 | 263 | public static function getOne( $id, $meta = false ) { |
| 264 | - global $wpdb; |
|
| 264 | + global $wpdb; |
|
| 265 | 265 | |
| 266 | - $query = "SELECT it.*, fr.name as form_name, fr.form_key as form_key FROM {$wpdb->prefix}frm_items it |
|
| 266 | + $query = "SELECT it.*, fr.name as form_name, fr.form_key as form_key FROM {$wpdb->prefix}frm_items it |
|
| 267 | 267 | LEFT OUTER JOIN {$wpdb->prefix}frm_forms fr ON it.form_id=fr.id WHERE "; |
| 268 | 268 | |
| 269 | - $query .= is_numeric($id) ? 'it.id=%d' : 'it.item_key=%s'; |
|
| 270 | - $query_args = array( $id ); |
|
| 271 | - $query = $wpdb->prepare( $query, $query_args ); |
|
| 269 | + $query .= is_numeric($id) ? 'it.id=%d' : 'it.item_key=%s'; |
|
| 270 | + $query_args = array( $id ); |
|
| 271 | + $query = $wpdb->prepare( $query, $query_args ); |
|
| 272 | 272 | |
| 273 | - if ( ! $meta ) { |
|
| 273 | + if ( ! $meta ) { |
|
| 274 | 274 | $entry = FrmAppHelper::check_cache( $id . '_nometa', 'frm_entry', $query, 'get_row' ); |
| 275 | - return stripslashes_deep($entry); |
|
| 276 | - } |
|
| 275 | + return stripslashes_deep($entry); |
|
| 276 | + } |
|
| 277 | 277 | |
| 278 | - $entry = FrmAppHelper::check_cache( $id, 'frm_entry' ); |
|
| 279 | - if ( $entry !== false ) { |
|
| 280 | - return stripslashes_deep($entry); |
|
| 281 | - } |
|
| 278 | + $entry = FrmAppHelper::check_cache( $id, 'frm_entry' ); |
|
| 279 | + if ( $entry !== false ) { |
|
| 280 | + return stripslashes_deep($entry); |
|
| 281 | + } |
|
| 282 | 282 | |
| 283 | - $entry = $wpdb->get_row( $query ); |
|
| 284 | - $entry = self::get_meta($entry); |
|
| 283 | + $entry = $wpdb->get_row( $query ); |
|
| 284 | + $entry = self::get_meta($entry); |
|
| 285 | 285 | |
| 286 | - return stripslashes_deep($entry); |
|
| 287 | - } |
|
| 286 | + return stripslashes_deep($entry); |
|
| 287 | + } |
|
| 288 | 288 | |
| 289 | 289 | public static function get_meta( $entry ) { |
| 290 | - if ( ! $entry ) { |
|
| 291 | - return $entry; |
|
| 292 | - } |
|
| 290 | + if ( ! $entry ) { |
|
| 291 | + return $entry; |
|
| 292 | + } |
|
| 293 | 293 | |
| 294 | - global $wpdb; |
|
| 294 | + global $wpdb; |
|
| 295 | 295 | $metas = FrmDb::get_results( $wpdb->prefix . 'frm_item_metas m LEFT JOIN ' . $wpdb->prefix . 'frm_fields f ON m.field_id=f.id', array( 'item_id' => $entry->id, 'field_id !' => 0 ), 'field_id, meta_value, field_key, item_id' ); |
| 296 | 296 | |
| 297 | - $entry->metas = array(); |
|
| 297 | + $entry->metas = array(); |
|
| 298 | 298 | |
| 299 | 299 | $include_key = apply_filters( 'frm_include_meta_keys', false ); |
| 300 | - foreach ( $metas as $meta_val ) { |
|
| 301 | - if ( $meta_val->item_id == $entry->id ) { |
|
| 300 | + foreach ( $metas as $meta_val ) { |
|
| 301 | + if ( $meta_val->item_id == $entry->id ) { |
|
| 302 | 302 | $entry->metas[ $meta_val->field_id ] = maybe_unserialize( $meta_val->meta_value ); |
| 303 | 303 | if ( $include_key ) { |
| 304 | 304 | $entry->metas[ $meta_val->field_key ] = $entry->metas[ $meta_val->field_id ]; |
| 305 | 305 | } |
| 306 | - continue; |
|
| 307 | - } |
|
| 306 | + continue; |
|
| 307 | + } |
|
| 308 | 308 | |
| 309 | - // include sub entries in an array |
|
| 309 | + // include sub entries in an array |
|
| 310 | 310 | if ( ! isset( $entry_metas[ $meta_val->field_id ] ) ) { |
| 311 | 311 | $entry->metas[ $meta_val->field_id ] = array(); |
| 312 | - } |
|
| 312 | + } |
|
| 313 | 313 | |
| 314 | 314 | $entry->metas[ $meta_val->field_id ][] = maybe_unserialize( $meta_val->meta_value ); |
| 315 | 315 | |
| 316 | - unset($meta_val); |
|
| 317 | - } |
|
| 318 | - unset($metas); |
|
| 316 | + unset($meta_val); |
|
| 317 | + } |
|
| 318 | + unset($metas); |
|
| 319 | 319 | |
| 320 | - wp_cache_set( $entry->id, $entry, 'frm_entry'); |
|
| 320 | + wp_cache_set( $entry->id, $entry, 'frm_entry'); |
|
| 321 | 321 | |
| 322 | - return $entry; |
|
| 323 | - } |
|
| 322 | + return $entry; |
|
| 323 | + } |
|
| 324 | 324 | |
| 325 | - /** |
|
| 326 | - * @param string $id |
|
| 327 | - */ |
|
| 325 | + /** |
|
| 326 | + * @param string $id |
|
| 327 | + */ |
|
| 328 | 328 | public static function &exists( $id ) { |
| 329 | - global $wpdb; |
|
| 330 | - |
|
| 331 | - if ( FrmAppHelper::check_cache( $id, 'frm_entry' ) ) { |
|
| 332 | - $exists = true; |
|
| 333 | - return $exists; |
|
| 334 | - } |
|
| 335 | - |
|
| 336 | - if ( is_numeric($id) ) { |
|
| 337 | - $where = array( 'id' => $id ); |
|
| 338 | - } else { |
|
| 339 | - $where = array( 'item_key' => $id ); |
|
| 340 | - } |
|
| 329 | + global $wpdb; |
|
| 330 | + |
|
| 331 | + if ( FrmAppHelper::check_cache( $id, 'frm_entry' ) ) { |
|
| 332 | + $exists = true; |
|
| 333 | + return $exists; |
|
| 334 | + } |
|
| 335 | + |
|
| 336 | + if ( is_numeric($id) ) { |
|
| 337 | + $where = array( 'id' => $id ); |
|
| 338 | + } else { |
|
| 339 | + $where = array( 'item_key' => $id ); |
|
| 340 | + } |
|
| 341 | 341 | $id = FrmDb::get_var( $wpdb->prefix . 'frm_items', $where ); |
| 342 | 342 | |
| 343 | - $exists = ($id && $id > 0) ? true : false; |
|
| 344 | - return $exists; |
|
| 345 | - } |
|
| 343 | + $exists = ($id && $id > 0) ? true : false; |
|
| 344 | + return $exists; |
|
| 345 | + } |
|
| 346 | 346 | |
| 347 | - public static function getAll( $where, $order_by = '', $limit = '', $meta = false, $inc_form = true ) { |
|
| 347 | + public static function getAll( $where, $order_by = '', $limit = '', $meta = false, $inc_form = true ) { |
|
| 348 | 348 | global $wpdb; |
| 349 | 349 | |
| 350 | - $limit = FrmAppHelper::esc_limit($limit); |
|
| 350 | + $limit = FrmAppHelper::esc_limit($limit); |
|
| 351 | 351 | |
| 352 | - $cache_key = maybe_serialize($where) . $order_by . $limit . $inc_form; |
|
| 353 | - $entries = wp_cache_get($cache_key, 'frm_entry'); |
|
| 352 | + $cache_key = maybe_serialize($where) . $order_by . $limit . $inc_form; |
|
| 353 | + $entries = wp_cache_get($cache_key, 'frm_entry'); |
|
| 354 | 354 | |
| 355 | - if ( false === $entries ) { |
|
| 356 | - $fields = 'it.id, it.item_key, it.name, it.ip, it.form_id, it.post_id, it.user_id, it.parent_item_id, it.updated_by, it.created_at, it.updated_at, it.is_draft'; |
|
| 355 | + if ( false === $entries ) { |
|
| 356 | + $fields = 'it.id, it.item_key, it.name, it.ip, it.form_id, it.post_id, it.user_id, it.parent_item_id, it.updated_by, it.created_at, it.updated_at, it.is_draft'; |
|
| 357 | 357 | $table = $wpdb->prefix . 'frm_items it '; |
| 358 | 358 | |
| 359 | - if ( $inc_form ) { |
|
| 360 | - $fields = 'it.*, fr.name as form_name,fr.form_key as form_key'; |
|
| 361 | - $table .= 'LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_forms fr ON it.form_id=fr.id '; |
|
| 362 | - } |
|
| 359 | + if ( $inc_form ) { |
|
| 360 | + $fields = 'it.*, fr.name as form_name,fr.form_key as form_key'; |
|
| 361 | + $table .= 'LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_forms fr ON it.form_id=fr.id '; |
|
| 362 | + } |
|
| 363 | 363 | |
| 364 | - if ( preg_match( '/ meta_([0-9]+)/', $order_by, $order_matches ) ) { |
|
| 365 | - // sort by a requested field |
|
| 366 | - $field_id = (int) $order_matches[1]; |
|
| 364 | + if ( preg_match( '/ meta_([0-9]+)/', $order_by, $order_matches ) ) { |
|
| 365 | + // sort by a requested field |
|
| 366 | + $field_id = (int) $order_matches[1]; |
|
| 367 | 367 | $fields .= ', (SELECT meta_value FROM ' . $wpdb->prefix . 'frm_item_metas WHERE field_id = ' . $field_id . ' AND item_id = it.id) as meta_' . $field_id; |
| 368 | 368 | unset( $order_matches, $field_id ); |
| 369 | - } |
|
| 369 | + } |
|
| 370 | 370 | |
| 371 | 371 | // prepare the query |
| 372 | 372 | $query = 'SELECT ' . $fields . ' FROM ' . $table . FrmAppHelper::prepend_and_or_where(' WHERE ', $where) . $order_by . $limit; |
| 373 | 373 | |
| 374 | - $entries = $wpdb->get_results($query, OBJECT_K); |
|
| 375 | - unset($query); |
|
| 374 | + $entries = $wpdb->get_results($query, OBJECT_K); |
|
| 375 | + unset($query); |
|
| 376 | 376 | |
| 377 | 377 | if ( ! FrmAppHelper::prevent_caching() ) { |
| 378 | 378 | wp_cache_set( $cache_key, $entries, 'frm_entry', 300 ); |
| 379 | 379 | } |
| 380 | - } |
|
| 380 | + } |
|
| 381 | 381 | |
| 382 | - if ( ! $meta || ! $entries ) { |
|
| 383 | - return stripslashes_deep($entries); |
|
| 384 | - } |
|
| 385 | - unset($meta); |
|
| 382 | + if ( ! $meta || ! $entries ) { |
|
| 383 | + return stripslashes_deep($entries); |
|
| 384 | + } |
|
| 385 | + unset($meta); |
|
| 386 | 386 | |
| 387 | - if ( ! is_array( $where ) && preg_match('/^it\.form_id=\d+$/', $where) ) { |
|
| 387 | + if ( ! is_array( $where ) && preg_match('/^it\.form_id=\d+$/', $where) ) { |
|
| 388 | 388 | $where = array( 'it.form_id' => substr( $where, 11 ) ); |
| 389 | - } |
|
| 389 | + } |
|
| 390 | 390 | |
| 391 | - $meta_where = array( 'field_id !' => 0 ); |
|
| 392 | - if ( $limit == '' && is_array($where) && count($where) == 1 && isset($where['it.form_id']) ) { |
|
| 393 | - $meta_where['fi.form_id'] = $where['it.form_id']; |
|
| 394 | - } else { |
|
| 395 | - $meta_where['item_id'] = array_keys( $entries ); |
|
| 396 | - } |
|
| 391 | + $meta_where = array( 'field_id !' => 0 ); |
|
| 392 | + if ( $limit == '' && is_array($where) && count($where) == 1 && isset($where['it.form_id']) ) { |
|
| 393 | + $meta_where['fi.form_id'] = $where['it.form_id']; |
|
| 394 | + } else { |
|
| 395 | + $meta_where['item_id'] = array_keys( $entries ); |
|
| 396 | + } |
|
| 397 | 397 | |
| 398 | - $metas = FrmDb::get_results( $wpdb->prefix . 'frm_item_metas it LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_fields fi ON (it.field_id = fi.id)', $meta_where, 'item_id, meta_value, field_id, field_key, form_id' ); |
|
| 398 | + $metas = FrmDb::get_results( $wpdb->prefix . 'frm_item_metas it LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_fields fi ON (it.field_id = fi.id)', $meta_where, 'item_id, meta_value, field_id, field_key, form_id' ); |
|
| 399 | 399 | |
| 400 | - unset( $meta_where ); |
|
| 400 | + unset( $meta_where ); |
|
| 401 | 401 | |
| 402 | - if ( ! $metas ) { |
|
| 403 | - return stripslashes_deep($entries); |
|
| 404 | - } |
|
| 402 | + if ( ! $metas ) { |
|
| 403 | + return stripslashes_deep($entries); |
|
| 404 | + } |
|
| 405 | 405 | |
| 406 | - foreach ( $metas as $m_key => $meta_val ) { |
|
| 407 | - if ( ! isset( $entries[ $meta_val->item_id ] ) ) { |
|
| 408 | - continue; |
|
| 409 | - } |
|
| 406 | + foreach ( $metas as $m_key => $meta_val ) { |
|
| 407 | + if ( ! isset( $entries[ $meta_val->item_id ] ) ) { |
|
| 408 | + continue; |
|
| 409 | + } |
|
| 410 | 410 | |
| 411 | - if ( ! isset( $entries[ $meta_val->item_id ]->metas ) ) { |
|
| 411 | + if ( ! isset( $entries[ $meta_val->item_id ]->metas ) ) { |
|
| 412 | 412 | $entries[ $meta_val->item_id ]->metas = array(); |
| 413 | - } |
|
| 413 | + } |
|
| 414 | 414 | |
| 415 | 415 | $entries[ $meta_val->item_id ]->metas[ $meta_val->field_id ] = maybe_unserialize( $meta_val->meta_value ); |
| 416 | 416 | |
| 417 | - unset($m_key, $meta_val); |
|
| 418 | - } |
|
| 417 | + unset($m_key, $meta_val); |
|
| 418 | + } |
|
| 419 | 419 | |
| 420 | 420 | if ( ! FrmAppHelper::prevent_caching() ) { |
| 421 | 421 | foreach ( $entries as $entry ) { |
@@ -424,31 +424,31 @@ discard block |
||
| 424 | 424 | } |
| 425 | 425 | } |
| 426 | 426 | |
| 427 | - return stripslashes_deep($entries); |
|
| 428 | - } |
|
| 427 | + return stripslashes_deep($entries); |
|
| 428 | + } |
|
| 429 | 429 | |
| 430 | - // Pagination Methods |
|
| 431 | - public static function getRecordCount( $where = '' ) { |
|
| 432 | - global $wpdb; |
|
| 430 | + // Pagination Methods |
|
| 431 | + public static function getRecordCount( $where = '' ) { |
|
| 432 | + global $wpdb; |
|
| 433 | 433 | $table_join = $wpdb->prefix . 'frm_items it LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_forms fr ON it.form_id=fr.id'; |
| 434 | 434 | |
| 435 | - if ( is_numeric($where) ) { |
|
| 436 | - $table_join = 'frm_items'; |
|
| 437 | - $where = array( 'form_id' => $where ); |
|
| 438 | - } |
|
| 435 | + if ( is_numeric($where) ) { |
|
| 436 | + $table_join = 'frm_items'; |
|
| 437 | + $where = array( 'form_id' => $where ); |
|
| 438 | + } |
|
| 439 | 439 | |
| 440 | - if ( is_array( $where ) ) { |
|
| 441 | - $count = FrmDb::get_count( $table_join, $where ); |
|
| 442 | - } else { |
|
| 440 | + if ( is_array( $where ) ) { |
|
| 441 | + $count = FrmDb::get_count( $table_join, $where ); |
|
| 442 | + } else { |
|
| 443 | 443 | $cache_key = 'count_' . maybe_serialize( $where ); |
| 444 | 444 | $query = 'SELECT COUNT(*) FROM ' . $table_join . FrmAppHelper::prepend_and_or_where( ' WHERE ', $where ); |
| 445 | 445 | $count = FrmAppHelper::check_cache( $cache_key, 'frm_entry', $query, 'get_var' ); |
| 446 | - } |
|
| 446 | + } |
|
| 447 | 447 | |
| 448 | - return $count; |
|
| 449 | - } |
|
| 448 | + return $count; |
|
| 449 | + } |
|
| 450 | 450 | |
| 451 | - public static function getPageCount( $p_size, $where = '' ) { |
|
| 451 | + public static function getPageCount( $p_size, $where = '' ) { |
|
| 452 | 452 | $p_size = (int) $p_size; |
| 453 | 453 | $count = 1; |
| 454 | 454 | if ( $p_size ) { |
@@ -459,16 +459,16 @@ discard block |
||
| 459 | 459 | } |
| 460 | 460 | |
| 461 | 461 | return $count; |
| 462 | - } |
|
| 462 | + } |
|
| 463 | 463 | |
| 464 | 464 | /** |
| 465 | - * Prepare the data before inserting it into the database |
|
| 466 | - * |
|
| 467 | - * @since 2.0.16 |
|
| 468 | - * @param array $values |
|
| 469 | - * @param string $type |
|
| 470 | - * @return array $new_values |
|
| 471 | - */ |
|
| 465 | + * Prepare the data before inserting it into the database |
|
| 466 | + * |
|
| 467 | + * @since 2.0.16 |
|
| 468 | + * @param array $values |
|
| 469 | + * @param string $type |
|
| 470 | + * @return array $new_values |
|
| 471 | + */ |
|
| 472 | 472 | private static function before_insert_entry_in_database( &$values, $type ) { |
| 473 | 473 | |
| 474 | 474 | self::sanitize_entry_post( $values ); |
@@ -483,13 +483,13 @@ discard block |
||
| 483 | 483 | } |
| 484 | 484 | |
| 485 | 485 | /** |
| 486 | - * Create an entry and perform after create actions |
|
| 487 | - * |
|
| 488 | - * @since 2.0.16 |
|
| 489 | - * @param array $values |
|
| 490 | - * @param array $new_values |
|
| 491 | - * @return boolean|int $entry_id |
|
| 492 | - */ |
|
| 486 | + * Create an entry and perform after create actions |
|
| 487 | + * |
|
| 488 | + * @since 2.0.16 |
|
| 489 | + * @param array $values |
|
| 490 | + * @param array $new_values |
|
| 491 | + * @return boolean|int $entry_id |
|
| 492 | + */ |
|
| 493 | 493 | private static function continue_to_create_entry( $values, $new_values ) { |
| 494 | 494 | $entry_id = self::insert_entry_into_database( $new_values ); |
| 495 | 495 | if ( ! $entry_id ) { |
@@ -501,37 +501,37 @@ discard block |
||
| 501 | 501 | return $entry_id; |
| 502 | 502 | } |
| 503 | 503 | |
| 504 | - /** |
|
| 505 | - * Sanitize the POST values before we use them |
|
| 506 | - * |
|
| 507 | - * @since 2.0 |
|
| 508 | - * @param array $values The POST values by reference |
|
| 509 | - */ |
|
| 510 | - public static function sanitize_entry_post( &$values ) { |
|
| 511 | - $sanitize_method = array( |
|
| 512 | - 'form_id' => 'absint', |
|
| 513 | - 'frm_action' => 'sanitize_title', |
|
| 514 | - 'form_key' => 'sanitize_title', |
|
| 515 | - 'item_key' => 'sanitize_title', |
|
| 516 | - 'item_name' => 'sanitize_text_field', |
|
| 517 | - 'frm_saving_draft' => 'absint', |
|
| 518 | - 'is_draft' => 'absint', |
|
| 519 | - 'post_id' => 'absint', |
|
| 520 | - 'parent_item_id' => 'absint', |
|
| 521 | - 'created_at' => 'sanitize_text_field', |
|
| 522 | - 'updated_at' => 'sanitize_text_field', |
|
| 523 | - ); |
|
| 524 | - |
|
| 525 | - FrmAppHelper::sanitize_request( $sanitize_method, $values ); |
|
| 526 | - } |
|
| 527 | - |
|
| 528 | - /** |
|
| 529 | - * Prepare the new values for inserting into the database |
|
| 530 | - * |
|
| 531 | - * @since 2.0.16 |
|
| 532 | - * @param array $values |
|
| 533 | - * @return array $new_values |
|
| 534 | - */ |
|
| 504 | + /** |
|
| 505 | + * Sanitize the POST values before we use them |
|
| 506 | + * |
|
| 507 | + * @since 2.0 |
|
| 508 | + * @param array $values The POST values by reference |
|
| 509 | + */ |
|
| 510 | + public static function sanitize_entry_post( &$values ) { |
|
| 511 | + $sanitize_method = array( |
|
| 512 | + 'form_id' => 'absint', |
|
| 513 | + 'frm_action' => 'sanitize_title', |
|
| 514 | + 'form_key' => 'sanitize_title', |
|
| 515 | + 'item_key' => 'sanitize_title', |
|
| 516 | + 'item_name' => 'sanitize_text_field', |
|
| 517 | + 'frm_saving_draft' => 'absint', |
|
| 518 | + 'is_draft' => 'absint', |
|
| 519 | + 'post_id' => 'absint', |
|
| 520 | + 'parent_item_id' => 'absint', |
|
| 521 | + 'created_at' => 'sanitize_text_field', |
|
| 522 | + 'updated_at' => 'sanitize_text_field', |
|
| 523 | + ); |
|
| 524 | + |
|
| 525 | + FrmAppHelper::sanitize_request( $sanitize_method, $values ); |
|
| 526 | + } |
|
| 527 | + |
|
| 528 | + /** |
|
| 529 | + * Prepare the new values for inserting into the database |
|
| 530 | + * |
|
| 531 | + * @since 2.0.16 |
|
| 532 | + * @param array $values |
|
| 533 | + * @return array $new_values |
|
| 534 | + */ |
|
| 535 | 535 | private static function package_entry_data( &$values ) { |
| 536 | 536 | global $wpdb; |
| 537 | 537 | |
@@ -564,67 +564,67 @@ discard block |
||
| 564 | 564 | } |
| 565 | 565 | |
| 566 | 566 | /** |
| 567 | - * Get the is_draft value for a new entry |
|
| 568 | - * |
|
| 569 | - * @since 2.0.16 |
|
| 570 | - * @param array $values |
|
| 571 | - * @return int |
|
| 572 | - */ |
|
| 567 | + * Get the is_draft value for a new entry |
|
| 568 | + * |
|
| 569 | + * @since 2.0.16 |
|
| 570 | + * @param array $values |
|
| 571 | + * @return int |
|
| 572 | + */ |
|
| 573 | 573 | private static function get_is_draft_value( $values ) { |
| 574 | 574 | return ( ( isset( $values['frm_saving_draft'] ) && $values['frm_saving_draft'] == 1 ) || ( isset( $values['is_draft'] ) && $values['is_draft'] == 1 ) ) ? 1 : 0; |
| 575 | 575 | } |
| 576 | 576 | |
| 577 | 577 | /** |
| 578 | - * Get the form_id value for a new entry |
|
| 579 | - * |
|
| 580 | - * @since 2.0.16 |
|
| 581 | - * @param array $values |
|
| 582 | - * @return int|null |
|
| 583 | - */ |
|
| 578 | + * Get the form_id value for a new entry |
|
| 579 | + * |
|
| 580 | + * @since 2.0.16 |
|
| 581 | + * @param array $values |
|
| 582 | + * @return int|null |
|
| 583 | + */ |
|
| 584 | 584 | private static function get_form_id( $values ) { |
| 585 | 585 | return isset( $values['form_id'] ) ? (int) $values['form_id'] : null; |
| 586 | 586 | } |
| 587 | 587 | |
| 588 | 588 | /** |
| 589 | - * Get the post_id value for a new entry |
|
| 590 | - * |
|
| 591 | - * @since 2.0.16 |
|
| 592 | - * @param array $values |
|
| 593 | - * @return int |
|
| 594 | - */ |
|
| 589 | + * Get the post_id value for a new entry |
|
| 590 | + * |
|
| 591 | + * @since 2.0.16 |
|
| 592 | + * @param array $values |
|
| 593 | + * @return int |
|
| 594 | + */ |
|
| 595 | 595 | private static function get_post_id( $values ) { |
| 596 | 596 | return isset( $values['post_id'] ) ? (int) $values['post_id']: 0; |
| 597 | 597 | } |
| 598 | 598 | |
| 599 | 599 | /** |
| 600 | - * Get the parent_item_id value for a new entry |
|
| 601 | - * |
|
| 602 | - * @since 2.0.16 |
|
| 603 | - * @param array $values |
|
| 604 | - * @return int |
|
| 605 | - */ |
|
| 600 | + * Get the parent_item_id value for a new entry |
|
| 601 | + * |
|
| 602 | + * @since 2.0.16 |
|
| 603 | + * @param array $values |
|
| 604 | + * @return int |
|
| 605 | + */ |
|
| 606 | 606 | private static function get_parent_item_id( $values ) { |
| 607 | 607 | return isset( $values['parent_item_id'] ) ? (int) $values['parent_item_id']: 0; |
| 608 | 608 | } |
| 609 | 609 | |
| 610 | 610 | /** |
| 611 | - * Get the created_at value for a new entry |
|
| 612 | - * |
|
| 613 | - * @since 2.0.16 |
|
| 614 | - * @param array $values |
|
| 615 | - * @return string |
|
| 616 | - */ |
|
| 611 | + * Get the created_at value for a new entry |
|
| 612 | + * |
|
| 613 | + * @since 2.0.16 |
|
| 614 | + * @param array $values |
|
| 615 | + * @return string |
|
| 616 | + */ |
|
| 617 | 617 | private static function get_created_at( $values ) { |
| 618 | 618 | return isset( $values['created_at'] ) ? $values['created_at']: current_time('mysql', 1); |
| 619 | 619 | } |
| 620 | 620 | |
| 621 | 621 | /** |
| 622 | - * Get the updated_at value for a new entry |
|
| 623 | - * |
|
| 624 | - * @since 2.0.16 |
|
| 625 | - * @param array $values |
|
| 626 | - * @return string |
|
| 627 | - */ |
|
| 622 | + * Get the updated_at value for a new entry |
|
| 623 | + * |
|
| 624 | + * @since 2.0.16 |
|
| 625 | + * @param array $values |
|
| 626 | + * @return string |
|
| 627 | + */ |
|
| 628 | 628 | private static function get_updated_at( $values ) { |
| 629 | 629 | if ( isset( $values['updated_at'] ) ) { |
| 630 | 630 | $updated_at = $values['updated_at']; |
@@ -636,12 +636,12 @@ discard block |
||
| 636 | 636 | } |
| 637 | 637 | |
| 638 | 638 | /** |
| 639 | - * Get the description value for a new entry |
|
| 640 | - * |
|
| 641 | - * @since 2.0.16 |
|
| 642 | - * @param array $values |
|
| 643 | - * @return string |
|
| 644 | - */ |
|
| 639 | + * Get the description value for a new entry |
|
| 640 | + * |
|
| 641 | + * @since 2.0.16 |
|
| 642 | + * @param array $values |
|
| 643 | + * @return string |
|
| 644 | + */ |
|
| 645 | 645 | private static function get_entry_description( $values ) { |
| 646 | 646 | if ( isset( $values['description'] ) && ! empty( $values['description'] ) ) { |
| 647 | 647 | $description = maybe_serialize( $values['description'] ); |
@@ -656,12 +656,12 @@ discard block |
||
| 656 | 656 | } |
| 657 | 657 | |
| 658 | 658 | /** |
| 659 | - * Get the user_id value for a new entry |
|
| 660 | - * |
|
| 661 | - * @since 2.0.16 |
|
| 662 | - * @param array $values |
|
| 663 | - * @return int |
|
| 664 | - */ |
|
| 659 | + * Get the user_id value for a new entry |
|
| 660 | + * |
|
| 661 | + * @since 2.0.16 |
|
| 662 | + * @param array $values |
|
| 663 | + * @return int |
|
| 664 | + */ |
|
| 665 | 665 | private static function get_entry_user_id( $values ) { |
| 666 | 666 | if ( isset( $values['frm_user_id'] ) && ( is_numeric( $values['frm_user_id'] ) || FrmAppHelper::is_admin() ) ) { |
| 667 | 667 | $user_id = $values['frm_user_id']; |
@@ -674,12 +674,12 @@ discard block |
||
| 674 | 674 | } |
| 675 | 675 | |
| 676 | 676 | /** |
| 677 | - * Insert new entry into the database |
|
| 678 | - * |
|
| 679 | - * @since 2.0.16 |
|
| 680 | - * @param array $new_values |
|
| 681 | - * @return int | boolean $entry_id |
|
| 682 | - */ |
|
| 677 | + * Insert new entry into the database |
|
| 678 | + * |
|
| 679 | + * @since 2.0.16 |
|
| 680 | + * @param array $new_values |
|
| 681 | + * @return int | boolean $entry_id |
|
| 682 | + */ |
|
| 683 | 683 | private static function insert_entry_into_database( $new_values ) { |
| 684 | 684 | global $wpdb; |
| 685 | 685 | |
@@ -695,11 +695,11 @@ discard block |
||
| 695 | 695 | } |
| 696 | 696 | |
| 697 | 697 | /** |
| 698 | - * Add the new entry to global $frm_vars |
|
| 699 | - * |
|
| 700 | - * @since 2.0.16 |
|
| 701 | - * @param int $entry_id |
|
| 702 | - */ |
|
| 698 | + * Add the new entry to global $frm_vars |
|
| 699 | + * |
|
| 700 | + * @since 2.0.16 |
|
| 701 | + * @param int $entry_id |
|
| 702 | + */ |
|
| 703 | 703 | private static function add_new_entry_to_frm_vars( $entry_id ) { |
| 704 | 704 | global $frm_vars; |
| 705 | 705 | |
@@ -711,12 +711,12 @@ discard block |
||
| 711 | 711 | } |
| 712 | 712 | |
| 713 | 713 | /** |
| 714 | - * Add entry metas, if there are any |
|
| 715 | - * |
|
| 716 | - * @since 2.0.16 |
|
| 717 | - * @param array $values |
|
| 718 | - * @param int $entry_id |
|
| 719 | - */ |
|
| 714 | + * Add entry metas, if there are any |
|
| 715 | + * |
|
| 716 | + * @since 2.0.16 |
|
| 717 | + * @param array $values |
|
| 718 | + * @param int $entry_id |
|
| 719 | + */ |
|
| 720 | 720 | private static function maybe_add_entry_metas( $values, $entry_id ) { |
| 721 | 721 | if ( isset($values['item_meta']) ) { |
| 722 | 722 | FrmEntryMeta::update_entry_metas( $entry_id, $values['item_meta'] ); |
@@ -724,12 +724,12 @@ discard block |
||
| 724 | 724 | } |
| 725 | 725 | |
| 726 | 726 | /** |
| 727 | - * Trigger frm_after_create_entry hooks |
|
| 728 | - * |
|
| 729 | - * @since 2.0.16 |
|
| 730 | - * @param int $entry_id |
|
| 731 | - * @param array $new_values |
|
| 732 | - */ |
|
| 727 | + * Trigger frm_after_create_entry hooks |
|
| 728 | + * |
|
| 729 | + * @since 2.0.16 |
|
| 730 | + * @param int $entry_id |
|
| 731 | + * @param array $new_values |
|
| 732 | + */ |
|
| 733 | 733 | private static function after_entry_created_actions( $entry_id, $values, $new_values ) { |
| 734 | 734 | // this is a child entry |
| 735 | 735 | $is_child = isset( $values['parent_form_id'] ) && isset( $values['parent_nonce'] ) && ! empty( $values['parent_form_id'] ) && wp_verify_nonce( $values['parent_nonce'], 'parent' ); |
@@ -739,13 +739,13 @@ discard block |
||
| 739 | 739 | } |
| 740 | 740 | |
| 741 | 741 | /** |
| 742 | - * Actions to perform immediately after an entry is inserted in the frm_items database |
|
| 743 | - * |
|
| 744 | - * @since 2.0.16 |
|
| 745 | - * @param array $values |
|
| 746 | - * @param array $new_values |
|
| 747 | - * @param int $entry_id |
|
| 748 | - */ |
|
| 742 | + * Actions to perform immediately after an entry is inserted in the frm_items database |
|
| 743 | + * |
|
| 744 | + * @since 2.0.16 |
|
| 745 | + * @param array $values |
|
| 746 | + * @param array $new_values |
|
| 747 | + * @param int $entry_id |
|
| 748 | + */ |
|
| 749 | 749 | private static function after_insert_entry_in_database( $values, $new_values, $entry_id ) { |
| 750 | 750 | |
| 751 | 751 | self::add_new_entry_to_frm_vars( $entry_id ); |
@@ -758,14 +758,14 @@ discard block |
||
| 758 | 758 | } |
| 759 | 759 | |
| 760 | 760 | /** |
| 761 | - * Perform some actions right before updating an entry |
|
| 762 | - * |
|
| 763 | - * @since 2.0.16 |
|
| 764 | - * @param int $id |
|
| 765 | - * @param array $values |
|
| 766 | - * @param string $update_type |
|
| 767 | - * @return boolean $update |
|
| 768 | - */ |
|
| 761 | + * Perform some actions right before updating an entry |
|
| 762 | + * |
|
| 763 | + * @since 2.0.16 |
|
| 764 | + * @param int $id |
|
| 765 | + * @param array $values |
|
| 766 | + * @param string $update_type |
|
| 767 | + * @return boolean $update |
|
| 768 | + */ |
|
| 769 | 769 | private static function before_update_entry( $id, &$values, $update_type ) { |
| 770 | 770 | $update = true; |
| 771 | 771 | |
@@ -783,13 +783,13 @@ discard block |
||
| 783 | 783 | } |
| 784 | 784 | |
| 785 | 785 | /** |
| 786 | - * Package the entry data for updating |
|
| 787 | - * |
|
| 788 | - * @since 2.0.16 |
|
| 789 | - * @param int $id |
|
| 790 | - * @param array $values |
|
| 791 | - * @return array $new_values |
|
| 792 | - */ |
|
| 786 | + * Package the entry data for updating |
|
| 787 | + * |
|
| 788 | + * @since 2.0.16 |
|
| 789 | + * @param int $id |
|
| 790 | + * @param array $values |
|
| 791 | + * @return array $new_values |
|
| 792 | + */ |
|
| 793 | 793 | private static function package_entry_to_update( $id, $values ) { |
| 794 | 794 | global $wpdb; |
| 795 | 795 | |
@@ -823,14 +823,14 @@ discard block |
||
| 823 | 823 | } |
| 824 | 824 | |
| 825 | 825 | /** |
| 826 | - * Perform some actions right after updating an entry |
|
| 827 | - * |
|
| 828 | - * @since 2.0.16 |
|
| 829 | - * @param boolean|int $query_results |
|
| 830 | - * @param int $id |
|
| 831 | - * @param array $values |
|
| 832 | - * @param array $new_values |
|
| 833 | - */ |
|
| 826 | + * Perform some actions right after updating an entry |
|
| 827 | + * |
|
| 828 | + * @since 2.0.16 |
|
| 829 | + * @param boolean|int $query_results |
|
| 830 | + * @param int $id |
|
| 831 | + * @param array $values |
|
| 832 | + * @param array $new_values |
|
| 833 | + */ |
|
| 834 | 834 | private static function after_update_entry( $query_results, $id, $values, $new_values ) { |
| 835 | 835 | if ( $query_results ) { |
| 836 | 836 | self::clear_cache(); |
@@ -852,13 +852,13 @@ discard block |
||
| 852 | 852 | } |
| 853 | 853 | |
| 854 | 854 | /** |
| 855 | - * Create entry from an XML import |
|
| 856 | - * Certain actions aren't necessary when importing (like saving sub entries, checking for duplicates, etc.) |
|
| 857 | - * |
|
| 858 | - * @since 2.0.16 |
|
| 859 | - * @param array $values |
|
| 860 | - * @return int | boolean $entry_id |
|
| 861 | - */ |
|
| 855 | + * Create entry from an XML import |
|
| 856 | + * Certain actions aren't necessary when importing (like saving sub entries, checking for duplicates, etc.) |
|
| 857 | + * |
|
| 858 | + * @since 2.0.16 |
|
| 859 | + * @param array $values |
|
| 860 | + * @return int | boolean $entry_id |
|
| 861 | + */ |
|
| 862 | 862 | public static function create_entry_from_xml( $values ) { |
| 863 | 863 | $entry_id = self::create_entry( $values, 'xml' ); |
| 864 | 864 | |
@@ -866,28 +866,28 @@ discard block |
||
| 866 | 866 | } |
| 867 | 867 | |
| 868 | 868 | /** |
| 869 | - * Update entry from an XML import |
|
| 870 | - * Certain actions aren't necessary when importing (like saving sub entries and modifying other vals) |
|
| 871 | - * |
|
| 872 | - * @since 2.0.16 |
|
| 873 | - * @param int $id |
|
| 874 | - * @param array $values |
|
| 875 | - * @return int | boolean $updated |
|
| 876 | - */ |
|
| 869 | + * Update entry from an XML import |
|
| 870 | + * Certain actions aren't necessary when importing (like saving sub entries and modifying other vals) |
|
| 871 | + * |
|
| 872 | + * @since 2.0.16 |
|
| 873 | + * @param int $id |
|
| 874 | + * @param array $values |
|
| 875 | + * @return int | boolean $updated |
|
| 876 | + */ |
|
| 877 | 877 | public static function update_entry_from_xml( $id, $values ) { |
| 878 | 878 | $updated = self::update_entry( $id, $values, 'xml' ); |
| 879 | 879 | |
| 880 | 880 | return $updated; |
| 881 | 881 | } |
| 882 | 882 | |
| 883 | - /** |
|
| 884 | - * @param string $key |
|
| 885 | - * @return int entry_id |
|
| 886 | - */ |
|
| 883 | + /** |
|
| 884 | + * @param string $key |
|
| 885 | + * @return int entry_id |
|
| 886 | + */ |
|
| 887 | 887 | public static function get_id_by_key( $key ) { |
| 888 | - $entry_id = FrmDb::get_var( 'frm_items', array( 'item_key' => sanitize_title( $key ) ) ); |
|
| 889 | - return $entry_id; |
|
| 890 | - } |
|
| 888 | + $entry_id = FrmDb::get_var( 'frm_items', array( 'item_key' => sanitize_title( $key ) ) ); |
|
| 889 | + return $entry_id; |
|
| 890 | + } |
|
| 891 | 891 | |
| 892 | 892 | public static function validate( $values, $exclude = false ) { |
| 893 | 893 | _deprecated_function( __FUNCTION__, '2.0.9', 'FrmEntryValidate::validate' ); |
@@ -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 | |
@@ -55,13 +55,13 @@ discard block |
||
| 55 | 55 | unset( $check_val['is_draft'], $check_val['id'], $check_val['item_key'] ); |
| 56 | 56 | |
| 57 | 57 | if ( $new_values['item_key'] == $new_values['name'] ) { |
| 58 | - unset($check_val['name']); |
|
| 58 | + unset( $check_val['name'] ); |
|
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | global $wpdb; |
| 62 | 62 | $entry_exists = FrmDb::get_col( $wpdb->prefix . 'frm_items', $check_val, 'id', array( 'order_by' => 'created_at DESC' ) ); |
| 63 | 63 | |
| 64 | - if ( ! $entry_exists || empty($entry_exists) || ! isset($values['item_meta']) ) { |
|
| 64 | + if ( ! $entry_exists || empty( $entry_exists ) || ! isset( $values['item_meta'] ) ) { |
|
| 65 | 65 | return false; |
| 66 | 66 | } |
| 67 | 67 | |
@@ -70,10 +70,10 @@ discard block |
||
| 70 | 70 | $is_duplicate = true; |
| 71 | 71 | |
| 72 | 72 | //add more checks here to make sure it's a duplicate |
| 73 | - $metas = FrmEntryMeta::get_entry_meta_info($entry_exist); |
|
| 73 | + $metas = FrmEntryMeta::get_entry_meta_info( $entry_exist ); |
|
| 74 | 74 | $field_metas = array(); |
| 75 | 75 | foreach ( $metas as $meta ) { |
| 76 | - $field_metas[ $meta->field_id ] = $meta->meta_value; |
|
| 76 | + $field_metas[$meta->field_id] = $meta->meta_value; |
|
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | // If prev entry is empty and current entry is not, they are not duplicates |
@@ -82,9 +82,9 @@ discard block |
||
| 82 | 82 | return false; |
| 83 | 83 | } |
| 84 | 84 | |
| 85 | - $diff = array_diff_assoc($field_metas, array_map('maybe_serialize', $values['item_meta'])); |
|
| 85 | + $diff = array_diff_assoc( $field_metas, array_map( 'maybe_serialize', $values['item_meta'] ) ); |
|
| 86 | 86 | foreach ( $diff as $field_id => $meta_value ) { |
| 87 | - if ( ! empty($meta_value) ) { |
|
| 87 | + if ( ! empty( $meta_value ) ) { |
|
| 88 | 88 | $is_duplicate = false; |
| 89 | 89 | continue; |
| 90 | 90 | } |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | } |
| 114 | 114 | |
| 115 | 115 | // If CSV is importing, don't check for duplicates |
| 116 | - if ( defined('WP_IMPORTING') && WP_IMPORTING ) { |
|
| 116 | + if ( defined( 'WP_IMPORTING' ) && WP_IMPORTING ) { |
|
| 117 | 117 | return false; |
| 118 | 118 | } |
| 119 | 119 | |
@@ -135,8 +135,8 @@ discard block |
||
| 135 | 135 | $new_values['name'] = $values->name; |
| 136 | 136 | $new_values['is_draft'] = $values->is_draft; |
| 137 | 137 | $new_values['user_id'] = $new_values['updated_by'] = (int) $values->user_id; |
| 138 | - $new_values['form_id'] = $values->form_id ? (int) $values->form_id: null; |
|
| 139 | - $new_values['created_at'] = $new_values['updated_at'] = current_time('mysql', 1); |
|
| 138 | + $new_values['form_id'] = $values->form_id ? (int) $values->form_id : null; |
|
| 139 | + $new_values['created_at'] = $new_values['updated_at'] = current_time( 'mysql', 1 ); |
|
| 140 | 140 | |
| 141 | 141 | $query_results = $wpdb->insert( $wpdb->prefix . 'frm_items', $new_values ); |
| 142 | 142 | if ( ! $query_results ) { |
@@ -146,12 +146,12 @@ discard block |
||
| 146 | 146 | $entry_id = $wpdb->insert_id; |
| 147 | 147 | |
| 148 | 148 | global $frm_vars; |
| 149 | - if ( ! isset($frm_vars['saved_entries']) ) { |
|
| 149 | + if ( ! isset( $frm_vars['saved_entries'] ) ) { |
|
| 150 | 150 | $frm_vars['saved_entries'] = array(); |
| 151 | 151 | } |
| 152 | 152 | $frm_vars['saved_entries'][] = (int) $entry_id; |
| 153 | 153 | |
| 154 | - FrmEntryMeta::duplicate_entry_metas($id, $entry_id); |
|
| 154 | + FrmEntryMeta::duplicate_entry_metas( $id, $entry_id ); |
|
| 155 | 155 | self::clear_cache(); |
| 156 | 156 | |
| 157 | 157 | do_action( 'frm_after_duplicate_entry', $entry_id, $new_values['form_id'], array( 'old_id' => $id ) ); |
@@ -190,7 +190,7 @@ discard block |
||
| 190 | 190 | |
| 191 | 191 | $new_values = self::package_entry_to_update( $id, $values ); |
| 192 | 192 | |
| 193 | - $query_results = $wpdb->update( $wpdb->prefix . 'frm_items', $new_values, compact('id') ); |
|
| 193 | + $query_results = $wpdb->update( $wpdb->prefix . 'frm_items', $new_values, compact( 'id' ) ); |
|
| 194 | 194 | |
| 195 | 195 | self::after_update_entry( $query_results, $id, $values, $new_values ); |
| 196 | 196 | |
@@ -207,7 +207,7 @@ discard block |
||
| 207 | 207 | return $result; |
| 208 | 208 | } |
| 209 | 209 | |
| 210 | - do_action('frm_before_destroy_entry', $id, $entry); |
|
| 210 | + do_action( 'frm_before_destroy_entry', $id, $entry ); |
|
| 211 | 211 | |
| 212 | 212 | $wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->prefix . 'frm_item_metas WHERE item_id=%d', $id ) ); |
| 213 | 213 | $result = $wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->prefix . 'frm_items WHERE id=%d', $id ) ); |
@@ -219,7 +219,7 @@ discard block |
||
| 219 | 219 | |
| 220 | 220 | public static function &update_form( $id, $value, $form_id ) { |
| 221 | 221 | global $wpdb; |
| 222 | - $form_id = isset($value) ? $form_id : null; |
|
| 222 | + $form_id = isset( $value ) ? $form_id : null; |
|
| 223 | 223 | $result = $wpdb->update( $wpdb->prefix . 'frm_items', array( 'form_id' => $form_id ), array( 'id' => $id ) ); |
| 224 | 224 | if ( $result ) { |
| 225 | 225 | self::clear_cache(); |
@@ -266,24 +266,24 @@ discard block |
||
| 266 | 266 | $query = "SELECT it.*, fr.name as form_name, fr.form_key as form_key FROM {$wpdb->prefix}frm_items it |
| 267 | 267 | LEFT OUTER JOIN {$wpdb->prefix}frm_forms fr ON it.form_id=fr.id WHERE "; |
| 268 | 268 | |
| 269 | - $query .= is_numeric($id) ? 'it.id=%d' : 'it.item_key=%s'; |
|
| 269 | + $query .= is_numeric( $id ) ? 'it.id=%d' : 'it.item_key=%s'; |
|
| 270 | 270 | $query_args = array( $id ); |
| 271 | 271 | $query = $wpdb->prepare( $query, $query_args ); |
| 272 | 272 | |
| 273 | 273 | if ( ! $meta ) { |
| 274 | 274 | $entry = FrmAppHelper::check_cache( $id . '_nometa', 'frm_entry', $query, 'get_row' ); |
| 275 | - return stripslashes_deep($entry); |
|
| 275 | + return stripslashes_deep( $entry ); |
|
| 276 | 276 | } |
| 277 | 277 | |
| 278 | 278 | $entry = FrmAppHelper::check_cache( $id, 'frm_entry' ); |
| 279 | 279 | if ( $entry !== false ) { |
| 280 | - return stripslashes_deep($entry); |
|
| 280 | + return stripslashes_deep( $entry ); |
|
| 281 | 281 | } |
| 282 | 282 | |
| 283 | 283 | $entry = $wpdb->get_row( $query ); |
| 284 | - $entry = self::get_meta($entry); |
|
| 284 | + $entry = self::get_meta( $entry ); |
|
| 285 | 285 | |
| 286 | - return stripslashes_deep($entry); |
|
| 286 | + return stripslashes_deep( $entry ); |
|
| 287 | 287 | } |
| 288 | 288 | |
| 289 | 289 | public static function get_meta( $entry ) { |
@@ -299,25 +299,25 @@ discard block |
||
| 299 | 299 | $include_key = apply_filters( 'frm_include_meta_keys', false ); |
| 300 | 300 | foreach ( $metas as $meta_val ) { |
| 301 | 301 | if ( $meta_val->item_id == $entry->id ) { |
| 302 | - $entry->metas[ $meta_val->field_id ] = maybe_unserialize( $meta_val->meta_value ); |
|
| 302 | + $entry->metas[$meta_val->field_id] = maybe_unserialize( $meta_val->meta_value ); |
|
| 303 | 303 | if ( $include_key ) { |
| 304 | - $entry->metas[ $meta_val->field_key ] = $entry->metas[ $meta_val->field_id ]; |
|
| 304 | + $entry->metas[$meta_val->field_key] = $entry->metas[$meta_val->field_id]; |
|
| 305 | 305 | } |
| 306 | 306 | continue; |
| 307 | 307 | } |
| 308 | 308 | |
| 309 | 309 | // include sub entries in an array |
| 310 | - if ( ! isset( $entry_metas[ $meta_val->field_id ] ) ) { |
|
| 311 | - $entry->metas[ $meta_val->field_id ] = array(); |
|
| 310 | + if ( ! isset( $entry_metas[$meta_val->field_id] ) ) { |
|
| 311 | + $entry->metas[$meta_val->field_id] = array(); |
|
| 312 | 312 | } |
| 313 | 313 | |
| 314 | - $entry->metas[ $meta_val->field_id ][] = maybe_unserialize( $meta_val->meta_value ); |
|
| 314 | + $entry->metas[$meta_val->field_id][] = maybe_unserialize( $meta_val->meta_value ); |
|
| 315 | 315 | |
| 316 | - unset($meta_val); |
|
| 316 | + unset( $meta_val ); |
|
| 317 | 317 | } |
| 318 | - unset($metas); |
|
| 318 | + unset( $metas ); |
|
| 319 | 319 | |
| 320 | - wp_cache_set( $entry->id, $entry, 'frm_entry'); |
|
| 320 | + wp_cache_set( $entry->id, $entry, 'frm_entry' ); |
|
| 321 | 321 | |
| 322 | 322 | return $entry; |
| 323 | 323 | } |
@@ -333,24 +333,24 @@ discard block |
||
| 333 | 333 | return $exists; |
| 334 | 334 | } |
| 335 | 335 | |
| 336 | - if ( is_numeric($id) ) { |
|
| 336 | + if ( is_numeric( $id ) ) { |
|
| 337 | 337 | $where = array( 'id' => $id ); |
| 338 | 338 | } else { |
| 339 | 339 | $where = array( 'item_key' => $id ); |
| 340 | 340 | } |
| 341 | 341 | $id = FrmDb::get_var( $wpdb->prefix . 'frm_items', $where ); |
| 342 | 342 | |
| 343 | - $exists = ($id && $id > 0) ? true : false; |
|
| 343 | + $exists = ( $id && $id > 0 ) ? true : false; |
|
| 344 | 344 | return $exists; |
| 345 | 345 | } |
| 346 | 346 | |
| 347 | 347 | public static function getAll( $where, $order_by = '', $limit = '', $meta = false, $inc_form = true ) { |
| 348 | 348 | global $wpdb; |
| 349 | 349 | |
| 350 | - $limit = FrmAppHelper::esc_limit($limit); |
|
| 350 | + $limit = FrmAppHelper::esc_limit( $limit ); |
|
| 351 | 351 | |
| 352 | - $cache_key = maybe_serialize($where) . $order_by . $limit . $inc_form; |
|
| 353 | - $entries = wp_cache_get($cache_key, 'frm_entry'); |
|
| 352 | + $cache_key = maybe_serialize( $where ) . $order_by . $limit . $inc_form; |
|
| 353 | + $entries = wp_cache_get( $cache_key, 'frm_entry' ); |
|
| 354 | 354 | |
| 355 | 355 | if ( false === $entries ) { |
| 356 | 356 | $fields = 'it.id, it.item_key, it.name, it.ip, it.form_id, it.post_id, it.user_id, it.parent_item_id, it.updated_by, it.created_at, it.updated_at, it.is_draft'; |
@@ -369,10 +369,10 @@ discard block |
||
| 369 | 369 | } |
| 370 | 370 | |
| 371 | 371 | // prepare the query |
| 372 | - $query = 'SELECT ' . $fields . ' FROM ' . $table . FrmAppHelper::prepend_and_or_where(' WHERE ', $where) . $order_by . $limit; |
|
| 372 | + $query = 'SELECT ' . $fields . ' FROM ' . $table . FrmAppHelper::prepend_and_or_where( ' WHERE ', $where ) . $order_by . $limit; |
|
| 373 | 373 | |
| 374 | - $entries = $wpdb->get_results($query, OBJECT_K); |
|
| 375 | - unset($query); |
|
| 374 | + $entries = $wpdb->get_results( $query, OBJECT_K ); |
|
| 375 | + unset( $query ); |
|
| 376 | 376 | |
| 377 | 377 | if ( ! FrmAppHelper::prevent_caching() ) { |
| 378 | 378 | wp_cache_set( $cache_key, $entries, 'frm_entry', 300 ); |
@@ -380,16 +380,16 @@ discard block |
||
| 380 | 380 | } |
| 381 | 381 | |
| 382 | 382 | if ( ! $meta || ! $entries ) { |
| 383 | - return stripslashes_deep($entries); |
|
| 383 | + return stripslashes_deep( $entries ); |
|
| 384 | 384 | } |
| 385 | - unset($meta); |
|
| 385 | + unset( $meta ); |
|
| 386 | 386 | |
| 387 | - if ( ! is_array( $where ) && preg_match('/^it\.form_id=\d+$/', $where) ) { |
|
| 387 | + if ( ! is_array( $where ) && preg_match( '/^it\.form_id=\d+$/', $where ) ) { |
|
| 388 | 388 | $where = array( 'it.form_id' => substr( $where, 11 ) ); |
| 389 | 389 | } |
| 390 | 390 | |
| 391 | 391 | $meta_where = array( 'field_id !' => 0 ); |
| 392 | - if ( $limit == '' && is_array($where) && count($where) == 1 && isset($where['it.form_id']) ) { |
|
| 392 | + if ( $limit == '' && is_array( $where ) && count( $where ) == 1 && isset( $where['it.form_id'] ) ) { |
|
| 393 | 393 | $meta_where['fi.form_id'] = $where['it.form_id']; |
| 394 | 394 | } else { |
| 395 | 395 | $meta_where['item_id'] = array_keys( $entries ); |
@@ -400,21 +400,21 @@ discard block |
||
| 400 | 400 | unset( $meta_where ); |
| 401 | 401 | |
| 402 | 402 | if ( ! $metas ) { |
| 403 | - return stripslashes_deep($entries); |
|
| 403 | + return stripslashes_deep( $entries ); |
|
| 404 | 404 | } |
| 405 | 405 | |
| 406 | 406 | foreach ( $metas as $m_key => $meta_val ) { |
| 407 | - if ( ! isset( $entries[ $meta_val->item_id ] ) ) { |
|
| 407 | + if ( ! isset( $entries[$meta_val->item_id] ) ) { |
|
| 408 | 408 | continue; |
| 409 | 409 | } |
| 410 | 410 | |
| 411 | - if ( ! isset( $entries[ $meta_val->item_id ]->metas ) ) { |
|
| 412 | - $entries[ $meta_val->item_id ]->metas = array(); |
|
| 411 | + if ( ! isset( $entries[$meta_val->item_id]->metas ) ) { |
|
| 412 | + $entries[$meta_val->item_id]->metas = array(); |
|
| 413 | 413 | } |
| 414 | 414 | |
| 415 | - $entries[ $meta_val->item_id ]->metas[ $meta_val->field_id ] = maybe_unserialize( $meta_val->meta_value ); |
|
| 415 | + $entries[$meta_val->item_id]->metas[$meta_val->field_id] = maybe_unserialize( $meta_val->meta_value ); |
|
| 416 | 416 | |
| 417 | - unset($m_key, $meta_val); |
|
| 417 | + unset( $m_key, $meta_val ); |
|
| 418 | 418 | } |
| 419 | 419 | |
| 420 | 420 | if ( ! FrmAppHelper::prevent_caching() ) { |
@@ -424,7 +424,7 @@ discard block |
||
| 424 | 424 | } |
| 425 | 425 | } |
| 426 | 426 | |
| 427 | - return stripslashes_deep($entries); |
|
| 427 | + return stripslashes_deep( $entries ); |
|
| 428 | 428 | } |
| 429 | 429 | |
| 430 | 430 | // Pagination Methods |
@@ -432,7 +432,7 @@ discard block |
||
| 432 | 432 | global $wpdb; |
| 433 | 433 | $table_join = $wpdb->prefix . 'frm_items it LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_forms fr ON it.form_id=fr.id'; |
| 434 | 434 | |
| 435 | - if ( is_numeric($where) ) { |
|
| 435 | + if ( is_numeric( $where ) ) { |
|
| 436 | 436 | $table_join = 'frm_items'; |
| 437 | 437 | $where = array( 'form_id' => $where ); |
| 438 | 438 | } |
@@ -474,7 +474,7 @@ discard block |
||
| 474 | 474 | self::sanitize_entry_post( $values ); |
| 475 | 475 | |
| 476 | 476 | if ( $type != 'xml' ) { |
| 477 | - $values = apply_filters('frm_pre_create_entry', $values); |
|
| 477 | + $values = apply_filters( 'frm_pre_create_entry', $values ); |
|
| 478 | 478 | } |
| 479 | 479 | |
| 480 | 480 | $new_values = self::package_entry_data( $values ); |
@@ -554,11 +554,11 @@ discard block |
||
| 554 | 554 | 'user_id' => self::get_entry_user_id( $values ), |
| 555 | 555 | ); |
| 556 | 556 | |
| 557 | - if ( is_array($new_values['name']) ) { |
|
| 558 | - $new_values['name'] = reset($new_values['name']); |
|
| 557 | + if ( is_array( $new_values['name'] ) ) { |
|
| 558 | + $new_values['name'] = reset( $new_values['name'] ); |
|
| 559 | 559 | } |
| 560 | 560 | |
| 561 | - $new_values['updated_by'] = isset($values['updated_by']) ? $values['updated_by'] : $new_values['user_id']; |
|
| 561 | + $new_values['updated_by'] = isset( $values['updated_by'] ) ? $values['updated_by'] : $new_values['user_id']; |
|
| 562 | 562 | |
| 563 | 563 | return $new_values; |
| 564 | 564 | } |
@@ -571,7 +571,7 @@ discard block |
||
| 571 | 571 | * @return int |
| 572 | 572 | */ |
| 573 | 573 | private static function get_is_draft_value( $values ) { |
| 574 | - return ( ( isset( $values['frm_saving_draft'] ) && $values['frm_saving_draft'] == 1 ) || ( isset( $values['is_draft'] ) && $values['is_draft'] == 1 ) ) ? 1 : 0; |
|
| 574 | + return ( ( isset( $values['frm_saving_draft'] ) && $values['frm_saving_draft'] == 1 ) || ( isset( $values['is_draft'] ) && $values['is_draft'] == 1 ) ) ? 1 : 0; |
|
| 575 | 575 | } |
| 576 | 576 | |
| 577 | 577 | /** |
@@ -593,7 +593,7 @@ discard block |
||
| 593 | 593 | * @return int |
| 594 | 594 | */ |
| 595 | 595 | private static function get_post_id( $values ) { |
| 596 | - return isset( $values['post_id'] ) ? (int) $values['post_id']: 0; |
|
| 596 | + return isset( $values['post_id'] ) ? (int) $values['post_id'] : 0; |
|
| 597 | 597 | } |
| 598 | 598 | |
| 599 | 599 | /** |
@@ -604,7 +604,7 @@ discard block |
||
| 604 | 604 | * @return int |
| 605 | 605 | */ |
| 606 | 606 | private static function get_parent_item_id( $values ) { |
| 607 | - return isset( $values['parent_item_id'] ) ? (int) $values['parent_item_id']: 0; |
|
| 607 | + return isset( $values['parent_item_id'] ) ? (int) $values['parent_item_id'] : 0; |
|
| 608 | 608 | } |
| 609 | 609 | |
| 610 | 610 | /** |
@@ -615,7 +615,7 @@ discard block |
||
| 615 | 615 | * @return string |
| 616 | 616 | */ |
| 617 | 617 | private static function get_created_at( $values ) { |
| 618 | - return isset( $values['created_at'] ) ? $values['created_at']: current_time('mysql', 1); |
|
| 618 | + return isset( $values['created_at'] ) ? $values['created_at'] : current_time( 'mysql', 1 ); |
|
| 619 | 619 | } |
| 620 | 620 | |
| 621 | 621 | /** |
@@ -703,7 +703,7 @@ discard block |
||
| 703 | 703 | private static function add_new_entry_to_frm_vars( $entry_id ) { |
| 704 | 704 | global $frm_vars; |
| 705 | 705 | |
| 706 | - if ( ! isset($frm_vars['saved_entries']) ) { |
|
| 706 | + if ( ! isset( $frm_vars['saved_entries'] ) ) { |
|
| 707 | 707 | $frm_vars['saved_entries'] = array(); |
| 708 | 708 | } |
| 709 | 709 | |
@@ -718,7 +718,7 @@ discard block |
||
| 718 | 718 | * @param int $entry_id |
| 719 | 719 | */ |
| 720 | 720 | private static function maybe_add_entry_metas( $values, $entry_id ) { |
| 721 | - if ( isset($values['item_meta']) ) { |
|
| 721 | + if ( isset( $values['item_meta'] ) ) { |
|
| 722 | 722 | FrmEntryMeta::update_entry_metas( $entry_id, $values['item_meta'] ); |
| 723 | 723 | } |
| 724 | 724 | } |
@@ -735,7 +735,7 @@ discard block |
||
| 735 | 735 | $is_child = isset( $values['parent_form_id'] ) && isset( $values['parent_nonce'] ) && ! empty( $values['parent_form_id'] ) && wp_verify_nonce( $values['parent_nonce'], 'parent' ); |
| 736 | 736 | |
| 737 | 737 | do_action( 'frm_after_create_entry', $entry_id, $new_values['form_id'], compact( 'is_child' ) ); |
| 738 | - do_action( 'frm_after_create_entry_' . $new_values['form_id'], $entry_id , compact( 'is_child' ) ); |
|
| 738 | + do_action( 'frm_after_create_entry_' . $new_values['form_id'], $entry_id, compact( 'is_child' ) ); |
|
| 739 | 739 | } |
| 740 | 740 | |
| 741 | 741 | /** |
@@ -776,7 +776,7 @@ discard block |
||
| 776 | 776 | } |
| 777 | 777 | |
| 778 | 778 | if ( $update && $update_type != 'xml' ) { |
| 779 | - $values = apply_filters('frm_pre_update_entry', $values, $id); |
|
| 779 | + $values = apply_filters( 'frm_pre_update_entry', $values, $id ); |
|
| 780 | 780 | } |
| 781 | 781 | |
| 782 | 782 | return $update; |
@@ -797,27 +797,27 @@ discard block |
||
| 797 | 797 | 'name' => self::get_new_entry_name( $values ), |
| 798 | 798 | 'form_id' => self::get_form_id( $values ), |
| 799 | 799 | 'is_draft' => self::get_is_draft_value( $values ), |
| 800 | - 'updated_at' => current_time('mysql', 1), |
|
| 801 | - 'updated_by' => isset($values['updated_by']) ? $values['updated_by'] : get_current_user_id(), |
|
| 800 | + 'updated_at' => current_time( 'mysql', 1 ), |
|
| 801 | + 'updated_by' => isset( $values['updated_by'] ) ? $values['updated_by'] : get_current_user_id(), |
|
| 802 | 802 | ); |
| 803 | 803 | |
| 804 | - if ( isset($values['post_id']) ) { |
|
| 804 | + if ( isset( $values['post_id'] ) ) { |
|
| 805 | 805 | $new_values['post_id'] = (int) $values['post_id']; |
| 806 | 806 | } |
| 807 | 807 | |
| 808 | - if ( isset($values['item_key']) ) { |
|
| 808 | + if ( isset( $values['item_key'] ) ) { |
|
| 809 | 809 | $new_values['item_key'] = FrmAppHelper::get_unique_key( $values['item_key'], $wpdb->prefix . 'frm_items', 'item_key', $id ); |
| 810 | 810 | } |
| 811 | 811 | |
| 812 | - if ( isset($values['parent_item_id']) ) { |
|
| 812 | + if ( isset( $values['parent_item_id'] ) ) { |
|
| 813 | 813 | $new_values['parent_item_id'] = (int) $values['parent_item_id']; |
| 814 | 814 | } |
| 815 | 815 | |
| 816 | - if ( isset($values['frm_user_id']) && is_numeric($values['frm_user_id']) ) { |
|
| 816 | + if ( isset( $values['frm_user_id'] ) && is_numeric( $values['frm_user_id'] ) ) { |
|
| 817 | 817 | $new_values['user_id'] = $values['frm_user_id']; |
| 818 | 818 | } |
| 819 | 819 | |
| 820 | - $new_values = apply_filters('frm_update_entry', $new_values, $id); |
|
| 820 | + $new_values = apply_filters( 'frm_update_entry', $new_values, $id ); |
|
| 821 | 821 | |
| 822 | 822 | return $new_values; |
| 823 | 823 | } |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | |
| 40 | 40 | $keyed_addons = array(); |
| 41 | 41 | foreach ( $addons as $addon ) { |
| 42 | - $keyed_addons[ $addon['info']['slug'] ] = $addon; |
|
| 42 | + $keyed_addons[$addon['info']['slug']] = $addon; |
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | $plugin_order = array( |
@@ -49,9 +49,9 @@ discard block |
||
| 49 | 49 | ); |
| 50 | 50 | $ordered_addons = array(); |
| 51 | 51 | foreach ( $plugin_order as $plugin ) { |
| 52 | - if ( isset( $keyed_addons[ $plugin ] ) ) { |
|
| 53 | - $ordered_addons[] = $keyed_addons[ $plugin ]; |
|
| 54 | - unset( $keyed_addons[ $plugin ] ); |
|
| 52 | + if ( isset( $keyed_addons[$plugin] ) ) { |
|
| 53 | + $ordered_addons[] = $keyed_addons[$plugin]; |
|
| 54 | + unset( $keyed_addons[$plugin] ); |
|
| 55 | 55 | } |
| 56 | 56 | } |
| 57 | 57 | $addons = $ordered_addons + $keyed_addons; |
@@ -86,10 +86,10 @@ discard block |
||
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | public static function get_licenses() { |
| 89 | - FrmAppHelper::permission_check('frm_change_settings'); |
|
| 89 | + FrmAppHelper::permission_check( 'frm_change_settings' ); |
|
| 90 | 90 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 91 | 91 | |
| 92 | - $license = get_option('frmpro-credentials'); |
|
| 92 | + $license = get_option( 'frmpro-credentials' ); |
|
| 93 | 93 | if ( $license && is_array( $license ) && isset( $license['license'] ) ) { |
| 94 | 94 | $url = 'http://formidablepro.com/frm-edd-api/licenses?l=' . urlencode( base64_encode( $license['license'] ) ); |
| 95 | 95 | $licenses = self::send_api_request( $url, array( 'name' => 'frm_api_licence', 'expires' => 60 * 60 * 5 ) ); |
@@ -2,110 +2,110 @@ discard block |
||
| 2 | 2 | |
| 3 | 3 | class FrmXMLController { |
| 4 | 4 | |
| 5 | - public static function menu() { |
|
| 5 | + public static function menu() { |
|
| 6 | 6 | add_submenu_page( 'formidable', 'Formidable | ' . __( 'Import/Export', 'formidable' ), __( 'Import/Export', 'formidable' ), 'frm_edit_forms', 'formidable-import', 'FrmXMLController::route' ); |
| 7 | - } |
|
| 7 | + } |
|
| 8 | 8 | |
| 9 | - public static function add_default_templates() { |
|
| 9 | + public static function add_default_templates() { |
|
| 10 | 10 | if ( ! function_exists( 'libxml_disable_entity_loader' ) ) { |
| 11 | - // XML import is not enabled on your server |
|
| 12 | - return; |
|
| 13 | - } |
|
| 11 | + // XML import is not enabled on your server |
|
| 12 | + return; |
|
| 13 | + } |
|
| 14 | 14 | |
| 15 | - $set_err = libxml_use_internal_errors(true); |
|
| 16 | - $loader = libxml_disable_entity_loader( true ); |
|
| 15 | + $set_err = libxml_use_internal_errors(true); |
|
| 16 | + $loader = libxml_disable_entity_loader( true ); |
|
| 17 | 17 | |
| 18 | 18 | $files = apply_filters( 'frm_default_templates_files', array( FrmAppHelper::plugin_path() . '/classes/views/xml/default-templates.xml' ) ); |
| 19 | 19 | |
| 20 | - foreach ( (array) $files as $file ) { |
|
| 21 | - FrmXMLHelper::import_xml($file); |
|
| 22 | - unset($file); |
|
| 23 | - } |
|
| 24 | - /* |
|
| 20 | + foreach ( (array) $files as $file ) { |
|
| 21 | + FrmXMLHelper::import_xml($file); |
|
| 22 | + unset($file); |
|
| 23 | + } |
|
| 24 | + /* |
|
| 25 | 25 | if(is_wp_error($result)) |
| 26 | 26 | $errors[] = $result->get_error_message(); |
| 27 | 27 | else if($result) |
| 28 | 28 | $message = $result; |
| 29 | 29 | */ |
| 30 | 30 | |
| 31 | - unset( $files ); |
|
| 31 | + unset( $files ); |
|
| 32 | 32 | |
| 33 | - libxml_use_internal_errors( $set_err ); |
|
| 34 | - libxml_disable_entity_loader( $loader ); |
|
| 35 | - } |
|
| 33 | + libxml_use_internal_errors( $set_err ); |
|
| 34 | + libxml_disable_entity_loader( $loader ); |
|
| 35 | + } |
|
| 36 | 36 | |
| 37 | - public static function route() { |
|
| 38 | - $action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action'; |
|
| 37 | + public static function route() { |
|
| 38 | + $action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action'; |
|
| 39 | 39 | $action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' ); |
| 40 | 40 | if ( $action == 'import_xml' ) { |
| 41 | - return self::import_xml(); |
|
| 41 | + return self::import_xml(); |
|
| 42 | 42 | } else if ( $action == 'export_xml' ) { |
| 43 | - return self::export_xml(); |
|
| 44 | - } else { |
|
| 45 | - if ( apply_filters( 'frm_xml_route', true, $action ) ) { |
|
| 46 | - return self::form(); |
|
| 47 | - } |
|
| 48 | - } |
|
| 49 | - } |
|
| 50 | - |
|
| 51 | - public static function form( $errors = array(), $message = '' ) { |
|
| 43 | + return self::export_xml(); |
|
| 44 | + } else { |
|
| 45 | + if ( apply_filters( 'frm_xml_route', true, $action ) ) { |
|
| 46 | + return self::form(); |
|
| 47 | + } |
|
| 48 | + } |
|
| 49 | + } |
|
| 50 | + |
|
| 51 | + public static function form( $errors = array(), $message = '' ) { |
|
| 52 | 52 | $where = array( |
| 53 | 53 | 'parent_form_id' => array( null, 0 ), |
| 54 | 54 | 'status' => array( null, '', 'published' ), |
| 55 | 55 | ); |
| 56 | 56 | $forms = FrmForm::getAll( $where, 'name' ); |
| 57 | 57 | |
| 58 | - $export_types = apply_filters( 'frm_xml_export_types', |
|
| 59 | - array( 'forms' => __( 'Forms', 'formidable' ), 'items' => __( 'Entries', 'formidable' ) ) |
|
| 60 | - ); |
|
| 58 | + $export_types = apply_filters( 'frm_xml_export_types', |
|
| 59 | + array( 'forms' => __( 'Forms', 'formidable' ), 'items' => __( 'Entries', 'formidable' ) ) |
|
| 60 | + ); |
|
| 61 | 61 | |
| 62 | - $export_format = apply_filters( 'frm_export_formats', array( |
|
| 63 | - 'xml' => array( 'name' => 'XML', 'support' => 'forms', 'count' => 'multiple' ), |
|
| 62 | + $export_format = apply_filters( 'frm_export_formats', array( |
|
| 63 | + 'xml' => array( 'name' => 'XML', 'support' => 'forms', 'count' => 'multiple' ), |
|
| 64 | 64 | 'csv' => array( 'name' => 'CSV', 'support' => 'items', 'count' => 'single' ), |
| 65 | - ) ); |
|
| 65 | + ) ); |
|
| 66 | 66 | |
| 67 | 67 | include( FrmAppHelper::plugin_path() . '/classes/views/xml/import_form.php' ); |
| 68 | - } |
|
| 68 | + } |
|
| 69 | 69 | |
| 70 | - public static function import_xml() { |
|
| 71 | - $errors = array(); |
|
| 72 | - $message = ''; |
|
| 70 | + public static function import_xml() { |
|
| 71 | + $errors = array(); |
|
| 72 | + $message = ''; |
|
| 73 | 73 | |
| 74 | - $permission_error = FrmAppHelper::permission_nonce_error('frm_edit_forms', 'import-xml', 'import-xml-nonce'); |
|
| 75 | - if ( $permission_error !== false ) { |
|
| 76 | - $errors[] = $permission_error; |
|
| 77 | - self::form($errors); |
|
| 78 | - return; |
|
| 79 | - } |
|
| 74 | + $permission_error = FrmAppHelper::permission_nonce_error('frm_edit_forms', 'import-xml', 'import-xml-nonce'); |
|
| 75 | + if ( $permission_error !== false ) { |
|
| 76 | + $errors[] = $permission_error; |
|
| 77 | + self::form($errors); |
|
| 78 | + return; |
|
| 79 | + } |
|
| 80 | 80 | |
| 81 | - if ( ! isset($_FILES) || ! isset($_FILES['frm_import_file']) || empty($_FILES['frm_import_file']['name']) || (int) $_FILES['frm_import_file']['size'] < 1 ) { |
|
| 82 | - $errors[] = __( 'Oops, you didn\'t select a file.', 'formidable' ); |
|
| 83 | - self::form($errors); |
|
| 84 | - return; |
|
| 85 | - } |
|
| 81 | + if ( ! isset($_FILES) || ! isset($_FILES['frm_import_file']) || empty($_FILES['frm_import_file']['name']) || (int) $_FILES['frm_import_file']['size'] < 1 ) { |
|
| 82 | + $errors[] = __( 'Oops, you didn\'t select a file.', 'formidable' ); |
|
| 83 | + self::form($errors); |
|
| 84 | + return; |
|
| 85 | + } |
|
| 86 | 86 | |
| 87 | - $file = $_FILES['frm_import_file']['tmp_name']; |
|
| 87 | + $file = $_FILES['frm_import_file']['tmp_name']; |
|
| 88 | 88 | |
| 89 | - if ( ! is_uploaded_file( $file ) ) { |
|
| 90 | - unset($file); |
|
| 91 | - $errors[] = __( 'The file does not exist, please try again.', 'formidable' ); |
|
| 92 | - self::form($errors); |
|
| 93 | - return; |
|
| 94 | - } |
|
| 89 | + if ( ! is_uploaded_file( $file ) ) { |
|
| 90 | + unset($file); |
|
| 91 | + $errors[] = __( 'The file does not exist, please try again.', 'formidable' ); |
|
| 92 | + self::form($errors); |
|
| 93 | + return; |
|
| 94 | + } |
|
| 95 | 95 | |
| 96 | - //add_filter('upload_mimes', 'FrmXMLController::allow_mime'); |
|
| 96 | + //add_filter('upload_mimes', 'FrmXMLController::allow_mime'); |
|
| 97 | 97 | |
| 98 | - $export_format = apply_filters('frm_export_formats', array( |
|
| 98 | + $export_format = apply_filters('frm_export_formats', array( |
|
| 99 | 99 | 'xml' => array( 'name' => 'XML', 'support' => 'forms', 'count' => 'multiple' ), |
| 100 | 100 | ) ); |
| 101 | 101 | |
| 102 | - $file_type = strtolower(pathinfo($_FILES['frm_import_file']['name'], PATHINFO_EXTENSION)); |
|
| 103 | - if ( $file_type != 'xml' && isset( $export_format[ $file_type ] ) ) { |
|
| 104 | - // allow other file types to be imported |
|
| 102 | + $file_type = strtolower(pathinfo($_FILES['frm_import_file']['name'], PATHINFO_EXTENSION)); |
|
| 103 | + if ( $file_type != 'xml' && isset( $export_format[ $file_type ] ) ) { |
|
| 104 | + // allow other file types to be imported |
|
| 105 | 105 | do_action( 'frm_before_import_' . $file_type ); |
| 106 | - return; |
|
| 107 | - } |
|
| 108 | - unset($file_type); |
|
| 106 | + return; |
|
| 107 | + } |
|
| 108 | + unset($file_type); |
|
| 109 | 109 | |
| 110 | 110 | if ( ! function_exists( 'libxml_disable_entity_loader' ) ) { |
| 111 | 111 | $errors[] = __( 'XML import is not enabled on your server.', 'formidable' ); |
@@ -124,148 +124,148 @@ discard block |
||
| 124 | 124 | libxml_use_internal_errors( $set_err ); |
| 125 | 125 | libxml_disable_entity_loader( $loader ); |
| 126 | 126 | |
| 127 | - self::form($errors, $message); |
|
| 128 | - } |
|
| 127 | + self::form($errors, $message); |
|
| 128 | + } |
|
| 129 | 129 | |
| 130 | - public static function export_xml() { |
|
| 131 | - $error = FrmAppHelper::permission_nonce_error( 'frm_edit_forms', 'export-xml', 'export-xml-nonce' ); |
|
| 132 | - if ( ! empty($error) ) { |
|
| 133 | - wp_die( $error ); |
|
| 134 | - } |
|
| 130 | + public static function export_xml() { |
|
| 131 | + $error = FrmAppHelper::permission_nonce_error( 'frm_edit_forms', 'export-xml', 'export-xml-nonce' ); |
|
| 132 | + if ( ! empty($error) ) { |
|
| 133 | + wp_die( $error ); |
|
| 134 | + } |
|
| 135 | 135 | |
| 136 | 136 | $ids = FrmAppHelper::get_post_param( 'frm_export_forms', array() ); |
| 137 | 137 | $type = FrmAppHelper::get_post_param( 'type', array() ); |
| 138 | 138 | $format = FrmAppHelper::get_post_param( 'format', 'xml', 'sanitize_title' ); |
| 139 | 139 | |
| 140 | - if ( ! headers_sent() && ! $type ) { |
|
| 141 | - wp_redirect( esc_url_raw( admin_url( 'admin.php?page=formidable-import' ) ) ); |
|
| 142 | - die(); |
|
| 143 | - } |
|
| 140 | + if ( ! headers_sent() && ! $type ) { |
|
| 141 | + wp_redirect( esc_url_raw( admin_url( 'admin.php?page=formidable-import' ) ) ); |
|
| 142 | + die(); |
|
| 143 | + } |
|
| 144 | 144 | |
| 145 | - if ( $format == 'xml' ) { |
|
| 146 | - self::generate_xml($type, compact('ids')); |
|
| 145 | + if ( $format == 'xml' ) { |
|
| 146 | + self::generate_xml($type, compact('ids')); |
|
| 147 | 147 | } if ( $format == 'csv' ) { |
| 148 | 148 | self::generate_csv( compact('ids') ); |
| 149 | - } else { |
|
| 149 | + } else { |
|
| 150 | 150 | do_action( 'frm_export_format_' . $format, compact('ids') ); |
| 151 | - } |
|
| 151 | + } |
|
| 152 | 152 | |
| 153 | - wp_die(); |
|
| 154 | - } |
|
| 153 | + wp_die(); |
|
| 154 | + } |
|
| 155 | 155 | |
| 156 | 156 | public static function generate_xml( $type, $args = array() ) { |
| 157 | - global $wpdb; |
|
| 157 | + global $wpdb; |
|
| 158 | 158 | |
| 159 | - $type = (array) $type; |
|
| 160 | - if ( in_array( 'items', $type) && ! in_array( 'forms', $type) ) { |
|
| 161 | - // make sure the form is included if there are entries |
|
| 162 | - $type[] = 'forms'; |
|
| 163 | - } |
|
| 159 | + $type = (array) $type; |
|
| 160 | + if ( in_array( 'items', $type) && ! in_array( 'forms', $type) ) { |
|
| 161 | + // make sure the form is included if there are entries |
|
| 162 | + $type[] = 'forms'; |
|
| 163 | + } |
|
| 164 | 164 | |
| 165 | - if ( in_array( 'forms', $type) ) { |
|
| 166 | - // include actions with forms |
|
| 167 | - $type[] = 'actions'; |
|
| 168 | - } |
|
| 165 | + if ( in_array( 'forms', $type) ) { |
|
| 166 | + // include actions with forms |
|
| 167 | + $type[] = 'actions'; |
|
| 168 | + } |
|
| 169 | 169 | |
| 170 | - $tables = array( |
|
| 170 | + $tables = array( |
|
| 171 | 171 | 'items' => $wpdb->prefix . 'frm_items', |
| 172 | 172 | 'forms' => $wpdb->prefix . 'frm_forms', |
| 173 | - 'posts' => $wpdb->posts, |
|
| 174 | - 'styles' => $wpdb->posts, |
|
| 175 | - 'actions' => $wpdb->posts, |
|
| 176 | - ); |
|
| 173 | + 'posts' => $wpdb->posts, |
|
| 174 | + 'styles' => $wpdb->posts, |
|
| 175 | + 'actions' => $wpdb->posts, |
|
| 176 | + ); |
|
| 177 | 177 | |
| 178 | 178 | $defaults = array( 'ids' => false ); |
| 179 | - $args = wp_parse_args( $args, $defaults ); |
|
| 179 | + $args = wp_parse_args( $args, $defaults ); |
|
| 180 | 180 | |
| 181 | - $sitename = sanitize_key( get_bloginfo( 'name' ) ); |
|
| 181 | + $sitename = sanitize_key( get_bloginfo( 'name' ) ); |
|
| 182 | 182 | |
| 183 | - if ( ! empty( $sitename ) ) { |
|
| 183 | + if ( ! empty( $sitename ) ) { |
|
| 184 | 184 | $sitename .= '.'; |
| 185 | 185 | } |
| 186 | - $filename = $sitename . 'formidable.' . date( 'Y-m-d' ) . '.xml'; |
|
| 186 | + $filename = $sitename . 'formidable.' . date( 'Y-m-d' ) . '.xml'; |
|
| 187 | 187 | |
| 188 | - header( 'Content-Description: File Transfer' ); |
|
| 189 | - header( 'Content-Disposition: attachment; filename=' . $filename ); |
|
| 190 | - header( 'Content-Type: text/xml; charset=' . get_option( 'blog_charset' ), true ); |
|
| 188 | + header( 'Content-Description: File Transfer' ); |
|
| 189 | + header( 'Content-Disposition: attachment; filename=' . $filename ); |
|
| 190 | + header( 'Content-Type: text/xml; charset=' . get_option( 'blog_charset' ), true ); |
|
| 191 | 191 | |
| 192 | - //make sure ids are numeric |
|
| 193 | - if ( is_array( $args['ids'] ) && ! empty( $args['ids'] ) ) { |
|
| 194 | - $args['ids'] = array_filter( $args['ids'], 'is_numeric' ); |
|
| 195 | - } |
|
| 192 | + //make sure ids are numeric |
|
| 193 | + if ( is_array( $args['ids'] ) && ! empty( $args['ids'] ) ) { |
|
| 194 | + $args['ids'] = array_filter( $args['ids'], 'is_numeric' ); |
|
| 195 | + } |
|
| 196 | 196 | |
| 197 | - $records = array(); |
|
| 197 | + $records = array(); |
|
| 198 | 198 | |
| 199 | 199 | foreach ( $type as $tb_type ) { |
| 200 | - $where = array(); |
|
| 200 | + $where = array(); |
|
| 201 | 201 | $join = ''; |
| 202 | - $table = $tables[ $tb_type ]; |
|
| 202 | + $table = $tables[ $tb_type ]; |
|
| 203 | 203 | |
| 204 | 204 | $select = $table . '.id'; |
| 205 | - $query_vars = array(); |
|
| 205 | + $query_vars = array(); |
|
| 206 | 206 | |
| 207 | - switch ( $tb_type ) { |
|
| 208 | - case 'forms': |
|
| 209 | - //add forms |
|
| 210 | - if ( $args['ids'] ) { |
|
| 207 | + switch ( $tb_type ) { |
|
| 208 | + case 'forms': |
|
| 209 | + //add forms |
|
| 210 | + if ( $args['ids'] ) { |
|
| 211 | 211 | $where[] = array( 'or' => 1, $table . '.id' => $args['ids'], $table . '.parent_form_id' => $args['ids'] ); |
| 212 | - } else { |
|
| 212 | + } else { |
|
| 213 | 213 | $where[ $table . '.status !' ] = 'draft'; |
| 214 | - } |
|
| 215 | - break; |
|
| 216 | - case 'actions': |
|
| 214 | + } |
|
| 215 | + break; |
|
| 216 | + case 'actions': |
|
| 217 | 217 | $select = $table . '.ID'; |
| 218 | 218 | $where['post_type'] = FrmFormActionsController::$action_post_type; |
| 219 | - if ( ! empty($args['ids']) ) { |
|
| 219 | + if ( ! empty($args['ids']) ) { |
|
| 220 | 220 | $where['menu_order'] = $args['ids']; |
| 221 | - } |
|
| 222 | - break; |
|
| 223 | - case 'items': |
|
| 224 | - //$join = "INNER JOIN {$wpdb->prefix}frm_item_metas im ON ($table.id = im.item_id)"; |
|
| 225 | - if ( $args['ids'] ) { |
|
| 221 | + } |
|
| 222 | + break; |
|
| 223 | + case 'items': |
|
| 224 | + //$join = "INNER JOIN {$wpdb->prefix}frm_item_metas im ON ($table.id = im.item_id)"; |
|
| 225 | + if ( $args['ids'] ) { |
|
| 226 | 226 | $where[ $table . '.form_id' ] = $args['ids']; |
| 227 | - } |
|
| 228 | - break; |
|
| 229 | - case 'styles': |
|
| 230 | - // Loop through all exported forms and get their selected style IDs |
|
| 231 | - $form_ids = $args['ids']; |
|
| 232 | - $style_ids = array(); |
|
| 233 | - foreach ( $form_ids as $form_id ) { |
|
| 234 | - $form_data = FrmForm::getOne( $form_id ); |
|
| 235 | - // For forms that have not been updated while running 2.0, check if custom_style is set |
|
| 236 | - if ( isset( $form_data->options['custom_style'] ) ) { |
|
| 237 | - $style_ids[] = $form_data->options['custom_style']; |
|
| 238 | - } |
|
| 239 | - unset( $form_id, $form_data ); |
|
| 240 | - } |
|
| 227 | + } |
|
| 228 | + break; |
|
| 229 | + case 'styles': |
|
| 230 | + // Loop through all exported forms and get their selected style IDs |
|
| 231 | + $form_ids = $args['ids']; |
|
| 232 | + $style_ids = array(); |
|
| 233 | + foreach ( $form_ids as $form_id ) { |
|
| 234 | + $form_data = FrmForm::getOne( $form_id ); |
|
| 235 | + // For forms that have not been updated while running 2.0, check if custom_style is set |
|
| 236 | + if ( isset( $form_data->options['custom_style'] ) ) { |
|
| 237 | + $style_ids[] = $form_data->options['custom_style']; |
|
| 238 | + } |
|
| 239 | + unset( $form_id, $form_data ); |
|
| 240 | + } |
|
| 241 | 241 | $select = $table . '.ID'; |
| 242 | - $where['post_type'] = 'frm_styles'; |
|
| 243 | - |
|
| 244 | - // Only export selected styles |
|
| 245 | - if ( ! empty( $style_ids ) ) { |
|
| 246 | - $where['ID'] = $style_ids; |
|
| 247 | - } |
|
| 248 | - break; |
|
| 249 | - default: |
|
| 242 | + $where['post_type'] = 'frm_styles'; |
|
| 243 | + |
|
| 244 | + // Only export selected styles |
|
| 245 | + if ( ! empty( $style_ids ) ) { |
|
| 246 | + $where['ID'] = $style_ids; |
|
| 247 | + } |
|
| 248 | + break; |
|
| 249 | + default: |
|
| 250 | 250 | $select = $table . '.ID'; |
| 251 | - $join = ' INNER JOIN ' . $wpdb->postmeta . ' pm ON (pm.post_id=' . $table . '.ID)'; |
|
| 252 | - $where['pm.meta_key'] = 'frm_form_id'; |
|
| 253 | - |
|
| 254 | - if ( empty($args['ids']) ) { |
|
| 255 | - $where['pm.meta_value >'] = 1; |
|
| 256 | - } else { |
|
| 257 | - $where['pm.meta_value'] = $args['ids']; |
|
| 258 | - } |
|
| 259 | - break; |
|
| 260 | - } |
|
| 251 | + $join = ' INNER JOIN ' . $wpdb->postmeta . ' pm ON (pm.post_id=' . $table . '.ID)'; |
|
| 252 | + $where['pm.meta_key'] = 'frm_form_id'; |
|
| 253 | + |
|
| 254 | + if ( empty($args['ids']) ) { |
|
| 255 | + $where['pm.meta_value >'] = 1; |
|
| 256 | + } else { |
|
| 257 | + $where['pm.meta_value'] = $args['ids']; |
|
| 258 | + } |
|
| 259 | + break; |
|
| 260 | + } |
|
| 261 | 261 | |
| 262 | 262 | $records[ $tb_type ] = FrmDb::get_col( $table . $join, $where, $select ); |
| 263 | - unset($tb_type); |
|
| 264 | - } |
|
| 263 | + unset($tb_type); |
|
| 264 | + } |
|
| 265 | 265 | |
| 266 | 266 | echo '<?xml version="1.0" encoding="' . esc_attr( get_bloginfo('charset') ) . "\" ?>\n"; |
| 267 | 267 | include( FrmAppHelper::plugin_path() . '/classes/views/xml/xml.php' ); |
| 268 | - } |
|
| 268 | + } |
|
| 269 | 269 | |
| 270 | 270 | |
| 271 | 271 | public static function generate_csv( $atts ) { |
@@ -336,14 +336,14 @@ discard block |
||
| 336 | 336 | } |
| 337 | 337 | |
| 338 | 338 | /** |
| 339 | - * Get the fields that should be included in the CSV export |
|
| 340 | - * |
|
| 341 | - * @since 2.0.19 |
|
| 342 | - * |
|
| 343 | - * @param int $form_id |
|
| 344 | - * @param object $form |
|
| 345 | - * @return array $csv_fields |
|
| 346 | - */ |
|
| 339 | + * Get the fields that should be included in the CSV export |
|
| 340 | + * |
|
| 341 | + * @since 2.0.19 |
|
| 342 | + * |
|
| 343 | + * @param int $form_id |
|
| 344 | + * @param object $form |
|
| 345 | + * @return array $csv_fields |
|
| 346 | + */ |
|
| 347 | 347 | private static function get_fields_for_csv_export( $form_id, $form ) { |
| 348 | 348 | // Phase frm_csv_field_ids out by 2.01.05 |
| 349 | 349 | $csv_field_ids = apply_filters( 'frm_csv_field_ids', '', $form_id, array( 'form' => $form ) ); |
@@ -373,16 +373,16 @@ discard block |
||
| 373 | 373 | } |
| 374 | 374 | |
| 375 | 375 | public static function allow_mime( $mimes ) { |
| 376 | - if ( ! isset( $mimes['csv'] ) ) { |
|
| 377 | - // allow csv files |
|
| 378 | - $mimes['csv'] = 'text/csv'; |
|
| 379 | - } |
|
| 380 | - |
|
| 381 | - if ( ! isset( $mimes['xml'] ) ) { |
|
| 382 | - // allow xml |
|
| 383 | - $mimes['xml'] = 'text/xml'; |
|
| 384 | - } |
|
| 385 | - |
|
| 386 | - return $mimes; |
|
| 387 | - } |
|
| 376 | + if ( ! isset( $mimes['csv'] ) ) { |
|
| 377 | + // allow csv files |
|
| 378 | + $mimes['csv'] = 'text/csv'; |
|
| 379 | + } |
|
| 380 | + |
|
| 381 | + if ( ! isset( $mimes['xml'] ) ) { |
|
| 382 | + // allow xml |
|
| 383 | + $mimes['xml'] = 'text/xml'; |
|
| 384 | + } |
|
| 385 | + |
|
| 386 | + return $mimes; |
|
| 387 | + } |
|
| 388 | 388 | } |
@@ -12,14 +12,14 @@ discard block |
||
| 12 | 12 | return; |
| 13 | 13 | } |
| 14 | 14 | |
| 15 | - $set_err = libxml_use_internal_errors(true); |
|
| 15 | + $set_err = libxml_use_internal_errors( true ); |
|
| 16 | 16 | $loader = libxml_disable_entity_loader( true ); |
| 17 | 17 | |
| 18 | 18 | $files = apply_filters( 'frm_default_templates_files', array( FrmAppHelper::plugin_path() . '/classes/views/xml/default-templates.xml' ) ); |
| 19 | 19 | |
| 20 | 20 | foreach ( (array) $files as $file ) { |
| 21 | - FrmXMLHelper::import_xml($file); |
|
| 22 | - unset($file); |
|
| 21 | + FrmXMLHelper::import_xml( $file ); |
|
| 22 | + unset( $file ); |
|
| 23 | 23 | } |
| 24 | 24 | /* |
| 25 | 25 | if(is_wp_error($result)) |
@@ -71,41 +71,41 @@ discard block |
||
| 71 | 71 | $errors = array(); |
| 72 | 72 | $message = ''; |
| 73 | 73 | |
| 74 | - $permission_error = FrmAppHelper::permission_nonce_error('frm_edit_forms', 'import-xml', 'import-xml-nonce'); |
|
| 74 | + $permission_error = FrmAppHelper::permission_nonce_error( 'frm_edit_forms', 'import-xml', 'import-xml-nonce' ); |
|
| 75 | 75 | if ( $permission_error !== false ) { |
| 76 | 76 | $errors[] = $permission_error; |
| 77 | - self::form($errors); |
|
| 77 | + self::form( $errors ); |
|
| 78 | 78 | return; |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | - if ( ! isset($_FILES) || ! isset($_FILES['frm_import_file']) || empty($_FILES['frm_import_file']['name']) || (int) $_FILES['frm_import_file']['size'] < 1 ) { |
|
| 81 | + if ( ! isset( $_FILES ) || ! isset( $_FILES['frm_import_file'] ) || empty( $_FILES['frm_import_file']['name'] ) || (int) $_FILES['frm_import_file']['size'] < 1 ) { |
|
| 82 | 82 | $errors[] = __( 'Oops, you didn\'t select a file.', 'formidable' ); |
| 83 | - self::form($errors); |
|
| 83 | + self::form( $errors ); |
|
| 84 | 84 | return; |
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | $file = $_FILES['frm_import_file']['tmp_name']; |
| 88 | 88 | |
| 89 | 89 | if ( ! is_uploaded_file( $file ) ) { |
| 90 | - unset($file); |
|
| 90 | + unset( $file ); |
|
| 91 | 91 | $errors[] = __( 'The file does not exist, please try again.', 'formidable' ); |
| 92 | - self::form($errors); |
|
| 92 | + self::form( $errors ); |
|
| 93 | 93 | return; |
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | //add_filter('upload_mimes', 'FrmXMLController::allow_mime'); |
| 97 | 97 | |
| 98 | - $export_format = apply_filters('frm_export_formats', array( |
|
| 98 | + $export_format = apply_filters( 'frm_export_formats', array( |
|
| 99 | 99 | 'xml' => array( 'name' => 'XML', 'support' => 'forms', 'count' => 'multiple' ), |
| 100 | 100 | ) ); |
| 101 | 101 | |
| 102 | - $file_type = strtolower(pathinfo($_FILES['frm_import_file']['name'], PATHINFO_EXTENSION)); |
|
| 103 | - if ( $file_type != 'xml' && isset( $export_format[ $file_type ] ) ) { |
|
| 102 | + $file_type = strtolower( pathinfo( $_FILES['frm_import_file']['name'], PATHINFO_EXTENSION ) ); |
|
| 103 | + if ( $file_type != 'xml' && isset( $export_format[$file_type] ) ) { |
|
| 104 | 104 | // allow other file types to be imported |
| 105 | 105 | do_action( 'frm_before_import_' . $file_type ); |
| 106 | 106 | return; |
| 107 | 107 | } |
| 108 | - unset($file_type); |
|
| 108 | + unset( $file_type ); |
|
| 109 | 109 | |
| 110 | 110 | if ( ! function_exists( 'libxml_disable_entity_loader' ) ) { |
| 111 | 111 | $errors[] = __( 'XML import is not enabled on your server.', 'formidable' ); |
@@ -124,12 +124,12 @@ discard block |
||
| 124 | 124 | libxml_use_internal_errors( $set_err ); |
| 125 | 125 | libxml_disable_entity_loader( $loader ); |
| 126 | 126 | |
| 127 | - self::form($errors, $message); |
|
| 127 | + self::form( $errors, $message ); |
|
| 128 | 128 | } |
| 129 | 129 | |
| 130 | 130 | public static function export_xml() { |
| 131 | 131 | $error = FrmAppHelper::permission_nonce_error( 'frm_edit_forms', 'export-xml', 'export-xml-nonce' ); |
| 132 | - if ( ! empty($error) ) { |
|
| 132 | + if ( ! empty( $error ) ) { |
|
| 133 | 133 | wp_die( $error ); |
| 134 | 134 | } |
| 135 | 135 | |
@@ -143,11 +143,11 @@ discard block |
||
| 143 | 143 | } |
| 144 | 144 | |
| 145 | 145 | if ( $format == 'xml' ) { |
| 146 | - self::generate_xml($type, compact('ids')); |
|
| 146 | + self::generate_xml( $type, compact( 'ids' ) ); |
|
| 147 | 147 | } if ( $format == 'csv' ) { |
| 148 | - self::generate_csv( compact('ids') ); |
|
| 148 | + self::generate_csv( compact( 'ids' ) ); |
|
| 149 | 149 | } else { |
| 150 | - do_action( 'frm_export_format_' . $format, compact('ids') ); |
|
| 150 | + do_action( 'frm_export_format_' . $format, compact( 'ids' ) ); |
|
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | wp_die(); |
@@ -157,12 +157,12 @@ discard block |
||
| 157 | 157 | global $wpdb; |
| 158 | 158 | |
| 159 | 159 | $type = (array) $type; |
| 160 | - if ( in_array( 'items', $type) && ! in_array( 'forms', $type) ) { |
|
| 160 | + if ( in_array( 'items', $type ) && ! in_array( 'forms', $type ) ) { |
|
| 161 | 161 | // make sure the form is included if there are entries |
| 162 | 162 | $type[] = 'forms'; |
| 163 | 163 | } |
| 164 | 164 | |
| 165 | - if ( in_array( 'forms', $type) ) { |
|
| 165 | + if ( in_array( 'forms', $type ) ) { |
|
| 166 | 166 | // include actions with forms |
| 167 | 167 | $type[] = 'actions'; |
| 168 | 168 | } |
@@ -199,7 +199,7 @@ discard block |
||
| 199 | 199 | foreach ( $type as $tb_type ) { |
| 200 | 200 | $where = array(); |
| 201 | 201 | $join = ''; |
| 202 | - $table = $tables[ $tb_type ]; |
|
| 202 | + $table = $tables[$tb_type]; |
|
| 203 | 203 | |
| 204 | 204 | $select = $table . '.id'; |
| 205 | 205 | $query_vars = array(); |
@@ -210,20 +210,20 @@ discard block |
||
| 210 | 210 | if ( $args['ids'] ) { |
| 211 | 211 | $where[] = array( 'or' => 1, $table . '.id' => $args['ids'], $table . '.parent_form_id' => $args['ids'] ); |
| 212 | 212 | } else { |
| 213 | - $where[ $table . '.status !' ] = 'draft'; |
|
| 213 | + $where[$table . '.status !'] = 'draft'; |
|
| 214 | 214 | } |
| 215 | 215 | break; |
| 216 | 216 | case 'actions': |
| 217 | 217 | $select = $table . '.ID'; |
| 218 | 218 | $where['post_type'] = FrmFormActionsController::$action_post_type; |
| 219 | - if ( ! empty($args['ids']) ) { |
|
| 219 | + if ( ! empty( $args['ids'] ) ) { |
|
| 220 | 220 | $where['menu_order'] = $args['ids']; |
| 221 | 221 | } |
| 222 | 222 | break; |
| 223 | 223 | case 'items': |
| 224 | 224 | //$join = "INNER JOIN {$wpdb->prefix}frm_item_metas im ON ($table.id = im.item_id)"; |
| 225 | 225 | if ( $args['ids'] ) { |
| 226 | - $where[ $table . '.form_id' ] = $args['ids']; |
|
| 226 | + $where[$table . '.form_id'] = $args['ids']; |
|
| 227 | 227 | } |
| 228 | 228 | break; |
| 229 | 229 | case 'styles': |
@@ -251,7 +251,7 @@ discard block |
||
| 251 | 251 | $join = ' INNER JOIN ' . $wpdb->postmeta . ' pm ON (pm.post_id=' . $table . '.ID)'; |
| 252 | 252 | $where['pm.meta_key'] = 'frm_form_id'; |
| 253 | 253 | |
| 254 | - if ( empty($args['ids']) ) { |
|
| 254 | + if ( empty( $args['ids'] ) ) { |
|
| 255 | 255 | $where['pm.meta_value >'] = 1; |
| 256 | 256 | } else { |
| 257 | 257 | $where['pm.meta_value'] = $args['ids']; |
@@ -259,11 +259,11 @@ discard block |
||
| 259 | 259 | break; |
| 260 | 260 | } |
| 261 | 261 | |
| 262 | - $records[ $tb_type ] = FrmDb::get_col( $table . $join, $where, $select ); |
|
| 263 | - unset($tb_type); |
|
| 262 | + $records[$tb_type] = FrmDb::get_col( $table . $join, $where, $select ); |
|
| 263 | + unset( $tb_type ); |
|
| 264 | 264 | } |
| 265 | 265 | |
| 266 | - echo '<?xml version="1.0" encoding="' . esc_attr( get_bloginfo('charset') ) . "\" ?>\n"; |
|
| 266 | + echo '<?xml version="1.0" encoding="' . esc_attr( get_bloginfo( 'charset' ) ) . "\" ?>\n"; |
|
| 267 | 267 | include( FrmAppHelper::plugin_path() . '/classes/views/xml/xml.php' ); |
| 268 | 268 | } |
| 269 | 269 | |
@@ -289,10 +289,10 @@ discard block |
||
| 289 | 289 | $fid = FrmAppHelper::get_param( 'fid', '', 'get', 'sanitize_text_field' ); |
| 290 | 290 | } |
| 291 | 291 | |
| 292 | - set_time_limit(0); //Remove time limit to execute this function |
|
| 293 | - $mem_limit = str_replace('M', '', ini_get('memory_limit')); |
|
| 292 | + set_time_limit( 0 ); //Remove time limit to execute this function |
|
| 293 | + $mem_limit = str_replace( 'M', '', ini_get( 'memory_limit' ) ); |
|
| 294 | 294 | if ( (int) $mem_limit < 256 ) { |
| 295 | - ini_set('memory_limit', '256M'); |
|
| 295 | + ini_set( 'memory_limit', '256M' ); |
|
| 296 | 296 | } |
| 297 | 297 | |
| 298 | 298 | global $wpdb; |
@@ -362,7 +362,7 @@ discard block |
||
| 362 | 362 | $no_export_fields = FrmField::no_save_fields(); |
| 363 | 363 | foreach ( $csv_fields as $k => $f ) { |
| 364 | 364 | if ( in_array( $f->type, $no_export_fields ) ) { |
| 365 | - unset( $csv_fields[ $k ] ); |
|
| 365 | + unset( $csv_fields[$k] ); |
|
| 366 | 366 | } |
| 367 | 367 | } |
| 368 | 368 | } |
@@ -135,7 +135,7 @@ discard block |
||
| 135 | 135 | <div class="update-nag frm-update-to-pro"> |
| 136 | 136 | <?php echo FrmAppHelper::kses( $tip['tip'] ) ?> |
| 137 | 137 | <span><?php echo FrmAppHelper::kses( $tip['call'] ) ?></span> |
| 138 | - <a href="<?php echo esc_url( FrmAppHelper::make_affiliate_url('https://formidablepro.com?banner=1&tip=' . absint( $tip['num'] ) ) ) ?>" class="button">Upgrade to Pro</a> |
|
| 138 | + <a href="<?php echo esc_url( FrmAppHelper::make_affiliate_url( 'https://formidablepro.com?banner=1&tip=' . absint( $tip['num'] ) ) ) ?>" class="button">Upgrade to Pro</a> |
|
| 139 | 139 | </div> |
| 140 | 140 | <?php |
| 141 | 141 | } |
@@ -385,7 +385,7 @@ discard block |
||
| 385 | 385 | } |
| 386 | 386 | |
| 387 | 387 | public static function uninstall() { |
| 388 | - FrmAppHelper::permission_check('administrator'); |
|
| 388 | + FrmAppHelper::permission_check( 'administrator' ); |
|
| 389 | 389 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 390 | 390 | |
| 391 | 391 | $frmdb = new FrmDb(); |
@@ -420,7 +420,7 @@ discard block |
||
| 420 | 420 | } |
| 421 | 421 | |
| 422 | 422 | public static function deauthorize() { |
| 423 | - FrmAppHelper::permission_check('frm_change_settings'); |
|
| 423 | + FrmAppHelper::permission_check( 'frm_change_settings' ); |
|
| 424 | 424 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 425 | 425 | |
| 426 | 426 | delete_option( 'frmpro-credentials' ); |
@@ -3,14 +3,14 @@ discard block |
||
| 3 | 3 | class FrmAppController { |
| 4 | 4 | |
| 5 | 5 | public static function menu() { |
| 6 | - FrmAppHelper::maybe_add_permissions(); |
|
| 7 | - if ( ! current_user_can( 'frm_view_forms' ) ) { |
|
| 8 | - return; |
|
| 9 | - } |
|
| 6 | + FrmAppHelper::maybe_add_permissions(); |
|
| 7 | + if ( ! current_user_can( 'frm_view_forms' ) ) { |
|
| 8 | + return; |
|
| 9 | + } |
|
| 10 | 10 | |
| 11 | 11 | $menu_name = FrmAppHelper::get_menu_name(); |
| 12 | 12 | add_menu_page( 'Formidable', $menu_name, 'frm_view_forms', 'formidable', 'FrmFormsController::route', '', self::get_menu_position() ); |
| 13 | - } |
|
| 13 | + } |
|
| 14 | 14 | |
| 15 | 15 | private static function get_menu_position() { |
| 16 | 16 | $count = count( get_post_types( array( 'show_ui' => true, '_builtin' => false, 'show_in_menu' => true ) ) ); |
@@ -19,39 +19,39 @@ discard block |
||
| 19 | 19 | return $pos; |
| 20 | 20 | } |
| 21 | 21 | |
| 22 | - public static function load_wp_admin_style() { |
|
| 23 | - FrmAppHelper::load_font_style(); |
|
| 24 | - } |
|
| 22 | + public static function load_wp_admin_style() { |
|
| 23 | + FrmAppHelper::load_font_style(); |
|
| 24 | + } |
|
| 25 | 25 | |
| 26 | 26 | public static function get_form_nav( $form, $show_nav = false, $title = 'show' ) { |
| 27 | - global $pagenow, $frm_vars; |
|
| 27 | + global $pagenow, $frm_vars; |
|
| 28 | 28 | |
| 29 | 29 | $show_nav = FrmAppHelper::get_param( 'show_nav', $show_nav, 'get', 'absint' ); |
| 30 | - if ( empty( $show_nav ) ) { |
|
| 31 | - return; |
|
| 32 | - } |
|
| 30 | + if ( empty( $show_nav ) ) { |
|
| 31 | + return; |
|
| 32 | + } |
|
| 33 | 33 | |
| 34 | 34 | $current_page = isset( $_GET['page'] ) ? FrmAppHelper::simple_get( 'page', 'sanitize_title' ) : FrmAppHelper::simple_get( 'post_type', 'sanitize_title', 'None' ); |
| 35 | 35 | if ( $pagenow == 'post.php' || $pagenow == 'post-new.php' ) { |
| 36 | 36 | $current_page = 'frm_display'; |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | - if ( $form ) { |
|
| 39 | + if ( $form ) { |
|
| 40 | 40 | FrmForm::maybe_get_form( $form ); |
| 41 | 41 | |
| 42 | - if ( is_object( $form ) ) { |
|
| 43 | - $id = $form->id; |
|
| 44 | - } |
|
| 45 | - } |
|
| 42 | + if ( is_object( $form ) ) { |
|
| 43 | + $id = $form->id; |
|
| 44 | + } |
|
| 45 | + } |
|
| 46 | 46 | |
| 47 | - if ( ! isset( $id ) ) { |
|
| 48 | - $form = $id = false; |
|
| 49 | - } |
|
| 47 | + if ( ! isset( $id ) ) { |
|
| 48 | + $form = $id = false; |
|
| 49 | + } |
|
| 50 | 50 | |
| 51 | 51 | $nav_items = self::get_form_nav_items( $id ); |
| 52 | 52 | |
| 53 | - include( FrmAppHelper::plugin_path() . '/classes/views/shared/form-nav.php' ); |
|
| 54 | - } |
|
| 53 | + include( FrmAppHelper::plugin_path() . '/classes/views/shared/form-nav.php' ); |
|
| 54 | + } |
|
| 55 | 55 | |
| 56 | 56 | private static function get_form_nav_items( $id ) { |
| 57 | 57 | $nav_items = array( |
@@ -82,28 +82,28 @@ discard block |
||
| 82 | 82 | return $nav_items; |
| 83 | 83 | } |
| 84 | 84 | |
| 85 | - // Adds a settings link to the plugins page |
|
| 86 | - public static function settings_link( $links ) { |
|
| 85 | + // Adds a settings link to the plugins page |
|
| 86 | + public static function settings_link( $links ) { |
|
| 87 | 87 | $settings = '<a href="' . esc_url( admin_url( 'admin.php?page=formidable-settings' ) ) . '">' . __( 'Settings', 'formidable' ) . '</a>'; |
| 88 | - array_unshift( $links, $settings ); |
|
| 88 | + array_unshift( $links, $settings ); |
|
| 89 | 89 | |
| 90 | - return $links; |
|
| 91 | - } |
|
| 90 | + return $links; |
|
| 91 | + } |
|
| 92 | 92 | |
| 93 | - public static function pro_get_started_headline() { |
|
| 93 | + public static function pro_get_started_headline() { |
|
| 94 | 94 | self::maybe_show_upgrade_bar(); |
| 95 | 95 | |
| 96 | - // Don't display this error as we're upgrading the thing, or if the user shouldn't see the message |
|
| 97 | - if ( 'upgrade-plugin' == FrmAppHelper::simple_get( 'action', 'sanitize_title' ) || ! current_user_can( 'update_plugins' ) ) { |
|
| 98 | - return; |
|
| 99 | - } |
|
| 96 | + // Don't display this error as we're upgrading the thing, or if the user shouldn't see the message |
|
| 97 | + if ( 'upgrade-plugin' == FrmAppHelper::simple_get( 'action', 'sanitize_title' ) || ! current_user_can( 'update_plugins' ) ) { |
|
| 98 | + return; |
|
| 99 | + } |
|
| 100 | 100 | |
| 101 | 101 | if ( get_site_option( 'frmpro-authorized' ) && ! file_exists( FrmAppHelper::plugin_path() . '/pro/formidable-pro.php' ) ) { |
| 102 | - FrmAppHelper::load_admin_wide_js(); |
|
| 102 | + FrmAppHelper::load_admin_wide_js(); |
|
| 103 | 103 | |
| 104 | - // user is authorized, but running free version |
|
| 105 | - $inst_install_url = 'https://formidablepro.com/knowledgebase/install-formidable-forms/'; |
|
| 106 | - ?> |
|
| 104 | + // user is authorized, but running free version |
|
| 105 | + $inst_install_url = 'https://formidablepro.com/knowledgebase/install-formidable-forms/'; |
|
| 106 | + ?> |
|
| 107 | 107 | <div class="error" class="frm_previous_install"> |
| 108 | 108 | <?php |
| 109 | 109 | echo wp_kses_post( apply_filters( 'frm_pro_update_msg', |
@@ -115,8 +115,8 @@ discard block |
||
| 115 | 115 | ) ); ?> |
| 116 | 116 | </div> |
| 117 | 117 | <?php |
| 118 | - } |
|
| 119 | - } |
|
| 118 | + } |
|
| 119 | + } |
|
| 120 | 120 | |
| 121 | 121 | private static function maybe_show_upgrade_bar() { |
| 122 | 122 | $page = FrmAppHelper::simple_get( 'page', 'sanitize_title' ); |
@@ -218,7 +218,7 @@ discard block |
||
| 218 | 218 | } |
| 219 | 219 | } |
| 220 | 220 | |
| 221 | - public static function admin_js() { |
|
| 221 | + public static function admin_js() { |
|
| 222 | 222 | $version = FrmAppHelper::plugin_version(); |
| 223 | 223 | FrmAppHelper::load_admin_wide_js( false ); |
| 224 | 224 | |
@@ -229,7 +229,7 @@ discard block |
||
| 229 | 229 | 'bootstrap_tooltip', 'bootstrap-multiselect', |
| 230 | 230 | ), $version, true ); |
| 231 | 231 | wp_register_style( 'formidable-admin', FrmAppHelper::plugin_url() . '/css/frm_admin.css', array(), $version ); |
| 232 | - wp_register_script( 'bootstrap_tooltip', FrmAppHelper::plugin_url() . '/js/bootstrap.min.js', array( 'jquery' ), '3.3.4' ); |
|
| 232 | + wp_register_script( 'bootstrap_tooltip', FrmAppHelper::plugin_url() . '/js/bootstrap.min.js', array( 'jquery' ), '3.3.4' ); |
|
| 233 | 233 | wp_register_style( 'formidable-grids', FrmAppHelper::plugin_url() . '/css/frm_grids.css', array(), $version ); |
| 234 | 234 | wp_register_style( 'formidable-dropzone', FrmAppHelper::plugin_url() . '/css/dropzone.css', array(), $version ); |
| 235 | 235 | |
@@ -242,65 +242,65 @@ discard block |
||
| 242 | 242 | global $pagenow; |
| 243 | 243 | if ( strpos( $page, 'formidable' ) === 0 || ( $pagenow == 'edit.php' && $post_type == 'frm_display' ) ) { |
| 244 | 244 | |
| 245 | - wp_enqueue_script( 'admin-widgets' ); |
|
| 246 | - wp_enqueue_style( 'widgets' ); |
|
| 247 | - wp_enqueue_script( 'formidable' ); |
|
| 248 | - wp_enqueue_script( 'formidable_admin' ); |
|
| 245 | + wp_enqueue_script( 'admin-widgets' ); |
|
| 246 | + wp_enqueue_style( 'widgets' ); |
|
| 247 | + wp_enqueue_script( 'formidable' ); |
|
| 248 | + wp_enqueue_script( 'formidable_admin' ); |
|
| 249 | 249 | FrmAppHelper::localize_script( 'admin' ); |
| 250 | 250 | |
| 251 | - wp_enqueue_style( 'formidable-admin' ); |
|
| 251 | + wp_enqueue_style( 'formidable-admin' ); |
|
| 252 | 252 | wp_enqueue_style( 'formidable-grids' ); |
| 253 | 253 | wp_enqueue_style( 'formidable-dropzone' ); |
| 254 | - add_thickbox(); |
|
| 254 | + add_thickbox(); |
|
| 255 | 255 | |
| 256 | - wp_register_script( 'formidable-editinplace', FrmAppHelper::plugin_url() . '/js/jquery/jquery.editinplace.packed.js', array( 'jquery' ), '2.3.0' ); |
|
| 256 | + wp_register_script( 'formidable-editinplace', FrmAppHelper::plugin_url() . '/js/jquery/jquery.editinplace.packed.js', array( 'jquery' ), '2.3.0' ); |
|
| 257 | 257 | |
| 258 | - } else if ( $pagenow == 'post.php' || ( $pagenow == 'post-new.php' && $post_type == 'frm_display' ) ) { |
|
| 259 | - if ( isset( $_REQUEST['post_type'] ) ) { |
|
| 260 | - $post_type = sanitize_title( $_REQUEST['post_type'] ); |
|
| 258 | + } else if ( $pagenow == 'post.php' || ( $pagenow == 'post-new.php' && $post_type == 'frm_display' ) ) { |
|
| 259 | + if ( isset( $_REQUEST['post_type'] ) ) { |
|
| 260 | + $post_type = sanitize_title( $_REQUEST['post_type'] ); |
|
| 261 | 261 | } else if ( isset( $_REQUEST['post'] ) && absint( $_REQUEST['post'] ) ) { |
| 262 | 262 | $post = get_post( absint( $_REQUEST['post'] ) ); |
| 263 | - if ( ! $post ) { |
|
| 264 | - return; |
|
| 265 | - } |
|
| 266 | - $post_type = $post->post_type; |
|
| 267 | - } else { |
|
| 268 | - return; |
|
| 269 | - } |
|
| 270 | - |
|
| 271 | - if ( $post_type == 'frm_display' ) { |
|
| 272 | - wp_enqueue_script( 'jquery-ui-draggable' ); |
|
| 273 | - wp_enqueue_script( 'formidable_admin' ); |
|
| 274 | - wp_enqueue_style( 'formidable-admin' ); |
|
| 263 | + if ( ! $post ) { |
|
| 264 | + return; |
|
| 265 | + } |
|
| 266 | + $post_type = $post->post_type; |
|
| 267 | + } else { |
|
| 268 | + return; |
|
| 269 | + } |
|
| 270 | + |
|
| 271 | + if ( $post_type == 'frm_display' ) { |
|
| 272 | + wp_enqueue_script( 'jquery-ui-draggable' ); |
|
| 273 | + wp_enqueue_script( 'formidable_admin' ); |
|
| 274 | + wp_enqueue_style( 'formidable-admin' ); |
|
| 275 | 275 | FrmAppHelper::localize_script( 'admin' ); |
| 276 | - } |
|
| 277 | - } else if ( $pagenow == 'widgets.php' ) { |
|
| 278 | - FrmAppHelper::load_admin_wide_js(); |
|
| 279 | - } |
|
| 280 | - } |
|
| 281 | - |
|
| 282 | - public static function load_lang() { |
|
| 283 | - load_plugin_textdomain( 'formidable', false, FrmAppHelper::plugin_folder() . '/languages/' ); |
|
| 284 | - } |
|
| 285 | - |
|
| 286 | - /** |
|
| 287 | - * Filter shortcodes in text widgets |
|
| 288 | - */ |
|
| 289 | - public static function widget_text_filter( $content ) { |
|
| 290 | - $regex = '/\[\s*(formidable|display-frm-data|frm-stats|frm-graph|frm-entry-links|formresults|frm-search)\s+.*\]/'; |
|
| 291 | - return preg_replace_callback( $regex, 'FrmAppHelper::widget_text_filter_callback', $content ); |
|
| 292 | - } |
|
| 293 | - |
|
| 294 | - public static function front_head() { |
|
| 295 | - if ( is_multisite() ) { |
|
| 296 | - $old_db_version = get_option( 'frm_db_version' ); |
|
| 297 | - $pro_db_version = FrmAppHelper::pro_is_installed() ? get_option( 'frmpro_db_version' ) : false; |
|
| 298 | - if ( ( (int) $old_db_version < (int) FrmAppHelper::$db_version ) || |
|
| 299 | - ( FrmAppHelper::pro_is_installed() && (int) $pro_db_version < (int) FrmAppHelper::$pro_db_version ) ) { |
|
| 300 | - self::install( $old_db_version ); |
|
| 301 | - } |
|
| 302 | - } |
|
| 303 | - } |
|
| 276 | + } |
|
| 277 | + } else if ( $pagenow == 'widgets.php' ) { |
|
| 278 | + FrmAppHelper::load_admin_wide_js(); |
|
| 279 | + } |
|
| 280 | + } |
|
| 281 | + |
|
| 282 | + public static function load_lang() { |
|
| 283 | + load_plugin_textdomain( 'formidable', false, FrmAppHelper::plugin_folder() . '/languages/' ); |
|
| 284 | + } |
|
| 285 | + |
|
| 286 | + /** |
|
| 287 | + * Filter shortcodes in text widgets |
|
| 288 | + */ |
|
| 289 | + public static function widget_text_filter( $content ) { |
|
| 290 | + $regex = '/\[\s*(formidable|display-frm-data|frm-stats|frm-graph|frm-entry-links|formresults|frm-search)\s+.*\]/'; |
|
| 291 | + return preg_replace_callback( $regex, 'FrmAppHelper::widget_text_filter_callback', $content ); |
|
| 292 | + } |
|
| 293 | + |
|
| 294 | + public static function front_head() { |
|
| 295 | + if ( is_multisite() ) { |
|
| 296 | + $old_db_version = get_option( 'frm_db_version' ); |
|
| 297 | + $pro_db_version = FrmAppHelper::pro_is_installed() ? get_option( 'frmpro_db_version' ) : false; |
|
| 298 | + if ( ( (int) $old_db_version < (int) FrmAppHelper::$db_version ) || |
|
| 299 | + ( FrmAppHelper::pro_is_installed() && (int) $pro_db_version < (int) FrmAppHelper::$pro_db_version ) ) { |
|
| 300 | + self::install( $old_db_version ); |
|
| 301 | + } |
|
| 302 | + } |
|
| 303 | + } |
|
| 304 | 304 | |
| 305 | 305 | public static function localize_script( $location ) { |
| 306 | 306 | _deprecated_function( __FUNCTION__, '2.0.9', 'FrmAppHelper::localize_script' ); |
@@ -355,20 +355,20 @@ discard block |
||
| 355 | 355 | wp_die(); |
| 356 | 356 | } |
| 357 | 357 | |
| 358 | - public static function activation_install() { |
|
| 359 | - FrmAppHelper::delete_cache_and_transient( 'frm_plugin_version' ); |
|
| 360 | - FrmFormActionsController::actions_init(); |
|
| 361 | - self::install(); |
|
| 362 | - } |
|
| 358 | + public static function activation_install() { |
|
| 359 | + FrmAppHelper::delete_cache_and_transient( 'frm_plugin_version' ); |
|
| 360 | + FrmFormActionsController::actions_init(); |
|
| 361 | + self::install(); |
|
| 362 | + } |
|
| 363 | 363 | |
| 364 | - public static function install( $old_db_version = false ) { |
|
| 365 | - $frmdb = new FrmDb(); |
|
| 366 | - $frmdb->upgrade( $old_db_version ); |
|
| 367 | - } |
|
| 364 | + public static function install( $old_db_version = false ) { |
|
| 365 | + $frmdb = new FrmDb(); |
|
| 366 | + $frmdb->upgrade( $old_db_version ); |
|
| 367 | + } |
|
| 368 | 368 | |
| 369 | - public static function uninstall() { |
|
| 369 | + public static function uninstall() { |
|
| 370 | 370 | FrmAppHelper::permission_check('administrator'); |
| 371 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 371 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 372 | 372 | |
| 373 | 373 | $frmdb = new FrmDb(); |
| 374 | 374 | $frmdb->uninstall(); |
@@ -377,43 +377,43 @@ discard block |
||
| 377 | 377 | deactivate_plugins( FrmAppHelper::plugin_folder() . '/formidable.php', false, false ); |
| 378 | 378 | echo esc_url_raw( admin_url( 'plugins.php?deactivate=true' ) ); |
| 379 | 379 | |
| 380 | - wp_die(); |
|
| 381 | - } |
|
| 380 | + wp_die(); |
|
| 381 | + } |
|
| 382 | 382 | |
| 383 | - public static function drop_tables( $tables ) { |
|
| 384 | - global $wpdb; |
|
| 385 | - $tables[] = $wpdb->prefix . 'frm_fields'; |
|
| 386 | - $tables[] = $wpdb->prefix . 'frm_forms'; |
|
| 387 | - $tables[] = $wpdb->prefix . 'frm_items'; |
|
| 388 | - $tables[] = $wpdb->prefix . 'frm_item_metas'; |
|
| 389 | - return $tables; |
|
| 390 | - } |
|
| 383 | + public static function drop_tables( $tables ) { |
|
| 384 | + global $wpdb; |
|
| 385 | + $tables[] = $wpdb->prefix . 'frm_fields'; |
|
| 386 | + $tables[] = $wpdb->prefix . 'frm_forms'; |
|
| 387 | + $tables[] = $wpdb->prefix . 'frm_items'; |
|
| 388 | + $tables[] = $wpdb->prefix . 'frm_item_metas'; |
|
| 389 | + return $tables; |
|
| 390 | + } |
|
| 391 | 391 | |
| 392 | - // Routes for wordpress pages -- we're just replacing content here folks. |
|
| 393 | - public static function page_route( $content ) { |
|
| 394 | - global $post; |
|
| 392 | + // Routes for wordpress pages -- we're just replacing content here folks. |
|
| 393 | + public static function page_route( $content ) { |
|
| 394 | + global $post; |
|
| 395 | 395 | |
| 396 | - $frm_settings = FrmAppHelper::get_settings(); |
|
| 397 | - if ( $post && $post->ID == $frm_settings->preview_page_id && isset( $_GET['form'] ) ) { |
|
| 398 | - $content = FrmFormsController::page_preview(); |
|
| 399 | - } |
|
| 396 | + $frm_settings = FrmAppHelper::get_settings(); |
|
| 397 | + if ( $post && $post->ID == $frm_settings->preview_page_id && isset( $_GET['form'] ) ) { |
|
| 398 | + $content = FrmFormsController::page_preview(); |
|
| 399 | + } |
|
| 400 | 400 | |
| 401 | - return $content; |
|
| 402 | - } |
|
| 401 | + return $content; |
|
| 402 | + } |
|
| 403 | 403 | |
| 404 | - public static function deauthorize() { |
|
| 404 | + public static function deauthorize() { |
|
| 405 | 405 | FrmAppHelper::permission_check('frm_change_settings'); |
| 406 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 407 | - |
|
| 408 | - delete_option( 'frmpro-credentials' ); |
|
| 409 | - delete_option( 'frmpro-authorized' ); |
|
| 410 | - delete_site_option( 'frmpro-credentials' ); |
|
| 411 | - delete_site_option( 'frmpro-authorized' ); |
|
| 412 | - wp_die(); |
|
| 413 | - } |
|
| 414 | - |
|
| 415 | - public static function get_form_shortcode( $atts ) { |
|
| 416 | - _deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::get_form_shortcode()' ); |
|
| 417 | - return FrmFormsController::get_form_shortcode( $atts ); |
|
| 418 | - } |
|
| 406 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 407 | + |
|
| 408 | + delete_option( 'frmpro-credentials' ); |
|
| 409 | + delete_option( 'frmpro-authorized' ); |
|
| 410 | + delete_site_option( 'frmpro-credentials' ); |
|
| 411 | + delete_site_option( 'frmpro-authorized' ); |
|
| 412 | + wp_die(); |
|
| 413 | + } |
|
| 414 | + |
|
| 415 | + public static function get_form_shortcode( $atts ) { |
|
| 416 | + _deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::get_form_shortcode()' ); |
|
| 417 | + return FrmFormsController::get_form_shortcode( $atts ); |
|
| 418 | + } |
|
| 419 | 419 | } |
@@ -48,17 +48,17 @@ discard block |
||
| 48 | 48 | 'highrise' => 'FrmDefHrsAction', |
| 49 | 49 | ) ); |
| 50 | 50 | |
| 51 | - include_once(FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/email_action.php'); |
|
| 52 | - include_once(FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/default_actions.php'); |
|
| 51 | + include_once( FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/email_action.php' ); |
|
| 52 | + include_once( FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/default_actions.php' ); |
|
| 53 | 53 | |
| 54 | 54 | foreach ( $action_classes as $action_class ) { |
| 55 | - self::$registered_actions->register($action_class); |
|
| 55 | + self::$registered_actions->register( $action_class ); |
|
| 56 | 56 | } |
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | public static function get_form_actions( $action = 'all' ) { |
| 60 | 60 | $temp_actions = self::$registered_actions; |
| 61 | - if ( empty($temp_actions) ) { |
|
| 61 | + if ( empty( $temp_actions ) ) { |
|
| 62 | 62 | self::actions_init(); |
| 63 | 63 | $temp_actions = self::$registered_actions->actions; |
| 64 | 64 | } else { |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | return $a; |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | - $actions[ $a->id_base ] = $a; |
|
| 75 | + $actions[$a->id_base] = $a; |
|
| 76 | 76 | } |
| 77 | 77 | unset( $temp_actions, $a ); |
| 78 | 78 | |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | arsort( $temp_actions ); |
| 87 | 87 | foreach ( $temp_actions as $type => $a ) { |
| 88 | 88 | if ( ! isset( $a->action_options['active'] ) || empty( $a->action_options['active'] ) ) { |
| 89 | - unset( $actions[ $type ] ); |
|
| 89 | + unset( $actions[$type] ); |
|
| 90 | 90 | if ( count( $actions ) <= $action_limit ) { |
| 91 | 91 | break; |
| 92 | 92 | } |
@@ -118,26 +118,26 @@ discard block |
||
| 118 | 118 | $action_map = array(); |
| 119 | 119 | |
| 120 | 120 | foreach ( $action_controls as $key => $control ) { |
| 121 | - $action_map[ $control->id_base ] = $key; |
|
| 121 | + $action_map[$control->id_base] = $key; |
|
| 122 | 122 | } |
| 123 | 123 | |
| 124 | 124 | foreach ( $form_actions as $action ) { |
| 125 | - if ( ! isset( $action_map[ $action->post_excerpt ] ) ) { |
|
| 125 | + if ( ! isset( $action_map[$action->post_excerpt] ) ) { |
|
| 126 | 126 | // don't try and show settings if action no longer exists |
| 127 | 127 | continue; |
| 128 | 128 | } |
| 129 | 129 | |
| 130 | - self::action_control( $action, $form, $action->ID, $action_controls[ $action_map[ $action->post_excerpt ] ], $values ); |
|
| 130 | + self::action_control( $action, $form, $action->ID, $action_controls[$action_map[$action->post_excerpt]], $values ); |
|
| 131 | 131 | } |
| 132 | 132 | } |
| 133 | 133 | |
| 134 | 134 | public static function action_control( $form_action, $form, $action_key, $action_control, $values ) { |
| 135 | - $action_control->_set($action_key); |
|
| 135 | + $action_control->_set( $action_key ); |
|
| 136 | 136 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/form_action.php' ); |
| 137 | 137 | } |
| 138 | 138 | |
| 139 | 139 | public static function add_form_action() { |
| 140 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 140 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
| 141 | 141 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 142 | 142 | |
| 143 | 143 | global $frm_vars; |
@@ -146,55 +146,55 @@ discard block |
||
| 146 | 146 | $action_type = sanitize_text_field( $_POST['type'] ); |
| 147 | 147 | |
| 148 | 148 | $action_control = self::get_form_actions( $action_type ); |
| 149 | - $action_control->_set($action_key); |
|
| 149 | + $action_control->_set( $action_key ); |
|
| 150 | 150 | |
| 151 | 151 | $form_id = absint( $_POST['form_id'] ); |
| 152 | 152 | |
| 153 | - $form_action = $action_control->prepare_new($form_id); |
|
| 153 | + $form_action = $action_control->prepare_new( $form_id ); |
|
| 154 | 154 | |
| 155 | 155 | $values = array(); |
| 156 | - $form = self::fields_to_values($form_id, $values); |
|
| 156 | + $form = self::fields_to_values( $form_id, $values ); |
|
| 157 | 157 | |
| 158 | 158 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/form_action.php' ); |
| 159 | 159 | wp_die(); |
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | public static function fill_action() { |
| 163 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 163 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
| 164 | 164 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 165 | 165 | |
| 166 | 166 | $action_key = absint( $_POST['action_id'] ); |
| 167 | 167 | $action_type = sanitize_text_field( $_POST['action_type'] ); |
| 168 | 168 | |
| 169 | 169 | $action_control = self::get_form_actions( $action_type ); |
| 170 | - if ( empty($action_control) ) { |
|
| 170 | + if ( empty( $action_control ) ) { |
|
| 171 | 171 | wp_die(); |
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 174 | $form_action = $action_control->get_single_action( $action_key ); |
| 175 | 175 | |
| 176 | 176 | $values = array(); |
| 177 | - $form = self::fields_to_values($form_action->menu_order, $values); |
|
| 177 | + $form = self::fields_to_values( $form_action->menu_order, $values ); |
|
| 178 | 178 | |
| 179 | 179 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/_action_inside.php' ); |
| 180 | 180 | wp_die(); |
| 181 | 181 | } |
| 182 | 182 | |
| 183 | 183 | private static function fields_to_values( $form_id, array &$values ) { |
| 184 | - $form = FrmForm::getOne($form_id); |
|
| 184 | + $form = FrmForm::getOne( $form_id ); |
|
| 185 | 185 | |
| 186 | 186 | $values = array( 'fields' => array(), 'id' => $form->id ); |
| 187 | 187 | |
| 188 | - $fields = FrmField::get_all_for_form($form->id); |
|
| 188 | + $fields = FrmField::get_all_for_form( $form->id ); |
|
| 189 | 189 | foreach ( $fields as $k => $f ) { |
| 190 | 190 | $f = (array) $f; |
| 191 | 191 | $opts = (array) $f['field_options']; |
| 192 | - $f = array_merge($opts, $f); |
|
| 192 | + $f = array_merge( $opts, $f ); |
|
| 193 | 193 | if ( ! isset( $f['post_field'] ) ) { |
| 194 | 194 | $f['post_field'] = ''; |
| 195 | 195 | } |
| 196 | 196 | $values['fields'][] = $f; |
| 197 | - unset($k, $f); |
|
| 197 | + unset( $k, $f ); |
|
| 198 | 198 | } |
| 199 | 199 | |
| 200 | 200 | return $form; |
@@ -209,7 +209,7 @@ discard block |
||
| 209 | 209 | $new_actions = array(); |
| 210 | 210 | |
| 211 | 211 | foreach ( $registered_actions as $registered_action ) { |
| 212 | - $action_ids = $registered_action->update_callback($form_id); |
|
| 212 | + $action_ids = $registered_action->update_callback( $form_id ); |
|
| 213 | 213 | if ( ! empty( $action_ids ) ) { |
| 214 | 214 | $new_actions[] = $action_ids; |
| 215 | 215 | } |
@@ -291,33 +291,33 @@ discard block |
||
| 291 | 291 | } |
| 292 | 292 | |
| 293 | 293 | // store actions so they can be triggered with the correct priority |
| 294 | - $stored_actions[ $action->ID ] = $action; |
|
| 295 | - $action_priority[ $action->ID ] = $link_settings[ $action->post_excerpt ]->action_options['priority']; |
|
| 294 | + $stored_actions[$action->ID] = $action; |
|
| 295 | + $action_priority[$action->ID] = $link_settings[$action->post_excerpt]->action_options['priority']; |
|
| 296 | 296 | |
| 297 | - unset($action); |
|
| 297 | + unset( $action ); |
|
| 298 | 298 | } |
| 299 | 299 | |
| 300 | 300 | if ( ! empty( $stored_actions ) ) { |
| 301 | - asort($action_priority); |
|
| 301 | + asort( $action_priority ); |
|
| 302 | 302 | |
| 303 | 303 | // make sure hooks are loaded |
| 304 | 304 | new FrmNotification(); |
| 305 | 305 | |
| 306 | 306 | foreach ( $action_priority as $action_id => $priority ) { |
| 307 | - $action = $stored_actions[ $action_id ]; |
|
| 307 | + $action = $stored_actions[$action_id]; |
|
| 308 | 308 | do_action( 'frm_trigger_' . $action->post_excerpt . '_action', $action, $entry, $form, $event ); |
| 309 | 309 | do_action( 'frm_trigger_' . $action->post_excerpt . '_' . $event . '_action', $action, $entry, $form ); |
| 310 | 310 | |
| 311 | 311 | // If post is created, get updated $entry object |
| 312 | 312 | if ( $action->post_excerpt == 'wppost' && $event == 'create' ) { |
| 313 | - $entry = FrmEntry::getOne($entry->id, true); |
|
| 313 | + $entry = FrmEntry::getOne( $entry->id, true ); |
|
| 314 | 314 | } |
| 315 | 315 | } |
| 316 | 316 | } |
| 317 | 317 | } |
| 318 | 318 | |
| 319 | 319 | public static function duplicate_form_actions( $form_id, $values, $args = array() ) { |
| 320 | - if ( ! isset($args['old_id']) || empty($args['old_id']) ) { |
|
| 320 | + if ( ! isset( $args['old_id'] ) || empty( $args['old_id'] ) ) { |
|
| 321 | 321 | // continue if we know which actions to copy |
| 322 | 322 | return; |
| 323 | 323 | } |
@@ -351,22 +351,22 @@ discard block |
||
| 351 | 351 | } |
| 352 | 352 | |
| 353 | 353 | public function register( $action_class ) { |
| 354 | - $this->actions[ $action_class ] = new $action_class(); |
|
| 354 | + $this->actions[$action_class] = new $action_class(); |
|
| 355 | 355 | } |
| 356 | 356 | |
| 357 | 357 | public function unregister( $action_class ) { |
| 358 | - if ( isset( $this->actions[ $action_class ] ) ) { |
|
| 359 | - unset($this->actions[ $action_class ]); |
|
| 358 | + if ( isset( $this->actions[$action_class] ) ) { |
|
| 359 | + unset( $this->actions[$action_class] ); |
|
| 360 | 360 | } |
| 361 | 361 | } |
| 362 | 362 | |
| 363 | 363 | public function _register_actions() { |
| 364 | - $keys = array_keys($this->actions); |
|
| 364 | + $keys = array_keys( $this->actions ); |
|
| 365 | 365 | |
| 366 | 366 | foreach ( $keys as $key ) { |
| 367 | 367 | // don't register new action if old action with the same id is already registered |
| 368 | - if ( ! isset( $this->actions[ $key ] ) ) { |
|
| 369 | - $this->actions[ $key ]->_register(); |
|
| 368 | + if ( ! isset( $this->actions[$key] ) ) { |
|
| 369 | + $this->actions[$key]->_register(); |
|
| 370 | 370 | } |
| 371 | 371 | } |
| 372 | 372 | } |
@@ -1,109 +1,109 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | class FrmFormActionsController { |
| 4 | - public static $action_post_type = 'frm_form_actions'; |
|
| 5 | - public static $registered_actions; |
|
| 6 | - |
|
| 7 | - public static function register_post_types() { |
|
| 8 | - register_post_type( self::$action_post_type, array( |
|
| 9 | - 'label' => __( 'Form Actions', 'formidable' ), |
|
| 10 | - 'description' => '', |
|
| 11 | - 'public' => false, |
|
| 12 | - 'show_ui' => false, |
|
| 13 | - 'exclude_from_search' => true, |
|
| 14 | - 'show_in_nav_menus' => false, |
|
| 15 | - 'show_in_menu' => true, |
|
| 16 | - 'capability_type' => 'page', |
|
| 17 | - 'supports' => array( |
|
| 4 | + public static $action_post_type = 'frm_form_actions'; |
|
| 5 | + public static $registered_actions; |
|
| 6 | + |
|
| 7 | + public static function register_post_types() { |
|
| 8 | + register_post_type( self::$action_post_type, array( |
|
| 9 | + 'label' => __( 'Form Actions', 'formidable' ), |
|
| 10 | + 'description' => '', |
|
| 11 | + 'public' => false, |
|
| 12 | + 'show_ui' => false, |
|
| 13 | + 'exclude_from_search' => true, |
|
| 14 | + 'show_in_nav_menus' => false, |
|
| 15 | + 'show_in_menu' => true, |
|
| 16 | + 'capability_type' => 'page', |
|
| 17 | + 'supports' => array( |
|
| 18 | 18 | 'title', 'editor', 'excerpt', 'custom-fields', |
| 19 | 19 | 'page-attributes', |
| 20 | - ), |
|
| 21 | - 'has_archive' => false, |
|
| 22 | - ) ); |
|
| 23 | - |
|
| 24 | - /** |
|
| 25 | - * post_content: json settings |
|
| 26 | - * menu_order: form id |
|
| 27 | - * post_excerpt: action type |
|
| 28 | - */ |
|
| 29 | - |
|
| 30 | - self::actions_init(); |
|
| 31 | - } |
|
| 32 | - |
|
| 33 | - public static function actions_init() { |
|
| 34 | - self::$registered_actions = new Frm_Form_Action_Factory(); |
|
| 35 | - self::register_actions(); |
|
| 36 | - do_action( 'frm_form_actions_init' ); |
|
| 37 | - } |
|
| 38 | - |
|
| 39 | - public static function register_actions() { |
|
| 40 | - $action_classes = apply_filters( 'frm_registered_form_actions', array( |
|
| 41 | - 'email' => 'FrmEmailAction', |
|
| 42 | - 'wppost' => 'FrmDefPostAction', |
|
| 43 | - 'register' => 'FrmDefRegAction', |
|
| 44 | - 'paypal' => 'FrmDefPayPalAction', |
|
| 45 | - //'aweber' => 'FrmDefAweberAction', |
|
| 46 | - 'mailchimp' => 'FrmDefMlcmpAction', |
|
| 47 | - 'twilio' => 'FrmDefTwilioAction', |
|
| 48 | - 'highrise' => 'FrmDefHrsAction', |
|
| 49 | - ) ); |
|
| 50 | - |
|
| 51 | - include_once(FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/email_action.php'); |
|
| 52 | - include_once(FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/default_actions.php'); |
|
| 53 | - |
|
| 54 | - foreach ( $action_classes as $action_class ) { |
|
| 55 | - self::$registered_actions->register($action_class); |
|
| 56 | - } |
|
| 57 | - } |
|
| 20 | + ), |
|
| 21 | + 'has_archive' => false, |
|
| 22 | + ) ); |
|
| 23 | + |
|
| 24 | + /** |
|
| 25 | + * post_content: json settings |
|
| 26 | + * menu_order: form id |
|
| 27 | + * post_excerpt: action type |
|
| 28 | + */ |
|
| 29 | + |
|
| 30 | + self::actions_init(); |
|
| 31 | + } |
|
| 32 | + |
|
| 33 | + public static function actions_init() { |
|
| 34 | + self::$registered_actions = new Frm_Form_Action_Factory(); |
|
| 35 | + self::register_actions(); |
|
| 36 | + do_action( 'frm_form_actions_init' ); |
|
| 37 | + } |
|
| 38 | + |
|
| 39 | + public static function register_actions() { |
|
| 40 | + $action_classes = apply_filters( 'frm_registered_form_actions', array( |
|
| 41 | + 'email' => 'FrmEmailAction', |
|
| 42 | + 'wppost' => 'FrmDefPostAction', |
|
| 43 | + 'register' => 'FrmDefRegAction', |
|
| 44 | + 'paypal' => 'FrmDefPayPalAction', |
|
| 45 | + //'aweber' => 'FrmDefAweberAction', |
|
| 46 | + 'mailchimp' => 'FrmDefMlcmpAction', |
|
| 47 | + 'twilio' => 'FrmDefTwilioAction', |
|
| 48 | + 'highrise' => 'FrmDefHrsAction', |
|
| 49 | + ) ); |
|
| 50 | + |
|
| 51 | + include_once(FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/email_action.php'); |
|
| 52 | + include_once(FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/default_actions.php'); |
|
| 53 | + |
|
| 54 | + foreach ( $action_classes as $action_class ) { |
|
| 55 | + self::$registered_actions->register($action_class); |
|
| 56 | + } |
|
| 57 | + } |
|
| 58 | 58 | |
| 59 | 59 | public static function get_form_actions( $action = 'all' ) { |
| 60 | - $temp_actions = self::$registered_actions; |
|
| 61 | - if ( empty($temp_actions) ) { |
|
| 62 | - self::actions_init(); |
|
| 63 | - $temp_actions = self::$registered_actions->actions; |
|
| 64 | - } else { |
|
| 65 | - $temp_actions = $temp_actions->actions; |
|
| 66 | - } |
|
| 60 | + $temp_actions = self::$registered_actions; |
|
| 61 | + if ( empty($temp_actions) ) { |
|
| 62 | + self::actions_init(); |
|
| 63 | + $temp_actions = self::$registered_actions->actions; |
|
| 64 | + } else { |
|
| 65 | + $temp_actions = $temp_actions->actions; |
|
| 66 | + } |
|
| 67 | 67 | |
| 68 | - $actions = array(); |
|
| 68 | + $actions = array(); |
|
| 69 | 69 | |
| 70 | - foreach ( $temp_actions as $a ) { |
|
| 71 | - if ( 'all' != $action && $a->id_base == $action ) { |
|
| 72 | - return $a; |
|
| 73 | - } |
|
| 70 | + foreach ( $temp_actions as $a ) { |
|
| 71 | + if ( 'all' != $action && $a->id_base == $action ) { |
|
| 72 | + return $a; |
|
| 73 | + } |
|
| 74 | 74 | |
| 75 | 75 | $actions[ $a->id_base ] = $a; |
| 76 | - } |
|
| 77 | - unset( $temp_actions, $a ); |
|
| 78 | - |
|
| 79 | - $action_limit = 10; |
|
| 80 | - if ( count( $actions ) <= $action_limit ) { |
|
| 81 | - return $actions; |
|
| 82 | - } |
|
| 83 | - |
|
| 84 | - // remove the last few inactive icons if there are too many |
|
| 85 | - $temp_actions = $actions; |
|
| 86 | - arsort( $temp_actions ); |
|
| 87 | - foreach ( $temp_actions as $type => $a ) { |
|
| 88 | - if ( ! isset( $a->action_options['active'] ) || empty( $a->action_options['active'] ) ) { |
|
| 76 | + } |
|
| 77 | + unset( $temp_actions, $a ); |
|
| 78 | + |
|
| 79 | + $action_limit = 10; |
|
| 80 | + if ( count( $actions ) <= $action_limit ) { |
|
| 81 | + return $actions; |
|
| 82 | + } |
|
| 83 | + |
|
| 84 | + // remove the last few inactive icons if there are too many |
|
| 85 | + $temp_actions = $actions; |
|
| 86 | + arsort( $temp_actions ); |
|
| 87 | + foreach ( $temp_actions as $type => $a ) { |
|
| 88 | + if ( ! isset( $a->action_options['active'] ) || empty( $a->action_options['active'] ) ) { |
|
| 89 | 89 | unset( $actions[ $type ] ); |
| 90 | - if ( count( $actions ) <= $action_limit ) { |
|
| 91 | - break; |
|
| 92 | - } |
|
| 93 | - } |
|
| 94 | - unset( $type, $a ); |
|
| 95 | - } |
|
| 90 | + if ( count( $actions ) <= $action_limit ) { |
|
| 91 | + break; |
|
| 92 | + } |
|
| 93 | + } |
|
| 94 | + unset( $type, $a ); |
|
| 95 | + } |
|
| 96 | 96 | |
| 97 | - return $actions; |
|
| 98 | - } |
|
| 97 | + return $actions; |
|
| 98 | + } |
|
| 99 | 99 | |
| 100 | 100 | /** |
| 101 | 101 | * @since 2.0 |
| 102 | 102 | */ |
| 103 | - public static function list_actions( $form, $values ) { |
|
| 104 | - if ( empty( $form ) ) { |
|
| 105 | - return; |
|
| 106 | - } |
|
| 103 | + public static function list_actions( $form, $values ) { |
|
| 104 | + if ( empty( $form ) ) { |
|
| 105 | + return; |
|
| 106 | + } |
|
| 107 | 107 | |
| 108 | 108 | /** |
| 109 | 109 | * use this hook to migrate old settings into a new action |
@@ -113,116 +113,116 @@ discard block |
||
| 113 | 113 | |
| 114 | 114 | $form_actions = FrmFormAction::get_action_for_form( $form->id ); |
| 115 | 115 | |
| 116 | - $action_controls = self::get_form_actions(); |
|
| 116 | + $action_controls = self::get_form_actions(); |
|
| 117 | 117 | |
| 118 | - $action_map = array(); |
|
| 118 | + $action_map = array(); |
|
| 119 | 119 | |
| 120 | 120 | foreach ( $action_controls as $key => $control ) { |
| 121 | - $action_map[ $control->id_base ] = $key; |
|
| 122 | - } |
|
| 121 | + $action_map[ $control->id_base ] = $key; |
|
| 122 | + } |
|
| 123 | 123 | |
| 124 | - foreach ( $form_actions as $action ) { |
|
| 125 | - if ( ! isset( $action_map[ $action->post_excerpt ] ) ) { |
|
| 126 | - // don't try and show settings if action no longer exists |
|
| 127 | - continue; |
|
| 128 | - } |
|
| 124 | + foreach ( $form_actions as $action ) { |
|
| 125 | + if ( ! isset( $action_map[ $action->post_excerpt ] ) ) { |
|
| 126 | + // don't try and show settings if action no longer exists |
|
| 127 | + continue; |
|
| 128 | + } |
|
| 129 | 129 | |
| 130 | - self::action_control( $action, $form, $action->ID, $action_controls[ $action_map[ $action->post_excerpt ] ], $values ); |
|
| 131 | - } |
|
| 132 | - } |
|
| 130 | + self::action_control( $action, $form, $action->ID, $action_controls[ $action_map[ $action->post_excerpt ] ], $values ); |
|
| 131 | + } |
|
| 132 | + } |
|
| 133 | 133 | |
| 134 | 134 | public static function action_control( $form_action, $form, $action_key, $action_control, $values ) { |
| 135 | - $action_control->_set($action_key); |
|
| 135 | + $action_control->_set($action_key); |
|
| 136 | 136 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/form_action.php' ); |
| 137 | - } |
|
| 137 | + } |
|
| 138 | 138 | |
| 139 | - public static function add_form_action() { |
|
| 139 | + public static function add_form_action() { |
|
| 140 | 140 | FrmAppHelper::permission_check('frm_edit_forms'); |
| 141 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 141 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 142 | 142 | |
| 143 | - global $frm_vars; |
|
| 143 | + global $frm_vars; |
|
| 144 | 144 | |
| 145 | 145 | $action_key = absint( $_POST['list_id'] ); |
| 146 | - $action_type = sanitize_text_field( $_POST['type'] ); |
|
| 146 | + $action_type = sanitize_text_field( $_POST['type'] ); |
|
| 147 | 147 | |
| 148 | - $action_control = self::get_form_actions( $action_type ); |
|
| 149 | - $action_control->_set($action_key); |
|
| 148 | + $action_control = self::get_form_actions( $action_type ); |
|
| 149 | + $action_control->_set($action_key); |
|
| 150 | 150 | |
| 151 | - $form_id = absint( $_POST['form_id'] ); |
|
| 151 | + $form_id = absint( $_POST['form_id'] ); |
|
| 152 | 152 | |
| 153 | - $form_action = $action_control->prepare_new($form_id); |
|
| 153 | + $form_action = $action_control->prepare_new($form_id); |
|
| 154 | 154 | |
| 155 | - $values = array(); |
|
| 156 | - $form = self::fields_to_values($form_id, $values); |
|
| 155 | + $values = array(); |
|
| 156 | + $form = self::fields_to_values($form_id, $values); |
|
| 157 | 157 | |
| 158 | 158 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/form_action.php' ); |
| 159 | - wp_die(); |
|
| 160 | - } |
|
| 159 | + wp_die(); |
|
| 160 | + } |
|
| 161 | 161 | |
| 162 | - public static function fill_action() { |
|
| 162 | + public static function fill_action() { |
|
| 163 | 163 | FrmAppHelper::permission_check('frm_edit_forms'); |
| 164 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 164 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 165 | 165 | |
| 166 | - $action_key = absint( $_POST['action_id'] ); |
|
| 167 | - $action_type = sanitize_text_field( $_POST['action_type'] ); |
|
| 166 | + $action_key = absint( $_POST['action_id'] ); |
|
| 167 | + $action_type = sanitize_text_field( $_POST['action_type'] ); |
|
| 168 | 168 | |
| 169 | - $action_control = self::get_form_actions( $action_type ); |
|
| 170 | - if ( empty($action_control) ) { |
|
| 171 | - wp_die(); |
|
| 172 | - } |
|
| 169 | + $action_control = self::get_form_actions( $action_type ); |
|
| 170 | + if ( empty($action_control) ) { |
|
| 171 | + wp_die(); |
|
| 172 | + } |
|
| 173 | 173 | |
| 174 | - $form_action = $action_control->get_single_action( $action_key ); |
|
| 174 | + $form_action = $action_control->get_single_action( $action_key ); |
|
| 175 | 175 | |
| 176 | - $values = array(); |
|
| 177 | - $form = self::fields_to_values($form_action->menu_order, $values); |
|
| 176 | + $values = array(); |
|
| 177 | + $form = self::fields_to_values($form_action->menu_order, $values); |
|
| 178 | 178 | |
| 179 | 179 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/_action_inside.php' ); |
| 180 | - wp_die(); |
|
| 181 | - } |
|
| 180 | + wp_die(); |
|
| 181 | + } |
|
| 182 | 182 | |
| 183 | 183 | private static function fields_to_values( $form_id, array &$values ) { |
| 184 | - $form = FrmForm::getOne($form_id); |
|
| 184 | + $form = FrmForm::getOne($form_id); |
|
| 185 | 185 | |
| 186 | 186 | $values = array( 'fields' => array(), 'id' => $form->id ); |
| 187 | 187 | |
| 188 | - $fields = FrmField::get_all_for_form($form->id); |
|
| 189 | - foreach ( $fields as $k => $f ) { |
|
| 190 | - $f = (array) $f; |
|
| 191 | - $opts = (array) $f['field_options']; |
|
| 192 | - $f = array_merge($opts, $f); |
|
| 193 | - if ( ! isset( $f['post_field'] ) ) { |
|
| 194 | - $f['post_field'] = ''; |
|
| 195 | - } |
|
| 196 | - $values['fields'][] = $f; |
|
| 197 | - unset($k, $f); |
|
| 198 | - } |
|
| 199 | - |
|
| 200 | - return $form; |
|
| 201 | - } |
|
| 188 | + $fields = FrmField::get_all_for_form($form->id); |
|
| 189 | + foreach ( $fields as $k => $f ) { |
|
| 190 | + $f = (array) $f; |
|
| 191 | + $opts = (array) $f['field_options']; |
|
| 192 | + $f = array_merge($opts, $f); |
|
| 193 | + if ( ! isset( $f['post_field'] ) ) { |
|
| 194 | + $f['post_field'] = ''; |
|
| 195 | + } |
|
| 196 | + $values['fields'][] = $f; |
|
| 197 | + unset($k, $f); |
|
| 198 | + } |
|
| 199 | + |
|
| 200 | + return $form; |
|
| 201 | + } |
|
| 202 | 202 | |
| 203 | 203 | public static function update_settings( $form_id ) { |
| 204 | - global $wpdb; |
|
| 204 | + global $wpdb; |
|
| 205 | 205 | |
| 206 | - $registered_actions = self::$registered_actions->actions; |
|
| 206 | + $registered_actions = self::$registered_actions->actions; |
|
| 207 | 207 | |
| 208 | 208 | $old_actions = FrmDb::get_col( $wpdb->posts, array( 'post_type' => self::$action_post_type, 'menu_order' => $form_id ), 'ID' ); |
| 209 | - $new_actions = array(); |
|
| 209 | + $new_actions = array(); |
|
| 210 | 210 | |
| 211 | - foreach ( $registered_actions as $registered_action ) { |
|
| 212 | - $action_ids = $registered_action->update_callback($form_id); |
|
| 213 | - if ( ! empty( $action_ids ) ) { |
|
| 214 | - $new_actions[] = $action_ids; |
|
| 215 | - } |
|
| 216 | - } |
|
| 211 | + foreach ( $registered_actions as $registered_action ) { |
|
| 212 | + $action_ids = $registered_action->update_callback($form_id); |
|
| 213 | + if ( ! empty( $action_ids ) ) { |
|
| 214 | + $new_actions[] = $action_ids; |
|
| 215 | + } |
|
| 216 | + } |
|
| 217 | 217 | |
| 218 | - //Only use array_merge if there are new actions |
|
| 219 | - if ( ! empty( $new_actions ) ) { |
|
| 220 | - $new_actions = call_user_func_array( 'array_merge', $new_actions ); |
|
| 221 | - } |
|
| 222 | - $old_actions = array_diff( $old_actions, $new_actions ); |
|
| 218 | + //Only use array_merge if there are new actions |
|
| 219 | + if ( ! empty( $new_actions ) ) { |
|
| 220 | + $new_actions = call_user_func_array( 'array_merge', $new_actions ); |
|
| 221 | + } |
|
| 222 | + $old_actions = array_diff( $old_actions, $new_actions ); |
|
| 223 | 223 | |
| 224 | 224 | self::delete_missing_actions( $old_actions ); |
| 225 | - } |
|
| 225 | + } |
|
| 226 | 226 | |
| 227 | 227 | public static function delete_missing_actions( $old_actions ) { |
| 228 | 228 | if ( ! empty( $old_actions ) ) { |
@@ -242,36 +242,36 @@ discard block |
||
| 242 | 242 | self::trigger_actions( $event, $form_id, $entry_id, 'all', $args ); |
| 243 | 243 | } |
| 244 | 244 | |
| 245 | - /** |
|
| 246 | - * @param string $event |
|
| 247 | - */ |
|
| 245 | + /** |
|
| 246 | + * @param string $event |
|
| 247 | + */ |
|
| 248 | 248 | public static function trigger_actions( $event, $form, $entry, $type = 'all', $args = array() ) { |
| 249 | 249 | $form_actions = FrmFormAction::get_action_for_form( ( is_object( $form ) ? $form->id : $form ), $type ); |
| 250 | 250 | |
| 251 | 251 | if ( empty( $form_actions ) ) { |
| 252 | - return; |
|
| 253 | - } |
|
| 252 | + return; |
|
| 253 | + } |
|
| 254 | 254 | |
| 255 | 255 | FrmForm::maybe_get_form( $form ); |
| 256 | 256 | |
| 257 | - $link_settings = self::get_form_actions( $type ); |
|
| 258 | - if ( 'all' != $type ) { |
|
| 259 | - $link_settings = array( $type => $link_settings ); |
|
| 260 | - } |
|
| 257 | + $link_settings = self::get_form_actions( $type ); |
|
| 258 | + if ( 'all' != $type ) { |
|
| 259 | + $link_settings = array( $type => $link_settings ); |
|
| 260 | + } |
|
| 261 | 261 | |
| 262 | - $stored_actions = $action_priority = array(); |
|
| 262 | + $stored_actions = $action_priority = array(); |
|
| 263 | 263 | |
| 264 | 264 | $importing = in_array( $event, array( 'create', 'update' ) ) && defined( 'WP_IMPORTING' ) && WP_IMPORTING; |
| 265 | 265 | |
| 266 | - foreach ( $form_actions as $action ) { |
|
| 266 | + foreach ( $form_actions as $action ) { |
|
| 267 | 267 | $trigger_on_import = $importing && in_array( 'import', $action->post_content['event'] ); |
| 268 | 268 | if ( ! in_array( $event, $action->post_content['event'] ) && ! $trigger_on_import ) { |
| 269 | - continue; |
|
| 270 | - } |
|
| 269 | + continue; |
|
| 270 | + } |
|
| 271 | 271 | |
| 272 | - if ( ! is_object( $entry ) ) { |
|
| 273 | - $entry = FrmEntry::getOne( $entry, true ); |
|
| 274 | - } |
|
| 272 | + if ( ! is_object( $entry ) ) { |
|
| 273 | + $entry = FrmEntry::getOne( $entry, true ); |
|
| 274 | + } |
|
| 275 | 275 | |
| 276 | 276 | if ( empty( $entry ) || ( $entry->is_draft && $event != 'draft' ) ) { |
| 277 | 277 | continue; |
@@ -285,64 +285,64 @@ discard block |
||
| 285 | 285 | if ( ! $trigger_children ) { |
| 286 | 286 | continue; |
| 287 | 287 | } |
| 288 | - } |
|
| 288 | + } |
|
| 289 | 289 | |
| 290 | - // check conditional logic |
|
| 290 | + // check conditional logic |
|
| 291 | 291 | $stop = FrmFormAction::action_conditions_met( $action, $entry ); |
| 292 | - if ( $stop ) { |
|
| 293 | - continue; |
|
| 294 | - } |
|
| 292 | + if ( $stop ) { |
|
| 293 | + continue; |
|
| 294 | + } |
|
| 295 | 295 | |
| 296 | - // store actions so they can be triggered with the correct priority |
|
| 297 | - $stored_actions[ $action->ID ] = $action; |
|
| 298 | - $action_priority[ $action->ID ] = $link_settings[ $action->post_excerpt ]->action_options['priority']; |
|
| 296 | + // store actions so they can be triggered with the correct priority |
|
| 297 | + $stored_actions[ $action->ID ] = $action; |
|
| 298 | + $action_priority[ $action->ID ] = $link_settings[ $action->post_excerpt ]->action_options['priority']; |
|
| 299 | 299 | |
| 300 | - unset($action); |
|
| 301 | - } |
|
| 300 | + unset($action); |
|
| 301 | + } |
|
| 302 | 302 | |
| 303 | - if ( ! empty( $stored_actions ) ) { |
|
| 304 | - asort($action_priority); |
|
| 303 | + if ( ! empty( $stored_actions ) ) { |
|
| 304 | + asort($action_priority); |
|
| 305 | 305 | |
| 306 | - // make sure hooks are loaded |
|
| 307 | - new FrmNotification(); |
|
| 306 | + // make sure hooks are loaded |
|
| 307 | + new FrmNotification(); |
|
| 308 | 308 | |
| 309 | - foreach ( $action_priority as $action_id => $priority ) { |
|
| 310 | - $action = $stored_actions[ $action_id ]; |
|
| 309 | + foreach ( $action_priority as $action_id => $priority ) { |
|
| 310 | + $action = $stored_actions[ $action_id ]; |
|
| 311 | 311 | do_action( 'frm_trigger_' . $action->post_excerpt . '_action', $action, $entry, $form, $event ); |
| 312 | 312 | do_action( 'frm_trigger_' . $action->post_excerpt . '_' . $event . '_action', $action, $entry, $form ); |
| 313 | 313 | |
| 314 | - // If post is created, get updated $entry object |
|
| 315 | - if ( $action->post_excerpt == 'wppost' && $event == 'create' ) { |
|
| 316 | - $entry = FrmEntry::getOne($entry->id, true); |
|
| 317 | - } |
|
| 318 | - } |
|
| 319 | - } |
|
| 320 | - } |
|
| 314 | + // If post is created, get updated $entry object |
|
| 315 | + if ( $action->post_excerpt == 'wppost' && $event == 'create' ) { |
|
| 316 | + $entry = FrmEntry::getOne($entry->id, true); |
|
| 317 | + } |
|
| 318 | + } |
|
| 319 | + } |
|
| 320 | + } |
|
| 321 | 321 | |
| 322 | 322 | public static function duplicate_form_actions( $form_id, $values, $args = array() ) { |
| 323 | - if ( ! isset($args['old_id']) || empty($args['old_id']) ) { |
|
| 324 | - // continue if we know which actions to copy |
|
| 325 | - return; |
|
| 326 | - } |
|
| 323 | + if ( ! isset($args['old_id']) || empty($args['old_id']) ) { |
|
| 324 | + // continue if we know which actions to copy |
|
| 325 | + return; |
|
| 326 | + } |
|
| 327 | 327 | |
| 328 | - $action_controls = self::get_form_actions( ); |
|
| 328 | + $action_controls = self::get_form_actions( ); |
|
| 329 | 329 | |
| 330 | - foreach ( $action_controls as $action_control ) { |
|
| 331 | - $action_control->duplicate_form_actions( $form_id, $args['old_id'] ); |
|
| 332 | - unset( $action_control ); |
|
| 333 | - } |
|
| 334 | - } |
|
| 330 | + foreach ( $action_controls as $action_control ) { |
|
| 331 | + $action_control->duplicate_form_actions( $form_id, $args['old_id'] ); |
|
| 332 | + unset( $action_control ); |
|
| 333 | + } |
|
| 334 | + } |
|
| 335 | 335 | |
| 336 | - public static function limit_by_type( $where ) { |
|
| 337 | - global $frm_vars, $wpdb; |
|
| 336 | + public static function limit_by_type( $where ) { |
|
| 337 | + global $frm_vars, $wpdb; |
|
| 338 | 338 | |
| 339 | - if ( ! isset( $frm_vars['action_type'] ) ) { |
|
| 340 | - return $where; |
|
| 341 | - } |
|
| 339 | + if ( ! isset( $frm_vars['action_type'] ) ) { |
|
| 340 | + return $where; |
|
| 341 | + } |
|
| 342 | 342 | |
| 343 | - $where .= $wpdb->prepare( ' AND post_excerpt = %s ', $frm_vars['action_type'] ); |
|
| 344 | - return $where; |
|
| 345 | - } |
|
| 343 | + $where .= $wpdb->prepare( ' AND post_excerpt = %s ', $frm_vars['action_type'] ); |
|
| 344 | + return $where; |
|
| 345 | + } |
|
| 346 | 346 | } |
| 347 | 347 | |
| 348 | 348 | |
@@ -369,7 +369,7 @@ discard block |
||
| 369 | 369 | foreach ( $keys as $key ) { |
| 370 | 370 | // don't register new action if old action with the same id is already registered |
| 371 | 371 | if ( ! isset( $this->actions[ $key ] ) ) { |
| 372 | - $this->actions[ $key ]->_register(); |
|
| 372 | + $this->actions[ $key ]->_register(); |
|
| 373 | 373 | } |
| 374 | 374 | } |
| 375 | 375 | } |
@@ -23,41 +23,41 @@ |
||
| 23 | 23 | |
| 24 | 24 | global $frm_vars; |
| 25 | 25 | $frm_vars = array( |
| 26 | - 'load_css' => false, 'forms_loaded' => array(), |
|
| 27 | - 'created_entries' => array(), |
|
| 28 | - 'pro_is_authorized' => false, |
|
| 26 | + 'load_css' => false, 'forms_loaded' => array(), |
|
| 27 | + 'created_entries' => array(), |
|
| 28 | + 'pro_is_authorized' => false, |
|
| 29 | 29 | ); |
| 30 | 30 | |
| 31 | 31 | function frm_forms_autoloader( $class_name ) { |
| 32 | - // Only load Frm classes here |
|
| 32 | + // Only load Frm classes here |
|
| 33 | 33 | if ( ! preg_match( '/^Frm.+$/', $class_name ) ) { |
| 34 | - return; |
|
| 35 | - } |
|
| 34 | + return; |
|
| 35 | + } |
|
| 36 | 36 | |
| 37 | - $filepath = dirname(__FILE__); |
|
| 37 | + $filepath = dirname(__FILE__); |
|
| 38 | 38 | if ( preg_match( '/^FrmPro.+$/', $class_name ) || 'FrmUpdatesController' == $class_name ) { |
| 39 | - $filepath .= '/pro'; |
|
| 40 | - } |
|
| 41 | - $filepath .= '/classes'; |
|
| 39 | + $filepath .= '/pro'; |
|
| 40 | + } |
|
| 41 | + $filepath .= '/classes'; |
|
| 42 | 42 | |
| 43 | 43 | if ( preg_match( '/^.+Helper$/', $class_name ) ) { |
| 44 | - $filepath .= '/helpers/'; |
|
| 44 | + $filepath .= '/helpers/'; |
|
| 45 | 45 | } else if ( preg_match( '/^.+Controller$/', $class_name ) ) { |
| 46 | - $filepath .= '/controllers/'; |
|
| 47 | - } else { |
|
| 48 | - $filepath .= '/models/'; |
|
| 49 | - } |
|
| 46 | + $filepath .= '/controllers/'; |
|
| 47 | + } else { |
|
| 48 | + $filepath .= '/models/'; |
|
| 49 | + } |
|
| 50 | 50 | |
| 51 | 51 | $filepath .= $class_name . '.php'; |
| 52 | 52 | |
| 53 | - if ( file_exists($filepath) ) { |
|
| 54 | - include($filepath); |
|
| 55 | - } |
|
| 53 | + if ( file_exists($filepath) ) { |
|
| 54 | + include($filepath); |
|
| 55 | + } |
|
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | // if __autoload is active, put it on the spl_autoload stack |
| 59 | 59 | if ( is_array(spl_autoload_functions()) && in_array( '__autoload', spl_autoload_functions()) ) { |
| 60 | - spl_autoload_register('__autoload'); |
|
| 60 | + spl_autoload_register('__autoload'); |
|
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | // Add the autoloader |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | return; |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | - $filepath = dirname(__FILE__); |
|
| 37 | + $filepath = dirname( __FILE__ ); |
|
| 38 | 38 | if ( preg_match( '/^FrmPro.+$/', $class_name ) || 'FrmUpdatesController' == $class_name ) { |
| 39 | 39 | $filepath .= '/pro'; |
| 40 | 40 | } |
@@ -50,25 +50,25 @@ discard block |
||
| 50 | 50 | |
| 51 | 51 | $filepath .= $class_name . '.php'; |
| 52 | 52 | |
| 53 | - if ( file_exists($filepath) ) { |
|
| 54 | - include($filepath); |
|
| 53 | + if ( file_exists( $filepath ) ) { |
|
| 54 | + include( $filepath ); |
|
| 55 | 55 | } |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | // if __autoload is active, put it on the spl_autoload stack |
| 59 | -if ( is_array(spl_autoload_functions()) && in_array( '__autoload', spl_autoload_functions()) ) { |
|
| 60 | - spl_autoload_register('__autoload'); |
|
| 59 | +if ( is_array( spl_autoload_functions() ) && in_array( '__autoload', spl_autoload_functions() ) ) { |
|
| 60 | + spl_autoload_register( '__autoload' ); |
|
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | // Add the autoloader |
| 64 | -spl_autoload_register('frm_forms_autoloader'); |
|
| 64 | +spl_autoload_register( 'frm_forms_autoloader' ); |
|
| 65 | 65 | |
| 66 | -$frm_path = dirname(__FILE__); |
|
| 67 | -if ( file_exists($frm_path . '/pro/formidable-pro.php') ) { |
|
| 66 | +$frm_path = dirname( __FILE__ ); |
|
| 67 | +if ( file_exists( $frm_path . '/pro/formidable-pro.php' ) ) { |
|
| 68 | 68 | include( $frm_path . '/pro/formidable-pro.php' ); |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | FrmHooksController::trigger_load_hook(); |
| 72 | 72 | |
| 73 | 73 | include_once( $frm_path . '/deprecated.php' ); |
| 74 | -unset($frm_path); |
|
| 74 | +unset( $frm_path ); |
|
@@ -1,22 +1,22 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | if ( ! is_array($field['options']) ) { |
| 3 | - return; |
|
| 3 | + return; |
|
| 4 | 4 | } |
| 5 | 5 | |
| 6 | 6 | foreach ( $field['options'] as $opt_key => $opt ) { |
| 7 | - $field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field); |
|
| 8 | - $opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field); |
|
| 7 | + $field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field); |
|
| 8 | + $opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field); |
|
| 9 | 9 | |
| 10 | - // Get string for Other text field, if needed |
|
| 10 | + // Get string for Other text field, if needed |
|
| 11 | 11 | $other_val = FrmFieldsHelper::get_other_val( compact( 'opt_key', 'field' ) ); |
| 12 | 12 | |
| 13 | - $checked = ( $other_val || isset($field['value']) && (( ! is_array($field['value']) && $field['value'] == $field_val ) || (is_array($field['value']) && in_array($field_val, $field['value']) ) ) ) ? ' checked="checked"':''; |
|
| 13 | + $checked = ( $other_val || isset($field['value']) && (( ! is_array($field['value']) && $field['value'] == $field_val ) || (is_array($field['value']) && in_array($field_val, $field['value']) ) ) ) ? ' checked="checked"':''; |
|
| 14 | 14 | |
| 15 | 15 | if ( FrmFieldsHelper::is_other_opt( $opt_key ) ) { |
| 16 | 16 | include( FrmAppHelper::plugin_path() . '/pro/classes/views/frmpro-fields/other-option.php' ); |
| 17 | - } else { |
|
| 17 | + } else { |
|
| 18 | 18 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/single-option.php' ); |
| 19 | - } |
|
| 19 | + } |
|
| 20 | 20 | |
| 21 | - unset($checked, $other_val); |
|
| 21 | + unset($checked, $other_val); |
|
| 22 | 22 | } |
@@ -1,16 +1,16 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if ( ! is_array($field['options']) ) { |
|
| 2 | +if ( ! is_array( $field['options'] ) ) { |
|
| 3 | 3 | return; |
| 4 | 4 | } |
| 5 | 5 | |
| 6 | 6 | foreach ( $field['options'] as $opt_key => $opt ) { |
| 7 | - $field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field); |
|
| 8 | - $opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field); |
|
| 7 | + $field_val = apply_filters( 'frm_field_value_saved', $opt, $opt_key, $field ); |
|
| 8 | + $opt = apply_filters( 'frm_field_label_seen', $opt, $opt_key, $field ); |
|
| 9 | 9 | |
| 10 | 10 | // Get string for Other text field, if needed |
| 11 | 11 | $other_val = FrmFieldsHelper::get_other_val( compact( 'opt_key', 'field' ) ); |
| 12 | 12 | |
| 13 | - $checked = ( $other_val || isset($field['value']) && (( ! is_array($field['value']) && $field['value'] == $field_val ) || (is_array($field['value']) && in_array($field_val, $field['value']) ) ) ) ? ' checked="checked"':''; |
|
| 13 | + $checked = ( $other_val || isset( $field['value'] ) && ( ( ! is_array( $field['value'] ) && $field['value'] == $field_val ) || ( is_array( $field['value'] ) && in_array( $field_val, $field['value'] ) ) ) ) ? ' checked="checked"' : ''; |
|
| 14 | 14 | |
| 15 | 15 | if ( FrmFieldsHelper::is_other_opt( $opt_key ) ) { |
| 16 | 16 | include( FrmAppHelper::plugin_path() . '/pro/classes/views/frmpro-fields/other-option.php' ); |
@@ -18,5 +18,5 @@ discard block |
||
| 18 | 18 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/single-option.php' ); |
| 19 | 19 | } |
| 20 | 20 | |
| 21 | - unset($checked, $other_val); |
|
| 21 | + unset( $checked, $other_val ); |
|
| 22 | 22 | } |
@@ -3,38 +3,38 @@ discard block |
||
| 3 | 3 | <?php } else if ( $field['type'] == 'textarea' ) { ?> |
| 4 | 4 | <textarea name="<?php echo esc_attr( $field_name ) ?>" <?php |
| 5 | 5 | echo ( FrmField::is_option_true( $field, 'size' ) ) ? esc_attr( 'style="width:'. $field['size'] . ( is_numeric( $field['size'] ) ? 'px' : '') . ';"' ) : ''; |
| 6 | - ?> rows="<?php echo esc_attr( $field['max'] ); ?>" id="<?php echo esc_attr( $html_id ) ?>" class="dyn_default_value"><?php echo FrmAppHelper::esc_textarea(force_balance_tags($field['default_value'])); ?></textarea> |
|
| 6 | + ?> rows="<?php echo esc_attr( $field['max'] ); ?>" id="<?php echo esc_attr( $html_id ) ?>" class="dyn_default_value"><?php echo FrmAppHelper::esc_textarea(force_balance_tags($field['default_value'])); ?></textarea> |
|
| 7 | 7 | |
| 8 | 8 | <?php |
| 9 | 9 | |
| 10 | 10 | } else if ( $field['type'] == 'radio' || $field['type'] == 'checkbox' ) { |
| 11 | - $field['default_value'] = maybe_unserialize($field['default_value']); |
|
| 12 | - if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) { |
|
| 11 | + $field['default_value'] = maybe_unserialize($field['default_value']); |
|
| 12 | + if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) { |
|
| 13 | 13 | do_action( 'frm_after_checkbox', array( 'field' => $field, 'field_name' => $field_name, 'type' => $field['type'] ) ); |
| 14 | - } else { |
|
| 15 | - do_action('frm_add_multiple_opts_labels', $field); ?> |
|
| 14 | + } else { |
|
| 15 | + do_action('frm_add_multiple_opts_labels', $field); ?> |
|
| 16 | 16 | <ul id="frm_field_<?php echo esc_attr( $field['id'] ) ?>_opts" class="frm_sortable_field_opts frm_clear<?php echo (count($field['options']) > 10) ? ' frm_field_opts_list' : ''; ?>"> |
| 17 | 17 | <?php include( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/radio.php' ); ?> |
| 18 | 18 | </ul> |
| 19 | 19 | <?php |
| 20 | - } |
|
| 20 | + } |
|
| 21 | 21 | } else if ( $field['type'] == 'select' ) { |
| 22 | - if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) { |
|
| 22 | + if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) { |
|
| 23 | 23 | echo FrmFieldsHelper::dropdown_categories( array( 'name' => $field_name, 'field' => $field ) ); |
| 24 | - } else { ?> |
|
| 24 | + } else { ?> |
|
| 25 | 25 | <select name="<?php echo esc_attr( $field_name ) . ( FrmField::is_option_true( $field, 'multiple' ) ? '[]' : '' ); ?>" <?php |
| 26 | 26 | echo FrmField::is_option_true( $field, 'size' ) ? 'class="auto_width"' : ''; |
| 27 | 27 | echo FrmField::is_option_true( $field, 'multiple' ) ? ' multiple="multiple"' : ''; ?> > |
| 28 | 28 | <?php foreach ( $field['options'] as $opt_key => $opt ) { |
| 29 | - $field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field); |
|
| 30 | - $opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field); |
|
| 29 | + $field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field); |
|
| 30 | + $opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field); |
|
| 31 | 31 | $selected = ( $field['default_value'] == $field_val || FrmFieldsHelper::get_other_val( array( 'opt_key', 'field' ) ) ) ? ' selected="selected"' : ''; ?> |
| 32 | 32 | <option value="<?php echo esc_attr( $field_val ) ?>"<?php echo $selected ?>><?php echo esc_html( $opt ) ?> </option> |
| 33 | 33 | <?php } ?> |
| 34 | 34 | </select> |
| 35 | 35 | <?php } |
| 36 | 36 | |
| 37 | - if ( $display['default_blank'] ) { ?> |
|
| 37 | + if ( $display['default_blank'] ) { ?> |
|
| 38 | 38 | <span id="frm_clear_on_focus_<?php echo esc_attr( $field['id'] ) ?>" class="frm_clear_on_focus frm-show-click"> |
| 39 | 39 | <?php FrmFieldsHelper::show_default_blank_js( $field['default_blank'] ); ?> |
| 40 | 40 | </span> |
@@ -50,18 +50,18 @@ discard block |
||
| 50 | 50 | <?php FrmFieldsHelper::show_single_option($field); ?> |
| 51 | 51 | </ul> |
| 52 | 52 | <?php |
| 53 | - } ?> |
|
| 53 | + } ?> |
|
| 54 | 54 | </div> |
| 55 | 55 | <?php |
| 56 | 56 | } else if ( $field['type'] == 'captcha' ) { |
| 57 | 57 | if ( empty($frm_settings->pubkey) ) { ?> |
| 58 | 58 | <div class="howto frm_no_captcha_text"><?php printf(__( 'Your captcha will not appear on your form until you %1$sset up%2$s the Site and Private Keys', 'formidable' ), '<a href="?page=formidable-settings">', '</a>') ?></div> |
| 59 | 59 | <?php |
| 60 | - } ?> |
|
| 60 | + } ?> |
|
| 61 | 61 | <img src="<?php echo esc_url( FrmAppHelper::plugin_url() . '/images/recaptcha.png' ) ?>" class="recaptcha_placeholder" alt="reCaptcha"/> |
| 62 | 62 | <input type="hidden" name="<?php echo esc_attr( $field_name ) ?>" value="1" /> |
| 63 | 63 | <?php |
| 64 | 64 | } else { |
| 65 | - do_action( 'frm_display_added_fields', $field ); |
|
| 65 | + do_action( 'frm_display_added_fields', $field ); |
|
| 66 | 66 | do_action( 'frm_display_added_' . $field['type'] . '_field', $field ); |
| 67 | 67 | } |
@@ -1,33 +1,33 @@ discard block |
||
| 1 | 1 | <?php if ( in_array( $display['type'], array( 'text', 'website', 'email', 'url' ) ) ) { ?> |
| 2 | - <input type="text" name="<?php echo esc_attr( $field_name ) ?>" id="<?php echo esc_attr( $html_id ) ?>" value="<?php echo esc_attr( $field['default_value'] ); ?>" <?php echo ( FrmField::is_option_true( $field, 'size' ) ) ? esc_attr( 'style="width:' . $field['size'] . ( is_numeric( $field['size'] ) ? 'px' : '') . ';"' ) : ''; ?> class="dyn_default_value" /> |
|
| 2 | + <input type="text" name="<?php echo esc_attr( $field_name ) ?>" id="<?php echo esc_attr( $html_id ) ?>" value="<?php echo esc_attr( $field['default_value'] ); ?>" <?php echo ( FrmField::is_option_true( $field, 'size' ) ) ? esc_attr( 'style="width:' . $field['size'] . ( is_numeric( $field['size'] ) ? 'px' : '' ) . ';"' ) : ''; ?> class="dyn_default_value" /> |
|
| 3 | 3 | <?php } else if ( $field['type'] == 'textarea' ) { ?> |
| 4 | 4 | <textarea name="<?php echo esc_attr( $field_name ) ?>" <?php |
| 5 | 5 | echo ( FrmField::is_option_true( $field, 'size' ) ) ? esc_attr( 'style="width:' . $field['size'] . ( is_numeric( $field['size'] ) ? 'px' : '' ) . ';"' ) : ''; |
| 6 | - ?> rows="<?php echo esc_attr( $field['max'] ); ?>" id="<?php echo esc_attr( $html_id ) ?>" class="dyn_default_value"><?php echo FrmAppHelper::esc_textarea(force_balance_tags($field['default_value'])); ?></textarea> |
|
| 6 | + ?> rows="<?php echo esc_attr( $field['max'] ); ?>" id="<?php echo esc_attr( $html_id ) ?>" class="dyn_default_value"><?php echo FrmAppHelper::esc_textarea( force_balance_tags( $field['default_value'] ) ); ?></textarea> |
|
| 7 | 7 | |
| 8 | 8 | <?php |
| 9 | 9 | |
| 10 | 10 | } else if ( $field['type'] == 'radio' || $field['type'] == 'checkbox' ) { |
| 11 | - $field['default_value'] = maybe_unserialize($field['default_value']); |
|
| 12 | - if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) { |
|
| 11 | + $field['default_value'] = maybe_unserialize( $field['default_value'] ); |
|
| 12 | + if ( isset( $field['post_field'] ) && $field['post_field'] == 'post_category' ) { |
|
| 13 | 13 | do_action( 'frm_after_checkbox', array( 'field' => $field, 'field_name' => $field_name, 'type' => $field['type'] ) ); |
| 14 | 14 | } else { |
| 15 | - do_action('frm_add_multiple_opts_labels', $field); ?> |
|
| 16 | - <ul id="frm_field_<?php echo esc_attr( $field['id'] ) ?>_opts" class="frm_sortable_field_opts frm_clear<?php echo (count($field['options']) > 10) ? ' frm_field_opts_list' : ''; ?>"> |
|
| 15 | + do_action( 'frm_add_multiple_opts_labels', $field ); ?> |
|
| 16 | + <ul id="frm_field_<?php echo esc_attr( $field['id'] ) ?>_opts" class="frm_sortable_field_opts frm_clear<?php echo ( count( $field['options'] ) > 10 ) ? ' frm_field_opts_list' : ''; ?>"> |
|
| 17 | 17 | <?php include( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/radio.php' ); ?> |
| 18 | 18 | </ul> |
| 19 | 19 | <?php |
| 20 | 20 | } |
| 21 | 21 | } else if ( $field['type'] == 'select' ) { |
| 22 | - if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) { |
|
| 22 | + if ( isset( $field['post_field'] ) && $field['post_field'] == 'post_category' ) { |
|
| 23 | 23 | echo FrmFieldsHelper::dropdown_categories( array( 'name' => $field_name, 'field' => $field ) ); |
| 24 | 24 | } else { ?> |
| 25 | 25 | <select name="<?php echo esc_attr( $field_name ) . ( FrmField::is_option_true( $field, 'multiple' ) ? '[]' : '' ); ?>" <?php |
| 26 | 26 | echo FrmField::is_option_true( $field, 'size' ) ? 'class="auto_width"' : ''; |
| 27 | 27 | echo FrmField::is_option_true( $field, 'multiple' ) ? ' multiple="multiple"' : ''; ?> > |
| 28 | 28 | <?php foreach ( $field['options'] as $opt_key => $opt ) { |
| 29 | - $field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field); |
|
| 30 | - $opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field); |
|
| 29 | + $field_val = apply_filters( 'frm_field_value_saved', $opt, $opt_key, $field ); |
|
| 30 | + $opt = apply_filters( 'frm_field_label_seen', $opt, $opt_key, $field ); |
|
| 31 | 31 | $selected = ( $field['default_value'] == $field_val || FrmFieldsHelper::get_other_val( array( 'opt_key', 'field' ) ) ) ? ' selected="selected"' : ''; ?> |
| 32 | 32 | <option value="<?php echo esc_attr( $field_val ) ?>"<?php echo $selected ?>><?php echo esc_html( $opt ) ?> </option> |
| 33 | 33 | <?php } ?> |
@@ -45,17 +45,17 @@ discard block |
||
| 45 | 45 | <?php |
| 46 | 46 | |
| 47 | 47 | if ( ! isset( $field['post_field'] ) || ! in_array( $field['post_field'], array( 'post_category' ) ) ) { ?> |
| 48 | - <?php do_action('frm_add_multiple_opts_labels', $field); ?> |
|
| 49 | - <ul id="frm_field_<?php echo esc_attr( $field['id'] ) ?>_opts" class="frm_sortable_field_opts<?php echo ( count($field['options']) > 10 ) ? ' frm_field_opts_list' : ''; ?>"> |
|
| 50 | - <?php FrmFieldsHelper::show_single_option($field); ?> |
|
| 48 | + <?php do_action( 'frm_add_multiple_opts_labels', $field ); ?> |
|
| 49 | + <ul id="frm_field_<?php echo esc_attr( $field['id'] ) ?>_opts" class="frm_sortable_field_opts<?php echo ( count( $field['options'] ) > 10 ) ? ' frm_field_opts_list' : ''; ?>"> |
|
| 50 | + <?php FrmFieldsHelper::show_single_option( $field ); ?> |
|
| 51 | 51 | </ul> |
| 52 | 52 | <?php |
| 53 | 53 | } ?> |
| 54 | 54 | </div> |
| 55 | 55 | <?php |
| 56 | 56 | } else if ( $field['type'] == 'captcha' ) { |
| 57 | - if ( empty($frm_settings->pubkey) ) { ?> |
|
| 58 | - <div class="howto frm_no_captcha_text"><?php printf(__( 'Your captcha will not appear on your form until you %1$sset up%2$s the Site and Secret Keys', 'formidable' ), '<a href="?page=formidable-settings">', '</a>') ?></div> |
|
| 57 | + if ( empty( $frm_settings->pubkey ) ) { ?> |
|
| 58 | + <div class="howto frm_no_captcha_text"><?php printf( __( 'Your captcha will not appear on your form until you %1$sset up%2$s the Site and Secret Keys', 'formidable' ), '<a href="?page=formidable-settings">', '</a>' ) ?></div> |
|
| 59 | 59 | <?php |
| 60 | 60 | } ?> |
| 61 | 61 | <img src="<?php echo esc_url( FrmAppHelper::plugin_url() . '/images/recaptcha.png' ) ?>" class="recaptcha_placeholder" alt="reCaptcha"/> |
@@ -4,18 +4,18 @@ discard block |
||
| 4 | 4 | <meta charset="<?php bloginfo( 'charset' ); ?>" /> |
| 5 | 5 | <title><?php bloginfo('name'); ?></title> |
| 6 | 6 | <?php |
| 7 | - wp_admin_css( 'global' ); |
|
| 8 | - wp_admin_css(); |
|
| 9 | - wp_admin_css( 'colors' ); |
|
| 10 | - wp_admin_css( 'ie' ); |
|
| 7 | + wp_admin_css( 'global' ); |
|
| 8 | + wp_admin_css(); |
|
| 9 | + wp_admin_css( 'colors' ); |
|
| 10 | + wp_admin_css( 'ie' ); |
|
| 11 | 11 | if ( is_multisite() ) { |
| 12 | - wp_admin_css( 'ms' ); |
|
| 12 | + wp_admin_css( 'ms' ); |
|
| 13 | 13 | } |
| 14 | 14 | |
| 15 | - do_action('admin_print_styles'); |
|
| 16 | - do_action('admin_print_scripts'); |
|
| 15 | + do_action('admin_print_styles'); |
|
| 16 | + do_action('admin_print_scripts'); |
|
| 17 | 17 | |
| 18 | - ?> |
|
| 18 | + ?> |
|
| 19 | 19 | </head> |
| 20 | 20 | <body class="wp-admin no-js wp-core-ui frm_field_opts_popup <?php echo esc_attr( apply_filters( 'admin_body_class', '' ) . ' ' . $admin_body_class ); ?>"> |
| 21 | 21 | <div class="frm_med_padding"> |
@@ -29,21 +29,21 @@ discard block |
||
| 29 | 29 | <?php |
| 30 | 30 | $other_array = array(); |
| 31 | 31 | foreach ( $field->options as $fkey => $fopt ) { |
| 32 | - //If it is an other option, don't include it |
|
| 33 | - if ( $fkey && strpos( $fkey, 'other') !== false ) { |
|
| 34 | - continue; |
|
| 35 | - } |
|
| 32 | + //If it is an other option, don't include it |
|
| 33 | + if ( $fkey && strpos( $fkey, 'other') !== false ) { |
|
| 34 | + continue; |
|
| 35 | + } |
|
| 36 | 36 | if ( is_array( $fopt ) ) { |
| 37 | - $label = (isset($fopt['label'])) ? $fopt['label'] : reset($fopt); |
|
| 38 | - $value = (isset($fopt['value'])) ? $fopt['value'] : $label; |
|
| 37 | + $label = (isset($fopt['label'])) ? $fopt['label'] : reset($fopt); |
|
| 38 | + $value = (isset($fopt['value'])) ? $fopt['value'] : $label; |
|
| 39 | 39 | if ( $label != $value && FrmField::is_option_true( $field, 'separate_value' ) ) { |
| 40 | - echo "$label|$value\n"; |
|
| 40 | + echo "$label|$value\n"; |
|
| 41 | 41 | } else { |
| 42 | 42 | echo $label . "\n"; |
| 43 | - } |
|
| 43 | + } |
|
| 44 | 44 | } else { |
| 45 | 45 | echo $fopt . "\n"; |
| 46 | - } |
|
| 46 | + } |
|
| 47 | 47 | } ?> |
| 48 | 48 | </textarea> |
| 49 | 49 | |
@@ -2,7 +2,7 @@ discard block |
||
| 2 | 2 | <html <?php language_attributes(); ?>> |
| 3 | 3 | <head> |
| 4 | 4 | <meta charset="<?php bloginfo( 'charset' ); ?>" /> |
| 5 | - <title><?php bloginfo('name'); ?></title> |
|
| 5 | + <title><?php bloginfo( 'name' ); ?></title> |
|
| 6 | 6 | <?php |
| 7 | 7 | wp_admin_css( 'global' ); |
| 8 | 8 | wp_admin_css(); |
@@ -12,8 +12,8 @@ discard block |
||
| 12 | 12 | wp_admin_css( 'ms' ); |
| 13 | 13 | } |
| 14 | 14 | |
| 15 | - do_action('admin_print_styles'); |
|
| 16 | - do_action('admin_print_scripts'); |
|
| 15 | + do_action( 'admin_print_styles' ); |
|
| 16 | + do_action( 'admin_print_scripts' ); |
|
| 17 | 17 | |
| 18 | 18 | ?> |
| 19 | 19 | </head> |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | <p class="howto"><?php _e( 'Edit or add field options (one per line)', 'formidable' ) ?></p> |
| 23 | 23 | <ul class="frm_prepop"> |
| 24 | 24 | <?php foreach ( $prepop as $label => $pop ) { ?> |
| 25 | - <li><a href="javascript:void(0)" onclick='frmPrePop(<?php echo str_replace("'", '‘', json_encode($pop)) ?>); return false;'><?php echo esc_html( $label ) ?></a></li> |
|
| 25 | + <li><a href="javascript:void(0)" onclick='frmPrePop(<?php echo str_replace( "'", '‘', json_encode( $pop ) ) ?>); return false;'><?php echo esc_html( $label ) ?></a></li> |
|
| 26 | 26 | <?php } ?> |
| 27 | 27 | </ul> |
| 28 | 28 | <textarea name="frm_bulk_options" id="frm_bulk_options"> |
@@ -30,12 +30,12 @@ discard block |
||
| 30 | 30 | $other_array = array(); |
| 31 | 31 | foreach ( $field->options as $fkey => $fopt ) { |
| 32 | 32 | //If it is an other option, don't include it |
| 33 | - if ( $fkey && strpos( $fkey, 'other') !== false ) { |
|
| 33 | + if ( $fkey && strpos( $fkey, 'other' ) !== false ) { |
|
| 34 | 34 | continue; |
| 35 | 35 | } |
| 36 | 36 | if ( is_array( $fopt ) ) { |
| 37 | - $label = (isset($fopt['label'])) ? $fopt['label'] : reset($fopt); |
|
| 38 | - $value = (isset($fopt['value'])) ? $fopt['value'] : $label; |
|
| 37 | + $label = ( isset( $fopt['label'] ) ) ? $fopt['label'] : reset( $fopt ); |
|
| 38 | + $value = ( isset( $fopt['value'] ) ) ? $fopt['value'] : $label; |
|
| 39 | 39 | if ( $label != $value && FrmField::is_option_true( $field, 'separate_value' ) ) { |
| 40 | 40 | echo "$label|$value\n"; |
| 41 | 41 | } else { |