Jetpack_Gallery_Settings

Renders extra controls in the Gallery Settings section of the new media UI.

Defined (1)

The class is defined in the following location(s).

/functions.gallery.php  
  1. class Jetpack_Gallery_Settings { 
  2. function __construct() { 
  3. add_action( 'admin_init', array( $this, 'admin_init' ) ); 
  4.  
  5. function admin_init() { 
  6. /** 
  7. * Filter the available gallery types. 
  8. * @module shortcodes, tiled-gallery 
  9. * @since 2.5.1 
  10. * @param array $value Array of the default thumbnail grid gallery type. Default array contains one key, *default*. 
  11. */ 
  12. $this->gallery_types = apply_filters( 'jetpack_gallery_types', array( 'default' => __( 'Thumbnail Grid', 'jetpack' ) ) ); 
  13.  
  14. // Enqueue the media UI only if needed. 
  15. if ( count( $this->gallery_types ) > 1 ) { 
  16. add_action( 'wp_enqueue_media', array( $this, 'wp_enqueue_media' ) ); 
  17. add_action( 'print_media_templates', array( $this, 'print_media_templates' ) ); 
  18.  
  19. /** 
  20. * Registers/enqueues the gallery settings admin js. 
  21. */ 
  22. function wp_enqueue_media() { 
  23. if ( ! wp_script_is( 'jetpack-gallery-settings', 'registered' ) ) { 
  24. /** 
  25. * This only happens if we're not in Jetpack, but on WPCOM instead. 
  26. * This is the correct path for WPCOM. 
  27. */ 
  28. wp_register_script( 'jetpack-gallery-settings', plugins_url( 'gallery-settings/gallery-settings.js', __FILE__ ), array( 'media-views' ), '20121225' ); 
  29.  
  30. wp_enqueue_script( 'jetpack-gallery-settings' ); 
  31.  
  32. /** 
  33. * Outputs a view template which can be used with wp.media.template 
  34. */ 
  35. function print_media_templates() { 
  36. /** 
  37. * Filter the default gallery type. 
  38. * @module tiled-gallery 
  39. * @since 2.5.1 
  40. * @param string $value A string of the gallery type. Default is *default*. 
  41. */ 
  42. $default_gallery_type = apply_filters( 'jetpack_default_gallery_type', 'default' ); 
  43.  
  44. ?> 
  45. <script type="text/html" id="tmpl-jetpack-gallery-settings"> 
  46. <label class="setting"> 
  47. <span><?php _e( 'Type', 'jetpack' ); ?></span> 
  48. <select class="type" name="type" data-setting="type"> 
  49. <?php foreach ( $this->gallery_types as $value => $caption ) : ?> 
  50. <option value="<?php echo esc_attr( $value ); ?>" <?php selected( $value, $default_gallery_type ); ?>><?php echo esc_html( $caption ); ?></option> 
  51. <?php endforeach; ?> 
  52. </select> 
  53. </label> 
  54. </script> 
  55. <?php