Пример #1
0
 function testWPTitleSingle()
 {
     //since we're testing with twentyfourteen -- need to remove its filters on wp_title
     remove_all_filters('wp_title');
     $post_id = $this->factory->post->create(array('post_title' => 'My New Post'));
     $post = get_post($post_id);
     $this->go_to(site_url('?p=' . $post_id));
     $this->assertEquals('My New Post', TimberHelper::get_wp_title());
 }
Пример #2
0
 /**
  * Get context.
  *
  * @return array
  */
 public static function get_context()
 {
     $data = array();
     $data['http_host'] = 'http://' . TimberURLHelper::get_host();
     $data['wp_title'] = TimberHelper::get_wp_title();
     $data['wp_head'] = TimberHelper::function_wrapper('wp_head');
     $data['wp_footer'] = TimberHelper::function_wrapper('wp_footer');
     $data['body_class'] = implode(' ', get_body_class());
     $data['site'] = new TimberSite();
     $data['theme'] = $data['site']->theme;
     //deprecated, these should be fetched via TimberSite or TimberTheme
     $data['theme_dir'] = WP_CONTENT_SUBDIR . str_replace(WP_CONTENT_DIR, '', get_stylesheet_directory());
     $data['language_attributes'] = TimberHelper::function_wrapper('language_attributes');
     $data['stylesheet_uri'] = get_stylesheet_uri();
     $data['template_uri'] = get_template_directory_uri();
     $data['posts'] = Timber::query_posts();
     //deprecated, this should be fetched via TimberMenu
     if (function_exists('wp_nav_menu')) {
         $locations = get_nav_menu_locations();
         if (count($locations)) {
             $data['wp_nav_menu'] = wp_nav_menu(array('container_class' => 'menu-header', 'echo' => false, 'menu_class' => 'nav-menu'));
         }
     }
     $data = apply_filters('timber_context', $data);
     $data = apply_filters('timber/context', $data);
     return $data;
 }
Пример #3
0
 /**
  * Get context.
  *
  * @return array
  */
 public static function get_context()
 {
     $data = array();
     $data['http_host'] = 'http://' . TimberURLHelper::get_host();
     $data['wp_title'] = TimberHelper::get_wp_title();
     $data['wp_head'] = TimberHelper::function_wrapper('wp_head');
     $data['wp_footer'] = TimberHelper::function_wrapper('wp_footer');
     $data['body_class'] = implode(' ', get_body_class());
     $data['site'] = new TimberSite();
     $data['theme'] = $data['site']->theme;
     $data['posts'] = Timber::query_posts();
     $data = apply_filters('timber_context', $data);
     $data = apply_filters('timber/context', $data);
     return $data;
 }
Пример #4
0
 public function add_to_context($context)
 {
     // Theme Options/Settings - prevent to run twice if child-themed
     if (!isset($context['theme_options'])) {
         $context['theme_options'] = new TimberFoundation_ThemeOptions();
     }
     $context = parent::add_to_context($context);
     // Override the title and force the seperator on the right
     $context['wp_title'] = TimberHelper::get_wp_title('»', 'right');
     // Menu
     $context = $this->add_menus_to_context($context);
     // WP API
     $context['dynamic_sidebar'] = TimberHelper::function_wrapper('dynamic_sidebar', array(), true);
     $context['is_user_logged_in'] = is_user_logged_in();
     $context['current_user'] = is_user_logged_in() ? new TimberUser() : false;
     $context['wp_login_url'] = TimberHelper::function_wrapper('wp_login_url', array(get_permalink()));
     $context['wp_logout_url'] = TimberHelper::function_wrapper('wp_logout_url', array(get_permalink()));
     global $comment_author, $comment_author_email, $comment_author_url;
     $context['comment_author'] = $comment_author;
     $context['comment_author_email'] = $comment_author_email;
     $context['comment_author_url'] = $comment_author_url;
     return $context;
 }