Skip to content

Commit

Permalink
Merge pull request #175 from 10up/fix/157
Browse files Browse the repository at this point in the history
Respect the user profile language
  • Loading branch information
faisal-alvi authored Jan 6, 2023
2 parents c7b54df + 4187802 commit 0c0ecb0
Showing 1 changed file with 8 additions and 23 deletions.
31 changes: 8 additions & 23 deletions includes/class-simple-local-avatars.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,7 @@ public function __construct() {
$this->options = (array) get_option( 'simple_local_avatars' );
$this->user_key = 'simple_local_avatar';
$this->rating_key = 'simple_local_avatar_rating';
$this->avatar_ratings = array(
'G' => __( 'G — Suitable for all audiences', 'simple-local-avatars' ),
'PG' => __( 'PG — Possibly offensive, usually for audiences 13 and above', 'simple-local-avatars' ),
'R' => __( 'R — Intended for adult audiences above 17', 'simple-local-avatars' ),
'X' => __( 'X — Even more mature than above', 'simple-local-avatars' ),
);


if (
! $this->is_avatar_shared() // Are we sharing avatars?
&& (
Expand Down Expand Up @@ -512,6 +506,13 @@ public function get_default_avatar_url( $size ) {
* Register admin settings.
*/
public function admin_init() {
$this->avatar_ratings = array(
'G' => __( 'G — Suitable for all audiences', ),
'PG' => __( 'PG — Possibly offensive, usually for audiences 13 and above', ),
'R' => __( 'R — Intended for adult audiences above 17', ),
'X' => __( 'X — Even more mature than above', ),
);

// upgrade pre 2.0 option
$old_ops = get_option( 'simple_local_avatars_caps' );
if ( $old_ops ) {
Expand Down Expand Up @@ -917,8 +918,6 @@ public function edit_user_profile( $profileuser ) {
<fieldset id="simple-local-avatar-ratings" <?php disabled( empty( $profileuser->simple_local_avatar ) ); ?>>
<legend class="screen-reader-text"><span><?php esc_html_e( 'Rating' ); ?></span></legend>
<?php
$this->update_avatar_ratings();

if ( empty( $profileuser->simple_local_avatar_rating ) || ! array_key_exists( $profileuser->simple_local_avatar_rating, $this->avatar_ratings ) ) {
$profileuser->simple_local_avatar_rating = 'G';
}
Expand Down Expand Up @@ -1302,20 +1301,6 @@ public function admin_body_class( $classes ) {
return $classes;
}

/**
* Overwriting existing avatar_ratings so this can be called just before the rating strings would be used so that
* translations will work correctly.
* Default text-domain because the strings have already been translated
*/
private function update_avatar_ratings() {
$this->avatar_ratings = array(
'G' => __( 'G &#8212; Suitable for all audiences' ),
'PG' => __( 'PG &#8212; Possibly offensive, usually for audiences 13 and above' ),
'R' => __( 'R &#8212; Intended for adult audiences above 17' ),
'X' => __( 'X &#8212; Even more mature than above' ),
);
}

/**
* Clear user cache.
*/
Expand Down

0 comments on commit 0c0ecb0

Please sign in to comment.