Example #1
0
 /**
  * Function to be run when migrating to a WordPress version after 3.6.
  *
  * - Post format adaptation: image, link, video, audio, quote
  *
  * @return void
  */
 function thb_wp_migration_36()
 {
     $posts = get_posts(array('posts_per_page' => -1, 'post_status' => array('image', 'link', 'audio', 'video', 'quote')));
     $posts = (array) $posts;
     if (count($posts) > 0) {
         foreach ($posts as $post) {
             $format = get_post_format($post->ID);
             switch ($format) {
                 case 'image':
                     $featured_image = thb_get_featured_image($post->ID);
                     if (!empty($featured_image)) {
                         update_post_meta($post->ID, '_format_image', $featured_image);
                         // delete_post_meta($post->ID, '_thumbnail_id');
                     }
                     break;
                 case 'link':
                     $link_url = thb_get_post_meta($post->ID, 'link_url');
                     if (!empty($link_url)) {
                         update_post_meta($post->ID, '_format_link_url', $link_url);
                         // delete_post_meta($post->ID, THB_META_KEY . 'link_url');
                     }
                     break;
                 case 'video':
                 case 'audio':
                     $url = thb_get_post_meta($post->ID, $format . '_url');
                     if (!empty($url)) {
                         update_post_meta($post->ID, '_format_' . $format . '_embed', $url);
                         // delete_post_meta($post->ID, THB_META_KEY . $format . '_url');
                     }
                     break;
                 case 'quote':
                     $quote_text = thb_get_post_meta($post->ID, 'quote');
                     $quote_url = thb_get_post_meta($post->ID, 'quote_url');
                     $quote_url = str_replace('http://', '', $quote_url);
                     $quote_author = thb_get_post_meta($post->ID, 'quote_author');
                     wp_update_post(array('ID' => $post->ID, 'post_content' => $quote_text));
                     update_post_meta($post->ID, '_format_quote_source_url', $quote_url);
                     update_post_meta($post->ID, '_format_quote_source_name', $quote_author);
                     // delete_post_meta($post->ID, THB_META_KEY . 'quote');
                     // delete_post_meta($post->ID, THB_META_KEY . 'quote_url');
                     // delete_post_meta($post->ID, THB_META_KEY . 'quote_author');
                     break;
             }
             wp_save_post_revision($post->ID);
         }
     }
 }
<?php

$post_id = thb_get_page_ID();
$post_layout = thb_get_post_meta($post_id, 'single_layout');
$image_size = '';
if ($post_id) {
    $is_sidebar = thb_is_page_sidebar_active();
} else {
    $is_sidebar = function_exists('dynamic_sidebar') && is_active_sidebar('post-sidebar');
}
if ($is_sidebar) {
    $image_size = 'thumb-760-cropped';
} else {
    $image_size = 'large-cropped';
}
$post_featured_image = thb_get_featured_image(get_the_ID(), $image_size);
$post_gallery = thb_get_post_meta(get_the_ID(), 'gallery_shortcode');
?>

<header class="item-header<?php 
if (!empty($post_gallery)) {
    ?>
 w-featured-image<?php 
}
?>
">
	<h1>
		<a href="<?php 
the_permalink();
?>
" rel="permalink"><?php 
if (have_posts()) {
    while (have_posts()) {
        the_post();
        ?>
			<?php 
        $slideshow = new THB_Collection($thb_page_id, 'work_slide');
        $slideshow->setSlidesImagesClickable();
        $slideshow->setSize('large');
        ?>

			<div class="single-work-slideshow-container">
			<?php 
        if (count($slideshow->getSlides()) > 0) {
            ?>
				<?php 
            if (thb_get_featured_image($thb_page_id) != '') {
                $slideshow->addCoverSlide(get_post_thumbnail_id($thb_page_id));
            }
            thb_get_template_part('config/modules/core/slideshows/submodules/flexslider/templates/slideshow', array('slideshow' => $slideshow, 'meta' => array('flexslider_smoothHeight' => '1', 'slideshowHeight' => '0', 'flexslider_effects' => 'fade', 'transition_speed' => 0.25, 'delay' => 4), 'id' => 'thb-single-work-slideshow'));
            ?>
			<?php 
        } else {
            ?>
				<?php 
            thb_post_format_image_markup(array('full' => thb_get_post_thumbnail_src($thb_page_id, 'full'), 'scaled' => thb_get_post_thumbnail_src($thb_page_id, 'large-cropped')));
            ?>
			<?php 
        }
        ?>
			</div>
		<?php 
Example #4
0
<li id="post-<?php 
the_ID();
?>
" <?php 
thb_portfolio_post_class();
?>
 <?php 
thb_portfolio_item_datafilters();
?>
>
	<a href="<?php 
echo thb_portfolio_item_permalink();
?>
" rel="bookmark" class="work-thumb">
		<?php 
if (($fi = thb_get_featured_image('full')) != '') {
    ?>
			<img src="<?php 
    echo $fi;
    ?>
" alt="">
		<?php 
}
?>

		<div class="thb-work-overlay">
			<div class="overlay-wrapper">
				<div class="work-data">
					<h3><?php 
the_title();
?>
Example #5
0
/**
 * Ottieni le immagini delle ultime tre ricette inserite.
 *
 * @return array
 */
function thb_get_ricette_images()
{
    $args = array('post_type' => 'ricetta', 'post_status' => 'publish', 'posts_per_page' => 3);
    $images = array();
    $ricette = get_posts($args);
    foreach ($ricette as $ricetta) {
        $images[] = thb_get_featured_image('medium', $ricetta->ID);
    }
    return $images;
}
 /**
  * Retrieve the collection items from a specific post type.
  *
  * @return void
  */
 protected function retrievePostSlides()
 {
     $args = thb_post_type_query_args('slideshows', $this->_id);
     /**
      * Default arguments
      */
     $defaultArgs = array('paged' => 1, 'meta_key' => '_thumbnail_id', 'post_type' => $this->_type, 'posts_per_page' => '-1');
     $args = thb_array_asum($defaultArgs, $args);
     foreach (get_posts($args) as $item) {
         $thumb_id = get_post_thumbnail_id($item->ID);
         $this->_slides[] = array('post_id' => $item->ID, 'id' => $thumb_id, 'url' => thb_image_get_size($thumb_id, $this->_size), 'full' => thb_get_featured_image($item->ID, 'full'), 'thumb' => thb_get_featured_image($item->ID, $this->_thumbSize), 'caption' => '', 'type' => 'image', 'link' => false);
     }
 }
<?php

/**
 * Slides
 */
$slideshow = new THB_Collection($id, 'work_slide');
$slideshow->setSize('full');
if (thb_get_featured_image($id) != '') {
    $slideshow->addCoverSlide(get_post_thumbnail_id($id));
}
$slides = $slideshow->getSlides();
/**
 * Image size
 */
$image_size = $slideshow->getSize();
/**
 * Class
 */
$class = array('cycle-slideshow');
if (count($slides) > 1) {
    $class[] = 'w-cycle-nav';
}
?>

<?php 
if (count($slides) > 1) {
    ?>
	<a href="#" id="thb-slideshow_prev">
		<?php 
    echo __('Previous', 'thb_text_domain');
    ?>
Example #8
0
 function thb_get_home_slides()
 {
     $home_slides_raw = thb_duplicable_get('home_page_slide', thb_get_page_ID());
     $home_slides = array();
     $image_size = 'large';
     $i = 0;
     foreach ($home_slides_raw as $slide) {
         $slide = $slide['value'];
         $home_slide = (object) array();
         $home_slide->index = $i;
         $home_slide->big_text = '';
         $home_slide->small_text = '';
         $home_slide->btn_url = '';
         $home_slide->btn_text = '';
         $home_slide->bg_picture = '';
         $home_slide->bg_color = '';
         $home_slide->bg_opacity = '0';
         $home_slide->class = '';
         $home_slide->post_id = $slide['post_id'];
         if (!empty($home_slide->post_id)) {
             $post = get_post($home_slide->post_id);
             if ($post) {
                 $home_slide->big_text = $post->post_title;
                 $home_slide->small_text = $post->post_excerpt;
                 $home_slide->btn_url = get_permalink($home_slide->post_id);
                 $home_slide->btn_text = __('More', 'thb_text_domain');
                 $home_slide->bg_picture = thb_get_featured_image($home_slide->post_id, $image_size);
             }
         }
         if (!empty($slide['big_text'])) {
             $home_slide->big_text = $slide['big_text'];
         }
         if (!empty($slide['small_text'])) {
             $home_slide->small_text = $slide['small_text'];
         }
         if (!empty($slide['btn_url'])) {
             $home_slide->btn_url = $slide['btn_url'];
         }
         if (!empty($slide['btn_text'])) {
             $home_slide->btn_text = $slide['btn_text'];
         }
         if (!empty($slide['id'])) {
             $home_slide->bg_picture = thb_image_get_size($slide['id'], $image_size);
         }
         $home_slide->bg_color = $slide['bg_color'];
         $home_slide->bg_opacity = $slide['bg_opacity'];
         $is_valid_solid_background = $home_slide->bg_color != '';
         if ($home_slide->bg_picture == '') {
             $home_slide->bg_opacity = 1;
         }
         if (!empty($slide['class'])) {
             $home_slide->class = $slide['class'];
         }
         $home_slides[] = $home_slide;
         $i++;
     }
     return $home_slides;
 }
 /**
  * Get the post format image source code or image URL.
  *
  * @param String $size The image size
  * @return Mixed An array with two keys 'full' and 'scaled', or an HTML string.
  */
 function thb_get_post_format_image_src($size = 'large')
 {
     $post_id = get_the_ID();
     $image = '';
     $src = array('full' => '', 'scaled' => '');
     // if( thb_is_wordpress_version_before(3.6) ) {
     // Legacy
     $src['full'] = thb_get_featured_image($post_id, 'full');
     $src['scaled'] = thb_get_featured_image($post_id, $size);
     // }
     // else {
     // 	// WP 3.6+
     // 	$image = get_post_meta($post_id, '_format_image', true);
     // 	if( thb_text_startsWith($image, 'http') ) {
     // 		// URL
     // 		$attachment_id = thb_image_get_attachment_id($image);
     // 		if( $attachment_id ) {
     // 			// Image from media library
     // 			$src['full'] = $image;
     // 			$src['scaled'] = thb_image_get_size($attachment_id, $size);
     // 		}
     // 		else {
     // 			// Image from somewhere else
     // 			$src['full'] = $image;
     // 			$src['scaled'] = $image;
     // 		}
     // 	}
     // 	else {
     // 		return $image;
     // 	}
     // }
     return $src;
 }
Example #10
0
<ul id="thb-portfolio-container">

	<?php 
thb_works_query();
if (have_posts()) {
    $i = 1;
    while (have_posts()) {
        the_post();
        ?>

		<?php 
        global $post;
        $work_id = get_the_ID();
        $work_featured_image = thb_get_featured_image($work_id, $work_image_size);
        $work_categories = wp_get_object_terms($work_id, 'portfolio_categories');
        $itemclass = $cats = array();
        $itemclass = thb_get_post_classes($i, array(''), $num_cols);
        if (empty($work_featured_image)) {
            $itemclass[] = 'wout-featured-image';
        }
        foreach ($work_categories as $cat) {
            $itemclass[] = $cat->slug;
            $cats[] = $cat->name;
        }
        ?>
		<?php 
        thb_post_before();
        ?>

		<li class="item <?php 
        echo implode(" ", $itemclass);