/**
  * Fetches a url based on values set in the backend
  * @param array $option_array array that at least needs to contain the linking method and depending on that, the appropriate 2nd id value
  * @param string $keyprefix option set key that must be in front of every element key
  * @param string $inside if inside is passed it will be wrapped inside <a> tags with the href set to the previously returned link url
  * @param string $post_id if the function is called outside of the loop we might want to retrieve the permalink of a different post with this id
  * @return string url (with image inside <a> tag if the image string was passed)
  */
 function avia_get_link($option_array, $keyprefix, $inside = false, $post_id = false, $attr = "")
 {
     if (empty($option_array[$keyprefix . 'link'])) {
         $option_array[$keyprefix . 'link'] = "";
     }
     //check which value the link array has (possible are empty, lightbox, page, post, cat, url) and create the according link
     switch ($option_array[$keyprefix . 'link']) {
         case "lightbox":
             $url = avia_image_by_id($option_array[$keyprefix . 'image'], array('width' => 8000, 'height' => 8000), 'url');
             break;
         case "cat":
             $url = get_category_link($option_array[$keyprefix . 'link_cat']);
             break;
         case "page":
             $url = get_page_link($option_array[$keyprefix . 'link_page']);
             break;
         case "self":
             if (!is_singular() || $post_id != avia_get_the_ID() || !isset($option_array[$keyprefix . 'image'])) {
                 $url = get_permalink($post_id);
             } else {
                 $url = avia_image_by_id($option_array[$keyprefix . 'image'], array('width' => 8000, 'height' => 8000), 'url');
             }
             break;
         case "url":
             $url = $option_array[$keyprefix . 'link_url'];
             break;
         case "video":
             $video_url = $option_array[$keyprefix . 'link_video'];
             if (avia_backend_is_file($video_url, 'html5video')) {
                 $output = avia_html5_video_embed($video_url);
                 $class = "html5video";
             } else {
                 global $wp_embed;
                 $output = $wp_embed->run_shortcode("[embed]" . $video_url . "[/embed]");
                 $class = "embeded_video";
             }
             $output = "<div class='slideshow_video {$class}'>" . $output . "</div>";
             return $inside . $output;
             break;
         default:
             $url = $inside;
             break;
     }
     if (!$inside || $url == $inside) {
         return $url;
     } else {
         return "<a {$attr} href='" . $url . "'>" . $inside . "</a>";
     }
 }
 function widget($args, $instance)
 {
     global $avia_config;
     extract($args, EXTR_SKIP);
     echo $before_widget;
     $title = empty($instance['title']) ? '' : apply_filters('widget_title', $instance['title']);
     $count = empty($instance['count']) ? '' : $instance['count'];
     $cat = empty($instance['cat']) ? '' : $instance['cat'];
     $excerpt = empty($instance['excerpt']) ? '' : $instance['excerpt'];
     $image_size = isset($avia_config['widget_image_size']) ? $avia_config['widget_image_size'] : 'widget';
     if (!empty($title)) {
         echo $before_title . $title . $after_title;
     }
     if (empty($this->avia_term)) {
         $additional_loop = new WP_Query("cat=" . $cat . "&posts_per_page=" . $count);
     } else {
         $catarray = explode(',', $cat);
         if (empty($catarray[0])) {
             $new_query = array("posts_per_page" => $count, "post_type" => $this->avia_post_type);
         } else {
             if ($this->avia_new_query) {
                 $new_query = $this->avia_new_query;
             } else {
                 $new_query = array("posts_per_page" => $count, 'tax_query' => array(array('taxonomy' => $this->avia_term, 'field' => 'id', 'terms' => explode(',', $cat), 'operator' => 'IN')));
             }
         }
         $additional_loop = new WP_Query($new_query);
     }
     if ($additional_loop->have_posts()) {
         echo '<ul class="news-wrap image_size_' . $image_size . '">';
         while ($additional_loop->have_posts()) {
             $additional_loop->the_post();
             $format = "";
             if (empty($this->avia_post_type)) {
                 $format = $this->avia_post_type;
             }
             if (empty($format)) {
                 $format = get_post_format();
             }
             if (empty($format)) {
                 $format = 'standard';
             }
             $the_id = get_the_ID();
             $link = get_post_meta($the_id, '_portfolio_custom_link', true) != "" ? get_post_meta($the_id, '_portfolio_custom_link_url', true) : get_permalink();
             echo '<li class="news-content post-format-' . $format . '">';
             //check for preview images:
             $image = "";
             if (!current_theme_supports('force-post-thumbnails-in-widget')) {
                 $slides = avia_post_meta(get_the_ID(), 'slideshow', true);
                 if ($slides != "" && !empty($slides[0]['slideshow_image'])) {
                     $image = avia_image_by_id($slides[0]['slideshow_image'], $image_size, 'image');
                 }
             }
             if (current_theme_supports('post-thumbnails') && !$image) {
                 $image = get_the_post_thumbnail($the_id, $image_size);
             }
             $time_format = apply_filters('avia_widget_time', get_option('date_format') . " - " . get_option('time_format'), 'avia_newsbox');
             echo "<a class='news-link' title='" . get_the_title() . "' href='" . $link . "'>";
             $nothumb = !$image ? 'no-news-thumb' : '';
             echo "<span class='news-thumb {$nothumb}'>";
             echo $image;
             echo "</span>";
             if (empty($avia_config['widget_image_size']) || 'display title and excerpt' != $excerpt) {
                 echo "<strong class='news-headline'>" . get_the_title();
                 if ($time_format) {
                     echo "<span class='news-time'>" . get_the_time($time_format) . "</span>";
                 }
                 echo "</strong>";
             }
             echo "</a>";
             if ('display title and excerpt' == $excerpt) {
                 echo "<div class='news-excerpt'>";
                 if (!empty($avia_config['widget_image_size'])) {
                     echo "<a class='news-link-inner' title='" . get_the_title() . "' href='" . $link . "'>";
                     echo "<strong class='news-headline'>" . get_the_title() . "</strong>";
                     echo "</a>";
                     if ($time_format) {
                         echo "<span class='news-time'>" . get_the_time($time_format) . "</span>";
                     }
                 }
                 the_excerpt();
                 echo "</div>";
             }
             echo '</li>';
         }
         echo "</ul>";
         wp_reset_postdata();
     }
     echo $after_widget;
 }
示例#3
0
  * ... last apply the default wordpress filters to the content
  */
 $current_post['content'] = str_replace(']]>', ']]&gt;', apply_filters('the_content', $current_post['content']));
 /*
  * Now extract the variables so that $current_post['slider'] becomes $slider, $current_post['title'] becomes $title, etc
  */
 extract($current_post);
 /*
  * render the html:
  */
 echo "<div class='" . implode(" ", get_post_class('post-entry post-entry-type-' . $post_format . " " . $post_class . " " . $with_slider)) . "'>";
 //default link for preview images
 $link = get_permalink();
 //on single page replace the link with a fullscreen image
 if (is_singular()) {
     $link = avia_image_by_id(get_post_thumbnail_id(), 'large', 'url');
 }
 //echo preview image
 if (strpos($blog_style, 'big') !== false) {
     if ($slider) {
         $slider = '<a href="' . $link . '">' . $slider . '</a>';
     }
     if ($slider) {
         echo '<div class="big-preview ' . $blog_style . '">' . $slider . '</div>';
     }
 }
 if (!empty($before_content)) {
     echo '<div class="big-preview ' . $blog_style . '">' . $before_content . '</div>';
 }
 echo "<div class='blog-meta'>";
 $blog_meta_output = "";
 /**
  * 
  * The upload method renders a single upload element so users can add their own pictures
  * the script first gets the id of a hidden post that should store the image. if no post is set it will create one
  * then we check if a basic url based upload should be used or a more sophisticated id based for slideshows and feauted images, which need
  * the images resized automatically
  *
  * @param array $element the array holds data like type, value, id, class, description which are necessary to render the whole option-section
  * @return string $output the string returned contains the html code generated within the method
  */
 function upload($element)
 {
     global $post_ID;
     $output = "";
     $gallery_mode = false;
     $id_generated = false;
     $image_url = $element['std'];
     if (empty($element['button-label'])) {
         $element['button-label'] = "Upload";
     }
     //get post id of the hidden post that stores the image
     if (!empty($element['attachment-prefix'])) {
         if (empty($element['std']) && empty($element['no-attachment-id'])) {
             $element['std'] = uniqid();
             $id_generated = true;
         }
         $gallery_mode = true;
         $postId = avia_media::get_custom_post($element['attachment-prefix'] . $element['std']);
     } else {
         $postId = avia_media::get_custom_post($element['name']);
         if (is_numeric($element['std'])) {
             $image_url = wp_get_attachment_image_src($element['std'], 'full');
             $image_url = $image_url[0];
         }
     }
     //switch between normal url upload and advanced image id upload
     $mode = $prevImg = "";
     //video or image, advanced or default upload?
     if (isset($element['subtype'])) {
         $mode = ' avia_advanced_upload';
         if (!is_numeric($element['std']) && $element['std'] != '') {
             $prevImg = '<a href="#" class="avia_remove_image">remove</a><img src="' . AVIA_IMG_URL . 'icons/video.png" alt="" />';
         } else {
             if ($element['std'] != '') {
                 $prevImg = '<a href="#" class="avia_remove_image">remove</a>' . wp_get_attachment_image($element['std'], array(100, 100));
             }
         }
     } else {
         if (!preg_match('!\\.jpg$|\\.jpeg$|\\.ico$|\\.png$|\\.gif$!', $image_url) && $image_url != "") {
             $prevImg = '<a href="#" class="avia_remove_image">remove</a><img src="' . AVIA_IMG_URL . 'icons/video.png" alt="" />';
         } else {
             if ($image_url != '') {
                 $prevImg = '<a href="#" class="avia_remove_image">remove</a><img src="' . $image_url . '" alt="" />';
             }
         }
     }
     if ($gallery_mode) {
         $image_url_array = array();
         $attachments = get_children(array('post_parent' => $postId, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order ID'));
         foreach ($attachments as $key => $attachment) {
             $image_url_array[] = avia_image_by_id($attachment->ID, array('width' => 80, 'height' => 80));
         }
         $output .= "<div class='avia_thumbnail_container'>";
         if (isset($image_url_array[0])) {
             foreach ($image_url_array as $key => $img) {
                 $output .= "<div class='avia_gallery_thumb'><div class='avia_gallery_thumb_inner'>" . $img . "</div></div>";
             }
             $output .= "<div class='avia_clear'></div>";
         }
         $output .= "</div>";
     }
     $data = "";
     $upload_class = "avia_uploader";
     global $wp_version;
     if (version_compare($wp_version, '3.5', '>=') && empty($element['force_old_media']) && empty($element['subtype'])) {
         $upload_class = "avia_uploader_35";
         if (empty($element['data'])) {
             $element['data'] = array('target' => $element['id'], 'title' => $element['name'], 'type' => 'image', 'button' => $element['label'], 'class' => 'media-frame av-media-frame-image-only', 'frame' => 'select', 'state' => 'av_select_single_image', 'fetch' => 'url');
         }
         foreach ($element['data'] as $key => $value) {
             if (is_array($value)) {
                 $value = implode(", ", $value);
             }
             $data .= " data-{$key}='{$value}' ";
         }
     }
     $output .= '<div class="avia_upload_container avia_upload_container_' . $postId . $mode . '">';
     $output .= '	<span class="avia_style_wrap avia_upload_style_wrap">';
     $output .= '	<input type="text" class="avia_upload_input ' . $element['class'] . '" value="' . $element['std'] . '" name="' . $element['id'] . '" id="' . $element['id'] . '" />';
     $output .= '	<a ' . $data . ' href="#' . $postId . '" class="avia_button ' . $upload_class . '" title="' . $element['name'] . '" id="avia_upload' . $element['id'] . '">' . $element['button-label'] . '</a>';
     $output .= '	</span>';
     $output .= '	<div class="avia_preview_pic" id="div_' . $element['id'] . '">' . $prevImg . '</div>';
     $output .= '	<input class="avia_upload_insert_label" type="hidden" value="' . $element['label'] . '" />';
     if ($gallery_mode) {
         $output .= '	<input class="avia_gallery_mode" type="hidden" value="' . $postId . '" />';
     }
     $output .= '</div>';
     return $output;
 }
 function avia_ajax_get_gallery()
 {
     #backend single post/page/portfolio item: add multiple preview pictures. get a preview picture via ajax request and display it
     $postId = (int) $_POST['attachment_id'];
     $output = "";
     $image_url_array = array();
     $attachments = get_children(array('post_parent' => $postId, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order ID'));
     foreach ($attachments as $key => $attachment) {
         $image_url_array[] = avia_image_by_id($attachment->ID, array('width' => 80, 'height' => 80));
     }
     if (isset($image_url_array[0])) {
         foreach ($image_url_array as $key => $img) {
             $output .= "<div class='avia_gallery_thumb'><div class='avia_gallery_thumb_inner'>" . $img . "</div></div>";
         }
         $output .= "<div class='avia_clear'></div>";
     }
     die($output);
 }
示例#6
0
 $output .= "<div class='content_slider autoslide_false'>";
 while ($my_query->have_posts()) {
     $my_query->the_post();
     if ($post->ID != $this_id) {
         $reladed_posts = true;
         $slidecount++;
         if ($count == 1) {
             $output .= "<div class='single_slide single_slide_nr_{$slidecount}'>";
         }
         $image = "<span class='related_posts_default_image'></span>";
         $slides = avia_post_meta(get_the_ID(), 'slideshow', true);
         //check if a preview image is set
         if ($slides != "" && !empty($slides[0]['slideshow_image'])) {
             //check for image or video
             if (is_numeric($slides[0]['slideshow_image'])) {
                 $image = avia_image_by_id($slides[0]['slideshow_image'], 'related', 'image');
             } else {
                 $image = "<span class='related_posts_default_image related_posts_video'></span>";
             }
         }
         $output .= "<div class='relThumb relThumb" . $count . "'>\n";
         $output .= "<a href='" . get_permalink() . "' class='relThumWrap noLightbox'>\n";
         $output .= "<span class='related_image_wrap'>";
         $output .= "<span class='rounded_corner rctl'></span>";
         $output .= "<span class='rounded_corner rctr'></span>";
         $output .= "<span class='rounded_corner rcbl'></span>";
         $output .= "<span class='rounded_corner rcbr'></span>";
         $output .= $image;
         $output .= "</span>\n";
         $output .= "<span class='relThumbTitle'>\n";
         $output .= "<strong class='relThumbHeading'>" . avia_backend_truncate(get_the_title(), 50) . "</strong>\n";
示例#7
0
 function _build_xml_slides($element)
 {
     global $avia_config;
     $text = $url = $title = "";
     if (!empty($element['slideshow_caption'])) {
         if (!empty($element['slideshow_caption_title'])) {
             $title = '&lt;h1&gt;' . $element['slideshow_caption_title'] . '&lt;/p&gt;';
         }
         $text = "<Text>" . $title . "&lt;p&gt;" . strip_tags($element['slideshow_caption']) . "&lt;/p&gt;</Text>";
     }
     //apply links to the image if thats what the user wanted
     $url = avia_get_link($element, 'slideshow_', false, $this->post_id);
     if ($url) {
         $url = "<Hyperlink URL='" . $url . "'  />";
     }
     if (is_numeric($element['slideshow_image'])) {
         $this->slides_xml .= '<Image Source="' . avia_image_by_id($element['slideshow_image'], 'featured', 'url') . '" Title="' . $element['slideshow_caption_title'] . '">';
         $this->slides_xml .= $text . $url;
         $this->slides_xml .= '</Image>';
     } else {
         if (avia_backend_is_file($element['slideshow_image'], 'html5video') || avia_backend_is_file($element['slideshow_image'], array('swf'))) {
             preg_match("!^(.+?)(?:\\.([^.]+))?\$!", $element['slideshow_image'], $path_split);
             $tag = 'Video';
             if ($path_split[2] == 'swf') {
                 $tag = 'Flash';
             }
             $this->slides_xml .= '<' . $tag . ' Source="' . $element['slideshow_image'] . '" Title="' . $element['slideshow_caption_title'] . '" Width="' . $avia_config['imgSize']['featured']['width'] . '" Height="' . $avia_config['imgSize']['featured']['height'] . '" Autoplay="true" >';
             $image = $path_split[1] . '.jpg';
             $checkpath = $path_split[1] . '-' . $avia_config['imgSize']['featured']['width'] . 'x' . $avia_config['imgSize']['featured']['height'] . '.jpg';
             if (@file_get_contents($checkpath, 0, NULL, 0, 1)) {
                 $image = $checkpath;
             }
             $this->slides_xml .= '<Image Source="' . $image . '" />';
             $this->slides_xml .= '</' . $tag . '>';
         }
     }
 }
示例#8
0
//reset wordpress query in case we modified it
wp_reset_query();
/**
 *  The footer default dummy widgets are defined in folder includes/register-widget-area.php
 *  If you add a widget to the appropriate widget area in your wordpress backend the 
 *  dummy widget will be removed and replaced by the real one previously defined
 */
if (is_front_page() || avia_get_option('footer_logo_where') == 'everywhere') {
    $attachment_holder = avia_get_post_by_title("avia_smart-logo-gallery");
}
if (!empty($attachment_holder['ID'])) {
    $attachments = get_children(array('post_parent' => $attachment_holder['ID'], 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order ID'));
    if (is_array($attachments)) {
        echo "<div class='footer-logos'><div class='container'>";
        foreach ($attachments as $key => $attachment) {
            echo avia_image_by_id($attachment->ID);
        }
        echo "</div></div>";
    }
}
?>
			
			
			
			
			
			<!-- ####### FOOTER CONTAINER ####### -->
			<div class='container_wrap' id='footer'>
				<div class='container'>
				
					<?php 
示例#9
0
<?php

global $avia_config;
if (isset($avia_config['new_query'])) {
    query_posts($avia_config['new_query']);
}
// check if we got posts to display:
if (have_posts()) {
    $first = true;
    while (have_posts()) {
        the_post();
        //check for preview images:
        $image = "";
        $slides = avia_post_meta('slideshow');
        if (is_array($slides) && !empty($slides[0]['slideshow_image'])) {
            $image = avia_image_by_id($slides[0]['slideshow_image'], 'widget', 'image');
        }
        if (!$first) {
            echo "<div class='hr'></div>";
        }
        echo "<a class='post-entry news-content' title='" . get_the_title() . "' href='" . get_permalink() . "'>";
        echo "<span class='news-link'>";
        if ($image) {
            echo "<span class='news-thumb'>";
            echo $image;
            echo "</span>";
        }
        echo "<strong class='news-headline'>" . get_the_title();
        echo "<span class='news-time'>" . get_the_time("F j, Y, g:i a") . "</span>";
        echo "</strong>";
        echo "</span>";