- Timestamp:
- 04/01/2015 11:56:35 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-xprofile/classes/class-bp-xprofile-group.php
r9676 r9677 80 80 */ 81 81 public function populate( $id ) { 82 global $wpdb; 83 84 $group = wp_cache_get( $id, 'bp_xprofile_groups' ); 85 86 if ( false === $group ) { 87 $bp = buddypress(); 88 $group = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$bp->profile->table_name_groups} WHERE id = %d", $id ) ); 89 wp_cache_set( $id, $group, 'bp_xprofile_groups' ); 90 } 91 82 83 // Get this group 84 $group = self::get( array( 85 'profile_group_id' => $id 86 ) ); 87 88 // Bail if group not found 92 89 if ( empty( $group ) ) { 93 90 return false; 94 91 } 95 92 93 // Get the first array element 94 $group = reset( $group ); 95 96 // Set object properties 96 97 $this->id = $group->id; 97 98 $this->name = $group->name; … … 129 130 $bp = buddypress(); 130 131 132 // Update or insert 131 133 if ( ! empty( $this->id ) ) { 132 134 $sql = $wpdb->prepare( "UPDATE {$bp->profile->table_name_groups} SET name = %s, description = %s WHERE id = %d", $this->name, $this->description, $this->id ); … … 135 137 } 136 138 139 // Attempt to insert or update 140 $query = $wpdb->query( $sql ); 141 137 142 // Bail if query fails 138 if ( is_wp_error( $wpdb->query( $sql )) ) {143 if ( empty( $query ) || is_wp_error( $query ) ) { 139 144 return false; 140 145 }
Note: See TracChangeset
for help on using the changeset viewer.