Changeset 9658
- Timestamp:
- 03/29/2015 04:27:24 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-xprofile/classes/class-bp-xprofile-field.php
r9657 r9658 54 54 } 55 55 56 $bp = buddypress();57 $ sql = $wpdb->prepare( "SELECT * FROM {$bp->profile->table_name_fields} WHERE id = %d", $id);58 59 if ( $field = $wpdb->get_row( $sql) ) {56 $bp = buddypress(); 57 $field = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$bp->profile->table_name_fields} WHERE id = %d", $id ) ); 58 59 if ( ! empty( $field ) ) { 60 60 $this->id = $field->id; 61 61 $this->group_id = $field->group_id; … … 95 95 // Prevent deletion by url when can_delete is false. 96 96 // Prevent deletion of option 1 since this invalidates fields with options. 97 if ( empty( $this->id ) || empty( $this->can_delete ) || ( $this->parent_id && $this->option_order == 1 ) ) 97 if ( empty( $this->id ) || empty( $this->can_delete ) || ( $this->parent_id && $this->option_order == 1 ) ) { 98 98 return false; 99 } 99 100 100 101 $bp = buddypress(); 101 102 102 if ( !$wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->profile->table_name_fields} WHERE id = %d OR parent_id = %d", $this->id, $this->id ) ) ) 103 if ( !$wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->profile->table_name_fields} WHERE id = %d OR parent_id = %d", $this->id, $this->id ) ) ) { 103 104 return false; 105 } 104 106 105 107 // delete the data in the DB for this field 106 if ( true === $delete_data ) 108 if ( true === $delete_data ) { 107 109 BP_XProfile_ProfileData::delete_for_field( $this->id ); 110 } 108 111 109 112 return true; … … 210 213 211 214 if ( is_array( $defaults ) ) { 212 if ( isset( $defaults[$option_key] ) ) 215 if ( isset( $defaults[$option_key] ) ) { 213 216 $is_default = 1; 217 } 214 218 } else { 215 if ( (int) $defaults == $option_key ) 219 if ( (int) $defaults == $option_key ) { 216 220 $is_default = 1; 221 } 217 222 } 218 223 … … 336 341 $bp = buddypress(); 337 342 338 if ( empty( $bp->profile->table_name_fields ) || !isset( $field_name ) ) 343 if ( empty( $bp->profile->table_name_fields ) || !isset( $field_name ) ) { 339 344 return false; 345 } 340 346 341 347 return $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp->profile->table_name_fields} WHERE name = %s AND parent_id = 0", $field_name ) ); … … 345 351 global $wpdb; 346 352 347 if ( !is_numeric( $position ) || !is_numeric( $field_group_id ) ) 353 if ( !is_numeric( $position ) || !is_numeric( $field_group_id ) ) { 348 354 return false; 355 } 349 356 350 357 $bp = buddypress();
Note: See TracChangeset
for help on using the changeset viewer.