Skip to:
Content

BuddyPress.org

Changeset 9759


Ignore:
Timestamp:
04/16/2015 10:54:11 PM (5 years ago)
Author:
imath
Message:

Avatar UI: use it in wp-admin/extended profile.

Clicking on the "Edit Profile Photo" link from the avatar metabox will open a thickbox window in which the Avatar UI will be displayed.

See #6290

Location:
trunk/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-members/admin/css/admin-rtl.css

    r8958 r9759  
    2626div#community-profile-page li.bp-groups-profile-stats:before,
    2727div#community-profile-page li.bp-blogs-profile-stats:before,
    28 div#community-profile-page a.bp-xprofile-avatar-user-admin:before {
     28div#community-profile-page a.bp-xprofile-avatar-user-admin:before,
     29div#community-profile-page a.bp-xprofile-avatar-user-edit:before {
    2930    font: normal 20px/1 'dashicons';
    3031    speak: none;
     
    5960div#community-profile-page a.bp-xprofile-avatar-user-admin:before {
    6061    content:"\f182";
     62}
     63
     64div#community-profile-page a.bp-xprofile-avatar-user-edit:before {
     65    content: "\f107";
    6166}
    6267
  • trunk/src/bp-members/admin/css/admin.css

    r8958 r9759  
    2626div#community-profile-page li.bp-groups-profile-stats:before,
    2727div#community-profile-page li.bp-blogs-profile-stats:before,
    28 div#community-profile-page a.bp-xprofile-avatar-user-admin:before {
     28div#community-profile-page a.bp-xprofile-avatar-user-admin:before,
     29div#community-profile-page a.bp-xprofile-avatar-user-edit:before {
    2930    font: normal 20px/1 'dashicons';
    3031    speak: none;
     
    5960div#community-profile-page a.bp-xprofile-avatar-user-admin:before {
    6061    content:"\f182";
     62}
     63
     64div#community-profile-page a.bp-xprofile-avatar-user-edit:before {
     65    content: "\f107";
    6166}
    6267
  • trunk/src/bp-members/bp-members-admin.php

    r9665 r9759  
    218218     */
    219219    private function get_user_id() {
    220         $user_id = get_current_user_id();
    221 
    222         // We'll need a user ID when not on the user admin
     220        if ( ! empty( $this->user_id ) ) {
     221            return $this->user_id;
     222        }
     223
     224        $this->user_id = (int) get_current_user_id();
     225
     226        // We'll need a user ID when not on self profile
    223227        if ( ! empty( $_GET['user_id'] ) ) {
    224             $user_id = $_GET['user_id'];
    225         }
    226 
    227         return intval( $user_id );
     228            $this->user_id = (int) $_GET['user_id'];
     229        }
     230
     231        return $this->user_id;
    228232    }
    229233
  • trunk/src/bp-xprofile/bp-xprofile-admin.php

    r9691 r9759  
    674674     */
    675675    private function setup_actions() {
     676        // Enqueue scripts
     677        add_action( 'bp_members_admin_enqueue_scripts',  array( $this, 'enqueue_scripts'    ), 10, 1 );
    676678
    677679        // Register the metabox in Member's community admin profile
     
    680682        // Saves the profile actions for user ( avatar, profile fields )
    681683        add_action( 'bp_members_admin_update_user',      array( $this, 'user_admin_load'    ), 10, 4 );
     684    }
     685
     686    /**
     687     * Enqueue needed scripts.
     688     *
     689     * @access public
     690     * @since BuddyPress (2.3.0)
     691     */
     692    public function enqueue_scripts( $screen_id ) {
     693        if ( ( false === strpos( $screen_id, 'users_page_bp-profile-edit' ) && false === strpos( $screen_id, 'profile_page_bp-profile-edit' ) ) || bp_core_get_root_option( 'bp-disable-avatar-uploads' ) ) {
     694            return;
     695        }
     696
     697        /**
     698         * Get Thickbox
     699         *
     700         * We cannot simply use add_thickbox() here as WordPress is not playing
     701         * nice with Thickbox width/height see https://core.trac.wordpress.org/ticket/17249
     702         * Using media-upload might be interesting in the future for the send to editor stuff
     703         * and we make sure the tb_window is wide enougth
     704         */
     705        wp_enqueue_style ( 'thickbox' );
     706        wp_enqueue_script( 'media-upload' );
     707
     708        // Get Avatar Uploader
     709        bp_attachments_enqueue_scripts( 'BP_Attachment_Avatar' );
    682710    }
    683711
     
    10381066                <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>
    10391067
     1068            <?php endif;
     1069
     1070            // Load the Avatar UI templates if user avatar uploads are enabled
     1071            if ( ! bp_core_get_root_option( 'bp-disable-avatar-uploads' ) ) : ?>
     1072                <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>
     1073                <div id="bp-xprofile-avatar-editor" style="display:none;">
     1074                    <?php bp_attachments_get_template_part( 'avatars/index' ); ?>
     1075                </div>
    10401076            <?php endif; ?>
    10411077
Note: See TracChangeset for help on using the changeset viewer.