Timber - Version 0.10.6

Version Description

  • more normalization of comments
  • Lots of cleanup of starter theme
Download this release

Release Info

Developer jarednova
Plugin Icon 128x128 Timber
Version 0.10.6
Comparing to
See all releases

Code changes from version 0.10.5 to 0.10.6

objects/timber-comment.php CHANGED
@@ -1,45 +1,40 @@
1
  <?php
2
 
3
- class TimberComment extends TimberCore
4
- {
5
 
6
- function __construct($cid)
7
- {
8
- $this->init($cid);
9
- }
10
 
11
- /* core definition */
 
 
 
 
 
 
 
 
 
 
 
 
12
 
13
- function author()
14
- {
15
- if ($this->user_id) {
16
- return new TimberUser($this->user_id);
17
  }
18
- $fakeUser = new stdClass();
19
- $fakeUser->name = 'Anonymous';
20
- if ($this->comment_author) {
21
- $fakeUser->name = $this->comment_author;
22
  }
23
- return $fakeUser;
24
- }
25
-
26
- function date()
27
- {
28
- return $this->comment_date;
29
- }
30
-
31
- function content()
32
- {
33
- return $this->comment_content;
34
- }
35
-
36
- function init($cid)
37
- {
38
- $comment_data = $cid;
39
- if (is_integer($cid)) {
40
- $comment_data = get_comment($cid);
41
  }
42
- $this->import($comment_data);
43
- }
44
 
45
  }
1
  <?php
2
 
3
+ class TimberComment extends TimberCore {
 
4
 
5
+ function __construct($cid) {
6
+ $this->init($cid);
7
+ }
 
8
 
9
+ /* core definition */
10
+
11
+ function author() {
12
+ if ($this->user_id) {
13
+ return new TimberUser($this->user_id);
14
+ }
15
+ $fakeUser = new stdClass();
16
+ $fakeUser->name = 'Anonymous';
17
+ if ($this->comment_author) {
18
+ $fakeUser->name = $this->comment_author;
19
+ }
20
+ return $fakeUser;
21
+ }
22
 
23
+ function date() {
24
+ return $this->comment_date;
 
 
25
  }
26
+
27
+ function content() {
28
+ return $this->comment_content;
 
29
  }
30
+
31
+ function init($cid) {
32
+ $comment_data = $cid;
33
+ if (is_integer($cid)) {
34
+ $comment_data = get_comment($cid);
35
+ }
36
+ $this->import($comment_data);
37
+ $this->ID = $this->comment_ID;
 
 
 
 
 
 
 
 
 
 
38
  }
 
 
39
 
40
  }
objects/timber-user.php CHANGED
@@ -1,78 +1,75 @@
1
  <?php
2
 
3
- class TimberUser extends TimberCore
4
- {
5
 
6
- function __construct($uid = false)
7
- {
8
- $this->init($uid);
9
- }
10
-
11
- public function get_link()
12
- {
13
- $p = WPHelper::get_path_base();
14
- return $p . 'author/' . $this->slug();
15
- }
16
-
17
- function init($uid = false)
18
- {
19
- if (!$uid) {
20
- $uid = get_current_user_id();
21
  }
22
- if (function_exists('get_userdata')) {
23
- $data = get_userdata($uid);
24
- if (is_object($data) && isset($data)) {
25
- $this->import($data->data);
26
- }
27
  }
28
 
29
- $this->ID = $uid;
30
- $this->import_custom();
31
- }
 
 
 
 
 
 
 
 
 
 
 
32
 
33
- function get_custom()
34
- {
35
- if ($this->ID) {
36
- $um = get_user_meta($this->ID);
37
- $custom = new stdClass();
38
- foreach ($um as $key => $value) {
39
- $v = $value[0];
40
- $custom->$key = $v;
41
- if (is_serialized($v)) {
42
- if (gettype(unserialize($v)) == 'array') {
43
- $custom->$key = unserialize($v);
44
- }
 
 
45
  }
46
- }
47
- return $custom;
48
  }
49
- return null;
50
- }
51
 
52
- function import_custom()
53
- {
54
- $custom = $this->get_custom();
55
- $this->import($custom);
56
- }
57
 
 
 
 
58
 
59
- function name()
60
- {
61
- return $this->display_name;
62
- }
63
 
64
- function get_path()
65
- {
66
- return $this->get_link();
67
- }
68
 
69
- function path()
70
- {
71
- return $this->get_path();
72
- }
73
 
74
- function slug()
75
- {
76
- return $this->user_nicename;
77
- }
 
 
 
78
  }
1
  <?php
2
 
3
+ class TimberUser extends TimberCore {
 
4
 
5
+ function __construct($uid = false) {
6
+ $this->init($uid);
 
 
 
 
 
 
 
 
 
 
 
 
 
7
  }
8
+
9
+ public function get_link() {
10
+ $p = WPHelper::get_path_base();
11
+ return $p . 'author/' . $this->slug();
 
12
  }
13
 
14
+ function init($uid = false) {
15
+ if (!$uid) {
16
+ $uid = get_current_user_id();
17
+ }
18
+ if (function_exists('get_userdata')) {
19
+ $data = get_userdata($uid);
20
+ if (is_object($data) && isset($data)) {
21
+ $this->import($data->data);
22
+ }
23
+ }
24
+
25
+ $this->ID = $uid;
26
+ $this->import_custom();
27
+ }
28
 
29
+ function get_custom() {
30
+ if ($this->ID) {
31
+ $um = get_user_meta($this->ID);
32
+ $custom = new stdClass();
33
+ foreach ($um as $key => $value) {
34
+ $v = $value[0];
35
+ $custom->$key = $v;
36
+ if (is_serialized($v)) {
37
+ if (gettype(unserialize($v)) == 'array') {
38
+ $custom->$key = unserialize($v);
39
+ }
40
+ }
41
+ }
42
+ return $custom;
43
  }
44
+ return null;
 
45
  }
 
 
46
 
47
+ function import_custom() {
48
+ $custom = $this->get_custom();
49
+ $this->import($custom);
50
+ }
 
51
 
52
+ function name() {
53
+ return $this->display_name;
54
+ }
55
 
56
+ function get_permalink(){
57
+ return $this->get_link();
58
+ }
 
59
 
60
+ function permalink() {
61
+ return $this->get_link();
62
+ }
 
63
 
64
+ function get_path() {
65
+ return $this->get_link();
66
+ }
 
67
 
68
+ function path() {
69
+ return $this->get_path();
70
+ }
71
+
72
+ function slug() {
73
+ return $this->user_nicename;
74
+ }
75
  }
readme.txt CHANGED
@@ -2,7 +2,7 @@
2
  Contributors: jarednova
3
  Tags: template engine, templates, twig
4
  Requires at least: 3.5
5
- Stable tag: 0.10.5
6
  Tested up to: 3.6
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
@@ -32,6 +32,13 @@ Timber is great for any WordPress developer who cares about writing good, mainta
32
 
33
  == Changelog ==
34
 
 
 
 
 
 
 
 
35
  = 0.10.4 =
36
  * Lots of code cleanup thanks to [Jakub](http://github.com/hsz)
37
  * Added new function for bloginfo
2
  Contributors: jarednova
3
  Tags: template engine, templates, twig
4
  Requires at least: 3.5
5
+ Stable tag: 0.10.6
6
  Tested up to: 3.6
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
32
 
33
  == Changelog ==
34
 
35
+ = 0.10.6 =
36
+ * more normalization of comments
37
+ * Lots of cleanup of starter theme
38
+
39
+ = 0.10.5 =
40
+ * added theme URI to universal context
41
+
42
  = 0.10.4 =
43
  * Lots of code cleanup thanks to [Jakub](http://github.com/hsz)
44
  * Added new function for bloginfo
timber-starter-theme/functions.php CHANGED
@@ -2,12 +2,12 @@
2
 
3
  add_theme_support('post-formats');
4
  add_theme_support('post-thumbnails');
 
5
 
6
  add_filter('get_twig', 'add_to_twig');
7
  add_filter('timber_context', 'add_to_context');
8
 
9
  add_action('wp_enqueue_scripts', 'load_scripts');
10
- add_action('wp_enqueue_scripts', 'load_styles');
11
 
12
  define('THEME_URL', get_template_directory_uri());
13
 
@@ -20,21 +20,15 @@
20
  function add_to_twig($twig){
21
  /* this is where you can add your own fuctions to twig */
22
  $twig->addExtension(new Twig_Extension_StringLoader());
 
23
  return $twig;
24
  }
25
 
26
- function load_scripts(){
27
- wp_enqueue_script('jquery');
 
28
  }
29
 
30
- function load_styles(){
31
- wp_register_style( 'screen', THEME_URL.'/style.css', '', '', 'screen' );
32
- wp_enqueue_style( 'screen' );
33
  }
34
-
35
-
36
-
37
-
38
-
39
-
40
-
2
 
3
  add_theme_support('post-formats');
4
  add_theme_support('post-thumbnails');
5
+ add_theme_support('menus');
6
 
7
  add_filter('get_twig', 'add_to_twig');
8
  add_filter('timber_context', 'add_to_context');
9
 
10
  add_action('wp_enqueue_scripts', 'load_scripts');
 
11
 
12
  define('THEME_URL', get_template_directory_uri());
13
 
20
  function add_to_twig($twig){
21
  /* this is where you can add your own fuctions to twig */
22
  $twig->addExtension(new Twig_Extension_StringLoader());
23
+ $twig->addFilter('myfoo', new Twig_Filter_Function('myfoo'));
24
  return $twig;
25
  }
26
 
27
+ function myfoo($text){
28
+ $text .= ' bar!';
29
+ return $text;
30
  }
31
 
32
+ function load_scripts(){
33
+ wp_enqueue_script('jquery');
 
34
  }
 
 
 
 
 
 
 
timber-starter-theme/single.php CHANGED
@@ -13,6 +13,6 @@ $context = Timber::get_context();
13
  $post = new TimberPost();
14
  $context['post'] = $post;
15
  $context['wp_title'] .= ' - ' . $post->post_title;
16
- $context['comment_form'] = WPHelper::get_comment_form($pid);
17
 
18
  Timber::render(array('single-' . $post->post_type . '.twig', 'single.twig'), $context);
13
  $post = new TimberPost();
14
  $context['post'] = $post;
15
  $context['wp_title'] .= ' - ' . $post->post_title;
16
+ $context['comment_form'] = WPHelper::get_comment_form();
17
 
18
  Timber::render(array('single-' . $post->post_type . '.twig', 'single.twig'), $context);
timber-starter-theme/views/tease-post.twig CHANGED
@@ -1,6 +1,6 @@
1
  {% extends "tease.twig" %}
2
  {% block content %}
3
- <h2 class="h2"><a href="{{post.get_link}}">{{post.title}}</a></h2>
4
  <p>{{post.get_preview(25)}}</p>
5
 
6
  {% if post.get_thumbnail %}
1
  {% extends "tease.twig" %}
2
  {% block content %}
3
+ <h2 class="h2"><a href="{{post.permalink}}">{{post.title}}</a></h2>
4
  <p>{{post.get_preview(25)}}</p>
5
 
6
  {% if post.get_thumbnail %}
timber.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Timber
4
  Description: The WordPress Timber Library allows you to write themes using the power Twig templates
5
  Author: Jared Novack + Upstatement
6
- Version: 0.10.5
7
  Author URI: http://timber.upstatement.com/
8
  */
9
 
@@ -255,7 +255,6 @@ class Timber {
255
  }
256
 
257
  public static function handle_term_query($taxonomies, $args, $TermClass){
258
-
259
  $terms = get_terms($taxonomies, $args);
260
  foreach($terms as &$term){
261
  $term = new TimberTerm($term->term_id);
@@ -263,8 +262,6 @@ class Timber {
263
  return $terms;
264
  }
265
 
266
-
267
-
268
 
269
  /* Template Setup and Display
270
  ================================ */
@@ -338,7 +335,7 @@ class Timber {
338
  }
339
 
340
 
341
- /* Routes
342
  ================================ */
343
 
344
  public function init_routes() {
3
  Plugin Name: Timber
4
  Description: The WordPress Timber Library allows you to write themes using the power Twig templates
5
  Author: Jared Novack + Upstatement
6
+ Version: 0.10.6
7
  Author URI: http://timber.upstatement.com/
8
  */
9
 
255
  }
256
 
257
  public static function handle_term_query($taxonomies, $args, $TermClass){
 
258
  $terms = get_terms($taxonomies, $args);
259
  foreach($terms as &$term){
260
  $term = new TimberTerm($term->term_id);
262
  return $terms;
263
  }
264
 
 
 
265
 
266
  /* Template Setup and Display
267
  ================================ */
335
  }
336
 
337
 
338
+ /* Routes
339
  ================================ */
340
 
341
  public function init_routes() {