Bump to 1.4.0, made some fixes for 8.2+
This commit is contained in:
@ -197,3 +197,40 @@ require get_template_directory() . '/inc/metaboxes/mt-post-sidebar-meta.php';
|
||||
if ( ! function_exists( 'breadcrumb_trail' ) ) {
|
||||
require get_template_directory() . '/inc/mt-class-breadcrumbs.php';
|
||||
}
|
||||
|
||||
// Function to allow images in WordPress comments
|
||||
function allow_images_in_comments($comment_content) {
|
||||
// Allow only specific HTML tags, including <img>
|
||||
$allowed_tags = array(
|
||||
'a' => array('href' => array(), 'title' => array()),
|
||||
'em' => array(),
|
||||
'strong' => array(),
|
||||
'img' => array(
|
||||
'src' => array(),
|
||||
'alt' => array(),
|
||||
'width' => array(),
|
||||
'height' => array(),
|
||||
'class' => array(),
|
||||
),
|
||||
);
|
||||
|
||||
// Strip out disallowed tags but keep allowed ones
|
||||
return wp_kses($comment_content, $allowed_tags);
|
||||
}
|
||||
|
||||
// Hook to filter the comment text before displaying it
|
||||
add_filter('comment_text', 'allow_images_in_comments');
|
||||
|
||||
// Function to make URLs for images clickable in comments
|
||||
function clickable_images_in_comments($comment_content) {
|
||||
// Automatically convert image URLs to HTML <img> tags
|
||||
$comment_content = preg_replace(
|
||||
'/(http:\/\/[^\s"]+\.(jpg|jpeg|png|gif))/i',
|
||||
'<img src="$1" alt="" class="comment-image" />',
|
||||
$comment_content
|
||||
);
|
||||
return $comment_content;
|
||||
}
|
||||
|
||||
// Hook to make image URLs clickable
|
||||
add_filter('comment_text', 'clickable_images_in_comments');
|
||||
|
Reference in New Issue
Block a user