Example #1
0
 /**
  * @group bp_get_user_has_avatar
  */
 public function test_bp_get_user_has_avatar_has_avatar_uploaded()
 {
     $u = $this->factory->user->create();
     // Fake it
     add_filter('bp_core_fetch_avatar_url', array($this, 'avatar_cb'));
     $this->assertTrue(bp_get_user_has_avatar($u));
     remove_filter('bp_core_fetch_avatar_url', array($this, 'avatar_cb'));
 }
Example #2
0
 function ulogin_bp_core_fetch_avatar($html, $params)
 {
     if (get_option('avatar_default') == 'ulogin') {
         $photo = get_user_meta($params['item_id'], 'ulogin_photo', 1);
         if ($photo) {
             if (function_exists('bp_get_user_has_avatar')) {
                 $photo = bp_get_user_has_avatar($params['item_id']) ? false : $photo;
             }
             if ($photo) {
                 return preg_replace('/src=".+?"/', 'src="' . $photo . '"', $html);
             }
         }
         $html = preg_replace("/d=ulogin/", "d=mystery", $html);
     }
     return $html;
 }
Example #3
0
function ulogin_bp_core_fetch_avatar($html, $params)
{
    $soc_avatar = uLoginPluginSettings::getOptions();
    $soc_avatar = $soc_avatar['social_avatar'];
    if ($soc_avatar) {
        $photo = get_user_meta($params['item_id'], 'ulogin_photo', 1);
        if ($photo && $params['object'] == 'user') {
            if (function_exists('bp_get_user_has_avatar')) {
                $photo = bp_get_user_has_avatar($params['item_id']) ? false : $photo;
            }
            if ($photo) {
                $html = preg_replace('/src=".+?"/', 'src="' . $photo . '"', $html);
                return preg_replace('/srcset=".+?"/', 'srcset="' . $photo . '"', $html);
            }
        }
    }
    return $html;
}
Example #4
0
			<p><?php 
        _e('Click below to select a JPG, GIF or PNG format photo from your computer and then click \'Upload Image\' to proceed.', 'bp-magic');
        ?>
</p>

			<p id="avatar-upload">
				<input type="file" name="file" id="file" />
				<input type="submit" name="upload" id="upload" value="<?php 
        _e('Upload Image', 'bp-magic');
        ?>
" />
				<input type="hidden" name="action" id="action" value="bp_avatar_upload" />
			</p>

			<?php 
        if (bp_get_user_has_avatar()) {
            ?>
				<p><?php 
            _e("If you'd like to delete your current avatar but not upload a new one, please use the delete avatar button.", 'bp-magic');
            ?>
</p>
				<p><a class="btn btn-delete button edit" href="<?php 
            bp_avatar_delete_link();
            ?>
" title="<?php 
            _e('Delete Avatar', 'bp-magic');
            ?>
"><?php 
            _e('Delete My Avatar', 'bp-magic');
            ?>
</a></p>
 /**
  * Build script datas for the Uploader UI.
  *
  * @since 2.3.0
  *
  * @return array The javascript localization data.
  */
 public function script_data()
 {
     // Get default script data.
     $script_data = parent::script_data();
     // Defaults to Avatar Backbone script.
     $js_scripts = array('bp-avatar');
     // Default object.
     $object = '';
     // Get the possible item ids.
     $user_id = $this->get_user_id();
     $group_id = $this->get_group_id();
     if (!empty($user_id)) {
         // Should we load the the Webcam Avatar javascript file.
         if (bp_avatar_use_webcam()) {
             $js_scripts = array('bp-webcam');
         }
         $script_data['bp_params'] = array('object' => 'user', 'item_id' => $user_id, 'has_avatar' => bp_get_user_has_avatar($user_id), 'nonces' => array('set' => wp_create_nonce('bp_avatar_cropstore'), 'remove' => wp_create_nonce('bp_delete_avatar_link')));
         // Set feedback messages.
         $script_data['feedback_messages'] = array(1 => __('There was a problem cropping your profile photo.', 'buddypress'), 2 => __('Your new profile photo was uploaded successfully.', 'buddypress'), 3 => __('There was a problem deleting your profile photo. Please try again.', 'buddypress'), 4 => __('Your profile photo was deleted successfully!', 'buddypress'));
     } elseif (!empty($group_id)) {
         $script_data['bp_params'] = array('object' => 'group', 'item_id' => $group_id, 'has_avatar' => bp_get_group_has_avatar($group_id), 'nonces' => array('set' => wp_create_nonce('bp_avatar_cropstore'), 'remove' => wp_create_nonce('bp_group_avatar_delete')));
         // Set feedback messages.
         $script_data['feedback_messages'] = array(1 => __('There was a problem cropping the group profile photo.', 'buddypress'), 2 => __('The group profile photo was uploaded successfully.', 'buddypress'), 3 => __('There was a problem deleting the group profile photo. Please try again.', 'buddypress'), 4 => __('The group profile photo was deleted successfully!', 'buddypress'));
     } else {
         /**
          * Use this filter to include specific BuddyPress params for your object.
          * e.g. Blavatar.
          *
          * @since 2.3.0
          *
          * @param array $value The avatar specific BuddyPress parameters.
          */
         $script_data['bp_params'] = apply_filters('bp_attachment_avatar_params', array());
     }
     // Include the specific css.
     $script_data['extra_css'] = array('bp-avatar');
     // Include the specific css.
     $script_data['extra_js'] = $js_scripts;
     // Set the object to contextualize the filter.
     if (isset($script_data['bp_params']['object'])) {
         $object = $script_data['bp_params']['object'];
     }
     /**
      * Use this filter to override/extend the avatar script data.
      *
      * @since 2.3.0
      *
      * @param array  $script_data The avatar script data.
      * @param string $object      The object the avatar belongs to (eg: user or group).
      */
     return apply_filters('bp_attachment_avatar_script_data', $script_data, $object);
 }
        /**
         * Render the Avatar metabox to moderate inappropriate images.
         *
         * @since 2.0.0
         *
         * @param WP_User|null $user The WP_User object for the user being edited.
         */
        public function user_admin_avatar_metabox($user = null)
        {
            if (empty($user->ID)) {
                return;
            }
            ?>

		<div class="avatar">

			<?php 
            echo bp_core_fetch_avatar(array('item_id' => $user->ID, 'object' => 'user', 'type' => 'full', 'title' => $user->display_name));
            ?>

			<?php 
            if (bp_get_user_has_avatar($user->ID)) {
                $query_args = array('user_id' => $user->ID, 'action' => 'delete_avatar');
                if (!empty($_REQUEST['wp_http_referer'])) {
                    $query_args['wp_http_referer'] = urlencode(wp_unslash($_REQUEST['wp_http_referer']));
                }
                $community_url = add_query_arg($query_args, buddypress()->members->admin->edit_profile_url);
                $delete_link = wp_nonce_url($community_url, 'delete_avatar');
                ?>

				<a href="<?php 
                echo esc_url($delete_link);
                ?>
" title="<?php 
                esc_attr_e('Delete Profile Photo', 'buddypress');
                ?>
" class="bp-xprofile-avatar-user-admin"><?php 
                esc_html_e('Delete Profile Photo', 'buddypress');
                ?>
</a>

			<?php 
            }
            // Load the Avatar UI templates if user avatar uploads are enabled and current WordPress version is supported.
            if (!bp_core_get_root_option('bp-disable-avatar-uploads') && bp_attachments_is_wp_version_supported()) {
                ?>
				<a href="#TB_inline?width=800px&height=400px&inlineId=bp-xprofile-avatar-editor" title="<?php 
                esc_attr_e('Edit Profile Photo', 'buddypress');
                ?>
" class="thickbox bp-xprofile-avatar-user-edit"><?php 
                esc_html_e('Edit Profile Photo', 'buddypress');
                ?>
</a>
				<div id="bp-xprofile-avatar-editor" style="display:none;">
					<?php 
                bp_attachments_get_template_part('avatars/index');
                ?>
				</div>
			<?php 
            }
            ?>

		</div>
		<?php 
        }
Example #7
0
	<p><?php _e( 'Your avatar will be used on your profile and throughout the site. If there is a <a href="http://gravatar.com">Gravatar</a> associated with your account email we will use that, or you can upload an image from your computer.', 'buddypress') ?></p>

	<form action="" method="post" id="avatar-upload-form" enctype="multipart/form-data">

		<?php if ( 'upload-image' == bp_get_avatar_admin_step() ) : ?>

			<p><?php _e( 'Click below to select a JPG, GIF or PNG format photo from your computer and then click \'Upload Image\' to proceed.', 'buddypress' ) ?></p>

			<p id="avatar-upload">
				<input type="file" name="file" id="file" />
				<input type="submit" name="upload" id="upload" value="<?php _e( 'Upload Image', 'buddypress' ) ?>" />
				<input type="hidden" name="action" id="action" value="bp_avatar_upload" />
			</p>

			<?php if ( bp_get_user_has_avatar() ) : ?>
				<p><?php _e( "If you'd like to delete your current avatar but not upload a new one, please use the delete avatar button.", 'buddypress' ) ?></p>
				<p><a class="button edit" href="<?php bp_avatar_delete_link() ?>" title="<?php _e( 'Delete Avatar', 'buddypress' ) ?>"><?php _e( 'Delete My Avatar', 'buddypress' ) ?></a></p>
			<?php endif; ?>

			<?php wp_nonce_field( 'bp_avatar_upload' ) ?>

		<?php endif; ?>

		<?php if ( 'crop-image' == bp_get_avatar_admin_step() ) : ?>

			<h5><?php _e( 'Crop Your New Avatar', 'buddypress' ) ?></h5>

			<img src="<?php bp_avatar_to_crop() ?>" id="avatar-to-crop" class="avatar" alt="<?php _e( 'Avatar to crop', 'buddypress' ) ?>" />

			<div id="avatar-crop-pane">
Example #8
0
        /**
         * Render the Avatar metabox to moderate inappropriate images.
         *
         * @access public
         * @since BuddyPress (2.0.0)
         *
         * @param WP_User $user The WP_User object for the user being edited.
         */
        public function user_admin_avatar_metabox($user = null)
        {
            if (empty($user->ID)) {
                return;
            }
            ?>

		<div class="avatar">

			<?php 
            echo bp_core_fetch_avatar(array('item_id' => $user->ID, 'object' => 'user', 'type' => 'full', 'title' => $user->display_name));
            ?>

			<?php 
            if (bp_get_user_has_avatar($user->ID)) {
                $query_args = array('user_id' => $user->ID, 'action' => 'delete_avatar');
                if (!empty($_REQUEST['wp_http_referer'])) {
                    $query_args['wp_http_referer'] = urlencode(wp_unslash($_REQUEST['wp_http_referer']));
                }
                $community_url = add_query_arg($query_args, buddypress()->members->admin->edit_profile_url);
                $delete_link = wp_nonce_url($community_url, 'delete_avatar');
                ?>

				<a href="<?php 
                echo esc_url($delete_link);
                ?>
" title="<?php 
                esc_attr_e('Delete Profile Photo', 'buddypress');
                ?>
" class="bp-xprofile-avatar-user-admin"><?php 
                esc_html_e('Delete Profile Photo', 'buddypress');
                ?>
</a></li>

			<?php 
            }
            ?>

		</div>
		<?php 
        }
 /**
  * GEM MD Funciton - add GEO my WP elements to members results
  */
 public function add_elements_to_results()
 {
     global $members_template;
     $distance = false;
     //if member does not have location get out!!
     if (!isset($members_template->member->lat)) {
         return;
     }
     //address
     if (isset($this->gmwSD['address'])) {
         echo '<div class="gmw-sd-address-wrapper"><span class="gmw-sd-address">' . __('Address:', 'GMW') . '</span> <span class="gmw-sd-address-value">' . $this->get_address() . '</span></div>';
     }
     //directions
     echo self::get_directions();
     if (isset($members_template->member->distance) && !empty($members_template->member->distance)) {
         $units = $this->gmwSD['units'] == '6371' ? __('km', 'GMW') : __('mi', 'GMW');
         $distance = $members_template->member->distance . ' ' . $units;
     }
     //add lat/long locations array to pass to map
     $this->gmwSD['members'][] = array('ID' => $members_template->member->ID, 'user_link' => bp_core_get_user_domain($members_template->member->ID), 'avatar' => bp_get_user_has_avatar($members_template->member->ID) ? bp_core_fetch_avatar(array('item_id' => $members_template->member->ID, 'type' => 'thumb', 'width' => 10, 'height' => 10, 'html' => false, 'no_grav' => true)) : GMW_SD_URL . '/assets/images/_no_avatar.png', 'lat' => $members_template->member->lat, 'long' => $members_template->member->long, 'user_name' => $members_template->member->user_nicename, 'distance' => $distance);
 }
 function wsl_get_bp_user_custom_avatar($html, $args)
 {
     //Buddypress component should be enabled
     if (!wsl_is_component_enabled('buddypress')) {
         return $html;
     }
     //Check if avatars display is enabled
     if (!get_option('wsl_settings_users_avatars')) {
         return $html;
     }
     //Check arguments
     if (is_array($args)) {
         //User Object
         if (!empty($args['object']) and strtolower($args['object']) == 'user') {
             //User Identifier
             if (!empty($args['item_id']) and is_numeric($args['item_id'])) {
                 $user_id = $args['item_id'];
                 //Only Overwrite gravatars
                 # https://wordpress.org/support/topic/buddypress-avatar-overwriting-problem?replies=1
                 if (bp_get_user_has_avatar($user_id)) {
                     return $html;
                 }
                 $wsl_avatar = wsl_get_user_custom_avatar($user_id);
                 //Retrieve Avatar
                 if ($wsl_avatar) {
                     $img_class = 'class="' . (!empty($args['class']) ? $args['class'] . ' ' : '') . 'avatar-wordpress-social-login" ';
                     $img_width = !empty($args['width']) ? 'width="' . $args['width'] . '" ' : 'width="' . bp_core_avatar_full_width() . '" ';
                     $img_height = !empty($args['height']) ? 'height="' . $args['height'] . '" ' : 'height="' . bp_core_avatar_full_height() . '" ';
                     $img_alt = !empty($args['alt']) ? 'alt="' . esc_attr($args['alt']) . '" ' : '';
                     //Replace
                     $wsl_html = preg_replace('#<img[^>]+>#i', '<img src="' . $wsl_avatar . '" ' . $img_alt . $img_class . $img_height . $img_width . '/>', $html);
                     // HOOKABLE:
                     return apply_filters('wsl_hook_alter_get_bp_user_custom_avatar', $wsl_html, $user_id, $wsl_avatar, $html, $args);
                 }
             }
         }
     }
     return $html;
 }