public function __construct($attachments)
 {
     $content_width = Jetpack_Tiled_Gallery::get_content_width();
     $ua_info = new Jetpack_User_Agent_Info();
     $this->last_shape = '';
     $this->images = $this->get_images_with_sizes($attachments);
     $this->grouped_images = $this->get_grouped_images();
     $this->apply_content_width($content_width);
 }
 private function compute_items()
 {
     $content_width = Jetpack_Tiled_Gallery::get_content_width();
     $images_per_row = $this->columns;
     $margin = 2;
     $margin_space = $images_per_row * $margin * 2;
     $size = floor(($content_width - $margin_space) / $images_per_row);
     $remainder = count($this->attachments) % $images_per_row;
     if ($remainder > 0) {
         $remainder_space = $remainder * $margin * 2;
         $remainder_size = floor(($content_width - $remainder_space) / $remainder);
     }
     $items = array();
     $c = 1;
     $items_in_row = 0;
     $rows = array();
     $row = new stdClass();
     $row->images = array();
     foreach ($this->attachments as $image) {
         if ($remainder > 0 && $c <= $remainder) {
             $img_size = $remainder_size;
         } else {
             $img_size = $size;
         }
         $image->width = $image->height = $img_size;
         $item = new Jetpack_Tiled_Gallery_Square_Item($image, $this->needs_attachment_link, $this->grayscale);
         $row->images[] = $item;
         $c++;
         $items_in_row++;
         if ($images_per_row === $items_in_row || $remainder + 1 == $c) {
             $rows[] = $row;
             $items_in_row = 0;
             $row->height = $img_size + $margin * 2;
             $row->width = $content_width;
             $row->group_size = $img_size + 2 * $margin;
             $row = new stdClass();
             $row->images = array();
         }
     }
     if (!empty($row->images)) {
         $row->height = $img_size + $margin * 2;
         $row->width = $content_width;
         $row->group_size = $img_size + 2 * $margin;
         $rows[] = $row;
     }
     return $rows;
 }
Example #3
0
 public function __construct($attachments)
 {
     $content_width = Jetpack_Tiled_Gallery::get_content_width();
     $ua_info = new Jetpack_User_Agent_Info();
     $this->last_shape = '';
     $this->images = $this->get_images_with_sizes($attachments);
     $this->grouped_images = $this->get_grouped_images();
     $this->apply_content_width($content_width - 5);
     //reduce the margin hack to 5px. It will be further reduced when we fix more themes and the rounding error.
 }
Example #4
0
 /**
  * Generate HTML for a circular (grid style) Widget
  *
  * @param array $args Display arguments including before_title, after_title, before_widget, and after_widget.
  * @param array $instance The Widget instance to generate HTML for
  * @return string String of HTML representing a circular gallery
  */
 public function circle_widget($args, $instance)
 {
     if (!class_exists('Jetpack_Tiled_Gallery') && !class_exists('Jetpack_Tiled_Gallery_Layout_Circle')) {
         return;
     }
     $widget_tiled_gallery = new Jetpack_Tiled_Gallery();
     $widget_tiled_gallery->default_scripts_and_styles();
     $layout = new Jetpack_Tiled_Gallery_Layout_Circle($instance['attachments'], $instance['link'], false, 3);
     return $layout->HTML();
 }
Example #5
0
 /**
  * Always load certain scripts when IS is enabled, as they can't be loaded after `document.ready` fires, meaning they can't leverage IS's script loader.
  *
  * @global $videopress
  * @uses do_action()
  * @uses apply_filters()
  * @uses wp_enqueue_style()
  * @uses wp_enqueue_script()
  * @action wp_enqueue_scripts
  * @return null
  */
 public function action_wp_enqueue_scripts()
 {
     // VideoPress stand-alone plugin
     global $videopress;
     if (!empty($videopress) && The_Neverending_Home_Page::archive_supports_infinity() && is_a($videopress, 'VideoPress') && method_exists($videopress, 'enqueue_scripts')) {
         $videopress->enqueue_scripts();
     }
     // VideoPress Jetpack module
     if (Jetpack::is_module_active('videopress')) {
         Jetpack_VideoPress_Shortcode::enqueue_scripts();
     }
     // Fire the post_gallery action early so Carousel scripts are present.
     if (Jetpack::is_module_active('carousel')) {
         do_action('post_gallery', '', '');
     }
     // Always enqueue Tiled Gallery scripts when both IS and Tiled Galleries are enabled
     if (Jetpack::is_module_active('tiled-gallery')) {
         Jetpack_Tiled_Gallery::default_scripts_and_styles();
     }
     // Core's Audio and Video Shortcodes
     if ('mediaelement' === apply_filters('wp_audio_shortcode_library', 'mediaelement')) {
         wp_enqueue_style('wp-mediaelement');
         wp_enqueue_script('wp-mediaelement');
     }
     if ('mediaelement' === apply_filters('wp_video_shortcode_library', 'mediaelement')) {
         wp_enqueue_style('wp-mediaelement');
         wp_enqueue_script('wp-mediaelement');
     }
 }
Example #6
0
 /**
  * Always load certain scripts when IS is enabled, as they can't be loaded after `document.ready` fires, meaning they can't leverage IS's script loader.
  *
  * @global $videopress
  * @uses do_action()
  * @uses apply_filters()
  * @uses wp_enqueue_style()
  * @uses wp_enqueue_script()
  * @action wp_enqueue_scripts
  * @return null
  */
 public function action_wp_enqueue_scripts()
 {
     // Do not load scripts and styles on singular pages and static pages
     $load_scripts_and_styles = !(is_singular() || is_page());
     if (!apply_filters('jetpack_infinite_scroll_load_scripts_and_styles', $load_scripts_and_styles)) {
         return;
     }
     // VideoPress stand-alone plugin
     global $videopress;
     if (!empty($videopress) && The_Neverending_Home_Page::archive_supports_infinity() && is_a($videopress, 'VideoPress') && method_exists($videopress, 'enqueue_scripts')) {
         $videopress->enqueue_scripts();
     }
     // VideoPress Jetpack module
     if (Jetpack::is_module_active('videopress')) {
         wp_enqueue_script('videopress');
     }
     // Fire the post_gallery action early so Carousel scripts are present.
     if (Jetpack::is_module_active('carousel')) {
         /** This filter is already documented in core/wp-includes/media.php */
         do_action('post_gallery', '', '');
     }
     // Always enqueue Tiled Gallery scripts when both IS and Tiled Galleries are enabled
     if (Jetpack::is_module_active('tiled-gallery')) {
         Jetpack_Tiled_Gallery::default_scripts_and_styles();
     }
     // Core's Audio and Video Shortcodes
     if ('mediaelement' === apply_filters('wp_audio_shortcode_library', 'mediaelement')) {
         wp_enqueue_style('wp-mediaelement');
         wp_enqueue_script('wp-mediaelement');
     }
     if ('mediaelement' === apply_filters('wp_video_shortcode_library', 'mediaelement')) {
         wp_enqueue_style('wp-mediaelement');
         wp_enqueue_script('wp-mediaelement');
     }
 }
if (defined('JSON_HEX_AMP')) {
    // see shortcodes/slideshow.php
    // This is nice to have, but not strictly necessary since we use _wp_specialchars() below
    $extra = json_encode($this->get_container_extra_data(), JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_APOS | JSON_HEX_QUOT);
} else {
    $extra = json_encode($this->get_container_extra_data());
}
?>
<div
	class="tiled-gallery type-<?php 
echo $this->type;
?>
 tiled-gallery-unresized"
	data-original-width="<?php 
echo esc_attr(Jetpack_Tiled_Gallery::get_content_width());
?>
"
	<?php 
if (isset($extra)) {
    ?>
		data-carousel-extra='<?php 
    echo _wp_specialchars(wp_check_invalid_utf8($extra), ENT_QUOTES, false, true);
    ?>
'
	<?php 
}
?>
	>
	<?php 
$this->template("{$this->type}-layout", $context);
Example #8
0
/**
 * Enqueue scripts and styles.
 */
function foxhound_scripts()
{
    wp_enqueue_style('foxhound-style', get_template_directory_uri() . '/build/style.css');
    wp_enqueue_script(FOXHOUND_APP, get_template_directory_uri() . '/build/app.js', array('jquery'), FOXHOUND_VERSION, true);
    if (class_exists('Jetpack_Tiled_Gallery')) {
        Jetpack_Tiled_Gallery::default_scripts_and_styles();
    }
    $url = trailingslashit(home_url());
    $path = trailingslashit(parse_url($url, PHP_URL_PATH));
    $front_page_slug = false;
    $blog_page_slug = false;
    if ('posts' !== get_option('show_on_front')) {
        $front_page_id = get_option('page_on_front');
        $front_page = get_post($front_page_id);
        if ($front_page->post_name) {
            $front_page_slug = $front_page->post_name;
        }
        $blog_page_id = get_option('page_for_posts');
        $blog_page = get_post($blog_page_id);
        if ($blog_page->post_name) {
            $blog_page_slug = $blog_page->post_name;
        }
    }
    wp_localize_script(FOXHOUND_APP, 'SiteSettings', array('endpoint' => esc_url_raw(get_rest_url()), 'nonce' => wp_create_nonce('wp_rest')));
    $user_id = get_current_user_id();
    $user = get_userdata($user_id);
    wp_localize_script(FOXHOUND_APP, 'FoxhoundSettings', array('user' => get_current_user_id(), 'userDisplay' => $user ? $user->display_name : '', 'frontPage' => array('page' => $front_page_slug, 'blog' => $blog_page_slug), 'URL' => array('base' => esc_url_raw($url), 'path' => $path), 'meta' => array('title' => get_bloginfo('name', 'display'), 'description' => get_bloginfo('description', 'display'))));
}
Example #9
0
 /**
  * Generate HTML for a circular (grid style) Widget
  *
  * @param array $args Display arguments including before_title, after_title, before_widget, and after_widget.
  * @param array $instance The Widget instance to generate HTML for
  * @return string String of HTML representing a circular gallery
  */
 public function circle_widget($args, $instance)
 {
     if (!class_exists('Jetpack_Tiled_Gallery')) {
         return;
     }
     $widget_tiled_gallery = new Jetpack_Tiled_Gallery();
     // Tell the Tiled_Gallery what we want the images to link to
     $widget_tiled_gallery->set_atts(array('link' => $instance['link'], 'type' => 'circle'));
     $widget_tiled_gallery->default_scripts_and_styles();
     $html = $widget_tiled_gallery->circle_talavera($instance['attachments']);
     return $html;
 }