Hi,
I am not a coder and therefore I cannot provide any further support to the following.
If you want to use translation files for this plugin that work in the back- and front-end, then you will need to do add the following code to the init.php (version 1.0.0), at least it worked for me:
Have a look at the parts that start with “Author: snowbeachking”.
class basic_user_avatars {
private $user_id_being_edited;
/**
* Initialize all the things
*
* @since 1.0.0
*/
public function __construct() {
// Actions
add_action( 'admin_init', array( $this, 'admin_init' ) );
add_action( 'show_user_profile', array( $this, 'edit_user_profile' ) );
add_action( 'edit_user_profile', array( $this, 'edit_user_profile' ) );
add_action( 'personal_options_update', array( $this, 'edit_user_profile_update' ) );
add_action( 'edit_user_profile_update', array( $this, 'edit_user_profile_update' ) );
add_action( 'bbp_user_edit_after_about', array( $this, 'bbpress_user_profile' ) );
// Author: snowbeachking
// Calling load_plugin_textdomain() during the init action and not earlier.
add_action( 'init', array( $this, 'load_plugin_textdomain' ) );
// Shortcode
add_shortcode( 'basic-user-avatars', array( $this, 'shortcode' ) );
// Filters
add_filter( 'get_avatar', array( $this, 'get_avatar' ), 10, 5 );
add_filter( 'avatar_defaults', array( $this, 'avatar_defaults' ) );
}
/**
* Start the admin engine.
*
* @since 1.0.0
*/
public function admin_init() {
/**
* Author: snowbeachking
* Disabled, because by the time you want to hook into the load_textdomain() function, it will be
* too late already since the load_plugin_textdomain() call gets done immediately when the plugin
* is loaded.
* That is why we call load_plugin_textdomain() during the init action and not earlier.
*/
// Load the textdomain so we can support other languages
// load_plugin_textdomain( 'basic-user-avatars', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
// Register/add the Discussion setting to restrict avatar upload capabilites
register_setting( 'discussion', 'basic_user_avatars_caps', array( $this, 'sanitize_options' ) );
add_settings_field( 'basic-user-avatars-caps', __( 'Local Avatar Permissions', 'basic-user-avatars' ), array( $this, 'avatar_settings_field' ), 'discussion', 'avatars' );
}
/**
* Author: snowbeachking
* load_plugin_textdomain() is called and gets told to load the applicable mo-files from the
* subdirectory languages of the plugin’s directory or the default WordPress languages directory for
* plugin translations.
*/
public function load_plugin_textdomain() {
load_plugin_textdomain( 'basic-user-avatars', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
}