Esempio n. 1
0
function flickr_shortcode_handler($atts)
{
    $atts = shortcode_atts(array('video' => 0, 'photo' => 0, 'show_info' => 0, 'w' => 400, 'h' => 300, 'secret' => 0, 'size' => 0), $atts, 'flickr');
    if (!empty($atts['video'])) {
        $showing = 'video';
        $src = $atts['video'];
    } elseif (!empty($atts['photo'])) {
        $showing = 'photo';
        $src = $atts['photo'];
    } else {
        return '';
    }
    if (is_ssl()) {
        $src = str_replace('http://', 'https://', $src);
    }
    if ($showing == 'video') {
        if (!is_numeric($src) && !preg_match('~^(https?:)?//([\\da-z\\-]+\\.)*?((static)?flickr\\.com|flic\\.kr)/.*~i', $src)) {
            return '';
        }
        if (preg_match("!photos/(([0-9a-zA-Z-_]+)|([0-9]+@N[0-9]+))/([0-9]+)/?\$!", $src, $m)) {
            $atts['photo_id'] = $m[4];
        } else {
            $atts['photo_id'] = $atts['video'];
        }
        if (!isset($atts['show_info']) || in_array($atts['show_info'], array('yes', 'true'))) {
            $atts['show_info'] = 'true';
        } elseif (in_array($atts['show_info'], array('false', 'no'))) {
            $atts['show_info'] = 'false';
        }
        if (isset($atts['secret'])) {
            $atts['secret'] = preg_replace('![^\\w]+!i', '', $atts['secret']);
        }
        return flickr_shortcode_video_markup($atts);
    } elseif ('photo' == $showing) {
        if (!preg_match('~^(https?:)?//([\\da-z\\-]+\\.)*?((static)?flickr\\.com|flic\\.kr)/.*~i', $src)) {
            return '';
        }
        $src = sprintf('%s/player/', untrailingslashit($src));
        return sprintf('<iframe src="%s" height="%s" width="%s"  frameborder="0" allowfullscreen webkitallowfullscreen mozallowfullscreen oallowfullscreen msallowfullscreen></iframe>', esc_url($src), esc_attr($atts['h']), esc_attr($atts['w']));
    }
}
Esempio n. 2
0
function flickr_shortcode_handler($atts)
{
    $atts = shortcode_atts(array('video' => 0, 'photo' => 0, 'show_info' => 0, 'w' => 400, 'h' => 300, 'secret' => 0, 'size' => 0), $atts);
    if (isset($atts['video'])) {
        $showing = 'video';
        $src = $atts['video'];
    } elseif (isset($atts['photo'])) {
        $showing = 'photo';
        $src = $atts['photo'];
    } else {
        return '';
    }
    if (preg_match("!photos/(([0-9a-zA-Z-_]+)|([0-9]+@N[0-9]+))/([0-9]+)/?\$!", $src, $m)) {
        $atts['photo_id'] = $m[4];
    } else {
        $atts['photo_id'] = $atts['video'];
    }
    if ($showing == 'video') {
        if (!isset($atts['show_info']) || in_array($atts['show_info'], array('yes', 'true'))) {
            $atts['show_info'] = 'true';
        } elseif (in_array($atts['show_info'], array('false', 'no'))) {
            $atts['show_info'] = 'false';
        }
        if (isset($atts['secret'])) {
            $atts['secret'] = preg_replace('![^\\w]+!i', '', $atts['secret']);
        }
        return flickr_shortcode_video_markup($atts);
    } else {
        return '';
    }
}