• Welcome to Tux Reports: Where Penguins Fly. We hope you find the topics varied, interesting, and worthy of your time. Please become a member and join in the discussions.

Temporary Fix For Avatars in WP 4.4

LPH

Flight Director
Flight Instructor
The following is only a temporary fix until all of the conditionals are working properly.

Filename: class-xenword-avatars.php

Replace the file contents with the following PHP code.

PHP:
<?php

/**
* Filename: class-xenword-avatars.php
*
* XenForo handles avatars
*
* @package    XenWord
* @subpackage WordPress/includes
*
* @since WordPress 4.4 the handling of Avatars has been changed
*/

/**
* This section is for security. Do not modify this part:
* @ignore
*/

if ( ! defined( 'ABSPATH' ) ) exit;

class XenWord_Avatars {

    public function construct() {
                $this->filters();
        }

        public function filters() {
        add_filter( 'get_avatar', array( $this, 'set_comment_avatar' ), 10, 5 );
    }

    private function set_avatar( $email, $size, $alt = '' ) {
        $avatar_img_output = $this->generate_avatar_img_tag( $avatar_uri, $size, $alt );
        return $avatar_img_output;
    }

    public function set_comment_avatar( $avatar, $id_or_email, $size = '96', $default = '', $alt = '' ) {
        $avatar_output = $this->set_avatar( $email, $size, $alt );
        return $avatar_output;
    }

    private function generate_avatar_img_tag( $avatar_uri, $size, $alt = '' ) {
        $output_data = "<img alt='{$alt}' src='{$avatar_uri}' class='avatar avatar-{$size} width='{$size}' height='{$size}' />";
        return $output_data;
    }
 
}

$xenword_avatars = new XenWord_Avatars();

/**
* Add Custom Avatar (Discussion Settings)
*
* @param $avatar_defaults
*
* @return mixed
* @throws Zend_Exception
*/
function xenword_avatar_defaults( $avatar_defaults ) {

    // Get Avatar from plugin folder
    $new_avatar = plugins_url( '../admin/images/xenforo_logo.og.png', __FILE__ );
    $avatar_defaults[$new_avatar] = "XenForo";

    // Remove default avatars
    //unset ( $avatar_defaults['mystery'] );
    //unset ( $avatar_defaults['blank'] );
    //unset ( $avatar_defaults['gravatar_default'] );
    //unset ( $avatar_defaults['identicon'] );
    //unset ( $avatar_defaults['wavatar'] );
    //unset ( $avatar_defaults['monsterid'] );
    //unset ( $avatar_defaults['retro'] );
    return $avatar_defaults;
}

add_filter( 'avatar_defaults', 'xenword_avatar_defaults' );

// End class-xenword-avatars.php

Create a new directory WordPress/admin/images
Upload the attached file xenforo_logo.og.png
Next, go to settings->discussions in the WordPress admin panel
Click on XenForo
Save settings

Expected Results:
Gravatars will load
The XenForo logo will be the default for anyone who uses an uploaded avatar in XenForo.
 

Attachments

  • xenforo_logo.og.png
    xenforo_logo.og.png
    1.2 KB · Views: 11
Last edited:
Top