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

DEV: data-* attributes are now allowed by default #425

Merged
merged 3 commits into from
Nov 10, 2021
Merged
Show file tree
Hide file tree
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
28 changes: 0 additions & 28 deletions lib/discourse-comment.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ public function __construct( $comment_formatter ) {
add_filter( 'get_comments_number', array( $this, 'get_comments_number' ), 10, 2 );
add_action( 'wpdc_sync_discourse_comments', array( $this, 'sync_comments' ) );
add_filter( 'comments_template', array( $this, 'comments_template' ), 20, 1 );
add_filter( 'wp_kses_allowed_html', array( $this, 'extend_allowed_html' ), 10, 2 );
add_action( 'wp_enqueue_scripts', array( $this, 'discourse_comments_js' ) );
add_action( 'rest_api_init', array( $this, 'initialize_comment_route' ) );
}
Expand All @@ -80,33 +79,6 @@ public function setup_logger() {
$this->logger = Logger::create( 'comment' );
}

/**
* Adds data-youtube-id to the allowable div attributes.
*
* Discourse returns the youtube video id as the value of the 'data-youtube-attribute',
* this function makes it possible to filter the comments with `wp_kses_post` without
* stripping out that attribute.
*
* @param array $allowedposttags The array of allowed post tags.
* @param string $context The current context ('post', 'data', etc.).
*
* @return mixed
*/
public function extend_allowed_html( $allowedposttags, $context ) {
if ( 'post' === $context ) {
$allowedposttags['div'] = array(
'class' => true,
'id' => true,
'style' => true,
'title' => true,
'role' => true,
'data-youtube-id' => array(),
);
}

return $allowedposttags;
}

/**
* Enqueues the comment scripts and styles.
*
Expand Down
6 changes: 5 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Tags: discourse, forum, comments, sso
Requires at least: 4.7
Tested up to: 5.8
Requires PHP: 5.6.0
Stable tag: 2.3.3
Stable tag: 2.3.4
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Expand Down Expand Up @@ -123,6 +123,10 @@ To create a coherent top menu, see our tutorial on how to make a [Custom nav hea

== Changelog ==

#### 2.3.4 10/30/2021

- Improve comment HTML tag sanitization

#### 2.3.3 10/29/2021

- Update Discourse API key help text
Expand Down
4 changes: 2 additions & 2 deletions wp-discourse.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* Plugin Name: WP-Discourse
* Description: Use Discourse as a community engine for your WordPress blog
* Version: 2.3.3
* Version: 2.3.4
* Author: Discourse
* Text Domain: wp-discourse
* Domain Path: /languages
Expand Down Expand Up @@ -34,7 +34,7 @@
define( 'WPDISCOURSE_URL', plugins_url( '', __FILE__ ) );
define( 'MIN_WP_VERSION', '4.7' );
define( 'MIN_PHP_VERSION', '5.6.0' );
define( 'WPDISCOURSE_VERSION', '2.3.3' );
define( 'WPDISCOURSE_VERSION', '2.3.4' );

require_once WPDISCOURSE_PATH . 'lib/plugin-utilities.php';
require_once WPDISCOURSE_PATH . 'lib/template-functions.php';
Expand Down