| @@ -1,35 +1,21 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | class Meow_MGL_Run { |
| 4 | - private $isEnqueued = false; | |
| 5 | 4 | |
| 6 | 5 | public function __construct( $core ) { |
| 6 | + add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ) ); | |
| 7 | + add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) ); | |
| 7 | 8 | add_shortcode( 'gallery', array( $core, 'gallery' ) ); |
| 8 | 9 | add_shortcode( 'meow-gallery', array( $core, 'gallery' ) ); |
| 9 | - | |
| 10 | - if ( is_admin() ) { | |
| 11 | - add_action( 'init', array( $this, 'enqueue_scripts' ) ); | |
| 12 | - } | |
| 13 | - else { | |
| 14 | - add_action( 'mgl_gallery_created', array( $this, 'enqueue_scripts' ), 10, 0 ); | |
| 15 | - } | |
| 16 | - | |
| 17 | 10 | // Yoast: Some people really want this, but it needs to be reviewed as Yoast changed its API |
| 18 | 11 | //add_filter( 'wpseo_sitemap_urlimages', array( $this, 'wpseo_siteimap' ), 10, 2 ); |
| 19 | 12 | } |
| 20 | 13 | |
| 21 | 14 | function enqueue_scripts() { |
| 22 | - // Only need to load the scripts once. | |
| 23 | - if ( $this->isEnqueued ) { | |
| 24 | - return; | |
| 25 | - } | |
| 26 | - $this->isEnqueued = true; | |
| 27 | - | |
| 28 | - // Load the JS for Meow Gallery | |
| 29 | 15 | $physical_file = MGL_PATH . '/app/galleries.js'; |
| 30 | 16 | $cache_buster = file_exists( $physical_file ) ? filemtime( $physical_file ) : MGL_VERSION; |
| 31 | - wp_enqueue_script( 'mgl-js', plugins_url( '/app/galleries.js', __DIR__ ), array( 'jquery' ), $cache_buster, true ); | |
| 17 | + wp_enqueue_script( 'mgl-js', plugins_url( '/app/galleries.js', __DIR__ ), array( 'jquery' ), $cache_buster, false ); | |
| 32 | 18 | |
| 33 | 19 | // TODO: This should be moved in a getter (since it is also used by tiles.php) |
| 34 | 20 | $density = []; |
| 35 | 21 | if ( isset( $this->atts['density'] ) ) { |