Exemple #1
0
 /**
  * Shortcode callback function.
  *
  * @return string
  */
 protected function do_shortcode()
 {
     extract($this->extract());
     $content = preg_replace('#^<\\/p>|<p>$#', '', $content);
     // Compose final HTML id attribute
     $final_id = strlen($id) ? $id : 'placeholder-counter-' . $this->get_counter();
     // Compose final HTML class attribute
     $final_class = array('g1-placeholder');
     $final_class = array_merge($final_class, explode(' ', $class));
     // Determine width and height
     if (strlen($size)) {
         list($width, $height) = g1_get_image_dimensions($size);
         $value = array('width' => $width, 'height' => $height);
         // Apply custom filters
         $value = apply_filters('g1_shortcode_placeholder_size', $value, $size);
         $width = $value['width'];
         $height = $value['height'];
     }
     $width = absint($width);
     $width = $width ? $width : 1;
     $height = absint($height);
     $height = $height ? $height : 1;
     if ($height == 9999) {
         $height = absint(round($width * (9 / 16)));
     }
     $icon = strlen($icon) ? '<i class="icon-' . sanitize_html_class($icon) . '"></i>' : '';
     $out = '<span ' . 'id="' . esc_attr($final_id) . '" ' . 'class="' . sanitize_html_classes($final_class) . '" ' . 'style="width:' . $width . 'px;" ' . '>' . '<span class="g1-inner" style="padding-bottom:' . $height / $width * 100 . '%;">' . '</span>' . $icon . '</span>';
     return $out;
 }
Exemple #2
0
 protected static function format_oEmbed($url, $width, $height, $size)
 {
     global $wp_embed;
     if (!empty($width) && !empty($height)) {
         $embed = $wp_embed->run_shortcode('[embed height="' . $height . '" width="' . $width . '"]' . esc_url($url) . '[/embed]');
     } else {
         if (!empty($size)) {
             list($width, $height) = g1_get_image_dimensions($size);
             $embed = $wp_embed->run_shortcode('[embed height="' . $height . '" width="' . $width . '"]' . esc_url($url) . '[/embed]');
         } else {
             $embed = $wp_embed->run_shortcode('[embed]' . esc_url($url) . '[/embed]');
         }
     }
     $embed = do_shortcode($embed);
     return $embed;
 }
Exemple #3
0
 /**
  * Captures the HTML code for the video post format
  *
  * @param   Post $post
  * @param   string $size Image size name
  *
  * @return  string
  */
 function g1_capture_post_video($post_id, $size)
 {
     $out = '';
     $url_embed = get_post_meta($post_id, '_format_video_embed', true);
     $post = get_post($post_id);
     if (empty($url_embed)) {
         if (preg_match('/^http:\\/\\/[^\\s]+/', $post->post_content, $matches)) {
             $url_embed = $matches[0];
         }
     }
     if (empty($url_embed)) {
         if (preg_match('/^\\[.+\\]/', $post->post_content, $matches)) {
             $url_embed = $matches[0];
         }
     }
     if (!empty($url_embed)) {
         list($width, $height) = g1_get_image_dimensions($size);
         if (is_html_code($url_embed)) {
             $out = '[fluid_wrapper width="' . $width . '" height="' . $height . '"]' . $url_embed . '[/fluid_wrapper]';
         } else {
             global $wp_embed;
             $embed = $wp_embed->run_shortcode('[embed height="' . $height . '" width="' . $width . '"]' . esc_url($url_embed) . '[/embed]');
             $out = $embed;
         }
     }
     return $out;
 }