Exemple #1
0
 function grve_gmap_shortcode($atts, $content)
 {
     $output = $el_class = '';
     extract(shortcode_atts(array('map_lat' => '51.516221', 'map_lng' => '-0.136986', 'map_height' => '280', 'map_marker' => '', 'map_zoom' => 14, 'margin_bottom' => '', 'el_class' => ''), $atts));
     wp_enqueue_script('grve-googleapi-script');
     wp_enqueue_script('grve-maps-script');
     $gmap_classes = array('grve-element', 'grve-map');
     if (!empty($el_class)) {
         array_push($gmap_classes, $el_class);
     }
     $gmap_class_string = implode(' ', $gmap_classes);
     $style = grve_osmosis_vce_build_margin_bottom_style($margin_bottom);
     if (empty($map_marker)) {
         $map_marker = get_template_directory_uri() . '/images/markers/markers.png';
     } else {
         $id = preg_replace('/[^\\d]/', '', $map_marker);
         $full_src = wp_get_attachment_image_src($id, 'full');
         $map_marker = $full_src[0];
     }
     $map_title = '';
     $data_map = 'data-lat="' . esc_attr($map_lat) . '" data-lng="' . esc_attr($map_lng) . '" data-zoom="' . esc_attr($map_zoom) . '"';
     $output .= '<div class="grve-map-wrapper">';
     $output .= '  <div style="display:none" class="grve-map-point" data-point-lat="' . esc_attr($map_lat) . '" data-point-lng="' . esc_attr($map_lng) . '" data-point-marker="' . esc_attr($map_marker) . '" data-point-title="' . esc_attr($map_title) . '"></div>';
     $output .= '  <div class="' . esc_attr($gmap_class_string) . '" ' . $data_map . ' style="' . $style . grve_osmosis_vce_build_dimension('height', $map_height) . '"></div>';
     $output .= '</div>';
     return $output;
 }
Exemple #2
0
 function grve_media_box_shortcode($atts, $content)
 {
     global $wp_embed;
     $output = $data = $retina_data = $el_class = '';
     extract(shortcode_atts(array('title' => '', 'media_type' => 'image', 'image' => '', 'retina_image' => '', 'video_popup' => '', 'video_link' => '', 'map_lat' => '51.516221', 'map_lng' => '-0.136986', 'map_height' => '280', 'map_marker' => '', 'map_zoom' => 14, 'title_link' => '', 'read_more_title' => '', 'align' => 'left', 'animation' => '', 'animation_delay' => '200', 'margin_bottom' => '', 'el_class' => ''), $atts));
     if (!empty($title_link)) {
         $href = vc_build_link($title_link);
         $url = $href['url'];
         if (!empty($href['target'])) {
             $target = $href['target'];
         } else {
             $target = "_self";
         }
     } else {
         $url = "#";
         $target = "_self";
     }
     $media_box_classes = array('grve-element', 'grve-box', 'grve-align-' . $align);
     if (!empty($animation)) {
         array_push($media_box_classes, 'grve-animated-item');
         array_push($media_box_classes, $animation);
         $data = ' data-delay="' . esc_attr($animation_delay) . '"';
     }
     if (!empty($el_class)) {
         array_push($media_box_classes, $el_class);
     }
     $media_box_classe_string = implode(' ', $media_box_classes);
     $style = grve_osmosis_vce_build_margin_bottom_style($margin_bottom);
     $output .= '<div class="' . esc_attr($media_box_classe_string) . '" style="' . $style . '"' . $data . '>';
     switch ($media_type) {
         case 'image':
         case 'image-video-popup':
             if (!empty($image)) {
                 $img_id = preg_replace('/[^\\d]/', '', $image);
                 $img_src = wp_get_attachment_image_src($img_id, 'full');
                 $image_dimensions = 'width="' . $img_src[1] . '" height="' . $img_src[2] . '"';
                 if (!empty($retina_image)) {
                     $img_retina_id = preg_replace('/[^\\d]/', '', $retina_image);
                     $img_retina_src = wp_get_attachment_image_src($img_retina_id, 'full');
                     $retina_data = ' data-at2x="' . esc_attr($img_retina_src[0]) . '"';
                 }
                 $alt = get_post_meta($img_id, '_wp_attachment_image_alt', true);
                 $alt = !empty($alt) ? esc_attr($alt) : '';
                 if ('image-video-popup' == $media_type && !empty($video_link)) {
                     $output .= '<div class="grve-media">';
                     $output .= '	<a class="grve-vimeo-popup grve-icon-video" href="' . $video_link . '">';
                     $output .= '		<img alt="' . $alt . '" src="' . esc_url($img_src[0]) . '" ' . $image_dimensions . $retina_data . '>';
                     $output .= '	</a>';
                     $output .= '</div>';
                 } else {
                     $output .= '<div class="grve-media">';
                     $output .= '  <img alt="' . $alt . '" src="' . esc_url($img_src[0]) . '" ' . $image_dimensions . $retina_data . '>';
                     $output .= '</div>';
                 }
             }
             break;
         case 'video':
             if (!empty($video_link)) {
                 $output .= '<div class="grve-media">';
                 $output .= $wp_embed->run_shortcode('[embed]' . $video_link . '[/embed]');
                 $output .= '</div>';
             }
             break;
         case 'map':
             wp_enqueue_script('grve-googleapi-script');
             wp_enqueue_script('grve-maps-script');
             if (empty($map_marker)) {
                 $map_marker = get_template_directory_uri() . '/images/markers/markers.png';
             } else {
                 $id = preg_replace('/[^\\d]/', '', $map_marker);
                 $full_src = wp_get_attachment_image_src($id, 'full');
                 $map_marker = $full_src[0];
             }
             $map_title = '';
             $data_map = 'data-lat="' . esc_attr($map_lat) . '" data-lng="' . esc_attr($map_lng) . '" data-zoom="' . esc_attr($map_zoom) . '"';
             $output .= '<div class="grve-media">';
             $output .= '  <div class="grve-map" ' . $data_map . ' style="' . $style . grve_osmosis_vce_build_dimension('height', $map_height) . '"></div>';
             $output .= '  <div style="display:none" class="grve-map-point" data-point-lat="' . esc_attr($map_lat) . '" data-point-lng="' . esc_attr($map_lng) . '" data-point-marker="' . esc_attr($map_marker) . '" data-point-title="' . esc_attr($map_title) . '"></div>';
             $output .= '</div>';
             break;
         default:
             break;
     }
     $output .= '  <div class="grve-box-content">';
     if (!empty($title_link)) {
         $output .= '    <a href="' . esc_url($url) . '" target="' . $target . '">';
     }
     $output .= '      <h5 class="grve-box-title">' . $title . '</h5>';
     if (!empty($title_link)) {
         $output .= '    </a>';
     }
     $output .= '    <p>' . $content . '</p>';
     if (!empty($read_more_title) && !empty($url)) {
         $output .= '    <a href="' . esc_url($url) . '" target="' . $target . '" class="grve-read-more">';
         $output .= $read_more_title;
         $output .= '</a>';
     }
     $output .= '  </div>';
     $output .= '</div>';
     return $output;
 }