Skip to content

Commit 035af35

Browse files
author
Yoast
committed
Updates to 14.9
1 parent 3031f38 commit 035af35

File tree

249 files changed

+1700
-1006
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

249 files changed

+1700
-1006
lines changed

classes/class-wpseo-meta-video.php

Lines changed: 12 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@
2121
*
2222
* {@internal WPSEO_Meta is a class with only static methods, so we will not extend it with
2323
* a child class, we will only add to it by hooking in.}
24-
*
25-
* @phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedClassFound -- This actually extends / builds upon WPSEO_Meta, so it sorta makes sense.
2624
*/
2725
class WPSEO_Meta_Video {
2826

@@ -146,13 +144,13 @@ class WPSEO_Meta_Video {
146144
* @return void
147145
*/
148146
public static function init() {
149-
add_filter( 'add_extra_wpseo_meta_fields', [ __CLASS__, 'register_video_meta_fields' ] );
150-
add_filter( 'wpseo_metabox_entries_video', [ __CLASS__, 'adjust_video_meta_field_defs' ], 10, 2 );
147+
add_filter( 'add_extra_wpseo_meta_fields', [ self::class, 'register_video_meta_fields' ] );
148+
add_filter( 'wpseo_metabox_entries_video', [ self::class, 'adjust_video_meta_field_defs' ], 10, 2 );
151149

152-
add_filter( 'wpseo_sanitize_post_meta_' . WPSEO_Meta::$meta_prefix . 'videositemap-duration', [ __CLASS__, 'sanitize_duration' ], 10, 3 );
153-
add_filter( 'wpseo_sanitize_post_meta_' . WPSEO_Meta::$meta_prefix . 'videositemap-rating', [ __CLASS__, 'sanitize_rating' ], 10, 3 );
154-
add_filter( 'wpseo_sanitize_post_meta_' . WPSEO_Meta::$meta_prefix . 'videositemap-thumbnail', [ __CLASS__, 'sanitize_thumbnail_upload' ], 10, 3 );
155-
add_filter( 'wpseo_sanitize_post_meta_' . WPSEO_Meta::$meta_prefix . 'video_meta', [ __CLASS__, 'sanitize_video_meta' ], 10, 2 );
150+
add_filter( 'wpseo_sanitize_post_meta_' . WPSEO_Meta::$meta_prefix . 'videositemap-duration', [ self::class, 'sanitize_duration' ], 10, 3 );
151+
add_filter( 'wpseo_sanitize_post_meta_' . WPSEO_Meta::$meta_prefix . 'videositemap-rating', [ self::class, 'sanitize_rating' ], 10, 3 );
152+
add_filter( 'wpseo_sanitize_post_meta_' . WPSEO_Meta::$meta_prefix . 'videositemap-thumbnail', [ self::class, 'sanitize_thumbnail_upload' ], 10, 3 );
153+
add_filter( 'wpseo_sanitize_post_meta_' . WPSEO_Meta::$meta_prefix . 'video_meta', [ self::class, 'sanitize_video_meta' ], 10, 2 );
156154
}
157155

158156
/**
@@ -281,40 +279,14 @@ public static function sanitize_video_meta( $clean, $meta_value ) {
281279

282280
/**
283281
* Upgrade routine to deal with the fall-out of issue #102
282+
*
283+
* @deprecated 14.9
284+
* @codeCoverageIgnore
285+
*
286+
* @return void
284287
*/
285288
public static function re_add_durations() {
286-
global $wpdb;
287-
288-
// phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- Only runs on upgrade, only gets data.
289-
$query = $wpdb->prepare(
290-
"SELECT post_id, meta_value
291-
FROM {$wpdb->postmeta}
292-
WHERE meta_key = %s",
293-
WPSEO_Meta::$meta_prefix . 'video_meta'
294-
);
295-
$video_metas = $wpdb->get_results( $query ); // phpcs:ignore WordPress.DB.PreparedSQL -- Correctly prepared above.
296-
297-
$query = $wpdb->prepare(
298-
"SELECT post_id
299-
FROM {$wpdb->postmeta}
300-
WHERE meta_key = %s",
301-
WPSEO_Meta::$meta_prefix . 'videositemap-duration'
302-
);
303-
$known_durations = $wpdb->get_col( $query ); // phpcs:ignore WordPress.DB.PreparedSQL -- Correctly prepared above.
304-
// phpcs:enable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
305-
306-
if ( is_array( $video_metas ) && $video_metas !== [] ) {
307-
foreach ( $video_metas as $video ) {
308-
if ( $known_durations === [] || ! in_array( $video->post_id, $known_durations, true ) ) {
309-
$meta = maybe_unserialize( $video->meta_value );
310-
if ( isset( $meta['duration'] ) ) {
311-
WPSEO_Meta::set_value( 'videositemap-duration', $meta['duration'], $video->post_id );
312-
}
313-
unset( $meta );
314-
}
315-
}
316-
}
317-
unset( $query, $video_metas, $known_durations, $video );
289+
_deprecated_function( __METHOD__, 'Yoast Video SEO 14.9' );
318290
}
319291
}
320292
}

classes/class-wpseo-option-video.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818

1919
/**
2020
* Class WPSEO_Option_Video
21-
*
22-
* @phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedClassFound -- This actually extends / builds upon WPSEO_Option, so it sorta makes sense.
2321
*/
2422
class WPSEO_Option_Video extends WPSEO_Option {
2523

@@ -35,7 +33,7 @@ class WPSEO_Option_Video extends WPSEO_Option {
3533
*
3634
* Shouldn't be requested directly, use $this->get_defaults();
3735
*
38-
* @var array
36+
* @var array<string, int|bool|string|array<mixed>>
3937
*/
4038
protected $defaults = [
4139
// Non-form fields, set via validation routine / license activation method.
@@ -71,6 +69,8 @@ public static function get_instance() {
7169

7270
/**
7371
* Registers the option with the options framework.
72+
*
73+
* @return void
7474
*/
7575
public static function register_option() {
7676
WPSEO_Options::register_option( self::get_instance() );
@@ -88,11 +88,11 @@ public function enrich_defaults() {
8888
/**
8989
* Validate the option
9090
*
91-
* @param array $dirty New value for the option.
92-
* @param array $clean Clean value for the option, normally the defaults.
93-
* @param array $old Old value of the option.
91+
* @param array<string, mixed> $dirty New value for the option.
92+
* @param array<string, mixed> $clean Clean value for the option, normally the defaults.
93+
* @param array<string, mixed> $old Old value of the option.
9494
*
95-
* @return array Validated clean value for the option to be saved to the database
95+
* @return array<string, mixed> Validated clean value for the option to be saved to the database
9696
*/
9797
protected function validate_option( $dirty, $clean, $old ) {
9898

classes/class-wpseo-video-admin-page.php

Lines changed: 56 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,14 @@ class WPSEO_Video_Admin_Page {
2626
* Renders the admin page.
2727
*
2828
* @param string $sitemap_url The url to the sitemap.
29+
*
30+
* @return void
2931
*/
3032
public function display( $sitemap_url ) {
3133
$page = null;
3234
// phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Reason: We are not processing form information.
3335
if ( isset( $_GET['page'] ) && is_string( $_GET['page'] ) ) {
34-
// phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Reason: We are not processing form information, We are only strictly comparing and thus no need to sanitize.
36+
// phpcs:ignore WordPress.Security.NonceVerification.Recommended,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Reason: We are not processing form information, We are only strictly comparing and thus no need to sanitize.
3537
$page = wp_unslash( $_GET['page'] );
3638
}
3739

@@ -41,92 +43,89 @@ public function display( $sitemap_url ) {
4143

4244
Yoast_Form::get_instance()->admin_header( true, 'wpseo_video' );
4345

44-
// phpcs:ignore WordPress.Security.NonceVerification.Missing -- only loads a page, doesn't do any actions by itself.
46+
// phpcs:ignore WordPress.Security.NonceVerification.Missing -- only loads a page, doesn't do any actions by itself.
4547
if ( isset( $_POST['reindex'] ) ) {
4648
/*
4749
* Load the reindex page, shows a progressbar and sents ajax calls to the server with
4850
* small amounts of posts to reindex.
4951
*/
5052
require plugin_dir_path( WPSEO_VIDEO_FILE ) . 'views/reindex-page.php';
5153
}
54+
elseif ( WPSEO_Options::get( 'enable_xml_sitemap', false ) !== true ) {
55+
printf(
56+
'<p>%s</p>',
57+
sprintf(
58+
/* translators: 1: link open tag; 2: link close tag. */
59+
esc_html__( 'Please enable XML sitemaps in Yoast SEO > Settings > %1$sSite features%2$s.', 'yoast-video-seo' ),
60+
'<a href="' . esc_url( admin_url( '/admin.php?page=wpseo_page_settings#/site-features#card-wpseo-enable_xml_sitemap' ) ) . '">',
61+
'</a>'
62+
)
63+
);
64+
}
5265
else {
53-
if ( WPSEO_Options::get( 'enable_xml_sitemap', false ) !== true ) {
54-
printf(
55-
'<p>%s</p>',
56-
sprintf(
57-
/* translators: 1: link open tag; 2: link close tag. */
58-
esc_html__( 'Please enable XML sitemaps in Yoast SEO > Settings > %1$sSite features%2$s.', 'yoast-video-seo' ),
59-
'<a href="' . esc_url( admin_url( '/admin.php?page=wpseo_page_settings#/site-features#card-wpseo-enable_xml_sitemap' ) ) . '">',
60-
'</a>'
61-
)
62-
);
66+
echo '<h2>' . esc_html__( 'General Settings', 'yoast-video-seo' ) . '</h2>';
67+
if ( $sitemap_url !== null ) {
68+
echo '<p>' . esc_html__( 'Please find your video sitemap here:', 'yoast-video-seo' ) . ' <a target="_blank" href="' . esc_url( $sitemap_url ) . '">' . esc_html__( 'XML Video Sitemap', 'yoast-video-seo' ) . '</a></p>';
6369
}
6470
else {
65-
echo '<h2>' . esc_html__( 'General Settings', 'yoast-video-seo' ) . '</h2>';
66-
if ( $sitemap_url !== null ) {
67-
echo '<p>' . esc_html__( 'Please find your video sitemap here:', 'yoast-video-seo' ) . ' <a target="_blank" href="' . esc_url( $sitemap_url ) . '">' . esc_html__( 'XML Video Sitemap', 'yoast-video-seo' ) . '</a></p>';
68-
}
69-
else {
70-
echo '<div class="notice notice-warning"><p>' . esc_html__( 'Select at least one post type to enable the video sitemap.', 'yoast-video-seo' ) . '</p></div>';
71-
}
72-
73-
Yoast_Form::get_instance()->checkbox( 'video_cloak_sitemap', esc_html__( 'Hide the sitemap from normal visitors?', 'yoast-video-seo' ) );
74-
Yoast_Form::get_instance()->checkbox( 'video_disable_rss', esc_html__( 'Disable Media RSS Enhancement', 'yoast-video-seo' ) );
75-
echo '<br class="clear"/>';
76-
77-
Yoast_Form::get_instance()->textinput( 'video_custom_fields', esc_html__( 'Custom fields', 'yoast-video-seo' ) );
78-
echo '<p class="clear description desc label">' . esc_html__( 'Custom fields the plugin should check for video content (comma separated)', 'yoast-video-seo' ) . '</p>';
79-
Yoast_Form::get_instance()->textinput( 'video_embedly_api_key', esc_html__( '(Optional) Embedly API Key', 'yoast-video-seo' ) );
80-
/* translators: 1,3: link open tag; 2: link close tag. */
81-
echo '<p class="clear description desc label">' . sprintf( esc_html__( 'The video SEO plugin provides where possible enriched information about your videos. A lot of %1$svideo services%2$s are supported by default. For those services which aren\'t supported, we can try to retrieve enriched video information using %3$sEmbedly%2$s. If you want to use this option, you\'ll need to sign up for a (free) %3$sEmbedly%2$s account and provide the API key you receive.', 'yoast-video-seo' ), '<a href="' . esc_url( WPSEO_Shortlinker::get( 'https://yoa.st/video-hosting' ) ) . '">', '</a>', '<a href="http://embed.ly/">' ) . '</p>';
82-
83-
84-
echo '<h2>' . esc_html__( 'Embed Settings', 'yoast-video-seo' ) . '</h2>';
71+
echo '<div class="notice notice-warning"><p>' . esc_html__( 'Select at least one post type to enable the video sitemap.', 'yoast-video-seo' ) . '</p></div>';
72+
}
8573

86-
Yoast_Form::get_instance()->checkbox( 'video_facebook_embed', esc_html__( 'Allow videos to be played directly on other websites, such as Facebook or Twitter?', 'yoast-video-seo' ) );
87-
/* translators: 1: link open tag, 2: link close tag. */
88-
Yoast_Form::get_instance()->checkbox( 'video_fitvids', sprintf( esc_html__( 'Try to make videos responsive using %1$sFitVids.js%2$s?', 'yoast-video-seo' ), '<a href="http://fitvidsjs.com/">', '</a>' ) );
74+
Yoast_Form::get_instance()->checkbox( 'video_cloak_sitemap', esc_html__( 'Hide the sitemap from normal visitors?', 'yoast-video-seo' ) );
75+
Yoast_Form::get_instance()->checkbox( 'video_disable_rss', esc_html__( 'Disable Media RSS Enhancement', 'yoast-video-seo' ) );
76+
echo '<br class="clear"/>';
8977

90-
Yoast_Form::get_instance()->checkbox( 'video_youtube_faster_embed', esc_html__( 'YouTube embeds: make pages load faster by only loading the YouTube player when the user clicks play.', 'yoast-video-seo' ) );
91-
echo '<br class="clear"/>';
78+
Yoast_Form::get_instance()->textinput( 'video_custom_fields', esc_html__( 'Custom fields', 'yoast-video-seo' ) );
79+
echo '<p class="clear description desc label">' . esc_html__( 'Custom fields the plugin should check for video content (comma separated)', 'yoast-video-seo' ) . '</p>';
80+
Yoast_Form::get_instance()->textinput( 'video_embedly_api_key', esc_html__( '(Optional) Embedly API Key', 'yoast-video-seo' ) );
81+
/* translators: 1,3: link open tag; 2: link close tag. */
82+
echo '<p class="clear description desc label">' . sprintf( esc_html__( 'The video SEO plugin provides where possible enriched information about your videos. A lot of %1$svideo services%2$s are supported by default. For those services which aren\'t supported, we can try to retrieve enriched video information using %3$sEmbedly%2$s. If you want to use this option, you\'ll need to sign up for a (free) %3$sEmbedly%2$s account and provide the API key you receive.', 'yoast-video-seo' ), '<a href="' . esc_url( WPSEO_Shortlinker::get( 'https://yoa.st/video-hosting' ) ) . '">', '</a>', '<a href="http://embed.ly/">' ) . '</p>';
9283

93-
Yoast_Form::get_instance()->textinput( 'video_content_width', esc_html__( 'Content width', 'yoast-video-seo' ) );
94-
echo '<p class="clear description desc label">' . esc_html__( 'This defaults to your themes content width, but if it\'s empty, setting a value here will make sure videos are embedded in the right width.', 'yoast-video-seo' ) . '</p>';
84+
echo '<h2>' . esc_html__( 'Embed Settings', 'yoast-video-seo' ) . '</h2>';
9585

96-
Yoast_Form::get_instance()->textinput( 'video_wistia_domain', esc_html__( 'Wistia domain', 'yoast-video-seo' ) );
97-
echo '<p class="clear description desc label">' . esc_html__( 'If you use Wistia in combination with a custom domain, set this to the domain name you use for your Wistia videos, no http: or slashes needed.', 'yoast-video-seo' ) . '</p>';
86+
Yoast_Form::get_instance()->checkbox( 'video_facebook_embed', esc_html__( 'Allow videos to be played directly on other websites, such as Facebook or X?', 'yoast-video-seo' ) );
87+
/* translators: 1: link open tag, 2: link close tag. */
88+
Yoast_Form::get_instance()->checkbox( 'video_fitvids', sprintf( esc_html__( 'Try to make videos responsive using %1$sFitVids.js%2$s?', 'yoast-video-seo' ), '<a href="http://fitvidsjs.com/">', '</a>' ) );
9889

90+
Yoast_Form::get_instance()->checkbox( 'video_youtube_faster_embed', esc_html__( 'YouTube embeds: make pages load faster by only loading the YouTube player when the user clicks play.', 'yoast-video-seo' ) );
91+
echo '<br class="clear"/>';
9992

100-
echo '<h2>' . esc_html__( 'Post Types for which to enable the Video SEO plugin', 'yoast-video-seo' ) . '</h2>';
101-
echo '<p>' . esc_html__( 'Determine which post types on your site might contain video.', 'yoast-video-seo' ) . '</p>';
93+
Yoast_Form::get_instance()->textinput( 'video_content_width', esc_html__( 'Content width', 'yoast-video-seo' ) );
94+
echo '<p class="clear description desc label">' . esc_html__( 'This defaults to your themes content width, but if it\'s empty, setting a value here will make sure videos are embedded in the right width.', 'yoast-video-seo' ) . '</p>';
10295

96+
Yoast_Form::get_instance()->textinput( 'video_wistia_domain', esc_html__( 'Wistia domain', 'yoast-video-seo' ) );
97+
echo '<p class="clear description desc label">' . esc_html__( 'If you use Wistia in combination with a custom domain, set this to the domain name you use for your Wistia videos, no http: or slashes needed.', 'yoast-video-seo' ) . '</p>';
10398

104-
$post_types = get_post_types( [ 'public' => true ], 'objects' );
105-
$post_types_list = [];
106-
foreach ( $post_types as $post_type ) {
107-
$post_types_list[ $post_type->name ] = $post_type->labels->name;
108-
}
99+
echo '<h2>' . esc_html__( 'Post Types for which to enable the Video SEO plugin', 'yoast-video-seo' ) . '</h2>';
100+
echo '<p>' . esc_html__( 'Determine which post types on your site might contain video.', 'yoast-video-seo' ) . '</p>';
109101

110-
Yoast_Form::get_instance()->checkbox_list( 'videositemap_posttypes', $post_types_list );
102+
$post_types = get_post_types( [ 'public' => true ], 'objects' );
103+
$post_types_list = [];
104+
foreach ( $post_types as $post_type ) {
105+
$post_types_list[ $post_type->name ] = $post_type->labels->name;
106+
}
111107

112-
echo '<h2>' . esc_html__( 'Taxonomies to include in XML Video Sitemap', 'yoast-video-seo' ) . '</h2>';
113-
echo '<p>' . esc_html__( 'You can also include your taxonomy archives, for instance, if you have videos on a category page.', 'yoast-video-seo' ) . '</p>';
108+
Yoast_Form::get_instance()->checkbox_list( 'videositemap_posttypes', $post_types_list );
114109

115-
$taxonomies = get_taxonomies( [ 'public' => true ], 'objects' );
116-
$taxonomies_list = [];
117-
foreach ( $taxonomies as $taxonomy ) {
118-
$taxonomies_list[ $taxonomy->name ] = $taxonomy->labels->name;
119-
}
110+
echo '<h2>' . esc_html__( 'Taxonomies to include in XML Video Sitemap', 'yoast-video-seo' ) . '</h2>';
111+
echo '<p>' . esc_html__( 'You can also include your taxonomy archives, for instance, if you have videos on a category page.', 'yoast-video-seo' ) . '</p>';
120112

121-
Yoast_Form::get_instance()->checkbox_list( 'videositemap_taxonomies', $taxonomies_list );
113+
$taxonomies = get_taxonomies( [ 'public' => true ], 'objects' );
114+
$taxonomies_list = [];
115+
foreach ( $taxonomies as $taxonomy ) {
116+
$taxonomies_list[ $taxonomy->name ] = $taxonomy->labels->name;
122117
}
118+
119+
Yoast_Form::get_instance()->checkbox_list( 'videositemap_taxonomies', $taxonomies_list );
123120
}
124121
// Add debug info.
125122
Yoast_Form::get_instance()->admin_footer( true, false );
126123
}
127124

128125
/**
129126
* Adds the reindexing form for videos.
127+
*
128+
* @return void
130129
*/
131130
public function reindex_videos_form() {
132131
?>

classes/class-wpseo-video-bootstrap.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,9 @@ protected function add_integration_hooks() {
8484

8585
$editor_reactification_alert = new WPSEO_Video_Editor_Reactification_Alert();
8686
$editor_reactification_alert->register_hooks();
87+
88+
$translationspress = new WPSEO_Video_TranslationsPress( YoastSEO()->helpers->date );
89+
$translationspress->register_hooks();
8790
}
8891

8992
/**
@@ -377,7 +380,7 @@ protected function is_spl_autoload_available() {
377380
* @return bool True if WordPress is at a minimal required version.
378381
*/
379382
protected function is_wordpress_up_to_date() {
380-
return version_compare( $GLOBALS['wp_version'], '6.1', '>=' );
383+
return version_compare( $GLOBALS['wp_version'], '6.4', '>=' );
381384
}
382385

383386
/**
@@ -395,7 +398,7 @@ public function is_yoast_seo_active() {
395398
* @return bool True if Yoast SEO is at a minimal required version.
396399
*/
397400
protected function is_yoast_seo_up_to_date() {
398-
return $this->is_yoast_seo_active() && version_compare( WPSEO_VERSION, '20.13-RC0', '>=' );
401+
return $this->is_yoast_seo_active() && version_compare( WPSEO_VERSION, '22.8-RC0', '>=' );
399402
}
400403

401404
/**

classes/class-wpseo-video-embed.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,12 @@ public function set_high_res_default_image() {
4343
div.setAttribute( "data-id", youtubePlayers[ i ].dataset.id );
4444
div.setAttribute( "tabindex", "0" );
4545
div.setAttribute( "role", "button" );
46-
div.setAttribute( "aria-label", "' . esc_attr__( 'Load YouTube video', 'yoast-video-seo' ) . '" );
46+
div.setAttribute(
47+
"aria-label", "'
48+
/* translators: Hidden accessibility text. */
49+
. esc_attr__( 'Load YouTube video', 'yoast-video-seo' )
50+
. '"
51+
);
4752
div.innerHTML = videoSEOGenerateYouTubeThumbnail( youtubePlayers[ i ].dataset.id );
4853
div.addEventListener( "click", videoSEOGenerateYouTubeIframe );
4954
div.addEventListener( "keydown", videoSEOYouTubeThumbnailHandleKeydown );

0 commit comments

Comments
 (0)