本文整理汇总了PHP中bp_core_avatar_upload_path函数的典型用法代码示例。如果您正苦于以下问题:PHP bp_core_avatar_upload_path函数的具体用法?PHP bp_core_avatar_upload_path怎么用?PHP bp_core_avatar_upload_path使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了bp_core_avatar_upload_path函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: um_admin_addon_hook
function um_admin_addon_hook($hook)
{
global $ultimatemember;
switch ($hook) {
case 'bp_avatar_transfer':
if (class_exists('BuddyPress')) {
$path = bp_core_avatar_upload_path() . '/avatars';
$files = glob($path . '/*');
$i = 0;
foreach ($files as $key) {
$q = count(glob("{$key}/*")) === 0 ? 0 : 1;
if ($q == 1) {
$photo = glob($key . '/*');
foreach ($photo as $file) {
if (strstr($file, 'bpfull')) {
$get_user_id = explode('/', $file);
array_pop($get_user_id);
$user_id = end($get_user_id);
if (!file_exists($ultimatemember->files->upload_basedir . $user_id . '/profile_photo.jpg')) {
$ultimatemember->files->new_user($user_id);
copy($file, $ultimatemember->files->upload_basedir . $user_id . '/profile_photo.jpg');
update_user_meta($user_id, 'profile_photo', 'profile_photo.jpg');
$i++;
}
}
}
}
}
$this->content = '<p><strong>Done. Process completed!</p>';
$this->content .= $i . ' user(s) changed.</strong></p>';
}
break;
}
}
示例2: clean_existing_avatars
private function clean_existing_avatars($type = 'user')
{
if ('user' === $type) {
$avatar_dir = 'avatars';
} elseif ('group' === $object) {
$avatar_dir = 'group-avatars';
}
$this->rrmdir(bp_core_avatar_upload_path() . '/' . $avatar_dir);
}
示例3: set_upload_dir
/**
* Set Upload Dir data for avatars.
*
* @since 2.3.0
*
* @uses bp_core_avatar_upload_path()
* @uses bp_core_avatar_url()
* @uses bp_upload_dir()
* @uses BP_Attachment::set_upload_dir()
*/
public function set_upload_dir()
{
if (bp_core_avatar_upload_path() && bp_core_avatar_url()) {
$this->upload_path = bp_core_avatar_upload_path();
$this->url = bp_core_avatar_url();
$this->upload_dir = bp_upload_dir();
} else {
parent::set_upload_dir();
}
}
示例4: bp_core_set_avatar_constants
function bp_core_set_avatar_constants()
{
global $bp;
if (!defined('BP_AVATAR_UPLOAD_PATH')) {
define('BP_AVATAR_UPLOAD_PATH', bp_core_avatar_upload_path());
}
if (!defined('BP_AVATAR_URL')) {
define('BP_AVATAR_URL', bp_core_avatar_url());
}
if (!defined('BP_AVATAR_THUMB_WIDTH')) {
define('BP_AVATAR_THUMB_WIDTH', 32);
}
if (!defined('BP_AVATAR_THUMB_HEIGHT')) {
define('BP_AVATAR_THUMB_HEIGHT', 32);
}
if (!defined('BP_AVATAR_FULL_WIDTH')) {
define('BP_AVATAR_FULL_WIDTH', 184);
}
if (!defined('BP_AVATAR_FULL_HEIGHT')) {
define('BP_AVATAR_FULL_HEIGHT', 184);
}
if (!defined('BP_AVATAR_ORIGINAL_MAX_WIDTH')) {
define('BP_AVATAR_ORIGINAL_MAX_WIDTH', 450);
}
if (!defined('BP_AVATAR_ORIGINAL_MAX_FILESIZE')) {
if (!$bp->site_options['fileupload_maxk']) {
define('BP_AVATAR_ORIGINAL_MAX_FILESIZE', 5120000);
} else {
define('BP_AVATAR_ORIGINAL_MAX_FILESIZE', $bp->site_options['fileupload_maxk'] * 1024);
}
}
if (!defined('BP_AVATAR_DEFAULT')) {
define('BP_AVATAR_DEFAULT', BP_PLUGIN_URL . '/bp-core/images/mystery-man.jpg');
}
if (!defined('BP_AVATAR_DEFAULT_THUMB')) {
define('BP_AVATAR_DEFAULT_THUMB', BP_PLUGIN_URL . '/bp-core/images/mystery-man-50.jpg');
}
}
示例5: bcp_fetch_cover_photo
/**
* fetch the cover photo of group/user
*
* @return string url
*/
function bcp_fetch_cover_photo($args)
{
$cover_photos_collection = array();
$r = wp_parse_args($args, array('object_id' => 0, 'type' => 'user'));
extract($r, EXTR_SKIP);
if (0 == $object_id) {
return $cover_photos_collection;
}
$upload_dir = wp_upload_dir();
$avatars_dir = $type == 'user' ? 'avatars' : 'group-avatars';
// begin fetching avatar
$avatar_upload_dir = bp_core_avatar_upload_path() . '/' . $avatars_dir . '/' . $object_id . '/';
$avatar_upload_url = $upload_dir['baseurl'] . '/' . $avatars_dir . '/' . $object_id . '/';
// open the dir
if (!file_exists($avatar_upload_dir)) {
return $cover_photos_collection;
}
if ($handle = opendir($avatar_upload_dir)) {
while (false !== ($entry = readdir($handle))) {
if ($entry != "." && $entry != "..") {
$file_info = pathinfo($entry);
$file_name = $file_info['filename'];
$file_ext = $file_info['extension'];
$cover_photos = array('coverphoto-full', 'coverphoto-thumb');
if (in_array($file_name, $cover_photos)) {
// cover photo exists
$cover_photo_url = $avatar_upload_url . $file_name . '.' . $file_ext;
$cover_timestamp = '?bcp_cover=' . get_user_meta($object_id, 'cover-photo-timestamp', true);
if ('user' !== $type) {
$cover_timestamp = '?bcp_group_cover=' . groups_get_groupmeta($object_id, 'cover-photo-timestamp');
}
if ('coverphoto-full' == $file_name) {
$cover_photos_collection['full'] = $cover_photo_url . $cover_timestamp;
} else {
$cover_photos_collection['thumb'] = $cover_photo_url . $cover_timestamp;
}
}
}
}
// close the directory
closedir($handle);
}
return $cover_photos_collection;
}
示例6: bp_core_add_cropper_inline_js
/**
* Output the inline JS needed for the cropper to work on a per-page basis.
*
* @since 1.1.0
*/
function bp_core_add_cropper_inline_js()
{
/**
* Filters the return value of getimagesize to determine if an image was uploaded.
*
* @since 1.1.0
*
* @param array $value Array of data found by getimagesize.
*/
$image = apply_filters('bp_inline_cropper_image', getimagesize(bp_core_avatar_upload_path() . buddypress()->avatar_admin->image->dir));
if (empty($image)) {
return;
}
// Get avatar full width and height.
$full_height = bp_core_avatar_full_height();
$full_width = bp_core_avatar_full_width();
// Calculate Aspect Ratio.
if (!empty($full_height) && $full_width != $full_height) {
$aspect_ratio = $full_width / $full_height;
} else {
$aspect_ratio = 1;
}
// Default cropper coordinates.
// Smaller than full-width: cropper defaults to entire image.
if ($image[0] < $full_width) {
$crop_left = 0;
$crop_right = $image[0];
// Less than 2x full-width: cropper defaults to full-width.
} elseif ($image[0] < $full_width * 2) {
$padding_w = round(($image[0] - $full_width) / 2);
$crop_left = $padding_w;
$crop_right = $image[0] - $padding_w;
// Larger than 2x full-width: cropper defaults to 1/2 image width.
} else {
$crop_left = round($image[0] / 4);
$crop_right = $image[0] - $crop_left;
}
// Smaller than full-height: cropper defaults to entire image.
if ($image[1] < $full_height) {
$crop_top = 0;
$crop_bottom = $image[1];
// Less than double full-height: cropper defaults to full-height.
} elseif ($image[1] < $full_height * 2) {
$padding_h = round(($image[1] - $full_height) / 2);
$crop_top = $padding_h;
$crop_bottom = $image[1] - $padding_h;
// Larger than 2x full-height: cropper defaults to 1/2 image height.
} else {
$crop_top = round($image[1] / 4);
$crop_bottom = $image[1] - $crop_top;
}
?>
<script type="text/javascript">
jQuery(window).load( function(){
jQuery('#avatar-to-crop').Jcrop({
onChange: showPreview,
onSelect: updateCoords,
aspectRatio: <?php
echo (int) $aspect_ratio;
?>
,
setSelect: [ <?php
echo (int) $crop_left;
?>
, <?php
echo (int) $crop_top;
?>
, <?php
echo (int) $crop_right;
?>
, <?php
echo (int) $crop_bottom;
?>
]
});
});
function updateCoords(c) {
jQuery('#x').val(c.x);
jQuery('#y').val(c.y);
jQuery('#w').val(c.w);
jQuery('#h').val(c.h);
}
function showPreview(coords) {
if ( parseInt(coords.w) > 0 ) {
var fw = <?php
echo (int) $full_width;
?>
;
var fh = <?php
echo (int) $full_height;
?>
;
//.........这里部分代码省略.........
示例7: bp_core_screen_activation
/**
* Handle the loading of the Activate screen.
*
* @todo Move the actual activation process into an action in bp-members-actions.php
*/
function bp_core_screen_activation()
{
// Bail if not viewing the activation page
if (!bp_is_current_component('activate')) {
return false;
}
// If the user is already logged in, redirect away from here
if (is_user_logged_in()) {
// If activation page is also front page, set to members directory to
// avoid an infinite loop. Otherwise, set to root domain.
$redirect_to = bp_is_component_front_page('activate') ? bp_get_root_domain() . '/' . bp_get_members_root_slug() : bp_get_root_domain();
// Trailing slash it, as we expect these URL's to be
$redirect_to = trailingslashit($redirect_to);
/**
* Filters the URL to redirect logged in users to when visiting activation page.
*
* @since BuddyPress (1.9.0)
*
* @param string $redirect_to URL to redirect user to.
*/
$redirect_to = apply_filters('bp_loggedin_activate_page_redirect_to', $redirect_to);
// Redirect away from the activation page
bp_core_redirect($redirect_to);
}
// grab the key (the old way)
$key = isset($_GET['key']) ? $_GET['key'] : '';
// grab the key (the new way)
if (empty($key)) {
$key = bp_current_action();
}
// Get BuddyPress
$bp = buddypress();
// we've got a key; let's attempt to activate the signup
if (!empty($key)) {
/**
* Filters the activation signup.
*
* @since BuddyPress (1.1.0)
*
* @param bool|int $value Value returned by activation.
* Integer on success, boolean on failure.
*/
$user = apply_filters('bp_core_activate_account', bp_core_activate_signup($key));
// If there were errors, add a message and redirect
if (!empty($user->errors)) {
bp_core_add_message($user->get_error_message(), 'error');
bp_core_redirect(trailingslashit(bp_get_root_domain() . '/' . $bp->pages->activate->slug));
}
$hashed_key = wp_hash($key);
// Check if the signup avatar folder exists. If it does, move the folder to
// the BP user avatars directory
if (file_exists(bp_core_avatar_upload_path() . '/avatars/signups/' . $hashed_key)) {
@rename(bp_core_avatar_upload_path() . '/avatars/signups/' . $hashed_key, bp_core_avatar_upload_path() . '/avatars/' . $user);
}
bp_core_add_message(__('Your account is now active!', 'buddypress'));
$bp->activation_complete = true;
}
/**
* Filters the template to load for the Member activation page screen.
*
* @since BuddyPress (1.1.1)
*
* @param string $value Path to the Member activation template to load.
*/
bp_core_load_template(apply_filters('bp_core_template_activate', array('activate', 'registration/activate')));
}
示例8: bp_core_avatar_handle_crop
/**
* 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 array $args {
* Array of function parameters.
* @type string $object Object type of the item whose avatar you're
* handling. 'user', 'group', 'blog', or custom. Default: 'user'.
* @type string $avatar_dir Subdirectory where avatar should be stored.
* Default: 'avatars'.
* @type bool|int $item_id ID of the item that the avatar belongs to.
* @type bool|string $original_file Absolute papth to the original avatar
* file.
* @type int $crop_w Crop width. Default: the global 'full' avatar width,
* as retrieved by bp_core_avatar_full_width().
* @type int $crop_h Crop height. Default: the global 'full' avatar height,
* as retrieved by bp_core_avatar_full_height().
* @type int $crop_x The horizontal starting point of the crop. Default: 0.
* @type int $crop_y The vertical starting point of the crop. Default: 0.
* }
* @return bool True on success, false on 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
$existing_avatar = bp_core_fetch_avatar(array('object' => $object, 'item_id' => $item_id, 'html' => false));
if (!empty($existing_avatar)) {
// Check that the new avatar doesn't have the same name as the
// old one before deleting
$upload_dir = wp_upload_dir();
$existing_avatar_path = str_replace($upload_dir['baseurl'], '', $existing_avatar);
$new_avatar_path = str_replace($upload_dir['basedir'], '', $original_file);
if ($existing_avatar_path !== $new_avatar_path) {
bp_core_delete_existing_avatar(array('object' => $object, 'item_id' => $item_id, '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;
}
示例9: handle_crop
public function handle_crop()
{
require_once ABSPATH . '/wp-admin/includes/image.php';
$user_id = bp_displayed_user_id();
$cover_photo = get_transient('profile_cover_photo_' . $user_id);
// Get the file extension
$data = @getimagesize($cover_photo);
$ext = $data['mime'] == 'image/png' ? 'png' : 'jpg';
$base_filename = basename($cover_photo, '.' . $ext);
// create a new filename but, if it's already been cropped, strip out the -cropped
$new_filename = str_replace('-cropped', '', $base_filename) . '-cropped.' . $ext;
$new_filepath = bp_core_avatar_upload_path() . '/cover-photo/' . $user_id . '/' . $new_filename;
$new_fileurl = bp_core_avatar_url() . '/cover-photo/' . $user_id . '/' . $new_filename;
$crop_fileurl = str_replace(trailingslashit(get_home_url()), '', bp_core_avatar_url()) . '/cover-photo/' . $user_id . '/' . $new_filename;
// delete the old cover photo if it exists
if (file_exists($new_filepath)) {
@unlink($new_filepath);
}
$cropped_header = wp_crop_image($cover_photo, $_POST['x'], $_POST['y'], $_POST['w'], $_POST['h'], $this->width, $this->height, false, $crop_fileurl);
if (!is_wp_error($cropped_header)) {
$old_file_path = get_user_meta(bp_loggedin_user_id(), 'profile_cover_photo_path', true);
if (file_exists($old_file_path)) {
@unlink($old_file_path);
}
// update with the new image and path
bp_update_user_meta(bp_loggedin_user_id(), 'profile_cover_photo', $new_fileurl);
bp_update_user_meta(bp_loggedin_user_id(), 'profile_cover_photo_path', $new_filepath);
delete_transient('is_cover_photo_uploaded_' . bp_displayed_user_id());
delete_transient('profile_cover_photo_' . bp_displayed_user_id());
}
}
示例10: tv_bp_core_avatar_handle_upload
function tv_bp_core_avatar_handle_upload($file, $upload_dir_filter)
{
/***
* 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_upload', true, $file, $upload_dir_filter)) {
return true;
}
require_once ABSPATH . '/wp-admin/includes/file.php';
$uploadErrors = array(0 => __('The image was uploaded successfully', 'buddypress'), 1 => __('The image exceeds the maximum allowed file size of: ', 'buddypress') . size_format(bp_core_avatar_original_max_filesize()), 2 => __('The image exceeds the maximum allowed file size of: ', 'buddypress') . size_format(bp_core_avatar_original_max_filesize()), 3 => __('The uploaded file was only partially uploaded.', 'buddypress'), 4 => __('The image was not uploaded.', 'buddypress'), 6 => __('Missing a temporary folder.', 'buddypress'));
if (!bp_core_check_avatar_upload($file)) {
bp_core_add_message(sprintf(__('Your upload failed, please try again. Error was: %s', 'buddypress'), $uploadErrors[$file['file']['error']]), 'error');
return false;
}
if (!bp_core_check_avatar_size($file)) {
bp_core_add_message(sprintf(__('The file you uploaded is too big. Please upload a file under %s', 'buddypress'), size_format(bp_core_avatar_original_max_filesize())), 'error');
return false;
}
if (!bp_core_check_avatar_type($file)) {
bp_core_add_message(__('Please upload only JPG, GIF or PNG photos.', 'buddypress'), 'error');
return false;
}
// Filter the upload location
add_filter('upload_dir', $upload_dir_filter, 10, 0);
$upload_dir = wp_upload_dir();
emptyDirectory($upload_dir['path']);
$bp = buddypress();
$bp->avatar_admin->original = wp_handle_upload($file['file'], array('test_form' => false));
// Remove the upload_dir filter, so that other upload URLs on the page
// don't break
remove_filter('upload_dir', $upload_dir_filter, 10, 0);
// Move the file to the correct upload location.
if (!empty($bp->avatar_admin->original['error'])) {
bp_core_add_message(sprintf(__('Upload Failed! Error was: %s', 'buddypress'), $bp->avatar_admin->original['error']), 'error');
return false;
}
// Get image size
$size = @getimagesize($bp->avatar_admin->original['file']);
$error = false;
// Check image size and shrink if too large
if ($size[0] > bp_core_avatar_original_max_width()) {
$editor = wp_get_image_editor($bp->avatar_admin->original['file']);
if (!is_wp_error($editor)) {
$editor->set_quality(100);
$resized = $editor->resize(bp_core_avatar_original_max_width(), bp_core_avatar_original_max_width(), false);
if (!is_wp_error($resized)) {
$thumb = $editor->save($editor->generate_filename());
} else {
$error = $resized;
}
// Check for thumbnail creation errors
if (false === $error && is_wp_error($thumb)) {
$error = $thumb;
}
// Thumbnail is good so proceed
if (false === $error) {
$bp->avatar_admin->resized = $thumb;
}
} else {
$error = $editor;
}
if (false !== $error) {
bp_core_add_message(sprintf(__('Upload Failed! Error was: %s', 'buddypress'), $error->get_error_message()), 'error');
return false;
}
}
if (!isset($bp->avatar_admin->image)) {
$bp->avatar_admin->image = new stdClass();
}
// We only want to handle one image after resize.
if (empty($bp->avatar_admin->resized)) {
$bp->avatar_admin->image->dir = str_replace(bp_core_avatar_upload_path(), '', $bp->avatar_admin->original['file']);
} else {
$bp->avatar_admin->image->dir = str_replace(bp_core_avatar_upload_path(), '', $bp->avatar_admin->resized['path']);
@unlink($bp->avatar_admin->original['file']);
}
// Check for WP_Error on what should be an image
if (is_wp_error($bp->avatar_admin->image->dir)) {
bp_core_add_message(sprintf(__('Upload failed! Error was: %s', 'buddypress'), $bp->avatar_admin->image->dir->get_error_message()), 'error');
return false;
}
// Set the url value for the image
$bp->avatar_admin->image->url = bp_core_avatar_url() . $bp->avatar_admin->image->dir;
return true;
}
示例11: bp_caver_avatar_handle_upload
function bp_caver_avatar_handle_upload()
{
global $bp;
if ($_POST['encodedimg']) {
$user_id = !empty($_POST['user_id']) ? $_POST['user_id'] : bp_displayed_user_id();
$imgresponse = array();
$uploaddir = bp_core_avatar_upload_path() . '/avatars';
if (!file_exists($uploaddir)) {
mkdir($uploaddir);
}
$img = $_POST['encodedimg'];
$img = str_replace('data:' . $_POST['imgtype'] . ';base64,', '', $img);
$img = str_replace(' ', '+', $img);
$data = base64_decode($img);
$filepath = $uploaddir . '/' . $user_id;
if (!file_exists($filepath)) {
mkdir($filepath);
}
$imgname = wp_unique_filename($uploaddir, $_POST['imgname']);
$fileurl = $filepath . '/' . $imgname;
$siteurl = trailingslashit(get_blog_option(1, 'siteurl'));
$url = str_replace(ABSPATH, $siteurl, $fileurl);
$success = file_put_contents($fileurl, $data);
$file = $_POST['imgsize'];
$max_upload_size = bp_cover_get_max_media_size();
if ($max_upload_size > $file) {
if ($success) {
$imgresponse[0] = "1";
$imgresponse[1] = $fileurl;
$size = getimagesize($fileurl);
/* Check image size and shrink if too large */
if ($size[0] > 150) {
$original_file = image_resize($fileurl, 150, 150, true);
//$ava_file = image_resize( $fileurl, 250, 250, true );
/* Check for thumbnail creation errors */
if (is_wp_error($original_file)) {
$imgresponse[0] = "0";
$imgresponse[1] = sprintf(__('Upload Failed! Error was: %s', 'bp-cover'), $original_file->get_error_message());
die;
}
$avatar_to_crop = str_replace(bp_core_avatar_upload_path(), '', $original_file);
bp_core_delete_existing_avatar(array('item_id' => $user_id, 'avatar_path' => bp_core_avatar_upload_path() . '/avatars/' . $user_id));
$crop_args = array('item_id' => $user_id, 'original_file' => $avatar_to_crop, 'crop_w' => 0, 'crop_h' => 0);
bp_core_avatar_handle_crop($crop_args);
//$url = str_replace(ABSPATH,$siteurl,$ava_file);
update_user_meta(bp_loggedin_user_id(), 'profile_avatar', $url);
do_action('xprofile_avatar_uploaded');
} else {
$imgresponse[0] = "0";
$imgresponse[1] = __('Upload Failed! Your photo must be larger than 150px', 'bp-cover');
}
} else {
$imgresponse[0] = "0";
$imgresponse[1] = __('Upload Failed! Unable to write the image on server', 'bp-cover');
}
} else {
$imgresponse[0] = "0";
$imgresponse[1] = sprintf(__('The file you uploaded is too big. Please upload a file under %s', 'bp-cover'), size_format($max_upload_size));
}
} else {
$imgresponse[0] = "0";
$imgresponse[1] = __('Upload Failed! No image sent', 'bp-cover');
}
/* if everything is ok, we send back url to thumbnail and to full image */
echo json_encode($imgresponse);
die;
}
示例12: bp_core_screen_activation
function bp_core_screen_activation()
{
global $bp;
if (!bp_is_current_component('activate')) {
return false;
}
// Check if an activation key has been passed
if (isset($_GET['key'])) {
// Activate the signup
$user = apply_filters('bp_core_activate_account', bp_core_activate_signup($_GET['key']));
// If there were errors, add a message and redirect
if (!empty($user->errors)) {
bp_core_add_message($user->get_error_message(), 'error');
bp_core_redirect(trailingslashit(bp_get_root_domain() . '/' . $bp->pages->activate->slug));
}
// Check for an uploaded avatar and move that to the correct user folder
if (is_multisite()) {
$hashed_key = wp_hash($_GET['key']);
} else {
$hashed_key = wp_hash($user);
}
// Check if the avatar folder exists. If it does, move rename it, move
// it and delete the signup avatar dir
if (file_exists(bp_core_avatar_upload_path() . '/avatars/signups/' . $hashed_key)) {
@rename(bp_core_avatar_upload_path() . '/avatars/signups/' . $hashed_key, bp_core_avatar_upload_path() . '/avatars/' . $user);
}
bp_core_add_message(__('Your account is now active!', 'buddypress'));
$bp->activation_complete = true;
}
if ('' != locate_template(array('registration/activate'), false)) {
bp_core_load_template(apply_filters('bp_core_template_activate', 'activate'));
} else {
bp_core_load_template(apply_filters('bp_core_template_activate', 'registration/activate'));
}
}
示例13: bp_rbe_remove_imap_connection_marker
/**
* Remove IMAP connection marker file.
*
* @since 1.0-RC4
*
* @see bp_rbe_add_imap_lock()
*/
function bp_rbe_remove_imap_connection_marker()
{
clearstatcache();
if (file_exists(bp_core_avatar_upload_path() . '/bp-rbe-connected.txt')) {
unlink(bp_core_avatar_upload_path() . '/bp-rbe-connected.txt');
}
}
示例14: bp_core_screen_activation
/**
* Handle the loading of the Activate screen.
*/
function bp_core_screen_activation()
{
global $bp;
if (!bp_is_current_component('activate')) {
return false;
}
// If the user is logged in, redirect away from here
if (is_user_logged_in()) {
if (bp_is_component_front_page('activate')) {
$redirect_to = trailingslashit(bp_get_root_domain() . '/' . bp_get_members_root_slug());
} else {
$redirect_to = trailingslashit(bp_get_root_domain());
}
bp_core_redirect(apply_filters('bp_loggedin_activate_page_redirect_to', $redirect_to));
return;
}
// Check if an activation key has been passed
if (isset($_GET['key'])) {
// Activate the signup
$user = apply_filters('bp_core_activate_account', bp_core_activate_signup($_GET['key']));
// If there were errors, add a message and redirect
if (!empty($user->errors)) {
bp_core_add_message($user->get_error_message(), 'error');
bp_core_redirect(trailingslashit(bp_get_root_domain() . '/' . $bp->pages->activate->slug));
}
$hashed_key = wp_hash($_GET['key']);
// Check if the avatar folder exists. If it does, move rename it, move
// it and delete the signup avatar dir
if (file_exists(bp_core_avatar_upload_path() . '/avatars/signups/' . $hashed_key)) {
@rename(bp_core_avatar_upload_path() . '/avatars/signups/' . $hashed_key, bp_core_avatar_upload_path() . '/avatars/' . $user);
}
bp_core_add_message(__('Your account is now active!', 'buddypress'));
$bp->activation_complete = true;
}
bp_core_load_template(apply_filters('bp_core_template_activate', array('activate', 'registration/activate')));
}
示例15: xprofile_avatar_upload_dir
/**
* Setup the avatar upload directory for a user.
*
* @since BuddyPress (1.0.0)
*
* @package BuddyPress Core
*
* @param string $directory The root directory name. Optional.
* @param int $user_id The user ID. Optional.
*
* @return array() Array containing the path, URL, and other helpful settings.
*/
function xprofile_avatar_upload_dir($directory = 'avatars', $user_id = 0)
{
// Use displayed user if no user ID was passed
if (empty($user_id)) {
$user_id = bp_displayed_user_id();
}
// Failsafe against accidentally nooped $directory parameter
if (empty($directory)) {
$directory = 'avatars';
}
$path = bp_core_avatar_upload_path() . '/' . $directory . '/' . $user_id;
$newbdir = $path;
if (!file_exists($path)) {
@wp_mkdir_p($path);
}
$newurl = bp_core_avatar_url() . '/' . $directory . '/' . $user_id;
$newburl = $newurl;
$newsubdir = '/' . $directory . '/' . $user_id;
return apply_filters('xprofile_avatar_upload_dir', array('path' => $path, 'url' => $newurl, 'subdir' => $newsubdir, 'basedir' => $newbdir, 'baseurl' => $newburl, 'error' => false));
}