Skip to content

Commit

Permalink
Move configuration of allowed HTML in labels to Tools\Template
Browse files Browse the repository at this point in the history
  • Loading branch information
mundschenk-at committed Aug 4, 2019
1 parent 5c97564 commit e8f341c
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 22 deletions.
11 changes: 1 addition & 10 deletions admin/partials/profile/allow-anonymous.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* This file is part of Avatar Privacy.
*
* Copyright 2018 Peter Putzer.
* Copyright 2018-2019 Peter Putzer.
* Copyright 2012-2013 Johannes Freudendahl.
*
* This program is free software; you can redistribute it and/or
Expand All @@ -25,15 +25,6 @@
* @license http://www.gnu.org/licenses/gpl-2.0.html
*/

// Allowed HTML tags in the checkbox label.
$allowed_html = [
'a' => [
'href' => true,
'rel' => true,
'target' => true,
],
];

?>
<tr class"avatar-privacy-allow-anonymous">
<th scope="row"><?php \esc_html_e( 'Logged-out Commenting', 'avatar-privacy' ); ?></th>
Expand Down
13 changes: 2 additions & 11 deletions admin/partials/profile/use-gravatar.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* This file is part of Avatar Privacy.
*
* Copyright 2018 Peter Putzer.
* Copyright 2018-2019 Peter Putzer.
* Copyright 2012-2013 Johannes Freudendahl.
*
* This program is free software; you can redistribute it and/or
Expand All @@ -27,15 +27,6 @@

use Avatar_Privacy\Tools\Template;

// Allowed HTML tags in the checkbox label.
$allowed_html = [
'a' => [
'href' => true,
'rel' => true,
'target' => true,
],
];

?>
<tr class"avatar-privacy-use-gravatar">
<th scope="row"><?php esc_html_e( 'Gravatars', 'avatar-privacy' ); ?></th>
Expand All @@ -48,7 +39,7 @@
value="true"
<?php checked( $use_gravatar ); ?>
/>
<label for="<?php echo esc_attr( self::CHECKBOX_FIELD_NAME ); ?>"><?php echo wp_kses( sprintf( /* translators: 1: gravatar.com URL, 2: rel attribute, 3: target attribute */ __( 'Display a <a href="%1$s" rel="%2$s" target="%3$s">Gravatar</a> image for my e-mail address.', 'avatar-privacy' ), __( 'https://en.gravatar.com/', 'avatar-privacy' ), Template::get_gravatar_link_rel(), Template::get_gravatar_link_target() ), $allowed_html ); ?></label><br />
<label for="<?php echo esc_attr( self::CHECKBOX_FIELD_NAME ); ?>"><?php echo wp_kses( sprintf( /* translators: 1: gravatar.com URL, 2: rel attribute, 3: target attribute */ __( 'Display a <a href="%1$s" rel="%2$s" target="%3$s">Gravatar</a> image for my e-mail address.', 'avatar-privacy' ), __( 'https://en.gravatar.com/', 'avatar-privacy' ), Template::get_gravatar_link_rel(), Template::get_gravatar_link_target() ), Template::ALLOWED_HTML_LABEL ); ?></label><br />
<p class="description">
<?php esc_html_e( "Uncheck this box if you don't want to display the gravatar for your e-mail address (or don't have an account on Gravatar.com).", 'avatar-privacy' ); ?>
<?php esc_html_e( 'This setting will only take effect if you have not uploaded a local profile picture.', 'avatar-privacy' ); ?>
Expand Down
2 changes: 1 addition & 1 deletion admin/partials/profile/user-avatar-upload.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
</p>
<?php endif; ?>
<p class="description">
<?php echo \wp_kses( $description, [ 'a' => [ 'href' => true ] ] ); ?>
<?php echo \wp_kses( $description, Template::ALLOWED_HTML_LABEL ); ?>
</p>
</td>
</tr>
Expand Down
13 changes: 13 additions & 0 deletions includes/avatar-privacy/tools/class-template.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,19 @@
*/
abstract class Template {

/**
* The allowed HTML tags and attributes for checkbox labels.
*
* @var array
*/
const ALLOWED_HTML_LABEL = [
'a' => [
'href' => true,
'rel' => true,
'target' => true,
],
];

/**
* Retrieves and filters the `rel` attribute for links to gravatar.com.
*
Expand Down

0 comments on commit e8f341c

Please sign in to comment.