Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Respect the user profile language #175

Merged
merged 2 commits into from
Jan 6, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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