Plugin Directory

Changeset 1250820


Ignore:
Timestamp:
09/22/2015 02:41:50 AM (10 years ago)
Author:
aruljayarajs
Message:

Overwrite default avator

Location:
profile-picture
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • profile-picture/tags/1.0/class/class_pp.php

    r1249951 r1250820  
    1010
    1111        # Register shortcodes   
    12         add_filter( 'the_content', 'do_shortcode');                 
     12        add_filter( 'the_content', 'do_shortcode');
     13        add_filter( 'get_avatar', array($this, 'pp_avatar'), 1, 5 );               
    1314        $this->setup_actions();                                         
    1415    }
     
    6465    }
    6566
     67    // Overwrite Default avator
     68    public function pp_avatar( $avatar, $id_or_email, $size, $default, $alt ) { 
     69        $user = false;
     70       
     71        if ( is_numeric( $id_or_email ) ) {
     72   
     73            $id = (int) $id_or_email;
     74            $user = get_user_by( 'id' , $id );
     75   
     76        } elseif ( is_object( $id_or_email ) ) {
     77   
     78            if ( ! empty( $id_or_email->user_id ) ) {
     79                $id = (int) $id_or_email->user_id;
     80                $user = get_user_by( 'id' , $id );
     81            }
     82   
     83        } else {           
     84            $user = get_user_by( 'email', $id_or_email );   
     85        }
     86       
     87        if ( $user && is_object( $user ) ) {
     88            $upload_dir = wp_upload_dir();
     89            $pp_url = get_user_meta($user->ID, 'pp_url', true);
     90            $custom_avatar = $upload_dir['baseurl'].$pp_url;
     91   
     92            if (isset($custom_avatar) && !empty($custom_avatar)) {
     93                $avatar = "<img alt='{$alt}' src='{$custom_avatar}' class='avatar avatar-{$size} photo' height='{$size}' width='{$size}' />";
     94            }
     95   
     96        }
     97   
     98        return $avatar;
     99    }
    66100
    67101}
  • profile-picture/tags/1.0/readme.txt

    r1249951 r1250820  
    11=== Plugin Name ===
    2 Contributors: arul
     2Contributors: aruljayarajs
    33Tags: user profile, custom profile photo, profile picture, custom profile picture, profile photo
    44Requires at least: 3.0
  • profile-picture/trunk/class/class_pp.php

    r1249951 r1250820  
    1010
    1111        # Register shortcodes   
    12         add_filter( 'the_content', 'do_shortcode');                 
     12        add_filter( 'the_content', 'do_shortcode');
     13        add_filter( 'get_avatar', array($this, 'pp_avatar'), 1, 5 );               
    1314        $this->setup_actions();                                         
    1415    }
     
    6364        include_once(PP_PLUGIN_HTML_DIR."/profile_fields.php");
    6465    }
     66   
     67    // Overwrite Default avator
     68    public function pp_avatar( $avatar, $id_or_email, $size, $default, $alt ) { 
     69        $user = false;
     70       
     71        if ( is_numeric( $id_or_email ) ) {
     72   
     73            $id = (int) $id_or_email;
     74            $user = get_user_by( 'id' , $id );
     75   
     76        } elseif ( is_object( $id_or_email ) ) {
     77   
     78            if ( ! empty( $id_or_email->user_id ) ) {
     79                $id = (int) $id_or_email->user_id;
     80                $user = get_user_by( 'id' , $id );
     81            }
     82   
     83        } else {           
     84            $user = get_user_by( 'email', $id_or_email );   
     85        }
     86       
     87        if ( $user && is_object( $user ) ) {
     88            $upload_dir = wp_upload_dir();
     89            $pp_url = get_user_meta($user->ID, 'pp_url', true);
     90            $custom_avatar = $upload_dir['baseurl'].$pp_url;
     91   
     92            if (isset($custom_avatar) && !empty($custom_avatar)) {
     93                $avatar = "<img alt='{$alt}' src='{$custom_avatar}' class='avatar avatar-{$size} photo' height='{$size}' width='{$size}' />";
     94            }
     95   
     96        }
     97   
     98        return $avatar;
     99    }
    65100
    66101
  • profile-picture/trunk/readme.txt

    r1249951 r1250820  
    11=== Plugin Name ===
    2 Contributors: arul
     2Contributors: aruljayarajs
    33Tags: user profile, custom profile photo, profile picture, custom profile picture, profile photo
    44Requires at least: 3.0
Note: See TracChangeset for help on using the changeset viewer.