Ejemplo n.º 1
0
 /**
  * get_post
  *
  * @return mixed
  */
 protected function get_post()
 {
     if (empty($this->post)) {
         $this->post = \Timber::get_post();
     }
     return $this->post;
 }
Ejemplo n.º 2
0
 function testCommentCountZero()
 {
     $quote = 'Named must your fear be before banish it you can.';
     $post_id = $this->factory->post->create(array('post_content' => $quote));
     $post = Timber::get_post($post_id);
     $this->assertEquals(0, $post->get_comment_count());
 }
 function testGetPostsFromSlug()
 {
     $post_id = $this->factory->post->create();
     $post = Timber::get_post($post_id);
     $str = $post->post_name;
     $post = Timber::get_post($str);
     $this->assertEquals($post_id, $post->ID);
 }
Ejemplo n.º 4
0
 public function featured_testimonial()
 {
     $cats = wp_get_post_terms($this->ID, 'areas');
     //print_r($cats);
     $tax = array(array('taxonomy' => 'areas', 'field' => 'slug', 'terms' => $cats[0]->slug, 'operator' => 'IN'));
     //print_r($tax);
     $args = array('post_type' => 'testimonials', 'tax_query' => $tax, 'orderby' => 'rand', 'numberposts' => 1);
     return Timber::get_post($args);
 }
Ejemplo n.º 5
0
 /**
  * paypal_item_shortcode
  *
  */
 public function paypal_item_shortcode($atts)
 {
     $atts = shortcode_atts(array('id' => null), $atts);
     if ($atts['id']) {
         $item = \Timber::get_post($atts['id']);
         if ($item->post_type === 'paypal_item') {
             $account = array('email' => get_field('paypal_email', 'option'), 'currency' => get_field('paypal_currency', 'option'), 'location' => get_field('paypal_location', 'option'));
             return \Timber::compile('paypal-item.twig', array('paypal_item' => $item, 'paypal_account' => $account));
         }
     }
 }
Ejemplo n.º 6
0
<?php

$post = new TimberPost();
$data = Timber::get_context();
$related_posts = yarpp_get_related();
if (!empty($related_posts)) {
    foreach ($related_posts as $related_post) {
        $timber_related_posts[] = Timber::get_post($related_post->ID);
    }
    $data['related_posts'] = $timber_related_posts;
}
$data['post'] = $post;
$data['author_image'] = get_lazyloadxt_html(get_wp_user_avatar($post->author->ID, 150));
Timber::render(array('single.twig'), $data);
Ejemplo n.º 7
0
$project_slug = get_query_var('project');
if (!empty($project_slug)) {
    $projecte = get_page_by_path($project_slug, OBJECT, 'projecte');
    $projecte = new TimberPost($projecte->ID);
    $content_title = 'Col·laboreu en el projecte ' . $projecte->post_title;
    $projecte->project_requirements = apply_filters('the_content', $projecte->project_requirements);
    $projecte->lectures_recomanades = apply_filters('the_content', $projecte->lectures_recomanades);
    $context_filterer = new SC_ContextFilterer();
    $context = $context_filterer->get_filtered_context(array('title' => $content_title . '| Softcatalà'));
    $context['projecte'] = $projecte;
    $context['steps'] = $projecte->get_field('steps');
    $templates = array('plantilla-steps-single.twig');
    $args = array('meta_query' => array(get_meta_query_value('projectes', $projecte->ID, 'like', '')));
    $context['membres'] = get_users($args);
} else {
    $post = Timber::get_post();
    $profile = $post->get_field('perfil');
    $profile_label = get_field_object('perfil', $post->ID);
    $all_acf_data = get_field_objects($post->ID);
    $content_title = 'Col·laboreu amb nosaltres: ' . $profile_label['choices'][$profile];
    if (false === $profile || empty($profile)) {
        wp_redirect('/col·laboreu/', 302);
    }
    $project_args = array('tax_query' => array(array('taxonomy' => 'ajuda-projecte', 'field' => 'slug', 'terms' => $profile), array('taxonomy' => 'classificacio', 'field' => 'slug', 'terms' => 'arxivat', 'operator' => 'NOT IN')));
    $projects = $sc_types['projectes']->get_sorted_projects($project_args);
    $context = Timber::get_context();
    $context['projectes'] = $projects;
    $context['steps'] = $post->get_field('steps');
}
$post = new TimberPost();
$context['post'] = $post;
Ejemplo n.º 8
0
 function testGetPostPreview()
 {
     $editor_user_id = $this->factory->user->create(array('role' => 'editor'));
     wp_set_current_user($editor_user_id);
     $post_id = $this->factory->post->create(array('post_author' => $editor_user_id));
     _wp_put_post_revision(array('ID' => $post_id, 'post_content' => 'New Stuff Goes here'), true);
     $_GET['preview'] = true;
     $_GET['preview_id'] = $post_id;
     $the_post = Timber::get_post($post_id);
     $this->assertEquals('New Stuff Goes here', $the_post->post_content);
 }
Ejemplo n.º 9
0
<?php

get_header();
/*
Template Name: Coaches
*/
$context = array();
// $context = Timber::get_context();
// $post = new TimberPost();
$context['hulk'] = Timber::get_post(94);
$context['posts'] = $post;
Timber::render('hulk-enterprises.twig', $context);
// Timber::render( array( 'page-' . $post->post_name . '.twig', 'coaches.twig' ), $context );
?>


			
			<!-- <div id="content"> -->
			
				<!-- <div id="inner-content" class="row"> -->
			
<!-- 				    <div id="main" class="large-12 medium-12 columns" role="main">
					
				
					    


					    					
    				</div> -->
    				 <!-- end #main -->
    
Ejemplo n.º 10
0
    $billboard_ids[] = $bb->ID;
    $bb->billboard = new TimberImage($bb->billboard);
    if (isset($bb->hero_tease)) {
        $bb->hero_tease = new TimberImage($bb->hero_tease);
    }
    $billboards[] = $bb;
}
// $data['billboards'] = array_slice($billboards, 0, 5);
// $data['plist'] = array_slice($billboards, 5);
$data['billboards'] = $billboards;
$data['clients'] = Timber::get_posts(array('post_type' => 'portfolio', 'numberposts' => -1, 'post__not_in' => $billboard_ids));
$portfolio_client_names = array();
foreach ($data['clients'] as $client) {
    $portfolio_client_names[] = $client->client_name;
}
$client_list = Timber::get_post('client-list');
$client_list = explode("\n", $client_list->post_content);
$client_list = array_unique($client_list);
foreach ($client_list as &$client) {
    $client = trim($client);
}
$data['clients'] = array_merge($data['clients'], $client_list);
$clients = array();
$used_client_names = array();
foreach ($data['clients'] as $client) {
    if (is_string($client)) {
        $client_name = $client;
        $new_client = new stdClass();
        $new_client->client_name = $client_name;
        if (!in_array($client_name, $used_client_names)) {
            $used_client_names[] = $client_name;
Ejemplo n.º 11
0
$context = Timber::get_context();
$post = new TimberPost();
$context['post'] = $post;
global $paged;
if (!isset($paged) || !$paged) {
    $paged = 1;
}
$custom_args = array('post_status' => 'publish', 'paged' => $paged, 'meta_query' => array(array('key' => '_show_front_page', 'value' => 'yes', 'compare' => '=')));
$my_args = new WP_Query($custom_args);
// echo "<pre>";
// print_r($my_args);
// echo "</pre>";
//$my_query= new WP_Query($custom_args);
$context['homepageposts'] = Timber::get_posts($custom_args);
$context['clients'] = Timber::get_posts('post_type=clients');
$get_tour_page_id = get_post_meta($post->ID, '_my_meta_value_key', true);
if (!empty($get_tour_page_id) && is_numeric($get_tour_page_id)) {
    $context['tour_data'] = Timber::get_post($get_tour_page_id);
}
$context['pagination'] = Timber::get_pagination();
$context['gallery'] = Timber::get_posts('post_type=gallery');
$context['gallery_archieve_link'] = site_url() . '/gallery';
$templates = array('page-' . $post->post_name . '.twig', 'page.twig');
$context['testimonials'] = Timber::get_posts('post_type=testimonial&order=desc&order_by=date');
//Timber::render( array( 'page-' . $post->post_name . '.twig', 'page.twig' ), $context );
/* Snippets */
if (is_home() || is_front_page()) {
    $templates = array('home.twig');
}
Timber::render($templates, $context);
/* End of snippets */
Ejemplo n.º 12
0
<?php

get_header();
?>



<?php 
$context = array();
$context['home'] = Timber::get_post(46);
$context['posts'] = Timber::get_posts();
$context['hero_logo'] = get_stylesheet_directory_uri() . '/library/images/fe-fitness-logo-outline.png';
$context['hero_video_mp4'] = get_stylesheet_directory_uri() . '/library/images/fefitness.mp4';
$context['hero_video_webm'] = get_stylesheet_directory_uri() . '/library/images/fefitness.webm';
$context['hero_video_image'] = get_stylesheet_directory_uri() . '/library/images/home/img-hero-barbell.jpg';
Timber::render('index.twig', $context);
?>


<?php 
get_footer();
Ejemplo n.º 13
0
 function testPagedContent()
 {
     $quote = $page1 = 'Named must your fear be before banish it you can.';
     $quote .= '<!--nextpage-->';
     $quote .= $page2 = "No, try not. Do or do not. There is no try.";
     $post_id = $this->factory->post->create(array('post_content' => $quote));
     $this->go_to(get_permalink($post_id));
     // @todo The below should work magically when the iterators are merged
     setup_postdata(get_post($post_id));
     $post = Timber::get_post();
     $this->assertEquals($page1, trim(strip_tags($post->get_paged_content())));
     $pagination = $post->pagination();
     $this->go_to($pagination['pages'][1]['link']);
     setup_postdata(get_post($post_id));
     $post = Timber::get_post();
     $this->assertEquals($page2, trim(strip_tags($post->get_paged_content())));
 }
Ejemplo n.º 14
0
<?php

$context = Timber::get_context();
$context['page'] = Timber::get_post();
$args = array('post_type' => 'student', 'post_status' => 'publish', 'posts_per_page' => '-1');
$context['students'] = Timber::get_posts($args);
Timber::render('front-page.twig', $context);
function retrieve_page_data($page_slug = '')
{
    //Actions to be taken depending on the post type
    switch ($page_slug) {
        case 'noticies':
            $args = array('name' => 'noticies', 'post_type' => 'page');
            $post = Timber::get_post($args);
            break;
        default:
            $args = array('name' => $page_slug . '-page', 'post_type' => 'page');
            $post = Timber::get_post($args);
            break;
    }
    return $post;
}
Ejemplo n.º 16
0
<?php

get_header();
/*
Template Name: Press Releases
*/
$context = array();
$context['pressReleases'] = Timber::get_post(1063);
$context['posts'] = $post;
Timber::render('press-releases.twig', $context);
?>


<?php 
get_footer();
Ejemplo n.º 17
0
<?php

get_header();
/*
Template Name: Coaches
*/
$context = array();
// $context = Timber::get_context();
// $post = new TimberPost();
$context['coaches'] = Timber::get_post(40);
$context['posts'] = $post;
Timber::render('coaches.twig', $context);
// Timber::render( array( 'page-' . $post->post_name . '.twig', 'coaches.twig' ), $context );
?>


			
			<!-- <div id="content"> -->
			
				<!-- <div id="inner-content" class="row"> -->
			
<!-- 				    <div id="main" class="large-12 medium-12 columns" role="main">
					
				
					    


					    					
    				</div> -->
    				 <!-- end #main -->
    
Ejemplo n.º 18
0
<?php

/*
Template Name: Introduction
*/
global $post;
$context = Timber::get_context();
$post = new TimberPost();
// Set context
$context = array_merge($context, array('post' => $post, 'last_blog_post' => Timber::get_post(array('posts_per_page' => 1, 'post_type' => 'post'))));
Timber::render('home/intro.twig', $context);
Ejemplo n.º 19
0
$data = Timber::get_context();
$data['page'] = new TimberPost();
$templates = array('page-' . $post->post_name . '.twig', 'page.twig');
// Homepage
if (is_front_page()) {
    // Carousel
    $data['slider_images'] = get_field('slider_images');
    $data['slider_intro'] = get_field('slider_intro');
    $data['slider_button_label'] = get_field('slider_button_label');
    $data['slider_button_url'] = get_field('slider_button_url');
    // Programma's
    $data['programma_items'] = Timber::get_posts('post_type=programmas&post_status=publish&orderby=menu_order&order=ASC&posts_per_page=3');
    // Cases
    // Obtain cases by this filter(featured)
    $featured = array('post_type' => 'cases', 'post_status' => 'publish', 'order' => 'DESC', 'post_per_page' => '3', 'meta_query' => array(array('key' => 'featured-checkbox', 'value' => 'yes')));
    $data['case_items'] = Timber::get_posts($featured);
    // Klanten
    $data['client_items'] = Timber::get_posts('post_type=klanten&post_status=publish&orderby=menu_order&order=ASC&posts_per_page=-1');
    // Quote's
    $data['quote'] = Timber::get_post('post_type=quotes&post_status=publish&orderby=rand');
    // Blog
    $blog_items = array('post_type' => 'post', 'paged' => $paged, 'posts_per_page' => 3, 'status' => 'publish', 'order' => 'DESC');
    $data['posts'] = Timber::get_posts($blog_items);
    //get normal posts
    $data['tweets'] = Timber::get_posts('post_type=tweet');
    //get tweets
    $twitter_user = get_option('itap_user_id');
    $data['twitter_user'] = $twitter_user;
    array_unshift($templates, 'home.twig');
}
Timber::render($templates, $data);
Ejemplo n.º 20
0
// Calculate Read Time
$postContent = $context['post']->content;
$postExcerpt = $context['post']->post_excerpt;
$Content = explode(" ", $postContent);
$Excerpt = explode(" ", $postExcerpt);
$ContentCount = count($Content);
$ExcerptCount = count($Excerpt);
$WordCount = $ExcerptCount + $ContentCount;
$MinRead = ceil($WordCount / 150);
$context['minRead'] = $MinRead;
// Parse Vimeo ID
$vimeo = $context['post']->video_link;
$vimeo = substr(parse_url($vimeo, PHP_URL_PATH), 1);
$context['video_link'] = $vimeo;
if ($context['post']->related_report != 'null') {
    $context['related_story'] = Timber::get_post($context['post']->related_story);
}
$context['authors'] = Timber::get_posts(array('numberposts' => -1, 'post_type' => 'authors', 'order' => 'ASC'));
///// Gets the next three post based on current post date //////
$nextthree = Timber::get_posts(array('numberposts' => 3, 'orderby' => 'date', 'offset' => 1, 'order' => 'ASC', 'exclude' => $postID, 'date_query' => array(array('after' => $context['post']->post_date, 'inclusive' => true))));
$context['nextthree'] = array();
foreach ($nextthree as $key) {
    $postID = $key->ID;
    $postContent = $key->content;
    $postExcerpt = $key->post_excerpt;
    $postTitle = $key->post_title;
    $Title = explode(" ", $postTitle, 8);
    if (count($Title) >= 8) {
        array_pop($Title);
        $Title = implode(" ", $Title) . "...";
        $key->Title = $Title;
Ejemplo n.º 21
0
<?php

// Get the header content
get_header();
// Set Contect to pass into the view
$ctx = Timber::get_context();
// Add to the array
$ctx["post"] = Timber::get_post();
$ctx["theme"] = $themeGlobals;
// Render a view
Timber::render('page.twig', $ctx);
// Get the footer content
get_footer();
Ejemplo n.º 22
0
<?php

get_header();
/*
Template Name: Coaches
*/
$context = array();
$context['services'] = Timber::get_post(163);
$context['posts'] = $post;
Timber::render('services.twig', $context);
?>


<?php 
get_footer();
Ejemplo n.º 23
0
<?php

/**
 * Homepage
 */
// Context array.
$context = array();
// Add the page ID which is 4 in my case.
$context['welcome_page'] = Timber::get_post(4);
// Timber render().
Timber::render('welcome.twig', $context);
Ejemplo n.º 24
0
 function testQueryPost()
 {
     $posts = $this->factory->post->create_many(6);
     $post = Timber::get_post($posts[3]);
     $this->go_to(home_url('/?p=' . $posts[2]));
     $this->assertNotEquals(get_the_ID(), $post->ID);
     $post = Timber::query_post($posts[3]);
     $this->assertEquals(get_the_ID(), $post->ID);
 }
Ejemplo n.º 25
0
    echo 'Timber not activated. Make sure you activate the plugin in <a href="/wp-admin/plugins.php#timber">/wp-admin/plugins.php</a>';
}
$context = Timber::get_context();
$context['posts'] = Timber::get_posts();
$templates = array('index.twig');
if (is_home()) {
    array_unshift($templates, 'home.twig');
}
if (is_front_page()) {
    /* Today & upcomings events for front page */
    // $upcoming_events = tribe_get_events(array('posts_per_page' => 4));
    // $upcoming_events = Timber::get_posts(array(
    //     'post_type' => 'tribe_events',
    //     'posts_per_page' => 10));
    $upcoming_events = tribe_get_events(array('start_date' => date("Y-m-d"), 'posts_per_age' => 10));
    // Turn these posts into Timber post objects
    $today = date("Y-m-d");
    foreach ($upcoming_events as $key => $event) {
        $event_date = date("Y-m-d", strtotime($event->_EventStartDate));
        if ($event_date === $today) {
            $context['todays_event'] = Timber::get_post($event->ID);
            unset($upcoming_events[$key]);
        } else {
            $upcoming_events[$key] = Timber::get_post($event->ID);
        }
    }
    $context['upcoming_events'] = $upcoming_events;
    /* use the front page template */
    array_unshift($templates, 'front-page.twig');
}
Timber::render($templates, $context);
Ejemplo n.º 26
0
<?php

/**
 * @package  WordPress
 * @subpackage  Timber
 * @since   Timber 0.1
 */
if (!class_exists('Timber')) {
    echo 'Timber not activated. Make sure you activate the plugin in <a href="/wp-admin/plugins.php#timber">/wp-admin/plugins.php</a>';
    return;
}
$context = Timber::get_context();
$context['post'] = Timber::get_post();
$context['is_home'] = is_home() || is_front_page();
if ($context['is_home']) {
    $context['site_css_contents'] = TimberHelper::transient('site_css_contents', function () {
        return file_get_contents(get_template_directory_uri() . "/assets/dist/css/application.min.css");
    }, 14400);
}
$templates = array('home.twig');
Timber::render($templates, $context);
Ejemplo n.º 27
0
<?php

get_header();
/*
Template Name: Coaches
*/
$context = array();
// $context = Timber::get_context();
// $post = new TimberPost();
$context['transformation'] = Timber::get_post(1052);
$context['posts'] = $post;
Timber::render('transformation.twig', $context);
// Timber::render( array( 'page-' . $post->post_name . '.twig', 'coaches.twig' ), $context );
?>



            <!-- <div id="content"> -->

                <!-- <div id="inner-content" class="row"> -->

<!--                    <div id="main" class="large-12 medium-12 columns" role="main">






                    </div> -->
                     <!-- end #main -->