| @@ -1,6 +1,12 @@ | ||
| 1 | 1 | <?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName |
| 2 | 2 | |
| 3 | +if ( ! defined( 'ABSPATH' ) ) { | |
| 4 | + exit( 0 ); | |
| 5 | +} | |
| 6 | + | |
| 7 | +use Automattic\Jetpack\VideoPress\Data as VideoPress_Data; | |
| 8 | + | |
| 3 | 9 | /** |
| 4 | 10 | * VideoPress Shortcode Handler |
| 5 | 11 | * |
| 6 | 12 | * This file may or may not be included from the Jetpack VideoPress module. |
| @@ -58,9 +64,9 @@ | ||
| 58 | 64 | |
| 59 | 65 | /** |
| 60 | 66 | * We only accept GUIDs as a first unnamed argument. |
| 61 | 67 | */ |
| 62 | - $guid = isset( $attr[0] ) ? $attr[0] : null; | |
| 68 | + $guid = $attr[0] ?? null; | |
| 63 | 69 | |
| 64 | 70 | if ( isset( $attr['postid'] ) ) { |
| 65 | 71 | $guid = get_post_meta( $attr['postid'], 'videopress_guid', true ); |
| 66 | 72 | } |
| @@ -103,8 +109,13 @@ | ||
| 103 | 109 | if ( isset( $attr['preload'] ) ) { |
| 104 | 110 | $attr['preloadcontent'] = $attr['preload']; |
| 105 | 111 | } |
| 106 | 112 | |
| 113 | + // The site-wide opt-out wins over the shortcode's own preload attribute. | |
| 114 | + if ( VideoPress_Data::get_videopress_player_preload_disabled() ) { | |
| 115 | + $attr['preloadcontent'] = 'none'; | |
| 116 | + } | |
| 117 | + | |
| 107 | 118 | $attr = shortcode_atts( $defaults, $attr, 'videopress' ); |
| 108 | 119 | |
| 109 | 120 | /** |
| 110 | 121 | * Cast the attributes, post-input. |
| @@ -126,9 +137,9 @@ | ||
| 126 | 137 | /** |
| 127 | 138 | * If there was an invalid or unspecified width, set the width equal to the theme's `$content_width`. |
| 128 | 139 | */ |
| 129 | 140 | if ( 0 === $attr['width'] && isset( $content_width ) && $content_width >= VIDEOPRESS_MIN_WIDTH ) { |
| 130 | - $attr['width'] = $content_width; | |
| 141 | + $attr['width'] = (int) $content_width; | |
| 131 | 142 | } |
| 132 | 143 | |
| 133 | 144 | /** |
| 134 | 145 | * If the width isn't an even number, reduce it by one (making it even). |