From ecb7f871f99ead7a08a542c403cab4a61529e1db Mon Sep 17 00:00:00 2001 From: Krystie Date: Mon, 7 Sep 2026 17:09:48 -0700 Subject: [PATCH] [grade=B] v1.9.2: hide raw YouTube URL above the video card (strip first YT link from displayed text, preserve trailing punctuation) --- beep.php | 4 ++-- includes/class-quotes.php | 2 +- includes/helpers.php | 31 +++++++++++++++++++++++++++++-- readme.txt | 5 ++++- 4 files changed, 36 insertions(+), 6 deletions(-) diff --git a/beep.php b/beep.php index 6d47875..9e729b2 100755 --- a/beep.php +++ b/beep.php @@ -2,7 +2,7 @@ /** * Plugin Name: Beep * Description: A Twitter-style microblog for WordPress, with likes, replies, and Gravatars. Use the [beep_feed] shortcode on any page. - * Version: 1.9.1 + * Version: 1.9.2 * Requires at least: 6.0 * Requires PHP: 7.4 * Author: Sami Ahmed @@ -14,7 +14,7 @@ if (!defined('ABSPATH')) { exit; } -define('BEEP_VERSION', '1.9.1'); +define('BEEP_VERSION', '1.9.2'); define('BEEP_FILE', __FILE__); define('BEEP_DIR', plugin_dir_path(__FILE__)); define('BEEP_URL', plugin_dir_url(__FILE__)); diff --git a/includes/class-quotes.php b/includes/class-quotes.php index d320ded..7d9353e 100755 --- a/includes/class-quotes.php +++ b/includes/class-quotes.php @@ -71,7 +71,7 @@ class Beep_Quotes { $avatar = esc_url($author['avatar']); $name = esc_html($author['name']); $handle = esc_html('@' . $author['username']); - $content = make_clickable(wp_kses_post($quoted['content'])); + $content = make_clickable(wp_kses_post(beep_strip_youtube_link($quoted['content']))); $time = esc_html($quoted['time_ago']); $qid = esc_attr($quoted['id']); diff --git a/includes/helpers.php b/includes/helpers.php index f410f67..1905971 100755 --- a/includes/helpers.php +++ b/includes/helpers.php @@ -318,7 +318,7 @@ function beep_render_post($post, $args = []) { $time_iso = gmdate('c', $ts); $time_full = mysql2date('F j, Y g:i a', $post->post_date); - $content = beep_format_content($post->post_content); + $content = beep_format_content(beep_strip_youtube_link($post->post_content)); $like_count = Beep_Likes::get_count($post->ID, 'post'); $reply_count = Beep_Replies::reply_count($post->ID); $user_liked = Beep_Likes::user_has_liked($post->ID, 'post'); @@ -576,7 +576,7 @@ function beep_render_reply($comment, $all_comments = [], $depth = 0, $post_id = $time = beep_relative_time($ts); $time_iso = gmdate('c', $ts); - $content = beep_format_content($comment->comment_content); + $content = beep_format_content(beep_strip_youtube_link($comment->comment_content)); $can_delete = current_user_can('moderate_comments') || ($author_id && $author_id === get_current_user_id()); $like_count = Beep_Likes::get_count($comment->comment_ID, 'reply'); $user_liked = Beep_Likes::user_has_liked($comment->comment_ID, 'reply'); @@ -740,6 +740,33 @@ function beep_render_youtube_card($text) { . ''; } +/** + * Remove the first YouTube URL from text (the one that gets a video card), + * so the raw link doesn't display above the card. Returns text unchanged + * when no YouTube link is present. + */ +function beep_strip_youtube_link($text) { + $vid = beep_youtube_id_from_text($text); + if ($vid === '') { + return $text; + } + $stripped = preg_replace_callback( + '~(?