/** * Request server with token if defined * * @param string $url URL for request data * @param boolean $token use token from settings * * @return string received data */ public function get_feed($url) { $url = convert_to_https($url); return $this->real_fetcher->get_feed($url); }
/** * Envelope content with tag * used by shortcode 'peg_image' * * @param array $atts tag, class and style defined. * @param string $content * * @return string */ function image_shortcode($atts, $content) { // extract all of the variables from defaults/options with // any tag attribute overrides // go through any attributes and set string values of "false" // to boolean false to fix lazy evaluation issues $newAtts = array(); foreach ($atts as $key => $value) { if ($atts[$key] === 'false') { // set this attribute to boolean false $atts[$key] = false; } if (substr($key, 0, 3) == "pe2") { $newAtts['peg' . substr($key, 3)] = $atts[$key]; } else { $newAtts[$key] = $atts[$key]; } } $atts = $newAtts; /** * The following variables will be used in this scope * @see PicasaConfiguration->options for a description of $peg_XXX variables * @var $peg_caption boolean * @var $peg_img_align string * @var $peg_a_img_css string * @var $peg_a_img_style string * @var $peg_link string * @var $peg_relate_images boolean * @var $type string image or video * @var $peg_single_image_size string * @var $peg_large_limit boolean * @var $peg_single_video_size string * @var $href string the Picasa URL of the image/video * @var $peg_title boolean * @var $caption string the individual caption of the image/video * @var $peg_img_css string * @var $peg_img_style string * @var $alt string the alternative text for the img tag * @var $src string * @var $image_size string the size of the image */ // extract our attributes extract(shortcode_atts(array_merge(array('src' => '', 'href' => '', 'caption' => '', 'type' => '', 'alt' => '', 'limit' => '', 'hide_rest' => '', 'image_size' => ''), $this->configuration->get_options()), $atts)); // create align vars // for caption - align="alignclass" including alignnone also // else add alignclass to iclass $calign = ''; $iclass = array(); if ($peg_caption) { // captions have a surrounding div that must be aligned properly $calign = 'align="align' . $peg_img_align . '" '; } // also put the align variable on the image itself array_push($iclass, 'align' . $peg_img_align); if ($peg_a_img_css != null) { $aclass = ' ' . $peg_a_img_css; } else { $aclass = ''; } if ($peg_a_img_style != null) { $astyle = ' style="' . $peg_a_img_style . '"'; } else { $astyle = ''; } // generate the unique id if we're relating images $uniqid = 'post-' . get_the_ID(); // link and gallery additions $a_link_additions = ''; switch ($peg_link) { case 'thickbox': case 'thickbox_integrated': case 'thickbox_custom': $a_link_additions = 'class="thickbox' . $aclass . '"' . $astyle . ' '; if ($peg_relate_images) { // they have chosen to relate all of the images, use the post id $a_link_additions .= 'rel="' . $uniqid . '" '; } break; case 'lightbox': if ($peg_relate_images) { // they have chosen to relate all of the images, use the post id $a_link_additions = 'rel="lightbox-' . $uniqid . '" '; } else { // separate images without navigation $a_link_additions = 'rel="lightbox" '; } $a_link_additions .= 'class="' . $aclass . '"' . $astyle . ' '; break; case 'highslide': if ($peg_relate_images) { // they have chosen to relate all of the images, use the post id $a_link_additions = 'class="highslide' . $aclass . '"' . $astyle . ' onclick="return hs.expand(this,{ slideshowGroup: \'' . $uniqid . '\' })"'; } else { // separate images without navigation $a_link_additions = 'class="highslide' . $aclass . '"' . $astyle . ' onclick="return hs.expand(this)"'; } break; case 'photoswipe': $a_link_additions = 'class="photoswipe' . $aclass . '" '; if ($peg_relate_images) { // they've chosen to relate, use the post id $a_link_additions .= 'rel="' . $uniqid . '" '; } break; } // end switch $a_link_additions .= $astyle; // determine the type and then set the thumbnail url $amore = ''; $imore = ''; if ($type == 'image') { // use the image size $thumb_size = $peg_single_image_size; // set the link href to the large size. determine if the // size has been defined, or if we just use the default if ($peg_large_limit == null) { // none set, use a default $large_size = 's0'; } else { // use the large limit from the configuration $large_size = $peg_large_limit; } // create the a link, linking to the larger version of the image $a_href = preg_replace('/\\/(w|h|s)[0-9]+(-c-o|-c|-o|)\\//', '/' . $large_size . '/', $src); // Reduce the size correctly $new_size = $this->determine_image_size(explode('x', $image_size), $large_size); $a_link_additions = $a_link_additions . ' data-size="' . $new_size[0] . 'x' . $new_size[1] . '"'; // set the amore to our a_link_additions $amore = $a_link_additions; } else { // use the video size $thumb_size = $peg_single_video_size; // set the link href to the picasa HREF $a_href = $href; // set the amore to make it open in a new tab and mark it as a video // type, and not add in the a_link_additions configuration $amore .= ' target="_blank" type="video"'; $imore = ' type="video"'; } // end else for if we're displaying an image // determine width if captions are enabled if ($peg_caption) { // extract (or calculate) the width for the caption box if (preg_match('/(w|h|s)([0-9]+)(-c-o|-c|-o|)/', $thumb_size, $matches) > 0) { // we were able to match it, figure out what our width is if ($matches[1] == 'w') { // our width is this number $cwidth = $matches[2]; } elseif ($matches[1] == 's' && strpos($matches[3], '-c') !== false) { // our width is always = height in a square, we can use // the raw number $cwidth = $matches[2]; } else { // for height or uncropped square, we have no idea what the // width is going to be. This is a very tricky situation. // The width really needs to be determined via JavaScript. // Perform our best guess here (which is not a good one as // it only works for portrait photos), then include a // bit of JavaScript that will adjust the width appropriately // on page load $cwidth = round($matches[2] * 3 / 4); // set our variable to enable the JavaScript calculation $GLOBALS['peg_include_caption_width_correction_javascript'] = true; } } else { // unable to parse the thumb size, simply set to a numeric // value of something small, then enable the JavaScript to // calculate the width $cwidth = 75; // set our variable to enable the JavaScript calculation $GLOBALS['peg_include_caption_width_correction_javascript'] = true; } } // end if we need to calculate width for the caption // generate the URL for the thumbnail image $thumb_src = preg_replace('/\\/(w|h|s)[0-9]+(-c-o|-c|-o|)\\//', '/' . $thumb_size . '-o/', $src); // add our peg class to the image class $iclass[] = 'peg-photo'; // generate the other image attributes we need $ititle = $peg_title ? 'title="' . $caption . '" ' : ''; $iclass = implode(' ', $iclass); if ($peg_img_css) { $iclass .= ' ' . $peg_img_css; } if ($iclass) { $iclass = 'class="' . $iclass . '" '; } if ($peg_img_style) { $istyle = 'style="' . $peg_img_style . '" '; } else { $istyle = ''; } //Force SSL if needed if ($this->configuration->get_option('peg_force_ssl')) { $a_href = convert_to_https($a_href); $thumb_src = convert_to_https($thumb_src); } // create the HTML for the image tag $html = "<img src=\"{$thumb_src}\" alt=\"{$alt}\" {$ititle}{$iclass}{$istyle}{$imore} />"; // add the link? if ($peg_link != 'none') { // the image should also have a link, determine if this particular // link has been displayed already or not (to prevent multiple // copies related to each other from busting the navigation) if (in_array($a_href, $this->photos_displayed)) { // this photo has already been displayed, skip relating // it to the rest and instead make up a new relationship // for it so that we don't break the navigation $amore_this = str_replace($uniqid, uniqid(), $amore); } else { // this photo hasn't been displayed yet, it can be related // without issue $amore_this = $amore; } // store this photo in our list of displayed photos $this->photos_displayed[] = $a_href; // figure out what the link is if ($peg_link == 'picasa') { // the large_url gets switched for the href $a_href = $href; } // wrap the current image tag with the A tag, adding the "link" // attribute so the thickbox-custom can add the link to picasa $html = "<a href=\"{$a_href}\" link=\"{$href}\" {$ititle}{$amore_this}>{$html}</a>"; } // end if we need to add the link if ($peg_caption) { // add caption $html = "[caption id=\"\" {$calign} width=\"{$cwidth}\" caption=\"{$caption}\"]{$html}[/caption] "; } // return our processed shortcode with the image link return do_shortcode($html); }