/** * Format a theme for the public API * @param object $theme WP_Theme object * @return array Named array of theme info used by the API */ protected function format_theme($theme) { $fields = array('name' => 'Name', 'description' => 'Description', 'tags' => 'Tags', 'version' => 'Version'); $formatted_theme = array('id' => $theme->get_stylesheet(), 'screenshot' => jetpack_photon_url($theme->get_screenshot(), array(), 'network_path')); foreach ($fields as $key => $field) { $formatted_theme[$key] = $theme->get($field); } return $formatted_theme; }
/** * Returns the URL to an image resized and cropped to the given dimensions. * * You can use this image URL directly -- it's cached and such by our servers. * Please use this function to generate the URL rather than doing it yourself as * this function uses staticize_subdomain() makes it serve off our CDN network. * * Somewhat contrary to the function's name, it can be used for ANY image URL, hosted by us or not. * So even though it says "remote", you can use it for attachments hosted by us, etc. * * @link http://vip.wordpress.com/documentation/image-resizing-and-cropping/ Image Resizing And Cropping * @param string $url The raw URL to the image (URLs that redirect are currently not supported with the exception of http://foobar.wordpress.com/files/ type URLs) * @param int $width The desired width of the final image * @param int $height The desired height of the final image * @param bool $escape Optional. If true (the default), the URL will be run through esc_url(). Set this to false if you need the raw URL. * @return string */ function wpcom_vip_get_resized_remote_image_url($url, $width, $height, $escape = true) { $width = (int) $width; $height = (int) $height; // Photon doesn't support redirects, so help it out by doing http://foobar.wordpress.com/files/ to http://foobar.files.wordpress.com/ if (function_exists('new_file_urls')) { $url = new_file_urls($url); } $thumburl = jetpack_photon_url($url, array('resize' => array($width, $height))); return $escape ? esc_url($thumburl) : $thumburl; }
function legacy_get_fit_remote_image_url($url, $width, $height, $escape = true) { if (class_exists('Jetpack') && Jetpack::is_module_active('photon')) { $width = (int) $width; $height = (int) $height; // Photon doesn't support redirects, so help it out by doing http://foobar.wordpress.com/files/ to http://foobar.files.wordpress.com/ if (function_exists('new_file_urls')) { $url = new_file_urls($url); } $thumburl = jetpack_photon_url($url, array('fit' => array($width, $height))); return $escape ? esc_url($thumburl) : $thumburl; } }
function uber_grid_get_photon_url($url, $options) { $photon_options = array(); if (isset($options['width']) && (int) $options['width'] && isset($options['height']) && (int) $options['height']) { $photon_options['resize'] = array($options['width'], $options['height']); } else { if (isset($options['width']) && (int) $options['width']) { $photon_options['w'] = $options['width']; } if (isset($options['height']) && (int) $options['height']) { $photon_options['h'] = $options['height']; } } //$photon_options['zoom'] = $options['pixel_ratio']; return jetpack_photon_url($url, $photon_options); }
/** * Fetch the slide collection for a given slideset * * @uses $_POST['slideset'] Identifies presentation based on slideset ID. */ public function get_slides() { $slideset_id = intval($_POST['slideset']); // $response = array( // 'success' => true/false, // 'data' => array( // $child_array_1, // $child_array_2 // ... // ) // } $response = array(); if (0 === $slideset_id) { $response['success'] = false; } else { /** @var SEOSlides_Slideset $slideset */ $slideset = SEOSlides_Module_Provider::get('SEOSlides Core')->get_slideset($slideset_id); $child_data = array(); // Build an array containing each slide in a separate associative array /** @var SEOSlides_Slide $slide */ foreach ($slideset->slides as $slide) { $bg_image = $slide->get_bg_image(); $bg_id = SEOSlides_Util::get_attachment_id_from_url($bg_image); if (false !== $bg_id) { $bg_arr = wp_get_attachment_image_src($bg_id, 'seoslides-thumb'); $bg_image = $bg_arr[0]; } $data = array('id' => $slide->ID, 'title' => stripslashes($slide->title), 'content' => $slide->content, 'image' => stripslashes($slide->image), 'bg_image' => $bg_image, 'style' => $slide->style, 'position' => $slide->position, 'preview' => $slide->preview, 'fill_color' => $slide->fill_color, 'seo_title' => $slide->seo_title, 'seo_description' => $slide->seo_description, 'seo_keywords' => $slide->seo_keywords, 'presenter_notes' => wp_trim_words($slide->presenter_notes, 50, ' […]'), 'status' => $slide->status); if (isset($data['bg_image']) && function_exists('jetpack_photon_url')) { $data['bg_image'] = jetpack_photon_url($data['bg_image'], array(), '//'); } $oembed = SEOSlides_Slide::get_embed_url($slide->oembed); $oembed_thumb = SEOSlides_Slide::get_embed_thumbnail($slide->oembed); if (!is_wp_error($oembed) && !is_wp_error($oembed_thumb)) { $data['oembed'] = $oembed; $data['oembed_thumb'] = $oembed_thumb; } // Build out canvas objects $data['objects'] = array_map(array($this, 'sanitize_slide_object'), $slide->objects); // Add the object $child_data[] = $data; } $response['success'] = true; $response['data'] = $child_data; } wp_send_json($response); }
/** * Format a theme for the public API * @param object $theme WP_Theme object * @return array Named array of theme info used by the API */ protected function format_theme($theme) { if (!$theme instanceof WP_Theme) { $theme = wp_get_theme($theme); } $fields = array('name' => 'Name', 'theme_uri' => 'ThemeURI', 'description' => 'Description', 'author' => 'Author', 'author_uri' => 'AuthorURI', 'tags' => 'Tags', 'version' => 'Version'); $id = $theme->get_stylesheet(); $formatted_theme = array('id' => $id, 'screenshot' => jetpack_photon_url($theme->get_screenshot(), array(), 'network_path'), 'active' => $id === $this->current_theme_id); foreach ($fields as $key => $field) { $formatted_theme[$key] = $theme->get($field); } $update_themes = get_site_transient('update_themes'); $formatted_theme['update'] = isset($update_themes->response[$id]) ? $update_themes->response[$id] : null; $autoupdate_themes = Jetpack_Options::get_option('autoupdate_themes', array()); $autoupdate = in_array($id, $autoupdate_themes); $formatted_theme['autoupdate'] = $autoupdate; if (isset($this->log[$id])) { $formatted_theme['log'] = $this->log[$id]; } return $formatted_theme; }
public static function apply_filter_post_gallery($output, $attr) { global $post; // Determine what our postID for attachments is - either // from our shortcode attr or from $post->ID. If we don't // have one from either of those places...something weird // is going on, so just bail. if (isset($attr['id'])) { $post_id = intval($attr['id']); } else { if ($post) { $post_id = intval($post->ID); } else { return ' '; } } if (isset($attr['ignore_gallery_link_urls']) && strtolower(trim($attr['ignore_gallery_link_urls'])) === 'true') { // If the user has passed in a parameter to ignore the custom link // URLs for this gallery, just skip over this whole plugin and // return what was passed in return $output; } else { if (self::$first_call) { // Our first run, so the gallery function thinks it's being // overwritten. Set the variable to prevent actual endless // overwriting later. self::$first_call = false; } else { // We're inside our dynamically called gallery function and // don't want to spiral into an endless loop, so return // whatever output we were given so the gallery function // will run as normal. Also reset the first call variable // so if there's two galleries or something it will run the // same next time. self::$first_call = true; return $output; } } // Get the normal gallery shortcode function if (isset($GLOBALS['shortcode_tags']) && isset($GLOBALS['shortcode_tags']['gallery'])) { $gallery_shortcode_function = $GLOBALS['shortcode_tags']['gallery']; } // Run whatever gallery shortcode function has been set up, // default, theme-specified or whatever $output = call_user_func($gallery_shortcode_function, $attr); $attachment_ids = array(); if (isset($attr['ids'])) { // WP 3.5+: $attachment_ids = array_merge($attachment_ids, explode(',', $attr['ids'])); } else { // < WP 3.5: // Get the attachment ids for this post $attachments = get_children(array('post_parent' => $post_id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image')); if (count($attachments) > 0) { $attachment_ids = array_merge($attachment_ids, array_keys($attachments)); } } // End if it's the "ids" attribute way of specifying images or not // Add in any "include"d attachmentIDs if (isset($attr['include'])) { $attachment_ids = array_merge($attachment_ids, explode(',', $attr['include'])); } // Make sure we don't replace the same one multiple times $attachment_ids = array_unique($attachment_ids); foreach ($attachment_ids as $attachment_id) { $link = ''; $target = ''; $rel = ''; $preserve_click = ''; $remove_link = false; $additional_css_classes = ''; $attachment_id = intval($attachment_id); // See if we have a custom url for this attachment image $attachment_meta = get_post_meta($attachment_id, '_gallery_link_url', true); if ($attachment_meta) { $link = $attachment_meta; // Apply filters to the custom link (e.g. the case of prefixing internal // links with /en/ or /fr/ etc. for languages on the fly) $link = apply_filters('wpgcl_filter_raw_gallery_link_url', $link, $attachment_id, $post_id); } // See if we have a target for this attachment image $attachment_meta = get_post_meta($attachment_id, '_gallery_link_target', true); if ($attachment_meta) { $target = $attachment_meta; } if (isset($attr['open_all_in_new_window']) && strtolower(trim($attr['open_all_in_new_window'])) === 'true') { // Override setting if the gallery shortcode says to open everything in a new window // This should accommodate both "3000 images in new window" guy (to some extent) and allow _blank // by default lady to reset her gallery to _blank at once $target = '_blank'; } if (isset($attr['open_all_in_same_window']) && strtolower(trim($attr['open_all_in_same_window'])) === 'true') { // Override setting if the gallery shortcode says to open everything in the same window // This should allow _blank by default lady to set her gallery to _self at once $target = '_self'; } // See if we have a rel for this link if (isset($attr['rel'])) { // Add a rel property to this image link with the specified value $rel = $attr['rel']; // Note: this is escaped before being dropped in } // See if we have additional css classes for this attachment image $attachment_meta = get_post_meta($attachment_id, '_gallery_link_additional_css_classes', true); if ($attachment_meta) { $additional_css_classes = trim($attachment_meta); } // See how to handle click events for this attachment image $attachment_meta = get_post_meta($attachment_id, '_gallery_link_preserve_click', true); if ($attachment_meta) { $preserve_click = $attachment_meta; } if (isset($attr['preserve_click_events']) && strtolower(trim($attr['preserve_click_events'])) === 'true') { // Override the individual setting if the gallery shortcode says to preserve on all $preserve_click = 'preserve'; } // See if we need to remove the link for this image or not if (strtolower(trim($link)) === '[none]' || isset($attr['remove_links']) && strtolower(trim($attr['remove_links'])) === 'true') { $remove_link = true; } if ($link != '' || $target != '' || $rel != '' || $remove_link || $additional_css_classes != '') { // Replace the attachment href $needle = get_attachment_link($attachment_id); $output = self::replace_link($needle, $link, $target, $rel, $preserve_click, $remove_link, $additional_css_classes, $output); // Replace the file href list($needle) = wp_get_attachment_image_src($attachment_id, ''); $output = self::replace_link($needle, $link, $target, $rel, $preserve_click, $remove_link, $additional_css_classes, $output); // Also, in case of jetpack photon with tiled galleries... if (function_exists('jetpack_photon_url')) { // The CDN url currently is generated with "$subdomain = rand( 0, 2 );", // and then "$photon_url = "http://i{$subdomain}.wp.com/$image_host_path";". // So just to cover our bases, loop over a slightly larger range of numbers // to make sure we include all possibilities for what the photon url // could be. The max $j value may need to be increased someday if they // get a lot busier. Also the URL could change. I guess I'll cross // those bridges when we come to them. Blah. for ($j = 0; $j < 10; $j++) { $needle_parts = explode('.wp.com', jetpack_photon_url($needle)); if (count($needle_parts) == 2) { $needle_part_1 = preg_replace('/\\d+$/U', '', $needle_parts[0]); $needle_part_2 = '.wp.com' . $needle_parts[1]; $needle_reassembled = $needle_part_1 . $j . $needle_part_2; $output = self::replace_link($needle_reassembled, $link, $target, $rel, $preserve_click, $remove_link, $additional_css_classes, $output); } } } // Replace all possible file sizes - some themes etc. // may use sizes other than the full version $attachment_metadata = wp_get_attachment_metadata($attachment_id); if ($attachment_metadata !== false && isset($attachment_metadata['sizes'])) { $attachment_sizes = $attachment_metadata['sizes']; if (is_array($attachment_sizes) && count($attachment_sizes) > 0) { foreach ($attachment_sizes as $attachment_size => $attachment_info) { list($needle) = wp_get_attachment_image_src($attachment_id, $attachment_size); $output = self::replace_link($needle, $link, $target, $rel, $preserve_click, $remove_link, $additional_css_classes, $output); } // End of foreach attachment size } // End if we have attachment sizes } // End if we have attachment metadata (specifically sizes) } // End if we have a link to swap in or a target to add } // End foreach post attachment return $output; }
/** * Takes an image URL and pixel dimensions then returns a URL for the * resized and croped image. * * @param string $src * @param int $dimension * @return string Transformed image URL */ static function fit_image_url($src, $width, $height) { $width = (int) $width; $height = (int) $height; // Umm... if ($width < 1 || $height < 1) { return $src; } // See if we should bypass WordPress.com SaaS resizing if (has_filter('jetpack_images_fit_image_url_override')) { return apply_filters('jetpack_images_fit_image_url_override', $src, $width, $height); } // If WPCOM hosted image use native transformations $img_host = parse_url($src, PHP_URL_HOST); if ('.files.wordpress.com' == substr($img_host, -20)) { return add_query_arg(array('w' => $width, 'h' => $height, 'crop' => 1), $src); } // Use Photon magic if (function_exists('jetpack_photon_url')) { return jetpack_photon_url($src, array('resize' => "{$width},{$height}")); } // Arg... no way to resize image using WordPress.com infrastructure! return $src; }
/** * Takes an image URL and a pixel dimensions and returns a URL for the * squared up image if possible. * * @param string $src * @param int $dimension * @return string Transformed image URL */ static function square_image_url($src, $dimension) { $dimension = (int) $dimension; // Umm... if ($dimension < 1) { return $src; } // If WPCOM hosted image use native transformations $img_host = parse_url($src, PHP_URL_HOST); if ('.files.wordpress.com' == substr($img_host, -20)) { return add_query_arg(array('w' => $dimension, 'h' => $dimension, 'crop' => 1), $src); } // Use Photon magic if (function_exists('jetpack_photon_url')) { return jetpack_photon_url($src, array('resize' => "{$dimension},{$dimension}")); } // Arg... no way to resize image using WordPress.com infrastructure! return $src; }
/** * Returns the attributes for a given attachment thumbnail. Meant for hooking into image_downsize(). * * @param $existing_resize array|false Any existing data. Returned on no action. * @param $attachment_id int Attachment ID. * @param $size string Thumbnail size name. * @return mixed Array of thumbnail details (URL, width, height, is_intermedite) or the previous data. */ public function get_thumbnail_url($existing_resize, $attachment_id, $size) { // Named sizes only if (is_array($size)) { return $existing_resize; } $coordinates = $this->get_coordinates($attachment_id, $size); if (!$coordinates || !is_array($coordinates) || 4 != count($coordinates)) { return $existing_resize; } if (!($thumbnail_size = $this->get_thumbnail_dimensions($size))) { return $existing_resize; } list($selection_x1, $selection_y1, $selection_x2, $selection_y2) = $coordinates; if (function_exists('jetpack_photon_url')) { $url = jetpack_photon_url(wp_get_attachment_url($attachment_id), array('crop' => array($selection_x1 . 'px', $selection_y1 . 'px', $selection_x2 - $selection_x1 . 'px', $selection_y2 - $selection_y1 . 'px'), 'resize' => array($thumbnail_size['width'], $thumbnail_size['height']))); } else { $url = wp_get_attachment_url($attachment_id); } return array($url, $thumbnail_size['width'], $thumbnail_size['height'], true); }
/** * Set up the widget display on the front end. * * @param array $args * @param array $instance */ public function widget($args, $instance) { /** This action is documented in modules/widgets/gravatar-profile.php */ do_action('jetpack_stats_extra', 'widget_view', 'display_posts'); /** This filter is documented in core/src/wp-includes/default-widgets.php */ $title = apply_filters('widget_title', $instance['title']); // Enqueue front end assets. $this->enqueue_scripts(); echo $args['before_widget']; $data = $this->get_blog_data($instance['url']); // check for errors if (is_wp_error($data) || empty($data['site_info']['data'])) { echo '<p>' . __('Cannot load blog information at this time.', 'jetpack') . '</p>'; echo $args['after_widget']; return; } $site_info = $data['site_info']['data']; if (!empty($title)) { echo $args['before_title'] . esc_html($title . ': ' . $site_info->name) . $args['after_title']; } else { echo $args['before_title'] . esc_html($site_info->name) . $args['after_title']; } echo '<div class="jetpack-display-remote-posts">'; if (is_wp_error($data['posts']['data']) || empty($data['posts']['data'])) { echo '<p>' . __('Cannot load blog posts at this time.', 'jetpack') . '</p>'; echo '</div><!-- .jetpack-display-remote-posts -->'; echo $args['after_widget']; return; } $posts_list = $data['posts']['data']; /** * Show only as much posts as we need. If we have less than configured amount, * we must show only that much posts. */ $number_of_posts = min($instance['number_of_posts'], count($posts_list)); for ($i = 0; $i < $number_of_posts; $i++) { $single_post = $posts_list[$i]; $post_title = $single_post['title'] ? $single_post['title'] : '( No Title )'; $target = ''; if (isset($instance['open_in_new_window']) && $instance['open_in_new_window'] == true) { $target = ' target="_blank"'; } echo '<h4><a href="' . esc_url($single_post['url']) . '"' . $target . '>' . esc_html($post_title) . '</a></h4>' . "\n"; if ($instance['featured_image'] == true && !empty($single_post['featured_image'])) { $featured_image = $single_post['featured_image']; /** * Allows setting up custom Photon parameters to manipulate the image output in the Display Posts widget. * * @see https://developer.wordpress.com/docs/photon/ * * @module widgets * * @since 3.6.0 * * @param array $args Array of Photon Parameters. */ $image_params = apply_filters('jetpack_display_posts_widget_image_params', array()); echo '<a title="' . esc_attr($post_title) . '" href="' . esc_url($single_post['url']) . '"' . $target . '><img src="' . jetpack_photon_url($featured_image, $image_params) . '" alt="' . esc_attr($post_title) . '"/></a>'; } if ($instance['show_excerpts'] == true) { echo $single_post['excerpt']; } } echo '</div><!-- .jetpack-display-remote-posts -->'; echo $args['after_widget']; }
public function rectangular_talavera($attachments) { $grouper = new Jetpack_Tiled_Gallery_Grouper($attachments); Jetpack_Tiled_Gallery_Shape::reset_last_shape(); $output = $this->generate_carousel_container(); foreach ($grouper->grouped_images as $row) { $output .= '<div class="gallery-row" style="' . esc_attr('width: ' . $row->width . 'px; height: ' . ($row->height - 4) . 'px;') . '">'; foreach ($row->groups as $group) { $count = count($group->images); $output .= '<div class="gallery-group images-' . esc_attr($count) . '" style="' . esc_attr('width: ' . $group->width . 'px; height: ' . $group->height . 'px;') . '">'; foreach ($group->images as $image) { $size = 'large'; if ($image->width < 250) { $size = 'small'; } $image_title = $image->post_title; $orig_file = wp_get_attachment_url($image->ID); $link = $this->get_attachment_link($image->ID, $orig_file); $img_src = add_query_arg(array('w' => $image->width, 'h' => $image->height), $orig_file); $output .= '<div class="tiled-gallery-item tiled-gallery-item-' . esc_attr($size) . '"><a href="' . esc_url($link) . '"><img ' . $this->generate_carousel_image_args($image) . ' src="' . esc_url($img_src) . '" width="' . esc_attr($image->width) . '" height="' . esc_attr($image->height) . '" align="left" title="' . esc_attr($image_title) . '" /></a>'; if ($this->atts['grayscale'] == true) { $img_src_grayscale = jetpack_photon_url($img_src, array('filter' => 'grayscale')); $output .= '<a href="' . esc_url($link) . '"><img ' . $this->generate_carousel_image_args($image) . ' class="grayscale" src="' . esc_url($img_src_grayscale) . '" width="' . esc_attr($image->width) . '" height="' . esc_attr($image->height) . '" align="left" title="' . esc_attr($image_title) . '" /></a>'; } if (trim($image->post_excerpt)) { $output .= '<div class="tiled-gallery-caption">' . wptexturize($image->post_excerpt) . '</div>'; } $output .= '</div>'; } $output .= '</div>'; } $output .= '</div>'; } $output .= '</div>'; return $output; }
/** * Pass og:image URLs through Photon * * @param array $tags * @param array $parameters * @uses jetpack_photon_url * @return array */ function filter_open_graph_tags($tags, $parameters) { if (empty($tags['og:image'])) { return $tags; } $photon_args = array('fit' => sprintf('%d,%d', 2 * $parameters['image_width'], 2 * $parameters['image_height'])); if (is_array($tags['og:image'])) { $images = array(); foreach ($tags['og:image'] as $image) { $images[] = jetpack_photon_url($image, $photon_args); } $tags['og:image'] = $images; } else { $tags['og:image'] = jetpack_photon_url($tags['og:image'], $photon_args); } return $tags; }
<?php // Check if the author of this post is connected to the Twitter importer, // if so load their Twitter avatar, if not use their Gravatar $icon_size = 35; // In px, how big (square) should the avatar/icon be? // I'm being a horrible person and accessing options directly to avoid re-loading all the importer code if (class_exists('Keyring')) { if ($importer = get_option('keyring_twitter_importer')) { if ($token = $importer['token']) { $token = Keyring::get_token_store()->get_token(array('id' => $token, 'type' => 'access')); $url = $token->get_meta('picture'); if ($url) { // Use Photon (if available) to resize their icon properly if (function_exists('jetpack_photon_url')) { $url = jetpack_photon_url($url, array('resize' => "{$icon_size},{$icon_size}", 'filter' => 'grayscale')); } // Output that sucka echo '<a href="' . get_author_posts_url(false, get_the_author_meta('ID')) . '">'; echo '<img src="' . esc_url($url) . '" class="format-icon" width="' . esc_attr($icon_size) . '" height="' . esc_attr($icon_size) . '" alt="" />'; echo '</a>'; return; // Avoid doing the Gravatar, below } } } } // No Twitter connection, try to use their Gravatar instead $gravatar = get_avatar(get_the_author_meta('ID'), $icon_size); $gravatar = str_replace("class='", "class='format-icon ", $gravatar); echo '<a href="' . get_author_posts_url(false, get_the_author_meta('ID')) . '">';
/** * Returns a URL for a given attachment with the appropriate resizing querystring. * * Typically, you should be using image sizes for handling this. * * However, this function can come in handy if you want a specific artibitrary or varying image size. * * @link http://vip.wordpress.com/documentation/image-resizing-and-cropping/ * * @param int $attachment_id ID of the attachment * @param int $width Width of our resized image * @param int $height Height of our resized image * @param bool $crop (optional) whether or not to crop the image * @return string URL of the resized attachmen */ function wpcom_vip_get_resized_attachment_url($attachment_id, $width, $height, $crop = false) { $url = wp_get_attachment_url($attachment_id); if (!$url) { return false; } $args = array('w' => intval($width), 'h' => intval($height)); // @todo crop handling? return jetpack_photon_url($url, $args, '//'); }
/** * This is just a tiny wrapper function for the class above so that there is no * need to change any code in your own WP themes. Usage is still the same :) */ function aq_resize($url, $width = null, $height = null, $crop = null, $single = true, $upscale = false) { if (class_exists('Jetpack') && Jetpack::is_module_active('photon')) { if (empty($height)) { $args = array('w' => $width); } else { if (empty($width)) { $args = array('h' => $height); } else { $args = array('resize' => $width . ',' . $height); } } if ($single) { // str return. $image = jetpack_photon_url($url, $args); } else { // array return. $image = array(0 => jetpack_photon_url($url, $args), 1 => '', 2 => ''); } return $image; } else { $aq_resize = Aq_Resize::getInstance(); return $aq_resize->process($url, $width, $height, $crop, $single, $upscale); } }
function get_icon() { if (function_exists('jetpack_site_icon_url') && function_exists('jetpack_photon_url')) { return array('img' => (string) jetpack_photon_url(jetpack_site_icon_url(get_current_blog_id(), 80), array('w' => 80), 'https'), 'ico' => (string) jetpack_photon_url(jetpack_site_icon_url(get_current_blog_id(), 16), array('w' => 16), 'https')); } return null; }
/** * Filter post thumbnail image retrieval, passing images through Photon * * @param string|bool $image * @param int $attachment_id * @param string|array $size * @uses is_admin, apply_filters, wp_get_attachment_url, this::validate_image_url, this::image_sizes, jetpack_photon_url * @filter image_downsize * @return string|bool */ public function filter_image_downsize($image, $attachment_id, $size) { // Don't foul up the admin side of things, and provide plugins a way of preventing Photon from being applied to images. if (is_admin() && apply_filters('jetpack_photon_override_image_downsize', true, compact('image', 'attachment_id', 'size'))) { return $image; } // Get the image URL and proceed with Photon-ification if successful $image_url = wp_get_attachment_url($attachment_id); if ($image_url) { // Check if image URL should be used with Photon if (!$this->validate_image_url($image_url)) { return $image; } // If an image is requested with a size known to WordPress, use that size's settings with Photon if (array_key_exists($size, $this->image_sizes())) { $image_args = $this->image_sizes(); $image_args = $image_args[$size]; // Expose arguments to a filter before passing to Photon $photon_args = array(); if ($image_args['crop']) { $photon_args['resize'] = $image_args['width'] . ',' . $image_args['height']; } else { $photon_args['fit'] = $image_args['width'] . ',' . $image_args['height']; } $photon_args = apply_filters('jetpack_photon_image_downsize_string', $photon_args, compact('image_args', 'image_url', 'attachment_id', 'size')); // Generate Photon URL $image = array(jetpack_photon_url($image_url, $photon_args), false, false); } elseif (is_array($size)) { // Pull width and height values from the provided array, if possible $width = isset($size[0]) ? (int) $size[0] : false; $height = isset($size[1]) ? (int) $size[1] : false; // Don't bother if necessary parameters aren't passed. if (!$width || !$height) { return $image; } // Expose arguments to a filter before passing to Photon $photon_args = array('fit' => $image_args['width'] . ',' . $image_args['height']); $photon_args = apply_filters('jetpack_photon_image_downsize_array', $photon_args, compact('width', 'height', 'image_url', 'attachment_id')); // Generate Photon URL $image = array(jetpack_photon_url($image_url, $photon_args), false, false); } } return $image; }
/** * Returns the URL to an image resized and cropped to the given dimensions. * * You can use this image URL directly -- it's cached and such by our servers. * Please use this function to generate the URL rather than doing it yourself as * this function uses staticize_subdomain() makes it serve off our CDN network. * * Somewhat contrary to the function's name, it can be used for ANY image URL, hosted by us or not. * So even though it says "remote", you can use it for attachments hosted by us, etc. * * @deprecated Deprecated since 2.0.0 - use jetpack_photon_url() * @link http://vip.wordpress.com/documentation/image-resizing-and-cropping/ Image Resizing And Cropping * @param string $url The raw URL to the image (URLs that redirect are currently not supported with the exception of http://foobar.wordpress.com/files/ type URLs) * @param int $width The desired width of the final image * @param int $height The desired height of the final image * @param bool $escape Optional. If true (the default), the URL will be run through esc_url(). Set this to false if you need the raw URL. * @return string */ function wpcom_vip_get_resized_remote_image_url($url, $width, $height, $escape = true) { _deprecated_function(__FUNCTION__, '2.0.0', 'jetpack_photon_url'); $width = (int) $width; $height = (int) $height; $thumburl = jetpack_photon_url($url, array('resize' => array($width, $height))); return $escape ? esc_url($thumburl) : $thumburl; }
public function widget($args, $instance) { /** This filter is documented in core/src/wp-includes/default-widgets.php */ $title = apply_filters('widget_title', $instance['title']); wp_enqueue_style('jetpack_display_posts_widget', plugins_url('wordpress-post-widget/style.css', __FILE__)); $site_info = $this->get_site_info($instance['url']); echo $args['before_widget']; if (false === $site_info) { echo '<p>' . __('We cannot load blog data at this time.', 'jetpack') . '</p>'; echo $args['after_widget']; return; } if (!empty($title)) { echo $args['before_title'] . esc_html($title . ': ' . $site_info->name) . $args['after_title']; } else { echo $args['before_title'] . esc_html($site_info->name) . $args['after_title']; } $site_hash = $this->get_site_hash($instance['url']); $data_from_cache = get_transient('display_posts_post_info_' . $site_hash); if (false === $data_from_cache) { $response = wp_remote_get(sprintf('https://public-api.wordpress.com/rest/v1.1/sites/%1$d/posts/%2$s', $site_info->ID, apply_filters('jetpack_display_posts_widget_posts_params', ''))); set_transient('display_posts_post_info_' . $site_hash, $response, 10 * MINUTE_IN_SECONDS); } else { $response = $data_from_cache; } if (is_wp_error($response)) { echo '<p>' . __('We cannot load blog data at this time.', 'jetpack') . '</p>'; echo $args['after_widget']; return; } $posts_info = json_decode($response['body']); echo '<div class="jetpack-display-remote-posts">'; if (isset($posts_info->error) && 'jetpack_error' == $posts_info->error) { echo '<p>' . __('We cannot display posts for this blog.', 'jetpack') . '</p>'; echo '</div><!-- .jetpack-display-remote-posts -->'; echo $args['after_widget']; return; } $number_of_posts = min($instance['number_of_posts'], count($posts_info->posts)); for ($i = 0; $i < $number_of_posts; $i++) { $single_post = $posts_info->posts[$i]; $post_title = $single_post->title ? $single_post->title : '( No Title )'; $target = ''; if (isset($instance['open_in_new_window']) && $instance['open_in_new_window'] == true) { $target = ' target="_blank"'; } echo '<h4><a href="' . esc_url($single_post->URL) . '"' . $target . '>' . esc_html($post_title) . '</a></h4>' . "\n"; if ($instance['featured_image'] == true && !empty($single_post->featured_image)) { $featured_image = $single_post->featured_image ? $single_post->featured_image : ''; /** * Allows setting up custom Photon parameters to manipulate the image output in the Display Posts widget. * * @see https://developer.wordpress.com/docs/photon/ * * @module widgets * * @since 3.6.0 * * @param array $args Array of Photon Parameters. */ $image_params = apply_filters('jetpack_display_posts_widget_image_params', array()); echo '<a title="' . esc_attr($post_title) . '" href="' . esc_url($single_post->URL) . '"><img src="' . jetpack_photon_url($featured_image, $image_params) . '" alt="' . esc_attr($post_title) . '"/></a>'; } if ($instance['show_excerpts'] == true) { $post_excerpt = $single_post->excerpt ? $single_post->excerpt : ''; echo $post_excerpt; } } echo '</div><!-- .jetpack-display-remote-posts -->'; echo $args['after_widget']; }
function widget($args, $instance) { $title = isset($instance['title']) ? $instance['title'] : false; if (false === $title) { $title = $this->default_title; } $title = apply_filters('widget_title', $title); $count = isset($instance['count']) ? (int) $instance['count'] : false; if ($count < 1 || 20 < $count) { $count = 10; } if (isset($instance['display']) && in_array($instance['display'], array('grid', 'list', 'text'))) { $display = $instance['display']; } else { $display = 'text'; } if ('text' != $display) { $get_image_options = array('fallback_to_avatars' => true, 'gravatar_default' => apply_filters('jetpack_static_url', is_ssl() ? 'https' : 'http' . '://en.wordpress.com/i/logo/white-gray-80.png')); if ('grid' == $display) { if ($count % 2 != 0) { $count++; } $get_image_options['avatar_size'] = 200; } else { $get_image_options['avatar_size'] = 40; } $get_image_options = apply_filters('jetpack_top_posts_widget_image_options', $get_image_options); } $posts = $this->get_by_views($count); if (!$posts) { $posts = $this->get_fallback_posts(); } echo $args['before_widget']; if (!empty($title)) { echo $args['before_title'] . $title . $args['after_title']; } if (!$posts) { if (current_user_can('edit_theme_options')) { echo '<p>' . sprintf(__('There are no posts to display. <a href="%s">Want more traffic?</a>', 'jetpack'), 'http://en.support.wordpress.com/getting-more-site-traffic/') . '</p>'; } echo $args['after_widget']; return; } switch ($display) { case 'list': case 'grid': wp_enqueue_style('widget-grid-and-list'); foreach ($posts as &$post) { $image = Jetpack_PostImages::get_image($post['post_id']); $post['image'] = $image['src']; if ('blavatar' != $image['from'] && 'gravatar' != $image['from']) { $size = (int) $get_image_options['avatar_size']; $post['image'] = jetpack_photon_url($post['image'], array('resize' => "{$size},{$size}")); } } unset($post); if ('grid' == $display) { echo "<div class='widgets-grid-layout no-grav'>\n"; foreach ($posts as $post) { ?> <div class="widget-grid-view-image"> <a href="<?php echo esc_url($post['permalink']); ?> " title="<?php echo esc_attr(wp_kses($post['title'], array())); ?> " class="bump-view" data-bump-view="tp"><img src="<?php echo esc_url($post['image']); ?> " /></a> </div> <?php } echo "</div>\n"; } else { echo "<ul class='widgets-list-layout no-grav'>\n"; foreach ($posts as $post) { ?> <li> <img src="<?php echo esc_url($post['image']); ?> " class='widgets-list-layout-blavatar' /> <div class="widgets-list-layout-links"><a href="<?php echo esc_url($post['permalink']); ?> " class="bump-view" data-bump-view="tp"><?php echo esc_html(wp_kses($post['title'], array())); ?> </a></div> </li> <?php } echo "</ul>\n"; } break; default: echo '<ul>'; foreach ($posts as $post) { echo '<li><a href="' . esc_url($post['permalink']) . '" class="bump-view" data-bump-view="tp">' . esc_html($post['title']) . "</a></li>\n"; } echo '</ul>'; } echo $args['after_widget']; }
function opengraphprotocoltools_image() { global $post; $meta_tags = array(); if (has_post_thumbnail($post)) { $image_tags = array(); $opengraphprotocoltools_image_id = get_post_thumbnail_id($post->ID); if (function_exists('jetpack_photon_url') && class_exists('Jetpack') && method_exists('Jetpack', 'get_active_modules') && in_array('photon', Jetpack::get_active_modules())) { $opengraphprotocoltools_image = wp_get_attachment_image_src($opengraphprotocoltools_image_id, 'full'); $image_tags['url'] = jetpack_photon_url($opengraphprotocoltools_image[0], array('resize' => '600,600')); $image_tags['width'] = '600'; $image_tags['height'] = '600'; } else { $opengraphprotocoltools_image = wp_get_attachment_image_src($opengraphprotocoltools_image_id, array(400, 400)); $image_tags['url'] = $opengraphprotocoltools_image[0]; $image_tags['width'] = $opengraphprotocoltools_image[1]; $image_tags['height'] = $opengraphprotocoltools_image[2]; } $meta_tags['http://ogp.me/ns#image'] = array($image_tags); $meta_tags['twitter:card'] = 'photo'; return $meta_tags; } $args = array('post_type' => 'attachment', 'post_mime_type' => 'image', 'post_parent' => $post->ID); if ($images = get_children($args)) { foreach ($images as $image) { $opengraphprotocoltools_image = wp_get_attachment_image_src($image->ID, 'medium'); $image_tags = array(); $image_tags['url'] = $opengraphprotocoltools_image[0]; $image_tags['width'] = $opengraphprotocoltools_image[1]; $image_tags['height'] = $opengraphprotocoltools_image[2]; $meta_tags['http://ogp.me/ns#image'] = array($image_tags); $meta_tags['twitter:card'] = 'photo'; return $meta_tags; } } // if no images, return the default $meta_tags['http://ogp.me/ns#image'] = opengraphprotocoltools_image_url_default(); return $meta_tags; }
public function __construct($attachment_image, $needs_attachment_link, $grayscale) { parent::__construct($attachment_image, $needs_attachment_link, $grayscale); $this->img_src_grayscale = jetpack_photon_url($this->img_src, array('filter' => 'grayscale', 'resize' => array($this->image->width, $this->image->height))); }
/** * Collects the necessary information to return for a site's response. * * @return (array) */ public function build_current_site_response() { global $wpdb, $wp_version; $response_format = self::$site_format; $is_user_logged_in = is_user_logged_in(); $visible = array(); if ($is_user_logged_in) { $current_user = wp_get_current_user(); $visible = get_user_meta($current_user->ID, 'blog_visibility', true); if (!is_array($visible)) { $visible = array(); } } $blog_id = (int) $this->api->get_blog_id_for_output(); $is_jetpack = true === apply_filters('is_jetpack_site', false, $blog_id); $site_url = get_option('siteurl'); if ($is_jetpack) { remove_filter('option_stylesheet', 'fix_theme_location'); if ('https' !== parse_url($site_url, PHP_URL_SCHEME)) { add_filter('set_url_scheme', array($this, 'force_http'), 10, 3); } } foreach (array_keys($response_format) as $key) { switch ($key) { case 'ID': $response[$key] = $blog_id; break; case 'name': $response[$key] = (string) htmlspecialchars_decode(get_bloginfo('name'), ENT_QUOTES); break; case 'description': $response[$key] = (string) htmlspecialchars_decode(get_bloginfo('description'), ENT_QUOTES); break; case 'URL': $response[$key] = (string) home_url(); break; case 'jetpack': $response[$key] = $is_jetpack; // jetpack magic affects this value break; case 'is_private': if (defined('IS_WPCOM') && IS_WPCOM) { $public_setting = get_option('blog_public'); if (-1 == $public_setting) { $response[$key] = true; } else { $response[$key] = false; } } else { $response[$key] = false; // magic } break; case 'visible': if ($is_user_logged_in) { $is_visible = true; if (isset($visible[$blog_id])) { $is_visible = $visible[$blog_id]; } // null and true are visible $response[$key] = $is_visible; } break; case 'post_count': if ($is_user_logged_in) { $response[$key] = (int) $wpdb->get_var("SELECT COUNT(*) FROM {$wpdb->posts} WHERE post_status = 'publish'"); } break; case 'lang': if ($is_user_logged_in) { $response[$key] = (string) get_bloginfo('language'); } break; case 'icon': if (function_exists('blavatar_domain') && function_exists('blavatar_exists') && function_exists('blavatar_url')) { $domain = blavatar_domain(home_url()); if (blavatar_exists($domain)) { $response[$key] = array('img' => (string) remove_query_arg('s', blavatar_url($domain, 'img')), 'ico' => (string) remove_query_arg('s', blavatar_url($domain, 'ico'))); } } elseif (function_exists('jetpack_site_icon_url') && function_exists('jetpack_photon_url')) { $response[$key] = array('img' => (string) jetpack_photon_url(jetpack_site_icon_url(get_current_blog_id(), 80), array('w' => 80), 'https'), 'ico' => (string) jetpack_photon_url(jetpack_site_icon_url(get_current_blog_id(), 16), array('w' => 16), 'https')); } break; case 'logo': // Set an empty response array. $response[$key] = array('id' => (int) 0, 'sizes' => array(), 'url' => ''); // Get current site logo values. $logo = get_option('site_logo'); // Update the response array if there's a site logo currenty active. if ($logo && 0 != $logo['id']) { $response[$key]['id'] = $logo['id']; $response[$key]['url'] = $logo['url']; foreach ($logo['sizes'] as $size => $properties) { $response[$key]['sizes'][$size] = $properties; } } break; case 'subscribers_count': if (function_exists('wpcom_subs_total_wpcom_subscribers')) { $total_wpcom_subs = wpcom_subs_total_wpcom_subscribers(array('blog_id' => $blog_id)); $response[$key] = $total_wpcom_subs; } else { $response[$key] = 0; // magic } break; case 'is_following': $response[$key] = (bool) $this->api->is_following($blog_id); break; case 'options': // Figure out if the blog supports VideoPress, have to do some extra checking for JP blogs $has_videopress = false; if (get_option('video_upgrade') == '1') { $has_videopress = true; } else { if (class_exists('Jetpack_Options')) { $videopress = Jetpack_Options::get_option('videopress', array()); if ($videopress['blog_id'] > 0) { $has_videopress = true; } } } // deprecated - see separate endpoint. get a list of supported post formats $all_formats = get_post_format_strings(); $supported = get_theme_support('post-formats'); $supported_formats = array(); if (isset($supported[0])) { foreach ($supported[0] as $format) { $supported_formats[$format] = $all_formats[$format]; } } // determine if sharing buttons should be visible by default $default_sharing_status = false; if (class_exists('Sharing_Service')) { $ss = new Sharing_Service(); $blog_services = $ss->get_blog_services(); $default_sharing_status = !empty($blog_services['visible']); } $is_mapped_domain = false; if (function_exists('get_primary_redirect')) { $primary_redirect = strtolower(get_primary_redirect()); if (false === strpos($primary_redirect, '.wordpress.com')) { $is_mapped_domain = true; } } if (function_exists('get_mime_types')) { $allowed_file_types = get_mime_types(); } else { // http://codex.wordpress.org/Uploading_Files $mime_types = get_allowed_mime_types(); foreach ($mime_types as $type => $mime_type) { $extras = explode('|', $type); foreach ($extras as $extra) { $allowed_file_types[] = $extra; } } } $response[$key] = array('timezone' => (string) get_option('timezone_string'), 'gmt_offset' => (double) get_option('gmt_offset'), 'videopress_enabled' => $has_videopress, 'login_url' => wp_login_url(), 'admin_url' => get_admin_url(), 'is_mapped_domain' => $is_mapped_domain, 'unmapped_url' => get_site_url($blog_id), 'featured_images_enabled' => current_theme_supports('post-thumbnails'), 'header_image' => get_theme_mod('header_image_data'), 'background_color' => get_theme_mod('background_color'), 'image_default_link_type' => get_option('image_default_link_type'), 'image_thumbnail_width' => (int) get_option('thumbnail_size_w'), 'image_thumbnail_height' => (int) get_option('thumbnail_size_h'), 'image_thumbnail_crop' => get_option('thumbnail_crop'), 'image_medium_width' => (int) get_option('medium_size_w'), 'image_medium_height' => (int) get_option('medium_size_h'), 'image_large_width' => (int) get_option('large_size_w'), 'image_large_height' => (int) get_option('large_size_h'), 'post_formats' => $supported_formats, 'allowed_file_types' => $allowed_file_types, 'default_likes_enabled' => (bool) apply_filters('wpl_is_enabled_sitewide', !get_option('disabled_likes')), 'default_sharing_status' => (bool) $default_sharing_status, 'default_comment_status' => 'closed' == get_option('default_comment_status') ? false : true, 'default_ping_status' => 'closed' == get_option('default_ping_status') ? false : true, 'software_version' => $wp_version); if (!current_user_can('edit_posts')) { unset($response[$key]); } break; case 'meta': $xmlrpc_scheme = apply_filters('wpcom_json_api_xmlrpc_scheme', parse_url(get_option('home'), PHP_URL_SCHEME)); $xmlrpc_url = site_url('xmlrpc.php', $xmlrpc_scheme); $response[$key] = (object) array('links' => (object) array('self' => (string) $this->get_site_link($blog_id), 'help' => (string) $this->get_site_link($blog_id, 'help'), 'posts' => (string) $this->get_site_link($blog_id, 'posts/'), 'comments' => (string) $this->get_site_link($blog_id, 'comments/'), 'xmlrpc' => (string) $xmlrpc_url)); break; } } if ($is_jetpack) { add_filter('option_stylesheet', 'fix_theme_location'); if ('https' !== parse_url($site_url, PHP_URL_SCHEME)) { remove_filter('set_url_scheme', array($this, 'force_http'), 10, 3); } } return $response; }
static function ssl_img($url) { if (false !== strpos($url, 'files.wordpress.com')) { return self::https($url); } else { return self::https(jetpack_photon_url($url)); } }
/** * Get an avatar from Photon * * @since JetpackComments (1.4) * @param string $url * @param int $size * @return string */ protected function photon_avatar($url, $size) { $size = (int) $size; return jetpack_photon_url($url, array('resize' => "{$size},{$size}")); }
function widget($args, $instance) { $title = isset($instance['title']) ? $instance['title'] : false; if (false === $title) { $title = $this->default_title; } /** This filter is documented in core/src/wp-includes/default-widgets.php */ $title = apply_filters('widget_title', $title); $count = isset($instance['count']) ? (int) $instance['count'] : false; if ($count < 1 || 10 < $count) { $count = 10; } /** * Control the number of displayed posts. * * @since 3.3.0 * * @param string $count Number of Posts displayed in the Top Posts widget. Default is 10. */ $count = apply_filters('jetpack_top_posts_widget_count', $count); $types = isset($instance['types']) ? (array) $instance['types'] : array('post', 'page'); if (isset($instance['display']) && in_array($instance['display'], array('grid', 'list', 'text'))) { $display = $instance['display']; } else { $display = 'text'; } if ('text' != $display) { $get_image_options = array('fallback_to_avatars' => true, 'gravatar_default' => apply_filters('jetpack_static_url', set_url_scheme('http://en.wordpress.com/i/logo/white-gray-80.png'))); if ('grid' == $display) { $get_image_options['avatar_size'] = 200; } else { $get_image_options['avatar_size'] = 40; } /** * Top Posts Widget Image options. * * @since 1.8.0 * * @param array $get_image_options { * Array of Image options. * @type bool true Should we default to Gravatars when no image is found? Default is true. * @type string $gravatar_default Default Image URL if no Gravatar is found. * @type int $avatar_size Default Image size. * } */ $get_image_options = apply_filters('jetpack_top_posts_widget_image_options', $get_image_options); } $posts = $this->get_by_views($count); // Filter the returned posts. Remove all posts that do not match the chosen Post Types. if (isset($types)) { foreach ($posts as $k => $post) { if (!in_array($post['post_type'], $types)) { unset($posts[$k]); } } } if (!$posts) { $posts = $this->get_fallback_posts(); } echo $args['before_widget']; if (!empty($title)) { echo $args['before_title'] . $title . $args['after_title']; } if (!$posts) { if (current_user_can('edit_theme_options')) { echo '<p>' . sprintf(__('There are no posts to display. <a href="%s">Want more traffic?</a>', 'jetpack'), 'http://en.support.wordpress.com/getting-more-site-traffic/') . '</p>'; } echo $args['after_widget']; return; } switch ($display) { case 'list': case 'grid': wp_enqueue_style('widget-grid-and-list'); foreach ($posts as &$post) { $image = Jetpack_PostImages::get_image($post['post_id'], array('fallback_to_avatars' => true)); $post['image'] = $image['src']; if ('blavatar' != $image['from'] && 'gravatar' != $image['from']) { $size = (int) $get_image_options['avatar_size']; $post['image'] = jetpack_photon_url($post['image'], array('resize' => "{$size},{$size}")); } } unset($post); if ('grid' == $display) { echo "<div class='widgets-grid-layout no-grav'>\n"; foreach ($posts as $post) { ?> <div class="widget-grid-view-image"> <?php /** * Fires before each Top Post result, inside <li>. * * @since 3.2.0 * * @param string $post['post_id'] Post ID. */ do_action('jetpack_widget_top_posts_before_post', $post['post_id']); ?> <a href="<?php echo esc_url($post['permalink']); ?> " title="<?php echo esc_attr(wp_kses($post['title'], array())); ?> " class="bump-view" data-bump-view="tp"> <img src="<?php echo esc_url($post['image']); ?> " alt="<?php echo esc_attr(wp_kses($post['title'], array())); ?> " data-pin-nopin="true" /> </a> <?php /** * Fires after each Top Post result, inside <li>. * * @since 3.2.0 * * @param string $post['post_id'] Post ID. */ do_action('jetpack_widget_top_posts_after_post', $post['post_id']); ?> </div> <?php } echo "</div>\n"; } else { echo "<ul class='widgets-list-layout no-grav'>\n"; foreach ($posts as $post) { ?> <li> <?php /** This action is documented in modules/widgets/top-posts.php */ do_action('jetpack_widget_top_posts_before_post', $post['post_id']); ?> <a href="<?php echo esc_url($post['permalink']); ?> " title="<?php echo esc_attr(wp_kses($post['title'], array())); ?> " class="bump-view" data-bump-view="tp"> <img src="<?php echo esc_url($post['image']); ?> " class='widgets-list-layout-blavatar' alt="<?php echo esc_attr(wp_kses($post['title'], array())); ?> " data-pin-nopin="true" /> </a> <div class="widgets-list-layout-links"> <a href="<?php echo esc_url($post['permalink']); ?> " class="bump-view" data-bump-view="tp"> <?php echo esc_html(wp_kses($post['title'], array())); ?> </a> </div> <?php /** This action is documented in modules/widgets/top-posts.php */ do_action('jetpack_widget_top_posts_after_post', $post['post_id']); ?> </li> <?php } echo "</ul>\n"; } break; default: echo '<ul>'; foreach ($posts as $post) { ?> <li> <?php /** This action is documented in modules/widgets/top-posts.php */ do_action('jetpack_widget_top_posts_before_post', $post['post_id']); ?> <a href="<?php echo esc_url($post['permalink']); ?> " class="bump-view" data-bump-view="tp"> <?php echo esc_html(wp_kses($post['title'], array())); ?> </a> <?php /** This action is documented in modules/widgets/top-posts.php */ do_action('jetpack_widget_top_posts_after_post', $post['post_id']); ?> </li> <?php } echo '</ul>'; } echo $args['after_widget']; }
/** * Collects the necessary information to return for a site's response. * * @return (array) */ public function build_current_site_response() { global $wpdb, $wp_version; $response_format = self::$site_format; $is_user_logged_in = is_user_logged_in(); $visible = array(); if ($is_user_logged_in) { $current_user = wp_get_current_user(); $visible = get_user_meta($current_user->ID, 'blog_visibility', true); if (!is_array($visible)) { $visible = array(); } } $blog_id = (int) $this->api->get_blog_id_for_output(); /** This filter is documented in class.json-api-endpoints.php */ $is_jetpack = true === apply_filters('is_jetpack_site', false, $blog_id); $site_url = get_option('siteurl'); if ($is_jetpack) { remove_filter('option_stylesheet', 'fix_theme_location'); if ('https' !== parse_url($site_url, PHP_URL_SCHEME)) { add_filter('set_url_scheme', array($this, 'force_http'), 10, 3); } } foreach (array_keys($response_format) as $key) { switch ($key) { case 'ID': $response[$key] = $blog_id; break; case 'name': $response[$key] = (string) htmlspecialchars_decode(get_bloginfo('name'), ENT_QUOTES); break; case 'description': $response[$key] = (string) htmlspecialchars_decode(get_bloginfo('description'), ENT_QUOTES); break; case 'URL': $response[$key] = (string) home_url(); break; case 'jetpack': $response[$key] = $is_jetpack; // jetpack magic affects this value break; case 'is_private': if (defined('IS_WPCOM') && IS_WPCOM) { $public_setting = get_option('blog_public'); if (-1 == $public_setting) { $response[$key] = true; } else { $response[$key] = false; } } else { $response[$key] = false; // magic } break; case 'visible': if ($is_user_logged_in) { $is_visible = true; if (isset($visible[$blog_id])) { $is_visible = (bool) $visible[$blog_id]; } // null and true are visible $response[$key] = $is_visible; } break; case 'post_count': if ($is_user_logged_in) { $response[$key] = (int) $wpdb->get_var("SELECT COUNT(*) FROM {$wpdb->posts} WHERE post_status = 'publish'"); } break; case 'lang': if ($is_user_logged_in) { $response[$key] = (string) get_bloginfo('language'); } break; case 'icon': if (function_exists('blavatar_domain') && function_exists('blavatar_exists') && function_exists('blavatar_url')) { $domain = blavatar_domain(home_url()); if (blavatar_exists($domain)) { $response[$key] = array('img' => (string) remove_query_arg('s', blavatar_url($domain, 'img')), 'ico' => (string) remove_query_arg('s', blavatar_url($domain, 'ico'))); } else { // This is done so that we can access the updated blavatar on .com via the /me/sites endpoint if (is_jetpack_site()) { $site_icon_url = get_option('jetpack_site_icon_url'); if ($site_icon_url) { $response[$key] = array('img' => (string) jetpack_photon_url($site_icon_url, array(), 'https'), 'ico' => (string) jetpack_photon_url($site_icon_url, array('w' => 16), 'https')); } } } } elseif (function_exists('jetpack_site_icon_url') && function_exists('jetpack_photon_url')) { $response[$key] = array('img' => (string) jetpack_photon_url(jetpack_site_icon_url(get_current_blog_id(), 80), array('w' => 80), 'https'), 'ico' => (string) jetpack_photon_url(jetpack_site_icon_url(get_current_blog_id(), 16), array('w' => 16), 'https')); } break; case 'logo': // Set an empty response array. $response[$key] = array('id' => (int) 0, 'sizes' => array(), 'url' => ''); // Get current site logo values. $logo = get_option('site_logo'); // Update the response array if there's a site logo currenty active. if ($logo && 0 != $logo['id']) { $response[$key]['id'] = $logo['id']; $response[$key]['url'] = $logo['url']; foreach ($logo['sizes'] as $size => $properties) { $response[$key]['sizes'][$size] = $properties; } } break; case 'subscribers_count': if (function_exists('wpcom_subs_total_wpcom_subscribers')) { $total_wpcom_subs = wpcom_subs_total_wpcom_subscribers(array('blog_id' => $blog_id)); $response[$key] = $total_wpcom_subs; } else { $response[$key] = 0; // magic } break; case 'is_following': $response[$key] = (bool) $this->api->is_following($blog_id); break; case 'options': // Figure out if the blog supports VideoPress, have to do some extra checking for JP blogs $has_videopress = false; if (get_option('video_upgrade') == '1') { $has_videopress = true; } else { if (class_exists('Jetpack_Options')) { $videopress = Jetpack_Options::get_option('videopress', array()); if (isset($videopress['blog_id']) && $videopress['blog_id'] > 0) { $has_videopress = true; } } } // deprecated - see separate endpoint. get a list of supported post formats $all_formats = get_post_format_strings(); $supported = get_theme_support('post-formats'); $supported_formats = array(); if (isset($supported[0])) { foreach ($supported[0] as $format) { $supported_formats[$format] = $all_formats[$format]; } } // determine if sharing buttons should be visible by default $default_sharing_status = false; if (class_exists('Sharing_Service')) { $ss = new Sharing_Service(); $blog_services = $ss->get_blog_services(); $default_sharing_status = !empty($blog_services['visible']); } $is_mapped_domain = false; if (function_exists('get_primary_redirect')) { $primary_redirect = strtolower(get_primary_redirect()); if (false === strpos($primary_redirect, '.wordpress.com')) { $is_mapped_domain = true; } } $is_redirect = false; if (function_exists('get_primary_domain_mapping_record')) { if (get_primary_domain_mapping_record()->type == 1) { $is_redirect = true; } } if (function_exists('get_mime_types')) { $allowed_file_types = get_mime_types(); } else { // http://codex.wordpress.org/Uploading_Files $mime_types = get_allowed_mime_types(); foreach ($mime_types as $type => $mime_type) { $extras = explode('|', $type); foreach ($extras as $extra) { $allowed_file_types[] = $extra; } } } if (function_exists('get_blog_details')) { $blog_details = get_blog_details(); if (!empty($blog_details->registered)) { $registered_date = $blog_details->registered; } } $upgraded_filetypes_enabled = false; if ($is_jetpack || get_option('use_upgraded_upload_filetypes')) { $upgraded_filetypes_enabled = true; } $wordads = false; if (function_exists('has_any_blog_stickers')) { $wordads = has_any_blog_stickers(array('wordads-approved', 'wordads-approved-misfits'), $blog_id); } $response[$key] = array('timezone' => (string) get_option('timezone_string'), 'gmt_offset' => (double) get_option('gmt_offset'), 'videopress_enabled' => $has_videopress, 'upgraded_filetypes_enabled' => $upgraded_filetypes_enabled, 'login_url' => wp_login_url(), 'admin_url' => get_admin_url(), 'is_mapped_domain' => $is_mapped_domain, 'is_redirect' => $is_redirect, 'unmapped_url' => get_site_url($blog_id), 'featured_images_enabled' => current_theme_supports('post-thumbnails'), 'theme_slug' => get_option('stylesheet'), 'header_image' => get_theme_mod('header_image_data'), 'background_color' => get_theme_mod('background_color'), 'image_default_link_type' => get_option('image_default_link_type'), 'image_thumbnail_width' => (int) get_option('thumbnail_size_w'), 'image_thumbnail_height' => (int) get_option('thumbnail_size_h'), 'image_thumbnail_crop' => get_option('thumbnail_crop'), 'image_medium_width' => (int) get_option('medium_size_w'), 'image_medium_height' => (int) get_option('medium_size_h'), 'image_large_width' => (int) get_option('large_size_w'), 'image_large_height' => (int) get_option('large_size_h'), 'permalink_structure' => get_option('permalink_structure'), 'post_formats' => $supported_formats, 'default_post_format' => get_option('default_post_format'), 'default_category' => (int) get_option('default_category'), 'allowed_file_types' => $allowed_file_types, 'show_on_front' => get_option('show_on_front'), 'default_likes_enabled' => (bool) apply_filters('wpl_is_enabled_sitewide', !get_option('disabled_likes')), 'default_sharing_status' => (bool) $default_sharing_status, 'default_comment_status' => 'closed' == get_option('default_comment_status') ? false : true, 'default_ping_status' => 'closed' == get_option('default_ping_status') ? false : true, 'software_version' => $wp_version, 'created_at' => !empty($registered_date) ? $this->format_date($registered_date) : '0000-00-00T00:00:00+00:00', 'wordads' => $wordads); if ('page' === get_option('show_on_front')) { $response['options']['page_on_front'] = (int) get_option('page_on_front'); $response['options']['page_for_posts'] = (int) get_option('page_for_posts'); } if ($is_jetpack) { $response['options']['jetpack_version'] = get_option('jetpack_version'); if (get_option('jetpack_main_network_site')) { $response['options']['main_network_site'] = (string) rtrim(get_option('jetpack_main_network_site'), '/'); } if (is_array(Jetpack_Options::get_option('active_modules'))) { $response['options']['active_modules'] = (array) array_values(Jetpack_Options::get_option('active_modules')); } if ($jetpack_wp_version = get_option('jetpack_wp_version')) { $response['options']['software_version'] = (string) $jetpack_wp_version; } else { if ($jetpack_update = get_option('jetpack_updates')) { if (is_array($jetpack_update) && isset($jetpack_update['wp_version'])) { $response['options']['software_version'] = (string) $jetpack_update['wp_version']; } else { $response['options']['software_version'] = null; } } else { $response['options']['software_version'] = null; } } $response['options']['max_upload_size'] = get_option('jetpack_max_upload_size', false); // Sites have to prove that they are not main_network site. // If the sync happends right then we should be able to see that we are not dealing with a network site $response['options']['is_multi_network'] = (bool) get_option('jetpack_is_main_network', true); $response['options']['is_multi_site'] = (bool) get_option('jetpack_is_multi_site', true); } if (!current_user_can('edit_posts')) { unset($response[$key]); } break; case 'meta': /** * Filters the URL scheme used when querying your site's REST API endpoint. * * @module json-api * * @since 3.2.0 * * @param string parse_url( get_option( 'home' ), PHP_URL_SCHEME ) URL scheme parsed from home URL. */ $xmlrpc_scheme = apply_filters('wpcom_json_api_xmlrpc_scheme', parse_url(get_option('home'), PHP_URL_SCHEME)); $xmlrpc_url = site_url('xmlrpc.php', $xmlrpc_scheme); $response[$key] = (object) array('links' => (object) array('self' => (string) $this->get_site_link($blog_id), 'help' => (string) $this->get_site_link($blog_id, 'help'), 'posts' => (string) $this->get_site_link($blog_id, 'posts/'), 'comments' => (string) $this->get_site_link($blog_id, 'comments/'), 'xmlrpc' => (string) $xmlrpc_url)); break; } } if ($is_jetpack) { // Add the updates only make them visible if the user has manage options permission. $jetpack_update = (array) get_option('jetpack_updates'); if (!empty($jetpack_update) && current_user_can('manage_options')) { if (isset($jetpack_update['wp_version'])) { // In previous version of Jetpack 3.4, 3.5, 3.6 we synced the wp_version into to jetpack_updates unset($jetpack_update['wp_version']); } if (isset($jetpack_update['site_is_version_controlled'])) { // In previous version of Jetpack 3.4, 3.5, 3.6 we synced the site_is_version_controlled into to jetpack_updates unset($jetpack_update['site_is_version_controlled']); } $response['updates'] = (array) $jetpack_update; } add_filter('option_stylesheet', 'fix_theme_location'); if ('https' !== parse_url($site_url, PHP_URL_SCHEME)) { remove_filter('set_url_scheme', array($this, 'force_http'), 10, 3); } } return $response; }
/** * Resize an image using DSLC_Aq_Resize Class * * @since 1.0 * * @param string $url The URL of the image * @param int $width The new width of the image * @param int $height The new height of the image * @param bool $crop To crop or not to crop, the question is now * @param bool $single If true only returns the URL, if false returns array * @param bool $upscale If image not big enough for new size should it upscale * @return mixed If $single is true return new image URL, if it is false return array * Array contains 0 = URL, 1 = width, 2 = height */ function dslc_aq_resize($url, $width = null, $height = null, $crop = null, $single = true, $upscale = false) { if (class_exists('Jetpack') && Jetpack::is_module_active('photon')) { $args = array('resize' => "{$width},{$height}"); if ($single == true) { return jetpack_photon_url($url, $args); } else { $image = array(0 => $img_url, 1 => $width, 2 => $height); return jetpack_photon_url($url, $args); } } else { $aq_resize = DSLC_Aq_Resize::getInstance(); return $aq_resize->process($url, $width, $height, $crop, $single, $upscale); } }
function jig_init_shortcode($atts) { if ($this->settings['take_over_gallery'] === 'hide') { remove_shortcode('gallery'); add_shortcode('gallery', array($this, 'jig_blank_gallery')); } global $justified_image_grid_instance; $justified_image_grid_instance++; $jig_id = $justified_image_grid_instance; global $post; extract(shortcode_atts(array('preset' => NULL, 'mobile_preset' => NULL), $atts)); if (!empty($mobile_preset)) { if (!class_exists("Mobile_Detect")) { include 'mobiledetect.php'; } $detect = new Mobile_Detect(); if ($detect->isMobile()) { $preset = $mobile_preset; } } if (!empty($preset)) { // takes the default values that are overridden by the preset's values, this ensures a clean preset view // BUT overrides with the protected values (system settings) AND the 'settings_flexbile' $this->settings_backup = $this->settings; if (substr($preset, 0, 1) !== 'c') { if (!empty($this->presets[$preset])) { $this->settings = array_merge(array_merge($this->defaults, $this->presets[$preset]), $this->settings_override); } } else { if (!empty($this->custom_presets[(int) substr($preset, 1)])) { $this->settings = array_merge(array_merge($this->defaults, $this->custom_presets[(int) substr($preset, 1)]), $this->settings_override); } } } if (function_exists('icl_translate')) { $icl_context = 'admin_texts_plugin_' . self::PAGE_NAME; $icl_name = '[' . self::SETTINGS_NAME . ']'; // NOT shortcode attributes $please_log_in = icl_translate($icl_context, $icl_name . 'please_log_in', $this->settings['please_log_in']); $view_rest_of_gallery = icl_translate($icl_context, $icl_name . 'view_rest_of_gallery', $this->settings['view_rest_of_gallery']); $download_link_text = icl_translate($icl_context, $icl_name . 'download_link_text', $this->settings['download_link_text']); $flickr_link_text = icl_translate($icl_context, $icl_name . 'flickr_link_text', $this->settings['flickr_link_text']); $instagram_link_text = icl_translate($icl_context, $icl_name . 'instagram_link_text', $this->settings['instagram_link_text']); $developer_link_text = icl_translate($icl_context, $icl_name . 'developer_link_text', $this->settings['developer_link_text']); $notice_before = icl_translate($icl_context, $icl_name . 'text_before', $this->settings['text_before']); $notice_after = icl_translate($icl_context, $icl_name . 'text_after', $this->settings['text_after']); // shortcode attributes $load_more_text = icl_translate($icl_context, $icl_name . 'load_more_text', $this->settings['load_more_text']); $load_more_count_text = icl_translate($icl_context, $icl_name . 'load_more_count_text', $this->settings['load_more_count_text']); $filter_all_text = icl_translate($icl_context, $icl_name . 'filter_all_text', $this->settings['filter_all_text']); $l2_filter_all_text = icl_translate($icl_context, $icl_name . 'l2_filter_all_text', $this->settings['l2_filter_all_text']); $rss_link_text = icl_translate($icl_context, $icl_name . 'rss_link_text', $this->settings['rss_link_text']); } else { $please_log_in = $this->settings['please_log_in']; $view_rest_of_gallery = $this->settings['view_rest_of_gallery']; $download_link_text = $this->settings['download_link_text']; $flickr_link_text = $this->settings['flickr_link_text']; $instagram_link_text = $this->settings['instagram_link_text']; $developer_link_text = $this->settings['developer_link_text']; $notice_before = $this->settings['text_before']; $notice_after = $this->settings['text_after']; $load_more_text = $this->settings['load_more_text']; $load_more_count_text = $this->settings['load_more_count_text']; $filter_all_text = $this->settings['filter_all_text']; $l2_filter_all_text = $this->settings['l2_filter_all_text']; $rss_link_text = $this->settings['rss_link_text']; } extract(shortcode_atts(array('ids' => '', 'thumbs_spacing' => $this->settings['thumbs_spacing'], 'animation_speed' => $this->settings['animation_speed'], 'row_height' => $this->settings['row_height'], 'height_deviation' => $this->settings['height_deviation'], 'mobile_row_height' => $this->settings['mobile_row_height'], 'mobile_height_dev' => $this->settings['mobile_height_dev'], 'limit' => $this->settings['limit'], 'hidden_limit' => $this->settings['hidden_limit'], 'load_more' => $this->settings['load_more'], 'load_more_mobile' => $this->settings['load_more_mobile'], 'load_more_limit' => $this->settings['load_more_limit'], 'load_more_text' => $load_more_text, 'load_more_count_text' => $load_more_count_text, 'load_more_offset' => $this->settings['load_more_offset'], 'load_more_auto_width' => $this->settings['load_more_auto_width'], 'max_rows' => $this->settings['max_rows'], 'custom_width' => $this->settings['custom_width'], 'width_mode' => $this->settings['width_mode'], 'last_row' => $this->settings['last_row'], 'aspect_ratio' => $this->settings['aspect_ratio'], 'disable_cropping' => $this->settings['disable_cropping'], 'randomize_width' => $this->settings['randomize_width'], 'link_target' => $this->settings['link_target'], 'orderby' => $this->settings['orderby'], 'filterby' => $this->settings['filterby'], 'filter_style' => $this->settings['filter_style'], 'filter_all_text' => $filter_all_text, 'filter_orderby' => $this->settings['filter_orderby'], 'filter_custom_order' => $this->settings['filter_custom_order'], 'filter_min_count' => $this->settings['filter_min_count'], 'filter_top_x' => $this->settings['filter_top_x'], 'filter_all_button' => $this->settings['filter_all_button'], 'filter_multiple' => $this->settings['filter_multiple'], 'l2_filterby' => $this->settings['l2_filterby'], 'l2_filter_style' => $this->settings['l2_filter_style'], 'l2_filter_all_text' => $l2_filter_all_text, 'l2_filter_orderby' => $this->settings['l2_filter_orderby'], 'l2_filter_custom_order' => $this->settings['l2_filter_custom_order'], 'l2_filter_min_count' => $this->settings['l2_filter_min_count'], 'l2_filter_top_x' => $this->settings['l2_filter_top_x'], 'l2_filter_all_button' => $this->settings['l2_filter_all_button'], 'l2_filter_multiple' => $this->settings['l2_filter_multiple'], 'allow_animated_gifs' => $this->settings['allow_animated_gifs'], 'allow_transp_pngs' => $this->settings['allow_transp_pngs'], 'process_shortcodes' => $this->settings['process_shortcodes'], 'wrap_text' => $this->settings['wrap_text'], 'reading_direction' => $this->settings['reading_direction'], 'link_class' => $this->settings['link_class'], 'link_rel' => $this->settings['link_rel'], 'link_attribute_name' => $this->settings['link_attribute_name'], 'link_attribute_value' => $this->settings['link_attribute_value'], 'use_link_attributes' => $this->settings['use_link_attributes'], 'link_title_field' => $this->settings['link_title_field'], 'img_alt_field' => $this->settings['img_alt_field'], 'lightbox_custom_field' => $this->settings['lightbox_custom_field'], 'prettyphoto_social' => $this->settings['prettyphoto_social'], 'pp_social_buttons' => $this->settings['pp_social_buttons'], 'prettyphoto_theme' => $this->settings['prettyphoto_theme'], 'prettyphoto_analytics' => $this->settings['prettyphoto_analytics'], 'prettyphoto_title_pos' => $this->settings['prettyphoto_title_pos'], 'photoswipe_social' => $this->settings['photoswipe_social'], 'ps_social_buttons' => $this->settings['ps_social_buttons'], 'magnific_zoom' => $this->settings['magnific_zoom'], 'private_lightbox' => $this->settings['private_lightbox'], 'load_bundled_lightbox' => $this->settings['load_bundled_lightbox'], 'title_field' => $this->settings['title_field'], 'caption_field' => $this->settings['caption_field'], 'caption_custom_field' => $this->settings['caption_custom_field'], 'custom_link_follow' => $this->settings['custom_link_follow'], 'only_for_logged_in' => $this->settings['only_for_logged_in'], 'caption' => $this->settings['caption'], 'mobile_caption' => $this->settings['mobile_caption'], 'caption_opacity' => $this->settings['caption_opacity'], 'caption_bg_color' => $this->settings['caption_bg_color'], 'caption_match_width' => $this->settings['caption_match_width'], 'caption_text_color' => $this->settings['caption_text_color'], 'caption_height' => $this->settings['caption_height'], 'mobile_caption_height' => $this->settings['mobile_caption_height'], 'caption_title_size' => $this->settings['caption_title_size'], 'caption_desc_size' => $this->settings['caption_desc_size'], 'caption_align' => $this->settings['caption_align'], 'v_center_captions' => $this->settings['v_center_captions'], 'custom_fonts' => $this->settings['custom_fonts'], 'caption_text_shadow' => $this->settings['caption_text_shadow'], 'gradient_caption_bg' => $this->settings['gradient_caption_bg'], 'overlay' => $this->settings['overlay'], 'mobile_overlay' => $this->settings['mobile_overlay'], 'overlay_color' => $this->settings['overlay_color'], 'overlay_opacity' => $this->settings['overlay_opacity'], 'overlay_icon' => $this->settings['overlay_icon'], 'overlay_icon_opacity' => $this->settings['overlay_icon_opacity'], 'overlay_icon_url' => $this->settings['overlay_icon_url'], 'overlay_icon_retina' => $this->settings['overlay_icon_retina'], 'outer_shadow' => $this->settings['outer_shadow'], 'inner_shadow' => $this->settings['inner_shadow'], 'outer_border_width' => $this->settings['outer_border_width'], 'outer_border_color' => $this->settings['outer_border_color'], 'outer_border' => $this->settings['outer_border'], 'middle_border_width' => $this->settings['middle_border_width'], 'middle_border_color' => $this->settings['middle_border_color'], 'middle_border' => $this->settings['middle_border'], 'inner_border_width' => $this->settings['inner_border_width'], 'inner_border_color' => $this->settings['inner_border_color'], 'inner_border' => $this->settings['inner_border'], 'inner_border_animate' => $this->settings['inner_border_animate'], 'desaturate' => '', 'specialfx' => $this->settings['specialfx'], 'mobile_specialfx' => $this->settings['mobile_specialfx'], 'specialfx_type' => $this->settings['specialfx_type'], 'specialfx_blend' => $this->settings['specialfx_blend'], 'caption_fx_visibility' => $this->settings['caption_fx_visibility'], 'specialfx_options' => $this->settings['specialfx_options'], 'lightbox' => $this->settings['lightbox'], 'mobile_lightbox' => $this->settings['mobile_lightbox'], 'lightbox_max_size' => $this->settings['lightbox_max_size'], 'min_height' => $this->settings['min_height'], 'loading_background' => $this->settings['loading_background'], 'link_override' => '', 'separator_character' => $this->settings['separator_character'], 'show_text_before' => 'yes', 'show_text_after' => 'yes', 'margin' => $this->settings['margin'], "retina_ready" => $this->settings['retina_ready'], 'quality' => $this->settings['quality'], 'retina_quality' => $this->settings['retina_quality'], 'min_retina_quality' => $this->settings['min_retina_quality'], 'max_retina_density' => $this->settings['max_retina_density'], 'timthumb_path' => $this->settings['timthumb_path'], 'timthumb_crop_zone' => $this->settings['timthumb_crop_zone'], 'use_timthumb' => $this->settings['use_timthumb'], 'mouse_disable' => $this->settings['mouse_disable'], 'disable_mobile_hover' => $this->settings['disable_mobile_hover'], 'error_checking' => $this->settings['error_checking'], 'id' => !empty($post->ID) ? $post->ID : '', 'nggallery' => '', 'ngalbum' => '', 'ng_gallery' => '', 'ng_album' => '', 'ng_pics' => '', 'ng_tags_gallery' => '', 'ng_tags_album' => '', 'ng_recent_images' => '', 'ng_random_images' => '', 'ng_search_query' => '', 'ng_search_options' => '', 'ng_count' => $this->settings['ng_count'], 'ng_lightbox_gallery' => $this->settings['ng_lightbox_gallery'], 'ng_description' => $this->settings['ng_description'], 'ng_intersect_tags' => $this->settings['ng_intersect_tags'], 'ng_narrow_by_tags' => '', 'ng_display_tags' => $this->settings['ng_display_tags'], 'ng_breadcrumb' => 'no', 'ng_bc_separator' => 'default', 'ng_bc_base' => __('You are here:', 'jig_td'), 'ng_bc_home' => 'post_title', 'ng_bc_home_text' => __('Home', 'jig_td'), 'ng_bc_home_clickable' => 'yes', 'ng_bc_last_clickable' => 'no', 'ng_bc_top_level' => 'yes', 'ng_bc_add_separator' => 'no', 'nextgen_cf_link' => $this->settings['nextgen_cf_link'], 'exclude' => '', 'include' => '', 'image_tags' => '', 'image_categories' => '', 'image_taxonomy' => '', 'image_tax_term' => '', 'parent_id' => '', 'facebook_id' => '', 'facebook_album' => '', 'facebook_image_size' => $this->settings['facebook_image_size'], 'facebook_caching' => $this->settings['facebook_caching'], 'facebook_count' => $this->settings['facebook_count'], 'facebook_description' => $this->settings['facebook_description'], 'fb_lightbox_album' => $this->settings['fb_lightbox_album'], 'fb_actual_cover_photo' => $this->settings['fb_actual_cover_photo'], 'fb_album_exclude' => 'no', 'fb_breadcrumb' => 'yes', 'fb_bc_separator' => 'default', 'fb_bc_home_text' => '', 'flickr_user' => '', 'flickr_photostream' => '', 'flickr_favorites' => '', 'flickr_group' => '', 'flickr_photoset' => '', 'flickr_collection' => '', 'flickr_gallery' => '', 'flickr_search_text' => '', 'flickr_search_tags' => '', 'flickr_search_tags_m' => '', 'flickr_search_user' => '', 'flickr_search_group' => '', 'flickr_search_sort' => 'date-posted-desc', 'flickr_search_license' => '', 'flickr_search_geo' => '', 'flickr_caching' => $this->settings['flickr_caching'], 'flickr_count' => $this->settings['flickr_count'], 'flickr_description' => $this->settings['flickr_description'], 'flickr_lightbox_set' => $this->settings['flickr_lightbox_set'], 'flickr_breadcrumb' => 'yes', 'flickr_bc_separator' => 'default', 'flickr_bc_home_text' => '', 'instagram_feed' => '', 'instagram_recents' => '', 'instagram_liked' => '', 'instagram_tag' => '', 'instagram_location' => '', 'instagram_tag_filter' => '', 'instagram_tag_mode' => 'or', 'instagram_blacklist' => $this->settings['instagram_blacklist'], 'instagram_caching' => $this->settings['instagram_caching'], 'instagram_show_user' => $this->settings['instagram_show_user'], 'instagram_link' => $this->settings['instagram_link'], 'rss_url' => '', 'href' => '', 'rss_links_to' => $this->settings['rss_links_to'], 'rss_description' => $this->settings['rss_description'], 'rss_excerpt_length' => $this->settings['rss_excerpt_length'], 'rss_excerpt_ending' => $this->settings['rss_excerpt_ending'], 'rss_link' => $this->settings['rss_link'], 'rss_link_text' => $rss_link_text, 'rss_caching' => $this->settings['rss_caching'], 'developer_link' => $this->settings['developer_link'], 'download_link' => $this->settings['download_link'], 'flickr_link' => $this->settings['flickr_link'], 'recent_posts' => 'no', 'post_ids' => '', 'post_ids_exclude' => '', 'recents_description' => 'nothing', 'recents_description_2' => 'nothing', 'recents_description_3' => 'nothing', 'post_metadata_fields' => '', 'recents_title_override' => '', 'recents_exclude' => '', 'recents_include' => '', 'recents_tags' => '', 'recents_filter_tax' => '', 'recents_filter_term' => '', 'recents_author' => '', 'recents_placeholder' => '', 'recents_post_type' => 'post', 'recents_link_to' => 'post', 'recents_link' => 'no', 'recents_link_text' => __('Read more', 'jig_td'), 'recents_custom_links' => 'no', 'recents_sticky' => '', 'recents_date_range' => '', 'recents_last_x_days' => '', 'excerpt_length' => 20, 'excerpt_ending' => ' [...]', 'author_prefix' => __('by', 'jig_td'), 'comments_text' => __('comment', 'jig_td') . ' | ' . __('comments', 'jig_td'), 'recents_parent_id' => '', 'recents_tree_depth' => '', 'for_xml_sitemap' => 'no'), $atts)); if ($show_text_before !== 'yes') { $notice_before = ''; } if ($show_text_after !== 'yes') { $notice_after = ''; } if ($only_for_logged_in == 'yes' && is_user_logged_in() == false) { return $this->frontend_stop(trim(__($please_log_in, 'jig_td')), false); } if ($private_lightbox == 'yes' && is_user_logged_in() == false) { $lightbox = 'links-off'; $mobile_lightbox = 'links-off'; } if ($this->settings['blog_view_limit'] && is_numeric($this->settings['blog_view_limit']) && !is_singular()) { $limit = (int) $this->settings['blog_view_limit']; $hidden_limit = ''; if (__($view_rest_of_gallery, 'jig_td') !== '') { $notice_after .= '<div id="jig' . $jig_id . '-viewRestOfGallery"><a href="' . get_permalink(get_the_ID()) . '">' . __($view_rest_of_gallery, 'jig_td') . '</a></div>'; $gallery_truncated_with_message = true; } } if ($caption_custom_field !== '') { $caption_custom_field_array = explode(',', str_replace(', ', ',', $caption_custom_field)); if ($title_field == 'custom' && !empty($caption_custom_field_array)) { $title_field = 'custom_field_' . array_shift($caption_custom_field_array); } if ($caption_field == 'custom' && !empty($caption_custom_field_array)) { $caption_field = 'custom_field_' . array_shift($caption_custom_field_array); } } if ($lightbox_custom_field !== '') { $lightbox_custom_field_array = explode(',', str_replace(', ', ',', $lightbox_custom_field)); if ($link_title_field == 'custom' && !empty($lightbox_custom_field_array)) { $link_title_field = 'custom_field_' . array_shift($lightbox_custom_field_array); } if ($img_alt_field == 'custom' && !empty($lightbox_custom_field_array)) { $img_alt_field = 'custom_field_' . array_shift($lightbox_custom_field_array); } } $photon_activated = class_exists('Jetpack') && method_exists('Jetpack', 'get_active_modules') && in_array('photon', Jetpack::get_active_modules()) && function_exists('jetpack_photon_url'); $carousel_activated = $lightbox == 'carousel' && (class_exists('Jetpack') && method_exists('Jetpack', 'get_active_modules') && in_array('carousel', Jetpack::get_active_modules()) && class_exists('Jetpack_Carousel') || class_exists('CarouselWithoutJetpack')); if ($lightbox == 'carousel' && $carousel_activated === false) { $lightbox = 'prettyphoto'; } if ($filterby !== 'off' || $l2_filterby !== 'off') { global $justified_image_grid_filtering_css_needed; $justified_image_grid_filtering_css_needed = true; } if (!empty($link_attribute_value)) { $link_attribute_value = str_replace('*instance*', $jig_id, $link_attribute_value); } $separator_character = !empty($separator_character) ? ' ' . $separator_character . ' ' : ''; $gallery_type = 'wp_post_gallery'; if ($hidden_limit) { $real_limit = $limit; $limit = $hidden_limit; } if ($nggallery !== '' && $ng_gallery == '') { $ng_gallery = $nggallery; } if ($ngalbum !== '' && $ng_album == '') { $ng_album = $ngalbum; } if ($id !== '' && $id != $post->ID) { $gallery_type = 'wp_post_gallery'; } elseif ($recent_posts === 'yes') { $gallery_type = 'wp_recent_posts'; } elseif ($ng_gallery !== '' || $ng_album !== '' || $ng_pics !== '' || $ng_tags_gallery !== '' || $ng_tags_album !== '' || $ng_recent_images !== '' || $ng_random_images !== '' || $ng_search_query !== '') { $gallery_type = 'nextgen'; } elseif ($facebook_id && $facebook_album) { $gallery_type = 'facebook'; } elseif ($flickr_photostream !== '' || $flickr_favorites !== '' || $flickr_user !== '' && ($flickr_group !== '' || $flickr_photoset !== '' || $flickr_collection !== '' || $flickr_gallery !== '') || $flickr_search_text !== '' || $flickr_search_tags !== '') { $gallery_type = 'flickr'; } elseif ($instagram_feed !== '' || $instagram_recents !== '' || $instagram_liked !== '' || $instagram_tag !== '' || $instagram_location !== '') { $gallery_type = 'instagram'; } elseif ($rss_url !== '') { $gallery_type = 'rss'; } if ($for_xml_sitemap === 'yes' && ($gallery_type === 'flickr' || $gallery_type === 'facebook' || $gallery_type === 'instagram' || $gallery_type === 'rss')) { return $this->frontend_stop(); } if ($lightbox == 'carousel' && $gallery_type !== "wp_post_gallery" && $gallery_type !== "wp_recent_posts") { $lightbox = 'prettyphoto'; } // switch link rel to legacy mode to have old users still benefit from the unified hash if ($link_rel == 'auto' && $lightbox == 'prettyphoto' && $mobile_lightbox == 'photoswipe') { $link_rel = 'prettyPhoto[' . $jig_id . ']'; } elseif ($link_rel == '') { $link_rel = 'jig[*instance*]'; } $disable_hover = 'no'; if ($mobile_lightbox !== 'no' || $mobile_caption !== 'same' || $mobile_overlay !== 'same' || $mobile_specialfx !== 'same' || $disable_mobile_hover !== 'no' || $load_more_mobile !== 'no' || $mobile_row_height !== '' || $mobile_height_dev !== '' || $mobile_caption_height !== '') { if (!class_exists("Mobile_Detect")) { include 'mobiledetect.php'; } if (empty($detect)) { $detect = new Mobile_Detect(); } if ($detect->isMobile()) { if ($mobile_lightbox !== 'no') { $lightbox = $mobile_lightbox; } if ($mobile_caption !== 'same') { $caption = $mobile_caption; } if ($mobile_overlay !== 'same') { $overlay = $mobile_overlay; } if ($mobile_specialfx !== 'same') { $specialfx = $mobile_specialfx; } if ($disable_mobile_hover !== 'no') { $disable_hover = $disable_mobile_hover; } if ($use_link_attributes == 'desktop') { $link_class = ''; $link_rel = 'jig[*instance*]'; $link_attribute_name = ''; $link_attribute_value = ''; } if ($this->settings['jquery_mobile'] == 'yes' && ($link_rel == 'auto' || $link_rel == 'jig[*instance*]')) { $link_rel .= ' external'; } if ($load_more_mobile !== 'no' && $load_more_mobile !== 'yes') { $load_more = $load_more_mobile; } $row_height = $mobile_row_height !== '' ? $mobile_row_height : $row_height; $height_deviation = $mobile_height_dev !== '' ? $mobile_height_dev : $height_deviation; $caption_height = $mobile_caption_height !== '' ? $mobile_caption_height : $caption_height; } else { if ($load_more_mobile == 'yes') { $load_more = 'off'; } if ($use_link_attributes == 'mobile') { $link_class = ''; $link_rel = 'jig[*instance*]'; $link_attribute_name = ''; $link_attribute_value = ''; } } } if ($load_more !== 'off') { $max_rows = ''; } $this->max_height = $max_height = $row_height + $height_deviation; $title_needed = $title_field == 'title' || $caption_field == 'title' || $link_title_field == 'title' || $img_alt_field == 'title' || $lightbox == 'carousel'; $caption_needed = $title_field == 'caption' || $caption_field == 'caption' || $link_title_field == 'caption' || $img_alt_field == 'caption' || $lightbox == 'carousel'; $description_needed = $title_field == 'description' || $caption_field == 'description' || $link_title_field == 'description' || $img_alt_field == 'description' || $lightbox == 'carousel'; $alternate_needed = $title_field == 'alternate' || $caption_field == 'alternate' || $link_title_field == 'alternate' || $img_alt_field == 'alternate' || $lightbox == 'carousel'; switch ($gallery_type) { case 'wp_post_gallery': add_filter('editor_max_image_size', array($this, 'jig_bypass_editor_max_image_size')); $order = 'ASC'; switch ($orderby) { case 'title_asc': $orderby = 'title'; break; case 'title_desc': $orderby = 'title'; $order = 'DESC'; break; case 'date_desc': $orderby = 'date'; $order = 'DESC'; break; case 'date_asc': $orderby = 'date'; break; case 'custom': $orderby = 'menu_order'; break; default: } if ($limit === '' || $limit === '0') { $limit = -1; } // 'featured' word gets replaced with actual ID if (!empty($exclude) && !empty($post->ID)) { $exclude = str_replace('featured', get_post_thumbnail_id($post->ID), $exclude); } if ($ids !== '') { // if there is a list of image ids if ($orderby === 'menu_order') { $orderby = 'post__in'; } if ($ids !== '*') { if (strpos($ids, '-') !== false) { $ids_exploded = explode(',', $ids); foreach ($ids_exploded as &$single_id) { if (strpos($single_id, '-') !== false) { $id_range = explode('-', $single_id); $single_id = implode(',', range($id_range[0], $id_range[1])); } } $ids = implode(',', $ids_exploded); } $args = array('include' => $ids, 'post_status' => 'any', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby); } else { $args = array('post_status' => 'any', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'exclude' => $exclude, 'order' => $order, 'orderby' => $orderby, 'posts_per_page' => -1); } $attachments = get_posts($args); // Fetch the images with a WP query if ($orderby == 'rand') { $attachments = (array) $attachments; shuffle($attachments); } if ($limit !== -1) { $attachments = array_slice($attachments, 0, $limit); } } elseif ($image_tags !== '' || $image_categories !== '' || $image_taxonomy !== '' && $image_tax_term !== '') { $image_tags = explode(',', str_replace(' ', '-', str_replace(', ', ',', $image_tags))); $image_categories = explode(',', str_replace(' ', '-', str_replace(', ', ',', $image_categories))); $attachment_tax = get_object_taxonomies('attachment'); if (empty($attachment_tax)) { return $this->frontend_stop(__('Category or tag filtering for images is not enabled!', 'jig_td')); } // Base $args array for WP-Query $args = array('post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby, 'post_status' => null, 'exclude' => $exclude, 'include' => $include, 'numberposts' => $limit); // All category/tag/tax queries will be using the tax_query array $args['tax_query'] = array(); // AND is the default relation even without tax_query (when just specifying them in the $args array) $args['tax_query']['relation'] = 'AND'; // Exact taxonomy selected by the user if ($image_taxonomy !== '' && $image_tax_term !== '') { // this is the proper way to query for images using a specific taxonomy $args['tax_query'][] = array('taxonomy' => $image_taxonomy, 'field' => 'slug', 'terms' => explode(',', str_replace(' ', '-', str_replace(', ', ',', $image_tax_term)))); } // If MLA plugin is installed these taxonomies will available on images, assume the user uses these if (in_array("attachment_category", $attachment_tax) && in_array("attachment_tag", $attachment_tax)) { if ($image_categories[0] !== '') { $args['tax_query'][] = array('taxonomy' => 'attachment_category', 'field' => 'slug', 'terms' => $image_categories); } if ($image_tags[0] !== '') { $args['tax_query'][] = array('taxonomy' => 'attachment_tag', 'field' => 'slug', 'terms' => $image_tags); } $attachments = get_posts($args); // Fetch the images with a WP query } // If this is empty or not yet created, it could be that the user was in fact just using the WP built-in taxonomies if (empty($attachments)) { // Remove the tax query (if the exact one is also used, keep it!) if (!empty($args['tax_query'][0]) && $args['tax_query'][0]['taxonomy'] == $image_taxonomy) { $args['tax_query'] = array('relation' => 'AND', $args['tax_query'][0]); } else { $args['tax_query'] = array('relation' => 'AND'); } // Then add queries for the WP built-in taxonomies if ($image_categories[0] !== '') { $args['tax_query'][] = array('taxonomy' => 'category', 'field' => 'slug', 'terms' => $image_categories); } if ($image_tags[0] !== '') { $args['tax_query'][] = array('taxonomy' => 'post_tag', 'field' => 'slug', 'terms' => $image_tags); } $attachments = get_posts($args); // Fetch the images with a WP query } if (empty($attachments)) { return $this->frontend_stop(__('No images found for your category or tag filters!', 'jig_td')); } } elseif ($include !== '') { // If only one post's attached images are to be fetched // build the image list json object for JS $args = array('post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby, 'post_status' => null, 'include' => $include, 'numberposts' => $limit); $attachments = get_posts($args); // Fetch the images with a WP query } elseif ($id !== '') { // If images from multiple posts are to be fetched if ($parent_id !== '') { $args = array('hierarchical' => 1, 'child_of' => $parent_id, 'parent' => -1, 'number' => 500, 'post_type' => 'page', 'post_status' => 'publish'); $page_children = get_pages($args); $page_children_list = array(); if (!empty($page_children)) { foreach ($page_children as $page_child) { $page_children_list[] = $page_child->ID; } $id = implode(',', $page_children_list); } } $args = array('post_parent__in' => explode(',', $id), 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby, 'post_status' => null, 'exclude' => $exclude, 'include' => $include, 'numberposts' => $limit); $attachments = get_posts($args); if (empty($attachments)) { // If old WP that doesn't support post_parent__in if (strpos($id, ',') !== false) { $id = explode(',', $id); $id = $id[0]; } $args = array('post_parent' => $id, 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby, 'post_status' => null, 'exclude' => $exclude, 'include' => $include, 'numberposts' => $limit); $attachments = get_posts($args); } } if ($attachments) { // If there are images attached to the post $this->images = $url_hash_list = array(); // Create a new array for the images foreach ($attachments as &$attachment) { // Loop through each $image = $this->jig_wp_get_attachment_image_src($attachment->ID, $lightbox_max_size); if (!is_numeric($image[1]) || !is_numeric($image[2]) || $image[1] == 0 || $image[2] == 0) { $question_mark_in_url = strpos($image[0], '?'); if ($question_mark_in_url !== false) { $image[3] = substr($image[0], 0, $question_mark_in_url); $url_hash_list[] = hash('md5', $image[3]); } else { $url_hash_list[] = hash('md5', $image[0]); } } $attachment->jig_image_src = $image; } unset($attachment); // this prepopulates wp_cache with the dimensions, if found if (!$this->jig_query_ext_images($url_hash_list)) { $notice_after .= __('Cannot create database for caching external image dimensions.', 'jig_td'); } foreach ($attachments as $attachment) { // Loop through each $image = $attachment->jig_image_src; // Get URL [0], width [1], and height [2] if (!is_numeric($image[1]) || !is_numeric($image[2]) || $image[1] == 0 || $image[2] == 0) { // If any of the dimensions are not a normal value $image = $this->jig_get_ext_imagesize($image); } if (!is_numeric($image[1]) || !is_numeric($image[2]) || $image[1] == 0 || $image[2] == 0) { continue; } $data = $d = array(); // Create 2 arrays for this image one temporary and one that gets pushed $data['url'] = $image[0]; // Store the full URL value $data['width'] = $image[1]; $data['height'] = $image[2]; // Get title if ($title_needed === true) { $d['title'] = $attachment->post_title; if ($d['title'] !== '') { $data['title'] = esc_attr(stripslashes($d['title'])); } } // Get caption if ($caption_needed === true) { $d['caption'] = $attachment->post_excerpt; if ($d['caption'] !== '') { $data['caption'] = esc_attr(stripslashes($d['caption'])); } } // Get description if ($description_needed === true) { $d['description'] = $attachment->post_content; if ($d['description'] !== '') { $data['description'] = esc_attr(stripslashes($d['description'])); } } // Get alternate if ($alternate_needed === true) { $d['alternate'] = get_post_meta($attachment->ID, '_wp_attachment_image_alt', true); if ($d['alternate'] !== '') { $data['alternate'] = esc_attr(stripslashes($d['alternate'])); } } if ($caption_custom_field !== '' || $lightbox_custom_field !== '') { $custom_fields_to_fetch = explode(',', str_replace(', ', '', trim(implode(',', array($caption_custom_field, $lightbox_custom_field)), ','))); foreach ($custom_fields_to_fetch as $custom_field_name) { $custom_field_index = 'custom_field_' . $custom_field_name; $d[$custom_field_index] = esc_attr(stripslashes(get_post_meta($attachment->ID, $custom_field_name, true))); if ($d[$custom_field_index] !== '') { $data[$custom_field_index] = $d[$custom_field_index]; } } } // Get link $d['link'] = esc_attr(stripslashes(get_post_meta($attachment->ID, '_jig_image_link', true))); if ($d['link'] != '') { $data['link'] = $d['link']; // Get link target $meta_link_target = get_post_meta($attachment->ID, '_jig_image_link_target', true); if ($meta_link_target !== '' && $meta_link_target !== 'default') { $data['link_target'] = $meta_link_target; } else { $data['link_target'] = $link_target; } $d['link_rel'] = array(); if ($data['link_target'] == '_blank') { $d['link_rel'][] = 'external'; } if ($custom_link_follow == 'no') { $d['link_rel'][] = 'nofollow'; } $d['link_rel_imploded'] = implode(' ', $d['link_rel']); if ($d['link_rel_imploded'] != '') { $data['link_rel'] = $d['link_rel_imploded']; } } else { if ($lightbox == 'attachment') { $data['link'] = get_attachment_link($attachment->ID); $data['link_target'] = $link_target; } } $d['extra_class'] = array(); if ($this->settings['image_custom_classes'] === 'enable') { $d['extra_class'][] = esc_attr(stripslashes(get_post_meta($attachment->ID, '_jig_custom_class', true))); if (!$d['extra_class'][0]) { unset($d['extra_class'][0]); } } if ($this->settings['image_custom_classes'] !== 'nothing') { // don't set an ID if prettyPhoto is the lightbox AND link doesn't have ?iframe=true or a video if (!(!empty($data['link']) && $lightbox == 'prettyphoto' && stripos($data['link'], '?iframe=true') === false && stripos($data['link'], 'youtube.com/watch') === false && stripos($data['link'], 'youtu.be') === false && stripos($data['link'], 'vimeo.com') === false)) { $d['extra_class'][] = 'jig-contentID-ML-' . $attachment->ID; } } $d['extra_class_imploded'] = implode(' ', $d['extra_class']); if ($d['extra_class_imploded'] != '') { $data['extra_class'] = $d['extra_class_imploded']; } if ($download_link != 'no') { $download_src = $this->jig_wp_get_attachment_image_src($attachment->ID, 'full'); $data['download'] = esc_attr(stripslashes('<a href="' . plugins_url('download.php', __FILE__) . '?file=' . urlencode($download_src[0]) . '">' . __($download_link_text, 'jig_td') . '</a>')); } if ($carousel_activated) { if ($link_target == '_blank') { $lightbox = 'no'; } $data['carousel_data'] = $this->jig_add_carousel_data($attachment->ID, $link_title_field, $img_alt_field); } if ($filterby == 'on') { $filterby = 'post_tag'; } if ($l2_filterby == 'on') { $l2_filterby = 'post_tag'; } if ($filterby !== 'off' && taxonomy_exists($filterby)) { $d['filters'] = wp_get_object_terms($attachment->ID, $filterby); if (!empty($d['filters'])) { foreach ($d['filters'] as $filter_term) { $data['filters'][] = array($filter_term->slug, $filter_term->name); } } } if ($l2_filterby !== 'off' && taxonomy_exists($l2_filterby)) { $d['L2filters'] = wp_get_object_terms($attachment->ID, $l2_filterby); if (!empty($d['L2filters'])) { foreach ($d['L2filters'] as $filter_term) { $data['L2filters'][] = array($filter_term->slug, $filter_term->name); } } } // Add to the main images array array_push($this->images, $data); } } else { return $this->frontend_stop(sprintf(__('There are no photos with those IDs or post %1$s does not have any attached images!', 'jig_td'), $id)); } remove_filter('editor_max_image_size', array($this, 'jig_bypass_editor_max_image_size')); break; case 'wp_recent_posts': add_filter('editor_max_image_size', array($this, 'jig_bypass_editor_max_image_size')); $order = 'ASC'; switch ($orderby) { case 'menu_order': $orderby_original = 'menu_order'; case 'date_desc': $orderby = 'date'; $order = 'DESC'; break; case 'title_asc': $orderby = 'title'; break; case 'title_desc': $orderby = 'title'; $order = 'DESC'; break; case 'date_asc': $orderby = 'date'; break; case 'custom': $orderby = 'menu_order'; $order = 'ASC'; break; default: } if ($limit === '') { $limit = 50; } else { if ($limit === '0') { $limit = -1; } } $cat = ''; $tag = ''; if ($recents_exclude != '') { $recents_exclude = explode(',', str_replace(' ', '-', str_replace(', ', ',', $recents_exclude))); foreach ($recents_exclude as &$recents_exclude_cat) { if (!is_numeric($recents_exclude_cat)) { $recents_exclude_cat = get_category_by_slug($recents_exclude_cat)->term_id; } $recents_exclude_cat = "-" . $recents_exclude_cat; } $cat = implode(',', $recents_exclude); } elseif ($recents_include != '') { $recents_include = explode(',', str_replace(' ', '-', str_replace(', ', ',', $recents_include))); foreach ($recents_include as &$recents_include_cat) { if (!is_numeric($recents_include_cat)) { $recents_include_cat = get_category_by_slug($recents_include_cat)->term_id; } } $cat = implode(',', $recents_include); } if ($recents_tags != '') { $tag = str_replace(' ', '-', str_replace(', ', ',', $recents_tags)); } if ($recents_tree_depth === '' || $recents_tree_depth === 0 || !is_numeric($recents_tree_depth)) { $recents_tree_depth = 10; } $posts = array(); $recents_post_type = strpos($recents_post_type, ',') === false ? $recents_post_type : explode(',', $recents_post_type); $args = array('post_type' => $recents_post_type, 'order' => $order, 'orderby' => $orderby, 'post_status' => array('publish'), 'category' => $cat, 'tag' => $tag, 'numberposts' => $limit, 'ignore_sticky_posts' => 1); if ($recents_placeholder === '') { $args['meta_key'] = '_thumbnail_id'; } if ($post_ids !== '') { // Regular recent posts call when the results are automatic, depending on settings $args['post__in'] = explode(',', $post_ids); if (isset($orderby_original)) { $args['orderby'] = 'post__in'; } } elseif ($post_ids_exclude !== '') { // Regular recent posts call when the results are automatic, depending on settings global $post; $post_ids_exclude = str_replace('current', $post->ID, $post_ids_exclude); $args['post__not_in'] = explode(',', $post_ids_exclude); } if ($recents_sticky === 'yes') { $args['post__in'] = get_option('sticky_posts'); } elseif ($recents_sticky === 'no') { unset($args['post__in']); $args['post__not_in'] = get_option('sticky_posts'); } if ($recents_filter_tax !== 'none' && !empty($recents_filter_term)) { // this is the proper way to query for posts using a specific taxonomy $args['tax_query'] = array(array('taxonomy' => $recents_filter_tax, 'field' => 'slug', 'terms' => explode(',', str_replace(' ', '-', str_replace(', ', ',', $recents_filter_term))))); } if (!empty($recents_author)) { if ($recents_author !== 'currently_logged_in') { $recents_user = get_user_by('login', $recents_author); $args['author'] = $recents_user->ID; } else { $recents_current_user_id = get_current_user_id(); if ($recents_current_user_id !== 0) { $args['author'] = $recents_current_user_id; } else { return $this->frontend_stop(sprintf(__('You need to be logged in to view your posts.', 'jig_td'), $id)); } } } if ($recents_date_range !== '') { $recents_date_range = trim(str_replace(' ', '', $recents_date_range)); $recents_date_range_after = array('year' => substr($recents_date_range, 0, 4), 'month' => ltrim(substr($recents_date_range, 5, 2), '0'), 'day' => ltrim(substr($recents_date_range, 8, 2), '0'), 'hour' => 0); $recents_date_range_before = array('hour' => 23, 'minute' => 59, 'second' => 59); if (strtolower(substr($recents_date_range, 11)) !== 'today') { $recents_date_range_before['year'] = substr($recents_date_range, 11, 4); $recents_date_range_before['month'] = ltrim(substr($recents_date_range, 16, 2), '0'); $recents_date_range_before['day'] = ltrim(substr($recents_date_range, 19, 2), '0'); } else { $recents_date_range_today = getdate(); $recents_date_range_before['year'] = $recents_date_range_today['year']; $recents_date_range_before['month'] = $recents_date_range_today['mon']; $recents_date_range_before['day'] = $recents_date_range_today['mday']; } $args['date_query'] = array(array('after' => $recents_date_range_after, 'before' => $recents_date_range_before), 'inclusive' => true); } if ($recents_last_x_days !== '') { $recents_last_x_days_today = getdate(); $recents_last_x_days_other_day = getdate(date('U') - (int) $recents_last_x_days * 86400); $args['date_query'] = array(array('after' => array('year' => $recents_last_x_days_other_day['year'], 'month' => $recents_last_x_days_other_day['mon'], 'day' => $recents_last_x_days_other_day['mday'], 'hour' => $recents_last_x_days_other_day['hours'], 'minute' => $recents_last_x_days_other_day['minutes'], 'second' => $recents_last_x_days_other_day['seconds']), 'before' => array('year' => $recents_last_x_days_today['year'], 'month' => $recents_last_x_days_today['mon'], 'day' => $recents_last_x_days_today['mday'], 'hour' => $recents_last_x_days_today['hours'], 'minute' => $recents_last_x_days_today['minutes'], 'second' => $recents_last_x_days_today['seconds'])), 'inclusive' => true); } if ($orderby == 'menu_order' && $recents_post_type == 'page') { $args['suppress_filters'] = false; add_filter('posts_orderby', array($this, 'add_secondary_order_to_pages')); } if ($recents_parent_id === '') { $posts = get_posts($args); } else { $args['post_parent'] = $recents_parent_id; $posts = $this->get_recents_recursive($args, $recents_tree_depth, 0); } if ($orderby == 'menu_order' && $recents_post_type == 'page') { remove_filter('posts_orderby', array($this, 'add_secondary_order_to_pages')); } elseif ($orderby == 'rand') { $posts = (array) $posts; shuffle($posts); } $is_wpml = defined('ICL_SITEPRESS_VERSION') || function_exists('wpml_get_language_information'); if ($posts) { // If there are images attached to the post $this->images = $url_hash_list = array(); // Create a new array for the images foreach ($posts as &$post) { // Loop through each if ($is_wpml === true) { if (version_compare(ICL_SITEPRESS_VERSION, '3.2', '>=')) { //Code for the new version greater than or equal to 3.2 $post_language = apply_filters('wpml_post_language_details', NULL, $post->ID); } else { //support for older WPML versions $post_language = wpml_get_language_information($post->ID); } if ($post_language['different_language'] == true) { $post->jig_image_src = 'skip'; continue; } } $post->post_thumbnail_id = get_post_thumbnail_id($post->ID); $image = $this->jig_wp_get_attachment_image_src($post->post_thumbnail_id, $lightbox_max_size); if ($image == false && !empty($post->post_thumbnail_id) && class_exists('nggdb')) { global $wpdb; $nggID = substr($post->post_thumbnail_id, 4); if ($nggID !== false) { $nggImage = $this->jig_ng_find_images($nggID, true); if (!empty($nggImage)) { $image = array(); $image[0] = $nggImage->imageURL; $image[1] = $nggImage->meta_data['width']; $image[2] = $nggImage->meta_data['height']; } } } if ($image == false && $recents_placeholder !== '') { $image[0] = $recents_placeholder; $image[1] = $image[2] = 0; } if (!is_numeric($image[1]) || !is_numeric($image[2]) || $image[1] == 0 || $image[2] == 0) { $url_hash_list[] = hash('md5', $image[0]); } $post->jig_image_src = $image; } unset($post); // this prepopulates wp_cache with the dimensions, if found if (!$this->jig_query_ext_images($url_hash_list)) { $notice_after .= __('Cannot create database for caching external image dimensions.', 'jig_td'); } if ($post_metadata_fields !== '') { $post_metadata_fields = explode(',', str_replace(', ', ',', $post_metadata_fields)); } foreach ($posts as $post) { // Loop through each $image = $post->jig_image_src; // Get URL [0], width [1], and height [2] if ($image == "skip") { continue; } if (!is_numeric($image[1]) || !is_numeric($image[2]) || $image[1] == 0 || $image[2] == 0) { // If any of the dimensions are not a normal value $image = $this->jig_get_ext_imagesize($image); } if (!is_numeric($image[1]) || !is_numeric($image[2]) || $image[1] == 0 || $image[2] == 0) { continue; } $data = $d = array(); // Create 2 arrays for this image one temporary and one that gets pushed $data['url'] = $image[0]; // Store the full URL value $data['width'] = $image[1]; $data['height'] = $image[2]; // Get title if ($title_needed === true) { if ($recents_title_override !== '') { $d['title'] = get_post_meta($post->ID, $recents_title_override, true); } if (empty($d['title'])) { $d['title'] = esc_attr(stripslashes($post->post_title)); } if ($d['title'] != '') { $data['title'] = (empty($post->post_password) ? '' : __('Protected', 'jig_td') . ': ') . $d['title']; } } if ($description_needed === true) { if ($recents_description !== '') { $recents_descriptions['1'] = $recents_description; } if ($recents_description_2 !== '') { $recents_descriptions['2'] = $recents_description_2; } if ($recents_description_3 !== '') { $recents_descriptions['3'] = $recents_description_3; } if (!empty($post_metadata_fields)) { $d['post_metadata_fields'] = $post_metadata_fields; // temp copy as they'll get shifted } foreach ($recents_descriptions as $recents_desc_id => $recents_description_value) { // Get description switch ($recents_description_value) { case 'nothing': $d['description'][$recents_desc_id] = ''; break; case 'categories': $d['description'][$recents_desc_id] = implode(", ", wp_get_post_categories($post->ID, array('fields' => 'names'))); break; case 'tags': $d['description'][$recents_desc_id] = implode(", ", wp_get_post_tags($post->ID, array('fields' => 'names'))); break; case 'auto_excerpt': $d['description'][$recents_desc_id] = $this->jig_the_excerpt($post, $excerpt_length, $excerpt_ending); break; case 'manual_excerpt': $d['description'][$recents_desc_id] = esc_attr(stripslashes($post->post_excerpt)); break; case 'auto_manual_excerpt': $d['description'][$recents_desc_id] = esc_attr(stripslashes($post->post_excerpt)); if ($d['description'][$recents_desc_id] == '') { $d['description'][$recents_desc_id] = $this->jig_the_excerpt($post, $excerpt_length, $excerpt_ending); } break; case 'datetime': $d['description'][$recents_desc_id] = date(get_option('date_format') . ' ' . get_option('time_format'), strtotime($post->post_date)); break; case 'date': $d['description'][$recents_desc_id] = date(get_option('date_format'), strtotime($post->post_date)); break; case 'nicetime': $d['description'][$recents_desc_id] = $this->jig_nice_time($post->post_date); break; case 'comments': $comments_count = get_comments_number($post->ID); if (!empty($comments_count)) { $comments_texts = explode('|', $comments_text); if ($comments_count != 1) { $d['description'][$recents_desc_id] = $comments_count . ' ' . trim(!empty($comments_texts[1]) ? $comments_texts[1] : $comments_texts[0]); } else { $d['description'][$recents_desc_id] = $comments_count . ' ' . trim($comments_texts[0]); } } $comments_count = null; unset($comments_count); break; case 'author': $author_data = get_userdata($post->post_author); $d['description'][$recents_desc_id] = ($author_prefix !== 'none' ? trim($author_prefix) . ' ' : '') . (!empty($author_data->display_name) ? $author_data->display_name : $author_data->user_login); unset($author_data); break; case 'woocommerce_price': $d['description'][$recents_desc_id] = get_post_meta($post->ID, '_regular_price', true); if ($d['description'][$recents_desc_id] && function_exists('wc_price')) { $d['description'][$recents_desc_id] = wc_price($d['description'][$recents_desc_id]); } break; case 'custom_post_metadata': if (!empty($d['post_metadata_fields'])) { $d['description'][$recents_desc_id] = get_post_meta($post->ID, array_shift($d['post_metadata_fields']), true); } else { $d['description'][$recents_desc_id] = ''; } break; default: $d['description'][$recents_desc_id] = ''; if (substr($recents_description_value, 0, 15) === 'custom_taxonomy') { $custom_taxonomy_for_recents_description = substr($recents_description_value, 16); if (taxonomy_exists($custom_taxonomy_for_recents_description)) { $d['description'][$recents_desc_id] = implode(", ", wp_get_post_terms($post->ID, $custom_taxonomy_for_recents_description, array('fields' => 'names'))); } } } if (empty($d['description'][$recents_desc_id])) { unset($d['description'][$recents_desc_id]); } } $d['description'] = implode('<br />', $d['description']); if ($d['description'] != '') { $data['description'] = esc_attr($d['description']); } } switch ($recents_link_to) { case 'post': // Get link $data['link'] = esc_attr(stripslashes(get_permalink($post->ID))); // Get link target if ($recents_custom_links == 'yes') { $data['link_target'] = '_self'; } break; case 'attachment': $data['link'] = get_attachment_link($post->post_thumbnail_id); if (substr($data['link'], -1) == "=") { // If link is not valid (old NG?) $data['link'] = $data['url']; } if ($recents_custom_links == 'yes') { $data['link_target'] = '_self'; } break; case 'image': default: if ($download_link != 'no') { $data['download'] = esc_attr(stripslashes('<a href="' . plugins_url('download.php', __FILE__) . '?file=' . urlencode($data['url']) . '">' . __($download_link_text, 'jig_td') . '</a>')); } if ($recents_link != 'no') { $data['lightbox_link'] = esc_attr(stripslashes('<a href="' . esc_attr(stripslashes(get_permalink($post->ID))) . '" >' . $recents_link_text . '</a>')); } if ($carousel_activated) { $data['carousel_data'] = $this->jig_add_carousel_data($post->post_thumbnail_id, $link_title_field, $img_alt_field); } } if ($recents_custom_links == 'yes') { $d['link'] = esc_attr(stripslashes(get_post_meta($post->post_thumbnail_id, '_jig_image_link', true))); if ($d['link'] != '') { $data['link'] = $d['link']; // Get link target $meta_link_target = get_post_meta($post->post_thumbnail_id, '_jig_image_link_target', true); if ($meta_link_target !== '' && $meta_link_target !== 'default') { $data['link_target'] = $meta_link_target; } else { $data['link_target'] = $link_target; } $d['link_rel'] = array(); if ($data['link_target'] == '_blank') { $d['link_rel'][] = 'external'; } if ($custom_link_follow == 'no') { $d['link_rel'][] = 'nofollow'; } $d['link_rel_imploded'] = implode(' ', $d['link_rel']); if ($d['link_rel_imploded'] != '') { $data['link_rel'] = $d['link_rel_imploded']; } } } $d['extra_class'] = array(); if ($this->settings['image_custom_classes'] === 'enable') { $d['extra_class'][] = esc_attr(stripslashes(get_post_meta($post->post_thumbnail_id, '_jig_custom_class', true))); if (!$d['extra_class'][0]) { unset($d['extra_class'][0]); } } if ($this->settings['image_custom_classes'] !== 'nothing') { $d['extra_class'][] = 'jig-contentID-RP-' . $post->ID; } if (isset($post->extra_class)) { $d['extra_class'][] = $post->extra_class; } $d['extra_class_imploded'] = implode(' ', $d['extra_class']); if ($d['extra_class_imploded'] != '') { $data['extra_class'] = $d['extra_class_imploded']; } if ($filterby == 'on') { $filterby = 'post_tag'; } if ($l2_filterby == 'on') { $l2_filterby = 'post_tag'; } if ($filterby !== 'off' && taxonomy_exists($filterby)) { $d['filters'] = wp_get_object_terms($post->ID, $filterby); if (!empty($d['filters'])) { foreach ($d['filters'] as $filter_term) { if ($filter_term->slug !== 'uncategorized') { $data['filters'][] = array($filter_term->slug, $filter_term->name); } } } } if ($l2_filterby !== 'off' && taxonomy_exists($l2_filterby)) { $d['L2filters'] = wp_get_object_terms($post->ID, $l2_filterby); if (!empty($d['L2filters'])) { foreach ($d['L2filters'] as $filter_term) { if ($filter_term->slug !== 'uncategorized') { $data['L2filters'][] = array($filter_term->slug, $filter_term->name); } } } } // Add to the main images array array_push($this->images, $data); } if ($recents_custom_links == 'no' && ($recents_link_to == 'post' || $recents_link_to == 'attachment')) { $lightbox = 'no'; } } else { return $this->frontend_stop(sprintf(__('There are no recent posts with featured images.', 'jig_td'), $id)); } remove_filter('editor_max_image_size', array($this, 'jig_bypass_editor_max_image_size')); break; case 'nextgen': if (!class_exists('nggGallery')) { return $this->frontend_stop(__('NextGEN gallery is not installed/inactive!', 'jig_td')); } $ngg_options = nggGallery::get_option('ngg_options'); switch ($orderby) { case 'rand': $ngg_options['galSort'] = 'RAND'; $ngg_options['galSortDir'] = $ngg_options['galSortDir'] == 'DESC' ? 'DESC' : 'ASC'; break; case 'title_asc': $ngg_options['galSort'] = 'alttext'; $ngg_options['galSortDir'] = 'ASC'; break; case 'title_desc': $ngg_options['galSort'] = 'alttext'; $ngg_options['galSortDir'] = 'DESC'; break; case 'date_asc': $ngg_options['galSort'] = 'imagedate'; $ngg_options['galSortDir'] = 'ASC'; break; case 'date_desc': $ngg_options['galSort'] = 'imagedate'; $ngg_options['galSortDir'] = 'DESC'; break; default: // menu_order and custom $ngg_options['galSort'] = $ngg_options['galSort'] ? $ngg_options['galSort'] : 'pid'; $ngg_options['galSortDir'] = $ngg_options['galSortDir'] == 'DESC' ? 'DESC' : 'ASC'; break; } if (class_exists('C_NextGEN_Bootstrap')) { $this->ng_version = 2; } else { $this->ng_version = 1; } $original_nextgen_limit = $limit; if ($limit === '' || $limit === "0") { $limit = 1000; } if ($ng_album !== '') { $ng_bc_home_album = $ng_album; } if ($ng_narrow_by_tags !== '') { $ng_narrow_by_tags = explode(',', str_replace(', ', ',', $ng_narrow_by_tags)); } global $wpdb, $jigNgConnect; $ng_gallerytag = false; if (!isset($jigNgConnect)) { if ($this->jig_ng_get_query_var('gallery') !== '') { $ng_gallery = $this->jig_ng_get_query_var('gallery'); // Doesn't matter if it's ID or slug $ng_album = ''; $jigNgConnect = true; } else { if ($this->jig_ng_get_query_var('album') !== '') { $ng_album = $this->jig_ng_get_query_var('album'); // It's best if the album value is always an ID if (!is_numeric($ng_album)) { $ng_album = $wpdb->get_var($wpdb->prepare("SELECT id FROM {$wpdb->nggalbum} WHERE slug = %s", $ng_album)); if (empty($ng_album)) { $ng_album = ''; } } $ng_gallery = ''; if ($ng_album !== '') { $jigNgConnect = true; } } else { if ($this->jig_ng_get_query_var('gallerytag') !== '') { $ng_gallerytag = $this->jig_ng_get_query_var('gallerytag'); // Doesn't matter if it's ID or slug $ng_gallery = ''; $ng_album = ''; $jigNgConnect = true; $ng_tags_gallery = $ng_gallerytag; } } } } else { return $this->frontend_stop(); // Another instance is serving the gallery from the URL parameters } if ($ng_gallery !== '') { // If a gallery is displayed $ng_gallery = str_replace(' ', '', $ng_gallery); $images = $this->jig_ng_get_galleries($ng_gallery, $ngg_options['galSort'], $ngg_options['galSortDir'], $limit); if (empty($images)) { return $this->frontend_stop(sprintf(__('The NextGEN gallery with ID/slug: %1$s does not exist or is empty.', 'jig_td'), $ng_gallery)); } if (!empty($images)) { $this->images = $url_hash_list = array(); // Create a new array for the images foreach ($images as &$image) { if (!$image->meta_data['width'] || !$image->meta_data['height']) { $url_hash_list[] = hash('md5', $image->imageURL); } $image->jig_image_src = array($image->imageURL, $image->meta_data['width'], $image->meta_data['height']); } unset($image); // this prepopulates wp_cache with the dimensions, if found if (!$this->jig_query_ext_images($url_hash_list)) { $notice_after .= __('Cannot create database for caching external image dimensions.', 'jig_td'); } foreach ($images as $image) { if (!$image->jig_image_src[1] || !$image->jig_image_src[2]) { // If any of the dimensions are not a normal value $image->jig_image_src = $this->jig_get_ext_imagesize($image->jig_image_src); } $image->meta_data['width'] = $image->jig_image_src[1]; $image->meta_data['height'] = $image->jig_image_src[2]; if ($image->meta_data['width'] != 0 && $image->meta_data['height'] != 0) { // If none of the dimensions are 0 $data = $d = array(); // Create 2 arrays for this image one temporary and one that gets pushed $data['url'] = $image->imageURL; $data['width'] = $image->meta_data['width']; $data['height'] = $image->meta_data['height']; $d['title'] = esc_attr(stripslashes(nggGallery::i18n($image->alttext, 'pic_' . $image->pid . '_alttext'))); if ($d['title'] != '') { $data['title'] = $d['title']; } $d['description'] = trim(esc_attr(stripslashes(nggGallery::i18n($image->description, 'pic_' . $image->pid . '_description')))); if ($ng_display_tags == 'yes') { $d['tags'] = ucwords(implode(', ', wp_get_object_terms($image->pid, 'ngg_tag', array('fields' => 'names')))); if (!empty($d['tags'])) { $d['description'] = esc_attr(($d['description'] != '' ? $d['description'] . $separator_character : '') . '<i>' . $d['tags'] . '</i>'); } } if ($d['description'] != '') { $data['description'] = $d['description']; } if ($download_link != 'no') { $data['download'] = esc_attr(stripslashes('<a href="' . plugins_url('download.php', __FILE__) . '?file=' . urlencode($data['url']) . '">' . __($download_link_text, 'jig_td') . '</a>')); } if (isset($image->ng_cf_link)) { $data['link'] = $image->ng_cf_link; $data['link_target'] = $link_target; } if ($filterby == 'on') { $d['filters'] = wp_get_object_terms($image->pid, 'ngg_tag'); if (!empty($d['filters'])) { foreach ($d['filters'] as $filter_term) { $data['filters'][] = array($filter_term->slug, $filter_term->name); } } } elseif ($filterby == 'ng_galleries') { if (!empty($image->slug) && !empty($image->title)) { $data['filters'][] = array($image->slug, $image->title); } } if ($l2_filterby == 'on') { $d['L2filters'] = wp_get_object_terms($image->pid, 'ngg_tag'); if (!empty($d['L2filters'])) { foreach ($d['L2filters'] as $filter_term) { $data['L2filters'][] = array($filter_term->slug, $filter_term->name); } } } elseif ($l2_filterby == 'ng_galleries') { if (!empty($image->slug) && !empty($image->title)) { $data['L2filters'][] = array($image->slug, $image->title); } } if (!empty($ng_narrow_by_tags)) { $ng_image_tags = wp_get_object_terms($image->pid, 'ngg_tag'); if (!empty($ng_image_tags)) { foreach ($ng_image_tags as $filter_term) { if (in_array($filter_term->slug, $ng_narrow_by_tags) || in_array($filter_term->name, $ng_narrow_by_tags)) { $ng_tag_found_in_image = true; break; } } if (!isset($ng_tag_found_in_image)) { unset($ng_tag_found_in_image); continue; // Don't add this image to the images if it's missing the tag(s) } } else { continue; // Don't add this image to the images if it's missing ANY tag(s) } unset($ng_image_tags, $ng_tag_found_in_image); } if ($ng_description == 'yes') { $ng_description = 'no'; if ($image->galdesc) { $notice_before .= '<p class="jig-ngDescription">' . $image->galdesc . '</p>'; } } if ($this->settings['image_custom_classes'] !== 'nothing') { $data['extra_class'] = 'jig-contentID-NG-' . $image->pid; } array_push($this->images, $data); } } } } else { if ($ng_album !== '') { // If an album (or overview album) is displayed $albums = $wpdb->get_results("SELECT * FROM {$wpdb->nggalbum}"); if (!empty($albums)) { foreach ($albums as $val) { wp_cache_set($val->id, $val, 'jig_ng_albums'); } } $album = $this->jig_ng_get_album($ng_album, $ngg_options['galSort'], $ngg_options['galSortDir']); if (!empty($album)) { if ($album->content_ids) { if ($ng_description == 'yes') { $ng_description = 'no'; if ($album->albumdesc) { $notice_before .= '<p class="jig-ngDescription">' . $album->albumdesc . '</p>'; } } $album_contents = $album->content_ids; if (!empty($album_contents)) { $photo_count_by_gallery_id = array(); if ($album->id == 'all') { $album->slug = $album->id; } $album_contents_imploded = "'" . implode("','", $album_contents) . "'"; if (empty($ng_narrow_by_tags)) { $picturesCounter = $wpdb->get_results("SELECT galleryid, COUNT(*) as counter FROM {$wpdb->nggpictures} WHERE galleryid IN ( {$album_contents_imploded} ) AND exclude != 1 GROUP BY galleryid", OBJECT_K); } else { $term_ids_string = $this->ng_get_term_id_from_tag($ng_narrow_by_tags); $picturesCounter = $this->ng_count_tagged_images_per_gallery($term_ids_string); } if (!empty($picturesCounter)) { foreach ($picturesCounter as $key => $value) { $photo_count_by_gallery_id[$key] = $value->counter; } } $this->images = $shadow_galleries = array(); $counter = 0; foreach ($album_contents as $album_content) { // $album content can be a gallery on an album if (++$counter > $limit) { break; } if (substr($album_content, 0, 1) != "a") { // If it's a gallery if (empty($photo_count_by_gallery_id[$album_content])) { continue; } $image = $this->ng_find_cover_image_for_gallery($album_content); // pass the gallery ID and get back a representative image that is processed if (!empty($image)) { if (!empty($ng_narrow_by_tags)) { $gallery_images_for_narrowing = $lightbox_images = $this->jig_ng_get_galleries($album_content, $ngg_options['galSort'], $ngg_options['galSortDir'], $limit); if (!empty($gallery_images_for_narrowing)) { $gallery_is_needed = false; foreach ($gallery_images_for_narrowing as $image_for_narrowing) { $ng_image_tags = wp_get_object_terms($image_for_narrowing->pid, 'ngg_tag'); if (!empty($ng_image_tags)) { foreach ($ng_image_tags as $filter_term) { if (in_array($filter_term->slug, $ng_narrow_by_tags) || in_array($filter_term->name, $ng_narrow_by_tags)) { $gallery_is_needed = true; break 2; } } } } if ($gallery_is_needed == false) { continue; } } } if ($ng_lightbox_gallery == 'yes') { // If gallery should be displayed as a lightbox $lightbox_images = $this->jig_ng_get_galleries($album_content, $ngg_options['galSort'], $ngg_options['galSortDir'], $limit); if (!empty($lightbox_images)) { $shadow_galleries[] = $shadow_group_id = "jig{$jig_id}-hiddenGalleryGroup-" . $album_content; $shadow_gallery = '<div class="jig-hiddenGallery">'; if (stripos($link_rel, '*instance*') !== false) { $shadow_rel = str_replace('*instance*', 'NG-' . $album_content, $link_rel); } else { switch ($lightbox) { case 'prettyphoto': $shadow_rel = 'prettyPhoto[ngg-' . $album_content . ']'; break; case 'colorbox': $shadow_rel = 'colorBox[ngg-' . $album_content . ']'; break; case 'foobox': $shadow_rel = 'foobox[ngg-' . $album_content . ']'; break; default: $shadow_rel = 'jig[ngg-' . $album_content . ']'; break; } } if ($lightbox == 'photoswipe') { foreach ($lightbox_images as &$lightbox_image) { if (!$lightbox_image->meta_data['width'] || !$lightbox_image->meta_data['height']) { $url_hash_list[] = hash('md5', $lightbox_image->imageURL); } $lightbox_image->jig_image_src = array($lightbox_image->imageURL, $lightbox_image->meta_data['width'], $lightbox_image->meta_data['height']); } unset($lightbox_image); // this prepopulates wp_cache with the dimensions, if found if (!$this->jig_query_ext_images($url_hash_list)) { $notice_after .= __('Cannot create database for caching external image dimensions.', 'jig_td'); } } foreach ($lightbox_images as $lightbox_image) { // Skip image from the hidden gallery if it's the same as the opener image if ($lightbox_image->filename == $image->filename) { continue; } $data = $d = array(); // Create 2 arrays for this image one temporary and one that gets pushed $data['url'] = $lightbox_image->imageURL; $d['title'] = esc_attr(stripslashes(nggGallery::i18n($lightbox_image->alttext, 'pic_' . $lightbox_image->pid . '_alttext'))); $d['description'] = trim(esc_attr(stripslashes(nggGallery::i18n($lightbox_image->description, 'pic_' . $lightbox_image->pid . '_description')))); if ($ng_display_tags == 'yes') { $d['tags'] = ucwords(implode(', ', wp_get_object_terms($lightbox_image->pid, 'ngg_tag', array('fields' => 'names')))); if (!empty($d['tags'])) { $d['description'] = esc_attr(($d['description'] != '' ? $d['description'] . $separator_character : '') . '<i>' . $d['tags'] . '</i>'); } } $title_fragment = isset($d[$link_title_field]) ? $d[$link_title_field] : ''; $alt_fragment = isset($d[$img_alt_field]) ? $d[$img_alt_field] : ''; if ($download_link != 'no') { $data['download'] = esc_attr(stripslashes('<a href="' . plugins_url('download.php', __FILE__) . '?file=' . urlencode($data['url']) . '">' . __($download_link_text, 'jig_td') . '</a>')); if ($download_link == 'yes') { if ($title_fragment !== '') { $title_fragment .= $separator_character . $data['download']; } else { $title_fragment = $data['download']; } } else { if ($alt_fragment !== '') { $alt_fragment .= $separator_character . $data['download']; } else { $alt_fragment = $data['download']; } } } if ($lightbox == 'photoswipe') { if (!$lightbox_image->jig_image_src[1] || !$lightbox_image->jig_image_src[2]) { // If any of the dimensions are not a normal value $lightbox_image->jig_image_src = $this->jig_get_ext_imagesize($lightbox_image->jig_image_src); } $lightbox_image->meta_data['width'] = $lightbox_image->jig_image_src[1]; $lightbox_image->meta_data['height'] = $lightbox_image->jig_image_src[2]; if ($lightbox_image->meta_data['width'] != 0 && $lightbox_image->meta_data['height'] != 0) { // If none of the dimensions are 0 $shadow_size = ' data-wh="' . $lightbox_image->meta_data['width'] . 'x' . $lightbox_image->meta_data['height'] . '"'; } else { continue; } } else { $shadow_size = ''; } $shadow_class = 'class="jig-link jig-contentID-NG-' . $lightbox_image->pid . (empty($link_class) ? '' : ' ' . $link_class) . '" '; $shadow_gallery .= '<a href="' . $data['url'] . '" rel="' . $shadow_rel . '" ' . $shadow_class . $shadow_size . ' title="' . $title_fragment . '"><img src="data:image/gif;base64,R0lGODlhAQABAPABAP///wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw%3D%3D" alt="' . $alt_fragment . '" /></a>'; } $shadow_gallery .= "</div>"; } } $meta_data = $image->meta_data; $url_hash_list = array(); // Create a new array for the images if (!$meta_data['width'] || !$meta_data['height']) { $url_hash_list[] = hash('md5', $image->imageURL); } $image->jig_image_src = array($image->imageURL, $meta_data['width'], $meta_data['height']); // this prepopulates wp_cache with the dimensions, if found if (!$this->jig_query_ext_images($url_hash_list)) { $notice_after .= __('Cannot create database for caching external image dimensions.', 'jig_td'); } if (!$image->jig_image_src[1] || !$image->jig_image_src[2]) { // If any of the dimensions are not a normal value $image->jig_image_src = $this->jig_get_ext_imagesize($image->jig_image_src); } $meta_data['width'] = $image->jig_image_src[1]; $meta_data['height'] = $image->jig_image_src[2]; if ($meta_data['width'] != 0 && $meta_data['height'] != 0) { // If none of the dimensions are 0 $data = $d = array(); // Create 2 arrays for this image one temporary and one that gets pushed $data['url'] = $image->jig_image_src[0]; $data['width'] = $meta_data['width']; $data['height'] = $meta_data['height']; $d['title'] = esc_attr(nggGallery::i18n(stripslashes($image->title), 'gal_' . $image->gid . '_title')); if ($d['title'] != '') { $data['title'] = $d['title']; } if ($ng_count == 'yes') { $description_fragments = array($photo_count_by_gallery_id[$album_content] . ' ' . _n('Photo', 'Photos', $photo_count_by_gallery_id[$album_content], 'jig_td')); if ($image->galdesc !== '') { $description_fragments[] = nggGallery::i18n(stripslashes($image->galdesc), 'gal_' . $image->gid . '_description'); } $d['description'] = esc_attr(stripslashes(implode('<br />', $description_fragments))); } else { $d['description'] = esc_attr(nggGallery::i18n(stripslashes($image->galdesc), 'gal_' . $image->gid . '_description')); } if ($d['description'] != '') { $data['description'] = $d['description']; } if ($this->ng_version == 2) { if (empty($image->pageid)) { $d['link'] = $this->jig_ng_get_permalink(array('album' => $album->slug, 'gallery' => $image->slug)); } else { $d['link'] = get_permalink($image->pageid); } } else { if ($ngg_options['galNoPages']) { if ($ngg_options['usePermalinks']) { $d['link'] = $this->jig_ng_get_permalink(array('album' => $album->slug, 'gallery' => $image->slug)); } else { $d['link'] = $this->jig_ng_get_permalink(array('album' => $album->id, 'gallery' => $image->gid)); } } else { $d['link'] = get_permalink($image->pageid); } } if ($ng_lightbox_gallery == 'yes' && isset($shadow_gallery)) { $d['link'] = NULL; $data['gallery']['html'] = $shadow_gallery; $data['gallery']['rel'] = $shadow_rel; $data['gallery']['id'] = $shadow_group_id; if (isset($data['title'])) { $data['gallery']['title'] = $data['title']; } if (isset($data['description'])) { $data['gallery']['description'] = $data['description']; } $d['title'] = esc_attr(stripslashes(nggGallery::i18n($image->alttext, 'pic_' . $image->pid . '_alttext'))); if ($d['title'] != '') { $data['title'] = $d['title']; } else { unset($data['title']); } $d['description'] = trim(esc_attr(stripslashes(nggGallery::i18n($image->description, 'pic_' . $image->pid . '_description')))); if ($ng_display_tags == 'yes') { $d['tags'] = ucwords(implode(', ', wp_get_object_terms($image->pid, 'ngg_tag', array('fields' => 'names')))); if (!empty($d['tags'])) { $d['description'] = esc_attr(($d['description'] != '' ? $d['description'] . $separator_character : '') . '<i>' . $d['tags'] . '</i>'); } } if ($d['description'] != '') { $data['description'] = $d['description']; } else { unset($data['description']); } switch ($lightbox) { case 'foobox': $data['gallery']['lightbox_class'] = 'jigFooBoxConnect'; break; case 'socialgallery': $data['gallery']['lightbox_class'] = 'jigSgConnect'; break; default: } } if ($download_link != 'no') { $data['download'] = esc_attr(stripslashes('<a href="' . plugins_url('download.php', __FILE__) . '?file=' . urlencode($data['url']) . '">' . __($download_link_text, 'jig_td') . '</a>')); } if ($d['link'] != '') { $data['link'] = $d['link']; } if ($this->settings['image_custom_classes'] !== 'nothing') { $data['extra_class'] = 'jig-contentID-NG-' . $image->pid; } array_push($this->images, $data); } } } else { // If it's an album $cover_image = $this->jig_ng_find_subalbums($album_content, 'needed', true); if (!is_null($cover_image)) { $meta_data = $cover_image->meta_data; $url_hash_list = array(); // Create a new array for the images if (!$meta_data['width'] || !$meta_data['height']) { $url_hash_list[] = hash('md5', $cover_image->imageURL); } $cover_image->jig_image_src = array($cover_image->imageURL, $meta_data['width'], $meta_data['height']); // this prepopulates wp_cache with the dimensions, if found if (!$this->jig_query_ext_images($url_hash_list)) { $notice_after .= __('Cannot create database for caching external image dimensions.', 'jig_td'); } if (!$cover_image->jig_image_src[1] || !$cover_image->jig_image_src[2]) { // If any of the dimensions are not a normal value $cover_image->jig_image_src = $this->jig_get_ext_imagesize($cover_image->jig_image_src); } $meta_data['width'] = $cover_image->jig_image_src[1]; $meta_data['height'] = $cover_image->jig_image_src[2]; if ($meta_data['width'] != 0 && $meta_data['height'] != 0) { // If none of the dimensions are 0 $data = $d = array(); // Create 2 arrays for this image one temporary and one that gets pushed $data['url'] = $cover_image->jig_image_src[0]; $data['width'] = $meta_data['width']; $data['height'] = $meta_data['height']; $d['title'] = esc_attr(stripslashes($cover_image->jig['name'])); if ($d['title'] != '') { $data['title'] = $d['title']; } if ($ng_count == 'yes') { $description_fragments = $counter_fragments = array(); if ($cover_image->jig['albumCount'] > 0) { $counter_fragments[] = $cover_image->jig['albumCount'] . ' ' . _n('Album', 'Albums', $cover_image->jig['albumCount'], 'jig_td'); } if ($cover_image->jig['galleryCount'] > 0) { $counter_fragments[] = $cover_image->jig['galleryCount'] . ' ' . _n('Gallery', 'Galleries', $cover_image->jig['galleryCount'], 'jig_td'); } $description_fragments[] = implode(', ', $counter_fragments); if (empty($description_fragments[0])) { unset($description_fragments); } if ($cover_image->jig['albumdesc'] != '') { $description_fragments[] = $cover_image->jig['albumdesc']; } $d['description'] = esc_attr(stripslashes(implode('<br />', $description_fragments))); } else { $d['description'] = esc_attr(stripslashes($cover_image->jig['albumdesc'])); } if ($d['description'] != '') { $data['description'] = $d['description']; } if (empty($cover_image->jig['pageid'])) { if ($this->ng_version == 2) { $d['link'] = $this->jig_ng_get_permalink(array('album' => $cover_image->jig['slug'], 'gallery' => false)); } else { if ($ngg_options['usePermalinks']) { $d['link'] = $this->jig_ng_get_permalink(array('album' => $cover_image->jig['slug'], 'gallery' => false)); } else { $d['link'] = $this->jig_ng_get_permalink(array('album' => $cover_image->jig['id'], 'gallery' => false)); } } } else { $d['link'] = get_permalink($cover_image->jig['pageid']); $data['link_target'] = $link_target; } if ($d['link'] != '') { $data['link'] = $d['link']; } if ($this->settings['image_custom_classes'] !== 'nothing') { $data['extra_class'] = 'jig-contentID-NG-' . $cover_image->pid; } array_push($this->images, $data); } } } } } else { return $this->frontend_stop(sprintf(__('There is no content in the NextGEN album: "%1$s"!', 'jig_td'), stripcslashes($album->name))); } } else { return $this->frontend_stop(sprintf(__('There is no content in the NextGEN album: "%1$s"!', 'jig_td'), stripcslashes($album->name))); } } else { return $this->frontend_stop(sprintf(__('There is no NextGEN album with the ID: "%1$s"!', 'jig_td'), $ng_album)); } } else { if ($ng_pics !== '' || $ng_recent_images !== '' || $ng_random_images !== '' || $ng_search_query !== '') { if ($ng_pics) { if (strpos($ng_pics, '-') !== false) { $ng_pics_exploded = explode(',', $ng_pics); foreach ($ng_pics_exploded as &$single_ng_pic) { if (strpos($single_ng_pic, '-') !== false) { $ng_pic_range = explode('-', $single_ng_pic); $single_ng_pic = implode(',', range($ng_pic_range[0], $ng_pic_range[1])); } } $ng_pics = implode(',', $ng_pics_exploded); } $images = $this->jig_ng_find_images($ng_pics); if ($orderby == 'rand') { $images = (array) $images; shuffle($images); } } else { if ($ng_recent_images) { if ($original_nextgen_limit === '') { $limit = 25; } $images = $this->jig_ng_get_recent_images($ng_recent_images, $limit); if ($orderby == 'rand') { $images = (array) $images; shuffle($images); } } else { if ($ng_random_images) { if ($original_nextgen_limit === '') { $limit = 25; } $images = $this->jig_ng_get_random_images($limit, $ng_random_images); } else { if ($ng_search_query) { $this->ng_intersect_tags = $ng_intersect_tags; $images = $this->jig_ng_image_search($ng_search_query, $ng_search_options, $ngg_options['galSort'], $ngg_options['galSortDir'], $limit); if (empty($images)) { return $this->frontend_stop(__('There are no photos that match your search query.', 'jig_td')); } } } } } if (!empty($images)) { $this->images = $url_hash_list = array(); // Create a new array for the images foreach ($images as &$image) { if (!$image->meta_data['width'] || !$image->meta_data['height']) { $url_hash_list[] = hash('md5', $image->imageURL); } $image->jig_image_src = array($image->imageURL, $image->meta_data['width'], $image->meta_data['height']); } unset($image); if (!$this->jig_query_ext_images($url_hash_list)) { $notice_after .= __('Cannot create database for caching external image dimensions.', 'jig_td'); } foreach ($images as $image) { if (!$image->jig_image_src[1] || !$image->jig_image_src[2]) { // If any of the dimensions are not a normal value $image->jig_image_src = $this->jig_get_ext_imagesize($image->jig_image_src); } $image->meta_data['width'] = $image->jig_image_src[1]; $image->meta_data['height'] = $image->jig_image_src[2]; if ($image->meta_data['width'] != 0 && $image->meta_data['height'] != 0) { // If none of the dimensions are 0 $data = $d = array(); // Create 2 arrays for this image one temporary and one that gets pushed $data['url'] = $image->imageURL; $data['width'] = $image->meta_data['width']; $data['height'] = $image->meta_data['height']; $d['title'] = esc_attr(stripslashes(nggGallery::i18n($image->alttext, 'pic_' . $image->pid . '_alttext'))); if ($d['title'] != '') { $data['title'] = $d['title']; } $d['description'] = trim(esc_attr(stripslashes(nggGallery::i18n($image->description, 'pic_' . $image->pid . '_description')))); if ($ng_display_tags == 'yes') { $d['tags'] = ucwords(implode(', ', wp_get_object_terms($image->pid, 'ngg_tag', array('fields' => 'names')))); if (!empty($d['tags'])) { $d['description'] = esc_attr(($d['description'] != '' ? $d['description'] . $separator_character : '') . '<i>' . $d['tags'] . '</i>'); } } if ($d['description'] != '') { $data['description'] = $d['description']; } if ($download_link != 'no') { $data['download'] = esc_attr(stripslashes('<a href="' . plugins_url('download.php', __FILE__) . '?file=' . urlencode($data['url']) . '">' . __($download_link_text, 'jig_td') . '</a>')); } if (isset($image->ng_cf_link)) { $data['link'] = $image->ng_cf_link; $data['link_target'] = $link_target; } if ($filterby == 'on') { $d['filters'] = wp_get_object_terms($image->pid, 'ngg_tag'); if (!empty($d['filters'])) { foreach ($d['filters'] as $filter_term) { $data['filters'][] = array($filter_term->slug, $filter_term->name); } } } elseif ($filterby == 'ng_galleries') { if (!empty($image->slug) && !empty($image->title)) { $data['filters'][] = array($image->slug, $image->title); } } if ($l2_filterby == 'on') { $d['L2filters'] = wp_get_object_terms($image->pid, 'ngg_tag'); if (!empty($d['L2filters'])) { foreach ($d['L2filters'] as $filter_term) { $data['L2filters'][] = array($filter_term->slug, $filter_term->name); } } } elseif ($l2_filterby == 'ng_galleries') { if (!empty($image->slug) && !empty($image->title)) { $data['L2filters'][] = array($image->slug, $image->title); } } if ($this->settings['image_custom_classes'] !== 'nothing') { $data['extra_class'] = 'jig-contentID-NG-' . $image->pid; } array_push($this->images, $data); } } } else { return $this->frontend_stop(__('There are no NextGEN images that could be displayed.', 'jig_td')); } } else { if ($ng_tags_gallery) { $this->ng_intersect_tags = $ng_intersect_tags; $images = $this->jig_ng_find_images_for_tags($ng_tags_gallery, $ngg_options['galSort'], $ngg_options['galSortDir'], $limit); if (!empty($images)) { $this->images = $url_hash_list = array(); // Create a new array for the images $counter = 0; $images = $this->jig_ng_process_images($images); // Very important, sets up the image objects, mimics NG foreach ($images as &$image) { if (++$counter > $limit) { break; } if (!$image->meta_data['width'] || !$image->meta_data['height']) { $url_hash_list[] = hash('md5', $image->imageURL); } $image->jig_image_src = array($image->imageURL, $image->meta_data['width'], $image->meta_data['height']); } unset($image); if (!$this->jig_query_ext_images($url_hash_list)) { $notice_after .= __('Cannot create database for caching external image dimensions.', 'jig_td'); } $counter = 0; foreach ($images as $image) { if (++$counter > $limit) { break; } if (!$image->jig_image_src[1] || !$image->jig_image_src[2]) { // If any of the dimensions are not a normal value $image->jig_image_src = $this->jig_get_ext_imagesize($image->jig_image_src); } $image->meta_data['width'] = $image->jig_image_src[1]; $image->meta_data['height'] = $image->jig_image_src[2]; if ($image->meta_data['width'] != 0 && $image->meta_data['height'] != 0) { // If none of the dimensions are 0 $data = $d = array(); // Create 2 arrays for this image one temporary and one that gets pushed $data['url'] = $image->imageURL; $data['width'] = $image->meta_data['width']; $data['height'] = $image->meta_data['height']; $d['title'] = esc_attr(stripslashes(nggGallery::i18n($image->alttext, 'pic_' . $image->pid . '_alttext'))); if ($d['title'] != '') { $data['title'] = $d['title']; } $d['description'] = trim(esc_attr(stripslashes(nggGallery::i18n($image->description, 'pic_' . $image->pid . '_description')))); if ($ng_display_tags == 'yes') { $d['tags'] = ucwords(implode(', ', wp_get_object_terms($image->pid, 'ngg_tag', array('fields' => 'names')))); if (!empty($d['tags'])) { $d['description'] = esc_attr(($d['description'] != '' ? $d['description'] . $separator_character : '') . '<i>' . $d['tags'] . '</i>'); } } if ($d['description'] != '') { $data['description'] = $d['description']; } if ($download_link != 'no') { $data['download'] = esc_attr(stripslashes('<a href="' . plugins_url('download.php', __FILE__) . '?file=' . urlencode($data['url']) . '">' . __($download_link_text, 'jig_td') . '</a>')); } if (isset($image->ng_cf_link)) { $data['link'] = $image->ng_cf_link; $data['link_target'] = $link_target; } if ($filterby == 'on') { $d['filters'] = wp_get_object_terms($image->pid, 'ngg_tag'); if (!empty($d['filters'])) { foreach ($d['filters'] as $filter_term) { $data['filters'][] = array($filter_term->slug, $filter_term->name); } } } elseif ($filterby == 'ng_galleries') { if (!empty($image->slug) && !empty($image->title)) { $data['filters'][] = array($image->slug, $image->title); } } if ($l2_filterby == 'on') { $d['L2filters'] = wp_get_object_terms($image->pid, 'ngg_tag'); if (!empty($d['L2filters'])) { foreach ($d['L2filters'] as $filter_term) { $data['L2filters'][] = array($filter_term->slug, $filter_term->name); } } } elseif ($l2_filterby == 'ng_galleries') { if (!empty($image->slug) && !empty($image->title)) { $data['L2filters'][] = array($image->slug, $image->title); } } if (!empty($ng_narrow_by_tags)) { $ng_image_tags = wp_get_object_terms($image->pid, 'ngg_tag'); if (!empty($ng_image_tags)) { foreach ($ng_image_tags as $filter_term) { if (in_array($filter_term->slug, $ng_narrow_by_tags) || in_array($filter_term->name, $ng_narrow_by_tags)) { $ng_tag_found_in_image = true; break; } } if (!isset($ng_tag_found_in_image)) { unset($ng_tag_found_in_image); continue; // Don't add this image to the images if it's missing the tag(s) } } else { continue; // Don't add this image to the images if it's missing ANY tag(s) } unset($ng_image_tags, $ng_tag_found_in_image); } if ($this->settings['image_custom_classes'] !== 'nothing') { $data['extra_class'] = 'jig-contentID-NG-' . $image->pid; } array_push($this->images, $data); } } } else { return $this->frontend_stop(__('No images could be found with that tag.', 'jig_td')); } } else { if ($ng_tags_album) { $this->ng_intersect_tags = $ng_intersect_tags; $images = $this->jig_ng_find_images_for_tags($ng_tags_album, $ngg_options['galSort'], $ngg_options['galSortDir'], $limit, true); if (!empty($images)) { $this->images = $url_hash_list = array(); // Create a new array for the images $images = $this->jig_ng_process_images($images); // Very important, sets up the image objects, mimics NG foreach ($images as &$image) { if (empty($image)) { unset($image); continue; } if (!$image->meta_data['width'] || !$image->meta_data['height']) { $url_hash_list[] = hash('md5', $image->imageURL); } $image->jig_image_src = array($image->imageURL, $image->meta_data['width'], $image->meta_data['height']); } unset($image); if (!$this->jig_query_ext_images($url_hash_list)) { $notice_after .= __('Cannot create database for caching external image dimensions.', 'jig_td'); } foreach ($images as $image) { if (empty($image)) { unset($image); continue; } if ($ng_lightbox_gallery == 'yes') { // If gallery should be displayed as a lightbox $lightbox_images = $this->jig_ng_find_images_for_tags($image->slug, $ngg_options['galSort'], $ngg_options['galSortDir'], $limit); if (!empty($lightbox_images)) { $lightbox_images = $this->jig_ng_process_images($lightbox_images); // Very important, sets up the image objects, mimics NG $shadow_galleries[] = $shadow_group_id = "jig{$jig_id}-hiddenGalleryGroup-" . $image->slug; $shadow_gallery = '<div class="jig-hiddenGallery">'; if (stripos($link_rel, '*instance*') !== false) { $shadow_rel = str_replace('*instance*', 'NG-' . $image->slug, $link_rel); } else { switch ($lightbox) { case 'prettyphoto': $shadow_rel = 'prettyPhoto[ngg-' . $image->slug . ']'; break; case 'colorbox': $shadow_rel = 'colorBox[ngg-' . $image->slug . ']'; break; case 'foobox': $shadow_rel = 'foobox[ngg-' . $image->slug . ']'; break; default: $shadow_rel = 'jig[ngg-' . $image->slug . ']'; break; } } if ($lightbox == 'photoswipe') { foreach ($lightbox_images as &$lightbox_image) { if (!$lightbox_image->meta_data['width'] || !$lightbox_image->meta_data['height']) { $url_hash_list[] = hash('md5', $lightbox_image->imageURL); } $lightbox_image->jig_image_src = array($lightbox_image->imageURL, $lightbox_image->meta_data['width'], $lightbox_image->meta_data['height']); } unset($lightbox_image); // this prepopulates wp_cache with the dimensions, if found if (!$this->jig_query_ext_images($url_hash_list)) { $notice_after .= __('Cannot create database for caching external image dimensions.', 'jig_td'); } } foreach ($lightbox_images as $lightbox_image) { // Skip image from the hidden gallery if it's the same as the opener image if ($lightbox_image->filename == $image->filename) { continue; } $data = $d = array(); // Create 2 arrays for this image one temporary and one that gets pushed $data['url'] = $lightbox_image->imageURL; $d['title'] = esc_attr(stripslashes(nggGallery::i18n($lightbox_image->alttext, 'pic_' . $lightbox_image->pid . '_alttext'))); $d['description'] = trim(esc_attr(stripslashes(nggGallery::i18n($lightbox_image->description, 'pic_' . $lightbox_image->pid . '_description')))); if ($ng_display_tags == 'yes') { $d['tags'] = ucwords(implode(', ', wp_get_object_terms($lightbox_image->pid, 'ngg_tag', array('fields' => 'names')))); if (!empty($d['tags'])) { $d['description'] = esc_attr(($d['description'] != '' ? $d['description'] . $separator_character : '') . '<i>' . $d['tags'] . '</i>'); } } $title_fragment = isset($d[$link_title_field]) ? $d[$link_title_field] : ''; $alt_fragment = isset($d[$img_alt_field]) ? $d[$img_alt_field] : ''; if ($download_link != 'no') { $data['download'] = esc_attr(stripslashes('<a href="' . plugins_url('download.php', __FILE__) . '?file=' . urlencode($data['url']) . '">' . __($download_link_text, 'jig_td') . '</a>')); if ($download_link == 'yes') { if ($title_fragment !== '') { $title_fragment .= $separator_character . $data['download']; } else { $title_fragment = $data['download']; } } else { if ($alt_fragment !== '') { $alt_fragment .= $separator_character . $data['download']; } else { $alt_fragment = $data['download']; } } } if ($lightbox == 'photoswipe') { if (!$lightbox_image->jig_image_src[1] || !$lightbox_image->jig_image_src[2]) { // If any of the dimensions are not a normal value $lightbox_image->jig_image_src = $this->jig_get_ext_imagesize($lightbox_image->jig_image_src); } $lightbox_image->meta_data['width'] = $lightbox_image->jig_image_src[1]; $lightbox_image->meta_data['height'] = $lightbox_image->jig_image_src[2]; if ($lightbox_image->meta_data['width'] != 0 && $lightbox_image->meta_data['height'] != 0) { // If none of the dimensions are 0 $shadow_size = ' data-wh="' . $lightbox_image->meta_data['width'] . 'x' . $lightbox_image->meta_data['height'] . '"'; } else { continue; } } else { $shadow_size = ''; } $shadow_class = 'class="jig-link jig-contentID-NG-' . $lightbox_image->pid . (empty($link_class) ? '' : ' ' . $link_class) . '" '; $shadow_gallery .= '<a href="' . $data['url'] . '" rel="' . $shadow_rel . '" ' . $shadow_class . $shadow_size . ' title="' . $title_fragment . '"><img src="data:image/gif;base64,R0lGODlhAQABAPABAP///wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw%3D%3D" alt="' . $alt_fragment . '" /></a>'; } $shadow_gallery .= "</div>"; $image->count = count((array) $lightbox_images); } } if (!$image->jig_image_src[1] || !$image->jig_image_src[2]) { // If any of the dimensions are not a normal value $image->jig_image_src = $this->jig_get_ext_imagesize($image->jig_image_src); } $image->meta_data['width'] = $image->jig_image_src[1]; $image->meta_data['height'] = $image->jig_image_src[2]; if ($image->meta_data['width'] != 0 && $image->meta_data['height'] != 0) { // If none of the dimensions are 0 $data = $d = array(); // Create 2 arrays for this image one temporary and one that gets pushed $data['url'] = $image->imageURL; $data['width'] = $image->meta_data['width']; $data['height'] = $image->meta_data['height']; $d['title'] = esc_attr(stripslashes($image->name)); if ($d['title'] != '') { $data['title'] = ucfirst(nggGallery::i18n($d['title'], 'tag_' . $d['title'])); } $d['description'] = esc_attr(stripslashes($image->count . ' ' . __('Photos', 'nggallery'))); if ($d['description'] != '') { $data['description'] = $d['description']; } $d['link'] = $this->jig_ng_get_permalink(array('gallerytag' => $image->slug)); if ($ng_lightbox_gallery == 'yes' && isset($shadow_gallery)) { $d['link'] = NULL; $data['gallery']['html'] = $shadow_gallery; $data['gallery']['rel'] = $shadow_rel; $data['gallery']['id'] = $shadow_group_id; if (isset($data['title'])) { $data['gallery']['title'] = $data['title']; } if (isset($data['description'])) { $data['gallery']['description'] = $data['description']; } $d['title'] = esc_attr(stripslashes(nggGallery::i18n($image->alttext, 'pic_' . $image->pid . '_alttext'))); if ($d['title'] != '') { $data['title'] = $d['title']; } else { unset($data['title']); } $d['description'] = trim(esc_attr(stripslashes(nggGallery::i18n($image->description, 'pic_' . $image->pid . '_description')))); if ($ng_display_tags == 'yes') { $d['tags'] = ucwords(implode(', ', wp_get_object_terms($image->pid, 'ngg_tag', array('fields' => 'names')))); if (!empty($d['tags'])) { $d['description'] = esc_attr(($d['description'] != '' ? $d['description'] . $separator_character : '') . '<i>' . $d['tags'] . '</i>'); } } if ($d['description'] != '') { $data['description'] = $d['description']; } else { unset($data['description']); } switch ($lightbox) { case 'foobox': $data['gallery']['lightbox_class'] = 'jigFooBoxConnect'; break; case 'socialgallery': $data['gallery']['lightbox_class'] = 'jigSgConnect'; break; default: } } if ($download_link != 'no') { $data['download'] = esc_attr(stripslashes('<a href="' . plugins_url('download.php', __FILE__) . '?file=' . urlencode($data['url']) . '">' . __($download_link_text, 'jig_td') . '</a>')); } if ($d['link']) { $data['link'] = $d['link']; } if ($this->settings['image_custom_classes'] !== 'nothing') { $data['extra_class'] = 'jig-contentID-NG-' . $image->pid; } array_push($this->images, $data); } } } else { return $this->frontend_stop(__('No images could be found with that tag.', 'jig_td')); } } } } } } // NG custom breadcrumb $ng_bc_album_need = true; if ($ng_breadcrumb == 'yes') { // If the breadcrumb feature is enabled $query_gallery = $this->jig_ng_get_query_var('gallery'); $query_album = $this->jig_ng_get_query_var('album'); $query_tags = $this->jig_ng_get_query_var('gallerytag'); $ng_breadcrumb_output = array(); if ($ng_bc_base !== '' && $ng_bc_base !== 'none') { $ng_breadcrumb_output[0] = $ng_bc_base . ' '; } if (isset($ng_bc_home_album)) { // If there was an album id originally if ($ng_bc_home_album !== 'all' && $ng_bc_home_album != "0") { // And it was a single particular album // Get the album's name from the cache or the db $ng_bc_home_album_object = wp_cache_get($ng_bc_home_album, 'jig_ng_albums'); if ($ng_bc_home_album_object !== false) { $ng_bc_home_output = stripcslashes(nggGallery::i18n($ng_bc_home_album_object->name, 'album_' . $ng_bc_home_album_object->id . '_name')); } else { $ng_bc_home_album_object = $wpdb->get_row($wpdb->prepare("SELECT name,slug,id FROM {$wpdb->nggalbum} WHERE id = %d", $ng_bc_home_album)); $ng_bc_home_output = stripcslashes(nggGallery::i18n($ng_bc_home_album_object->name, 'album_' . $ng_bc_home_album_object->id . '_name')); } // If the original album is the same as the currently displayed album, don't show the album part of the breadcrumb if (!empty($query_album) && ($ng_bc_home_album_object->slug == $query_album || $ng_bc_home_album_object->id == $query_album)) { $ng_bc_album_need = false; } } else { // If the album was an overview $ng_bc_home_output = __('Album overview', 'jig_td'); } } else { // If the original shortcode wasn't an album, fall back to post title $ng_bc_home_output = $post->post_title; } switch ($ng_bc_home) { // Different home styles case 'post_title': $ng_bc_home_output = $post->post_title; break; case 'custom_text': $ng_bc_home_output = $ng_bc_home_text; break; case 'album_name': // Leave $ng_bc_home_output as it is, it was previously created break; case 'none': default: $ng_bc_home_output = ''; } if ($ng_bc_home !== 'none' && $ng_bc_home_clickable == 'yes' && empty($query_album) && empty($query_gallery) && empty($query_tags) && $ng_bc_last_clickable == 'yes' || $ng_bc_home !== 'none' && $ng_bc_home_clickable == 'yes' && (!empty($query_album) || !empty($query_gallery) || !empty($query_tags))) { // Get the current URL using WP Class global $wp, $wp_rewrite; $ng_home_permalink = home_url(add_query_arg(array(), $wp->request)); $ngoptions = get_option('ngg_options'); $ng_permalink_slug = !empty($ngoptions['router_param_slug']) ? $ngoptions['router_param_slug'] : $ngoptions['permalinkSlug']; // If the permalink slug is in the URL, return the true base URL $slug_position = strripos($ng_home_permalink, $ng_permalink_slug); if ($slug_position !== false) { $ng_home_permalink = substr($ng_home_permalink, 0, $slug_position); } // Trailing slash it $ng_home_permalink = trailingslashit($ng_home_permalink); // If WP permalinks are off this makes the home element detect the origin page or post... global $query_string; if ($wp_rewrite->using_permalinks() !== true && !empty($query_string)) { $ng_home_permalink .= '?' . remove_query_arg(array('album', 'gallery', 'gallerytag'), $query_string); $ng_home_permalink = untrailingslashit(urldecode($ng_home_permalink)); } $ng_breadcrumb_output[0] .= '<a href="' . esc_url($ng_home_permalink) . '" >' . $ng_bc_home_output . '</a>'; } else { // If it's not clickable just show it as-is $ng_breadcrumb_output[0] .= $ng_bc_home_output; } // Album part if (!empty($query_album) && $query_album !== 'all' && $ng_bc_album_need === true) { if (is_numeric($query_album)) { $album = $wpdb->get_row($wpdb->prepare("SELECT name,id FROM {$wpdb->nggalbum} WHERE id = %d LIMIT 0,1", $query_album)); } if (!is_numeric($query_album) || is_numeric($query_album) && empty($album)) { $album = $wpdb->get_row($wpdb->prepare("SELECT name,id FROM {$wpdb->nggalbum} WHERE slug = %s LIMIT 0,1", $query_album)); } $album_text = stripcslashes(nggGallery::i18n($album->name, 'album_' . $album->id . '_name')); if (empty($query_gallery) && $ng_bc_last_clickable == 'no') { $ng_breadcrumb_output[] = $album_text; } else { global $wp_query; $wp_query->set('gallery', false); $ng_breadcrumb_output[] = '<a href="' . $this->jig_ng_get_permalink(array('gallery' => false, 'album' => $query_album, 'nggpage' => false)) . '">' . $album_text . '</a>'; $wp_query->set('gallery', $query_gallery); } } // Gallery part if (!empty($query_gallery)) { // Needed by the breadcrumb if (is_numeric($query_gallery)) { $gallery = $wpdb->get_row($wpdb->prepare("SELECT title,gid FROM {$wpdb->nggallery} WHERE gid = %d LIMIT 0,1", $query_gallery)); } if (!is_numeric($query_gallery) || is_numeric($query_gallery) && empty($gallery)) { $gallery = $wpdb->get_row($wpdb->prepare("SELECT title,gid FROM {$wpdb->nggallery} WHERE slug = %s LIMIT 0,1", $query_gallery)); } $gallery_text = nggGallery::i18n(stripslashes($gallery->title), 'gal_' . $gallery->gid . '_title'); if ($ng_bc_last_clickable == 'no') { $ng_breadcrumb_output[] = $gallery_text; } else { $ng_breadcrumb_output[] = '<a href="' . $this->jig_ng_get_permalink(array('album' => !empty($query_album) ? $query_album : false, 'gallery' => !empty($query_gallery) ? $query_gallery : false)) . '" >' . $gallery_text . '</a>'; } } // Tags (gallery) part if (!empty($query_tags)) { $tagname = ucfirst($wpdb->get_var($wpdb->prepare("SELECT name FROM {$wpdb->terms} WHERE slug = %s", $query_tags))); if ($ng_bc_last_clickable == 'no') { $ng_breadcrumb_output[] = nggGallery::i18n($tagname, 'tag_' . $tagname); } else { $ng_breadcrumb_output[] = '<a href="' . $this->jig_ng_get_permalink(array('gallerytag' => $query_tags)) . '" >' . nggGallery::i18n($tagname, 'tag_' . $tagname) . '</a>'; } } switch ($ng_bc_separator) { case 'default': $ng_bc_separator = ' »'; break; case 'greater': $ng_bc_separator = ' >'; break; case 'comma': $ng_bc_separator = ','; break; case 'slash': $ng_bc_separator = ' /'; break; case 'doubleslash': $ng_bc_separator = ' //'; break; case 'minus': $ng_bc_separator = ' -'; break; case 'plus': $ng_bc_separator = ' +'; break; case 'arrow': $ng_bc_separator = ' →'; break; case 'bslash': $ng_bc_separator = ' \\'; break; case 'doublebslash': $ng_bc_separator = ' \\\\'; break; case 'middledot': $ng_bc_separator = ' ·'; break; case 'dobulecolon': $ng_bc_separator = ' ::'; break; case 'numbersign': $ng_bc_separator = ' #'; break; } // Join the breadcrumb parts together with the separator as a glue, with spaces $ng_breadcrumb_output_joined = implode($ng_bc_separator . ' ', $ng_breadcrumb_output); // If an extra separator is needed at the end, add it if ($ng_bc_add_separator == 'yes') { $ng_breadcrumb_output_joined .= $ng_bc_separator; } // Display it if this is the jig-connected NG instance or the top level is forced if (isset($jigNgConnect) || $ng_bc_top_level == 'yes') { $notice_before = '<div class="jig-ngBreadcrumb">' . $ng_breadcrumb_output_joined . '</div>' . $notice_before; } } // end of NG custom breadcrumb break; case 'facebook': if (!isset($this->settings['fb_authed'][$facebook_id])) { return $this->frontend_stop(__('That Facebook ID is unauthorized for use, please go to Settings and add it.', 'jig_td')); } $user = $this->settings['fb_authed'][$facebook_id]; $token = $user['access_token']; if (empty($token) || $token == 'public') { if (!empty($this->settings['fb_app_id']) && !empty($this->settings['fb_app_secret'])) { $token = $this->settings['fb_app_id'] . '|' . $this->settings['fb_app_secret']; } else { $output = array('error' => __('Justified Image Grid: To access any Facebook content, you must create a simple Facebook App first (and fill App ID and App Secret fields).', 'jig_td')); echo json_encode($output); die; } } if ($limit === "0") { $limit = 500; $limit_parameter = "&limit=500"; } else { if ($limit !== '') { $limit_parameter = "&limit=" . $limit; } else { $limit = 25; // mimic the default limit $limit_parameter = ''; } } $facebook_album = str_replace(' ', '', $facebook_album); // Multi album mode if (strpos($facebook_album, ',') !== false || $fb_album_exclude == 'yes' || $facebook_album == 'latestone') { $facebook_album_multi = explode(',', $facebook_album); $facebook_album = 'overview'; $limit = 500; $limit_parameter = "&limit=500"; // When user selects some from the bottom, don't cut it off because of the default 25 limit } // For any of the overview modes if ($facebook_album == 'overview' || $facebook_album == 'overview_only_albums') { if ($fb_lightbox_album == 'yes') { if (empty($facebook_album_multi) || !empty($facebook_album_multi) && $fb_album_exclude == 'yes') { // Preventing showing everything at once with lightbox albums. $preliminary_count_check_albums_url = 'https://graph.facebook.com/v2.4/' . $facebook_id . '?fields=albums.limit(' . $limit . ').fields(count)&access_token=' . $token; $preliminary_count_check_albums = $this->facebook_api_call($preliminary_count_check_albums_url, $facebook_caching, $limit); if (!empty($preliminary_count_check_albums) && empty($preliminary_count_check_albums['message'])) { $total_count = 0; foreach ($preliminary_count_check_albums as $preliminary_count_check_album) { if (!empty($preliminary_count_check_album->count)) { $total_count += min($preliminary_count_check_album->count, $limit); } } } else { if (!empty($preliminary_count_check_albums['message'])) { return $this->frontend_stop(__('Justified Image Grid: The Facebook content cannot be displayed, the error from Facebook:', 'jig_td') . ' ' . $preliminary_count_check_albums['message']); } else { return $this->frontend_stop(__('There are no albums.', 'jig_td')); } } if ($total_count > 2000) { return $this->frontend_stop(sprintf(__('Too many photos for lightbox albums. Disable "Open albums in lightbox" as you have %d photos. This feature is only suitable for max 2000 photos!', 'jig_td'), $total_count)); } else { $auto_limit = 500; } } else { $auto_limit = 1; } $albums_url = 'https://graph.facebook.com/v2.4/' . $facebook_id . '?fields=albums.limit(' . $limit . ').fields(id,cover_photo,link,count,name,description,type,photos.limit(' . $auto_limit . ').fields(images,source,height,width,name))&access_token=' . $token; } else { $albums_url = 'https://graph.facebook.com/v2.4/' . $facebook_id . '?fields=albums.limit(' . $limit . ').fields(id,cover_photo,link,count,name,description,type,photos.limit(1).fields(images))&access_token=' . $token; } if (!empty($facebook_album_multi) && $facebook_album_multi[0] == 'latestone') { $facebook_album = 'overview_only_albums'; if (count($facebook_album_multi) == 1) { $fb_lightbox_album = 'yes'; } $albums_url = 'https://graph.facebook.com/v2.4/' . $facebook_id . '?fields=albums.limit(5).fields(id,cover_photo,link,count,name,description,type,photos.limit(' . $limit . ').fields(images,source,height,width,name))&access_token=' . $token; $albums = $this->facebook_api_call($albums_url, $facebook_caching, 5); } else { $albums = $this->facebook_api_call($albums_url, $facebook_caching, $limit); } if (!empty($albums) && empty($albums['message'])) { if ($limit !== '' && count($albums) > $limit) { $albums = array_slice($albums, 0, $limit); } if ($fb_lightbox_album == 'no') { $facebook_album_from_slug = get_query_var($this->settings['fb_overview_slug']); foreach ($albums as $album) { if ($album->id === $facebook_album_from_slug) { $album_name = $album->name; $facebook_album = $facebook_album_from_slug; break; } } } global $wp, $query_string, $wp_rewrite, $wp_query; if (!empty($album_name)) { if ($fb_breadcrumb == 'yes') { $fb_home_permalink = home_url(add_query_arg(array(), $wp->request)); $slug_position = strripos($fb_home_permalink, $this->settings['fb_overview_slug']); if ($slug_position !== false) { $fb_home_permalink = substr($fb_home_permalink, 0, $slug_position); } if (substr($fb_home_permalink, -1) != '/') { $fb_home_permalink .= '/'; } if ($fb_home_permalink == home_url('/') && strlen($query_string) > 0 && strpos($query_string, $this->settings['fb_overview_slug']) !== false) { $fb_home_permalink .= '?' . remove_query_arg($this->settings['fb_overview_slug'], $query_string); } switch ($fb_bc_separator) { case 'default': $fb_bc_separator = ' »'; break; case 'greater': $fb_bc_separator = ' >'; break; case 'comma': $fb_bc_separator = ','; break; case 'slash': $fb_bc_separator = ' /'; break; case 'doubleslash': $fb_bc_separator = ' //'; break; case 'minus': $fb_bc_separator = ' -'; break; case 'plus': $fb_bc_separator = ' +'; break; case 'arrow': $fb_bc_separator = ' →'; break; case 'bslash': $fb_bc_separator = ' \\'; break; case 'doublebslash': $fb_bc_separator = ' \\\\'; break; case 'middledot': $fb_bc_separator = ' ·'; break; case 'dobulecolon': $fb_bc_separator = ' ::'; break; case 'numbersign': $fb_bc_separator = ' #'; break; } $notice_before .= '<div class="jig-fbBreadcrumb"><a href="' . esc_url($fb_home_permalink) . '">' . ($fb_bc_home_text === '' ? $user['user_name'] : $fb_bc_home_text) . '</a> ' . $fb_bc_separator . ' ' . $album_name . '</div>'; $fb_bc_CSS_needed = true; if ($facebook_description == 'yes' || $facebook_description == 'above') { $facebook_description_displayed_already = true; if (!empty($album->description)) { if (strpos($album->description, '@') === false) { $notice_before .= '<p class="jig-fbDescription">' . $album->description . '</p>'; } else { $notice_before .= '<p class="jig-fbDescription">' . preg_replace('/@\\[[:\\d]+:(.+?)\\]/im', '$1', $album->description) . '</p>'; } } } } } else { $this->images = array(); // Create a new array for the images $found = 0; $facebook_overview_caching = $this->settings['facebook_overview_caching']; if ($orderby == 'rand') { $albums = (array) $albums; shuffle($albums); } if ($retina_ready == 'yes') { $calculated_max_height = $max_height * 3; } else { $calculated_max_height = $max_height; } foreach ($albums as $key => $album) { if ($facebook_album == 'overview_only_albums' && $album->type !== 'normal') { continue; } elseif (!empty($facebook_album_multi) && $facebook_album_multi[0] !== 'latestone' && ($fb_album_exclude == 'yes' && in_array($album->id, $facebook_album_multi) || $fb_album_exclude == 'no' && !in_array($album->id, $facebook_album_multi))) { continue; } if (!empty($album->count) && !empty($album->link) && !empty($album->photos->data)) { if ($fb_lightbox_album == 'no' && $fb_actual_cover_photo == 'yes' && !empty($album->cover_photo)) { // Since FB has a cover_photo in the album, it can be queried directly, this is a request for just one single photo. if (is_string($album->cover_photo)) { $fb_cover_photo_url = 'https://graph.facebook.com/v2.4/' . $album->cover_photo . '?fields=images&access_token=' . $token; } elseif (!empty($album->cover_photo->id)) { $fb_cover_photo_url = 'https://graph.facebook.com/v2.4/' . $album->cover_photo->id . '?fields=images&access_token=' . $token; } // Shared album (created by multiple people) cover photo (manual) is not sent properly by the Facebook API if ($facebook_overview_caching > 0) { if (get_transient('jigfb_' . md5($fb_cover_photo_url . $facebook_overview_caching)) == true) { $fb_cover_photo_result = get_transient('jigfb_' . md5($fb_cover_photo_url . $facebook_overview_caching)); } else { $fb_cover_photo_result = json_decode($this->file_get_contents_curl($fb_cover_photo_url)); set_transient('jigfb_' . md5($fb_cover_photo_url . $facebook_overview_caching), $fb_cover_photo_result, 60 * $facebook_overview_caching); } } else { $fb_cover_photo_result = json_decode($this->file_get_contents_curl($fb_cover_photo_url)); } // This is necessary because sometimes the FB result has a data object, sometimes doesn't... if (!empty($fb_cover_photo_result->data)) { $album->photos->data[0] = $fb_cover_photo_result->data[0]; } else { $album->photos->data[0] = $fb_cover_photo_result; } } if (!empty($album->photos)) { $subalbum = new stdClass(); $subalbum->data = $album->photos->data; $data = array(); // Create a new array for this image if (isset($album->name)) { $data['title'] = esc_attr(stripslashes($album->name)); } if ($facebook_count == 'yes') { $description_fragments = array(min($album->count, $limit) . ' ' . _n('Photo', 'Photos', $album->count, 'jig_td')); if ($facebook_description == 'yes' || $facebook_description == 'thumbnails') { if (!empty($album->description)) { if (strpos($album->description, '@') === false) { $description_fragments[] = esc_attr(stripslashes($album->description)); } else { $description_fragments[] = esc_attr(stripslashes(preg_replace('/@\\[[:\\d]+:(.+?)\\]/im', '$1', $album->description))); } } } $data['description'] = esc_attr(stripslashes(implode('<br />', $description_fragments))); } else { if (($facebook_description == 'yes' || $facebook_description == 'thumbnails') && !empty($album->description)) { if (strpos($album->description, '@') === false) { $data['description'] = esc_attr(stripslashes($album->description)); } else { $data['description'] = esc_attr(stripslashes(preg_replace('/@\\[[:\\d]+:(.+?)\\]/im', '$1', $album->description))); } } } $show_on_front = get_option('show_on_front'); $page_on_front = get_option('page_on_front'); $args[$this->settings['fb_overview_slug']] = $album->id; if ($wp_rewrite->using_permalinks()) { if (is_singular()) { $post =& get_post(get_the_ID()); $url = trailingslashit(get_permalink($post->ID)); if ($show_on_front == 'page' && $page_on_front == get_the_ID()) { $url = trailingslashit(home_url($post->page_name ? $post->page_name : $post->post_name)); } } else { $url = 'http' . (is_ssl() ? 's' : '') . '://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; } $url .= $this->settings['fb_overview_slug'] . '/' . $args[$this->settings['fb_overview_slug']]; $data['link'] = $url; } else { if (is_home()) { $args['pageid'] = get_the_ID(); } if ($show_on_front == 'page' && $page_on_front == get_the_ID()) { $args['page_id'] = get_the_ID(); } if (is_singular()) { $query = htmlspecialchars(add_query_arg($args, get_permalink(get_the_ID()))); } else { $query = htmlspecialchars(add_query_arg($args)); } $data['link'] = esc_url($query); } if ($fb_lightbox_album == 'yes') { $data['url'] = $subalbum->data[0]->source; $data['width'] = $subalbum->data[0]->width; $data['height'] = $subalbum->data[0]->height; } elseif ($photon_activated || $aspect_ratio || $randomize_width > 0) { $data['url'] = $subalbum->data[0]->images[0]->source; $data['width'] = $subalbum->data[0]->images[0]->width; $data['height'] = $subalbum->data[0]->images[0]->height; } else { for ($i = count($subalbum->data[0]->images) - 1; $i >= 0; $i--) { if ($subalbum->data[0]->images[$i]->height >= $calculated_max_height) { $data['url'] = $subalbum->data[0]->images[$i]->source; $data['width'] = $subalbum->data[0]->images[$i]->width; $data['height'] = $subalbum->data[0]->images[$i]->height; break; } } if (empty($data['url'])) { $data['url'] = $subalbum->data[0]->images[0]->source; $data['width'] = $subalbum->data[0]->images[0]->width; $data['height'] = $subalbum->data[0]->images[0]->height; } } if ($this->settings['image_custom_classes'] !== 'nothing') { $data['extra_class'] = 'jig-contentID-FB-' . $subalbum->data[0]->id; } if ($fb_lightbox_album == 'yes') { // If gallery should be displayed as a lightbox $shadow_galleries[] = $shadow_group_id = "jig{$jig_id}-hiddenGalleryGroup-" . $album->id; $shadow_gallery = '<div class="jig-hiddenGallery">'; if (stripos($link_rel, '*instance*') !== false) { $shadow_rel = str_replace('*instance*', 'FB-' . $album->id, $link_rel); } else { switch ($lightbox) { case 'prettyphoto': $shadow_rel = 'prettyPhoto[fb-' . $album->id . ']'; break; case 'colorbox': $shadow_rel = 'colorBox[fb-' . $album->id . ']'; break; case 'foobox': $shadow_rel = 'foobox[fb-' . $album->id . ']'; break; default: $shadow_rel = 'jig[fb-' . $album->id . ']'; break; } } if (isset($data['title'])) { $data['gallery']['title'] = $data['title']; } if (isset($data['description'])) { $data['gallery']['description'] = $data['description']; } if ($album->count !== count($subalbum->data) && count($subalbum->data) < $limit) { // Facebook returned less images than desired. The reason is their paging limits or in case of JIG lightbox albums, the album contents are initialized by a tiny amount images first to not exhaust Facebook. Thus the internal limit is increased. $auto_limit = empty($auto_limit) ? 0 : $auto_limit; $additional_photos = $this->facebook_api_call(str_replace('limit=1&', 'limit=' . ($limit < 500 ? max(array($auto_limit - 1, 1)) : 500 - $auto_limit) . '&', $album->photos->paging->next), $facebook_caching, $limit, count($subalbum->data)); if (!empty($additional_photos) && is_array($additional_photos)) { $subalbum->data = array_merge($subalbum->data, $additional_photos); // This corrects the amount of photos in the lightbox gallery because FB sometimes says there are more photos than the amount available if ($facebook_count == 'yes' && $album->count !== count($subalbum->data)) { $data['description'] = str_replace($album->count, count($subalbum->data), $data['description']); } } } foreach ($subalbum->data as $subalbum_image) { $shadow_data = $sd = array(); // Create 2 arrays for this image one temporary and one that gets pushed $shadow_size = ''; if ($facebook_image_size == 'larger') { if ($subalbum_image->images[0]->height < 2048 && $subalbum_image->images[0]->width < 2048) { $shadow_data['url'] = $subalbum_image->images[0]->source; if ($lightbox == 'photoswipe') { $shadow_size = ' data-wh="' . $subalbum_image->images[0]->width . 'x' . $subalbum_image->images[0]->height . '"'; } } else { $shadow_data['url'] = $subalbum_image->images[1]->source; if ($lightbox == 'photoswipe') { $shadow_size = ' data-wh="' . $subalbum_image->images[1]->width . 'x' . $subalbum_image->images[1]->height . '"'; } } } else { if ($facebook_image_size == 'maximum') { $shadow_data['url'] = $subalbum_image->images[0]->source; if ($lightbox == 'photoswipe') { $shadow_size = ' data-wh="' . $subalbum_image->images[0]->width . 'x' . $subalbum_image->images[0]->height . '"'; } } else { $shadow_data['url'] = $subalbum_image->source; if ($lightbox == 'photoswipe') { $shadow_size = ' data-wh="' . $subalbum_image->width . 'x' . $subalbum_image->height . '"'; } } } // Skip image from the hidden gallery if it's the same as the opener image if ($subalbum_image->id == $subalbum->data[0]->id) { // These show up as captions on the thumbnail that launches the lightbox gallery if (isset($data['description'])) { $data['gallery']['description'] = $data['description']; } unset($data['description']); // Have to set the image's own title and desc, once opened in the lightbox if (isset($subalbum_image->name)) { $data['description'] = esc_attr(stripslashes($subalbum_image->name)); } if ($download_link != 'no') { $data['download'] = esc_attr(stripslashes('<a href="' . plugins_url('download.php', __FILE__) . '?file=' . urlencode($shadow_data['url']) . '">' . __($download_link_text, 'jig_td') . '</a>')); } // And don't create the opener picture again in the shadow gallery continue; } $sd['title'] = esc_attr(stripslashes($album->name)); if (isset($subalbum_image->name)) { $sd['description'] = esc_attr(stripslashes($subalbum_image->name)); } $title_fragment = isset($sd[$link_title_field]) ? $sd[$link_title_field] : ''; $alt_fragment = isset($sd[$img_alt_field]) ? $sd[$img_alt_field] : ''; if ($download_link != 'no') { $shadow_data['download'] = esc_attr(stripslashes('<a href="' . plugins_url('download.php', __FILE__) . '?file=' . urlencode($shadow_data['url']) . '">' . __($download_link_text, 'jig_td') . '</a>')); if ($download_link == 'yes') { if ($title_fragment !== '') { $title_fragment .= $separator_character . $shadow_data['download']; } else { $title_fragment = $shadow_data['download']; } } else { if ($alt_fragment !== '') { $alt_fragment .= $separator_character . $shadow_data['download']; } else { $alt_fragment = $shadow_data['download']; } } } $shadow_class = 'class="jig-link jig-contentID-FB-' . $subalbum_image->id . (empty($link_class) ? '' : ' ' . $link_class) . '" '; $shadow_gallery .= '<a href="' . $shadow_data['url'] . '" rel="' . $shadow_rel . '" ' . $shadow_class . $shadow_size . ' title="' . $title_fragment . '"><img src="data:image/gif;base64,R0lGODlhAQABAPABAP///wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw%3D%3D" alt="' . $alt_fragment . '" /></a>'; } $shadow_gallery .= "</div>"; $data['link'] = null; unset($data['link']); $data['thumbUrl'] = $data['url']; if ($facebook_image_size == 'larger') { if ($subalbum->data[0]->images[0]->height < 2048 && $subalbum->data[0]->images[0]->width < 2048) { $data['url'] = $subalbum->data[0]->images[0]->source; $data['width'] = $subalbum->data[0]->images[0]->width; $data['height'] = $subalbum->data[0]->images[0]->height; } else { $data['url'] = $subalbum->data[0]->images[1]->source; $data['width'] = $subalbum->data[0]->images[1]->width; $data['height'] = $subalbum->data[0]->images[1]->height; } } else { if ($facebook_image_size == 'maximum') { $data['url'] = $subalbum->data[0]->images[0]->source; $data['width'] = $subalbum->data[0]->images[0]->width; $data['height'] = $subalbum->data[0]->images[0]->height; } else { $data['url'] = $data['thumbUrl']; $data['thumbUrl'] = null; unset($data['thumbUrl']); } } $data['gallery']['html'] = $shadow_gallery; $data['gallery']['rel'] = $shadow_rel; $data['gallery']['id'] = $shadow_group_id; switch ($lightbox) { case 'foobox': $data['gallery']['lightbox_class'] = 'jigFooBoxConnect'; break; case 'socialgallery': $data['gallery']['lightbox_class'] = 'jigSgConnect'; break; default: } } if (!empty($facebook_album_multi) && $facebook_album_multi[0] == 'latestone') { $facebook_album_multi[0] = ''; } array_push($this->images, $data); // Add to the main images array } } $found++; } if ($found == 0 || empty($this->images)) { return $this->frontend_stop(__('There are no pictures in any of the albums.', 'jig_td')); } } } else { if (!empty($albums['message'])) { return $this->frontend_stop(__('Justified Image Grid: The Facebook content cannot be displayed, the error from Facebook:', 'jig_td') . ' ' . $albums['message']); } else { return $this->frontend_stop(__('There are no albums.', 'jig_td')); } } } // For displaying the feed if ($facebook_album == 'feed') { if ($limit > 250) { $limit = 250; $limit_parameter = "&limit=250"; } $feed_url = 'https://graph.facebook.com/v2.4/' . $facebook_id . '/feed?fields=picture,caption,description,message,object_id' . $limit_parameter . '&access_token=' . $token; $photos = $this->facebook_api_call($feed_url, $facebook_caching, $limit); if (!empty($photos)) { $this->images = array(); // Create a new array for the images if ($orderby == 'rand') { $photos = (array) $photos; shuffle($photos); } // Since this is just a request for the image sizes, it could be cached for a very very long time (as album covers) $facebook_overview_caching = $this->settings['facebook_overview_caching']; foreach ($photos as &$feed_post) { if (!(isset($feed_post->picture) && isset($feed_post->object_id))) { continue; // It is not a photo object } else { $photo_object_url = 'https://graph.facebook.com/v2.4/' . $feed_post->object_id . '?fields=images,source,height,width&access_token=' . $token; $photo_object = $this->facebook_api_call($photo_object_url, $facebook_overview_caching, -1); if (isset($photo_object->images)) { $data = $d = array(); // Create a new array for this image $data['thumbUrl'] = $photo_object->source; // Store the full URL value $data['width'] = $photo_object->width; $data['height'] = $photo_object->height; if ($facebook_image_size == 'larger') { if ($photo_object->images[0]->height < 2048 && $photo_object->images[0]->width < 2048) { $data['url'] = $photo_object->images[0]->source; $data['width'] = $photo_object->images[0]->width; $data['height'] = $photo_object->images[0]->height; } else { $data['url'] = $photo_object->images[1]->source; $data['width'] = $photo_object->images[1]->width; $data['height'] = $photo_object->images[1]->height; } } else { if ($facebook_image_size == 'maximum') { $data['url'] = $photo_object->images[0]->source; $data['width'] = $photo_object->images[0]->width; $data['height'] = $photo_object->images[0]->height; } else { $data['url'] = $data['thumbUrl']; $data['thumbUrl'] = null; unset($data['thumbUrl']); } } if (!empty($feed_post->message)) { $d['text'][] = $feed_post->message; } if (!empty($feed_post->caption)) { $d['text'][] = $feed_post->caption; } if (!empty($feed_post->description)) { $d['text'][] = $feed_post->description; } if (!empty($d['text'])) { $d['text'] = array_values(array_unique($d['text'])); $d['textCount'] = count($d['text']); for ($i = 0; $i < $d['textCount']; $i++) { if ($i == 0) { $data['title'] = esc_attr(stripslashes($d['text'][$i])); } else { if (empty($data['description'])) { $data['description'] = esc_attr(stripslashes($d['text'][$i])); } else { $data['description'] .= '<br />' . esc_attr(stripslashes($d['text'][$i])); } } } } if ($download_link != 'no') { $data['download'] = esc_attr(stripslashes('<a href="' . plugins_url('download.php', __FILE__) . '?file=' . urlencode(!empty($photo_object->images[0]->source) ? $photo_object->images[0]->source : $data['url']) . '">' . __($download_link_text, 'jig_td') . '</a>')); } if ($this->settings['image_custom_classes'] !== 'nothing') { $data['extra_class'] = 'jig-contentID-FB-' . $photo_object->id; } if (!in_array($data, $this->images)) { $found = false; foreach ($this->images as $existing_feed_item) { if ($existing_feed_item['thumbUrl'] == $data['thumbUrl']) { $found = true; break; } } if ($found === false) { array_push($this->images, $data); // Add to the main images array } unset($existing_feed_item, $found); } } } } unset($feed_post, $photo_object); } } // For displaying single albums if ($facebook_album !== 'overview' && $facebook_album !== 'overview_only_albums' && $facebook_album !== 'feed') { if ($facebook_album == 'latest') { $albums_url = 'https://graph.facebook.com/v2.4/' . $facebook_id . '?fields=albums.limit(5).fields(id,cover_photo,link,count,name,description,type,photos.limit(' . $limit . ').fields(images,source,height,width,name))&access_token=' . $token; $albums = $this->facebook_api_call($albums_url, $facebook_caching, 5); if (!empty($albums) && empty($albums['message'])) { foreach ($albums as $key => $album) { if ($album->type == 'normal' && !empty($album->count)) { $facebook_album = $album->id; if (($facebook_description == 'yes' || $facebook_description == 'above') && !empty($album->name)) { $facebook_description_displayed_already = true; $notice_before .= '<p class="jig-fbDescription"><strong>' . $album->name . '</strong>' . (!empty($album->description) ? '<br/>' . $album->description : '') . '</p>'; } break; } } if ($facebook_album == 'latest') { return $this->frontend_stop(__('There are no pictures in any of the normal albums.', 'jig_td')); } } else { if (!empty($albums['message'])) { return $this->frontend_stop(__('Justified Image Grid: The Facebook content cannot be displayed, the error from Facebook:', 'jig_td') . ' ' . $albums['message']); } else { return $this->frontend_stop(__('There are no albums.', 'jig_td')); } } } $photos_url = "https://graph.facebook.com/v2.4/" . $facebook_album . "/photos?fields=source,height,width,name" . ($facebook_image_size == 'normal' ? '' : ',images') . $limit_parameter . '&access_token=' . $token; $photos = $this->facebook_api_call($photos_url, $facebook_caching, $limit); if (!empty($photos) && empty($photos['message'])) { if ($limit !== '' && count($photos) > $limit) { $photos = array_slice($photos, 0, $limit); } $this->images = array(); // Create a new array for the images if ($orderby == 'rand') { $photos = (array) $photos; shuffle($photos); } foreach ($photos as $image) { $data = array(); // Create a new array for this image if (isset($image->name)) { $data['title'] = esc_attr(stripslashes($image->name)); } $data['thumbUrl'] = $image->source; // Store the full URL value $data['width'] = $image->width; $data['height'] = $image->height; if ($facebook_image_size == 'larger') { if ($image->images[0]->height < 2048 && $image->images[0]->width < 2048) { $data['url'] = $image->images[0]->source; $data['width'] = $image->images[0]->width; $data['height'] = $image->images[0]->height; } else { $data['url'] = $image->images[1]->source; $data['width'] = $image->images[1]->width; $data['height'] = $image->images[1]->height; } } else { if ($facebook_image_size == 'maximum') { $data['url'] = $image->images[0]->source; $data['width'] = $image->images[0]->width; $data['height'] = $image->images[0]->height; } else { $data['url'] = $data['thumbUrl']; $data['thumbUrl'] = null; unset($data['thumbUrl']); } } if ($download_link != 'no') { $data['download'] = esc_attr(stripslashes('<a href="' . plugins_url('download.php', __FILE__) . '?file=' . urlencode(!empty($image->images[0]->source) ? $image->images[0]->source : $data['url']) . '">' . __($download_link_text, 'jig_td') . '</a>')); } if ($this->settings['image_custom_classes'] !== 'nothing') { $data['extra_class'] = 'jig-contentID-FB-' . $image->id; } array_push($this->images, $data); // Add to the main images array } // If you want to show the facebook album description then the album needs to be retrieved from FB if (($facebook_description == 'yes' || $facebook_description == 'above') && empty($facebook_description_displayed_already)) { $facebook_album_url = "https://graph.facebook.com/v2.4/" . $facebook_album . "?fields=description" . '&access_token=' . $token; if ($facebook_caching > 0) { if (get_transient('jigfb_' . md5($facebook_album_url . $facebook_caching)) == true) { $facebook_album_rsp = get_transient('jigfb_' . md5($facebook_album_url . $facebook_caching)); } else { $facebook_album_rsp = json_decode($this->file_get_contents_curl($facebook_album_url)); set_transient('jigfb_' . md5($facebook_album_url . $facebook_caching), $facebook_album_rsp, 60 * $facebook_caching); } } else { $facebook_album_rsp = json_decode($this->file_get_contents_curl($facebook_album_url)); } if (!empty($facebook_album_rsp->description)) { if (strpos($facebook_album_rsp->description, '@') === false) { $notice_before .= '<p class="jig-fbDescription">' . $facebook_album_rsp->description . '</p>'; } else { $notice_before .= '<p class="jig-fbDescription">' . preg_replace('/@\\[[:\\d]+:(.+?)\\]/im', '$1', $facebook_album_rsp->description) . '</p>'; } } } } else { return $this->frontend_stop(__('The requested album cannot be loaded at this time.', 'jig_td') . ($photos['message'] ? ' ' . $photos['message'] : '')); } } break; case 'flickr': if ($limit === '0') { $limit_parameter = "&per_page=500"; } else { if ($limit !== '') { $limit_parameter = "&per_page=" . $limit; } else { $limit_parameter = "&per_page=25"; } } if ($flickr_collection !== '') { global $wp, $query_string, $wp_rewrite, $wp_query; // Everything related to the collection mode $collection_var = get_query_var($this->settings['flickr_collections_slug']); if (!empty($collection_var)) { $collection_vars = explode('/', $collection_var); foreach ($collection_vars as $collection_path_element_index => $collection_path_element) { if (strlen($collection_path_element) > 21) { // If it's a collection ID $flickr_collection_ids[] = $collection_path_element; } else { $flickr_photoset = $collection_path_element; } } } if ($flickr_collection !== 'complete-overview') { $collections_url = 'https://api.flickr.com/services/rest?api_key=' . trim($this->settings['fli_api_key']) . '&format=php_serial&method=flickr.collections.getTree&collection_id=' . $flickr_collection . '&user_id=' . $flickr_user; } else { $collections_url = 'https://api.flickr.com/services/rest?api_key=' . trim($this->settings['fli_api_key']) . '&format=php_serial&method=flickr.collections.getTree&user_id=' . $flickr_user; } if ($flickr_caching > 0) { if (get_transient('jigfli_' . md5($collections_url . $flickr_caching)) == true) { $collections_raw = get_transient('jigfli_' . md5($collections_url . $flickr_caching)); } else { $collections_raw = maybe_unserialize($this->file_get_contents_curl($collections_url)); set_transient('jigfli_' . md5($collections_url . $flickr_caching), $collections_raw, 60 * $flickr_caching); } } else { $collections_raw = maybe_unserialize($this->file_get_contents_curl($collections_url)); } if (!empty($collections_raw) && $collections_raw['stat'] == 'ok') { $collections = $this->flickr_parse_collection($collections_raw['collections']); if ($flickr_collection == 'complete-overview') { $collections['complete-overview'] = $collections_raw['collections']; $collections['complete-overview']['title'] = 'Overview'; if (!empty($this->settings['fli_added'])) { foreach ($this->settings['fli_added'] as $single_flickr_user) { if ($single_flickr_user['user_id'] == $flickr_user) { $collections['complete-overview']['title'] = $single_flickr_user['user_name']; break; } } } } // Disallow showing a set if the shortcode flickr user ID does not have it, and fall back to what the shortcode would show by default - this allows multiple JIG instsances with Flickr collections AND does some security by disallowing foreign set IDs if (!empty($flickr_photoset) && empty($collections[$flickr_photoset])) { $flickr_photoset = ''; $collection_var = false; } if (!empty($flickr_collection_ids)) { $found_flickr_collection_id = false; foreach ($flickr_collection_ids as $flickr_collection_id) { if (!empty($collections[$flickr_collection_id])) { $found_flickr_collection_id = true; } } if ($found_flickr_collection_id == false) { $flickr_collection_ids = false; $collection_var = false; } } $flickr_set_list_needed = false; foreach ($collections as $collection_id => $collection_value) { if (strlen($collection_id) < 21) { $flickr_set_list_needed = true; break; } } if ($flickr_set_list_needed === true) { $flickr_set_list_url = 'https://api.flickr.com/services/rest?api_key=' . trim($this->settings['fli_api_key']) . '&format=php_serial&method=flickr.photosets.getList&user_id=' . $flickr_user . '&per_page=500&primary_photo_extras=description,url_o,url_k,url_h,url_l,url_c,url_z,url_m,url_n,url_s,url_t'; if ($flickr_caching > 0) { if (get_transient('jigfli_' . md5($flickr_set_list_url . $flickr_caching)) == true) { $flickr_set_list = get_transient('jigfli_' . md5($flickr_set_list_url . $flickr_caching)); } else { $flickr_set_list = maybe_unserialize($this->file_get_contents_curl($flickr_set_list_url)); set_transient('jigfli_' . md5($flickr_set_list_url . $flickr_caching), $flickr_set_list, 60 * $flickr_caching); } } else { $flickr_set_list = maybe_unserialize($this->file_get_contents_curl($flickr_set_list_url)); } if (!empty($flickr_set_list) && $flickr_set_list['stat'] == 'ok') { $flickr_set_list = $flickr_set_list['photosets']['photoset']; foreach ($flickr_set_list as $key => $value) { $flickr_set_list_mod[$value['id']] = $value; } $flickr_set_list = $flickr_set_list_mod; unset($flickr_set_list_mod); } } if ($flickr_breadcrumb == 'yes' && !empty($collection_var)) { $flickr_home_permalink = home_url(add_query_arg(array(), $wp->request)); $slug_position = strripos($flickr_home_permalink, $this->settings['flickr_collections_slug']); if ($slug_position !== false) { $flickr_home_permalink = substr($flickr_home_permalink, 0, $slug_position); } if (substr($flickr_home_permalink, -1) != '/') { $flickr_home_permalink .= '/'; } if ($flickr_home_permalink == home_url('/') && strlen($query_string) > 0 && strpos($query_string, $this->settings['flickr_collections_slug']) !== false) { $flickr_home_permalink .= '?' . remove_query_arg($this->settings['flickr_collections_slug'], $query_string); } switch ($flickr_bc_separator) { case 'default': $flickr_bc_separator = ' »'; break; case 'greater': $flickr_bc_separator = ' >'; break; case 'comma': $flickr_bc_separator = ','; break; case 'slash': $flickr_bc_separator = ' /'; break; case 'doubleslash': $flickr_bc_separator = ' //'; break; case 'minus': $flickr_bc_separator = ' -'; break; case 'plus': $flickr_bc_separator = ' +'; break; case 'arrow': $flickr_bc_separator = ' →'; break; case 'bslash': $flickr_bc_separator = ' \\'; break; case 'doublebslash': $flickr_bc_separator = ' \\\\'; break; case 'middledot': $flickr_bc_separator = ' ·'; break; case 'dobulecolon': $flickr_bc_separator = ' ::'; break; case 'numbersign': $flickr_bc_separator = ' #'; break; } $flickr_breadcrumb_inner = ''; if (!empty($flickr_collection_ids)) { foreach ($flickr_collection_ids as $flickr_collection_id_index => $flickr_collection_id) { if ($flickr_collection_id !== end($flickr_collection_ids) || !empty($flickr_photoset)) { $show_on_front = get_option('show_on_front'); $page_on_front = get_option('page_on_front'); $args[$this->settings['flickr_collections_slug']] = implode('/', array_slice($flickr_collection_ids, 0, $flickr_collection_id_index + 1)); if ($wp_rewrite->using_permalinks()) { if (is_singular()) { $post =& get_post(get_the_ID()); $url = trailingslashit(get_permalink($post->ID)); if ($show_on_front == 'page' && $page_on_front == get_the_ID()) { $url = trailingslashit(home_url($post->page_name ? $post->page_name : $post->post_name)); } } else { $url = 'http' . (is_ssl() ? 's' : '') . '://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; } $url .= $this->settings['flickr_collections_slug'] . '/' . $args[$this->settings['flickr_collections_slug']]; } else { if (is_home()) { $args['pageid'] = get_the_ID(); } if ($show_on_front == 'page' && $page_on_front == get_the_ID()) { $args['page_id'] = get_the_ID(); } if (is_singular()) { $url = htmlspecialchars(add_query_arg($args, get_permalink(get_the_ID()))); } else { $url = htmlspecialchars(add_query_arg($args)); } } $flickr_breadcrumb_inner .= $flickr_bc_separator . ' <a href="' . esc_url($url) . '">'; $flickr_breadcrumb_inner .= $collections[$flickr_collection_id]['title'] . '</a>'; } else { $flickr_breadcrumb_inner .= $flickr_bc_separator . ' ' . $collections[$flickr_collection_id]['title']; } } } if (!empty($flickr_photoset)) { $flickr_breadcrumb_inner .= $flickr_bc_separator . ' ' . esc_attr(stripslashes($flickr_set_list[$flickr_photoset]['title']['_content'])); } $notice_before .= '<div class="jig-flickrBreadcrumb"><a href="' . esc_url($flickr_home_permalink) . '">' . ($flickr_bc_home_text === '' ? $collections[$flickr_collection]['title'] : $flickr_bc_home_text) . '</a> ' . $flickr_breadcrumb_inner . '</div>'; $flickr_bc_CSS_needed = true; } } if (empty($flickr_photoset)) { // display a collection $flickr_collection = !empty($flickr_collection_ids) ? end($flickr_collection_ids) : $flickr_collection; if (($flickr_description == 'yes' || $flickr_description == 'above') && !empty($collections[$flickr_collection]['description'])) { $notice_before .= '<p class="jig-fliDescription">' . $collections[$flickr_collection]['description'] . '</p>'; } } // otherwise display a photoset if ($flickr_photoset === '' && (!empty($collections[$flickr_collection]['set']) && count($collections[$flickr_collection]['set']) > 0 || !empty($collections[$flickr_collection]['collection']) && count($collections[$flickr_collection]['collection']) > 0)) { $this->images = array(); // Create a new array for the images if (!empty($collections[$flickr_collection]['set']) && count($collections[$flickr_collection]['set']) > 0) { // If the collection only includes sets if ($retina_ready == 'yes') { $calculated_max_height = $max_height * 3; } else { $calculated_max_height = $max_height; } foreach ($collections[$flickr_collection]['set'] as $single_set) { $single_set = $flickr_set_list[$single_set['id']]; $photo = $single_set['primary_photo_extras']; $data = array(); // Create a new array for this image if (isset($photo['height_t']) && $photo['height_t'] >= $calculated_max_height) { $data['thumbUrl'] = $photo['url_t']; } elseif (isset($photo['height_s']) && $photo['height_s'] >= $calculated_max_height) { $data['thumbUrl'] = $photo['url_s']; } elseif (isset($photo['height_n']) && $photo['height_n'] >= $calculated_max_height) { $data['thumbUrl'] = $photo['url_n']; } elseif (isset($photo['height_m']) && $photo['height_m'] >= $calculated_max_height) { $data['thumbUrl'] = $photo['url_m']; } elseif (isset($photo['height_z']) && $photo['height_z'] >= $calculated_max_height) { $data['thumbUrl'] = $photo['url_z']; } elseif (isset($photo['height_c']) && $photo['height_c'] >= $calculated_max_height) { $data['thumbUrl'] = $photo['url_c']; } elseif (isset($photo['height_l']) && $photo['height_l'] >= $calculated_max_height) { $data['thumbUrl'] = $photo['url_l']; } elseif (isset($photo['height_h']) && $photo['height_h'] >= $calculated_max_height) { $data['thumbUrl'] = $photo['url_h']; } elseif (isset($photo['height_k']) && $photo['height_k'] >= $calculated_max_height) { $data['thumbUrl'] = $photo['url_k']; } else { if ($this->settings['flickr_too_small_images'] !== 'upscale') { continue; } else { $flickr_upscale_this = true; } } if ($this->settings['flickr_allow_big_images'] === 'original' && isset($photo['url_o'])) { $data['url'] = $photo['url_o']; $data['width'] = $photo['width_o']; $data['height'] = $photo['height_o']; } elseif ($this->settings['flickr_allow_big_images'] !== 'no' && isset($photo['url_k'])) { $data['url'] = $photo['url_k']; $data['width'] = $photo['width_k']; $data['height'] = $photo['height_k']; } elseif ($this->settings['flickr_allow_big_images'] !== 'no' && isset($photo['url_h'])) { $data['url'] = $photo['url_h']; $data['width'] = $photo['width_h']; $data['height'] = $photo['height_h']; } elseif (isset($photo['url_l'])) { $data['url'] = $photo['url_l']; $data['width'] = $photo['width_l']; $data['height'] = $photo['height_l']; } elseif (isset($photo['url_c'])) { $data['url'] = $photo['url_c']; $data['width'] = $photo['width_c']; $data['height'] = $photo['height_c']; } elseif (isset($photo['url_z'])) { $data['url'] = $photo['url_z']; $data['width'] = $photo['width_z']; $data['height'] = $photo['height_z']; } elseif (isset($photo['url_m'])) { $data['url'] = $photo['url_m']; $data['width'] = $photo['width_m']; $data['height'] = $photo['height_m']; } elseif (isset($photo['url_n'])) { $data['url'] = $photo['url_n']; $data['width'] = $photo['width_n']; $data['height'] = $photo['height_n']; } elseif (isset($photo['url_s'])) { $data['url'] = $photo['url_s']; $data['width'] = $photo['width_s']; $data['height'] = $photo['height_s']; } elseif (isset($photo['url_t'])) { $data['url'] = $photo['url_t']; $data['width'] = $photo['width_t']; $data['height'] = $photo['height_t']; } else { unset($flickr_upscale_this); continue; } if (isset($flickr_upscale_this)) { unset($flickr_upscale_this); $flickr_upscale_key = array_search($data['url'], $photo, true); if ($flickr_upscale_key !== false) { $flickr_upscale_key = substr($flickr_upscale_key, -1); $data['width'] = $photo['width_' . $flickr_upscale_key]; $data['height'] = $photo['height_' . $flickr_upscale_key]; } else { continue; } } if (!empty($single_set['title']['_content'])) { $data['title'] = esc_attr(stripslashes($single_set['title']['_content'])); } if ($flickr_count == 'yes') { $description_fragments = array($single_set['photos'] . ' ' . _n('Photo', 'Photos', $single_set['photos'], 'jig_td')); if (($flickr_description == 'yes' || $flickr_description == 'thumbnails') && !empty($single_set['description']['_content'])) { $description_fragments[] = esc_attr(stripslashes($single_set['description']['_content'])); } $d['description'] = esc_attr(stripslashes(implode('<br />', $description_fragments))); } else { if (($flickr_description == 'yes' || $flickr_description == 'thumbnails') && !empty($single_set['description']['_content'])) { $d['description'] = esc_attr(stripslashes($single_set['description']['_content'])); } } if ($d['description'] != '') { $data['description'] = $d['description']; } $data['link'] = $single_set['id']; if ($this->settings['image_custom_classes'] !== 'nothing') { $data['extra_class'] = 'jig-contentID-FL-' . $single_set['primary']; } if ($flickr_lightbox_set == 'yes') { // If gallery should be displayed as a lightbox $shadow_galleries[] = $shadow_group_id = "jig{$jig_id}-hiddenGalleryGroup-" . $single_set['id']; $shadow_gallery = '<div class="jig-hiddenGallery">'; if (stripos($link_rel, '*instance*') !== false) { $shadow_rel = str_replace('*instance*', 'FL-' . $single_set['id'], $link_rel); } else { switch ($lightbox) { case 'prettyphoto': $shadow_rel = 'prettyPhoto[fli-' . $single_set['id'] . ']'; break; case 'colorbox': $shadow_rel = 'colorBox[fli-' . $single_set['id'] . ']'; break; case 'foobox': $shadow_rel = 'foobox[fli-' . $single_set['id'] . ']'; break; default: $shadow_rel = 'jig[fli-' . $single_set['id'] . ']'; break; } } $photoset_url = 'https://api.flickr.com/services/rest?api_key=' . trim($this->settings['fli_api_key']) . '&format=php_serial&method=flickr.photosets.getPhotos&photoset_id=' . $single_set['id'] . $limit_parameter . '&extras=description,tags,geo,url_o,url_k,url_h,url_l,url_c,url_z,url_m,url_n,url_s,url_t'; if ($flickr_caching > 0) { if (get_transient('jigfli_' . md5($photoset_url . $flickr_caching)) == true) { $single_photoset = get_transient('jigfli_' . md5($photoset_url . $flickr_caching)); } else { $single_photoset = maybe_unserialize($this->file_get_contents_curl($photoset_url)); set_transient('jigfli_' . md5($photoset_url . $flickr_caching), $single_photoset, 60 * $flickr_caching); } } else { $single_photoset = maybe_unserialize($this->file_get_contents_curl($photoset_url)); } if (!empty($single_photoset) && $single_photoset['stat'] == "ok") { foreach ($single_photoset['photoset']['photo'] as $shadow_photo) { // Skip image from the hidden gallery if it's the same as the opener image if ($shadow_photo['id'] == $single_set['primary']) { // These show up as captions on the thumbnail that launches the lightbox gallery if (isset($data['title'])) { $data['gallery']['title'] = $data['title']; } if (isset($data['description'])) { $data['gallery']['description'] = $data['description']; } unset($data['title'], $data['description']); // Have to set the image's own title and desc, once opened in the lightbox if (isset($shadow_photo['title'])) { $data['title'] = esc_attr(stripslashes($shadow_photo['title'])); } if (isset($shadow_photo['description']['_content'])) { $data['description'] = esc_attr(stripslashes($shadow_photo['description']['_content'])); } if ($download_link != 'no') { $data['download'] = esc_attr(stripslashes('<a href="' . plugins_url('download.php', __FILE__) . '?file=' . urlencode($data['url']) . '">' . __($download_link_text, 'jig_td') . '</a>')); } if ($flickr_link != 'no') { $data['lightbox_link'] = esc_attr(stripslashes('<a href="http://www.flickr.com/photos/' . $flickr_user . '/' . $shadow_photo['id'] . '" target="' . $this->settings['flickr_link_target'] . '">' . __($flickr_link_text, 'jig_td') . '</a>')); } // And don't create the opener picture again in the shadow gallery continue; } $shadow_data = $sd = array(); // Create 2 arrays for this image one temporary and one that gets pushed $shadow_size = ''; if ($this->settings['flickr_allow_big_images'] === 'original' && isset($shadow_photo['url_o'])) { $shadow_data['url'] = $shadow_photo['url_o']; $shadow_data['width'] = $shadow_photo['width_o']; $shadow_data['height'] = $shadow_photo['height_o']; } elseif ($this->settings['flickr_allow_big_images'] !== 'no' && isset($shadow_photo['url_k'])) { $shadow_data['url'] = $shadow_photo['url_k']; $shadow_data['width'] = $shadow_photo['width_k']; $shadow_data['height'] = $shadow_photo['height_k']; } elseif ($this->settings['flickr_allow_big_images'] !== 'no' && isset($shadow_photo['url_h'])) { $shadow_data['url'] = $shadow_photo['url_h']; $shadow_data['width'] = $shadow_photo['width_h']; $shadow_data['height'] = $shadow_photo['height_h']; } elseif (isset($shadow_photo['url_l'])) { $shadow_data['url'] = $shadow_photo['url_l']; $shadow_data['width'] = $shadow_photo['width_l']; $shadow_data['height'] = $shadow_photo['height_l']; } elseif (isset($shadow_photo['url_c'])) { $shadow_data['url'] = $shadow_photo['url_c']; $shadow_data['width'] = $shadow_photo['width_c']; $shadow_data['height'] = $shadow_photo['height_c']; } elseif (isset($shadow_photo['url_z'])) { $shadow_data['url'] = $shadow_photo['url_z']; $shadow_data['width'] = $shadow_photo['width_z']; $shadow_data['height'] = $shadow_photo['height_z']; } elseif (isset($shadow_photo['url_m'])) { $shadow_data['url'] = $shadow_photo['url_m']; $shadow_data['width'] = $shadow_photo['width_m']; $shadow_data['height'] = $shadow_photo['height_m']; } elseif (isset($shadow_photo['url_n'])) { $shadow_data['url'] = $shadow_photo['url_n']; $shadow_data['width'] = $shadow_photo['width_n']; $shadow_data['height'] = $shadow_photo['height_n']; } elseif (isset($shadow_photo['url_s'])) { $shadow_data['url'] = $shadow_photo['url_s']; $shadow_data['width'] = $shadow_photo['width_s']; $shadow_data['height'] = $shadow_photo['height_s']; } elseif (isset($shadow_photo['url_t'])) { $shadow_data['url'] = $shadow_photo['url_t']; $shadow_data['width'] = $shadow_photo['width_t']; $shadow_data['height'] = $shadow_photo['height_t']; } else { continue; } if ($lightbox == 'photoswipe') { $shadow_size = ' data-wh="' . $shadow_data['width'] . 'x' . $shadow_data['height'] . '"'; } if (isset($shadow_photo['title'])) { $sd['title'] = esc_attr(stripslashes($shadow_photo['title'])); } if (isset($shadow_photo['description']['_content'])) { $sd['description'] = esc_attr(stripslashes($shadow_photo['description']['_content'])); } $title_fragment = isset($sd[$link_title_field]) ? trim($sd[$link_title_field]) : ''; $alt_fragment = isset($sd[$img_alt_field]) ? trim($sd[$img_alt_field]) : ''; if ($download_link != 'no') { $shadow_data['download'] = esc_attr(stripslashes('<a href="' . plugins_url('download.php', __FILE__) . '?file=' . urlencode($shadow_data['url']) . '">' . __($download_link_text, 'jig_td') . '</a>')); if ($download_link == 'yes') { if ($title_fragment !== '') { $title_fragment .= $separator_character . $shadow_data['download']; } else { $title_fragment = $shadow_data['download']; } } else { if ($alt_fragment !== '') { $alt_fragment .= $separator_character . $shadow_data['download']; } else { $alt_fragment = $shadow_data['download']; } } } if ($flickr_link != 'no') { $shadow_data['lightbox_link'] = esc_attr(stripslashes('<a href="http://www.flickr.com/photos/' . $flickr_user . '/' . $shadow_photo['id'] . '" target="' . $this->settings['flickr_link_target'] . '">' . __($flickr_link_text, 'jig_td') . '</a>')); if ($flickr_link == 'yes') { if ($title_fragment !== '') { $title_fragment .= $separator_character . $shadow_data['lightbox_link']; } else { $title_fragment = $shadow_data['lightbox_link']; } } else { if ($alt_fragment !== '') { $alt_fragment .= $separator_character . $shadow_data['lightbox_link']; } else { $alt_fragment = $shadow_data['lightbox_link']; } } } $shadow_class = 'class="jig-link jig-contentID-FB-' . $shadow_photo['id'] . (empty($link_class) ? '' : ' ' . $link_class) . '" '; $shadow_gallery .= '<a href="' . $shadow_data['url'] . '" rel="' . $shadow_rel . '" ' . $shadow_class . $shadow_size . ' title="' . $title_fragment . '"><img src="data:image/gif;base64,R0lGODlhAQABAPABAP///wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw%3D%3D" alt="' . $alt_fragment . '" /></a>'; } if (empty($data['gallery'])) { if (isset($data['title'])) { $data['gallery']['title'] = $data['title']; } if (isset($data['description'])) { $data['gallery']['description'] = $data['description']; } unset($data['title'], $data['description']); // Sadly Flickr doesn't provide the title as part of the the primary image's extras if (isset($data['gallery']['title'])) { $data['title'] = esc_attr(stripslashes($data['gallery']['title'])); } if (isset($photo['description']['_content'])) { $data['description'] = esc_attr(stripslashes($photo['description']['_content'])); } if ($download_link != 'no') { $data['download'] = esc_attr(stripslashes('<a href="' . plugins_url('download.php', __FILE__) . '?file=' . urlencode($data['url']) . '">' . __($download_link_text, 'jig_td') . '</a>')); } if ($flickr_link != 'no') { $data['lightbox_link'] = esc_attr(stripslashes('<a href="http://www.flickr.com/photos/' . $flickr_user . '/' . $single_set['primary'] . '" target="' . $this->settings['flickr_link_target'] . '">' . __($flickr_link_text, 'jig_td') . '</a>')); } } } $shadow_gallery .= "</div>"; unset($data['link']); $data['gallery']['html'] = $shadow_gallery; $data['gallery']['rel'] = $shadow_rel; $data['gallery']['id'] = $shadow_group_id; switch ($lightbox) { case 'foobox': $data['gallery']['lightbox_class'] = 'jigFooBoxConnect'; break; case 'socialgallery': $data['gallery']['lightbox_class'] = 'jigSgConnect'; break; default: } } array_push($this->images, $data); } } elseif (!empty($collections[$flickr_collection]['collection']) && count($collections[$flickr_collection]['collection']) > 0) { // If the collection only includes subcollections // some overwrites due to the very small size of the Flickr collection icons :( $row_height = $max_height = 134; $height_deviation = 0; $disable_cropping = 'yes'; $aspect_ratio = ''; $retina_ready = 'no'; $use_timthumb = 'no'; foreach ($collections[$flickr_collection]['collection'] as $single_collection) { $data['url'] = substr($single_collection['iconlarge'], 0, 1) !== '/' ? $single_collection['iconlarge'] : 'http://www.flickr.com/images/collection_default_l.gif'; $data['width'] = 179; $data['height'] = 134; if (!empty($single_collection['title'])) { $data['title'] = esc_attr(stripslashes($single_collection['title'])); } if ($flickr_count == 'yes') { $description_fragments = array(); if (!empty($single_collection['set']) && count($single_collection['set']) > 0) { $description_fragments[] = count($single_collection['set']) . ' ' . _n('Album', 'Albums', count($single_collection['set']), 'jig_td'); } elseif (count($single_collection['collection']) > 0) { $description_fragments[] = count($single_collection['collection']) . ' ' . _n('Collection', 'Collections', count($single_collection['collection']), 'jig_td'); } if (($flickr_description == 'yes' || $flickr_description == 'thumbnails') && !empty($single_collection['description'])) { $description_fragments[] = esc_attr(stripslashes($single_collection['description'])); } $d['description'] = esc_attr(stripslashes(implode('<br />', $description_fragments))); } else { if (($flickr_description == 'yes' || $flickr_description == 'thumbnails') && !empty($single_collection['description'])) { $d['description'] = esc_attr(stripslashes($single_collection['description'])); } } if ($d['description'] != '') { $data['description'] = $d['description']; } $data['link'] = $single_collection['id']; array_push($this->images, $data); } } // Setting the proper links foreach ($this->images as $image_index => &$data) { if (!isset($data['link'])) { // Permalink is not needed when sets are opened in the lightbox continue; } $show_on_front = get_option('show_on_front'); $page_on_front = get_option('page_on_front'); $args[$this->settings['flickr_collections_slug']] = (!empty($collection_var) ? $collection_var . '/' : '') . $data['link']; if ($wp_rewrite->using_permalinks()) { if (is_singular()) { $post = get_post(get_the_ID()); $url = trailingslashit(get_permalink($post->ID)); if ($show_on_front == 'page' && $page_on_front == get_the_ID()) { $url = trailingslashit(home_url($post->page_name ? $post->page_name : $post->post_name)); } } else { $url = 'http' . (is_ssl() ? 's' : '') . '://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; } $url .= $this->settings['flickr_collections_slug'] . '/' . $args[$this->settings['flickr_collections_slug']]; $data['link'] = $url; } else { if (is_home()) { $args['pageid'] = get_the_ID(); } if ($show_on_front == 'page' && $page_on_front == get_the_ID()) { $args['page_id'] = get_the_ID(); } if (is_singular()) { $query = htmlspecialchars(add_query_arg($args, get_permalink(get_the_ID()))); } else { $query = htmlspecialchars(add_query_arg($args)); } $data['link'] = esc_url($query); } } unset($image_index, $data); break; } } if ($flickr_photostream !== '') { $photos_url_bit = 'flickr.people.getPublicPhotos&user_id=' . $flickr_photostream; } elseif ($flickr_favorites !== '') { $photos_url_bit = 'flickr.favorites.getPublicList&user_id=' . $flickr_favorites; } elseif ($flickr_group !== '') { $photos_url_bit = 'flickr.groups.pools.getPhotos&group_id=' . $flickr_group; } elseif ($flickr_photoset !== '') { $photos_url_bit = 'flickr.photosets.getPhotos&photoset_id=' . $flickr_photoset; } elseif ($flickr_gallery !== '') { $photos_url_bit = 'flickr.galleries.getPhotos&gallery_id=' . $flickr_gallery; } elseif ($flickr_search_text !== '' || $flickr_search_tags !== '') { $photos_url_bit = 'flickr.photos.search&content_type=1'; if ($flickr_search_text !== '') { $photos_url_bit .= '&text=' . urlencode($flickr_search_text); } if ($flickr_search_tags !== '') { $photos_url_bit .= '&tags=' . urlencode($flickr_search_tags); } if ($flickr_search_tags_m !== '') { $photos_url_bit .= '&tag_mode=' . $flickr_search_tags_m; } if ($flickr_search_user !== '') { $photos_url_bit .= '&user_id=' . $flickr_search_user; } if ($flickr_search_group !== '') { $photos_url_bit .= '&group_id=' . $flickr_search_group; } if ($flickr_search_sort !== 'date-posted-desc') { $photos_url_bit .= '&sort=' . $flickr_search_sort; } if ($flickr_search_license !== '') { $photos_url_bit .= '&license=' . $flickr_search_license; } if ($flickr_search_geo !== '') { $photos_url_bit .= '&has_geo=' . $flickr_search_geo; } } $photos_url = 'https://api.flickr.com/services/rest?api_key=' . trim($this->settings['fli_api_key']) . '&format=php_serial&method=' . $photos_url_bit . $limit_parameter . '&extras=description,tags,geo,url_o,url_k,url_h,url_l,url_c,url_z,url_m,url_n,url_s,url_t'; if ($flickr_caching > 0) { if (get_transient('jigfli_' . md5($photos_url . $flickr_caching)) == true) { $photos = get_transient('jigfli_' . md5($photos_url . $flickr_caching)); } else { $photos = maybe_unserialize($this->file_get_contents_curl($photos_url)); set_transient('jigfli_' . md5($photos_url . $flickr_caching), $photos, 60 * $flickr_caching); } } else { $photos = maybe_unserialize($this->file_get_contents_curl($photos_url)); } if (!empty($photos) && $photos['stat'] == "ok") { if ($retina_ready == 'yes') { $calculated_max_height = $max_height * 3; } else { $calculated_max_height = $max_height; } $this->images = array(); // Create a new array for the images if (isset($photos['photos']) && count($photos['photos']['photo']) > 0 || isset($photos['photoset']) && count($photos['photoset']['photo'])) { // Make photoset mimic the other sources if (isset($photos['photoset'])) { $photos['photos'] = $photos['photoset']; } if ($orderby == 'rand') { $photos['photos']['photo'] = (array) $photos['photos']['photo']; shuffle($photos['photos']['photo']); } //$too_small_flickr_images = 0; foreach ($photos['photos']['photo'] as $photo) { $data = array(); // Create a new array for this image if (!empty($photo['longitude']) && !empty($photo['latitude']) && !empty($photo['accuracy'])) { $data['geo'] = $photo['latitude'] . ',' . $photo['longitude'] . ',' . $photo['accuracy']; } if (isset($photo['height_t']) && $photo['height_t'] >= $calculated_max_height) { $data['thumbUrl'] = $photo['url_t']; } elseif (isset($photo['height_s']) && $photo['height_s'] >= $calculated_max_height) { $data['thumbUrl'] = $photo['url_s']; } elseif (isset($photo['height_n']) && $photo['height_n'] >= $calculated_max_height) { $data['thumbUrl'] = $photo['url_n']; } elseif (isset($photo['height_m']) && $photo['height_m'] >= $calculated_max_height) { $data['thumbUrl'] = $photo['url_m']; } elseif (isset($photo['height_z']) && $photo['height_z'] >= $calculated_max_height) { $data['thumbUrl'] = $photo['url_z']; } elseif (isset($photo['height_c']) && $photo['height_c'] >= $calculated_max_height) { $data['thumbUrl'] = $photo['url_c']; } elseif (isset($photo['height_l']) && $photo['height_l'] >= $calculated_max_height) { $data['thumbUrl'] = $photo['url_l']; } elseif (isset($photo['height_h']) && $photo['height_h'] >= $calculated_max_height) { $data['thumbUrl'] = $photo['url_h']; } elseif (isset($photo['height_k']) && $photo['height_k'] >= $calculated_max_height) { $data['thumbUrl'] = $photo['url_k']; } else { //$too_small_flickr_images++; if ($this->settings['flickr_too_small_images'] !== 'upscale') { continue; } else { //$randomize_width = 0; $flickr_upscale_this = true; } } if ($this->settings['flickr_allow_big_images'] === 'original' && isset($photo['url_o'])) { $data['url'] = $photo['url_o']; $data['width'] = $photo['width_o']; $data['height'] = $photo['height_o']; } elseif ($this->settings['flickr_allow_big_images'] !== 'no' && isset($photo['url_k'])) { $data['url'] = $photo['url_k']; $data['width'] = $photo['width_k']; $data['height'] = $photo['height_k']; } elseif ($this->settings['flickr_allow_big_images'] !== 'no' && isset($photo['url_h'])) { $data['url'] = $photo['url_h']; $data['width'] = $photo['width_h']; $data['height'] = $photo['height_h']; } elseif (isset($photo['url_l'])) { $data['url'] = $photo['url_l']; $data['width'] = $photo['width_l']; $data['height'] = $photo['height_l']; } elseif (isset($photo['url_c'])) { $data['url'] = $photo['url_c']; $data['width'] = $photo['width_c']; $data['height'] = $photo['height_c']; } elseif (isset($photo['url_z'])) { $data['url'] = $photo['url_z']; $data['width'] = $photo['width_z']; $data['height'] = $photo['height_z']; } elseif (isset($photo['url_m'])) { $data['url'] = $photo['url_m']; $data['width'] = $photo['width_m']; $data['height'] = $photo['height_m']; } elseif (isset($photo['url_n'])) { $data['url'] = $photo['url_n']; $data['width'] = $photo['width_n']; $data['height'] = $photo['height_n']; } elseif (isset($photo['url_s'])) { $data['url'] = $photo['url_s']; $data['width'] = $photo['width_s']; $data['height'] = $photo['height_s']; } elseif (isset($photo['url_t'])) { $data['url'] = $photo['url_t']; $data['width'] = $photo['width_t']; $data['height'] = $photo['height_t']; } else { unset($flickr_upscale_this); continue; } if (isset($flickr_upscale_this)) { unset($flickr_upscale_this); $flickr_upscale_key = array_search($data['url'], $photo, true); if ($flickr_upscale_key !== false) { $flickr_upscale_key = substr($flickr_upscale_key, -1); $data['width'] = $photo['width_' . $flickr_upscale_key]; $data['height'] = $photo['height_' . $flickr_upscale_key]; } else { continue; } } if (!empty($photo['title'])) { $d['title'] = esc_attr(stripslashes(trim($photo['title']))); if ($d['title'] != '') { $data['title'] = $d['title']; } } if (!empty($photo['description']['_content'])) { $d['description'] = esc_attr(stripslashes(trim($photo['description']['_content']))); if ($d['description'] != '') { $data['description'] = $d['description']; } } if ($download_link != 'no') { $data['download'] = esc_attr(stripslashes('<a href="' . plugins_url('download.php', __FILE__) . '?file=' . urlencode($data['url']) . '">' . __($download_link_text, 'jig_td') . '</a>')); } if ($flickr_link != 'no') { $data['lightbox_link'] = esc_attr(stripslashes('<a href="http://www.flickr.com/photos/' . (!empty($photo['owner']) ? $photo['owner'] : $flickr_user) . '/' . $photo['id'] . '" target="' . $this->settings['flickr_link_target'] . '">' . __($flickr_link_text, 'jig_td') . '</a>')); } if ($flickr_link != 'no') { if ($flickr_link != 'direct') { $data['lightbox_link'] = esc_attr(stripslashes('<a href="http://www.flickr.com/photos/' . (!empty($photo['owner']) ? $photo['owner'] : $flickr_user) . '/' . $photo['id'] . '" target="' . $this->settings['flickr_link_target'] . '">' . __($flickr_link_text, 'jig_td') . '</a>')); } else { $data['link'] = 'http://www.flickr.com/photos/' . (!empty($photo['owner']) ? $photo['owner'] : $flickr_user) . '/' . $photo['id']; $data['link_target'] = $this->settings['flickr_link_target']; } } if ($filterby == 'on') { $d['filters'] = $photo['tags']; if (!empty($d['filters'])) { $d['filters'] = explode(' ', $d['filters']); foreach ($d['filters'] as $filter_term) { if (strstr($filter_term, ':') === false) { $data['filters'][] = array($filter_term, ucfirst($filter_term)); } } } } if ($this->settings['image_custom_classes'] !== 'nothing') { $data['extra_class'] = 'jig-contentID-FL-' . $photo['id']; } array_push($this->images, $data); } if ($flickr_photoset !== '' && !empty($flickr_set_list) && !empty($this->images) && $flickr_description == 'yes') { if (($flickr_description == 'yes' || $flickr_description == 'above') && !empty($flickr_set_list[$flickr_photoset]['description']['_content'])) { $notice_before .= '<p class="jig-fliDescription">' . $flickr_set_list[$flickr_photoset]['description']['_content'] . '</p>'; } } /* if($too_small_flickr_images !== 0 && $this->settings['flickr_too_small_images'] == 'error'){ $notice_after .= sprintf(__('Justified Image Grid: %d Flickr images are not shown because they are too small. Decrease row_height and height_deviation until all your photos show up. Tip: Start with a combined value of no larger than 200. Your current maximum height is %d (%d row_height + %d height_deviation).', 'jig_td'),$too_small_flickr_images,$calculated_max_height,$row_height,$height_deviation); }*/ } else { if ($flickr_search_text !== '' || $flickr_search_tags !== '') { return $this->frontend_stop(__('There are no photos that match your search criteria.', 'jig_td')); } else { return $this->frontend_stop(__('The requested photo source is not recognized.', 'jig_td')); } } } else { return $this->frontend_stop(__('The requested photo source cannot be loaded at this time.', 'jig_td') . ($photos['message'] ? ' ' . $photos['message'] : '')); } break; case 'instagram': $endpoint_url = 'https://api.instagram.com/v1'; $first_valid_access_token = ''; if (!empty($this->settings['ig_authed'])) { foreach ($this->settings['ig_authed'] as $user) { $authed_user = $user['id']; $first_valid_access_token = $user['access_token']; break; } } if ($first_valid_access_token === '') { return $this->frontend_stop(__('No access token found, please authorize an Instagram user.', 'jig_td')); } if ($instagram_feed !== '') { $authed_user = $instagram_feed; $endpoint_url .= '/users/self/feed?access_token=' . $this->settings['ig_authed'][$instagram_feed]['access_token']; } elseif ($instagram_recents !== '') { $endpoint_url .= '/users/' . $instagram_recents . '/media/recent?access_token=' . $first_valid_access_token; } elseif ($instagram_liked !== '') { $endpoint_url .= '/users/self/media/liked?access_token=' . $this->settings['ig_authed'][$instagram_liked]['access_token']; $authed_user = $instagram_liked; } elseif ($instagram_tag !== '') { $endpoint_url .= '/tags/' . $instagram_tag . '/media/recent?access_token=' . $first_valid_access_token; } elseif ($instagram_location !== '') { $endpoint_url .= '/locations/' . $instagram_location . '/media/recent?access_token=' . $first_valid_access_token; } if ($limit === '0') { $endpoint_url .= "&count=100"; $limit = 100; } else { if ($limit !== '') { $endpoint_url .= "&count=" . $limit; $limit = (int) $limit; } else { $endpoint_url .= "&count=20"; $limit = 20; } } $photos = $this->instagram_api_call($endpoint_url, $instagram_caching, $limit); if ($limit !== '' && count($photos) > $limit) { $photos = array_slice($photos, 0, $limit); } $instagram_blacklist = explode(',', str_replace(', ', ',', $instagram_blacklist)); if (!isset($photos['message'])) { $this->images = array(); // Create a new array for the images if (count($photos) > 0) { if ($orderby == 'rand') { $photos = (array) $photos; shuffle($photos); } if ($retina_ready == 'yes') { $calculated_max_height = $max_height * 3; } else { $calculated_max_height = $max_height; } foreach ($photos as $photo) { if (isset($photo->images) && ($photo->type == 'image' || $photo->type == 'video')) { if ($instagram_blacklist !== '') { if (in_array($photo->user->username, $instagram_blacklist) || in_array($photo->user->id, $instagram_blacklist)) { continue; } } $data = array(); // Create a new array for this image if ($photo->type == 'image') { $data['url'] = $photo->images->standard_resolution->url; } else { $data['link'] = $photo->videos->standard_resolution->url; $data['link_target'] = 'videoplayer'; $data['url'] = $photo->images->standard_resolution->url; } if ($photo->images->thumbnail->height >= $calculated_max_height) { $data['thumbUrl'] = $photo->images->thumbnail->url; $data['width'] = $photo->images->thumbnail->width; $data['height'] = $photo->images->thumbnail->height; } elseif ($photo->images->low_resolution->height >= $calculated_max_height) { $data['thumbUrl'] = $photo->images->low_resolution->url; $data['width'] = $photo->images->low_resolution->width; $data['height'] = $photo->images->low_resolution->height; } else { $data['width'] = $photo->images->standard_resolution->width; $data['height'] = $photo->images->standard_resolution->height; } if (!empty($photo->caption->text)) { $data['title'] = esc_attr(stripslashes($photo->caption->text)); } if ($instagram_show_user == 'title') { $data['title'] = (!empty($data['title']) ? $data['title'] . $separator_character : '') . esc_attr(stripslashes('<a href="http://instagram.com/' . $photo->user->username . '" target="_blank">' . $photo->user->username . '</a>')); } elseif ($instagram_show_user == 'description') { $data['description'] = esc_attr(stripslashes('<a href="http://instagram.com/' . $photo->user->username . '" target="_blank">' . $photo->user->username . '</a>')); } if ($download_link != 'no') { $data['download'] = esc_attr(stripslashes('<a href="' . plugins_url('download.php', __FILE__) . '?file=' . urlencode($data['url']) . '">' . __($download_link_text, 'jig_td') . '</a>')); } if ($instagram_link != 'no') { if ($instagram_link != 'direct') { $data['lightbox_link'] = esc_attr(stripslashes('<a href="' . $photo->link . '" target="' . $this->settings['instagram_link_target'] . '">' . ($photo->type == 'image' ? __($instagram_link_text, 'jig_td') : str_replace(__('photo', 'jig_td'), __('video', 'jig_td'), __($instagram_link_text, 'jig_td'))) . '</a>')); } else { $data['link'] = $photo->link; $data['link_target'] = $this->settings['instagram_link_target']; } } if ($filterby == 'on' || $instagram_tag_filter) { $d['filters'] = $photo->tags; if (!empty($d['filters'])) { foreach ($d['filters'] as $filter_term) { $data['filters'][] = array($filter_term, ucfirst($filter_term)); } } } if ($this->settings['image_custom_classes'] !== 'nothing') { $data['extra_class'] = 'jig-contentID-IG-' . $photo->id; } array_push($this->images, $data); } } } else { return $this->frontend_stop(__('The requested photo source is empty.', 'jig_td')); } } else { if (isset($photos['error_type']) && $photos['error_type'] == "OAuthAccessTokenException") { if (!empty($this->settings_backup)) { // restoring the settings after a preset has changed it $this->settings = $this->settings_backup; } $this->settings['ig_authed'][$authed_user]['validity'] = 'expired'; update_option(self::SETTINGS_NAME, $this->settings); } return $this->frontend_stop(__('The requested photo source cannot be loaded at this time.', 'jig_td') . ' ' . $photos['message']); } break; case 'rss': if ($limit === '0') { $limit = 0; } else { if ($limit !== '') { $limit = (int) $limit; } else { $limit = 0; } } $rss_url = htmlspecialchars_decode($rss_url); $is_youtube = stripos($rss_url, 'youtube.com') !== false; if ($rss_url !== '<a') { $rss_url = explode(',', $rss_url); // Accept multiple URLs } elseif ($href !== '') { $rss_url = explode(',', $href); // Accept multiple URLs } $rss_url = str_replace('uploads?alt=rss&v=2&orderby=published&client=ytapi-youtube-profile', 'uploads?max-results=50', $rss_url); // If there is only just 1 feed, do not use an array because it triggers Simplepie's multifeed features which force-sorts by item date, resulting undesired order in e.g. Picasa feeds -.- if (count($rss_url) == 1) { $rss_url = $rss_url[0]; } $this->images = array(); // Create a new array for the images if (!$is_youtube) { include_once ABSPATH . WPINC . '/feed.php'; add_action('wp_feed_options', array($this, 'jig_add_force_rss'), 10, 2); if (!is_numeric($rss_caching)) { $rss = fetch_feed($rss_url); } else { $this->rss_cache_override = $rss_caching; add_filter('wp_feed_cache_transient_lifetime', array($this, 'jig_set_rss_cache')); $rss = fetch_feed($rss_url); remove_filter('wp_feed_cache_transient_lifetime', array($this, 'jig_set_rss_cache')); } remove_action('wp_feed_options', array($this, 'jig_add_force_rss'), 10); if (is_wp_error($rss)) { $rss_sp_error_message = $rss->get_error_message(); return $this->frontend_stop(__('The requested RSS feed cannot be loaded at this time.', 'jig_td') . ' ' . (is_string($rss_sp_error_message) ? $rss_sp_error_message : $rss_sp_error_message[0])); } $rss_items = $rss->get_items(0, $rss->get_item_quantity($limit)); } else { // If this is a youtube URL if (is_array($rss_url)) { $rss_url_count = count($rss_url); } else { $rss_url = array($rss_url); $rss_url_count = 1; } $rss_items = array(); foreach ($rss_url as $rss_url_index => $single_rss_url) { $rss_caching = (int) $rss_caching; if ($rss_caching !== 0) { $actual_rss_caching = $rss_caching ? $rss_caching : 720; $cached_value = get_transient('jigrss_' . md5($single_rss_url . $actual_rss_caching . $limit)); if (!empty($cached_value) == true) { $rss_items[$rss_url_index] = $cached_value; } if (empty($rss_items[$rss_url_index])) { $rss_items[$rss_url_index] = $this->scrape_youtube($single_rss_url, $limit, $rss_description); if (!is_string($cached_value)) { set_transient('jigrss_' . md5($single_rss_url . $actual_rss_caching . $limit), $rss_items[$rss_url_index], 60 * $actual_rss_caching); } } } if (empty($rss_items[$rss_url_index])) { $rss_items[$rss_url_index] = $this->scrape_youtube($single_rss_url, $limit, $rss_description); } if (is_string($rss_items[$rss_url_index])) { return $this->frontend_stop($rss_items[$rss_url_index]); } } unset($rss_url_index, $single_rss_url); if ($rss_url_count > 1) { // merge n arrays // sort by a custom funtion, strtotime each value of each array // result a single array that looks just like one normal rss_items $merged_rss_items = array(); foreach ($rss_items as $single_rss_items_list) { $merged_rss_items = array_merge($merged_rss_items, $single_rss_items_list); } unset($single_rss_items_list); foreach ($merged_rss_items as $merged_rss_items_index => &$single_rss_item) { // The time index is substracted from the unix time so the original is preserved // The exact time is not known as the nice time is pretty vague ("1 year ago") $single_rss_item->unix_date = strtotime($single_rss_item->get_date) - $merged_rss_items_index; } unset($merged_rss_items_index, $single_rss_item); usort($merged_rss_items, array($this, 'sort_youtube_rss')); $rss_items = $merged_rss_items; } else { $rss_items = $rss_items[0]; } } if (count($rss_items) === 0) { return $this->frontend_stop(__('The requested RSS feed is empty.', 'jig_td')); } if ($orderby == 'rand') { $rss_items = (array) $rss_items; shuffle($rss_items); } $url_hash_list = array(); foreach ($rss_items as $rss_item_index => &$item) { $imageURL = false; $enclosure_links = $item->get_enclosures(); $enclosure_image = false; // Find enclosures, if possible if (!empty($enclosure_links)) { // Gravatar images are skipped for WP foreach ($enclosure_links as $enclosure_entry) { if (!empty($enclosure_entry)) { $enclosure_link = $enclosure_entry->get_link(); if (!empty($enclosure_link) && strpos($enclosure_link, 'gravatar') === false && $enclosure_link !== '//?#' && preg_match('/\\.(jpe?g|gif|png|bmp|webp)/im', $enclosure_link)) { // Test for images $enclosure_image = $enclosure_link; } else { if (!empty($enclosure_entry->thumbnails[0])) { if (preg_match('%.*vimeocdn\\.com/video/[^_]*%im', $enclosure_entry->thumbnails[0], $regs)) { $enclosure_image = $regs[0] . '.jpg'; } else { continue; } } else { continue; } } } } } // 1. Use enclosures if any good found if (!empty($enclosure_image)) { $imageURL = $enclosure_image; } else { // 2. Find article images in HTML $text = html_entity_decode($item->get_content(), ENT_QUOTES, 'UTF-8'); if (preg_match("/<img[^>]+\\>/i", $text, $matches) === 1) { if (preg_match('/src=[\'"]?([^\'">]+)[\'" >]/', $matches[0], $link) === 1) { $imageURL = urldecode($link[1]); } } } // 3. Fall back for article thumbnail, if any if (empty($imageURL) && ($thumb = $item->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'thumbnail'))) { $imageURL = $thumb[0]['attribs']['']['url']; } if (empty($imageURL)) { // if no image is found, skip that RSS item unset($rss_items[$rss_item_index]); continue; } // Handle protocol flexible links in RSS if (substr($imageURL, 0, 2) == '//') { $imageURL = (!is_ssl() ? 'http:' : 'https:') . $imageURL; } $rss_parsed_imageURL = parse_url($imageURL); // Handle relative links in RSS if (empty($rss_parsed_imageURL['host'])) { $rss_parsed_url = parse_url($item->get_feed()->subscribe_url()); // get the current feed URL (needs to be like this because of multifeed) $imageURL = $rss_parsed_url['scheme'] . '://' . $rss_parsed_url['host'] . $imageURL; } $imageURL = str_replace(' ', '%2B', $imageURL); $url_hash_list[] = hash('md5', $imageURL); $item->jig_image_src = array($imageURL); } unset($item, $imageURL); if (!$this->jig_query_ext_images($url_hash_list)) { $notice_after .= __('Cannot create database for caching external image dimensions.', 'jig_td'); } foreach ($rss_items as $item) { $item->jig_image_src = $this->jig_get_ext_imagesize($item->jig_image_src); if (!empty($item->jig_image_src[1]) && !empty($item->jig_image_src[2]) && $item->jig_image_src[1] > 16) { $data = $d = array(); // Create a new array for this image $data['url'] = $item->jig_image_src[0]; $data['width'] = $item->jig_image_src[1]; $data['height'] = $item->jig_image_src[2]; $data['title'] = esc_attr(stripslashes($item->get_title())); switch ($rss_description) { case 'none': break; case 'excerpt': // Excerpt is a controlled, textual story-based short description display that disallows html to aboid broken tags and has a fixed length $d['description'] = stripslashes(trim(strip_tags($item->get_description(), '<br>'))); // This is stronger for matching individual words, as it disregards any whitespace between them and later recombines with single space preg_match_all('/\\S+/m', $d['description'], $rss_words, PREG_PATTERN_ORDER); $rss_words = $rss_words[0]; if (count($rss_words) > (int) $rss_excerpt_length) { // this checks if the length is really longer than desired (could be exactly that long or shorter) $d['description'] = implode(' ', array_slice($rss_words, 0, (int) $rss_excerpt_length)); if ($rss_excerpt_ending !== 'none') { $d['description'] .= strtr($rss_excerpt_ending, array("(" => "[", ")" => "]")); } } break; case 'description': // regex removes the broken or unnecessary (p) and br tags in the beginning and the end as well as empty links, : at the end $d['description'] = stripslashes(trim(preg_replace('%<a[^>]*></a>%m', '', preg_replace('%(^(<(br|/p|p></p)\\s*+(/>|>))*+)|(((<(br|p></p)\\s*+(/>|>))|:)*+$)%m', '', strip_tags($item->get_description(), '<font><span><i><b><strong><italic><br><a>'))))); break; case 'datetime': $d['description'] = $item->get_date(get_option('date_format') . ' ' . get_option('time_format')); break; case 'date': $d['description'] = $item->get_date(get_option('date_format')); break; case 'nicetime': $d['description'] = $this->jig_nice_time($item->get_date()); break; } if (!empty($d['description'])) { $data['description'] = esc_attr($d['description']); } if ($rss_links_to === 'permalink') { $data['link'] = $item->get_permalink(); $data['link_target'] = $link_target; if ($data['link_target'] == 'video' && $lightbox === 'prettyphoto' && preg_match('%(?:([^:/?#]+):)?(?://([^/?#]*))?([^?#]*\\.(?:jpg|gif|png))(?:\\?([^#]*))?(?:#(.*))?%m', $data['link']) !== 1) { $data['link'] .= '?iframe=true'; } $d['link_rel'] = array(); if ($data['link_target'] == '_blank') { $d['link_rel'][] = 'external'; } if ($custom_link_follow == 'no') { $d['link_rel'][] = 'nofollow'; } $d['link_rel_imploded'] = implode(' ', $d['link_rel']); if ($d['link_rel_imploded'] != '') { $data['link_rel'] = $d['link_rel_imploded']; } } if ($download_link != 'no') { $data['download'] = esc_attr(stripslashes('<a href="' . plugins_url('download.php', __FILE__) . '?file=' . urlencode($data['url']) . '">' . __($download_link_text, 'jig_td') . '</a>')); } if ($rss_link != 'no') { $data['lightbox_link'] = esc_attr(stripslashes('<a href="' . $item->get_permalink() . '" target="' . $this->settings['rss_link_target'] . '">' . __($rss_link_text, 'jig_td') . '</a>')); } array_push($this->images, $data); } } break; } // end of the big switch() if (empty($this->images)) { return $this->frontend_stop(__('Justified Image Grid error: there are no images to show, the items are empty.', 'jig_td')); } if ($link_rel) { $link_rel = strtr($link_rel, array("(" => "[", ")" => "]")); } $borders_total = 0; if ($outer_border_width || $middle_border_width) { $borders_total = (intval($outer_border_width) + intval($middle_border_width)) * 2; } $outer_border_CSS = ''; $middle_border_color_CSS = ''; $middle_border_width_CSS = ''; $inner_border_CSS = ''; $inner_border_display = ''; $inner_border_width_fragment = $inner_border_width; $caption_wrapper_additional_css = ''; if ($inner_border === "hovered") { if ($inner_border_animate === "width") { $inner_border_width_fragment = 0; } else { $inner_border_display = 'display:none;'; } } if ($inner_border_width) { $inner_border_CSS = "#jig{$jig_id} .jig-border {\r\n\t\t\t\t\t\t\t\tbottom: 0;\r\n\t\t\t\t\t\t\t\tright: 0;\r\n\t\t\t\t\t\t\t\tleft: 0;\r\n\t\t\t\t\t\t\t\ttop: 0;\r\n\t\t\t\t\t\t\t\tposition: absolute;\r\n\t\t\t\t\t\t\t\tmargin:0;\r\n\t\t\t\t\t\t\t\tpadding:0;\r\n\t\t\t\t\t\t\t\tz-index:120;\r\n\t\t\t\t\t\t\t\toverflow:hidden;\r\n\t\t\t\t\t\t\t\tborder: {$inner_border_width_fragment}px solid {$inner_border_color}; /* 1px solid rgba(0, 0, 0, 0.9) */\r\n\t\t\t\t\t\t\t\t{$inner_border_display}\r\n\t\t\t\t\t\t\t}"; } if ($outer_border_width) { $outer_border_CSS = "border-style: solid;\r\n\t\t\t\t\t\t\t\t\tborder-width: {$outer_border_width}px;"; if ($outer_border === 'hovered') { $outer_border_CSS .= "border-color: transparent;"; } else { $outer_border_CSS .= "border-color: {$outer_border_color};"; } } if ($middle_border_width) { if ($middle_border === 'hovered') { $middle_border_color_CSS = "background-color: transparent;"; } else { $middle_border_color_CSS = "background-color: {$middle_border_color};"; } if ($caption == 'below' && $middle_border !== 'always') { if ($middle_border_width && $inner_border == 'always') { $caption_wrapper_additional_css = "margin-left: {$middle_border_width}px;\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tmargin-right: {$middle_border_width}px;\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tborder-left: {$inner_border_width}px solid {$inner_border_color};\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tborder-right: {$inner_border_width}px solid {$inner_border_color};\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tborder-bottom: {$inner_border_width}px solid {$inner_border_color};\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tmargin-top: -{$middle_border_width}px;\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tmargin-bottom: {$middle_border_width}px;"; } else { $caption_wrapper_additional_css = "margin-top: -{$middle_border_width}px;\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tmargin-bottom: {$middle_border_width}px;"; } } $middle_border_width_CSS = "margin: {$middle_border_width}px;"; } if ($outer_border_width && $middle_border_width && $outer_border !== 'always' && $middle_border !== 'always') { $animation_speed_seconds = $animation_speed / 1000; $outer_border_CSS .= "-webkit-transition:border-color {$animation_speed_seconds}s, background {$animation_speed_seconds}s;\r\n\t\t\t\t\t\t\t\t\t\t\t\t-moz-transition:border-color {$animation_speed_seconds}s, background {$animation_speed_seconds}s;\r\n\t\t\t\t\t\t\t\t\t\t\t\t-o-transition:border-color {$animation_speed_seconds}s, background {$animation_speed_seconds}s;\r\n\t\t\t\t\t\t\t\t\t\t\t\ttransition:border-color {$animation_speed_seconds}s, background {$animation_speed_seconds}s"; } elseif ($outer_border_width && $outer_border !== 'always') { $animation_speed_seconds = $animation_speed / 1000; $outer_border_CSS .= "-webkit-transition:border-color {$animation_speed_seconds}s;\r\n\t\t\t\t\t\t\t\t\t\t\t\t-moz-transition:border-color {$animation_speed_seconds}s;\r\n\t\t\t\t\t\t\t\t\t\t\t\t-o-transition:border-color {$animation_speed_seconds}s;\r\n\t\t\t\t\t\t\t\t\t\t\t\ttransition:border-color {$animation_speed_seconds}s"; } elseif ($middle_border_width && $middle_border !== 'always') { $animation_speed_seconds = $animation_speed / 1000; $middle_border_color_CSS .= "-webkit-transition:background {$animation_speed_seconds}s;\r\n\t\t\t\t\t\t\t\t\t\t\t\t-moz-transition:background {$animation_speed_seconds}s;\r\n\t\t\t\t\t\t\t\t\t\t\t\t-o-transition:background {$animation_speed_seconds}s;\r\n\t\t\t\t\t\t\t\t\t\t\t\ttransition:background {$animation_speed_seconds}s"; } $outer_shadow_CSS = ''; $inner_shadow_CSS = ''; if ($outer_shadow !== 'none') { $outer_shadow_CSS = "box-shadow: {$outer_shadow};"; } if ($inner_shadow !== 'none') { $inner_shadow_CSS = "box-shadow: {$inner_shadow} inset;"; } $overlay_CSS = ''; if ($overlay != 'off') { $overlay_appearance_CSS = ''; if ($overlay == 'hovered') { $overlay_appearance_CSS .= 'display:none;'; } $overlay_CSS = "#jig{$jig_id} .jig-overlay {\r\n\t\t\t\t\t\t\tbackground:{$overlay_color};\r\n\t\t\t\t\t\t\topacity: {$overlay_opacity};\r\n\t\t\t\t\t\t\t-moz-opacity: {$overlay_opacity};\r\n\t\t\t\t\t\t\tfilter:alpha(opacity=" . $overlay_opacity * 100 . ");\r\n\t\t\t\t\t\t\theight:100%;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\t#jig{$jig_id} .jig-overlay-wrapper {\r\n\t\t\t\t\t\t\t{$overlay_appearance_CSS}\r\n\t\t\t\t\t\t\tposition: absolute;\r\n\t\t\t\t\t\t\tbottom: 0;\r\n\t\t\t\t\t\t\tleft: 0;\r\n\t\t\t\t\t\t\tright: 0;\r\n\t\t\t\t\t\t\ttop: 0;\r\n\t\t\t\t\t\t\t{$inner_shadow_CSS}\r\n\t\t\t\t\t\t}"; if ($overlay_icon === 'on') { $overlay_CSS .= "#jig{$jig_id} .jig-overlay-icon-wrapper {\r\n\t\t\t\t\t\t\t{$overlay_appearance_CSS}\r\n\t\t\t\t\t\t\tposition: absolute;\r\n\t\t\t\t\t\t\tbottom: 0;\r\n\t\t\t\t\t\t\tleft: 0;\r\n\t\t\t\t\t\t\tright: 0;\r\n\t\t\t\t\t\t\ttop: 0;\r\n\t\t\t\t\t\t}"; $overlay_icon_url_for_CSS = $overlay_icon_url ? $overlay_icon_url : plugins_url('images/magnifier.png', __FILE__); $overlay_CSS .= "#jig{$jig_id} .jig-overlay-icon {\r\n\t\t\t\t\t\t\t\t\t\tbackground: url(" . $overlay_icon_url_for_CSS . ") no-repeat center center;\r\n\t\t\t\t\t\t\t\t\t\topacity: {$overlay_icon_opacity};\r\n\t\t\t\t\t\t\t\t\t\t-moz-opacity: {$overlay_icon_opacity};\r\n\t\t\t\t\t\t\t\t\t\tfilter:alpha(opacity=" . $overlay_icon_opacity * 100 . ");\r\n\t\t\t\t\t\t\t\t\t\theight:100%;\r\n\t\t\t\t\t\t\t\t\t}"; if ($retina_ready == 'yes') { $overlay_icon_retina_for_CSS = $overlay_icon_retina ? $overlay_icon_retina : ($overlay_icon_url ? $overlay_icon_url : plugins_url('images/magnifier@2x.png', __FILE__)); if (empty($overlay_icon_url)) { $ov_icon_px = "56px 56px"; } else { if (!$this->jig_query_ext_images(array(hash('md5', $overlay_icon_url_for_CSS)))) { $notice_after .= __('Cannot create database for caching external image dimensions.', 'jig_td'); } $overlay_icon_image_for_CSS = $this->jig_get_ext_imagesize(array($overlay_icon_url_for_CSS)); $ov_icon_px = $overlay_icon_image_for_CSS[1] . "px " . $overlay_icon_image_for_CSS[2] . "px"; } $overlay_CSS .= "@media only screen and (-webkit-min-device-pixel-ratio: 1.3), (min-resolution: 1.3dppx), (min-resolution: 124dpi){\r\n\t\t\t\t\t\t\t\t\t\t\t\t#jig{$jig_id} .jig-overlay-icon {\r\n\t\t\t\t\t\t\t\t\t\t\t\t\tbackground: url(" . $overlay_icon_retina_for_CSS . ") no-repeat center center;\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t-webkit-background-size:" . $ov_icon_px . ";\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t-moz-background-size:" . $ov_icon_px . ";\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t-o-background-size:" . $ov_icon_px . ";\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t \t\tbackground-size:" . $ov_icon_px . ";\r\n\t\t\t\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\t\t\t}"; } } } $nextgen_bc_CSS = ''; if ($ng_breadcrumb == 'yes') { $nextgen_bc_CSS = '.jig-ngBreadcrumb { ' . $this->settings['nextgen_breadcrumb_css'] . ' }'; } $fb_bc_CSS = ''; if (isset($fb_bc_CSS_needed)) { $fb_bc_CSS = '.jig-fbBreadcrumb { ' . $this->settings['fb_breadcrumb_css'] . ' }'; } $flickr_bc_CSS = ''; if (isset($flickr_bc_CSS_needed)) { $flickr_bc_CSS = '.jig-flickrBreadcrumb { ' . $this->settings['flickr_breadcrumb_css'] . ' }'; } $carousel_extra_CSS = ''; if ($lightbox == 'carousel') { $carousel_extra_CSS = '.jp-carousel-comment-post-success{ width:auto !important; }'; } $load_more_CSS_actual = ''; if ($load_more !== 'off') { $load_more_CSS_actual = "#jig{$jig_id} .jig-loadMoreButton{" . ($wrap_text == "no" ? '' : "\r\n\t\t\t\t\tfloat:left;\r\n\t\t\t\t\tmargin-right: " . $thumbs_spacing * 2 . "px !important;") . "\r\n\t\t\t\t\t" . $this->settings['load_more_css'] . "\r\n\t\t\t\t}\r\n\t\t\t\t#jig{$jig_id} .jig-loadMoreButton:hover{\r\n\t\t\t\t\t" . $this->settings['load_more_hover_css'] . "\r\n\t\t\t\t}"; } $caption_CSS = $image_container_additional_CSS = ''; if ($loading_background !== '') { $image_container_additional_CSS = "background: {$loading_background};"; } if ($caption != 'off') { $caption_appearance_CSS = $caption_desc_appearance_CSS = $caption_title_additional_CSS = $caption_desc_additional_CSS = ''; if ($caption == 'slide' || $caption == 'fade') { $caption_appearance_CSS = 'display:none;'; } if ($caption == 'below') { $caption_match_width = 'no'; $v_center_captions = 'off'; } if ($gradient_caption_bg == 'yes') { $caption_match_width = 'no'; $caption_opacity = 1; } if ($caption == 'mixed') { $caption_desc_appearance_CSS = "#jig{$jig_id} .jig-caption-description-wrapper {display:none;}"; } if ($caption_title_size) { $caption_title_additional_CSS .= 'font-size: ' . $caption_title_size . ' !important;'; } if ($caption_desc_size) { $caption_desc_additional_CSS .= 'font-size: ' . $caption_desc_size . ' !important;'; } if ($v_center_captions == 'yes' || $v_center_captions == 'simple') { $caption_appearance_CSS .= 'text-align: center !important;'; $caption_title_additional_CSS .= 'text-align: center !important;'; $caption_desc_additional_CSS .= 'text-align: center !important;'; $caption_align = 'center'; //if($caption_match_width == 'yes-rounded') $caption_match_width = 'yes'; } else { if ($caption_align !== 'css') { $caption_appearance_CSS .= 'text-align: ' . $caption_align . ' !important;'; $caption_title_additional_CSS .= 'text-align: ' . $caption_align . ' !important;'; $caption_desc_additional_CSS .= 'text-align: ' . $caption_align . ' !important;'; } } if ($caption_match_width == 'no') { $caption_title_additional_CSS .= "padding:5px 0 5px;"; $caption_desc_additional_CSS .= "padding-bottom: 5px;\r\n\t\t\t\t\t\t\t\t\t\t\t\t\tmargin-top: -3px;"; } else { $caption_title_additional_CSS .= "padding: 5px 7px 5px;\r\n\t\t\t\t\t\t\t\t\t\t\t\t\tvertical-align:bottom;\r\n\t\t\t\t\t\t\t\t\t\t\t\t\tbackground: {$caption_bg_color};\r\n\t\t\t\t\t\t\t\t\t\t\t\t\tdisplay:inline-block;"; if ($caption_match_width == 'yes-rounded') { switch ($caption_align) { case 'center': $caption_title_additional_CSS .= "-webkit-border-top-left-radius: 5px;\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t-webkit-border-top-right-radius: 5px;\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t-moz-border-radius-topleft: 5px;\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t-moz-border-radius-topright: 5px;\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tborder-top-left-radius: 5px;\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tborder-top-right-radius: 5px;"; break; case 'right': $caption_title_additional_CSS .= "-webkit-border-top-left-radius: 5px;\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t-moz-border-radius-topleft: 5px;\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tborder-top-left-radius: 5px;"; break; case 'left': default: $caption_title_additional_CSS .= "-webkit-border-top-right-radius: 5px;\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t-moz-border-radius-topright: 5px;\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tborder-top-right-radius: 5px;"; break; } /* IE glitch (all versions) */ $caption_title_additional_CSS .= "margin-bottom: -1px;"; } $caption_desc_additional_CSS .= "padding: 3px 7px 5px;\r\n\t\t\t\t\t\t\t\t\t\t\t\t\tbackground: {$caption_bg_color};\r\n\t\t\t\t\t\t\t\t\t\t\t\t\tdisplay:block;"; } if ($caption_match_width == 'no' && $caption !== 'below') { if ($gradient_caption_bg == 'no') { $caption_appearance_CSS .= "background: {$caption_bg_color};"; } $caption_appearance_CSS .= "padding:0 7px;"; } else { if ($caption !== 'below') { $caption_appearance_CSS .= "padding:0;"; } else { if ($caption_bg_color == 'transparent' || $caption_bg_color == 'none') { switch ($caption_align) { case 'center': $caption_appearance_CSS .= "padding:0 7px;"; break; case 'right': $caption_appearance_CSS .= "padding:0 0 0 7px;"; break; case 'left': default: $caption_appearance_CSS .= "padding:0 7px 0 0;"; break; } } else { $caption_appearance_CSS .= "padding:0 7px;"; } } } if ($gradient_caption_bg == 'yes') { $caption_appearance_CSS .= $this->settings['gradient_caption_bg_css']; } if ($caption_opacity == 1 && $caption_text_shadow != '') { $caption_appearance_CSS .= "text-shadow: {$caption_text_shadow};"; } if ($specialfx == 'captions' && $caption_opacity == 1 && strpos($caption_bg_color, 'rgba') === false && $caption_bg_color !== 'transparent' && $gradient_caption_bg == 'no') { // If the caption background is not translucent in any way, there is no point to use special effects $specialfx = 'off'; } $caption_CSS = "#jig{$jig_id} .jig-caption-wrapper {\r\n\t\t\t\t\t\t\tmax-height:100%;\r\n\t\t\t\t\t\t\tbottom: 0;\r\n\t\t\t\t\t\t\tright: 0;\r\n\t\t\t\t\t\t\tleft: 0;" . ($caption !== 'below' ? 'position: absolute;' : "height:{$caption_height}px;background: {$caption_bg_color};") . "\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\tmargin:0 auto;\r\n\t\t\t\t\t\t\tpadding:0;\r\n\t\t\t\t\t\t\tz-index:100;\r\n\t\t\t\t\t\t\toverflow:hidden;\r\n\t\t\t\t\t\t\topacity: {$caption_opacity};\r\n\t\t\t\t\t\t\t-moz-opacity: {$caption_opacity};\r\n\t\t\t\t\t\t\tfilter:alpha(opacity=" . $caption_opacity * 100 . ");\r\n\t\t\t\t\t\t\t{$caption_wrapper_additional_css}\r\n\t\t\t\t\t\t}" . ($specialfx == 'captions' && $overlay !== 'off' && $caption_fx_visibility == 'in_front_of_overlay' ? '' : "#jig{$jig_id} .jig-cw-role-effect {\r\n\t\t\t\t\t\t\tz-index: 0;\r\n\t\t\t\t\t\t}") . ($specialfx == 'captions' ? "#jig{$jig_id} .jig-cw-role-effect{\r\n\t\t\t\t\t\t\topacity: {$specialfx_blend};\r\n\t\t\t\t\t\t\t-moz-opacity: {$specialfx_blend};\r\n\t\t\t\t\t\t\tfilter:alpha(opacity=" . $specialfx_blend * 100 . ");\r\n\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\t#jig{$jig_id} .jig-cw-role-effect .jig-caption{\r\n\t\t\t\t\t\t\tbackground: transparent;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\t#jig{$jig_id} .jig-cw-role-effect .jig-caption-title,\r\n\t\t\t\t\t\t#jig{$jig_id} .jig-cw-role-effect .jig-caption-description{\r\n\t\t\t\t\t\t\tcolor: transparent !important;\r\n\t\t\t\t\t\t\tbackground: transparent;\r\n\t\t\t\t\t\t}" : "") . "\r\n\t\t\t\t\t\t#jig{$jig_id} .jig-caption {\r\n\t\t\t\t\t\t\t{$caption_appearance_CSS}\r\n\t\t\t\t\t\t\tmargin: 0;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\t#jig{$jig_id} .jig-caption-title {\r\n\t\t\t\t\t\t\toverflow: hidden;\r\n\t\t\t\t\t\t\tline-height: normal;\r\n\t\t\t\t\t\t\tbox-sizing: content-box !important;\r\n\t\t\t\t\t\t\tcolor:{$caption_text_color} !important;\r\n\t\t\t\t\t\t\t" . $this->settings['caption_title_css'] . "\r\n\t\t\t\t\t\t\t{$caption_title_additional_CSS}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\t{$caption_desc_appearance_CSS}\r\n\t\t\t\t\t\t#jig{$jig_id} .jig-caption-description {\r\n\t\t\t\t\t\t\toverflow: hidden;\r\n\t\t\t\t\t\t\tline-height: normal;\r\n\t\t\t\t\t\t\tcolor:{$caption_text_color} !important;\r\n\t\t\t\t\t\t\t" . $this->settings['caption_desc_css'] . "\r\n\t\t\t\t\t\t\t{$caption_desc_additional_CSS}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\r\n\t\t\t\t\t\t#jig{$jig_id} .jig-alone{\r\n\t\t\t\t\t\t\tpadding-top:5px !important;\r\n\t\t\t\t\t\t\tmargin-top: 0 !important;\r\n\t\t\t\t\t\t}"; } $instance_css = "#jig{$jig_id} {\r\n\t\t\t\t\t\t\t\tmargin:{$margin};\r\n\t\t\t\t\t\t\t\tmin-height:{$min_height}px;\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t#jig{$jig_id} .jig-imageContainer {\r\n\t\t\t\t\t\t\t\tmargin-bottom: {$thumbs_spacing}px;\r\n\t\t\t\t\t\t\t\t" . ($reading_direction == "ltr" ? "\r\n\t\t\t\t\t\t\t\tmargin-right: {$thumbs_spacing}px;\r\n\t\t\t\t\t\t\t\tfloat: left;" : "\r\n\t\t\t\t\t\t\t\tmargin-left: {$thumbs_spacing}px;\r\n\t\t\t\t\t\t\t\tfloat: right;") . "\r\n\t\t\t\t\t\t\t\tpadding: 0;\r\n\t\t\t\t\t\t\t\twidth: auto;\r\n\t\t\t\t\t\t\t\t{$outer_border_CSS}\r\n\t\t\t\t\t\t\t\t{$middle_border_color_CSS}\r\n\t\t\t\t\t\t\t\t{$outer_shadow_CSS}\r\n\t\t\t\t\t\t\t\t{$image_container_additional_CSS}\r\n\t\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\t\t#jig{$jig_id} .jig-imageContainer img {\r\n\t\t\t\t\t\t\t\tmax-width: none !important;\r\n\t\t\t\t\t\t\t\t" . ($allow_transp_pngs !== 'yes' ? "background-color: white !important;" : '') . ($specialfx !== 'off' ? "image-rendering:optimizeQuality;" : '') . "\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t#jig{$jig_id} .jig-overflow {\r\n\t\t\t\t\t\t\t\tposition: relative; \r\n\t\t\t\t\t\t\t\toverflow:hidden;\r\n\t\t\t\t\t\t\t\tvertical-align:baseline;\r\n\t\t\t\t\t\t\t\t{$middle_border_width_CSS}\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t{$caption_CSS}\r\n\t\t\t\t\t\t\t{$overlay_CSS}\r\n\t\t\t\t\t\t\t{$nextgen_bc_CSS}\r\n\t\t\t\t\t\t\t{$fb_bc_CSS}\r\n\t\t\t\t\t\t\t{$flickr_bc_CSS}\r\n\t\t\t\t\t\t\t{$inner_border_CSS}\r\n\t\t\t\t\t\t\t{$load_more_CSS_actual}\r\n\t\t\t\t\t\t\t{$carousel_extra_CSS}\r\n\t\t\t\t\t\t\t#jig{$jig_id} .jig-clearfix:after { clear: " . ($wrap_text == "no" ? "both" : "none") . "; }\r\n\t\t\t\t\t\t\t.jig-last {" . ($reading_direction == "ltr" ? "\r\n\t\t\t\t\t\t\t\tmargin-right: 0 !important;" : "\r\n\t\t\t\t\t\t\t\tmargin-left: 0 !important;") . "\r\n\t\t\t\t\t\t\t}"; if ($last_row == 'center' || $last_row == 'flexible-center' || $last_row == 'flexible-match-center' || $last_row == 'match-center') { if ($developer_link == 'show') { $instance_css .= "#jig{$jig_id}-developerLink{text-align:center;}"; } if (!empty($gallery_truncated_with_message)) { $instance_css .= "#jig{$jig_id}-viewRestOfGallery{text-align:center;}"; } } if ($this->settings['conditional_script_loading'] == 'yes') { if ($this->settings['jquery'] !== 'legacy') { if ($this->settings['jquery_location'] == 'footer') { wp_enqueue_script('jquery'); } } else { wp_register_script('jig-jq', plugins_url('js/jquery-1.8.3.min.js', __FILE__), array(), '1.8.3', true); wp_enqueue_script('jig-jq'); } } // create a hidden container // data-lazy-src prevents lazyload, apparently! $noscript_output = '<noscript id="jig' . $jig_id . '-html" class="justified-image-grid-html" data-lazy-src="skiplazyload" data-src="skipunveillazyload"><ul>'; $rss_output = ''; $site_host = explode('/', str_replace(array('http://', 'https://'), '', site_url())); // calculate timthumb path, take CDN into account $timthumb_calculated_path = plugins_url('timthumb.php', __FILE__); if ($timthumb_path) { $timthumb_calculated_path = $timthumb_path; } else { if ($this->settings['cdn_host'] !== '') { $timthumb_calculated_path = str_replace($site_host[0], $this->settings['cdn_host'], $timthumb_calculated_path); } } if ($aspect_ratio) { if (strrpos($aspect_ratio, ':') !== false) { $aspect_ratio_numbers = explode(':', $aspect_ratio); $aspect_ratio = (double) $aspect_ratio_numbers[0] / (double) $aspect_ratio_numbers[1]; } elseif (strrpos($aspect_ratio, '/') !== false) { $aspect_ratio_numbers = explode('/', $aspect_ratio); $aspect_ratio = (double) $aspect_ratio_numbers[0] / (double) $aspect_ratio_numbers[1]; } if (is_numeric($aspect_ratio)) { $aspect_ratio = round($aspect_ratio, 4); $max_width = round($max_height * $aspect_ratio); } else { $aspect_ratio = ''; } } if ($instagram_tag_filter !== '') { $instagram_tag_filter_exploded = explode(',', str_replace(array(', ', '#'), array(',', ''), strtolower($instagram_tag_filter))); $instagram_tag_filter_count = count($instagram_tag_filter_exploded); } if ($orderby == 'rand') { // Necessary to circumvent object caching shuffle($this->images); } // Post processing all images data foreach ($this->images as $image_index => &$image_element) { // Instagram tag filter feature if ($gallery_type == 'instagram' && $instagram_tag_filter !== '') { $matched_a_filter_in_image = false; $matches_count_for_instagram_filter = 0; // Only if the image has tags (filters) if (isset($image_element['filters'])) { foreach ($image_element['filters'] as $filter) { if (in_array($filter[0], $instagram_tag_filter_exploded)) { if ($instagram_tag_mode == 'or') { $matched_a_filter_in_image = true; break; } else { // If all filters must be found in the image tags, don't stop searching $matches_count_for_instagram_filter += 1; } } } unset($filter); } if ($matches_count_for_instagram_filter == $instagram_tag_filter_count) { $matched_a_filter_in_image = true; } if ($matched_a_filter_in_image === false) { unset($this->images[$image_index]); continue; } if ($filterby == 'off') { unset($this->images[$image_index]['filters']); } } if ($lightbox == 'photoswipe') { $image_element['wh'] = $image_element['width'] . 'x' . $image_element['height']; } $image_element['width'] = $image_element['width'] / $image_element['height'] * $max_height; unset($this->images[$image_index]['height']); if (!$photon_activated) { $image_element['width'] = floor($image_element['width']); // Calculate new width of TimThumb } else { $image_element['width'] = round($image_element['width']); // Calculate new width of Photon } // ? + in the filename drives timthumb crazy and convert backslashes, remove doubleslashes $image_element['unencoded_url'] = $image_element['url'] = str_replace(array('\\', '+'), array('/', '%2B'), $image_element['url']); if (!empty($image_element['thumbUrl'])) { //$image_element['thumbUrl'] = preg_replace('%(?<!:)/{2,}%m', '/', str_replace(array('\\','+','&','?'),array('/','%2B','%26','%3F'),$image_element['thumbUrl'])); $image_element['thumbUrl'] = urlencode(preg_replace('%(?<!:)/{2,}%m', '/', str_replace('\\', '/', $image_element['thumbUrl']))); $image_element['url'] = preg_replace('%(?<!:)/{2,}%m', '/', $image_element['url']); } else { //$image_element['url'] = preg_replace('%(?<!:)/{2,}%m', '/', str_replace(array('\\','+','&'),array('/','%2B','%26'),$image_element['url'])); $image_element['url'] = urlencode(preg_replace('%(?<!:)/{2,}%m', '/', $image_element['url'])); } // This can allow animated gifs by not modifying the aspect ratio or width, just relays the img src as is if (!($allow_animated_gifs === 'yes' && stripos($image_element['unencoded_url'], '.gif') !== false || $use_timthumb == 'no')) { if ($aspect_ratio) { $image_element['width'] = $max_width; } if ($randomize_width > 0) { $randomize_width_only_this = $randomize_width; if ($image_element['width'] - $randomize_width / 2 < $image_element['width'] / 2) { $randomize_width_only_this = $image_element['width'] / 2; } mt_srand(intval(substr(base_convert(md5($image_element['unencoded_url'] . $max_height), 16, 10), -8), 10)); $randomize_width_only_this /= 2; $image_element_original_width = $image_element['width']; $image_element['width'] -= mt_rand(-$randomize_width_only_this, $randomize_width_only_this); } } else { $image_element['photon'] = $image_element['unencoded_url']; $skip_photon_for_animated_gif = true; } if (!empty($link_override)) { $image_element['link'] = $link_override; } // Disregard custom links if ($link_target == 'off' && !($gallery_type == 'facebook' && $image_element['link_target'] == 'video')) { unset($image_element['link'], $image_element['link_target']); } elseif (!empty($image_element['link_target']) && !empty($image_element['link'])) { // If there are links on the images if ($image_element['link_target'] == 'videoplayer') { // If it's specifically the videoplayer mode if ($lightbox !== 'prettyphoto' || $lightbox == 'prettyphoto' && $this->settings['prettyphoto_deeplinking'] !== 'advanced_deeplinking' && $this->settings['prettyphoto_deeplinking'] !== 'smart_deeplinking') { // Create the video player URL with the video file and its cover photo as parameters $image_element['link'] = home_url('/') . '?' . $this->settings['video_slug'] . '=' . $image_element['link'] . ($this->settings['video_poster'] == 'yes' ? '&poster=' . $image_element['url'] : ''); if ($lightbox == 'photoswipe' || $lightbox == 'photoswipe3' || $lightbox == 'colorbox' || $lightbox == 'carousel' || $lightbox == 'socialgallery') { // These lightboxes don't support iframe so skip them $image_element['link_target'] = '_blank'; } elseif ($lightbox == 'prettyphoto') { // If there is just simple prettyPhoto deeplinking there is no worry about the long or ugly URL, so just add the suffix $image_element['link'] .= '?iframe=true'; } } else { // In advanced deeplinking the source URL is visible in the address bar so make it a bit shorter. $image_element['link'] .= str_replace('&', '|', ($this->settings['video_poster'] == 'yes' ? '&poster=' . $image_element['url'] : '') . '&videoplayer'); // Will pass the video player URL to prettyPhoto as a setting $prettyphoto_videoplayer_url = true; } } elseif ($image_element['link_target'] == 'video') { if ((strpos($image_element['link'], 'youtube.com/') !== false || strpos($image_element['link'], 'youtu.be/') !== false || strpos($image_element['link'], 'vimeo.com/') !== false) && ($lightbox == 'photoswipe' || $lightbox == 'photoswipe3' || $lightbox == 'colorbox' || $lightbox == 'carousel' || $lightbox == 'socialgallery')) { // These lightboxes don't support videos so skip them $image_element['link_target'] = '_blank'; } } if (($lightbox == 'foobox' || $lightbox == 'magnific') && ($image_element['link_target'] == 'video' || $image_element['link_target'] == 'videoplayer')) { if ($image_element['link_target'] == 'video' && preg_match('%https?://[^/\\s]+/\\S+\\.(jpe?g|png|[tg]iff?|svg|bmp|webp)%m', $image_element['link'])) { // It's an image and shouldn't open in an iframe of FooBox, just normally! $image_element['thumbUrl'] = $image_element['url']; $image_element['url'] = $image_element['link']; $image_element['unencoded_url'] = $image_element['link']; $image_element['link'] = $image_element['link_target'] = null; unset($image_element['link'], $image_element['link_target']); } elseif ($lightbox == 'foobox') { // It's needed by FooBox to act on iframes and videos $image_element['link_target'] = 'foobox'; } } } // Process shortcodes if ($process_shortcodes === 'yes') { if (isset($image_element['title'])) { $image_element['title'] = esc_attr(do_shortcode($image_element['title'])); } if (isset($image_element['caption'])) { $image_element['caption'] = esc_attr(do_shortcode($image_element['caption'])); } if (isset($image_element['description'])) { $image_element['description'] = esc_attr(do_shortcode($image_element['description'])); } if (isset($image_element['alternate'])) { $image_element['alternate'] = esc_attr(do_shortcode($image_element['alternate'])); } } if ($for_xml_sitemap === 'yes') { $sitemap_images[$image_index] = $image_element; } // rewrite URL to photon URL if ($photon_activated && empty($skip_photon_for_animated_gif)) { $photon_url = jetpack_photon_url($image_element['unencoded_url']); $photon_url = str_replace(' ', '+', $photon_url); // still serve the normal sized images from the social pages' CDNs if ($gallery_type == 'wp_post_gallery' || $gallery_type == 'wp_recent_posts' || $gallery_type == 'nextgen') { $image_element['url'] = $photon_url; } if (strpos($photon_url, '?') === false) { $image_element['photon'] = $photon_url . '?h=' . $max_height; if ($aspect_ratio || $randomize_width > 0) { $image_element['photon'] = $photon_url . '?resize=' . $image_element['width'] . ',' . $max_height; } } else { $image_element['photon'] = substr($photon_url, 0, strpos($photon_url, '?')) . '?h=' . $max_height; if ($aspect_ratio || $randomize_width > 0) { $image_element['photon'] = substr($photon_url, 0, strpos($photon_url, '?')) . '?resize=' . $image_element['width'] . ',' . $max_height; } } unset($photon_url); // or rewrite to CDN url } elseif ($this->settings['cdn_host'] !== '' && $gallery_type !== 'flickr' && $gallery_type !== 'facebook' && $gallery_type !== 'rss' && ($gallery_type !== 'wp_recent_posts' || $gallery_type == 'wp_recent_posts' && $recents_link_to == 'image')) { $image_element['url'] = str_replace($site_host[0], $this->settings['cdn_host'], $image_element['url']); $image_element['unencoded_url'] = str_replace($site_host[0], $this->settings['cdn_host'], $image_element['unencoded_url']); if ($this->settings['cdn_custom_links'] == 'yes' && !empty($image_element['link'])) { $image_element['link'] = str_replace($site_host[0], $this->settings['cdn_host'], $image_element['link']); } if ($for_xml_sitemap === 'yes') { $sitemap_images[$image_index] = $image_element; } } // make images findable by google if (!empty($image_element[$link_title_field])) { $title_fragment = $image_element[$link_title_field]; } else { if (preg_match('%(?<=/)(\\w*)(?=\\.[:\\w]{2,5}(?:$|\\?|#|&))%m', $image_element['unencoded_url'], $regs)) { $title_fragment = $regs[0]; } else { $title_fragment = ''; } } $alt_fragment = isset($image_element[$img_alt_field]) ? $image_element[$img_alt_field] : $title_fragment; if (!empty($title_fragment)) { $title_fragment_full = ' title="' . $title_fragment . '"'; } else { $title_fragment_full = ''; } if (!isset($image_element['photon'])) { $image_src = !isset($image_element['thumbUrl']) ? $image_element['url'] : $image_element['thumbUrl']; $ext = ''; if ($this->settings['thumbnail_filename'] == 'normal' && preg_match('/.*\\.(jpe?g|gif|bmp|png|webp)/im', $image_src, $regs)) { $ext = "&f=." . $regs[1]; } if (!$aspect_ratio) { $image_src = $timthumb_calculated_path . "?src=" . $image_src . "&h=" . $max_height . "&q=" . $quality . $ext; } else { $image_src = $timthumb_calculated_path . "?src=" . $image_src . "&h=" . $max_height . "&w=" . $image_element['width'] . "&q=" . $quality . $ext; } } else { $image_src = $image_element['photon']; } $rel_fragments = array(); if (isset($image_element['link_target']) && $image_element['link_target'] == '_blank') { $rel_fragments[] = 'external'; } if (isset($image_element['link']) && isset($image_element['link_target']) && $custom_link_follow === 'no' && $image_element['link_target'] == '_blank') { $rel_fragments[] = 'nofollow'; } if (empty($rel_fragments)) { $rel_fragment = ''; } else { $rel_fragment = ' rel="' . implode(' ', $rel_fragments) . '"'; } $description_text = ($alt_fragment !== $title_fragment ? $alt_fragment . '<br/>' : '') . $title_fragment; if (!empty($description_text)) { $description_text = '<p class="jig-HTMLdescription">' . html_entity_decode($description_text) . '</p>'; } $noscript_output .= '<li><a href="' . (!isset($image_element['link']) ? $image_element['unencoded_url'] : $image_element['link']) . '"' . $title_fragment_full . $rel_fragment . '><img ' . $this->class_for_noscript_img . 'src="' . str_replace('&', '&', $image_src) . '" alt="' . $alt_fragment . '" width="' . (!isset($image_element_original_width) ? $image_element['width'] : $image_element_original_width) . '" height="' . $max_height . '" /></a>' . $description_text . '</li>'; if ($this->settings['show_up_in_feeds'] == 'yes' && is_feed()) { $image_rss_src = !isset($image_element['thumbUrl']) ? $image_element['url'] : $image_element['thumbUrl']; if ($photon_activated && empty($skip_photon_for_animated_gif)) { if (strpos($image_element['photon'], '?') !== false) { $image_rss_src = substr($image_element['photon'], 0, strpos($image_element['photon'], '?')) . '?resize=150,150'; } else { $image_rss_src = $image_element['photon'] . '?resize=150,150'; } } else { if ($use_timthumb == 'yes') { $ext = ''; if ($this->settings['thumbnail_filename'] == 'normal' && preg_match('/.*\\.(jpe?g|gif|bmp|png|webp)/im', $image_rss_src, $regs)) { $ext = "&f=." . $regs[1]; } $image_rss_src = $timthumb_calculated_path . "?src=" . $image_rss_src . "&h=150&w=150&q=" . $quality . "&jigrss=yes" . $ext; $rss_output .= '<img src="' . str_replace('&', '&', $image_rss_src) . '" width="150" height="150" /> '; } else { $image_rss_src = !isset($image_element['thumbUrl']) ? $image_element['unencoded_url'] : $image_element['thumbUrl']; } } $rss_output .= '<img src="' . str_replace('&', '&', $image_rss_src) . '" width="150" /> '; // Height will be automatic } unset($image_element['unencoded_url']); // not needed for JS! unset($image_element_original_width); // Filtering features if ($filterby !== 'off') { if (!empty($image_element['filters'])) { foreach ($image_element['filters'] as &$filter) { // only adds unique tags to the filters for JS if (strpos($filter[0], '%') !== false) { $filter[0] = md5($filter[0]); } elseif (is_numeric($filter[0])) { $filter[0] = '_' . $filter[0]; } $filters_for_JS[$filter[0]] = $filter[1]; if (!empty($filters_for_JS_counter[$filter[0]])) { $filters_for_JS_counter[$filter[0]]++; } else { $filters_for_JS_counter[$filter[0]] = 1; } } unset($filter); } } if ($l2_filterby !== 'off') { if (!empty($image_element['L2filters'])) { foreach ($image_element['L2filters'] as &$filter) { // only adds unique tags to the l2_filters for JS if (strpos($filter[0], '%') !== false) { $filter[0] = md5($filter[0]); } elseif (is_numeric($filter[0])) { $filter[0] = '_' . $filter[0]; } $l2_filters_for_JS[$filter[0]] = $filter[1]; if (!empty($l2_filters_for_JS_counter[$filter[0]])) { $l2_filters_for_JS_counter[$filter[0]]++; } else { $l2_filters_for_JS_counter[$filter[0]] = 1; } } unset($filter); } } if (empty($image_element['width'])) { unset($this->images[$image_index]); } } if (!empty($prettyphoto_videoplayer_url)) { $prettyphoto_videoplayer_url = home_url('/') . '?' . $this->settings['video_slug'] . '='; } // end of 'post processing' // Level 1 filtering (original concept) if ($filterby !== 'off' && !empty($filters_for_JS)) { if ($filter_orderby == 'custom' && empty($filter_custom_order)) { $filter_orderby = 'appearance'; } $filters_for_JS = (array) $filters_for_JS; if ($filter_orderby == 'popularity' || $filter_top_x !== '' || $filter_min_count) { natcasesort($filters_for_JS_counter); $filters_for_JS_counter = array_reverse($filters_for_JS_counter, true); // Preserve numerical keys like years } $filters_for_JS_custom = array(); switch ($filter_orderby) { case 'title_asc': natcasesort($filters_for_JS); break; case 'title_desc': natcasesort($filters_for_JS); $filters_for_JS = array_reverse($filters_for_JS, true); // Preserve numerical keys like years break; case 'random': $filters_for_JS = $this->shuffle_assoc($filters_for_JS); break; case 'custom': $filter_custom_order = explode(',', $filter_custom_order); $filters_for_JS_custom_key = ''; foreach ($filter_custom_order as $filter_name) { $filter_name = trim($filter_name); if (strpos($filter_name, '&') !== false && strpos($filter_name, '&') === false) { $filter_name = str_replace('&', '&', $filter_name); } $filters_for_JS_custom_key = array_search($filter_name, $filters_for_JS); if ($filters_for_JS_custom_key !== false) { $filters_for_JS_custom[$filters_for_JS_custom_key] = $filter_name; } } $filters_for_JS = $filters_for_JS_custom; break; case 'popularity': // Order by the number of images with that tag foreach ($filters_for_JS_counter as $filter_slug => $image_count_for_filter) { $filters_for_JS_custom[$filter_slug] = $filters_for_JS[$filter_slug]; } unset($filter_slug, $image_count_for_filter); $filters_for_JS = $filters_for_JS_custom; break; case 'appearance': default: break; } if ($filter_top_x !== '') { $filters_for_JS_custom = array_slice($filters_for_JS_counter, 0, (int) $filter_top_x); $filters_for_JS = array_intersect_key($filters_for_JS, $filters_for_JS_custom); } if ($filter_min_count) { $filters_for_JS_custom = array(); foreach ($filters_for_JS as $filter_slug => $filter_value) { if ($filters_for_JS_counter[$filter_slug] >= $filter_min_count) { $filters_for_JS_custom[$filter_slug] = $filters_for_JS[$filter_slug]; } } unset($filter_slug, $image_count_for_filter); $filters_for_JS = $filters_for_JS_custom; } if ($filter_all_button == 'yes') { $filters_for_JS['all-items-nofilter'] = __($filter_all_text, 'jig_td'); } } // Level 2 filtering (shameless copy paste) if ($l2_filterby !== 'off' && !empty($l2_filters_for_JS)) { if ($l2_filter_orderby == 'custom' && empty($l2_filter_custom_order)) { $l2_filter_orderby = 'appearance'; } $l2_filters_for_JS = (array) $l2_filters_for_JS; if ($l2_filter_orderby == 'popularity' || $l2_filter_top_x !== '' || $l2_filter_min_count) { natcasesort($l2_filters_for_JS_counter); $l2_filters_for_JS_counter = array_reverse($l2_filters_for_JS_counter, true); // Preserve numerical keys like years } $l2_filters_for_JS_custom = array(); switch ($l2_filter_orderby) { case 'title_asc': natcasesort($l2_filters_for_JS); break; case 'title_desc': natcasesort($l2_filters_for_JS); $l2_filters_for_JS = array_reverse($l2_filters_for_JS, true); // Preserve numerical keys like years break; case 'random': $l2_filters_for_JS = $this->shuffle_assoc($l2_filters_for_JS); break; case 'custom': $l2_filter_custom_order = explode(',', $l2_filter_custom_order); $l2_filters_for_JS_custom_key = ''; foreach ($l2_filter_custom_order as $filter_name) { $filter_name = trim($filter_name); if (strpos($filter_name, '&') !== false && strpos($filter_name, '&') === false) { $filter_name = str_replace('&', '&', $filter_name); } $l2_filters_for_JS_custom_key = array_search($filter_name, $l2_filters_for_JS); if ($l2_filters_for_JS_custom_key !== false) { $l2_filters_for_JS_custom[$l2_filters_for_JS_custom_key] = $filter_name; } } $l2_filters_for_JS = $l2_filters_for_JS_custom; break; case 'popularity': // Order by the number of images with that tag foreach ($l2_filters_for_JS_counter as $filter_slug => $image_count_for_filter) { $l2_filters_for_JS_custom[$filter_slug] = $l2_filters_for_JS[$filter_slug]; } unset($filter_slug, $image_count_for_filter); $l2_filters_for_JS = $l2_filters_for_JS_custom; break; case 'appearance': default: break; } if ($l2_filter_top_x !== '') { $l2_filters_for_JS_custom = array_slice($l2_filters_for_JS_counter, 0, (int) $l2_filter_top_x); $l2_filters_for_JS = array_intersect_key($l2_filters_for_JS, $l2_filters_for_JS_custom); } if ($l2_filter_min_count) { $l2_filters_for_JS_custom = array(); foreach ($l2_filters_for_JS as $l2_filter_slug => $l2_filter_value) { if ($l2_filters_for_JS_counter[$l2_filter_slug] >= $l2_filter_min_count) { $l2_filters_for_JS_custom[$l2_filter_slug] = $l2_filters_for_JS[$l2_filter_slug]; } } unset($l2_filter_slug, $image_count_for_filter); $l2_filters_for_JS = $l2_filters_for_JS_custom; } if ($l2_filter_all_button == 'yes') { $l2_filters_for_JS['all-items-nofilter'] = __($l2_filter_all_text, 'jig_td'); } } if (empty($this->images)) { //needs to be checked again return $this->frontend_stop(__('Justified Image Grid error: there are no images to show, the "items" are empty.', 'jig_td')); } if ($for_xml_sitemap === 'yes') { global $jig_images_for_xml_sitemap; if (empty($sitemap_images)) { $jig_images_for_xml_sitemap = array_merge($jig_images_for_xml_sitemap, $this->images); } else { $jig_images_for_xml_sitemap = array_merge($jig_images_for_xml_sitemap, $sitemap_images); } return $this->frontend_stop(); } if ($this->settings['show_up_in_feeds'] == 'yes' && is_feed()) { return $this->frontend_stop($rss_output, false); } $noscript_output .= '</ul></noscript>'; $lightbox_JS = "window['jigAddLightbox{$jig_id}'] = function(){return};"; $lightbox_class = $lightbox_narrow = ''; if ($ng_lightbox_gallery == 'yes' && isset($shadow_gallery)) { $lightbox_class = ''; $lightbox_narrow = '.jig-imageContainer '; } $output = ''; switch ($lightbox) { case 'prettyphoto': if (!defined('JIG_SKIP_PRETTYPHOTO')) { global $jig_prettyphoto_activation_needed; $jig_prettyphoto_activation_needed = true; if ($this->settings['conditional_script_loading'] == 'yes' && $load_bundled_lightbox == 'yes') { wp_register_script('jig-prettyphoto', plugins_url('js/jquery.prettyphoto.custom-min.js', __FILE__), 'jquery', '3.1.6.' . self::PLUGIN_VERSION, true); wp_enqueue_script('jig-prettyphoto'); wp_register_style('jig-prettyphoto-style', plugins_url('css/prettyphoto.css', __FILE__), false, '3.1.6.' . self::PLUGIN_VERSION); wp_enqueue_style('jig-prettyphoto-style'); } } switch ($this->settings['prettyphoto_deeplinking']) { case 'smart_deeplinking': $prettyphoto_deeplinking_fragment = "\tsmart_deeplinking: true,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tadvanced_deeplinking: false,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tdeeplinking:true,"; break; case 'advanced_deeplinking': $prettyphoto_deeplinking_fragment = "\tsmart_deeplinking: false,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tadvanced_deeplinking: true,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tdeeplinking:true,"; break; case 'deeplinking': $prettyphoto_deeplinking_fragment = "\tsmart_deeplinking: false,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tadvanced_deeplinking: false,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tdeeplinking:true,"; break; default: $prettyphoto_deeplinking_fragment = "\tsmart_deeplinking: false,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tadvanced_deeplinking: false,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tdeeplinking:false,"; break; } $lightbox_JS = "window['jigAddLightbox{$jig_id}'] = function(){\r\n\t\t\t\t\t\t\t\t\t\tif(typeof \$.prettyPhoto === 'undefined'\r\n\t\t\t\t\t\t\t\t\t\t\t&& typeof loadJustifiedImageGrid !== 'undefined'\r\n\t\t\t\t\t\t\t\t\t\t\t&& typeof loadJIGprettyPhoto !== 'undefined'){\r\n\t\t\t\t\t\t\t\t\t\t\tloadJIGprettyPhoto(\$);\r\n\t\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\t\t\$('#jig{$jig_id} {$lightbox_narrow}a.jig-link').prettyPhoto({\r\n\t\t\t\t\t\t\t\t\t\t\tjig_call: true," . ($pp_social_buttons !== 'FTPG' ? ' jig_socials: "' . $pp_social_buttons . '",' : '') . ($prettyphoto_social == 'no' ? ' social_tools: false,' : '') . ($prettyphoto_analytics == 'yes' ? ' analytics: true,' : '') . ($prettyphoto_title_pos == 'outside' ? ' title_position: "outside",' : '') . (!empty($prettyphoto_videoplayer_url) ? ' videoplayer: "' . $prettyphoto_videoplayer_url . '",' : '') . $prettyphoto_deeplinking_fragment . ' theme: "' . $prettyphoto_theme . '", ' . $this->settings['prettyphoto_settings'] . "\r\n\t\t\t\t\t\t\t\t\t\t});\r\n\t\t\t\t\t\t\t\t\t};"; break; case 'colorbox': if ($this->settings['conditional_script_loading'] == 'yes' && $load_bundled_lightbox == 'yes') { wp_deregister_script('colorbox'); wp_register_script('colorbox', plugins_url('js/jquery.colorbox-min.js', __FILE__), 'jquery', '1.6.3', true); wp_enqueue_script('colorbox'); wp_register_style('colorbox-style', plugins_url('css/colorbox' . $this->settings['colorbox_design'] . '.css', __FILE__), false, '1.6.3'); wp_enqueue_style('colorbox-style'); } $lightbox_JS = "window['jigAddLightbox{$jig_id}'] = function(){\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\$('#jig{$jig_id} {$lightbox_narrow}a.jig-link').colorbox({\r\n\t\t\t\t\t\t\t\t\t\t\t" . $this->settings['colorbox_settings'] . "\r\n\t\t\t\t\t\t\t\t\t\t});\r\n\t\t\t\t\t\t\t\t\t};"; break; case 'magnific': if ($this->settings['conditional_script_loading'] == 'yes' && $load_bundled_lightbox == 'yes') { wp_deregister_script('magnific-popup'); wp_register_script('magnific-popup', plugins_url('js/jquery.magnific-popup.min.js', __FILE__), 'jquery', '1.0.0', true); wp_enqueue_script('magnific-popup'); wp_register_style('magnific-popup-style', plugins_url('css/magnific-popup.css', __FILE__), false, '1.0.0'); wp_enqueue_style('magnific-popup-style'); } $lightbox_JS = "window['jigAddLightbox{$jig_id}'] = function(){"; // Magnific needs different treatment for multiple galleries if (empty($shadow_galleries)) { $lightbox_JS .= "\$('#jig{$jig_id} a.jig-link')"; } else { $lightbox_JS .= "\$('#jig{$jig_id} .jig-imageContainer').each(function() { \$(this).find('a')"; } $lightbox_JS .= ".magnificPopup({\r\n\t\t\t\t\t\t\t\t\t\t\ttype: 'image',\r\n\t\t\t\t\t\t\t\t\t\t\tgallery: {\r\n\t\t\t\t\t\t\t\t\t\t\t\tenabled:true,\r\n\t\t\t\t\t\t\t\t\t\t\t\ttCounter:\t'%curr% / %total%',\r\n\t\t\t\t\t\t\t\t\t\t\t},\r\n\r\n\t\t\t\t\t\t\t\t\t\t\timage: {\r\n\t\t\t\t\t\t\t\t\t\t\t\ttitleSrc: function(item) {\r\n\t\t\t\t\t\t\t\t\t\t\t\t\tvar title = item.el.find('img').attr('alt');\r\n\t\t\t\t\t\t\t\t\t\t\t\t\tif(typeof title === 'undefined') title = '';\r\n\t\t\t\t\t\t\t\t\t\t\t\t\tvar description = item.el.attr('title');\r\n\t\t\t\t\t\t\t\t\t\t\t\t\tdescription = typeof description !== 'undefined' ? '<small>' + description + '</small>' : '';\r\n\t\t\t\t\t\t\t\t\t\t\t\t\treturn title + description;\r\n\t\t\t\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\t\t\t},\r\n\r\n\t\t\t\t\t\t\t\t\t\t\tiframe: {\r\n\t\t\t\t\t\t\t\t\t\t\t\tmarkup: '<div class=\"mfp-iframe-scaler\"><div class=\"mfp-close\"></div><iframe class=\"mfp-iframe\" frameborder=\"0\" allowfullscreen></iframe><div class=\"mfp-bottom-bar\"><div class=\"mfp-title\"></div><div class=\"mfp-counter\"></div></div></div>',\r\n\t\t\t\t\t\t\t\t\t\t\t patterns: {\r\n\t\t\t\t\t\t\t\t\t\t\t youtube: {\r\n\t\t\t\t\t\t\t\t\t\t\t\t\tid: function(url) {\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tvar match = /^(?:https?:\\/\\/)?(?:www\\.)?(?:youtube\\.com(?:\\/embed\\/|\\/v\\/|\\/watch\\?v=|\\/watch\\?.+&v=))([\\w\\-]{9,13})(?:.+)?\$/im.exec(url);\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tif (match != null) {\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\treturn match[1];\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\treturn false;\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t} \r\n\t\t\t\t\t\t\t\t\t\t\t },\r\n\t\t\t\t\t\t\t\t\t\t\t },\r\n\t\t\t\t\t\t\t\t\t\t\t},\r\n\t\t\t\t\t\t\t\t\t\t\tcallbacks: {\r\n\t\t\t\t\t\t\t\t\t\t\t markupParse: function(template, values, item) {\r\n\t\t\t\t\t\t\t\t\t\t\t \tif(item.type == 'iframe'){\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tvar title = item.el.find('img').attr('alt');\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tif(typeof title === 'undefined') title = '';\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tvar description = item.el.attr('title');\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tdescription = typeof description !== 'undefined' ? '<small>' + description + '</small>' : '';\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tvalues.title = title + description;\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\t\t\t }\r\n\t\t\t\t\t\t\t\t\t\t\t },\r\n\t\t\t\t\t\t\t\t\t\t\t" . ($magnific_zoom == 'yes' ? "\r\n\t\t\t\t\t\t\t\t\t\t\tmainClass: 'mfp-with-zoom',\r\n\t\t\t\t\t\t\t\t\t\t\tzoom: {\r\n\t\t\t\t\t\t\t\t\t\t\t\tenabled: true,\r\n\t\t\t\t\t\t\t\t\t\t\t\tduration: 300,\r\n\t\t\t\t\t\t\t\t\t\t\t\teasing: 'ease-in-out',\r\n\t\t\t\t\t\t\t\t\t\t\t\topener: function(openerElement) {\r\n\t\t\t\t\t\t\t\t\t\t\t\t\tif(openerElement.parent().attr('class') !== 'jig-overflow' ){\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\topenerElement.offset = function(){ return {top: \$(window).height()/2, left: \$(window).width()/2 };};\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\treturn openerElement;\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\t\t\t\t\treturn openerElement.find('img');\r\n\t\t\t\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\t\t\t}," : "") . "\r\n\t\t\t\t\t\t\t\t\t\t\t" . $this->settings['magnific_settings'] . "\r\n\t\t\t\t\t\t\t\t\t\t});"; // Different closing of JS if (empty($shadow_galleries)) { $lightbox_JS .= "};"; } else { $lightbox_JS .= "})};"; } break; case 'foobox': if (class_exists('fooboxV2') || class_exists('foobox')) { $lightbox_class = 'jigFooBoxConnect'; $lightbox_JS = "window['jigAddLightbox{$jig_id}'] = function(){\r\n\t\t\t\t\t\t\twindow.FOOBOX.init();\r\n\t\t\t\t\t\t};"; } break; case 'photoswipe': if ($this->settings['conditional_script_loading'] == 'yes' && $load_bundled_lightbox == 'yes') { wp_deregister_script('photoswipe'); wp_register_script('photoswipe', plugins_url('js/photoswipe4-min.js', __FILE__), 'jquery', '4.1.0', true); wp_enqueue_script('photoswipe'); wp_register_style('photoswipe-style', plugins_url('css/photoswipe4.css', __FILE__), 'jquery', '4.1.0'); wp_enqueue_style('photoswipe-style'); } // if button is shareEl disabled but then enabled specifically if ($photoswipe_social == 'yes' && (stripos($this->settings['photoswipe4_settings'], 'shareEl: false') !== false || stripos($this->settings['photoswipe4_settings'], 'shareEl:false') !== false)) { $this->settings['photoswipe4_settings'] = str_replace(array('shareEl: false', 'shareEl:false'), 'shareEl: true', $this->settings['photoswipe4_settings']); } //if button is shareEl true, but disabled in the setting, change it in the shareEl if ($photoswipe_social == 'no' || $photoswipe_social == 'inherit' && $prettyphoto_social == 'no' || empty($ps_social_buttons)) { if (stripos($this->settings['photoswipe4_settings'], 'shareEl: true') !== false || stripos($this->settings['photoswipe4_settings'], 'shareEl:true') !== false) { $this->settings['photoswipe4_settings'] = str_replace(array('shareEl: true', 'shareEl:true'), 'shareEl: false', $this->settings['photoswipe4_settings']); } if (stripos($this->settings['photoswipe4_settings'], 'shareEl') === false) { $photoswipe_add_sharel = true; } } $lightbox_JS = "window['jigAddLightbox{$jig_id}'] = function(){"; $lightbox_JS .= "\$('#jig{$jig_id} {$lightbox_narrow}a.jig-link').JIGphotoSwipe({\r\n\t\t\t\t\t\t\t\t\t\t\t" . ($aspect_ratio ? 'aspectRatioMismatch: true, ' : '') . ($this->settings['photoswipe_caption_align'] != 'center' ? 'captionAlign: "' . $this->settings['photoswipe_caption_align'] . '", ' : '') . ($this->settings['photoswipe_deeplinking'] == 'auto' && $this->settings['prettyphoto_deeplinking'] != 'smart_deeplinking' || $this->settings['photoswipe_deeplinking'] == 'no' ? 'history:false,' : '') . ($download_link == 'no' ? '' : 'allowDownload: true, ') . (empty($photoswipe_add_sharel) ? '' : 'shareEl: false, ') . ($ps_social_buttons !== 'FTPG' ? ' socialButtons: "' . $ps_social_buttons . '",' : '') . $this->settings['photoswipe4_settings'] . "\r\n\t\t\t\t\t\t\t\t\t\t});"; $lightbox_JS .= "};"; break; case 'photoswipe3': if ($this->settings['conditional_script_loading'] == 'yes' && $load_bundled_lightbox == 'yes') { wp_deregister_script('klass'); wp_register_script("klass", plugins_url('js/klass.min.js', __FILE__), 'jquery', '1.0', true); wp_enqueue_script("klass"); wp_deregister_script('photoswipe3'); wp_register_script('photoswipe3', plugins_url('js/code.photoswipe.jquery-3.0.5.min.js', __FILE__), 'jquery', '3.0.5', true); wp_enqueue_script('photoswipe3'); wp_register_style('photoswipe3-style', plugins_url('css/photoswipe3.css', __FILE__), false, '3.0.5'); wp_enqueue_style('photoswipe3-style'); } $lightbox_JS = "window['jigAddLightbox{$jig_id}'] = function(){"; // This fakes 1 ID-less shadow gallery when no shadow galleries are present if (empty($shadow_galleries)) { $shadow_galleries[] = ''; } foreach ($shadow_galleries as $gallery_id) { $gallery_id_numeric = '_' . substr($gallery_id, strrpos($gallery_id, '-') + 1); if ($gallery_id !== '') { $gallery_id = '#' . $gallery_id . ' '; } $lightbox_JS .= "if(\$('#jig{$jig_id} {$gallery_id}a.jig-link').length !== 0){\r\n\t\t\t\t\t\t\t\t\t\t\tif(typeof(JIGPhotoSwipeInstance{$jig_id}{$gallery_id_numeric}) != 'undefined' && JIGPhotoSwipeInstance{$jig_id}{$gallery_id_numeric} !== null) {\r\n\t\t\t\t\t\t\t\t\t\t\t\twindow.Code.PhotoSwipe.unsetActivateInstance(JIGPhotoSwipeInstance{$jig_id}{$gallery_id_numeric});\r\n\t\t\t\t\t\t\t\t\t\t\t\twindow.Code.PhotoSwipe.detatch(JIGPhotoSwipeInstance{$jig_id}{$gallery_id_numeric}); \r\n\t\t\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\t\t\tJIGPhotoSwipeInstance{$jig_id}{$gallery_id_numeric} = \$('#jig{$jig_id} {$gallery_id}a.jig-link').photoSwipe({\r\n\t\t\t\t\t\t\t\t\t\t\t\t" . $this->settings['photoswipe_settings'] . "\r\n\t\t\t\t\t\t\t\t\t\t\t});\r\n\t\t\t\t\t\t\t\t\t\t\tJIGPhotoSwipeResized = false;\r\n\r\n\t\t\t\t\t\t\t\t\t\t\tJIGPhotoSwipeInstance{$jig_id}{$gallery_id_numeric}.addEventHandler(window.Code.PhotoSwipe.EventTypes.onHide, function(e){\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\$('.justified-image-grid').each(function( index ) {\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\$(this).data('justifiedImageGrid').createGallery('resize');\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t});\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\$('.justified-image-grid').css('pointer-events','none');\r\n\t\t\t\t\t\t\t\t\t\t\t\t\tvar reenablePointerEvents = window.setTimeout(function(){\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\$('.justified-image-grid').css('pointer-events','auto');\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t}, 200);\r\n\t\t\t\t\t\t\t\t\t\t\t\t\tJIGPhotoSwipeResized = true;\r\n\t\t\t\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\t\t\t);\r\n\t\t\t\t\t\t\t\t\t\t\tJIGPhotoSwipeInstance{$jig_id}{$gallery_id_numeric}.addEventHandler(window.Code.PhotoSwipe.EventTypes.onToolbarTap, function(e){\r\n\t\t\t\t\t\t\t\t\t\t\t\t\tif(e.toolbarAction === 'close'){\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tif(JIGPhotoSwipeResized == false){\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\$('.justified-image-grid').each(function( index ) {\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\$(this).data('justifiedImageGrid').createGallery('resize');\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t});\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\$('.justified-image-grid').css('pointer-events','none');\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tvar reenablePointerEvents = window.setTimeout(function(){\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\$('.justified-image-grid').css('pointer-events','auto');\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t}, 200);\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\t\t\t);\r\n\t\t\t\t\t\t\t\t\t\t}else{\r\n\t\t\t\t\t\t\t\t\t\t\treturn false;\r\n\t\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\t\t"; } $lightbox_JS .= "};"; break; case 'socialgallery': $lightbox_class = 'jigSgConnect'; break; case 'carousel': $lightbox_class = 'tiled-gallery gallery-caption'; remove_all_filters('post_gallery', 1500); $Jetpack_Carousel = new Jetpack_Carousel(); add_filter('post_gallery', array($Jetpack_Carousel, 'enqueue_assets'), 1600, 2); apply_filters('post_gallery', '', $atts, $justified_image_grid_instance); break; case 'custom': if ($this->settings['custom_lightbox_js'] !== '$(JIG_selector).exampleLightbox();') { $lightbox_JS = "window['jigAddLightbox{$jig_id}'] = function(){\r\n\t\t\t\t\t\t\t" . str_replace('JIG_selector', "'#jig{$jig_id} {$lightbox_narrow}a.jig-link'", $this->settings['custom_lightbox_js']) . "\r\n\t\t\t\t\t\t};"; } break; } // Lightbox class is set up for each shadow gallery instead if (!empty($shadow_gallery)) { $lightbox_class = ''; } if ($notice_before !== '') { $output .= $notice_before; } if (!$carousel_activated) { $output .= '<div id="jig' . $jig_id . '" class="justified-image-grid jig-' . hash('md5', serialize($atts)) . ' jig-preset-' . (empty($preset) ? 'global' : $preset) . ($lightbox_class == '' ? '' : ' ' . $lightbox_class) . '"><div class="jig-clearfix"></div>' . $noscript_output . '</div>'; } else { if (empty($Jetpack_Carousel)) { $Jetpack_Carousel = new Jetpack_Carousel(); } $output .= $Jetpack_Carousel->add_data_to_container('<div id="jig' . $jig_id . '" class="justified-image-grid jig-' . hash('md5', serialize($atts)) . ($lightbox_class == '' ? '' : ' ' . $lightbox_class) . '">'); $output .= '<div class="jig-clearfix"></div></div>'; } if ($notice_after !== '') { $output .= $notice_after; } if ($developer_link == 'show') { $output .= '<div id="jig' . $jig_id . '-developerLink" class="jig-developerLink"><a href="http://codecanyon.net/item/justified-image-grid-premium-wordpress-gallery/2594251' . ($this->settings['envato_user'] != '' ? '?ref=' . $this->settings['envato_user'] : '') . '" target="_blank" title="Justified Image Grid - Premium WordPress Gallery">' . __($developer_link_text, 'jig_td') . '</a></div>'; } $mouse_JS = ''; if ($mouse_disable == 'yes') { $mouse_JS = "\$('#jig{$jig_id}').on('contextmenu', function(e){\r\n\t\t\t\t\t\t\t\te.preventDefault();\r\n\t\t\t\t\t\t\t\treturn false;\r\n\t\t\t\t\t\t\t});\r\n\t\t\t\t\t\t\t\$(document).on('click', \$('#jig{$jig_id}'), function(event){\r\n\t\t\t\t\t\t\t\tif(event.which === 2){\r\n\t\t\t\t\t\t\t\t\tevent.preventDefault();\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t});"; switch ($lightbox) { case 'prettyphoto': $mouse_JS .= '$("body").on("contextmenu", "#pp_full_res", function(e){ e.preventDefault(); return false; });'; break; case 'photoswipe': $mouse_JS .= '$("body").on("contextmenu", ".pswp", function(e){ e.preventDefault(); return false; });'; break; case 'colorbox': $mouse_JS .= '$("body").on("contextmenu", "#colorbox", function(e){ e.preventDefault(); return false; });'; break; case 'foobox': $mouse_JS .= '$("body").on("contextmenu", ".foobox-modal", function(e){ e.preventDefault(); return false; });'; break; case 'magnific': $mouse_JS .= '$("body").on("contextmenu", ".mfp-img", function(e){ e.preventDefault(); return false; });'; break; case 'carousel': $mouse_JS .= '$("body").on("contextmenu", ".jp-carousel-slide.selected", function(e){ e.preventDefault(); return false; });'; break; default: break; } } // legacy desaturation setting support if ($desaturate !== '') { $specialfx = $desaturate; $specialfx_type = 'desaturate'; } // remove desaturation if the thumbs are from another host as pixastic is not compatible with that if ($this->settings['cdn_host'] !== '' || $photon_activated) { $specialfx = 'off'; } // A new object that'll hold all the settings, eventually will get passed to JS as JSON $this->JS_settings = array(); // These settings have no defaults in the jQuery plugin $this->JS_settings['timthumb'] = $timthumb_calculated_path; $this->JS_settings['items'] = array_values((array) $this->images); // These settings have thes defaults in the jQuery plugin and only need to be included in the calling script, if they differ if ($row_height != 190) { $this->JS_settings['targetHeight'] = (int) $row_height; } if ($height_deviation != 40) { $this->JS_settings['heightDeviation'] = (int) $height_deviation; } if ($aspect_ratio) { $this->JS_settings['aspectRatio'] = $aspect_ratio; } if ($disable_cropping !== 'no') { $this->JS_settings['disableCropping'] = $disable_cropping; } if ($randomize_width) { $this->JS_settings['randomizeWidth'] = $randomize_width; } if ($thumbs_spacing != 4) { $this->JS_settings['margins'] = (int) $thumbs_spacing; } if ($animation_speed != 300) { $this->JS_settings['animSpeed'] = (int) $animation_speed; } if ($max_rows) { $this->JS_settings['maxRows'] = (int) $max_rows; } if ($link_class) { $this->JS_settings['linkClass'] = $link_class; } if ($link_rel !== 'jig[*instance*]') { $this->JS_settings['linkRel'] = $link_rel; } if ($link_attribute_name !== '') { $this->JS_settings['linkAttributeName'] = $link_attribute_name; } if ($link_attribute_value !== '') { $this->JS_settings['linkAttributeValue'] = $link_attribute_value; } if ($link_title_field !== 'description') { $this->JS_settings['linkTitleField'] = $link_title_field; } if ($img_alt_field !== 'title') { $this->JS_settings['imgAltField'] = $img_alt_field; } if ($wrap_text !== 'no') { $this->JS_settings['wrapText'] = $wrap_text; } if ($reading_direction !== 'ltr') { $this->JS_settings['readingDirection'] = $reading_direction; } if ($retina_ready !== 'yes') { $this->JS_settings['retinaReady'] = $retina_ready; } if ($quality != 90) { $this->JS_settings['quality'] = (int) $quality; } if ($retina_quality !== 'auto') { $this->JS_settings['retinaQuality'] = (int) $retina_quality; } if ($min_retina_quality != 30) { $this->JS_settings['minRetinaQuality'] = (int) $min_retina_quality; } if ($max_retina_density != 3) { $this->JS_settings['maxRetinaDensity'] = (int) $max_retina_density; } if ($download_link !== 'no') { $this->JS_settings['downloadLink'] = $download_link; } if ($caption !== 'fade') { $this->JS_settings['caption'] = $caption; } if ($caption_match_width !== 'no') { $this->JS_settings['captionMatchWidth'] = $caption_match_width; } if ($title_field !== 'title') { $this->JS_settings['titleField'] = $title_field; } if ($caption_field !== 'description') { $this->JS_settings['captionField'] = $caption_field; } if ($disable_hover !== 'no') { $this->JS_settings['disableHover'] = $disable_hover; } if ($lightbox !== 'prettyphoto') { $this->JS_settings['lightbox'] = $lightbox; } if ($overlay !== 'hovered') { $this->JS_settings['overlay'] = $overlay; } if ($overlay_icon !== 'off') { $this->JS_settings['overlayIcon'] = $overlay_icon; } if ($borders_total !== 0) { $this->JS_settings['bordersTotal'] = (int) $borders_total; } if ($specialfx !== 'off') { $this->JS_settings['specialFx'] = $specialfx; } if ($specialfx_type !== 'desaturate') { $this->JS_settings['specialFxType'] = $specialfx_type; } if ($specialfx_blend != 1) { $this->JS_settings['specialFxBlend'] = $specialfx_blend; } if ($specialfx_options !== '') { $this->JS_settings['specialFxOptions'] = explode(',', $specialfx_options); } if ($last_row !== 'normal') { $this->JS_settings['incompleteLastRow'] = $last_row; } if ($error_checking !== 'yes') { $this->JS_settings['errorChecking'] = $error_checking; } if ($separator_character !== ' - ') { $this->JS_settings['separatorCharacter'] = $separator_character; } if ($timthumb_crop_zone !== 'c') { $this->JS_settings['cropZone'] = '&a=' . $timthumb_crop_zone; } if ($this->settings['thumbnail_filename'] !== 'normal') { $this->JS_settings['thumbnailFilename'] = $this->settings['thumbnail_filename']; } // These have more complicated logic if ($jig_id !== 1) { $this->JS_settings['instance'] = $jig_id; $this->JS_settings['lightboxInit'] = 'jigAddLightbox' . $jig_id; } if ($load_more !== 'off') { $this->JS_settings['limit'] = (int) $load_more_limit; $this->JS_settings['loadMore'] = $load_more; if (__($load_more_text, 'jig_td') !== 'Load more') { $this->JS_settings['loadMoreText'] = __($load_more_text, 'jig_td'); } if (__($load_more_count_text, 'jig_td') !== '(*count* images remaining)') { $this->JS_settings['loadMoreCountText'] = __($load_more_count_text, 'jig_td'); } if ($load_more_offset !== 100) { $this->JS_settings['loadMoreOffset'] = $load_more_offset; } if ($load_more_auto_width !== 'on') { $this->JS_settings['loadMoreAutoWidth'] = $load_more_auto_width; } } elseif ($hidden_limit) { if ($real_limit) { $this->JS_settings['limit'] = (int) $real_limit; } else { $this->JS_settings['limit'] = 0; } } if ($custom_width) { if ($width_mode == 'responsive_fallback') { $this->JS_settings['fallbackWidth'] = (int) $custom_width; } elseif ($width_mode == 'fixed' || $width_mode == 'fixed-mobile' && $detect->isMobile() || $width_mode == 'fixed-desktop' && !$detect->isMobile()) { $this->JS_settings['fixedWidth'] = (int) $custom_width; } } if ($caption !== 'off') { if ($v_center_captions !== 'off') { $this->JS_settings['verticalCenterCaptions'] = $v_center_captions; } if ($custom_fonts !== 'yes') { $this->JS_settings['customFonts'] = $custom_fonts; } } if ($caption == 'below' && $caption_height != 54) { $this->JS_settings['captionHeight'] = (int) $caption_height; } if ($flickr_link !== 'no' && $gallery_type == 'flickr') { $this->JS_settings['lightboxLink'] = $flickr_link; } elseif ($instagram_link !== 'no' && $gallery_type == 'instagram') { $this->JS_settings['lightboxLink'] = $instagram_link; } elseif ($rss_link !== 'no' && $gallery_type == 'rss') { $this->JS_settings['lightboxLink'] = $rss_link; } elseif ($recents_link !== 'no' && $gallery_type == 'wp_recent_posts') { $this->JS_settings['lightboxLink'] = $recents_link; } if ($middle_border !== 'always') { $this->JS_settings['middleBorder'] = $middle_border; if ($middle_border_color !== 'white') { $this->JS_settings['middleBorderColor'] = $middle_border_color; } if ($middle_border_width !== 0) { $this->JS_settings['middleBorderWidth'] = (int) $middle_border_width; } } if ($inner_border !== 'always') { $this->JS_settings['innerBorder'] = $inner_border; if ($inner_border_animate !== 'width') { $this->JS_settings['innerBorderAnimate'] = $inner_border_animate; } } if ($outer_border !== 'always') { $this->JS_settings['outerBorder'] = $outer_border; if ($outer_border_color !== 'black') { $this->JS_settings['outerBorderColor'] = $outer_border_color; } } if ($inner_border_width !== 0) { $this->JS_settings['innerBorderWidth'] = (int) $inner_border_width; } if (!empty($filters_for_JS)) { $this->JS_settings['filters'] = $filters_for_JS; if ($filter_multiple !== 'no') { $this->JS_settings['filterMultiple'] = $filter_multiple; } if ($filter_style !== 'buttons') { $this->JS_settings['filterStyle'] = $filter_style; } } if (!empty($l2_filters_for_JS)) { $this->JS_settings['L2filters'] = $l2_filters_for_JS; if ($l2_filter_multiple !== 'no') { $this->JS_settings['L2filterMultiple'] = $l2_filter_multiple; } if ($l2_filter_style !== 'buttons') { $this->JS_settings['L2filterStyle'] = $l2_filter_style; } } if (!empty($filters_for_JS) || !empty($l2_filters_for_JS)) { if ($this->settings['filter_smallest_color'] !== '#A3A3A3') { $this->JS_settings['filterSmallestColor'] = $this->settings['filter_smallest_color']; } if ($this->settings['filter_smallest_size'] != '11') { $this->JS_settings['filterSmallestSize'] = (int) $this->settings['filter_smallest_size']; } if ($this->settings['filter_largest_color'] !== '#000000') { $this->JS_settings['filterLargestColor'] = $this->settings['filter_largest_color']; } if ($this->settings['filter_largest_size'] != '22') { $this->JS_settings['filterLargestSize'] = (int) $this->settings['filter_largest_size']; } } // convert all settings for JS to JSON $JS_settings_JSON = json_encode($this->JS_settings); $instance_js = "{$lightbox_JS}\r\n\t\t\t\t\t\t\t\$('#jig{$jig_id}').justifiedImageGrid({$JS_settings_JSON});\r\n\t\t\t\t\t\t\t{$mouse_JS}"; global $justified_image_grid_js, $justified_image_grid_css, $justified_image_grid_ie_css, $justified_image_grid_filtering_css_needed, $jig_prettyphoto_activation_needed; $justified_image_grid_js .= $instance_js; $justified_image_grid_css .= $instance_css; $justified_image_grid_ie_css .= ($this->settings['center_filter_buttons'] == 'yes' ? ".jig-filterButton{display:inline !important;}" : "") . ($this->settings['center_tag_cloud'] == 'yes' ? ".jig-filterTag{display:inline !important;}" : "") . $this->jig_rgbaIE($caption_bg_color, $jig_id, $caption_match_width, $gradient_caption_bg); if (isset($jig_prettyphoto_activation_needed)) { $js_print = "if(typeof \$.prettyPhoto.JIG === 'undefined'\r\n\t\t\t\t\t\t\t\t&& typeof loadJustifiedImageGrid !== 'undefined'\r\n\t\t\t\t\t\t\t\t&& typeof loadJIGprettyPhoto !== 'undefined'){\r\n\t\t\t\t\t\t\t\tloadJIGprettyPhoto(\$);\r\n\t\t\t\t\t\t\t}" . $justified_image_grid_js . "\r\n\t\t\t\t\t\t\tif(typeof jigOtherPrettyPhotoIsPresent !== 'undefined'){\r\n\t\t\t\t\t\t\t\t\$(document).ready(function(){\r\n\t\t\t\t\t\t\t\t\tsetTimeout(function(){\r\n\t\t\t\t\t\t\t\t\t\t\$(window).trigger('jigPrettyPhotoActivation');\r\n\t\t\t\t\t\t\t\t\t}, 50);\r\n\t\t\t\t\t\t\t\t});\r\n\t\t\t\t\t\t\t}else{\r\n\t\t\t\t\t\t\t\t\$(window).trigger('jigPrettyPhotoActivation');\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}"; } else { $js_print = $justified_image_grid_js . "}"; } $css_print = ' .justified-image-grid { max-width: none !important; padding:0; clear:both; line-height: normal; display: block !important; } .jig-hiddenGallery{ display:none !important; } .justified-image-grid .jig-imageContainer img, .justified-image-grid .jig-pixastic { position:absolute; top:0; left:0; margin: 0; padding: 0; border-style: none !important; vertical-align: baseline; max-width: none !important; max-height: none !important; min-height: 0 !important; min-width: 0 !important; box-shadow: none !important; z-index: auto !important; visibility: visible !important; } .justified-image-grid .jig-imageContainer a { margin: 0 !important; padding: 0 !important; position: static !important; display: inline; } .justified-image-grid div { position: static; } .justified-image-grid a:link, .justified-image-grid a:hover, .justified-image-grid a:visited { text-decoration:none; } .justified-image-grid .jig-removeThis { visibility:hidden; } .justified-image-grid .jig-hiddenLink, .justified-image-grid .jig-hiddenImg{ display:none !important; } .jig-last:after { clear:both; } .justified-image-grid .tiled-gallery-caption{ display: none !important; } .jig-developerLink{ line-height: 10px; margin-bottom: 5px; } .jig-developerLink a{ font-size: 9px; } .jig-fontCheck{ display: block !important; position: absolute !important; left: -99999px !important; top: -99999px !important; visibility: hidden !important; font-size: 100px !important; white-space: nowrap !important; max-width: none !important; width: auto !important; } .justified-image-grid-html li { float:left; position: relative; list-style:none; overflow:hidden; } .justified-image-grid-html .jig-HTMLdescription{ position: absolute; bottom: 0; left: 0; right: 0; background-color: rgba(0,0,0,0.5); color: white; margin: 0; padding: 5px; } .justified-image-grid > p, .justified-image-grid > li { display: none; } noscript.justified-image-grid-html p{ display:block; } noscript.justified-image-grid-html li { display: list-item; } .justified-image-grid-html li .jig-clearfix:before, .jig-clearfix:after, .justified-image-grid-html:before, .justified-image-grid-html:after { content: ""; display: table; } .jig-clearfix:after, .justified-image-grid-html:after { clear: both; } .jig-clearfix, .justified-image-grid-html { -webkit-backface-visibility: visible; zoom: 1; /* For IE 6/7 (trigger hasLayout) */ }' . (isset($justified_image_grid_filtering_css_needed) ? "\r\n\t\t\t\t\t\t\t.jig-filterButtons,\r\n\t\t\t\t\t\t\t.jig-filterTags{\r\n\t\t\t\t\t\t\t\tclear:both;\r\n\t\t\t\t\t\t\t\tmargin-bottom: 10px;\r\n\t\t\t\t\t\t\t\t-webkit-touch-callout: none;\r\n\t\t\t\t\t\t\t\t-webkit-user-select: none;\r\n\t\t\t\t\t\t\t\t-khtml-user-select: none;\r\n\t\t\t\t\t\t\t\t-moz-user-select: none;\r\n\t\t\t\t\t\t\t\t-ms-user-select: none;\r\n\t\t\t\t\t\t\t\tuser-select: none;\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t.jig-filterButton{\r\n\t\t\t\t\t\t\t\tdisplay:inline-block;\r\n\t\t\t\t\t\t\t\tcursor:pointer;\r\n\t\t\t\t\t\t\t\t" . $this->settings['filter_button_css'] . "\r\n\t\t\t\t\t\t\t\tfloat:none;\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t.jig-filterTag{\r\n\t\t\t\t\t\t\t\tdisplay:inline-block;\r\n\t\t\t\t\t\t\t\tvertical-align: baseline;\r\n\t\t\t\t\t\t\t\tcursor:pointer;\r\n\t\t\t\t\t\t\t\t" . $this->settings['filter_tag_css'] . "\r\n\t\t\t\t\t\t\t\tline-height: 1.2;\r\n\t\t\t\t\t\t\t}" . ($this->settings['center_filter_buttons'] == 'yes' ? "\r\n\t\t\t\t\t\t\t.jig-filterButtons {\r\n\t\t\t\t\t\t\t\ttext-align: center;\r\n\t\t\t\t\t\t\t}" : "") . ($this->settings['center_tag_cloud'] == 'yes' ? "\r\n\t\t\t\t\t\t\t.jig-filterTags {\r\n\t\t\t\t\t\t\t\ttext-align: center;\r\n\t\t\t\t\t\t\t}" : "") . "\r\n\t\t\t\t\t\t\t.jig-filterButton.jig-filterButtonSelected:hover,\r\n\t\t\t\t\t\t\t.jig-filterTag.jig-filterTagSelected:hover{\r\n\t\t\t\t\t\t\t\tcursor:default;\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t.jig-filterButton:hover,\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t.jig-filterButton.jig-filterButtonSelected:hover,\r\n\t\t\t\t\t\t\t.jig-filterButton.jig-filterButtonSelected{\r\n\t\t\t\t\t\t\t\t" . $this->settings['filter_button_hover_css'] . "\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t.jig-filterTag:hover,\r\n\t\t\t\t\t\t\t.jig-filterTag.jig-filterTagSelected:hover,\r\n\t\t\t\t\t\t\t.jig-filterTag.jig-filterTagSelected{\r\n\t\t\t\t\t\t\t\t" . $this->settings['filter_tag_hover_css'] . "\r\n\t\t\t\t\t\t\t}" : "") . $justified_image_grid_css . $this->settings['custom_CSS']; $this->dynamic_script = "<script type='text/javascript'>\r\n" . $this->slib_compress_script(' (function initJIG ($,ready) { if(typeof $.justifiedImageGrid !== "undefined"){ ' . $js_print . ' }else if(typeof $.justifiedImageGrid === "undefined" && ready == true){ if(typeof loadJustifiedImageGrid !== "undefined"){ loadJustifiedImageGrid($); initJIG($,true); return; } $(".justified-image-grid").html("<span style=\\"color:red;font-weight:bold\\">' . __('The Justified Image Grid JS is not loaded. Try disabling Conditional script loading in the General settings.', 'jig_td') . '</span>"); }else{ $(document).ready(function(){ initJIG($,true); }); } })(jQuery,false);') . $this->settings['custom_JS'] . "\r\n</script>\r\n"; $this->dynamic_style = "<style type='text/css'>\r\n" . str_replace(array("\r\n", "\r", "\n", "\t", ' ', ' ', ' '), '', $css_print) . "\r\n</style>\r\n" . ($justified_image_grid_ie_css ? "<!--[if IE]><style type='text/css'>" . str_replace(array("\r\n", "\r", "\n", "\t", ' ', ' ', ' '), '', $justified_image_grid_ie_css . '.jig-caption-wrapper-clone {filter: alpha(opacity=0) !important;}') . '</style><![endif]-->' : '') . "<!--[if lt IE 8]><style type='text/css'>.justified-image-grid .jig-overlay, .justified-image-grid .jig-overlay-icon-wrapper, .justified-image-grid .jig-overlay-icon {position:absolute;top:0;right:0;bottom:0;left:0;} .justified-image-grid .jig-overflow, .jig-overflow div {cursor: pointer;} .jig-caption-wrapper{margin:0 !important;} </style><![endif]-->\r\n"; if ($this->settings['conditional_script_loading'] == 'yes') { add_action('wp_print_footer_scripts', array($this, 'jig_print_style'), 100); add_action('wp_print_footer_scripts', array($this, 'jig_print_script'), 100); if ($specialfx != 'off') { wp_enqueue_script('pixastic.custom.jig', plugins_url('js/pixastic.custom.jig.min.js', __FILE__), 'jquery', self::PLUGIN_VERSION, true); } if ($caption == 'below') { wp_enqueue_script('dotdotdot', plugins_url('js/jquery.dotdotdot.min.js', __FILE__), 'jquery', '1.7.4', true); } wp_enqueue_script('justified-image-grid', plugins_url('js/justified-image-grid-min.js', __FILE__), 'jquery', self::PLUGIN_VERSION, true); } else { $output .= $this->dynamic_script . $this->dynamic_style; } return $this->frontend_stop($output, false); }