From bcf36bdf18c63640b7b03fe31b19bf0246ffe1e5 Mon Sep 17 00:00:00 2001 From: Jordan Schelew Date: Sun, 24 Jan 2016 11:21:33 -0600 Subject: [PATCH 1/3] Add feature: auto-embed of video links Uses WordPress wp_oembed_get function to auto-embed YouTube/Vimeo links etc. --- includes/views/single-listing.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/views/single-listing.php b/includes/views/single-listing.php index 6c2ae64..fb69569 100644 --- a/includes/views/single-listing.php +++ b/includes/views/single-listing.php @@ -196,7 +196,7 @@ function single_listing_post_content() { ID, '_listing_video', true) != '') { ?>
- ID, '_listing_video', true); ?> + ID, '_listing_video', true) ); ?>
From fd59cfcf0e7b8a8e1d4ae4c5637a85722490b462 Mon Sep 17 00:00:00 2001 From: Jordan Schelew Date: Sun, 24 Jan 2016 12:01:17 -0600 Subject: [PATCH 2/3] Improvements to auto-embedding videos MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Simplify code by introducing $video_url variable and updates to support a false return value from wp_oembed_get. Could probably still use better URL detection (such as if the admin enters a URL without the ‘http://' --- includes/views/single-listing.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/includes/views/single-listing.php b/includes/views/single-listing.php index fb69569..199a3e4 100644 --- a/includes/views/single-listing.php +++ b/includes/views/single-listing.php @@ -193,10 +193,14 @@ function single_listing_post_content() { - ID, '_listing_video', true) != '') { ?> + ID, '_listing_video', true) != '') { + $video_url = get_post_meta( $post->ID, '_listing_video', true); + ?>
- ID, '_listing_video', true) ); ?> + $video_url"; } ?>
From fb660f95acc34c5dc329a044f433ab133cdfacd6 Mon Sep 17 00:00:00 2001 From: Jordan Schelew Date: Sat, 26 Jan 2019 23:57:55 -0400 Subject: [PATCH 3/3] Also use esc_url to validate the URL prior to use Use esc_url as per wp codex. --- includes/views/single-listing.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/views/single-listing.php b/includes/views/single-listing.php index 199a3e4..ba3714b 100644 --- a/includes/views/single-listing.php +++ b/includes/views/single-listing.php @@ -194,7 +194,7 @@ function single_listing_post_content() { ID, '_listing_video', true) != '') { - $video_url = get_post_meta( $post->ID, '_listing_video', true); + $video_url = esc_url( get_post_meta( $post->ID, '_listing_video', true), array('http', 'https') ); ?>