PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 16.3-a.1
Jetpack – WP Security, Backup, Speed, & Growth v16.3-a.1
16.3-a.3 16.3-a.1 16.2 16.2-beta 12.0.3 12.1.3 12.2.3 12.3.2 12.4.2 12.5.2 12.6.4 12.7.3 12.8.3 12.9.5 13.0.2 13.1.5 13.2.4 13.3.3 13.4.5 13.5.2 13.6.2 13.7.2 13.8.3 13.9.2 14.0.1 All 504 releases
← All changes | modules/shortcodes/archiveorg.php +40 -9 13.6.216.3-a.1 View file →
@@ -11,8 +11,12 @@
11 11 *
12 12 * @package automattic/jetpack
13 13 */
14 14
15 +if ( ! defined( 'ABSPATH' ) ) {
16 + exit( 0 );
17 +}
18 +
15 19 /**
16 20 * Get ID of requested archive.org embed.
17 21 *
18 22 * @since 4.5.0
@@ -55,8 +59,9 @@
55 59 'width' => 640,
56 60 'height' => 480,
57 61 'autoplay' => 0,
58 62 'poster' => '',
63 + 'playlist' => 0,
59 64 ),
60 65 $atts
61 66 );
62 67
@@ -65,8 +70,25 @@
65 70 }
66 71
67 72 $id = $atts['id'];
68 73
74 + // Allow extra query parameters to be baked into the identifier, e.g. "myitem&playlist=1" or "myitem?playlist=1".
75 + // In some environments a the_content filter encodes "&" to "&" before do_shortcode runs, so the
76 + // parser receives "myitem&playlist=1" — normalize that back before splitting. The sibling function
77 + // jetpack_archiveorg_embed_to_shortcode() splits on "&" for the same reason.
78 + $id = str_replace( '&', '&', $id );
79 + $id_extra_args = array();
80 + if ( preg_match( '/^([^?&]*)[?&](.*)$/', $id, $id_match ) ) {
81 + $id = $id_match[1];
82 + wp_parse_str( $id_match[2], $id_extra_args );
83 + }
84 +
85 + // Re-check after the split — an identifier that's only a query string (e.g. "?playlist=1") leaves $id empty
86 + // and would otherwise produce an item-less embed URL.
87 + if ( '' === $id ) {
88 + return '<!-- error: missing archive.org ID -->';
89 + }
90 +
69 91 if ( ! $atts['width'] ) {
70 92 $width = absint( $content_width );
71 93 } else {
72 94 $width = (int) $atts['width'];
@@ -77,24 +99,31 @@
77 99 } else {
78 100 $height = (int) $atts['height'];
79 101 }
80 102
103 + $query_args = array();
81 104 if ( $atts['autoplay'] ) {
82 - $autoplay = '&autoplay=1';
83 - } else {
84 - $autoplay = '';
105 + $query_args['autoplay'] = 1;
85 106 }
107 + if ( $atts['poster'] ) {
108 + $query_args['poster'] = $atts['poster'];
109 + }
110 + if ( $atts['playlist'] ) {
111 + $query_args['playlist'] = 1;
112 + }
86 113
87 - if ( $atts['poster'] ) {
88 - $poster = '&poster=' . $atts['poster'];
89 - } else {
90 - $poster = '';
114 + // Explicit shortcode attributes take precedence over query parameters baked into the identifier.
115 + $query_args = array_merge( $id_extra_args, $query_args );
116 +
117 + $url = 'https://archive.org/embed/' . $id;
118 + if ( ! empty( $query_args ) ) {
119 + $url = add_query_arg( $query_args, $url );
91 120 }
92 121
93 122 return sprintf(
94 123 '<div class="embed-archiveorg" style="text-align:center;"><iframe title="%s" src="%s" width="%s" height="%s" style="border:0;" webkitallowfullscreen="true" mozallowfullscreen="true" allowfullscreen></iframe></div>',
95 124 esc_attr__( 'Archive.org', 'jetpack' ),
96 - esc_url( "https://archive.org/embed/{$id}{$autoplay}{$poster}" ),
125 + esc_url( $url ),
97 126 esc_attr( $width ),
98 127 esc_attr( $height )
99 128 );
100 129 }
@@ -158,5 +187,7 @@
158 187
159 188 return $content;
160 189 }
161 190
162 -add_filter( 'pre_kses', 'jetpack_archiveorg_embed_to_shortcode' );
191 +if ( jetpack_shortcodes_should_hook_pre_kses() ) {
192 + add_filter( 'pre_kses', 'jetpack_archiveorg_embed_to_shortcode' );
193 +}