summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/jetpack/modules/shortcodes/slideshow.php')
-rw-r--r--plugins/jetpack/modules/shortcodes/slideshow.php42
1 files changed, 32 insertions, 10 deletions
diff --git a/plugins/jetpack/modules/shortcodes/slideshow.php b/plugins/jetpack/modules/shortcodes/slideshow.php
index a3b99ac1..68357947 100644
--- a/plugins/jetpack/modules/shortcodes/slideshow.php
+++ b/plugins/jetpack/modules/shortcodes/slideshow.php
@@ -1,12 +1,13 @@
<?php //phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
use Automattic\Jetpack\Assets;
+use Automattic\Jetpack\Extensions\Slideshow;
/**
* Slideshow shortcode.
* Adds a new "slideshow" gallery type when adding a gallery using the classic editor.
*
- * @package Jetpack
+ * @package automattic/jetpack
*/
/**
@@ -112,7 +113,7 @@ class Jetpack_Slideshow_Shortcode {
}
// Don't restrict to the current post if include.
- $post_parent = ( empty( $attr['include'] ) ) ? intval( $attr['id'] ) : null;
+ $post_parent = ( empty( $attr['include'] ) ) ? (int) $attr['id'] : null;
$attachments = get_posts(
array(
@@ -163,13 +164,13 @@ class Jetpack_Slideshow_Shortcode {
);
}
- $color = Jetpack_Options::get_option( 'slideshow_background_color', 'black' );
-
- $js_attr = array(
+ $color = Jetpack_Options::get_option( 'slideshow_background_color', 'black' );
+ $autostart = $attr['autostart'] ? $attr['autostart'] : 'true';
+ $js_attr = array(
'gallery' => $gallery,
'selector' => $gallery_instance,
'trans' => $attr['trans'] ? $attr['trans'] : 'fade',
- 'autostart' => $attr['autostart'] ? $attr['autostart'] : 'true',
+ 'autostart' => $autostart,
'color' => $color,
);
@@ -182,6 +183,21 @@ class Jetpack_Slideshow_Shortcode {
);
}
+ if ( class_exists( 'Jetpack_AMP_Support' ) && Jetpack_AMP_Support::is_amp_request() ) {
+ // Load the styles and use the rendering method from the Slideshow block.
+ Jetpack_Gutenberg::load_styles_as_required( 'slideshow' );
+
+ $amp_args = array(
+ 'ids' => wp_list_pluck( $gallery, 'id' ),
+ );
+
+ if ( 'true' == $autostart ) { // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- attribute can be stored as boolean or string.
+ $amp_args['autoplay'] = true;
+ }
+
+ return Slideshow\render_amp( $amp_args );
+ }
+
return $this->slideshow_js( $js_attr );
}
@@ -279,14 +295,20 @@ class Jetpack_Slideshow_Shortcode {
* @since 4.7.0 Added the `speed` option to the array of options.
*
* @param array $args
- * - string - spinner - URL of the spinner image.
- * - string - speed - Speed of the slideshow. Defaults to 4000.
+ * - string - spinner - URL of the spinner image.
+ * - string - speed - Speed of the slideshow. Defaults to 4000.
+ * - string - label_prev - Aria label for slideshow's previous button
+ * - string - label_stop - Aria label for slideshow's pause button
+ * - string - label_next - Aria label for slideshow's next button
*/
apply_filters(
'jetpack_js_slideshow_settings',
array(
- 'spinner' => plugins_url( '/img/slideshow-loader.gif', __FILE__ ),
- 'speed' => '4000',
+ 'spinner' => plugins_url( '/img/slideshow-loader.gif', __FILE__ ),
+ 'speed' => '4000',
+ 'label_prev' => __( 'Previous Slide', 'jetpack' ),
+ 'label_stop' => __( 'Pause Slideshow', 'jetpack' ),
+ 'label_next' => __( 'Next Slide', 'jetpack' ),
)
)
);