| @@ -6,13 +6,26 @@ | ||
| 6 | 6 | */ |
| 7 | 7 | |
| 8 | 8 | use Automattic\Jetpack\Assets; |
| 9 | 9 | |
| 10 | +if ( ! defined( 'ABSPATH' ) ) { | |
| 11 | + exit( 0 ); | |
| 12 | +} | |
| 13 | + | |
| 10 | 14 | /** |
| 11 | 15 | * Renders extra controls in the Gallery Settings section of the new media UI. |
| 16 | + * | |
| 17 | + * @phan-constructor-used-for-side-effects | |
| 12 | 18 | */ |
| 13 | 19 | class Jetpack_Gallery_Settings { |
| 14 | 20 | /** |
| 21 | + * Available gallery types. | |
| 22 | + * | |
| 23 | + * @var array | |
| 24 | + */ | |
| 25 | + public $gallery_types; | |
| 26 | + | |
| 27 | + /** | |
| 15 | 28 | * The constructor. |
| 16 | 29 | */ |
| 17 | 30 | public function __construct() { |
| 18 | 31 | add_action( 'admin_init', array( $this, 'admin_init' ) ); |
| @@ -33,9 +46,9 @@ | ||
| 33 | 46 | */ |
| 34 | 47 | $this->gallery_types = apply_filters( 'jetpack_gallery_types', array( 'default' => __( 'Thumbnail Grid', 'jetpack' ) ) ); |
| 35 | 48 | |
| 36 | 49 | // Enqueue the media UI only if needed. |
| 37 | - if ( count( $this->gallery_types ) > 1 ) { | |
| 50 | + if ( is_countable( $this->gallery_types ) && count( $this->gallery_types ) > 1 ) { | |
| 38 | 51 | add_action( 'wp_enqueue_media', array( $this, 'wp_enqueue_media' ) ); |
| 39 | 52 | add_action( 'print_media_templates', array( $this, 'print_media_templates' ) ); |
| 40 | 53 | } |
| 41 | 54 | // Add Slideshow and Galleries functionality to core's media gallery widget. |