public
Created

User Avatar WP Plugin - dir patch 2

  • Download Gist
user-avatar.patch
Diff
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
diff --git a/public_html/wp-content/plugins/user-avatar/timthumb-config.php b/public_html/wp-content/plugins/user-avatar/timthumb-config.php
index fce3b18..06ec2db 100644
--- a/public_html/wp-content/plugins/user-avatar/timthumb-config.php
+++ b/public_html/wp-content/plugins/user-avatar/timthumb-config.php
@@ -8,13 +8,6 @@ if( isset($_GET['id']) && is_numeric($_GET['id']) ){
} else {
die();
}
-// this is the standard set up with wp-content living 3 levels down
-define ('WP_CONTENT_DIR', dirname(dirname(dirname(__FILE__))));
-define ('AVATARS_DIR',WP_CONTENT_DIR.'/uploads/avatars/');
-// cache the file inside the avatar directory
-// please modify this to your hearts content
-if(! defined('FILE_CACHE_DIRECTORY') ) define ('FILE_CACHE_DIRECTORY', AVATARS_DIR.$id.'/cache');
-
// this are pretty much the standard settings
if(! defined( 'DEBUG_ON' ) ) define ('DEBUG_ON', false); // Enable debug logging to web server error log (STDERR)
diff --git a/public_html/wp-content/plugins/user-avatar/user-avatar.php b/public_html/wp-content/plugins/user-avatar/user-avatar.php
index 04ecc22..0d856cc 100644
--- a/public_html/wp-content/plugins/user-avatar/user-avatar.php
+++ b/public_html/wp-content/plugins/user-avatar/user-avatar.php
@@ -115,10 +115,13 @@ function user_avatar_core_set_avatar_constants() {
*/
function user_avatar_core_avatar_upload_path()
{
- if( !file_exists(WP_CONTENT_DIR."/uploads/avatars/") )
- mkdir(WP_CONTENT_DIR."/uploads/avatars/", 0777 ,true);
+ $upload_dir = wp_upload_dir();
+ $avatar_dir = $upload_dir['basedir'] . "/avatars/";
+
+ if( !file_exists($avatar_dir) )
+ mkdir($avatar_dir, 0777 ,true);
- return WP_CONTENT_DIR."/uploads/avatars/";
+ return $avatar_dir;
}
/**
@@ -129,7 +132,10 @@ function user_avatar_core_avatar_upload_path()
*/
function user_avatar_core_avatar_url()
{
- return WP_CONTENT_URL."/uploads/avatars/";
+ $upload_dir = wp_upload_dir();
+ $avatar_url = $upload_dir['baseurl'] . "/avatars/";
+
+ return $avatar_url;
}
/**
@@ -591,10 +597,7 @@ function user_avatar_fetch_avatar( $args = '' ) {
if( $avatar_img = user_avatar_avatar_exists( $item_id ) ):
- $avatar_src = get_site_url()."/wp-content/uploads/avatars/".$item_id."/".$avatar_img;
- if(function_exists('is_subdomain_install') && !is_subdomain_install())
- $avatar_src = "/wp-content/uploads/avatars/".$item_id."/".$avatar_img;
-
+ $avatar_src = USER_AVATAR_URL.$item_id."/".$avatar_img;
$avatar_folder_dir = USER_AVATAR_UPLOAD_PATH."{$item_id}/";
$file_time = filemtime ($avatar_folder_dir."/".$avatar_img);
@@ -633,7 +636,7 @@ function user_avatar_delete(){
$user_id = "?user_id=".$user_id;
user_avatar_delete_files($_GET['u']);
- wp_redirect(get_option('siteurl') . '/wp-admin/'.$pagenow.$user_id);
+ wp_redirect(admin_url($pagenow.$user_id));
}
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.