/** * @param array $args Display arguments including before_title, after_title, before_widget, and after_widget. * @param array $instance The settings for the particular instance of the widget. */ public function widget($args, $instance) { $instance = wp_parse_args((array) $instance, $this->defaults()); $this->enqueue_frontend_scripts(); extract($args); $instance['attachments'] = $this->get_attachments($instance); $classes = array(); $classes[] = 'widget-gallery-' . $instance['type']; // Due to a bug in the carousel plugin, carousels will be triggered for all tiled galleries that exist on a page // with other tiled galleries, regardless of whether or not the widget was set to Carousel mode. The onClick selector // is simply too broad, since it was not written with widgets in mind. This special class prevents that behavior, via // an override handler in gallery.js if ('carousel' != $instance['link'] && 'slideshow' != $instance['type']) { $classes[] = 'no-carousel'; } else { $classes[] = 'carousel'; } $classes = implode(' ', $classes); if ('carousel' == $instance['link']) { require_once plugin_dir_path(realpath(dirname(__FILE__) . '/../carousel/jetpack-carousel.php')) . 'jetpack-carousel.php'; if (class_exists('Jetpack_Carousel')) { // Create new carousel so we can use the enqueue_assets() method. Not ideal, but there is a decent amount // of logic in that method that shouldn't be duplicated. $carousel = new Jetpack_Carousel(); // First parameter is $output, which comes from filters, and causes bypass of the asset enqueuing. Passing null is correct. $carousel->enqueue_assets(null); } } echo $before_widget . "\n"; /** This filter is documented in core/src/wp-includes/default-widgets.php */ $title = apply_filters('widget_title', $instance['title']); if ($title) { echo $before_title . esc_html($title) . $after_title . "\n"; } echo '<div class="' . esc_attr($classes) . '">' . "\n"; $method = $instance['type'] . '_widget'; /** * Allow the width of a gallery to be altered by themes or other code. * * @since 2.5.0 * * @param int self::DEFAULT_WIDTH Default gallery width. Default is 265. * @param string $args Display arguments including before_title, after_title, before_widget, and after_widget. * @param array $instance The settings for the particular instance of the widget. */ $this->_instance_width = apply_filters('gallery_widget_content_width', self::DEFAULT_WIDTH, $args, $instance); // Register a filter to modify the tiled_gallery_content_width, so Jetpack_Tiled_Gallery // can appropriately size the tiles. add_filter('tiled_gallery_content_width', array($this, 'tiled_gallery_content_width')); if (method_exists($this, $method)) { echo $this->{$method}($args, $instance); } // Remove the stored $_instance_width, as it is no longer needed $this->_instance_width = null; // Remove the filter, so any Jetpack_Tiled_Gallery in a post is not affected remove_filter('tiled_gallery_content_width', array($this, 'tiled_gallery_content_width')); echo "\n" . '</div>'; // .widget-gallery-$type echo "\n" . $after_widget; }
function asg_enqueue_scripts() { switch (get_option('asg_lightbox')) { case 'swipebox': asg_enqueue_script('swipebox', 'vendor/swipebox/jquery.swipebox', array('jquery')); wp_enqueue_style('swipebox', ASG_URL . "vendor/swipebox/swipebox.css", ASG_VERSION); break; case 'prettyphoto': asg_enqueue_script('jquery.prettyphoto', 'vendor/prettyphoto/jquery.prettyPhoto'); break; case 'jetpack': //wp_enqueue_script(''); if (class_exists('Jetpack_Carousel')) { $carousel = new Jetpack_Carousel(); $carousel->enqueue_assets(false); } break; case 'magnific-popup': default: asg_enqueue_script('magnific-popup', 'vendor/jquery.magnific-popup', array('jquery')); wp_enqueue_style('jquery.magnific-popup', ASG_URL . "assets/css/jquery.magnific-popup.css", null, ASG_VERSION); break; } asg_enqueue_script('awesome-gallery', 'assets/js/awesome-gallery', array('jquery')); }
function enqueue_lightbox_scripts() { switch (uber_grid_get_active_lightbox()) { case 'swipebox': wp_enqueue_script('jquery.swipebox', UBERGRID_URL . "vendor/swipebox/jquery.swipebox.js", array('jquery'), UBERGRID_VERSION); break; case 'prettyphoto': wp_enqueue_script('jquery.prettyphoto', UBERGRID_URL . "vendor/prettyphoto/jquery.prettyPhoto.js", array('jquery'), UBERGRID_VERSION); break; case 'jetpack': //wp_enqueue_script(''); if (class_exists('Jetpack_Carousel')) { $carousel = new Jetpack_Carousel(); $carousel->enqueue_assets(false); } case 'magnific-popup': default: wp_enqueue_script('jquery.magnific-popup', UBERGRID_URL . "assets/js/jquery.magnific-popup.js", array('jquery'), UBERGRID_VERSION); } }