Exemplo n.º 1
0
function revert_to_default_wp_avatar($img, $params, $item_id)
{
    // we are concerned only with users
    if ($params['object'] != 'user') {
        return $img;
    }
    //check if user has uploaded an avatar
    //if not then revert back to wordpress core get_avatar method
    //remove the filter first, or else it will go in infinite loop
    remove_filter('bp_core_fetch_avatar', 'revert_to_default_wp_avatar', 80, 3);
    if (!userpro_user_has_avatar($item_id)) {
        $width = $params['width'];
        // Set image width
        if (false !== $width) {
            $img_width = $width;
        } elseif ('thumb' == $type) {
            $img_width = bp_core_avatar_thumb_width();
        } else {
            $img_width = bp_core_avatar_full_width();
        }
        $img = get_avatar($item_id, $img_width);
    }
    //add the filter back again
    add_filter('bp_core_fetch_avatar', 'revert_to_default_wp_avatar', 80, 3);
    return $img;
}
Exemplo n.º 2
0
function revert_to_default_wp_avatar($img, $params, $item_id)
{
    if ($params['object'] != 'user') {
        return $img;
    }
    remove_filter('bp_core_fetch_avatar', 'revert_to_default_wp_avatar', 80, 3);
    if (!userpro_user_has_avatar($item_id)) {
        $width = $params['width'];
        if (false !== $width) {
            $img_width = $width;
        } elseif ('thumb' == $params['type']) {
            $img_width = bp_core_avatar_thumb_width();
        } else {
            $img_width = bp_core_avatar_full_width();
        }
        $img = get_avatar($item_id, $img_width);
    }
    add_filter('bp_core_fetch_avatar', 'revert_to_default_wp_avatar', 80, 3);
    return $img;
}
Exemplo n.º 3
0
<form action="<?php 
bp_activity_post_form_action();
?>
" method="post" id="whats-new-form" name="whats-new-form" role="complementary">

	<?php 
do_action('bp_before_activity_post_form');
?>

	<div id="whats-new-avatar">
		<a href="<?php 
echo bp_loggedin_user_domain();
?>
">
			<?php 
bp_loggedin_user_avatar('width=' . bp_core_avatar_thumb_width() . '&height=' . bp_core_avatar_thumb_height());
?>
		</a>
	</div>

	<h5><?php 
if (bp_is_group()) {
    printf(__("What's new in %s, %s?", 'buddypress'), bp_get_group_name(), bp_get_user_firstname());
} else {
    printf(__("What's new, %s?", 'buddypress'), bp_get_user_firstname());
}
?>
</h5>

	<div id="whats-new-content">
		<div id="whats-new-textarea">
Exemplo n.º 4
0
/**
 * Get the URL of the 'thumb' default avatar.
 *
 * Uses Gravatar's mystery-person avatar, unless BP_AVATAR_DEFAULT_THUMB has been
 * defined.
 *
 * @since 1.5.0
 *
 * @param string $type 'local' if the fallback should be the locally-hosted version
 *                     of the mystery-person, 'gravatar' if the fallback should be
 *                     Gravatar's version. Default: 'gravatar'.
 *
 * @return string The URL of the default avatar thumb.
 */
function bp_core_avatar_default_thumb($type = 'gravatar')
{
    // Local override
    if (defined('BP_AVATAR_DEFAULT_THUMB')) {
        $avatar = BP_AVATAR_DEFAULT_THUMB;
        // Use the local default image
    } elseif ('local' === $type) {
        $avatar = buddypress()->plugin_url . 'bp-core/images/mystery-man-50.jpg';
        // Use Gravatar's mystery person as fallback
    } else {
        $avatar = '//www.gravatar.com/avatar/00000000000000000000000000000000?d=mm&amp;s=' . bp_core_avatar_thumb_width();
    }
    /**
     * Filters the URL of the 'thumb' default avatar.
     *
     * @since 1.5.0
     *
     * @param string $avatar URL of the default avatar.
     */
    return apply_filters('bp_core_avatar_thumb', $avatar);
}
 /**
  * Crop the avatar.
  *
  * @since 2.3.0
  *
  * @see  BP_Attachment::crop for the list of parameters
  * @uses bp_core_fetch_avatar()
  * @uses bp_core_delete_existing_avatar()
  * @uses bp_core_avatar_full_width()
  * @uses bp_core_avatar_full_height()
  * @uses bp_core_avatar_dimension()
  * @uses BP_Attachment::crop
  *
  * @param array $args Array of arguments for the cropping.
  * @return array The cropped avatars (full and thumb).
  */
 public function crop($args = array())
 {
     // Bail if the original file is missing.
     if (empty($args['original_file'])) {
         return false;
     }
     /**
      * Original file is a relative path to the image
      * eg: /avatars/1/avatar.jpg
      */
     $relative_path = $args['original_file'];
     $absolute_path = $this->upload_path . $relative_path;
     // Bail if the avatar is not available.
     if (!file_exists($absolute_path)) {
         return false;
     }
     if (empty($args['item_id'])) {
         /** This filter is documented in bp-core/bp-core-avatars.php */
         $avatar_folder_dir = apply_filters('bp_core_avatar_folder_dir', dirname($absolute_path), $args['item_id'], $args['object'], $args['avatar_dir']);
     } else {
         /** This filter is documented in bp-core/bp-core-avatars.php */
         $avatar_folder_dir = apply_filters('bp_core_avatar_folder_dir', $this->upload_path . '/' . $args['avatar_dir'] . '/' . $args['item_id'], $args['item_id'], $args['object'], $args['avatar_dir']);
     }
     // Bail if the avatar folder is missing for this item_id.
     if (!file_exists($avatar_folder_dir)) {
         return false;
     }
     // Delete the existing avatar files for the object.
     $existing_avatar = bp_core_fetch_avatar(array('object' => $args['object'], 'item_id' => $args['item_id'], 'html' => false));
     /**
      * Check that the new avatar doesn't have the same name as the
      * old one before deleting
      */
     if (!empty($existing_avatar) && $existing_avatar !== $this->url . $relative_path) {
         bp_core_delete_existing_avatar(array('object' => $args['object'], 'item_id' => $args['item_id'], 'avatar_path' => $avatar_folder_dir));
     }
     // Make sure we at least have minimal data for cropping.
     if (empty($args['crop_w'])) {
         $args['crop_w'] = bp_core_avatar_full_width();
     }
     if (empty($args['crop_h'])) {
         $args['crop_h'] = bp_core_avatar_full_height();
     }
     // Get the file extension.
     $data = @getimagesize($absolute_path);
     $ext = $data['mime'] == 'image/png' ? 'png' : 'jpg';
     $args['original_file'] = $absolute_path;
     $args['src_abs'] = false;
     $avatar_types = array('full' => '', 'thumb' => '');
     foreach ($avatar_types as $key_type => $type) {
         if ('thumb' === $key_type) {
             $args['dst_w'] = bp_core_avatar_thumb_width();
             $args['dst_h'] = bp_core_avatar_thumb_height();
         } else {
             $args['dst_w'] = bp_core_avatar_full_width();
             $args['dst_h'] = bp_core_avatar_full_height();
         }
         $args['dst_file'] = $avatar_folder_dir . '/' . wp_hash($absolute_path . time()) . '-bp' . $key_type . '.' . $ext;
         $avatar_types[$key_type] = parent::crop($args);
     }
     // Remove the original.
     @unlink($absolute_path);
     // Return the full and thumb cropped avatars.
     return $avatar_types;
 }
Exemplo n.º 6
0
/**
 * Get the URL of the 'thumb' default avatar.
 *
 * Uses Gravatar's mystery-man avatar, unless BP_AVATAR_DEFAULT_THUMB has been
 * defined.
 *
 * @since BuddyPress (1.5.0)
 *
 * @param string $type 'local' if the fallback should be the locally-hosted
 *        version of the mystery-man, 'gravatar' if the fallback should be
 *        Gravatar's version. Default: 'gravatar'.
 * @return string The URL of the default avatar thumb.
 */
function bp_core_avatar_default_thumb($type = 'gravatar')
{
    // Local override
    if (defined('BP_AVATAR_DEFAULT_THUMB')) {
        $avatar = BP_AVATAR_DEFAULT_THUMB;
        // Use the local default image
    } else {
        if ('local' === $type) {
            $avatar = buddypress()->plugin_url . 'bp-core/images/mystery-man-50.jpg';
            // Use Gravatar's mystery man as fallback
        } else {
            if (is_ssl()) {
                $host = 'https://secure.gravatar.com';
            } else {
                $host = 'http://www.gravatar.com';
            }
            $avatar = $host . '/avatar/00000000000000000000000000000000?d=mm&amp;s=' . bp_core_avatar_thumb_width();
        }
    }
    return apply_filters('bp_core_avatar_thumb', $avatar);
}
Exemplo n.º 7
0
    function widget($args, $instance)
    {
        global $bp;
        extract($args);
        echo $before_widget;
        echo $before_title . $widget_name . $after_title;
        ?>

		<?php 
        if (bp_has_links('type=popular&per_page=' . $instance['max_links'] . '&max=' . $instance['max_links'])) {
            ?>
			<div class="item-options" id="links-list-options">
				<span class="ajax-loader" id="ajax-loader-links"></span>
				<a href="<?php 
            echo site_url() . '/' . bp_links_root_slug();
            ?>
" id="newest-links"><?php 
            _e("Newest", 'buddypress');
            ?>
</a> |
				<?php 
            if (bp_links_is_voting_enabled()) {
                ?>
				<a href="<?php 
                echo site_url() . '/' . bp_links_root_slug();
                ?>
" id="most-votes"><?php 
                _e("Votes", 'buddypress-links');
                ?>
</a> |
				<a href="<?php 
                echo site_url() . '/' . bp_links_root_slug();
                ?>
" id="high-votes"><?php 
                _e("Rating", 'buddypress-links');
                ?>
</a> |
				<a href="<?php 
                echo site_url() . '/' . bp_links_root_slug();
                ?>
" id="popular-links" class="selected"><?php 
                _e("Popular", 'buddypress');
                ?>
</a>
				<?php 
            } else {
                ?>
				<a href="<?php 
                echo site_url() . '/' . bp_links_root_slug();
                ?>
" id="active-links"><?php 
                _e("Active", 'buddypress');
                ?>
</a>
				<?php 
            }
            ?>
			</div>

			<ul id="links-list" class="item-list">
				<?php 
            while (bp_links()) {
                bp_the_link();
                ?>
					<li>
						<div class="item-avatar">
							<a href="<?php 
                bp_link_permalink();
                ?>
"><?php 
                bp_link_avatar(array('width' => bp_core_avatar_thumb_width(), 'height' => bp_core_avatar_thumb_height()));
                ?>
</a>
						</div>

						<div class="item">
							<div class="item-title"><a href="<?php 
                bp_link_permalink();
                ?>
" title="<?php 
                bp_link_name();
                ?>
"><?php 
                bp_link_name();
                ?>
</a></div>
							<?php 
                if (bp_links_is_voting_enabled()) {
                    ?>
							<div class="item-meta"><span class="activity"><?php 
                    printf(__('%+d rating', 'buddypress-links'), bp_get_link_vote_total());
                    ?>
</span></div>
							<?php 
                }
                ?>
						</div>
					</li>

				<?php 
            }
            ?>
			</ul>
			<?php 
            wp_nonce_field('bp_links_widget_links_list', '_wpnonce-links');
            ?>
			<input type="hidden" name="links_widget_max" id="links_widget_max" value="<?php 
            echo attribute_escape($instance['max_links']);
            ?>
" />

		<?php 
        } else {
            ?>

			<div class="widget-error">
				<?php 
            _e('There are no links to display.', 'buddypress-links');
            ?>
			</div>

		<?php 
        }
        ?>

		<?php 
        echo $after_widget;
        ?>
	<?php 
    }
Exemplo n.º 8
0
/**
 * Crop an uploaded avatar
 *
 * $args has the following parameters:
 *  object - What component the avatar is for, e.g. "user"
 *  avatar_dir  The absolute path to the avatar
 *  item_id - Item ID
 *  original_file - The absolute path to the original avatar file
 *  crop_w - Crop width
 *  crop_h - Crop height
 *  crop_x - The horizontal starting point of the crop
 *  crop_y - The vertical starting point of the crop
 *
 * @global object $bp BuddyPress global settings
 * @param mixed $args
 * @return bool Success/failure
 */
function bp_core_avatar_handle_crop($args = '')
{
    global $bp;
    $defaults = array('object' => 'user', 'avatar_dir' => 'avatars', 'item_id' => false, 'original_file' => false, 'crop_w' => bp_core_avatar_full_width(), 'crop_h' => bp_core_avatar_full_height(), 'crop_x' => 0, 'crop_y' => 0);
    $r = nxt_parse_args($args, $defaults);
    /***
     * You may want to hook into this filter if you want to override this function.
     * Make sure you return false.
     */
    if (!apply_filters('bp_core_pre_avatar_handle_crop', true, $r)) {
        return true;
    }
    extract($r, EXTR_SKIP);
    if (!$original_file) {
        return false;
    }
    $original_file = bp_core_avatar_upload_path() . $original_file;
    if (!file_exists($original_file)) {
        return false;
    }
    if (!$item_id) {
        $avatar_folder_dir = apply_filters('bp_core_avatar_folder_dir', dirname($original_file), $item_id, $object, $avatar_dir);
    } else {
        $avatar_folder_dir = apply_filters('bp_core_avatar_folder_dir', bp_core_avatar_upload_path() . '/' . $avatar_dir . '/' . $item_id, $item_id, $object, $avatar_dir);
    }
    if (!file_exists($avatar_folder_dir)) {
        return false;
    }
    require_once ABSPATH . '/nxt-admin/includes/image.php';
    require_once ABSPATH . '/nxt-admin/includes/file.php';
    // Delete the existing avatar files for the object
    bp_core_delete_existing_avatar(array('object' => $object, 'avatar_path' => $avatar_folder_dir));
    // Make sure we at least have a width and height for cropping
    if (!(int) $crop_w) {
        $crop_w = bp_core_avatar_full_width();
    }
    if (!(int) $crop_h) {
        $crop_h = bp_core_avatar_full_height();
    }
    // Set the full and thumb filenames
    $full_filename = nxt_hash($original_file . time()) . '-bpfull.jpg';
    $thumb_filename = nxt_hash($original_file . time()) . '-bpthumb.jpg';
    // Crop the image
    $full_cropped = nxt_crop_image($original_file, (int) $crop_x, (int) $crop_y, (int) $crop_w, (int) $crop_h, bp_core_avatar_full_width(), bp_core_avatar_full_height(), false, $avatar_folder_dir . '/' . $full_filename);
    $thumb_cropped = nxt_crop_image($original_file, (int) $crop_x, (int) $crop_y, (int) $crop_w, (int) $crop_h, bp_core_avatar_thumb_width(), bp_core_avatar_thumb_height(), false, $avatar_folder_dir . '/' . $thumb_filename);
    // Remove the original
    @unlink($original_file);
    return true;
}
 /**
  * Gets FB profile image and sets it as BuddyPress avatar.
  */
 function set_fb_image_as_bp_avatar($user_id, $me)
 {
     if (!defined('BP_VERSION')) {
         return true;
     }
     if (!function_exists('bp_core_avatar_upload_path')) {
         return true;
     }
     if (!$me || !@$me['id']) {
         return false;
     }
     $fb_uid = $me['id'];
     if (function_exists('xprofile_avatar_upload_dir')) {
         $xpath = xprofile_avatar_upload_dir(false, $user_id);
         $path = $xpath['path'];
     }
     if (!function_exists('xprofile_avatar_upload_dir') || empty($path)) {
         $object = 'user';
         $avatar_dir = apply_filters('bp_core_avatar_dir', 'avatars', $object);
         $path = bp_core_avatar_upload_path() . "/{$avatar_dir}/" . $user_id;
         $path = apply_filters('bp_core_avatar_folder_dir', $path, $user_id, $object, $avatar_dir);
         if (!realpath($path)) {
             @wp_mkdir_p($path);
         }
     }
     // Get FB picture
     //$fb_img = file_get_contents("http://graph.facebook.com/{$fb_uid}/picture?type=large");
     $page = wp_remote_get("http://graph.facebook.com/{$fb_uid}/picture?type=large", array('method' => 'GET', 'timeout' => '5', 'redirection' => '5', 'user-agent' => 'wdfb', 'blocking' => true, 'compress' => false, 'decompress' => true, 'sslverify' => false));
     if (is_wp_error($page)) {
         return false;
     }
     // Request fail
     if ((int) $page['response']['code'] != 200) {
         return false;
     }
     // Request fail
     $fb_img = $page['body'];
     $filename = md5($fb_uid);
     $filepath = "{$path}/{$filename}";
     file_put_contents($filepath, $fb_img);
     // Determine the right extension
     $info = getimagesize($filepath);
     $extension = false;
     if (function_exists('image_type_to_extension')) {
         $extension = image_type_to_extension($info[2], false);
     } else {
         switch ($info[2]) {
             case IMAGETYPE_GIF:
                 $extension = 'gif';
                 break;
             case IMAGETYPE_JPEG:
                 $extension = 'jpg';
                 break;
             case IMAGETYPE_PNG:
                 $extension = 'png';
                 break;
         }
     }
     // Unknown file type, clean up
     if (!$extension) {
         @unlink($filepath);
         return false;
     }
     $extension = 'jpeg' == strtolower($extension) ? 'jpg' : $extension;
     // Forcing .jpg extension for JPEGs
     // Clear old avatars
     $imgs = glob($path . '/*.{gif,png,jpg}', GLOB_BRACE);
     if (is_array($imgs)) {
         foreach ($imgs as $old) {
             @unlink($old);
         }
     }
     // Create and set new avatar
     if (defined('WDFB_BP_AVATAR_AUTO_CROP') && WDFB_BP_AVATAR_AUTO_CROP) {
         // Explicitly requested thumbnail processing
         // First, determine the centering position for cropping
         if ($info && isset($info[0]) && $info[0] && isset($info[1]) && $info[1]) {
             $full = apply_filters('wdfb-avatar-auto_crop', array('x' => (int) (($info[0] - bp_core_avatar_full_width()) / 2), 'y' => (int) (($info[1] - bp_core_avatar_full_height()) / 2), 'width' => bp_core_avatar_full_width(), 'height' => bp_core_avatar_full_height()), $filepath, $info);
         }
         $crop = $full ? wp_crop_image($filepath, $full['x'], $full['y'], $full['width'], $full['height'], bp_core_avatar_full_width(), bp_core_avatar_full_height(), false, "{$filepath}-bpfull.{$extension}") : false;
         if (!$crop) {
             @unlink($filepath);
             return false;
         }
         // Now, the thumbnail. First, try to resize the full avatar
         $thumb_file = wp_create_thumbnail("{$filepath}-bpfull.{$extension}", bp_core_avatar_thumb_width());
         if (!is_wp_error($thumb_file)) {
             // All good! We're done - clean up
             copy($thumb_file, "{$filepath}-bpthumb.{$extension}");
             @unlink($thumb_file);
         } else {
             // Sigh. Let's just fake it by using the original file then.
             copy("{$filepath}-bpfull.{$extension}", "{$filepath}-bpthumb.{$extension}");
         }
         @unlink($filepath);
         return true;
     } else {
         // No auto-crop, move on
         copy($filepath, "{$filepath}-bpfull.{$extension}");
         copy($filepath, "{$filepath}-bpthumb.{$extension}");
         @unlink($filepath);
         return true;
     }
     return false;
 }
Exemplo n.º 10
0
		<?php 
do_action('mpp_after_lightbox_media', $media);
?>
	
		
	</div>
	
	<div class="mpp-lightbox-activity-container">
		<div class="mpp-lightbox-media-uploader-meta mpp-clearfix">
			<div class="mpp-lightbox-media-uploader-avatar">
				<a href="<?php 
echo bp_core_get_user_domain(mpp_get_media_creator_id());
?>
">
					<?php 
echo bp_core_fetch_avatar(array('item_id' => mpp_get_media_creator_id(), 'object' => 'members', 'width' => bp_core_avatar_thumb_width(), 'height' => bp_core_avatar_thumb_height()));
?>
				</a>
			</div>
			<div class="mpp-lightbox-uploader-upload-details">
				<div class="mpp-lightbox-uploader-link">
					<?php 
echo bp_core_get_userlink(mpp_get_media_creator_id());
?>
				</div>
			</div>
		</div><!--end of the top row -->
		<div class="mpp-item-description mpp-media-description mpp-lightbox-media-description mpp-clearfix">
			<?php 
mpp_media_description();
?>
/**
 * Get a blog's avatar.
 *
 * At the moment, blog avatars are simply the user avatars of the blog
 * admin. Filter 'bp_get_blog_avatar_' . $blog_id to customize.
 *
 * @since 2.4.0 Introduced `$title` argument.
 *
 * @see bp_core_fetch_avatar() For a description of arguments and
 *      return values.
 *
 * @param array|string $args  {
 *     Arguments are listed here with an explanation of their defaults.
 *     For more information about the arguments, see
 *     {@link bp_core_fetch_avatar()}.
 *     @type string   $alt     Default: 'Profile picture of site author [user name]'.
 *     @type string   $class   Default: 'avatar'.
 *     @type string   $title   Default: 'Profile picture of site author [user name]'.
 *     @type string   $type    Default: 'full'.
 *     @type int|bool $width   Default: false.
 *     @type int|bool $height  Default: false.
 *     @type bool     $id      Currently unused.
 *     @type bool     $no_grav Default: true.
 * }
 * @return string User avatar string.
 */
function bp_get_blog_avatar($args = '')
{
    global $blogs_template;
    // Bail if avatars are turned off
    // @todo Should we maybe still filter this?
    if (!buddypress()->avatar->show_avatars) {
        return false;
    }
    $author_displayname = bp_core_get_user_displayname($blogs_template->blog->admin_user_id);
    // Parse the arguments.
    $r = bp_parse_args($args, array('type' => 'full', 'width' => false, 'height' => false, 'class' => 'avatar', 'title' => sprintf(__('Profile picture of site author %s', 'buddypress'), esc_attr($author_displayname)), 'id' => false, 'alt' => sprintf(__('Profile picture of site author %s', 'buddypress'), esc_attr($author_displayname)), 'no_grav' => true));
    // Use site icon if available.
    $avatar = '';
    if (bp_is_active('blogs', 'site-icon') && function_exists('has_site_icon')) {
        $site_icon = bp_blogs_get_blogmeta(bp_get_blog_id(), "site_icon_url_{$r['type']}");
        // Never attempted to fetch site icon before; do it now!
        if ('' === $site_icon) {
            switch_to_blog(bp_get_blog_id());
            // Fetch the other size first.
            if ('full' === $r['type']) {
                $size = bp_core_avatar_thumb_width();
                $save_size = 'thumb';
            } else {
                $size = bp_core_avatar_full_width();
                $save_size = 'full';
            }
            $site_icon = get_site_icon_url($size);
            // Empty site icons get saved as integer 0.
            if (empty($site_icon)) {
                $site_icon = 0;
            }
            // Sync site icon for other size to blogmeta.
            bp_blogs_update_blogmeta(bp_get_blog_id(), "site_icon_url_{$save_size}", $site_icon);
            // Now, fetch the size we want.
            if (0 !== $site_icon) {
                $size = 'full' === $r['type'] ? bp_core_avatar_full_width() : bp_core_avatar_thumb_width();
                $site_icon = get_site_icon_url($size);
            }
            // Sync site icon to blogmeta.
            bp_blogs_update_blogmeta(bp_get_blog_id(), "site_icon_url_{$r['type']}", $site_icon);
            restore_current_blog();
        }
        // We have a site icon.
        if (!is_numeric($site_icon)) {
            if (empty($r['width']) && !isset($size)) {
                $size = 'full' === $r['type'] ? bp_core_avatar_full_width() : bp_core_avatar_thumb_width();
            } else {
                $size = (int) $r['width'];
            }
            $avatar = sprintf('<img src="%1$s" class="%2$s" width="%3$s" height="%3$s" alt="%4$s" title="%4$s" />', esc_url($site_icon), esc_attr("{$r['class']} avatar-{$size}"), esc_attr($size), sprintf(esc_attr__('Site icon for %s', 'buddypress'), bp_get_blog_name()));
        }
    }
    // Fallback to user ID avatar.
    if ('' === $avatar) {
        $avatar = bp_core_fetch_avatar(array('item_id' => $blogs_template->blog->admin_user_id, 'title' => $r['title'], 'type' => $r['type'], 'alt' => $r['alt'], 'css_id' => $r['id'], 'class' => $r['class'], 'width' => $r['width'], 'height' => $r['height']));
    }
    /**
     * In future BuddyPress versions you will be able to set the avatar for a blog.
     * Right now you can use a filter with the ID of the blog to change it if you wish.
     * By default it will return the avatar for the primary blog admin.
     *
     * This filter is deprecated as of BuddyPress 1.5 and may be removed in a future version.
     * Use the 'bp_get_blog_avatar' filter instead.
     */
    $avatar = apply_filters('bp_get_blog_avatar_' . $blogs_template->blog->blog_id, $avatar);
    /**
     * Filters a blog's avatar.
     *
     * @since 1.5.0
     *
     * @param string $avatar  Formatted HTML <img> element, or raw avatar
     *                        URL based on $html arg.
     * @param int    $blog_id ID of the blog whose avatar is being displayed.
     * @param array  $r       Array of arguments used when fetching avatar.
     */
    return apply_filters('bp_get_blog_avatar', $avatar, $blogs_template->blog->blog_id, $r);
}
/**
 * Crop an uploaded avatar
 *
 * $args has the following parameters:
 *  object - What component the avatar is for, e.g. "user"
 *  avatar_dir  The absolute path to the avatar
 *  item_id - Item ID
 *  original_file - The absolute path to the original avatar file
 *  crop_w - Crop width
 *  crop_h - Crop height
 *  crop_x - The horizontal starting point of the crop
 *  crop_y - The vertical starting point of the crop
 *
 * @param mixed $args
 * @return bool Success/failure
 */
function bp_core_avatar_handle_crop($args = '')
{
    $r = wp_parse_args($args, array('object' => 'user', 'avatar_dir' => 'avatars', 'item_id' => false, 'original_file' => false, 'crop_w' => bp_core_avatar_full_width(), 'crop_h' => bp_core_avatar_full_height(), 'crop_x' => 0, 'crop_y' => 0));
    /***
     * You may want to hook into this filter if you want to override this function.
     * Make sure you return false.
     */
    if (!apply_filters('bp_core_pre_avatar_handle_crop', true, $r)) {
        return true;
    }
    extract($r, EXTR_SKIP);
    if (empty($original_file)) {
        return false;
    }
    $original_file = bp_core_avatar_upload_path() . $original_file;
    if (!file_exists($original_file)) {
        return false;
    }
    if (empty($item_id)) {
        $avatar_folder_dir = apply_filters('bp_core_avatar_folder_dir', dirname($original_file), $item_id, $object, $avatar_dir);
    } else {
        $avatar_folder_dir = apply_filters('bp_core_avatar_folder_dir', bp_core_avatar_upload_path() . '/' . $avatar_dir . '/' . $item_id, $item_id, $object, $avatar_dir);
    }
    if (!file_exists($avatar_folder_dir)) {
        return false;
    }
    require_once ABSPATH . '/wp-admin/includes/image.php';
    require_once ABSPATH . '/wp-admin/includes/file.php';
    // Delete the existing avatar files for the object
    bp_core_delete_existing_avatar(array('object' => $object, 'avatar_path' => $avatar_folder_dir));
    // Make sure we at least have a width and height for cropping
    if (empty($crop_w)) {
        $crop_w = bp_core_avatar_full_width();
    }
    if (empty($crop_h)) {
        $crop_h = bp_core_avatar_full_height();
    }
    // Get the file extension
    $data = @getimagesize($original_file);
    $ext = $data['mime'] == 'image/png' ? 'png' : 'jpg';
    // Set the full and thumb filenames
    $full_filename = wp_hash($original_file . time()) . '-bpfull.' . $ext;
    $thumb_filename = wp_hash($original_file . time()) . '-bpthumb.' . $ext;
    // Crop the image
    $full_cropped = wp_crop_image($original_file, (int) $crop_x, (int) $crop_y, (int) $crop_w, (int) $crop_h, bp_core_avatar_full_width(), bp_core_avatar_full_height(), false, $avatar_folder_dir . '/' . $full_filename);
    $thumb_cropped = wp_crop_image($original_file, (int) $crop_x, (int) $crop_y, (int) $crop_w, (int) $crop_h, bp_core_avatar_thumb_width(), bp_core_avatar_thumb_height(), false, $avatar_folder_dir . '/' . $thumb_filename);
    // Check for errors
    if (empty($full_cropped) || empty($thumb_cropped) || is_wp_error($full_cropped) || is_wp_error($thumb_cropped)) {
        return false;
    }
    // Remove the original
    @unlink($original_file);
    return true;
}
Exemplo n.º 13
0
		<?php 
do_action('mpp_after_lightbox_media', $media);
?>
	
		
	</div>
	
	<div class="mpp-lightbox-activity-container">
		<div class="mpp-lightbox-media-uploader-meta mpp-clearfix">
			<div class="mpp-lightbox-media-uploader-avatar">
				<a href="<?php 
echo bp_core_get_user_domain(mpp_get_media_creator_id());
?>
">
					<?php 
echo bp_core_fetch_avatar(array('object' => 'members', 'width' => bp_core_avatar_thumb_width(), 'height' => bp_core_avatar_thumb_height()));
?>
				</a>
			</div>
			<div class="mpp-lightbox-uploader-upload-details">
				<div class="mpp-lightbox-uploader-link">
					<?php 
echo bp_core_get_userlink(mpp_get_media_creator_id());
?>
				</div>
			</div>
		</div><!--end of the top row -->
		<div class="mpp-item-description mpp-media-description mpp-lightbox-media-description mpp-clearfix">
			<?php 
mpp_media_description();
?>
Exemplo n.º 14
0
	<div class="inner-sidebar <?php 
do_action('wf_class_inner_sidebar');
?>
 inner-sidebar-mobile">


		<a id="close-buddypress-mobile-sidebar" class="close-panel-button" href="#">
			<i class="fa fa-times-circle"></i> Close menu
		</a>

		<?php 
if (bp_is_user()) {
    ?>
			<div id="user-sidebar-menu" class="widget">
				<?php 
    bp_displayed_user_avatar('width=' . bp_core_avatar_thumb_width() . '&height=' . bp_core_avatar_thumb_height());
    ?>
				<?php 
    $userLink = bp_get_displayed_user_link();
    ?>
				<strong><?php 
    echo bp_core_get_user_displayname(bp_displayed_user_id());
    ?>
</strong>
				<br>
			</div>
		<?php 
}
?>

		<?php 
/**
 * Syncs site icon URLs to blogmeta.
 *
 * @since 2.7.0
 *
 * @param int|string $old_value Old value
 * @param int|string $new_value New value
 */
function bp_blogs_update_option_site_icon($old_value, $new_value)
{
    if (0 === $new_value) {
        bp_blogs_update_blogmeta(get_current_blog_id(), 'site_icon_url_thumb', 0);
        bp_blogs_update_blogmeta(get_current_blog_id(), 'site_icon_url_full', 0);
    } else {
        // Save site icon URL as blogmeta.
        bp_blogs_update_blogmeta(get_current_blog_id(), 'site_icon_url_thumb', get_site_icon_url(bp_core_avatar_thumb_width()));
        bp_blogs_update_blogmeta(get_current_blog_id(), 'site_icon_url_full', get_site_icon_url(bp_core_avatar_full_width()));
    }
}
/**
 * Registers our custom thumb size with WP's Site Icon feature.
 *
 * @since 2.7.0
 *
 * @param  array $sizes Current array of custom site icon sizes.
 * @return array
 */
function bp_blogs_register_custom_site_icon_size($sizes)
{
    $sizes[] = bp_core_avatar_thumb_width();
    return $sizes;
}