Changeset 1760 for trunk/bp-core/bp-core-avatars.php
- Timestamp:
- 09/02/2009 07:54:19 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-core/bp-core-avatars.php
r1714 r1760 140 140 'item_id' => false, 141 141 'object' => 'user', // user OR group OR blog OR custom type (if you use filters) 142 'avatar_ path' => false142 'avatar_dir' => false 143 143 ); 144 144 145 $r = wp_parse_args( $args, $defaults ); 146 extract( $r, EXTR_SKIP ); 147 148 if ( !$avatar_path ) 149 return false; 145 $args = wp_parse_args( $args, $defaults ); 146 extract( $args, EXTR_SKIP ); 147 148 if ( !$item_id ) { 149 if ( 'user' == $object ) 150 $item_id = $bp->displayed_user->id; 151 else if ( 'group' == $object ) 152 $item_id = $bp->groups->current_group->id; 153 else if ( 'blog' == $object ) 154 $item_id = $current_blog->id; 155 156 $item_id = apply_filters( 'bp_core_avatar_item_id', $item_id, $object ); 157 158 if ( !$item_id ) return false; 159 } 160 161 if ( !$avatar_dir ) { 162 if ( 'user' == $object ) 163 $avatar_dir = 'avatars'; 164 else if ( 'group' == $object ) 165 $avatar_dir = 'group-avatars'; 166 else if ( 'blog' == $object ) 167 $avatar_dir = 'blog-avatars'; 168 169 $avatar_dir = apply_filters( 'bp_core_avatar_dir', $avatar_dir, $object ); 170 171 if ( !$avatar_dir ) return false; 172 } 150 173 151 174 if ( 'user' == $object ) { … … 157 180 } 158 181 159 if ( $av_dir = opendir( $avatar_path ) ) { 182 $avatar_folder_dir = apply_filters( 'bp_core_avatar_folder_dir', WP_CONTENT_DIR . '/blogs.dir/' . BP_ROOT_BLOG . '/files/' . $avatar_dir . '/' . $item_id, $item_id, $object, $avatar_dir ); 183 184 if ( !file_exists( $avatar_folder_dir ) ) 185 return false; 186 187 if ( $av_dir = opendir( $avatar_folder_dir ) ) { 160 188 while ( false !== ( $avatar_file = readdir($av_dir) ) ) { 161 189 if ( ( preg_match( "/-bpfull/", $avatar_file ) || preg_match( "/-bpthumb/", $avatar_file ) ) && '.' != $avatar_file && '..' != $avatar_file ) 162 @unlink( $avatar_ path . '/' . $avatar_file );190 @unlink( $avatar_folder_dir . '/' . $avatar_file ); 163 191 } 164 192 } 165 193 closedir($av_dir); 194 195 @rmdir( $avatar_folder_dir ); 196 197 do_action( 'bp_core_delete_existing_avatar', $args ); 198 199 return true; 166 200 } 167 201
Note: See TracChangeset
for help on using the changeset viewer.