Example #1
0
/**
 * Trick to check if the theme's BuddyPress templates are up to date.
 *
 * If the "avatar templates" are not including the new template tag, this will
 * help users to get the avatar UI.
 *
 * @since  2.3.0
 */
function bp_avatar_template_check()
{
    if (!bp_avatar_is_front_edit()) {
        return;
    }
    if (!did_action('bp_attachments_avatar_check_template')) {
        bp_attachments_get_template_part('avatars/index');
    }
}
Example #2
0
<div class="bp-avatar-status"></div>

<script type="text/html" id="tmpl-bp-avatar-nav">
	<a href="{{data.href}}" class="bp-avatar-nav-item" data-nav="{{data.id}}">{{data.name}}</a>
</script>

<?php 
bp_attachments_get_template_part('uploader');
?>

<?php 
bp_attachments_get_template_part('avatars/crop');
?>

<?php 
bp_attachments_get_template_part('avatars/camera');
?>

<script id="tmpl-bp-avatar-delete" type="text/html">
	<# if ( 'user' === data.object ) { #>
		<p><?php 
_e("If you'd like to delete your current profile photo but not upload a new one, please use the delete profile photo button.", 'buddypress');
?>
</p>
		<p><a class="button edit" id="bp-delete-avatar" href="#" title="<?php 
esc_attr_e('Delete Profile Photo', 'buddypress');
?>
"><?php 
esc_html_e('Delete My Profile Photo', 'buddypress');
?>
</a></p>
        /**
         * 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 
        }
/**
 * An Editor other plugins can use for their need.
 *
 * @since 1.3.0
 *
 * @param string $editor_id the Editor's id to insert the BuddyDrive oembed link into.
 */
function buddydrive_editor($editor_id = '')
{
    $buddydrive = buddydrive();
    $current_user_can = (bool) apply_filters('buddydrive_editor_can', is_user_logged_in());
    // Bail if current user can't use it and if not in front end
    if (!$current_user_can || is_admin()) {
        return;
    }
    // Enqueue Thickbox
    wp_enqueue_style('thickbox');
    wp_enqueue_script('thickbox');
    if (!empty($editor_id)) {
        $buddydrive->editor_id = $editor_id;
    }
    // Temporary filters to add custom strings and settings
    add_filter('bp_attachments_get_plupload_l10n', 'buddydrive_editor_strings', 10, 1);
    add_filter('bp_attachments_get_plupload_default_settings', 'buddydrive_editor_settings', 10, 1);
    // Enqueue BuddyPress attachments scripts
    bp_attachments_enqueue_scripts('BuddyDrive_Attachment');
    // Remove the temporary filters
    remove_filter('bp_attachments_get_plupload_l10n', 'buddydrive_editor_strings', 10, 1);
    remove_filter('bp_attachments_get_plupload_default_settings', 'buddydrive_editor_settings', 10, 1);
    $url = remove_query_arg(array_keys($_REQUEST));
    ?>
	<a href="<?php 
    echo esc_url($url);
    ?>
#TB_inline?inlineId=buddydrive-public-uploader" title="<?php 
    esc_attr_e('Add file', 'buddydrive');
    ?>
" id="buddydrive-btn" class="thickbox button">
		<?php 
    echo esc_html_e('Add File', 'buddydrive');
    ?>
	</a>
	<div id="buddydrive-public-uploader" style="display:none;">
		<?php 
    /* Markup for the uploader */
    ?>
			<div class="buddydrive-uploader"></div>
			<div class="buddydrive-uploader-status"></div>

		<?php 
    bp_attachments_get_template_part('uploader');
    /* Markup for the uploader */
    ?>
	</div>
	<?php 
}
<h2><?php 
_e('Change Cover Image', 'buddypress');
?>
</h2>

<?php 
/**
 * Fires before the display of profile cover image upload content.
 *
 * @since 2.4.0
 */
do_action('bp_before_profile_edit_cover_image');
?>

<p><?php 
_e('Your Cover Image will be used to customize the header of your profile.', 'buddypress');
?>
</p>

<?php 
bp_attachments_get_template_part('cover-images/index');
?>

<?php 
/**
 * Fires after the display of profile cover image upload content.
 *
 * @since 2.4.0
 */
do_action('bp_after_profile_edit_cover_image');
Example #6
0
 *
 * It's also used to create the common Backbone views.
 *
 * @since 2.4.0
 *
 * @package BuddyPress
 * @subpackage bp-attachments
 */
?>

<div class="bp-cover-image"></div>
<div class="bp-cover-image-status"></div>
<div class="bp-cover-image-manage"></div>

<?php 
bp_attachments_get_template_part('uploader');
?>

<script id="tmpl-bp-cover-image-delete" type="text/html">
	<# if ( 'user' === data.object ) { #>
		<p><?php 
_e("If you'd like to delete your current cover image but not upload a new one, please use the delete Cover Image button.", 'buddypress');
?>
</p>
		<p><a class="button edit" id="bp-delete-cover-image" href="#"><?php 
esc_html_e('Delete My Cover Image', 'buddypress');
?>
</a></p>
	<# } else if ( 'group' === data.object ) { #>
		<p><?php 
_e("If you'd like to remove the existing group cover image but not upload a new one, please use the delete group cover image button.", 'buddypress');
/**
 * BP Attachment Editor
 */
function front_end_attachments_editor()
{
    // Bail if current user can't use it and if not in front end
    if (!current_user_can('upload_files') || !buddypress()->core->front_end_attachments->use_bp_attachment) {
        return;
    }
    // Enqueue Thickbox
    wp_enqueue_style('thickbox');
    wp_enqueue_script('thickbox');
    // Temporary filters to add custom strings and settings
    add_filter('bp_attachments_get_plupload_l10n', 'front_end_attachments_editor_strings', 10, 1);
    add_filter('bp_attachments_get_plupload_default_settings', 'front_end_attachments_editor_settings', 10, 1);
    // Enqueue BuddyPress attachments scripts
    bp_attachments_enqueue_scripts('Front_End_Attachment');
    // Remove the temporary filters
    remove_filter('bp_attachments_get_plupload_l10n', 'front_end_attachments_editor_strings', 10, 1);
    remove_filter('bp_attachments_get_plupload_default_settings', 'front_end_attachments_editor_settings', 10, 1);
    $url = remove_query_arg(array_keys($_REQUEST));
    ?>
	<a href="<?php 
    echo esc_url($url);
    ?>
#TB_inline?inlineId=front-end-attachments-modal" title="<?php 
    esc_attr_e('Add file', 'front-end-attachments');
    ?>
" id="front-end-attachments-btn" class="thickbox button">
		<?php 
    echo esc_html_e('Add File', 'front-end-attachments');
    ?>
	</a>
	<div id="front-end-attachments-modal" style="display:none;">
		<?php 
    /* Markup for the uploader */
    ?>
			<div class="fe-attachments-uploader"></div>
			<div class="fe-attachments-uploader-status"></div>

		<?php 
    bp_attachments_get_template_part('uploader');
    /* Markup for the uploader */
    ?>
	</div>
	<?php 
}