function testUserMetaFilter() { $uid = $this->factory->user->create(); $user = new TimberUser($uid); $user->update('jared', 'novack'); add_filter('timber_user_get_meta_field', array($this, 'filter_timber_user_get_meta_field'), 10, 4); $this->assertEquals($user->meta('jared'), 'novack'); }
function testLinks() { global $wp_rewrite; $struc = '/blog/%year%/%monthnum%/%postname%/'; $wp_rewrite->permalink_structure = $struc; update_option('permalink_structure', $struc); $uid = $this->factory->user->create(array('display_name' => 'Baberaham Lincoln', 'user_login' => 'lincoln')); $uid = get_user_by('id', $uid); $user = new TimberUser($uid); $this->assertEquals('http://example.org/author/lincoln', $user->link()); $this->assertEquals('/author/lincoln', $user->path()); $user->president = '16th'; $this->assertEquals('16th', $user->president); }
<?php /** * @package Gantry 5 Theme * @author RocketTheme http://www.rockettheme.com * @copyright Copyright (C) 2007 - 2015 RocketTheme, LLC * @license GNU/GPLv2 and later * * http://www.gnu.org/licenses/gpl-2.0.html */ /* * The template for displaying Author Archive pages */ $chooser = new \Gantry\Framework\OutlineChooser(); /** @var \Gantry\Framework\Theme $theme */ $theme = $gantry['theme']; $theme->setLayout($chooser->select()); global $wp_query; $context = Timber::get_context(); $context['posts'] = Timber::get_posts(); if (isset($query_vars['author'])) { $author = new TimberUser($wp_query->query_vars['author']); $context['author'] = $author; $context['title'] = 'Author Archives: ' . $author->name(); } Timber::render(array('author.html.twig', 'archive.html.twig'), $context);
<?php /** * @package Gantry 5 Theme * @author RocketTheme http://www.rockettheme.com * @copyright Copyright (C) 2007 - 2015 RocketTheme, LLC * @license GNU/GPLv2 and later * * http://www.gnu.org/licenses/gpl-2.0.html */ defined('ABSPATH') or die; /* * The template for displaying Author Archive pages */ global $wp_query; $context = Timber::get_context(); $context['posts'] = Timber::get_posts(); if (isset($authordata)) { $author = new TimberUser($authordata->ID); $context['author'] = $author; $context['title'] = __('Author:', 'g5_hydrogen') . ' ' . $author->name(); } Timber::render(['author.html.twig', 'archive.html.twig', 'index.html.twig'], $context);
<?php /** * @package Gantry 5 Theme * @author RocketTheme http://www.rockettheme.com * @copyright Copyright (C) 2007 - 2015 RocketTheme, LLC * @license GNU/GPLv2 and later * * http://www.gnu.org/licenses/gpl-2.0.html */ /* * The template for displaying Author Archive pages */ /** @var \Gantry\Framework\Theme $theme */ $theme = $gantry['theme']; $theme->setLayout('test'); global $wp_query; $data = Timber::get_context(); $data['posts'] = Timber::get_posts(); if (isset($query_vars['author'])) { $author = new TimberUser($wp_query->query_vars['author']); $data['author'] = $author; $data['title'] = 'Author Archives: ' . $author->name(); } Timber::render(array('author.twig', 'archive.twig'), $data);