Timber - Version 0.22.3

Version Description

  • Fixed-up conditional for when comments are being moderated (thanks @lggorman)
  • Fixed hooks for when attachments are deleted (thanks @lgaechter)
  • Added a new filter for list (thanks @lggorman)
Download this release

Release Info

Developer lggorman
Plugin Icon 128x128 Timber
Version 0.22.3
Comparing to
See all releases

Code changes from version 0.22.2 to 0.22.3

README.md CHANGED
@@ -4,13 +4,13 @@
4
  By Jared Novack (<a href="http://twitter.com/jarednova">@JaredNova</a>) and <a href="http://upstatement.com">Upstatement</a> (<a href="http://twitter.com/upstatement">@Upstatement</a>)</div>
5
  </div>
6
 
7
- [![Build Status](https://travis-ci.org/jarednova/timber.png?branch=master)](https://travis-ci.org/jarednova/timber)
8
- [![Coverage Status](https://coveralls.io/repos/jarednova/timber/badge.svg?branch=master)](https://coveralls.io/r/jarednova/timber?branch=master)
9
- [![Dependency Status](https://www.versioneye.com/user/projects/54e3c717d1ec5734f4000099/badge.svg?style=flat)](https://www.versioneye.com/user/projects/54e3c717d1ec5734f4000099)
10
- [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/jarednova/timber/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/jarednova/timber/?branch=master)
11
- [![Latest Stable Version](https://poser.pugx.org/jarednova/timber/v/stable.svg)](https://packagist.org/packages/jarednova/timber)
12
- [![WordPress Download Count](https://img.shields.io/wordpress/plugin/dt/timber-library.svg)](https://wordpress.org/plugins/timber-library/)
13
- [![HHVM Status](http://hhvm.h4cc.de/badge/jarednova/timber.svg)](http://hhvm.h4cc.de/package/jarednova/timber)
14
 
15
  ### Because WordPress is awesome, but the_loop isn't
16
  Timber helps you create fully-customized WordPress themes faster with more sustainable code. With Timber, you write your HTML using the [Twig Template Engine](http://twig.sensiolabs.org/) separate from your PHP files.
4
  By Jared Novack (<a href="http://twitter.com/jarednova">@JaredNova</a>) and <a href="http://upstatement.com">Upstatement</a> (<a href="http://twitter.com/upstatement">@Upstatement</a>)</div>
5
  </div>
6
 
7
+ [![Build Status](https://img.shields.io/travis/jarednova/timber.svg?style=flat-square)](https://travis-ci.org/jarednova/timber)
8
+ [![Coverage Status](https://img.shields.io/coveralls/jarednova/timber.svg?style=flat-square)](https://coveralls.io/r/jarednova/timber?branch=master)
9
+ [![Dependency Status](https://img.shields.io/versioneye/d/ruby/rails.svg?style=flat-square)](https://www.versioneye.com/user/projects/54e3c717d1ec5734f4000099)
10
+ [![Scrutinizer Code Quality](https://img.shields.io/scrutinizer/g/jarednova/timber.svg?style=flat-square)](https://scrutinizer-ci.com/g/jarednova/timber/?branch=master)
11
+ [![Latest Stable Version](https://img.shields.io/packagist/v/jarednova/timber.svg?style=flat-square)](https://packagist.org/packages/jarednova/timber)
12
+ [![WordPress Download Count](https://img.shields.io/wordpress/plugin/dt/timber-library.svg?style=flat-square)](https://wordpress.org/plugins/timber-library/)
13
+ [![HHVM Status](https://img.shields.io/hhvm/jarednova/timber.svg?style=flat-square)](http://hhvm.h4cc.de/package/jarednova/timber)
14
 
15
  ### Because WordPress is awesome, but the_loop isn't
16
  Timber helps you create fully-customized WordPress themes faster with more sustainable code. With Timber, you write your HTML using the [Twig Template Engine](http://twig.sensiolabs.org/) separate from your PHP files.
lib/timber-helper.php CHANGED
@@ -222,8 +222,7 @@ class TimberHelper {
222
  $allowed_tag_string .= '<' . $tag . '>';
223
  }
224
  $text = strip_tags( $text, $allowed_tag_string );
225
- /* translators: If your word count is based on single characters (East Asian characters),
226
- enter 'characters'. Otherwise, enter 'words'. Do not translate into your own language. */
227
  if ( 'characters' == _x( 'words', 'word count: words or characters?' ) && preg_match( '/^utf\-?8$/i', get_option( 'blog_charset' ) ) ) {
228
  $text = trim( preg_replace( "/[\n\r\t ]+/", ' ', $text ), ' ' );
229
  preg_match_all( '/./u', $text, $words_array );
222
  $allowed_tag_string .= '<' . $tag . '>';
223
  }
224
  $text = strip_tags( $text, $allowed_tag_string );
225
+ /* translators: If your word count is based on single characters (East Asian characters), enter 'characters'. Otherwise, enter 'words'. Do not translate into your own language. */
 
226
  if ( 'characters' == _x( 'words', 'word count: words or characters?' ) && preg_match( '/^utf\-?8$/i', get_option( 'blog_charset' ) ) ) {
227
  $text = trim( preg_replace( "/[\n\r\t ]+/", ' ', $text ), ' ' );
228
  preg_match_all( '/./u', $text, $words_array );
lib/timber-image-helper.php CHANGED
@@ -159,14 +159,16 @@ class TimberImageHelper {
159
  * Deletes all resized versions of an image when the source is deleted
160
  */
161
  protected static function add_actions() {
162
- add_action( 'delete_post', function ( $post_id ) {
163
- $post = get_post( $post_id );
164
- $image_types = array( 'image/jpeg', 'image/png', 'image/gif', 'image/jpg' );
165
- if ( $post->post_type == 'attachment' && in_array( $post->post_mime_type, $image_types ) ) {
166
- $attachment = new TimberImage( $post_id );
 
167
  TimberImageHelper::delete_generated_files( $attachment->file_loc );
168
  }
169
- } );
 
170
  }
171
 
172
  /**
159
  * Deletes all resized versions of an image when the source is deleted
160
  */
161
  protected static function add_actions() {
162
+ add_action( 'delete_attachment', function ( $post_id ) {
163
+ $post = get_post( $post_id );
164
+ $image_types = array( 'image/jpeg', 'image/png', 'image/gif', 'image/jpg' );
165
+ if ( in_array( $post->post_mime_type, $image_types ) ) {
166
+ $attachment = new TimberImage( $post_id );
167
+ if ( $attachment->file_loc ) {
168
  TimberImageHelper::delete_generated_files( $attachment->file_loc );
169
  }
170
+ }
171
+ } );
172
  }
173
 
174
  /**
lib/timber-post.php CHANGED
@@ -389,10 +389,11 @@ class TimberPost extends TimberCore implements TimberCoreInterface {
389
  $text .= ' &hellip; ';
390
  }
391
  }
 
392
  if ( $readmore && isset($readmore_matches) && !empty($readmore_matches[1]) ) {
393
- $text .= ' <a href="' . $this->get_permalink() . '" class="read-more">' . trim($readmore_matches[1]) . '</a>';
394
  } elseif ( $readmore ) {
395
- $text .= ' <a href="' . $this->get_permalink() . '" class="read-more">' . trim($readmore) . '</a>';
396
  }
397
  if ( !$strip && $last_p_tag && ( strpos($text, '<p>') || strpos($text, '<p ') ) ) {
398
  $text .= '</p>';
@@ -716,9 +717,12 @@ class TimberPost extends TimberCore implements TimberCoreInterface {
716
 
717
  function get_comments($ct = 0, $order = 'wp', $type = 'comment', $status = 'approve', $CommentClass = 'TimberComment') {
718
 
719
- global $overridden_cpage;
720
  $overridden_cpage = false;
721
 
 
 
 
722
  $args = array('post_id' => $this->ID, 'status' => $status, 'order' => $order);
723
  if ( $ct > 0 ) {
724
  $args['number'] = $ct;
@@ -727,6 +731,12 @@ class TimberPost extends TimberCore implements TimberCoreInterface {
727
  $args['order'] = get_option('comment_order');
728
  }
729
 
 
 
 
 
 
 
730
  $comments = get_comments($args);
731
  $timber_comments = array();
732
 
@@ -834,7 +844,6 @@ class TimberPost extends TimberCore implements TimberCoreInterface {
834
  $term_class_objects[$taxonomy] = $terms;
835
  }
836
  }
837
-
838
  return $term_class_objects;
839
  }
840
 
@@ -959,14 +968,13 @@ class TimberPost extends TimberCore implements TimberCoreInterface {
959
  }
960
 
961
  /**
962
- * @return int
963
  */
964
  public function get_comment_count() {
965
  if ( isset($this->ID) ) {
966
  return get_comments_number($this->ID);
967
- } else {
968
- return 0;
969
  }
 
970
  }
971
 
972
  /**
389
  $text .= ' &hellip; ';
390
  }
391
  }
392
+ $read_more_class = apply_filters('timber/post/get_preview/read_more_class', "read-more");
393
  if ( $readmore && isset($readmore_matches) && !empty($readmore_matches[1]) ) {
394
+ $text .= ' <a href="' . $this->get_permalink() . '" class="'.$read_more_class .'">' . trim($readmore_matches[1]) . '</a>';
395
  } elseif ( $readmore ) {
396
+ $text .= ' <a href="' . $this->get_permalink() . '" class="'.$read_more_class .'">' . trim($readmore) . '</a>';
397
  }
398
  if ( !$strip && $last_p_tag && ( strpos($text, '<p>') || strpos($text, '<p ') ) ) {
399
  $text .= '</p>';
717
 
718
  function get_comments($ct = 0, $order = 'wp', $type = 'comment', $status = 'approve', $CommentClass = 'TimberComment') {
719
 
720
+ global $overridden_cpage, $user_ID;
721
  $overridden_cpage = false;
722
 
723
+ $commenter = wp_get_current_commenter();
724
+ $comment_author_email = $commenter['comment_author_email'];
725
+
726
  $args = array('post_id' => $this->ID, 'status' => $status, 'order' => $order);
727
  if ( $ct > 0 ) {
728
  $args['number'] = $ct;
731
  $args['order'] = get_option('comment_order');
732
  }
733
 
734
+ if ( $user_ID ) {
735
+ $args['include_unapproved'] = array( $user_ID );
736
+ } elseif ( ! empty( $comment_author_email ) ) {
737
+ $args['include_unapproved'] = array( $comment_author_email );
738
+ }
739
+
740
  $comments = get_comments($args);
741
  $timber_comments = array();
742
 
844
  $term_class_objects[$taxonomy] = $terms;
845
  }
846
  }
 
847
  return $term_class_objects;
848
  }
849
 
968
  }
969
 
970
  /**
971
+ * @return int the number of comments on a post
972
  */
973
  public function get_comment_count() {
974
  if ( isset($this->ID) ) {
975
  return get_comments_number($this->ID);
 
 
976
  }
977
+ return 0;
978
  }
979
 
980
  /**
lib/timber-twig.php CHANGED
@@ -68,6 +68,7 @@ class TimberTwig {
68
  $twig->addFilter( new Twig_SimpleFilter( 'shortcodes', 'do_shortcode' ) );
69
  $twig->addFilter( new Twig_SimpleFilter( 'time_ago', array( $this, 'time_ago' ) ) );
70
  $twig->addFilter( new Twig_SimpleFilter( 'wpautop', 'wpautop' ) );
 
71
 
72
  $twig->addFilter( new Twig_SimpleFilter( 'relative', function ( $link ) {
73
  return TimberURLHelper::get_rel_url( $link, true );
@@ -317,4 +318,26 @@ class TimberTwig {
317
  }
318
  }
319
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
320
  }
68
  $twig->addFilter( new Twig_SimpleFilter( 'shortcodes', 'do_shortcode' ) );
69
  $twig->addFilter( new Twig_SimpleFilter( 'time_ago', array( $this, 'time_ago' ) ) );
70
  $twig->addFilter( new Twig_SimpleFilter( 'wpautop', 'wpautop' ) );
71
+ $twig->addFilter( new Twig_SimpleFilter( 'list', array( $this, 'add_list_separators' ) ) );
72
 
73
  $twig->addFilter( new Twig_SimpleFilter( 'relative', function ( $link ) {
74
  return TimberURLHelper::get_rel_url( $link, true );
318
  }
319
  }
320
 
321
+ /**
322
+ * @param array $arr
323
+ * @param string $first_delimiter
324
+ * @param string $second_delimiter
325
+ * @return string
326
+ */
327
+ function add_list_separators( $arr, $first_delimiter = ',', $second_delimiter = 'and' ) {
328
+ $length = count( $arr );
329
+ $list = '';
330
+ foreach( $arr as $index => $item ) {
331
+ if ( $index < $length - 2 ) {
332
+ $delimiter = $first_delimiter.' ';
333
+ } elseif ( $index == $length - 2 ) {
334
+ $delimiter = ' '.$second_delimiter.' ';
335
+ } else {
336
+ $delimiter = '';
337
+ }
338
+ $list = $list.$item.$delimiter;
339
+ }
340
+ return $list;
341
+ }
342
+
343
  }
readme.txt CHANGED
@@ -1,8 +1,8 @@
1
  === Timber ===
2
- Contributors: jarednova
3
  Tags: template engine, templates, twig
4
  Requires at least: 3.7
5
- Stable tag: 0.22.2
6
  Tested up to: 4.3.1
7
  PHP version: 5.3.0 or greater
8
  License: GPLv2 or later
@@ -17,7 +17,7 @@ Once Timber is installed and activated in your plugin directory, it gives any Wo
17
 
18
  ### Looking for docs?
19
  * **[Project Page](http://upstatement.com/timber)**
20
- * [Timber Documentation](https://github.com/jarednova/timber/wiki/)
21
  * [Twig Reference (from SensioLabs)](http://twig.sensiolabs.org/doc/templates.html)
22
  _Twig is the template language powering Timber; if you need a little background on what a template language is, [Twig's homepage has an overview](http://twig.sensiolabs.org/)_
23
  * **[Video Tutorials](https://github.com/jarednova/timber/wiki/Video-Tutorials)**
@@ -41,6 +41,11 @@ Timber is great for any WordPress developer who cares about writing good, mainta
41
 
42
  == Changelog ==
43
 
 
 
 
 
 
44
  = 0.22.2 =
45
  * New .time method for TimberPost and TimberComment (thanks @lggorman)
46
  * Added support for WordPress's quality filter when resizing (thanks @t-wright)
1
  === Timber ===
2
+ Contributors: jarednova, lggorman
3
  Tags: template engine, templates, twig
4
  Requires at least: 3.7
5
+ Stable tag: 0.22.3
6
  Tested up to: 4.3.1
7
  PHP version: 5.3.0 or greater
8
  License: GPLv2 or later
17
 
18
  ### Looking for docs?
19
  * **[Project Page](http://upstatement.com/timber)**
20
+ * [Timber Documentation](https://jarednova.github.io/timber/)
21
  * [Twig Reference (from SensioLabs)](http://twig.sensiolabs.org/doc/templates.html)
22
  _Twig is the template language powering Timber; if you need a little background on what a template language is, [Twig's homepage has an overview](http://twig.sensiolabs.org/)_
23
  * **[Video Tutorials](https://github.com/jarednova/timber/wiki/Video-Tutorials)**
41
 
42
  == Changelog ==
43
 
44
+ = 0.22.3 =
45
+ * Fixed-up conditional for when comments are being moderated (thanks @lggorman)
46
+ * Fixed hooks for when attachments are deleted (thanks @lgaechter)
47
+ * Added a new filter for `list` (thanks @lggorman)
48
+
49
  = 0.22.2 =
50
  * New .time method for TimberPost and TimberComment (thanks @lggorman)
51
  * Added support for WordPress's quality filter when resizing (thanks @t-wright)
timber-starter-theme/bin/install-wp-tests.sh CHANGED
@@ -1,78 +1,112 @@
1
  #!/usr/bin/env bash
2
 
3
  if [ $# -lt 3 ]; then
4
- echo "usage: $0 <db-name> <db-user> <db-pass> [db-host] [wp-version]"
5
- exit 1
6
  fi
7
 
8
  DB_NAME=$1
9
  DB_USER=$2
10
  DB_PASS=$3
11
  DB_HOST=${4-localhost}
12
- WP_VERSION=${5-master}
13
 
14
  WP_TESTS_DIR=${WP_TESTS_DIR-/tmp/wordpress-tests-lib}
15
- WP_CORE_DIR=/tmp/wordpress/
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
 
17
  set -ex
18
 
19
  install_wp() {
20
- mkdir -p $WP_CORE_DIR
21
 
22
- if [ $WP_VERSION == 'latest' ]; then
23
- local ARCHIVE_NAME='latest'
24
- else
25
- local ARCHIVE_NAME="wordpress-$WP_VERSION"
26
- fi
27
 
28
- wget -nv -O /tmp/wordpress.tar.gz http://wordpress.org/${ARCHIVE_NAME}.tar.gz
29
- tar --strip-components=1 -zxmf /tmp/wordpress.tar.gz -C $WP_CORE_DIR
30
 
31
- wget -nv -O $WP_CORE_DIR/wp-content/db.php https://raw.github.com/markoheijnen/wp-mysqli/master/db.php
 
 
 
 
 
 
 
 
 
32
  }
33
 
34
  install_test_suite() {
35
- # portable in-place argument for both GNU sed and Mac OSX sed
36
- if [[ $(uname -s) == 'Darwin' ]]; then
37
- local ioption='-i ""'
38
- else
39
- local ioption='-i'
40
- fi
41
 
 
 
42
  # set up testing suite
43
  mkdir -p $WP_TESTS_DIR
44
- cd $WP_TESTS_DIR
45
- svn co --quiet http://develop.svn.wordpress.org/trunk/tests/phpunit/includes/
46
-
47
- wget -nv -O wp-tests-config.php http://develop.svn.wordpress.org/trunk/wp-tests-config-sample.php
48
- sed $ioption "s:dirname( __FILE__ ) . '/src/':'$WP_CORE_DIR':" wp-tests-config.php
49
- sed $ioption "s/youremptytestdbnamehere/$DB_NAME/" wp-tests-config.php
50
- sed $ioption "s/yourusernamehere/$DB_USER/" wp-tests-config.php
51
- sed $ioption "s/yourpasswordhere/$DB_PASS/" wp-tests-config.php
52
- sed $ioption "s|localhost|${DB_HOST}|" wp-tests-config.php
 
 
 
 
 
53
  }
54
 
55
  install_db() {
56
- # parse DB_HOST for port or socket references
57
- local PARTS=(${DB_HOST//\:/ })
58
- local DB_HOSTNAME=${PARTS[0]};
59
- local DB_SOCK_OR_PORT=${PARTS[1]};
60
- local EXTRA=""
61
-
62
- if ! [ -z $DB_HOSTNAME ] ; then
63
- if [[ "$DB_SOCK_OR_PORT" =~ ^[0-9]+$ ]] ; then
64
- EXTRA=" --host=$DB_HOSTNAME --port=$DB_SOCK_OR_PORT --protocol=tcp"
65
- elif ! [ -z $DB_SOCK_OR_PORT ] ; then
66
- EXTRA=" --socket=$DB_SOCK_OR_PORT"
67
- elif ! [ -z $DB_HOSTNAME ] ; then
68
- EXTRA=" --host=$DB_HOSTNAME --protocol=tcp"
69
- fi
70
  fi
 
71
 
72
- # create database
73
- mysqladmin create $DB_NAME --user="$DB_USER" --password="$DB_PASS"$EXTRA
74
  }
75
 
76
  install_wp
77
  install_test_suite
78
- install_db
1
  #!/usr/bin/env bash
2
 
3
  if [ $# -lt 3 ]; then
4
+ echo "usage: $0 <db-name> <db-user> <db-pass> [db-host] [wp-version]"
5
+ exit 1
6
  fi
7
 
8
  DB_NAME=$1
9
  DB_USER=$2
10
  DB_PASS=$3
11
  DB_HOST=${4-localhost}
12
+ WP_VERSION=${5-latest}
13
 
14
  WP_TESTS_DIR=${WP_TESTS_DIR-/tmp/wordpress-tests-lib}
15
+ WP_CORE_DIR=${WP_CORE_DIR-/tmp/wordpress/}
16
+
17
+ download() {
18
+ if [ `which curl` ]; then
19
+ curl -s "$1" > "$2";
20
+ elif [ `which wget` ]; then
21
+ wget -nv -O "$2" "$1"
22
+ fi
23
+ }
24
+
25
+ if [[ $WP_VERSION =~ [0-9]+\.[0-9]+(\.[0-9]+)? ]]; then
26
+ WP_TESTS_TAG="tags/$WP_VERSION"
27
+ else
28
+ # http serves a single offer, whereas https serves multiple. we only want one
29
+ download http://api.wordpress.org/core/version-check/1.7/ /tmp/wp-latest.json
30
+ grep '[0-9]+\.[0-9]+(\.[0-9]+)?' /tmp/wp-latest.json
31
+ LATEST_VERSION=$(grep -o '"version":"[^"]*' /tmp/wp-latest.json | sed 's/"version":"//')
32
+ if [[ -z "$LATEST_VERSION" ]]; then
33
+ echo "Latest WordPress version could not be found"
34
+ exit 1
35
+ fi
36
+ WP_TESTS_TAG="tags/$LATEST_VERSION"
37
+ fi
38
 
39
  set -ex
40
 
41
  install_wp() {
 
42
 
43
+ if [ -d $WP_CORE_DIR ]; then
44
+ return;
45
+ fi
 
 
46
 
47
+ mkdir -p $WP_CORE_DIR
 
48
 
49
+ if [ $WP_VERSION == 'latest' ]; then
50
+ local ARCHIVE_NAME='latest'
51
+ else
52
+ local ARCHIVE_NAME="wordpress-$WP_VERSION"
53
+ fi
54
+
55
+ download https://wordpress.org/${ARCHIVE_NAME}.tar.gz /tmp/wordpress.tar.gz
56
+ tar --strip-components=1 -zxmf /tmp/wordpress.tar.gz -C $WP_CORE_DIR
57
+
58
+ download https://raw.github.com/markoheijnen/wp-mysqli/master/db.php $WP_CORE_DIR/wp-content/db.php
59
  }
60
 
61
  install_test_suite() {
62
+ # portable in-place argument for both GNU sed and Mac OSX sed
63
+ if [[ $(uname -s) == 'Darwin' ]]; then
64
+ local ioption='-i .bak'
65
+ else
66
+ local ioption='-i'
67
+ fi
68
 
69
+ # set up testing suite if it doesn't yet exist
70
+ if [ ! -d $WP_TESTS_DIR ]; then
71
  # set up testing suite
72
  mkdir -p $WP_TESTS_DIR
73
+ svn co --quiet https://develop.svn.wordpress.org/${WP_TESTS_TAG}/tests/phpunit/includes/ $WP_TESTS_DIR/includes
74
+ fi
75
+
76
+ cd $WP_TESTS_DIR
77
+
78
+ if [ ! -f wp-tests-config.php ]; then
79
+ download https://develop.svn.wordpress.org/${WP_TESTS_TAG}/wp-tests-config-sample.php "$WP_TESTS_DIR"/wp-tests-config.php
80
+ sed $ioption "s:dirname( __FILE__ ) . '/src/':'$WP_CORE_DIR':" "$WP_TESTS_DIR"/wp-tests-config.php
81
+ sed $ioption "s/youremptytestdbnamehere/$DB_NAME/" "$WP_TESTS_DIR"/wp-tests-config.php
82
+ sed $ioption "s/yourusernamehere/$DB_USER/" "$WP_TESTS_DIR"/wp-tests-config.php
83
+ sed $ioption "s/yourpasswordhere/$DB_PASS/" "$WP_TESTS_DIR"/wp-tests-config.php
84
+ sed $ioption "s|localhost|${DB_HOST}|" "$WP_TESTS_DIR"/wp-tests-config.php
85
+ fi
86
+
87
  }
88
 
89
  install_db() {
90
+ # parse DB_HOST for port or socket references
91
+ local PARTS=(${DB_HOST//\:/ })
92
+ local DB_HOSTNAME=${PARTS[0]};
93
+ local DB_SOCK_OR_PORT=${PARTS[1]};
94
+ local EXTRA=""
95
+
96
+ if ! [ -z $DB_HOSTNAME ] ; then
97
+ if [ $(echo $DB_SOCK_OR_PORT | grep -e '^[0-9]\{1,\}$') ]; then
98
+ EXTRA=" --host=$DB_HOSTNAME --port=$DB_SOCK_OR_PORT --protocol=tcp"
99
+ elif ! [ -z $DB_SOCK_OR_PORT ] ; then
100
+ EXTRA=" --socket=$DB_SOCK_OR_PORT"
101
+ elif ! [ -z $DB_HOSTNAME ] ; then
102
+ EXTRA=" --host=$DB_HOSTNAME --protocol=tcp"
 
103
  fi
104
+ fi
105
 
106
+ # create database
107
+ mysqladmin create $DB_NAME --user="$DB_USER" --password="$DB_PASS"$EXTRA
108
  }
109
 
110
  install_wp
111
  install_test_suite
112
+ install_db
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: 0.22.2
8
  Author URI: http://upstatement.com/
9
  */
10
 
@@ -50,6 +50,9 @@ class Timber {
50
  public static $auto_meta = true;
51
  public static $autoescape = false;
52
 
 
 
 
53
  public function __construct() {
54
  if ( !defined('ABSPATH') ) {
55
  return;
@@ -59,6 +62,11 @@ class Timber {
59
  $this->init();
60
  }
61
 
 
 
 
 
 
62
  protected function test_compatibility() {
63
  if ( is_admin() || $_SERVER['PHP_SELF'] == '/wp-login.php' ) {
64
  return;
@@ -75,6 +83,9 @@ class Timber {
75
  defined( "TIMBER_LOC" ) or define( "TIMBER_LOC", realpath( __DIR__ ) );
76
  }
77
 
 
 
 
78
  protected function init() {
79
  TimberTwig::init();
80
  TimberRoutes::init( $this );
@@ -465,10 +476,16 @@ class Timber {
465
  Routes::map( $route, $callback, $args );
466
  }
467
 
 
 
 
468
  public function cancel_query() {
469
  add_action( 'posts_request', array( $this, 'cancel_query_posts_request' ) );
470
  }
471
 
 
 
 
472
  function cancel_query_posts_request() {
473
  if ( is_main_query() ) {
474
  wp_reset_query();
@@ -566,7 +583,7 @@ class Timber {
566
  /**
567
  * Get calling script dir.
568
  *
569
- * @return boolean|string
570
  */
571
  public static function get_calling_script_dir( $offset = 0 ) {
572
  $caller = self::get_calling_script_file( $offset );
@@ -575,7 +592,6 @@ class Timber {
575
  $dir = $pathinfo['dirname'];
576
  return $dir;
577
  }
578
- return null;
579
  }
580
 
581
  /**
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: 0.22.3
8
  Author URI: http://upstatement.com/
9
  */
10
 
50
  public static $auto_meta = true;
51
  public static $autoescape = false;
52
 
53
+ /**
54
+ * @codeCoverageIgnore
55
+ */
56
  public function __construct() {
57
  if ( !defined('ABSPATH') ) {
58
  return;
62
  $this->init();
63
  }
64
 
65
+ /**
66
+ * Tests whether we can use Timber
67
+ * @codeCoverageIgnore
68
+ * @return
69
+ */
70
  protected function test_compatibility() {
71
  if ( is_admin() || $_SERVER['PHP_SELF'] == '/wp-login.php' ) {
72
  return;
83
  defined( "TIMBER_LOC" ) or define( "TIMBER_LOC", realpath( __DIR__ ) );
84
  }
85
 
86
+ /**
87
+ * @codeCoverageIgnore
88
+ */
89
  protected function init() {
90
  TimberTwig::init();
91
  TimberRoutes::init( $this );
476
  Routes::map( $route, $callback, $args );
477
  }
478
 
479
+ /**
480
+ * @deprecated since 0.22.2
481
+ */
482
  public function cancel_query() {
483
  add_action( 'posts_request', array( $this, 'cancel_query_posts_request' ) );
484
  }
485
 
486
+ /**
487
+ * @deprecated since 0.22.2
488
+ */
489
  function cancel_query_posts_request() {
490
  if ( is_main_query() ) {
491
  wp_reset_query();
583
  /**
584
  * Get calling script dir.
585
  *
586
+ * @return string
587
  */
588
  public static function get_calling_script_dir( $offset = 0 ) {
589
  $caller = self::get_calling_script_file( $offset );
592
  $dir = $pathinfo['dirname'];
593
  return $dir;
594
  }
 
595
  }
596
 
597
  /**
vendor/autoload.php CHANGED
@@ -4,4 +4,4 @@
4
 
5
  require_once __DIR__ . '/composer' . '/autoload_real.php';
6
 
7
- return ComposerAutoloaderInit6e3042e2ec56b2cc1bf8c8c9efe69b8e::getLoader();
4
 
5
  require_once __DIR__ . '/composer' . '/autoload_real.php';
6
 
7
+ return ComposerAutoloaderInit2d2b9fafc2334be2a58d651726da1d81::getLoader();
vendor/composer/autoload_real.php CHANGED
@@ -2,7 +2,7 @@
2
 
3
  // autoload_real.php @generated by Composer
4
 
5
- class ComposerAutoloaderInit6e3042e2ec56b2cc1bf8c8c9efe69b8e
6
  {
7
  private static $loader;
8
 
@@ -19,9 +19,9 @@ class ComposerAutoloaderInit6e3042e2ec56b2cc1bf8c8c9efe69b8e
19
  return self::$loader;
20
  }
21
 
22
- spl_autoload_register(array('ComposerAutoloaderInit6e3042e2ec56b2cc1bf8c8c9efe69b8e', 'loadClassLoader'), true, true);
23
  self::$loader = $loader = new \Composer\Autoload\ClassLoader();
24
- spl_autoload_unregister(array('ComposerAutoloaderInit6e3042e2ec56b2cc1bf8c8c9efe69b8e', 'loadClassLoader'));
25
 
26
  $map = require __DIR__ . '/autoload_namespaces.php';
27
  foreach ($map as $namespace => $path) {
@@ -44,7 +44,7 @@ class ComposerAutoloaderInit6e3042e2ec56b2cc1bf8c8c9efe69b8e
44
  }
45
  }
46
 
47
- function composerRequire6e3042e2ec56b2cc1bf8c8c9efe69b8e($file)
48
  {
49
  require $file;
50
  }
2
 
3
  // autoload_real.php @generated by Composer
4
 
5
+ class ComposerAutoloaderInit2d2b9fafc2334be2a58d651726da1d81
6
  {
7
  private static $loader;
8
 
19
  return self::$loader;
20
  }
21
 
22
+ spl_autoload_register(array('ComposerAutoloaderInit2d2b9fafc2334be2a58d651726da1d81', 'loadClassLoader'), true, true);
23
  self::$loader = $loader = new \Composer\Autoload\ClassLoader();
24
+ spl_autoload_unregister(array('ComposerAutoloaderInit2d2b9fafc2334be2a58d651726da1d81', 'loadClassLoader'));
25
 
26
  $map = require __DIR__ . '/autoload_namespaces.php';
27
  foreach ($map as $namespace => $path) {
44
  }
45
  }
46
 
47
+ function composerRequire2d2b9fafc2334be2a58d651726da1d81($file)
48
  {
49
  require $file;
50
  }