Timber - Version 1.0.5

Version Description

  • Restored prior {{ post.type }} behavior for existing custom fields (@jarednova) 6c9574912e526b8589eb134b79820c7e239a1dda
  • Fixed errors in PHP 7 (@FlyingDR) 48ba0fc125c2d19eeb0de0a895a83a9d3bb5a398
  • Misc bug fixes and upkeep (@connorjburton + @jarednova)
Download this release

Release Info

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

Code changes from version 1.0.4 to 1.0.5

lib/Core.php CHANGED
@@ -62,6 +62,9 @@ abstract class Core {
62
  }
63
  if ( is_array($info) ) {
64
  foreach ( $info as $key => $value ) {
 
 
 
65
  if ( !empty($key) && $force ) {
66
  $this->$key = $value;
67
  } else if ( !empty($key) && !method_exists($this, $key) ) {
@@ -114,4 +117,4 @@ abstract class Core {
114
  $ret['can_edit'] = $this->can_edit();
115
  return $ret;
116
  }
117
- }
62
  }
63
  if ( is_array($info) ) {
64
  foreach ( $info as $key => $value ) {
65
+ if ( $key === '' || ord( $key[0] ) === 0 ) {
66
+ continue;
67
+ }
68
  if ( !empty($key) && $force ) {
69
  $this->$key = $value;
70
  } else if ( !empty($key) && !method_exists($this, $key) ) {
117
  $ret['can_edit'] = $this->can_edit();
118
  return $ret;
119
  }
120
+ }
lib/Post.php CHANGED
@@ -163,7 +163,7 @@ class Post extends Core implements CoreInterface {
163
  /**
164
  * @var PostType $_type stores the PostType object for the Post
165
  */
166
- private $_type;
167
 
168
  /**
169
  * If you send the constructor nothing it will try to figure out the current post id based on being inside The_Loop
@@ -1018,10 +1018,13 @@ class Post extends Core implements CoreInterface {
1018
  * @return PostType
1019
  */
1020
  public function type() {
1021
- if ( !$this->_type instanceof PostType ) {
1022
- $this->_type = new PostType($this->post_type);
1023
  }
1024
- return $this->_type;
 
 
 
1025
  }
1026
 
1027
  /**
163
  /**
164
  * @var PostType $_type stores the PostType object for the Post
165
  */
166
+ protected $__type;
167
 
168
  /**
169
  * If you send the constructor nothing it will try to figure out the current post id based on being inside The_Loop
1018
  * @return PostType
1019
  */
1020
  public function type() {
1021
+ if ( isset($this->custom['type']) ) {
1022
+ return $this->custom['type'];
1023
  }
1024
+ if ( !$this->__type instanceof PostType ) {
1025
+ $this->__type = new PostType($this->post_type);
1026
+ }
1027
+ return $this->__type;
1028
  }
1029
 
1030
  /**
lib/PostType.php CHANGED
@@ -20,8 +20,11 @@ class PostType {
20
  protected function init( $post_type ) {
21
  $obj = get_post_type_object($post_type);
22
  foreach (get_object_vars($obj) as $key => $value) {
 
 
 
23
  $this->$key = $value;
24
  }
25
  }
26
 
27
- }
20
  protected function init( $post_type ) {
21
  $obj = get_post_type_object($post_type);
22
  foreach (get_object_vars($obj) as $key => $value) {
23
+ if ( $key === '' || ord( $key[0] ) === 0 ) {
24
+ continue;
25
+ }
26
  $this->$key = $value;
27
  }
28
  }
29
 
30
+ }
lib/Timber.php CHANGED
@@ -53,7 +53,7 @@ class Timber {
53
  $this->test_compatibility();
54
  $this->backwards_compatibility();
55
  $this->init_constants();
56
- $this->init();
57
  }
58
  }
59
 
@@ -100,7 +100,7 @@ class Timber {
100
  /**
101
  * @codeCoverageIgnore
102
  */
103
- protected function init() {
104
  if ( class_exists('\WP') && !defined('TIMBER_LOADED') ) {
105
  Twig::init();
106
  ImageHelper::init();
53
  $this->test_compatibility();
54
  $this->backwards_compatibility();
55
  $this->init_constants();
56
+ $this::init();
57
  }
58
  }
59
 
100
  /**
101
  * @codeCoverageIgnore
102
  */
103
+ protected static function init() {
104
  if ( class_exists('\WP') && !defined('TIMBER_LOADED') ) {
105
  Twig::init();
106
  ImageHelper::init();
readme.txt CHANGED
@@ -2,7 +2,7 @@
2
  Contributors: jarednova, connorjburton, lggorman
3
  Tags: template engine, templates, twig
4
  Requires at least: 3.7
5
- Stable tag: 1.0.4
6
  Tested up to: 4.5.1
7
  PHP version: 5.3.0 or greater
8
  License: GPLv2 or later
@@ -41,6 +41,11 @@ Timber is great for any WordPress developer who cares about writing good, mainta
41
 
42
  == Changelog ==
43
 
 
 
 
 
 
44
  = 1.0.4 =
45
  * New method for `{{ post.type }}` this makes it easy to access things like `{{post.type.labels.name}}` right in Twig https://github.com/timber/timber/pull/1003
46
  * New method for `{{ post.preview }}` which makes it easy to customize like `{{post.preview.length(50).read_more("Keep Reading").end('........')}}` https://github.com/timber/timber/pull/1015
2
  Contributors: jarednova, connorjburton, lggorman
3
  Tags: template engine, templates, twig
4
  Requires at least: 3.7
5
+ Stable tag: 1.0.5
6
  Tested up to: 4.5.1
7
  PHP version: 5.3.0 or greater
8
  License: GPLv2 or later
41
 
42
  == Changelog ==
43
 
44
+ = 1.0.5 =
45
+ * Restored prior `{{ post.type }}` behavior for existing custom fields (@jarednova) 6c9574912e526b8589eb134b79820c7e239a1dda
46
+ * Fixed errors in PHP 7 (@FlyingDR) 48ba0fc125c2d19eeb0de0a895a83a9d3bb5a398
47
+ * Misc bug fixes and upkeep (@connorjburton + @jarednova)
48
+
49
  = 1.0.4 =
50
  * New method for `{{ post.type }}` this makes it easy to access things like `{{post.type.labels.name}}` right in Twig https://github.com/timber/timber/pull/1003
51
  * New method for `{{ post.preview }}` which makes it easy to customize like `{{post.preview.length(50).read_more("Keep Reading").end('........')}}` https://github.com/timber/timber/pull/1015
timber-starter-theme/templates/base.twig CHANGED
@@ -11,7 +11,7 @@
11
  {% block header %}
12
  <div class="wrapper">
13
  <h1 class="hdr-logo" role="banner">
14
- <a class="hdr-logo-link" href="{{site.siteurl}}" rel="home">{{site.name}}</a>
15
  </h1>
16
  <nav id="nav-main" class="nav-main" role="navigation">
17
  {% include "menu.twig" with {'menu': menu.get_items} %}
11
  {% block header %}
12
  <div class="wrapper">
13
  <h1 class="hdr-logo" role="banner">
14
+ <a class="hdr-logo-link" href="{{site.url}}" rel="home">{{site.name}}</a>
15
  </h1>
16
  <nav id="nav-main" class="nav-main" role="navigation">
17
  {% include "menu.twig" with {'menu': menu.get_items} %}
timber-starter-theme/templates/html-header.twig CHANGED
@@ -15,7 +15,7 @@
15
  <meta name="description" content="{{site.description}}">
16
  <link rel="stylesheet" href="{{site.theme.link}}/style.css" type="text/css" media="screen" />
17
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
18
- <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
19
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
20
  <link rel="pingback" href="{{site.pingback_url}}" />
21
  {{function('wp_head')}}
15
  <meta name="description" content="{{site.description}}">
16
  <link rel="stylesheet" href="{{site.theme.link}}/style.css" type="text/css" media="screen" />
17
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
18
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
19
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
20
  <link rel="pingback" href="{{site.pingback_url}}" />
21
  {{function('wp_head')}}
timber-starter-theme/{views → templates}/menu.twig RENAMED
File without changes
timber.php CHANGED
@@ -4,7 +4,7 @@ Plugin Name: Timber
4
  Description: The WordPress Timber Library allows you to write themes using the power Twig templates.
5
  Plugin URI: http://timber.upstatement.com
6
  Author: Jared Novack + Upstatement
7
- Version: 1.0.4
8
  Author URI: http://upstatement.com/
9
  */
10
  // we look for Composer files first in the plugins dir.
4
  Description: The WordPress Timber Library allows you to write themes using the power Twig templates.
5
  Plugin URI: http://timber.upstatement.com
6
  Author: Jared Novack + Upstatement
7
+ Version: 1.0.5
8
  Author URI: http://upstatement.com/
9
  */
10
  // we look for Composer files first in the plugins dir.
vendor/autoload.php CHANGED
@@ -4,4 +4,4 @@
4
 
5
  require_once __DIR__ . '/composer' . '/autoload_real.php';
6
 
7
- return ComposerAutoloaderInit146647302270f1c55afad439213da448::getLoader();
4
 
5
  require_once __DIR__ . '/composer' . '/autoload_real.php';
6
 
7
+ return ComposerAutoloaderInitcb7cd3f591a5a00a4b4ac0d8e060a51d::getLoader();
vendor/composer/autoload_real.php CHANGED
@@ -2,7 +2,7 @@
2
 
3
  // autoload_real.php @generated by Composer
4
 
5
- class ComposerAutoloaderInit146647302270f1c55afad439213da448
6
  {
7
  private static $loader;
8
 
@@ -19,9 +19,9 @@ class ComposerAutoloaderInit146647302270f1c55afad439213da448
19
  return self::$loader;
20
  }
21
 
22
- spl_autoload_register(array('ComposerAutoloaderInit146647302270f1c55afad439213da448', 'loadClassLoader'), true, true);
23
  self::$loader = $loader = new \Composer\Autoload\ClassLoader();
24
- spl_autoload_unregister(array('ComposerAutoloaderInit146647302270f1c55afad439213da448', 'loadClassLoader'));
25
 
26
  $map = require __DIR__ . '/autoload_namespaces.php';
27
  foreach ($map as $namespace => $path) {
@@ -42,14 +42,14 @@ class ComposerAutoloaderInit146647302270f1c55afad439213da448
42
 
43
  $includeFiles = require __DIR__ . '/autoload_files.php';
44
  foreach ($includeFiles as $fileIdentifier => $file) {
45
- composerRequire146647302270f1c55afad439213da448($fileIdentifier, $file);
46
  }
47
 
48
  return $loader;
49
  }
50
  }
51
 
52
- function composerRequire146647302270f1c55afad439213da448($fileIdentifier, $file)
53
  {
54
  if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
55
  require $file;
2
 
3
  // autoload_real.php @generated by Composer
4
 
5
+ class ComposerAutoloaderInitcb7cd3f591a5a00a4b4ac0d8e060a51d
6
  {
7
  private static $loader;
8
 
19
  return self::$loader;
20
  }
21
 
22
+ spl_autoload_register(array('ComposerAutoloaderInitcb7cd3f591a5a00a4b4ac0d8e060a51d', 'loadClassLoader'), true, true);
23
  self::$loader = $loader = new \Composer\Autoload\ClassLoader();
24
+ spl_autoload_unregister(array('ComposerAutoloaderInitcb7cd3f591a5a00a4b4ac0d8e060a51d', 'loadClassLoader'));
25
 
26
  $map = require __DIR__ . '/autoload_namespaces.php';
27
  foreach ($map as $namespace => $path) {
42
 
43
  $includeFiles = require __DIR__ . '/autoload_files.php';
44
  foreach ($includeFiles as $fileIdentifier => $file) {
45
+ composerRequirecb7cd3f591a5a00a4b4ac0d8e060a51d($fileIdentifier, $file);
46
  }
47
 
48
  return $loader;
49
  }
50
  }
51
 
52
+ function composerRequirecb7cd3f591a5a00a4b4ac0d8e060a51d($fileIdentifier, $file)
53
  {
54
  if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
55
  require $file;