コード例 #1
0
ファイル: TimberProxy.php プロジェクト: mindgruve/mg-press
 public function link()
 {
     if (!$this->link) {
         $this->link = $this->post->link();
     }
     return $this->link;
 }
コード例 #2
0
 function testPreviewWithSpaceInMoreTag()
 {
     $pid = $this->factory->post->create(array('post_content' => 'Lauren is a duck, but a great duck let me tell you why <!--more--> Lauren is not a duck', 'post_excerpt' => ''));
     $post = new TimberPost($pid);
     $template = '{{post.preview.length(3).force}}';
     $str = Timber::compile_string($template, array('post' => $post));
     $this->assertEquals('Lauren is a&hellip; <a href="' . $post->link() . '" class="read-more">Read More</a>', $str);
 }
コード例 #3
0
 function testPostPathUglyPermalinks()
 {
     update_option('permalink_structure', '');
     $pid = $this->factory->post->create();
     $post = new TimberPost($pid);
     $this->assertEquals('http://example.org/?p=' . $pid, $post->link());
     $this->assertEquals('/?p=' . $pid, $post->path());
 }
コード例 #4
0
ファイル: test-timber-post.php プロジェクト: timber/timber
 function testPostPathPrettyPermalinks()
 {
     $struc = '/blog/%year%/%monthnum%/%postname%/';
     update_option('permalink_structure', $struc);
     $pid = $this->factory->post->create(array('post_date' => '2014-05-28'));
     $post = new TimberPost($pid);
     $this->assertStringStartsWith('http://example.org/blog/2014/05/post-title', $post->link());
     $this->assertStringStartsWith('/blog/2014/05/post-title', $post->path());
 }
コード例 #5
0
 function testPreviewWithCustomMoreTag()
 {
     $pid = $this->factory->post->create(array('post_content' => 'Eric is a polar bear <!-- more But what is Elaina? --> Lauren is not a duck', 'post_excerpt' => ''));
     $post = new TimberPost($pid);
     $this->assertEquals('Eric is a polar bear <a href="' . $post->link() . '" class="read-more">But what is Elaina?</a>', $post->get_preview());
 }
コード例 #6
0
ファイル: functions.php プロジェクト: nikosolihin/saat
 function add_to_context($context)
 {
     // SITE INFO
     $context['site'] = $this;
     // PRIMARY MENU
     $context['primary_menu'] = array();
     // Loop through each primary menu item
     foreach (get_fields('option')['primary_menu'] as $key => $item) {
         $context['primary_menu'][$key] = $item;
         // Getting parent's info
         $context['primary_menu'][$key]['pm_children'] = array();
         $itemPost = new TimberPost($item['pm_parent']);
         $context['primary_menu'][$key]['pm_label'] = $itemPost->name();
         $context['primary_menu'][$key]['pm_link'] = $itemPost->link();
         // Loop through each primary menu item's children
         foreach ($itemPost->children('page') as $subitem) {
             $context['primary_menu'][$key]['pm_children'][$subitem->name()] = $subitem->link();
         }
     }
     // SECONDARY MENU
     $context['secondary_menu'] = get_fields('option')['secondary_menu'];
     // LANGUAGES
     $context['languages']['english'] = get_fields('option')['english'];
     $context['languages']['indonesian'] = get_fields('option')['indonesian'];
     // MISC MOBILE MENU
     $context['misc_menu'] = get_fields('option')['quicklinks'];
     // FOOTER
     $context['footer']['bg'] = get_fields('option')['footer_bg'];
     $context['footer']['slogan'] = get_fields('option')['footer_slogan'];
     $context['footer']['social'] = get_fields('option')['footer_social'];
     // GLOBAL SETTINGS
     $context['global']['name'] = get_fields('option')['global_name'];
     $context['global']['address'] = get_fields('option')['global_address'];
     $context['global']['contacts'] = get_fields('option')['global_contacts'];
     return $context;
 }
コード例 #7
0
 /**
  * @group failing
  */
 function testPreviewWithCustomStripTags()
 {
     $pid = $this->factory->post->create(array('post_content' => '<span>Even in the <a href="">world</a> of make-believe there have to be rules. The parts have to be consistent and belong together</span>'));
     $post = new TimberPost($pid);
     $post->post_excerpt = '';
     $preview = $post->get_preview(6, true, 'Read More', '<span>');
     $this->assertEquals('<span>Even in the world of</span>&hellip; <a href="' . $post->link() . '" class="read-more">Read More</a>', $preview);
 }