@@ -2,57 +2,57 @@ |
||
2 | 2 | |
3 | 3 | class ACFTimber { |
4 | 4 | |
5 | - function __construct() { |
|
6 | - add_filter( 'timber_post_get_meta', array( $this, 'post_get_meta' ), 10, 2 ); |
|
7 | - add_filter( 'timber_post_get_meta_field', array( $this, 'post_get_meta_field' ), 10, 3 ); |
|
8 | - add_filter( 'timber_term_get_meta', array( $this, 'term_get_meta' ), 10, 3 ); |
|
9 | - add_filter( 'timber_term_get_meta_field', array( $this, 'term_get_meta_field' ), 10, 4 ); |
|
10 | - add_filter( 'timber_user_get_meta_field_pre', array( $this, 'user_get_meta_field' ), 10, 3 ); |
|
11 | - add_filter( 'timber_term_set_meta', array( $this, 'term_set_meta'), 10, 4 ); |
|
12 | - } |
|
13 | - |
|
14 | - function post_get_meta( $customs, $post_id ) { |
|
15 | - return $customs; |
|
16 | - } |
|
17 | - |
|
18 | - function post_get_meta_field( $value, $post_id, $field_name ) { |
|
19 | - return get_field( $field_name, $post_id ); |
|
20 | - } |
|
21 | - |
|
22 | - function term_get_meta_field( $value, $term_id, $field_name, $term ) { |
|
23 | - $searcher = $term->taxonomy . "_" . $term->ID; |
|
24 | - return get_field( $field_name, $searcher ); |
|
25 | - } |
|
26 | - |
|
27 | - function term_set_meta( $value, $field, $term_id, $term ) { |
|
28 | - $searcher = $term->taxonomy . "_" . $term->ID; |
|
29 | - update_field( $field, $value, $searcher ); |
|
30 | - return $value; |
|
31 | - } |
|
32 | - |
|
33 | - function term_get_meta( $fields, $term_id, $term ) { |
|
34 | - $searcher = $term->taxonomy . "_" . $term->ID; // save to a specific category |
|
35 | - $fds = get_fields( $searcher ); |
|
36 | - if ( is_array( $fds ) ) { |
|
37 | - foreach ( $fds as $key => $value ) { |
|
38 | - $key = preg_replace( '/_/', '', $key, 1 ); |
|
39 | - $key = str_replace( $searcher, '', $key ); |
|
40 | - $key = preg_replace( '/_/', '', $key, 1 ); |
|
41 | - $field = get_field( $key, $searcher ); |
|
42 | - $fields[$key] = $field; |
|
43 | - } |
|
44 | - $fields = array_merge( $fields, $fds ); |
|
45 | - } |
|
46 | - return $fields; |
|
47 | - } |
|
48 | - |
|
49 | - function user_get_meta( $fields, $user_id ) { |
|
50 | - return $fields; |
|
51 | - } |
|
52 | - |
|
53 | - function user_get_meta_field( $value, $uid, $field ) { |
|
54 | - return get_field( $field, 'user_' . $uid ); |
|
55 | - } |
|
5 | + function __construct() { |
|
6 | + add_filter( 'timber_post_get_meta', array( $this, 'post_get_meta' ), 10, 2 ); |
|
7 | + add_filter( 'timber_post_get_meta_field', array( $this, 'post_get_meta_field' ), 10, 3 ); |
|
8 | + add_filter( 'timber_term_get_meta', array( $this, 'term_get_meta' ), 10, 3 ); |
|
9 | + add_filter( 'timber_term_get_meta_field', array( $this, 'term_get_meta_field' ), 10, 4 ); |
|
10 | + add_filter( 'timber_user_get_meta_field_pre', array( $this, 'user_get_meta_field' ), 10, 3 ); |
|
11 | + add_filter( 'timber_term_set_meta', array( $this, 'term_set_meta'), 10, 4 ); |
|
12 | + } |
|
13 | + |
|
14 | + function post_get_meta( $customs, $post_id ) { |
|
15 | + return $customs; |
|
16 | + } |
|
17 | + |
|
18 | + function post_get_meta_field( $value, $post_id, $field_name ) { |
|
19 | + return get_field( $field_name, $post_id ); |
|
20 | + } |
|
21 | + |
|
22 | + function term_get_meta_field( $value, $term_id, $field_name, $term ) { |
|
23 | + $searcher = $term->taxonomy . "_" . $term->ID; |
|
24 | + return get_field( $field_name, $searcher ); |
|
25 | + } |
|
26 | + |
|
27 | + function term_set_meta( $value, $field, $term_id, $term ) { |
|
28 | + $searcher = $term->taxonomy . "_" . $term->ID; |
|
29 | + update_field( $field, $value, $searcher ); |
|
30 | + return $value; |
|
31 | + } |
|
32 | + |
|
33 | + function term_get_meta( $fields, $term_id, $term ) { |
|
34 | + $searcher = $term->taxonomy . "_" . $term->ID; // save to a specific category |
|
35 | + $fds = get_fields( $searcher ); |
|
36 | + if ( is_array( $fds ) ) { |
|
37 | + foreach ( $fds as $key => $value ) { |
|
38 | + $key = preg_replace( '/_/', '', $key, 1 ); |
|
39 | + $key = str_replace( $searcher, '', $key ); |
|
40 | + $key = preg_replace( '/_/', '', $key, 1 ); |
|
41 | + $field = get_field( $key, $searcher ); |
|
42 | + $fields[$key] = $field; |
|
43 | + } |
|
44 | + $fields = array_merge( $fields, $fds ); |
|
45 | + } |
|
46 | + return $fields; |
|
47 | + } |
|
48 | + |
|
49 | + function user_get_meta( $fields, $user_id ) { |
|
50 | + return $fields; |
|
51 | + } |
|
52 | + |
|
53 | + function user_get_meta_field( $value, $uid, $field ) { |
|
54 | + return get_field( $field, 'user_' . $uid ); |
|
55 | + } |
|
56 | 56 | } |
57 | 57 | |
58 | 58 |
@@ -3,12 +3,12 @@ discard block |
||
3 | 3 | class ACFTimber { |
4 | 4 | |
5 | 5 | function __construct() { |
6 | - add_filter( 'timber_post_get_meta', array( $this, 'post_get_meta' ), 10, 2 ); |
|
7 | - add_filter( 'timber_post_get_meta_field', array( $this, 'post_get_meta_field' ), 10, 3 ); |
|
8 | - add_filter( 'timber_term_get_meta', array( $this, 'term_get_meta' ), 10, 3 ); |
|
9 | - add_filter( 'timber_term_get_meta_field', array( $this, 'term_get_meta_field' ), 10, 4 ); |
|
10 | - add_filter( 'timber_user_get_meta_field_pre', array( $this, 'user_get_meta_field' ), 10, 3 ); |
|
11 | - add_filter( 'timber_term_set_meta', array( $this, 'term_set_meta'), 10, 4 ); |
|
6 | + add_filter('timber_post_get_meta', array($this, 'post_get_meta'), 10, 2); |
|
7 | + add_filter('timber_post_get_meta_field', array($this, 'post_get_meta_field'), 10, 3); |
|
8 | + add_filter('timber_term_get_meta', array($this, 'term_get_meta'), 10, 3); |
|
9 | + add_filter('timber_term_get_meta_field', array($this, 'term_get_meta_field'), 10, 4); |
|
10 | + add_filter('timber_user_get_meta_field_pre', array($this, 'user_get_meta_field'), 10, 3); |
|
11 | + add_filter('timber_term_set_meta', array($this, 'term_set_meta'), 10, 4); |
|
12 | 12 | } |
13 | 13 | |
14 | 14 | function post_get_meta( $customs, $post_id ) { |
@@ -16,32 +16,32 @@ discard block |
||
16 | 16 | } |
17 | 17 | |
18 | 18 | function post_get_meta_field( $value, $post_id, $field_name ) { |
19 | - return get_field( $field_name, $post_id ); |
|
19 | + return get_field($field_name, $post_id); |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | function term_get_meta_field( $value, $term_id, $field_name, $term ) { |
23 | 23 | $searcher = $term->taxonomy . "_" . $term->ID; |
24 | - return get_field( $field_name, $searcher ); |
|
24 | + return get_field($field_name, $searcher); |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | function term_set_meta( $value, $field, $term_id, $term ) { |
28 | 28 | $searcher = $term->taxonomy . "_" . $term->ID; |
29 | - update_field( $field, $value, $searcher ); |
|
29 | + update_field($field, $value, $searcher); |
|
30 | 30 | return $value; |
31 | 31 | } |
32 | 32 | |
33 | 33 | function term_get_meta( $fields, $term_id, $term ) { |
34 | 34 | $searcher = $term->taxonomy . "_" . $term->ID; // save to a specific category |
35 | - $fds = get_fields( $searcher ); |
|
36 | - if ( is_array( $fds ) ) { |
|
35 | + $fds = get_fields($searcher); |
|
36 | + if ( is_array($fds) ) { |
|
37 | 37 | foreach ( $fds as $key => $value ) { |
38 | - $key = preg_replace( '/_/', '', $key, 1 ); |
|
39 | - $key = str_replace( $searcher, '', $key ); |
|
40 | - $key = preg_replace( '/_/', '', $key, 1 ); |
|
41 | - $field = get_field( $key, $searcher ); |
|
38 | + $key = preg_replace('/_/', '', $key, 1); |
|
39 | + $key = str_replace($searcher, '', $key); |
|
40 | + $key = preg_replace('/_/', '', $key, 1); |
|
41 | + $field = get_field($key, $searcher); |
|
42 | 42 | $fields[$key] = $field; |
43 | 43 | } |
44 | - $fields = array_merge( $fields, $fds ); |
|
44 | + $fields = array_merge($fields, $fds); |
|
45 | 45 | } |
46 | 46 | return $fields; |
47 | 47 | } |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | } |
52 | 52 | |
53 | 53 | function user_get_meta_field( $value, $uid, $field ) { |
54 | - return get_field( $field, 'user_' . $uid ); |
|
54 | + return get_field($field, 'user_' . $uid); |
|
55 | 55 | } |
56 | 56 | } |
57 | 57 |
@@ -6,31 +6,31 @@ |
||
6 | 6 | */ |
7 | 7 | class TimberCommand { |
8 | 8 | |
9 | - public static function clear_cache($mode = 'all'){ |
|
10 | - if (is_array($mode)){ |
|
11 | - $mode = reset($mode); |
|
12 | - } |
|
13 | - if ($mode == 'all') { |
|
14 | - $twig_cache = self::clear_cache_twig(); |
|
15 | - $timber_cache = self::clear_cache_timber(); |
|
16 | - if ($twig_cache && $timber_cache){ |
|
17 | - return true; |
|
18 | - } |
|
19 | - } else if ($mode == 'twig') { |
|
20 | - return self::clear_cache_twig(); |
|
21 | - } else if ($mode == 'timber') { |
|
22 | - return self::clear_cache_timber(); |
|
23 | - } |
|
24 | - } |
|
9 | + public static function clear_cache($mode = 'all'){ |
|
10 | + if (is_array($mode)){ |
|
11 | + $mode = reset($mode); |
|
12 | + } |
|
13 | + if ($mode == 'all') { |
|
14 | + $twig_cache = self::clear_cache_twig(); |
|
15 | + $timber_cache = self::clear_cache_timber(); |
|
16 | + if ($twig_cache && $timber_cache){ |
|
17 | + return true; |
|
18 | + } |
|
19 | + } else if ($mode == 'twig') { |
|
20 | + return self::clear_cache_twig(); |
|
21 | + } else if ($mode == 'timber') { |
|
22 | + return self::clear_cache_timber(); |
|
23 | + } |
|
24 | + } |
|
25 | 25 | |
26 | - static function clear_cache_timber(){ |
|
27 | - $loader = new TimberLoader(); |
|
28 | - return $loader->clear_cache_timber(); |
|
29 | - } |
|
26 | + static function clear_cache_timber(){ |
|
27 | + $loader = new TimberLoader(); |
|
28 | + return $loader->clear_cache_timber(); |
|
29 | + } |
|
30 | 30 | |
31 | - static function clear_cache_twig(){ |
|
32 | - $loader = new TimberLoader(); |
|
33 | - return $loader->clear_cache_twig(); |
|
34 | - } |
|
31 | + static function clear_cache_twig(){ |
|
32 | + $loader = new TimberLoader(); |
|
33 | + return $loader->clear_cache_twig(); |
|
34 | + } |
|
35 | 35 | |
36 | 36 | } |
@@ -6,29 +6,29 @@ |
||
6 | 6 | */ |
7 | 7 | class TimberCommand { |
8 | 8 | |
9 | - public static function clear_cache($mode = 'all'){ |
|
10 | - if (is_array($mode)){ |
|
9 | + public static function clear_cache( $mode = 'all' ) { |
|
10 | + if ( is_array($mode) ) { |
|
11 | 11 | $mode = reset($mode); |
12 | 12 | } |
13 | - if ($mode == 'all') { |
|
13 | + if ( $mode == 'all' ) { |
|
14 | 14 | $twig_cache = self::clear_cache_twig(); |
15 | 15 | $timber_cache = self::clear_cache_timber(); |
16 | - if ($twig_cache && $timber_cache){ |
|
16 | + if ( $twig_cache && $timber_cache ) { |
|
17 | 17 | return true; |
18 | 18 | } |
19 | - } else if ($mode == 'twig') { |
|
19 | + } else if ( $mode == 'twig' ) { |
|
20 | 20 | return self::clear_cache_twig(); |
21 | - } else if ($mode == 'timber') { |
|
21 | + } else if ( $mode == 'timber' ) { |
|
22 | 22 | return self::clear_cache_timber(); |
23 | 23 | } |
24 | 24 | } |
25 | 25 | |
26 | - static function clear_cache_timber(){ |
|
26 | + static function clear_cache_timber() { |
|
27 | 27 | $loader = new TimberLoader(); |
28 | 28 | return $loader->clear_cache_timber(); |
29 | 29 | } |
30 | 30 | |
31 | - static function clear_cache_twig(){ |
|
31 | + static function clear_cache_twig() { |
|
32 | 32 | $loader = new TimberLoader(); |
33 | 33 | return $loader->clear_cache_twig(); |
34 | 34 | } |
@@ -5,53 +5,53 @@ |
||
5 | 5 | |
6 | 6 | class Timber_WP_CLI_Command extends WP_CLI_Command { |
7 | 7 | |
8 | - /** |
|
9 | - * Clears Timber and Twig's Cache |
|
10 | - * |
|
11 | - * ## EXAMPLES |
|
12 | - * |
|
13 | - * wp timber clear_cache |
|
14 | - * |
|
15 | - */ |
|
16 | - public function clear_cache($mode = 'all') { |
|
17 | - TimberCommand::clear_cache($mode); |
|
18 | - } |
|
8 | + /** |
|
9 | + * Clears Timber and Twig's Cache |
|
10 | + * |
|
11 | + * ## EXAMPLES |
|
12 | + * |
|
13 | + * wp timber clear_cache |
|
14 | + * |
|
15 | + */ |
|
16 | + public function clear_cache($mode = 'all') { |
|
17 | + TimberCommand::clear_cache($mode); |
|
18 | + } |
|
19 | 19 | |
20 | - /** |
|
21 | - * Clears Twig's Cache |
|
22 | - * |
|
23 | - * ## EXAMPLES |
|
24 | - * |
|
25 | - * wp timber clear_cache_twig |
|
26 | - * |
|
27 | - */ |
|
28 | - function clear_cache_twig(){ |
|
29 | - $clear = TimberCommand::clear_cache_twig(); |
|
30 | - if ($clear){ |
|
31 | - WP_CLI::success('Cleared contents of twig cache'); |
|
32 | - } else { |
|
33 | - WP_CLI::warning('Failed to clear twig cache'); |
|
34 | - } |
|
35 | - } |
|
20 | + /** |
|
21 | + * Clears Twig's Cache |
|
22 | + * |
|
23 | + * ## EXAMPLES |
|
24 | + * |
|
25 | + * wp timber clear_cache_twig |
|
26 | + * |
|
27 | + */ |
|
28 | + function clear_cache_twig(){ |
|
29 | + $clear = TimberCommand::clear_cache_twig(); |
|
30 | + if ($clear){ |
|
31 | + WP_CLI::success('Cleared contents of twig cache'); |
|
32 | + } else { |
|
33 | + WP_CLI::warning('Failed to clear twig cache'); |
|
34 | + } |
|
35 | + } |
|
36 | 36 | |
37 | - /** |
|
38 | - * Clears Timber's Cache |
|
39 | - * |
|
40 | - * ## EXAMPLES |
|
41 | - * |
|
42 | - * wp timber clear_cache_timber |
|
43 | - * |
|
44 | - */ |
|
45 | - function clear_cache_timber() { |
|
46 | - $clear = TimberCommand::clear_cache_timber(); |
|
47 | - $message = 'Failed to clear timber cache'; |
|
48 | - if ($clear){ |
|
49 | - $message = "Cleared contents of Timber's Cache"; |
|
50 | - WP_CLI::success($message); |
|
51 | - } else { |
|
52 | - WP_CLI::warning($message); |
|
53 | - } |
|
54 | - return $message; |
|
55 | - } |
|
37 | + /** |
|
38 | + * Clears Timber's Cache |
|
39 | + * |
|
40 | + * ## EXAMPLES |
|
41 | + * |
|
42 | + * wp timber clear_cache_timber |
|
43 | + * |
|
44 | + */ |
|
45 | + function clear_cache_timber() { |
|
46 | + $clear = TimberCommand::clear_cache_timber(); |
|
47 | + $message = 'Failed to clear timber cache'; |
|
48 | + if ($clear){ |
|
49 | + $message = "Cleared contents of Timber's Cache"; |
|
50 | + WP_CLI::success($message); |
|
51 | + } else { |
|
52 | + WP_CLI::warning($message); |
|
53 | + } |
|
54 | + return $message; |
|
55 | + } |
|
56 | 56 | |
57 | 57 | } |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if (!class_exists('WP_CLI_Command')) { |
|
2 | +if ( !class_exists('WP_CLI_Command') ) { |
|
3 | 3 | return; |
4 | 4 | } |
5 | 5 | |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | * wp timber clear_cache |
14 | 14 | * |
15 | 15 | */ |
16 | - public function clear_cache($mode = 'all') { |
|
16 | + public function clear_cache( $mode = 'all' ) { |
|
17 | 17 | TimberCommand::clear_cache($mode); |
18 | 18 | } |
19 | 19 | |
@@ -25,9 +25,9 @@ discard block |
||
25 | 25 | * wp timber clear_cache_twig |
26 | 26 | * |
27 | 27 | */ |
28 | - function clear_cache_twig(){ |
|
28 | + function clear_cache_twig() { |
|
29 | 29 | $clear = TimberCommand::clear_cache_twig(); |
30 | - if ($clear){ |
|
30 | + if ( $clear ) { |
|
31 | 31 | WP_CLI::success('Cleared contents of twig cache'); |
32 | 32 | } else { |
33 | 33 | WP_CLI::warning('Failed to clear twig cache'); |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | function clear_cache_timber() { |
46 | 46 | $clear = TimberCommand::clear_cache_timber(); |
47 | 47 | $message = 'Failed to clear timber cache'; |
48 | - if ($clear){ |
|
48 | + if ( $clear ) { |
|
49 | 49 | $message = "Cleared contents of Timber's Cache"; |
50 | 50 | WP_CLI::success($message); |
51 | 51 | } else { |
@@ -2,9 +2,9 @@ |
||
2 | 2 | |
3 | 3 | class TimberAdmin { |
4 | 4 | |
5 | - public static function init() { |
|
6 | - return add_filter( 'plugin_row_meta', array( __CLASS__, 'meta_links' ), 10, 2 ); |
|
7 | - } |
|
5 | + public static function init() { |
|
6 | + return add_filter( 'plugin_row_meta', array( __CLASS__, 'meta_links' ), 10, 2 ); |
|
7 | + } |
|
8 | 8 | |
9 | 9 | /** |
10 | 10 | * @param array $links |
@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | class TimberAdmin { |
4 | 4 | |
5 | 5 | public static function init() { |
6 | - return add_filter( 'plugin_row_meta', array( __CLASS__, 'meta_links' ), 10, 2 ); |
|
6 | + return add_filter('plugin_row_meta', array(__CLASS__, 'meta_links'), 10, 2); |
|
7 | 7 | } |
8 | 8 | |
9 | 9 | /** |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | * @return array |
13 | 13 | */ |
14 | 14 | public static function meta_links( $links, $file ) { |
15 | - if ( strstr( $file, '/timber.php' ) ) { |
|
15 | + if ( strstr($file, '/timber.php') ) { |
|
16 | 16 | unset($links[2]); |
17 | 17 | $links[] = '<a href="/wp-admin/plugin-install.php?tab=plugin-information&plugin=timber-library&TB_iframe=true&width=600&height=550" class="thickbox" aria-label="More information about Timber" data-title="Timber">View details</a>'; |
18 | 18 | $links[] = '<a href="http://upstatement.com/timber" target="_blank">Homepage</a>'; |
@@ -2,116 +2,116 @@ |
||
2 | 2 | |
3 | 3 | abstract class TimberCore { |
4 | 4 | |
5 | - public $id; |
|
6 | - public $ID; |
|
7 | - public $object_type; |
|
5 | + public $id; |
|
6 | + public $ID; |
|
7 | + public $object_type; |
|
8 | 8 | |
9 | - /** |
|
10 | - * |
|
11 | - * |
|
12 | - * @return boolean |
|
13 | - */ |
|
14 | - function __isset( $field ) { |
|
15 | - if ( isset( $this->$field ) ) { |
|
16 | - return $this->$field; |
|
17 | - } |
|
18 | - return false; |
|
19 | - } |
|
9 | + /** |
|
10 | + * |
|
11 | + * |
|
12 | + * @return boolean |
|
13 | + */ |
|
14 | + function __isset( $field ) { |
|
15 | + if ( isset( $this->$field ) ) { |
|
16 | + return $this->$field; |
|
17 | + } |
|
18 | + return false; |
|
19 | + } |
|
20 | 20 | |
21 | - /** |
|
22 | - * This is helpful for twig to return properties and methods see: https://github.com/fabpot/Twig/issues/2 |
|
23 | - * @return mixed |
|
24 | - */ |
|
25 | - function __call( $field, $args ) { |
|
26 | - return $this->__get( $field ); |
|
27 | - } |
|
21 | + /** |
|
22 | + * This is helpful for twig to return properties and methods see: https://github.com/fabpot/Twig/issues/2 |
|
23 | + * @return mixed |
|
24 | + */ |
|
25 | + function __call( $field, $args ) { |
|
26 | + return $this->__get( $field ); |
|
27 | + } |
|
28 | 28 | |
29 | - /** |
|
30 | - * This is helpful for twig to return properties and methods see: https://github.com/fabpot/Twig/issues/2 |
|
31 | - * |
|
32 | - * @return mixed |
|
33 | - */ |
|
34 | - function __get( $field ) { |
|
35 | - if ( property_exists($this, $field) ) { |
|
36 | - return $this->$field; |
|
37 | - } |
|
38 | - if ( method_exists($this, 'meta') && $meta_value = $this->meta( $field ) ) { |
|
39 | - return $this->$field = $meta_value; |
|
40 | - } |
|
41 | - if ( method_exists($this, $field) ) { |
|
42 | - return $this->$field = $this->$field(); |
|
43 | - } |
|
44 | - return $this->$field = false; |
|
45 | - } |
|
29 | + /** |
|
30 | + * This is helpful for twig to return properties and methods see: https://github.com/fabpot/Twig/issues/2 |
|
31 | + * |
|
32 | + * @return mixed |
|
33 | + */ |
|
34 | + function __get( $field ) { |
|
35 | + if ( property_exists($this, $field) ) { |
|
36 | + return $this->$field; |
|
37 | + } |
|
38 | + if ( method_exists($this, 'meta') && $meta_value = $this->meta( $field ) ) { |
|
39 | + return $this->$field = $meta_value; |
|
40 | + } |
|
41 | + if ( method_exists($this, $field) ) { |
|
42 | + return $this->$field = $this->$field(); |
|
43 | + } |
|
44 | + return $this->$field = false; |
|
45 | + } |
|
46 | 46 | |
47 | - /** |
|
48 | - * Takes an array or object and adds the properties to the parent object |
|
49 | - * @example |
|
50 | - * ```php |
|
51 | - * $data = array('airplane' => '757-200', 'flight' => '5316'); |
|
52 | - * $post = new TimberPost() |
|
53 | - * $post->import(data); |
|
54 | - * echo $post->airplane; //757-200 |
|
55 | - * ``` |
|
56 | - * @param array|object $info an object or array you want to grab data from to attach to the Timber object |
|
57 | - */ |
|
58 | - function import( $info, $force = false ) { |
|
59 | - if ( is_object( $info ) ) { |
|
60 | - $info = get_object_vars( $info ); |
|
61 | - } |
|
62 | - if ( is_array( $info ) ) { |
|
63 | - foreach ( $info as $key => $value ) { |
|
64 | - if ( !empty( $key ) && $force ) { |
|
65 | - $this->$key = $value; |
|
66 | - } else if ( !empty( $key ) && !method_exists($this, $key) ){ |
|
67 | - $this->$key = $value; |
|
68 | - } |
|
69 | - } |
|
70 | - } |
|
71 | - } |
|
47 | + /** |
|
48 | + * Takes an array or object and adds the properties to the parent object |
|
49 | + * @example |
|
50 | + * ```php |
|
51 | + * $data = array('airplane' => '757-200', 'flight' => '5316'); |
|
52 | + * $post = new TimberPost() |
|
53 | + * $post->import(data); |
|
54 | + * echo $post->airplane; //757-200 |
|
55 | + * ``` |
|
56 | + * @param array|object $info an object or array you want to grab data from to attach to the Timber object |
|
57 | + */ |
|
58 | + function import( $info, $force = false ) { |
|
59 | + if ( is_object( $info ) ) { |
|
60 | + $info = get_object_vars( $info ); |
|
61 | + } |
|
62 | + if ( is_array( $info ) ) { |
|
63 | + foreach ( $info as $key => $value ) { |
|
64 | + if ( !empty( $key ) && $force ) { |
|
65 | + $this->$key = $value; |
|
66 | + } else if ( !empty( $key ) && !method_exists($this, $key) ){ |
|
67 | + $this->$key = $value; |
|
68 | + } |
|
69 | + } |
|
70 | + } |
|
71 | + } |
|
72 | 72 | |
73 | 73 | |
74 | - /** |
|
75 | - * @ignore |
|
76 | - * @param string $key |
|
77 | - * @param mixed $value |
|
78 | - */ |
|
79 | - function update( $key, $value ) { |
|
80 | - update_metadata( $this->object_type, $this->ID, $key, $value ); |
|
81 | - } |
|
74 | + /** |
|
75 | + * @ignore |
|
76 | + * @param string $key |
|
77 | + * @param mixed $value |
|
78 | + */ |
|
79 | + function update( $key, $value ) { |
|
80 | + update_metadata( $this->object_type, $this->ID, $key, $value ); |
|
81 | + } |
|
82 | 82 | |
83 | - /** |
|
84 | - * Can you edit this post/term/user? Well good for you. You're no better than me. |
|
85 | - * @example |
|
86 | - * ```twig |
|
87 | - * {% if post.can_edit %} |
|
88 | - * <a href="{{ post.edit_link }}">Edit</a> |
|
89 | - * {% endif %} |
|
90 | - * ``` |
|
91 | - * ```html |
|
92 | - * <a href="http://example.org/wp-admin/edit.php?p=242">Edit</a> |
|
93 | - * ``` |
|
94 | - * @return bool |
|
95 | - */ |
|
96 | - function can_edit() { |
|
97 | - if ( !function_exists( 'current_user_can' ) ) { |
|
98 | - return false; |
|
99 | - } |
|
100 | - if ( current_user_can( 'edit_post', $this->ID ) ) { |
|
101 | - return true; |
|
102 | - } |
|
103 | - return false; |
|
104 | - } |
|
83 | + /** |
|
84 | + * Can you edit this post/term/user? Well good for you. You're no better than me. |
|
85 | + * @example |
|
86 | + * ```twig |
|
87 | + * {% if post.can_edit %} |
|
88 | + * <a href="{{ post.edit_link }}">Edit</a> |
|
89 | + * {% endif %} |
|
90 | + * ``` |
|
91 | + * ```html |
|
92 | + * <a href="http://example.org/wp-admin/edit.php?p=242">Edit</a> |
|
93 | + * ``` |
|
94 | + * @return bool |
|
95 | + */ |
|
96 | + function can_edit() { |
|
97 | + if ( !function_exists( 'current_user_can' ) ) { |
|
98 | + return false; |
|
99 | + } |
|
100 | + if ( current_user_can( 'edit_post', $this->ID ) ) { |
|
101 | + return true; |
|
102 | + } |
|
103 | + return false; |
|
104 | + } |
|
105 | 105 | |
106 | - /** |
|
107 | - * |
|
108 | - * |
|
109 | - * @return array |
|
110 | - */ |
|
111 | - function get_method_values() { |
|
112 | - $ret = array(); |
|
113 | - $ret['can_edit'] = $this->can_edit(); |
|
114 | - return $ret; |
|
115 | - } |
|
106 | + /** |
|
107 | + * |
|
108 | + * |
|
109 | + * @return array |
|
110 | + */ |
|
111 | + function get_method_values() { |
|
112 | + $ret = array(); |
|
113 | + $ret['can_edit'] = $this->can_edit(); |
|
114 | + return $ret; |
|
115 | + } |
|
116 | 116 | |
117 | 117 | } |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | * @return boolean |
13 | 13 | */ |
14 | 14 | function __isset( $field ) { |
15 | - if ( isset( $this->$field ) ) { |
|
15 | + if ( isset($this->$field) ) { |
|
16 | 16 | return $this->$field; |
17 | 17 | } |
18 | 18 | return false; |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | * @return mixed |
24 | 24 | */ |
25 | 25 | function __call( $field, $args ) { |
26 | - return $this->__get( $field ); |
|
26 | + return $this->__get($field); |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | /** |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | if ( property_exists($this, $field) ) { |
36 | 36 | return $this->$field; |
37 | 37 | } |
38 | - if ( method_exists($this, 'meta') && $meta_value = $this->meta( $field ) ) { |
|
38 | + if ( method_exists($this, 'meta') && $meta_value = $this->meta($field) ) { |
|
39 | 39 | return $this->$field = $meta_value; |
40 | 40 | } |
41 | 41 | if ( method_exists($this, $field) ) { |
@@ -56,14 +56,14 @@ discard block |
||
56 | 56 | * @param array|object $info an object or array you want to grab data from to attach to the Timber object |
57 | 57 | */ |
58 | 58 | function import( $info, $force = false ) { |
59 | - if ( is_object( $info ) ) { |
|
60 | - $info = get_object_vars( $info ); |
|
59 | + if ( is_object($info) ) { |
|
60 | + $info = get_object_vars($info); |
|
61 | 61 | } |
62 | - if ( is_array( $info ) ) { |
|
62 | + if ( is_array($info) ) { |
|
63 | 63 | foreach ( $info as $key => $value ) { |
64 | - if ( !empty( $key ) && $force ) { |
|
64 | + if ( !empty($key) && $force ) { |
|
65 | 65 | $this->$key = $value; |
66 | - } else if ( !empty( $key ) && !method_exists($this, $key) ){ |
|
66 | + } else if ( !empty($key) && !method_exists($this, $key) ) { |
|
67 | 67 | $this->$key = $value; |
68 | 68 | } |
69 | 69 | } |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | * @param mixed $value |
78 | 78 | */ |
79 | 79 | function update( $key, $value ) { |
80 | - update_metadata( $this->object_type, $this->ID, $key, $value ); |
|
80 | + update_metadata($this->object_type, $this->ID, $key, $value); |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | /** |
@@ -94,10 +94,10 @@ discard block |
||
94 | 94 | * @return bool |
95 | 95 | */ |
96 | 96 | function can_edit() { |
97 | - if ( !function_exists( 'current_user_can' ) ) { |
|
97 | + if ( !function_exists('current_user_can') ) { |
|
98 | 98 | return false; |
99 | 99 | } |
100 | - if ( current_user_can( 'edit_post', $this->ID ) ) { |
|
100 | + if ( current_user_can('edit_post', $this->ID) ) { |
|
101 | 101 | return true; |
102 | 102 | } |
103 | 103 | return false; |
@@ -5,20 +5,20 @@ |
||
5 | 5 | * @package timber |
6 | 6 | */ |
7 | 7 | class TimberIntegrations { |
8 | - public static function init() { |
|
8 | + public static function init() { |
|
9 | 9 | |
10 | - add_action( 'init', array( __CLASS__, 'maybe_init_acftimber' ) ); |
|
10 | + add_action( 'init', array( __CLASS__, 'maybe_init_acftimber' ) ); |
|
11 | 11 | |
12 | - if ( class_exists( 'WP_CLI_Command' ) ) { |
|
13 | - WP_CLI::add_command( 'timber', 'Timber_WP_CLI_Command' ); |
|
14 | - } |
|
15 | - } |
|
12 | + if ( class_exists( 'WP_CLI_Command' ) ) { |
|
13 | + WP_CLI::add_command( 'timber', 'Timber_WP_CLI_Command' ); |
|
14 | + } |
|
15 | + } |
|
16 | 16 | |
17 | - public static function maybe_init_acftimber() { |
|
17 | + public static function maybe_init_acftimber() { |
|
18 | 18 | |
19 | - if ( class_exists( 'ACF' ) ) { |
|
20 | - new ACFTimber(); |
|
21 | - } |
|
19 | + if ( class_exists( 'ACF' ) ) { |
|
20 | + new ACFTimber(); |
|
21 | + } |
|
22 | 22 | |
23 | - } |
|
23 | + } |
|
24 | 24 | } |
@@ -7,16 +7,16 @@ |
||
7 | 7 | class TimberIntegrations { |
8 | 8 | public static function init() { |
9 | 9 | |
10 | - add_action( 'init', array( __CLASS__, 'maybe_init_acftimber' ) ); |
|
10 | + add_action('init', array(__CLASS__, 'maybe_init_acftimber')); |
|
11 | 11 | |
12 | - if ( class_exists( 'WP_CLI_Command' ) ) { |
|
13 | - WP_CLI::add_command( 'timber', 'Timber_WP_CLI_Command' ); |
|
12 | + if ( class_exists('WP_CLI_Command') ) { |
|
13 | + WP_CLI::add_command('timber', 'Timber_WP_CLI_Command'); |
|
14 | 14 | } |
15 | 15 | } |
16 | 16 | |
17 | 17 | public static function maybe_init_acftimber() { |
18 | 18 | |
19 | - if ( class_exists( 'ACF' ) ) { |
|
19 | + if ( class_exists('ACF') ) { |
|
20 | 20 | new ACFTimber(); |
21 | 21 | } |
22 | 22 |
@@ -2,96 +2,96 @@ |
||
2 | 2 | |
3 | 3 | // Exit if accessed directly |
4 | 4 | if ( !defined( 'ABSPATH' ) ) |
5 | - exit; |
|
5 | + exit; |
|
6 | 6 | |
7 | 7 | class TimberPostsCollection extends ArrayObject { |
8 | 8 | |
9 | - public function __construct( $posts = array(), $post_class = 'TimberPost' ) { |
|
10 | - $returned_posts = array(); |
|
11 | - if ( is_null( $posts ) ){ |
|
12 | - $posts = array(); |
|
13 | - } |
|
14 | - foreach ( $posts as $post_object ) { |
|
15 | - $post_class_use = $post_class; |
|
16 | - |
|
17 | - if ( is_array( $post_class ) ) { |
|
18 | - $post_type = get_post_type( $post_object ); |
|
19 | - $post_class_use = 'TimberPost'; |
|
20 | - |
|
21 | - if ( isset( $post_class[$post_type] ) ) { |
|
22 | - $post_class_use = $post_class[$post_type]; |
|
23 | - |
|
24 | - } else { |
|
25 | - if ( is_array( $post_class ) ) { |
|
26 | - TimberHelper::error_log( $post_type . ' of ' . $post_object->ID . ' not found in ' . print_r( $post_class, true ) ); |
|
27 | - } else { |
|
28 | - TimberHelper::error_log( $post_type . ' not found in ' . $post_class ); |
|
29 | - } |
|
30 | - } |
|
31 | - } |
|
32 | - |
|
33 | - // Don't create yet another object if $post_object is already of the right type |
|
34 | - if ( is_a( $post_object, $post_class_use ) ) { |
|
35 | - $post = $post_object; |
|
36 | - } else { |
|
37 | - $post = new $post_class_use( $post_object ); |
|
38 | - } |
|
39 | - |
|
40 | - if ( isset( $post->ID ) ) { |
|
41 | - $returned_posts[] = $post; |
|
42 | - } |
|
43 | - } |
|
44 | - |
|
45 | - $returned_posts = self::maybe_set_preview($returned_posts); |
|
46 | - |
|
47 | - parent::__construct( $returned_posts, $flags = 0, 'TimberPostsIterator' ); |
|
48 | - } |
|
49 | - |
|
50 | - public function get_posts() { |
|
51 | - return $this->getArrayCopy(); |
|
52 | - } |
|
53 | - |
|
54 | - /** |
|
55 | - * @param array $posts |
|
56 | - * @return array |
|
57 | - */ |
|
58 | - static function maybe_set_preview( $posts ) { |
|
59 | - if ( is_array( $posts ) && isset( $_GET['preview'] ) && $_GET['preview'] |
|
60 | - && isset( $_GET['preview_id'] ) && $_GET['preview_id'] |
|
61 | - && current_user_can( 'edit_post', $_GET['preview_id'] ) ) { |
|
62 | - // No need to check the nonce, that already happened in _show_post_preview on init |
|
63 | - |
|
64 | - $preview_id = $_GET['preview_id']; |
|
65 | - foreach( $posts as &$post ) { |
|
66 | - if ( is_object( $post ) && $post->ID == $preview_id ) { |
|
67 | - // Based on _set_preview( $post ), but adds import_custom |
|
68 | - $preview = wp_get_post_autosave( $preview_id ); |
|
69 | - if ( is_object($preview) ) { |
|
70 | - |
|
71 | - $preview = sanitize_post($preview); |
|
72 | - |
|
73 | - $post->post_content = $preview->post_content; |
|
74 | - $post->post_title = $preview->post_title; |
|
75 | - $post->post_excerpt = $preview->post_excerpt; |
|
76 | - $post->import_custom( $preview_id ); |
|
77 | - |
|
78 | - add_filter( 'get_the_terms', '_wp_preview_terms_filter', 10, 3 ); |
|
79 | - } |
|
80 | - } |
|
81 | - } |
|
82 | - |
|
83 | - } |
|
84 | - |
|
85 | - return $posts; |
|
86 | - } |
|
9 | + public function __construct( $posts = array(), $post_class = 'TimberPost' ) { |
|
10 | + $returned_posts = array(); |
|
11 | + if ( is_null( $posts ) ){ |
|
12 | + $posts = array(); |
|
13 | + } |
|
14 | + foreach ( $posts as $post_object ) { |
|
15 | + $post_class_use = $post_class; |
|
16 | + |
|
17 | + if ( is_array( $post_class ) ) { |
|
18 | + $post_type = get_post_type( $post_object ); |
|
19 | + $post_class_use = 'TimberPost'; |
|
20 | + |
|
21 | + if ( isset( $post_class[$post_type] ) ) { |
|
22 | + $post_class_use = $post_class[$post_type]; |
|
23 | + |
|
24 | + } else { |
|
25 | + if ( is_array( $post_class ) ) { |
|
26 | + TimberHelper::error_log( $post_type . ' of ' . $post_object->ID . ' not found in ' . print_r( $post_class, true ) ); |
|
27 | + } else { |
|
28 | + TimberHelper::error_log( $post_type . ' not found in ' . $post_class ); |
|
29 | + } |
|
30 | + } |
|
31 | + } |
|
32 | + |
|
33 | + // Don't create yet another object if $post_object is already of the right type |
|
34 | + if ( is_a( $post_object, $post_class_use ) ) { |
|
35 | + $post = $post_object; |
|
36 | + } else { |
|
37 | + $post = new $post_class_use( $post_object ); |
|
38 | + } |
|
39 | + |
|
40 | + if ( isset( $post->ID ) ) { |
|
41 | + $returned_posts[] = $post; |
|
42 | + } |
|
43 | + } |
|
44 | + |
|
45 | + $returned_posts = self::maybe_set_preview($returned_posts); |
|
46 | + |
|
47 | + parent::__construct( $returned_posts, $flags = 0, 'TimberPostsIterator' ); |
|
48 | + } |
|
49 | + |
|
50 | + public function get_posts() { |
|
51 | + return $this->getArrayCopy(); |
|
52 | + } |
|
53 | + |
|
54 | + /** |
|
55 | + * @param array $posts |
|
56 | + * @return array |
|
57 | + */ |
|
58 | + static function maybe_set_preview( $posts ) { |
|
59 | + if ( is_array( $posts ) && isset( $_GET['preview'] ) && $_GET['preview'] |
|
60 | + && isset( $_GET['preview_id'] ) && $_GET['preview_id'] |
|
61 | + && current_user_can( 'edit_post', $_GET['preview_id'] ) ) { |
|
62 | + // No need to check the nonce, that already happened in _show_post_preview on init |
|
63 | + |
|
64 | + $preview_id = $_GET['preview_id']; |
|
65 | + foreach( $posts as &$post ) { |
|
66 | + if ( is_object( $post ) && $post->ID == $preview_id ) { |
|
67 | + // Based on _set_preview( $post ), but adds import_custom |
|
68 | + $preview = wp_get_post_autosave( $preview_id ); |
|
69 | + if ( is_object($preview) ) { |
|
70 | + |
|
71 | + $preview = sanitize_post($preview); |
|
72 | + |
|
73 | + $post->post_content = $preview->post_content; |
|
74 | + $post->post_title = $preview->post_title; |
|
75 | + $post->post_excerpt = $preview->post_excerpt; |
|
76 | + $post->import_custom( $preview_id ); |
|
77 | + |
|
78 | + add_filter( 'get_the_terms', '_wp_preview_terms_filter', 10, 3 ); |
|
79 | + } |
|
80 | + } |
|
81 | + } |
|
82 | + |
|
83 | + } |
|
84 | + |
|
85 | + return $posts; |
|
86 | + } |
|
87 | 87 | |
88 | 88 | } |
89 | 89 | |
90 | 90 | class TimberPostsIterator extends ArrayIterator { |
91 | 91 | |
92 | - public function current() { |
|
93 | - global $post; |
|
94 | - $post = parent::current(); |
|
95 | - return $post; |
|
96 | - } |
|
92 | + public function current() { |
|
93 | + global $post; |
|
94 | + $post = parent::current(); |
|
95 | + return $post; |
|
96 | + } |
|
97 | 97 | } |
@@ -1,50 +1,50 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | // Exit if accessed directly |
4 | -if ( !defined( 'ABSPATH' ) ) |
|
4 | +if ( !defined('ABSPATH') ) |
|
5 | 5 | exit; |
6 | 6 | |
7 | 7 | class TimberPostsCollection extends ArrayObject { |
8 | 8 | |
9 | 9 | public function __construct( $posts = array(), $post_class = 'TimberPost' ) { |
10 | 10 | $returned_posts = array(); |
11 | - if ( is_null( $posts ) ){ |
|
11 | + if ( is_null($posts) ) { |
|
12 | 12 | $posts = array(); |
13 | 13 | } |
14 | 14 | foreach ( $posts as $post_object ) { |
15 | 15 | $post_class_use = $post_class; |
16 | 16 | |
17 | - if ( is_array( $post_class ) ) { |
|
18 | - $post_type = get_post_type( $post_object ); |
|
17 | + if ( is_array($post_class) ) { |
|
18 | + $post_type = get_post_type($post_object); |
|
19 | 19 | $post_class_use = 'TimberPost'; |
20 | 20 | |
21 | - if ( isset( $post_class[$post_type] ) ) { |
|
21 | + if ( isset($post_class[$post_type]) ) { |
|
22 | 22 | $post_class_use = $post_class[$post_type]; |
23 | 23 | |
24 | 24 | } else { |
25 | - if ( is_array( $post_class ) ) { |
|
26 | - TimberHelper::error_log( $post_type . ' of ' . $post_object->ID . ' not found in ' . print_r( $post_class, true ) ); |
|
25 | + if ( is_array($post_class) ) { |
|
26 | + TimberHelper::error_log($post_type . ' of ' . $post_object->ID . ' not found in ' . print_r($post_class, true)); |
|
27 | 27 | } else { |
28 | - TimberHelper::error_log( $post_type . ' not found in ' . $post_class ); |
|
28 | + TimberHelper::error_log($post_type . ' not found in ' . $post_class); |
|
29 | 29 | } |
30 | 30 | } |
31 | 31 | } |
32 | 32 | |
33 | 33 | // Don't create yet another object if $post_object is already of the right type |
34 | - if ( is_a( $post_object, $post_class_use ) ) { |
|
34 | + if ( is_a($post_object, $post_class_use) ) { |
|
35 | 35 | $post = $post_object; |
36 | 36 | } else { |
37 | - $post = new $post_class_use( $post_object ); |
|
37 | + $post = new $post_class_use($post_object); |
|
38 | 38 | } |
39 | 39 | |
40 | - if ( isset( $post->ID ) ) { |
|
40 | + if ( isset($post->ID) ) { |
|
41 | 41 | $returned_posts[] = $post; |
42 | 42 | } |
43 | 43 | } |
44 | 44 | |
45 | 45 | $returned_posts = self::maybe_set_preview($returned_posts); |
46 | 46 | |
47 | - parent::__construct( $returned_posts, $flags = 0, 'TimberPostsIterator' ); |
|
47 | + parent::__construct($returned_posts, $flags = 0, 'TimberPostsIterator'); |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | public function get_posts() { |
@@ -56,16 +56,16 @@ discard block |
||
56 | 56 | * @return array |
57 | 57 | */ |
58 | 58 | static function maybe_set_preview( $posts ) { |
59 | - if ( is_array( $posts ) && isset( $_GET['preview'] ) && $_GET['preview'] |
|
60 | - && isset( $_GET['preview_id'] ) && $_GET['preview_id'] |
|
61 | - && current_user_can( 'edit_post', $_GET['preview_id'] ) ) { |
|
59 | + if ( is_array($posts) && isset($_GET['preview']) && $_GET['preview'] |
|
60 | + && isset($_GET['preview_id']) && $_GET['preview_id'] |
|
61 | + && current_user_can('edit_post', $_GET['preview_id']) ) { |
|
62 | 62 | // No need to check the nonce, that already happened in _show_post_preview on init |
63 | 63 | |
64 | 64 | $preview_id = $_GET['preview_id']; |
65 | - foreach( $posts as &$post ) { |
|
66 | - if ( is_object( $post ) && $post->ID == $preview_id ) { |
|
65 | + foreach ( $posts as &$post ) { |
|
66 | + if ( is_object($post) && $post->ID == $preview_id ) { |
|
67 | 67 | // Based on _set_preview( $post ), but adds import_custom |
68 | - $preview = wp_get_post_autosave( $preview_id ); |
|
68 | + $preview = wp_get_post_autosave($preview_id); |
|
69 | 69 | if ( is_object($preview) ) { |
70 | 70 | |
71 | 71 | $preview = sanitize_post($preview); |
@@ -73,9 +73,9 @@ discard block |
||
73 | 73 | $post->post_content = $preview->post_content; |
74 | 74 | $post->post_title = $preview->post_title; |
75 | 75 | $post->post_excerpt = $preview->post_excerpt; |
76 | - $post->import_custom( $preview_id ); |
|
76 | + $post->import_custom($preview_id); |
|
77 | 77 | |
78 | - add_filter( 'get_the_terms', '_wp_preview_terms_filter', 10, 3 ); |
|
78 | + add_filter('get_the_terms', '_wp_preview_terms_filter', 10, 3); |
|
79 | 79 | } |
80 | 80 | } |
81 | 81 | } |
@@ -1,156 +1,156 @@ |
||
1 | 1 | <?php |
2 | 2 | // Exit if accessed directly |
3 | 3 | if ( !defined( 'ABSPATH' ) ) |
4 | - exit; |
|
4 | + exit; |
|
5 | 5 | |
6 | 6 | class TimberQueryIterator implements Iterator { |
7 | 7 | |
8 | - /** |
|
9 | - * |
|
10 | - * |
|
11 | - * @var WP_Query |
|
12 | - */ |
|
13 | - private $_query = null; |
|
14 | - private $_posts_class = 'TimberPost'; |
|
15 | - |
|
16 | - public function __construct( $query = false, $posts_class = 'TimberPost' ) { |
|
17 | - add_action( 'pre_get_posts', array($this, 'fix_number_posts_wp_quirk' )); |
|
18 | - if ( $posts_class ) |
|
19 | - $this->_posts_class = $posts_class; |
|
20 | - |
|
21 | - if ( is_a( $query, 'WP_Query' ) ) { |
|
22 | - // We got a full-fledged WP Query, look no further! |
|
23 | - $the_query = $query; |
|
24 | - |
|
25 | - } elseif ( false === $query ) { |
|
26 | - // If query is explicitly set to false, use the main loop |
|
27 | - global $wp_query; |
|
28 | - $the_query =& $wp_query; |
|
29 | - //if we're on a custom posts page? |
|
30 | - $the_query = self::handle_maybe_custom_posts_page($the_query); |
|
31 | - } elseif ( TimberHelper::is_array_assoc( $query ) || ( is_string( $query ) && strstr( $query, '=' ) ) ) { |
|
32 | - // We have a regularly formed WP query string or array to use |
|
33 | - $the_query = new WP_Query( $query ); |
|
34 | - |
|
35 | - } elseif ( is_numeric( $query ) || is_string( $query ) ) { |
|
36 | - // We have what could be a post name or post ID to pull out |
|
37 | - $the_query = self::get_query_from_string( $query ); |
|
38 | - |
|
39 | - } elseif ( is_array( $query ) && count( $query ) && ( is_integer( $query[0] ) || is_string( $query[0] ) ) ) { |
|
40 | - // We have a list of pids (post IDs) to extract from |
|
41 | - $the_query = self::get_query_from_array_of_ids( $query ); |
|
42 | - } elseif ( is_array($query) && empty($query)) { |
|
43 | - // it's an empty array |
|
44 | - $the_query = array(); |
|
45 | - } else { |
|
46 | - TimberHelper::error_log( 'I have failed you! in ' . basename( __FILE__ ) . '::' . __LINE__ ); |
|
47 | - TimberHelper::error_log( $query ); |
|
48 | - |
|
49 | - // We have failed hard, at least let get something. |
|
50 | - $the_query = new WP_Query(); |
|
51 | - } |
|
52 | - |
|
53 | - $this->_query = $the_query; |
|
54 | - |
|
55 | - } |
|
56 | - |
|
57 | - public function get_posts( $return_collection = false ) { |
|
58 | - if (isset($this->_query->posts)){ |
|
59 | - $posts = new TimberPostsCollection( $this->_query->posts, $this->_posts_class ); |
|
60 | - return ( $return_collection ) ? $posts : $posts->get_posts(); |
|
61 | - } |
|
62 | - } |
|
63 | - |
|
64 | - // |
|
65 | - // GET POSTS |
|
66 | - // |
|
67 | - public static function get_query_from_array_of_ids( $query = array() ) { |
|
68 | - if ( !is_array( $query ) || !count( $query ) ) |
|
69 | - return null; |
|
70 | - |
|
71 | - return new WP_Query( array( |
|
72 | - 'post_type'=> 'any', |
|
73 | - 'ignore_sticky_posts' => true, |
|
74 | - 'post__in' => $query, |
|
75 | - 'orderby' => 'post__in', |
|
76 | - 'nopaging' => true |
|
77 | - ) ); |
|
78 | - } |
|
79 | - |
|
80 | - public static function get_query_from_string( $string = '' ) { |
|
81 | - $post_type = false; |
|
82 | - |
|
83 | - if ( is_string( $string ) && strstr( $string, '#' ) ) { |
|
84 | - //we have a post_type directive here |
|
85 | - list( $post_type, $string ) = explode( '#', $string ); |
|
86 | - } |
|
87 | - |
|
88 | - $query = array( |
|
89 | - 'post_type' => ( $post_type ) ? $post_type : 'any' |
|
90 | - ); |
|
91 | - |
|
92 | - if ( is_numeric( $string ) ) { |
|
93 | - $query['p'] = $string; |
|
94 | - |
|
95 | - } else { |
|
96 | - $query['name'] = $string; |
|
97 | - } |
|
98 | - |
|
99 | - return new WP_Query( $query ); |
|
100 | - } |
|
101 | - |
|
102 | - // |
|
103 | - // Iterator Interface |
|
104 | - // |
|
105 | - |
|
106 | - public function valid() { |
|
107 | - return $this->_query->have_posts(); |
|
108 | - } |
|
109 | - |
|
110 | - public function current() { |
|
111 | - global $post; |
|
112 | - |
|
113 | - $this->_query->the_post(); |
|
114 | - |
|
115 | - // Sets up the global post, but also return the post, for use in Twig template |
|
116 | - $posts_class = $this->_posts_class; |
|
117 | - return new $posts_class( $post ); |
|
118 | - } |
|
119 | - |
|
120 | - /** |
|
121 | - * Don't implement next, because current already advances the loop |
|
122 | - */ |
|
123 | - final public function next() {} |
|
124 | - |
|
125 | - public function rewind() { |
|
126 | - $this->_query->rewind_posts(); |
|
127 | - } |
|
128 | - |
|
129 | - public function key() { |
|
130 | - $this->_query->current_post; |
|
131 | - } |
|
132 | - |
|
133 | - //get_posts users numberposts |
|
134 | - static function fix_number_posts_wp_quirk( $query ) { |
|
135 | - if (isset($query->query) && isset($query->query['numberposts']) |
|
136 | - && !isset($query->query['posts_per_page'])) { |
|
137 | - $query->set( 'posts_per_page', $query->query['numberposts'] ); |
|
138 | - } |
|
139 | - return $query; |
|
140 | - } |
|
141 | - |
|
142 | - /** |
|
143 | - * this will test for whether a custom page to display posts is active, and if so, set the query to the default |
|
144 | - * @param WP_Query $query the original query recived from WordPress |
|
145 | - * @return WP_Query |
|
146 | - */ |
|
147 | - static function handle_maybe_custom_posts_page( $query ) { |
|
148 | - if ($custom_posts_page = get_option('page_for_posts')) { |
|
149 | - if ( isset($query->query['p']) && $query->query['p'] == $custom_posts_page ) { |
|
150 | - return new WP_Query(array('post_type' => 'post')); |
|
151 | - } |
|
152 | - } |
|
153 | - return $query; |
|
154 | - } |
|
8 | + /** |
|
9 | + * |
|
10 | + * |
|
11 | + * @var WP_Query |
|
12 | + */ |
|
13 | + private $_query = null; |
|
14 | + private $_posts_class = 'TimberPost'; |
|
15 | + |
|
16 | + public function __construct( $query = false, $posts_class = 'TimberPost' ) { |
|
17 | + add_action( 'pre_get_posts', array($this, 'fix_number_posts_wp_quirk' )); |
|
18 | + if ( $posts_class ) |
|
19 | + $this->_posts_class = $posts_class; |
|
20 | + |
|
21 | + if ( is_a( $query, 'WP_Query' ) ) { |
|
22 | + // We got a full-fledged WP Query, look no further! |
|
23 | + $the_query = $query; |
|
24 | + |
|
25 | + } elseif ( false === $query ) { |
|
26 | + // If query is explicitly set to false, use the main loop |
|
27 | + global $wp_query; |
|
28 | + $the_query =& $wp_query; |
|
29 | + //if we're on a custom posts page? |
|
30 | + $the_query = self::handle_maybe_custom_posts_page($the_query); |
|
31 | + } elseif ( TimberHelper::is_array_assoc( $query ) || ( is_string( $query ) && strstr( $query, '=' ) ) ) { |
|
32 | + // We have a regularly formed WP query string or array to use |
|
33 | + $the_query = new WP_Query( $query ); |
|
34 | + |
|
35 | + } elseif ( is_numeric( $query ) || is_string( $query ) ) { |
|
36 | + // We have what could be a post name or post ID to pull out |
|
37 | + $the_query = self::get_query_from_string( $query ); |
|
38 | + |
|
39 | + } elseif ( is_array( $query ) && count( $query ) && ( is_integer( $query[0] ) || is_string( $query[0] ) ) ) { |
|
40 | + // We have a list of pids (post IDs) to extract from |
|
41 | + $the_query = self::get_query_from_array_of_ids( $query ); |
|
42 | + } elseif ( is_array($query) && empty($query)) { |
|
43 | + // it's an empty array |
|
44 | + $the_query = array(); |
|
45 | + } else { |
|
46 | + TimberHelper::error_log( 'I have failed you! in ' . basename( __FILE__ ) . '::' . __LINE__ ); |
|
47 | + TimberHelper::error_log( $query ); |
|
48 | + |
|
49 | + // We have failed hard, at least let get something. |
|
50 | + $the_query = new WP_Query(); |
|
51 | + } |
|
52 | + |
|
53 | + $this->_query = $the_query; |
|
54 | + |
|
55 | + } |
|
56 | + |
|
57 | + public function get_posts( $return_collection = false ) { |
|
58 | + if (isset($this->_query->posts)){ |
|
59 | + $posts = new TimberPostsCollection( $this->_query->posts, $this->_posts_class ); |
|
60 | + return ( $return_collection ) ? $posts : $posts->get_posts(); |
|
61 | + } |
|
62 | + } |
|
63 | + |
|
64 | + // |
|
65 | + // GET POSTS |
|
66 | + // |
|
67 | + public static function get_query_from_array_of_ids( $query = array() ) { |
|
68 | + if ( !is_array( $query ) || !count( $query ) ) |
|
69 | + return null; |
|
70 | + |
|
71 | + return new WP_Query( array( |
|
72 | + 'post_type'=> 'any', |
|
73 | + 'ignore_sticky_posts' => true, |
|
74 | + 'post__in' => $query, |
|
75 | + 'orderby' => 'post__in', |
|
76 | + 'nopaging' => true |
|
77 | + ) ); |
|
78 | + } |
|
79 | + |
|
80 | + public static function get_query_from_string( $string = '' ) { |
|
81 | + $post_type = false; |
|
82 | + |
|
83 | + if ( is_string( $string ) && strstr( $string, '#' ) ) { |
|
84 | + //we have a post_type directive here |
|
85 | + list( $post_type, $string ) = explode( '#', $string ); |
|
86 | + } |
|
87 | + |
|
88 | + $query = array( |
|
89 | + 'post_type' => ( $post_type ) ? $post_type : 'any' |
|
90 | + ); |
|
91 | + |
|
92 | + if ( is_numeric( $string ) ) { |
|
93 | + $query['p'] = $string; |
|
94 | + |
|
95 | + } else { |
|
96 | + $query['name'] = $string; |
|
97 | + } |
|
98 | + |
|
99 | + return new WP_Query( $query ); |
|
100 | + } |
|
101 | + |
|
102 | + // |
|
103 | + // Iterator Interface |
|
104 | + // |
|
105 | + |
|
106 | + public function valid() { |
|
107 | + return $this->_query->have_posts(); |
|
108 | + } |
|
109 | + |
|
110 | + public function current() { |
|
111 | + global $post; |
|
112 | + |
|
113 | + $this->_query->the_post(); |
|
114 | + |
|
115 | + // Sets up the global post, but also return the post, for use in Twig template |
|
116 | + $posts_class = $this->_posts_class; |
|
117 | + return new $posts_class( $post ); |
|
118 | + } |
|
119 | + |
|
120 | + /** |
|
121 | + * Don't implement next, because current already advances the loop |
|
122 | + */ |
|
123 | + final public function next() {} |
|
124 | + |
|
125 | + public function rewind() { |
|
126 | + $this->_query->rewind_posts(); |
|
127 | + } |
|
128 | + |
|
129 | + public function key() { |
|
130 | + $this->_query->current_post; |
|
131 | + } |
|
132 | + |
|
133 | + //get_posts users numberposts |
|
134 | + static function fix_number_posts_wp_quirk( $query ) { |
|
135 | + if (isset($query->query) && isset($query->query['numberposts']) |
|
136 | + && !isset($query->query['posts_per_page'])) { |
|
137 | + $query->set( 'posts_per_page', $query->query['numberposts'] ); |
|
138 | + } |
|
139 | + return $query; |
|
140 | + } |
|
141 | + |
|
142 | + /** |
|
143 | + * this will test for whether a custom page to display posts is active, and if so, set the query to the default |
|
144 | + * @param WP_Query $query the original query recived from WordPress |
|
145 | + * @return WP_Query |
|
146 | + */ |
|
147 | + static function handle_maybe_custom_posts_page( $query ) { |
|
148 | + if ($custom_posts_page = get_option('page_for_posts')) { |
|
149 | + if ( isset($query->query['p']) && $query->query['p'] == $custom_posts_page ) { |
|
150 | + return new WP_Query(array('post_type' => 'post')); |
|
151 | + } |
|
152 | + } |
|
153 | + return $query; |
|
154 | + } |
|
155 | 155 | |
156 | 156 | } |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | // Exit if accessed directly |
3 | -if ( !defined( 'ABSPATH' ) ) |
|
3 | +if ( !defined('ABSPATH') ) |
|
4 | 4 | exit; |
5 | 5 | |
6 | 6 | class TimberQueryIterator implements Iterator { |
@@ -14,37 +14,37 @@ discard block |
||
14 | 14 | private $_posts_class = 'TimberPost'; |
15 | 15 | |
16 | 16 | public function __construct( $query = false, $posts_class = 'TimberPost' ) { |
17 | - add_action( 'pre_get_posts', array($this, 'fix_number_posts_wp_quirk' )); |
|
17 | + add_action('pre_get_posts', array($this, 'fix_number_posts_wp_quirk')); |
|
18 | 18 | if ( $posts_class ) |
19 | 19 | $this->_posts_class = $posts_class; |
20 | 20 | |
21 | - if ( is_a( $query, 'WP_Query' ) ) { |
|
21 | + if ( is_a($query, 'WP_Query') ) { |
|
22 | 22 | // We got a full-fledged WP Query, look no further! |
23 | 23 | $the_query = $query; |
24 | 24 | |
25 | 25 | } elseif ( false === $query ) { |
26 | 26 | // If query is explicitly set to false, use the main loop |
27 | 27 | global $wp_query; |
28 | - $the_query =& $wp_query; |
|
28 | + $the_query = & $wp_query; |
|
29 | 29 | //if we're on a custom posts page? |
30 | 30 | $the_query = self::handle_maybe_custom_posts_page($the_query); |
31 | - } elseif ( TimberHelper::is_array_assoc( $query ) || ( is_string( $query ) && strstr( $query, '=' ) ) ) { |
|
31 | + } elseif ( TimberHelper::is_array_assoc($query) || (is_string($query) && strstr($query, '=')) ) { |
|
32 | 32 | // We have a regularly formed WP query string or array to use |
33 | - $the_query = new WP_Query( $query ); |
|
33 | + $the_query = new WP_Query($query); |
|
34 | 34 | |
35 | - } elseif ( is_numeric( $query ) || is_string( $query ) ) { |
|
35 | + } elseif ( is_numeric($query) || is_string($query) ) { |
|
36 | 36 | // We have what could be a post name or post ID to pull out |
37 | - $the_query = self::get_query_from_string( $query ); |
|
37 | + $the_query = self::get_query_from_string($query); |
|
38 | 38 | |
39 | - } elseif ( is_array( $query ) && count( $query ) && ( is_integer( $query[0] ) || is_string( $query[0] ) ) ) { |
|
39 | + } elseif ( is_array($query) && count($query) && (is_integer($query[0]) || is_string($query[0])) ) { |
|
40 | 40 | // We have a list of pids (post IDs) to extract from |
41 | - $the_query = self::get_query_from_array_of_ids( $query ); |
|
42 | - } elseif ( is_array($query) && empty($query)) { |
|
41 | + $the_query = self::get_query_from_array_of_ids($query); |
|
42 | + } elseif ( is_array($query) && empty($query) ) { |
|
43 | 43 | // it's an empty array |
44 | 44 | $the_query = array(); |
45 | 45 | } else { |
46 | - TimberHelper::error_log( 'I have failed you! in ' . basename( __FILE__ ) . '::' . __LINE__ ); |
|
47 | - TimberHelper::error_log( $query ); |
|
46 | + TimberHelper::error_log('I have failed you! in ' . basename(__FILE__) . '::' . __LINE__); |
|
47 | + TimberHelper::error_log($query); |
|
48 | 48 | |
49 | 49 | // We have failed hard, at least let get something. |
50 | 50 | $the_query = new WP_Query(); |
@@ -55,9 +55,9 @@ discard block |
||
55 | 55 | } |
56 | 56 | |
57 | 57 | public function get_posts( $return_collection = false ) { |
58 | - if (isset($this->_query->posts)){ |
|
59 | - $posts = new TimberPostsCollection( $this->_query->posts, $this->_posts_class ); |
|
60 | - return ( $return_collection ) ? $posts : $posts->get_posts(); |
|
58 | + if ( isset($this->_query->posts) ) { |
|
59 | + $posts = new TimberPostsCollection($this->_query->posts, $this->_posts_class); |
|
60 | + return ($return_collection) ? $posts : $posts->get_posts(); |
|
61 | 61 | } |
62 | 62 | } |
63 | 63 | |
@@ -65,38 +65,38 @@ discard block |
||
65 | 65 | // GET POSTS |
66 | 66 | // |
67 | 67 | public static function get_query_from_array_of_ids( $query = array() ) { |
68 | - if ( !is_array( $query ) || !count( $query ) ) |
|
68 | + if ( !is_array($query) || !count($query) ) |
|
69 | 69 | return null; |
70 | 70 | |
71 | - return new WP_Query( array( |
|
71 | + return new WP_Query(array( |
|
72 | 72 | 'post_type'=> 'any', |
73 | 73 | 'ignore_sticky_posts' => true, |
74 | 74 | 'post__in' => $query, |
75 | 75 | 'orderby' => 'post__in', |
76 | 76 | 'nopaging' => true |
77 | - ) ); |
|
77 | + )); |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | public static function get_query_from_string( $string = '' ) { |
81 | 81 | $post_type = false; |
82 | 82 | |
83 | - if ( is_string( $string ) && strstr( $string, '#' ) ) { |
|
83 | + if ( is_string($string) && strstr($string, '#') ) { |
|
84 | 84 | //we have a post_type directive here |
85 | - list( $post_type, $string ) = explode( '#', $string ); |
|
85 | + list($post_type, $string) = explode('#', $string); |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | $query = array( |
89 | - 'post_type' => ( $post_type ) ? $post_type : 'any' |
|
89 | + 'post_type' => ($post_type) ? $post_type : 'any' |
|
90 | 90 | ); |
91 | 91 | |
92 | - if ( is_numeric( $string ) ) { |
|
92 | + if ( is_numeric($string) ) { |
|
93 | 93 | $query['p'] = $string; |
94 | 94 | |
95 | 95 | } else { |
96 | 96 | $query['name'] = $string; |
97 | 97 | } |
98 | 98 | |
99 | - return new WP_Query( $query ); |
|
99 | + return new WP_Query($query); |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | // |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | |
115 | 115 | // Sets up the global post, but also return the post, for use in Twig template |
116 | 116 | $posts_class = $this->_posts_class; |
117 | - return new $posts_class( $post ); |
|
117 | + return new $posts_class($post); |
|
118 | 118 | } |
119 | 119 | |
120 | 120 | /** |
@@ -132,9 +132,9 @@ discard block |
||
132 | 132 | |
133 | 133 | //get_posts users numberposts |
134 | 134 | static function fix_number_posts_wp_quirk( $query ) { |
135 | - if (isset($query->query) && isset($query->query['numberposts']) |
|
136 | - && !isset($query->query['posts_per_page'])) { |
|
137 | - $query->set( 'posts_per_page', $query->query['numberposts'] ); |
|
135 | + if ( isset($query->query) && isset($query->query['numberposts']) |
|
136 | + && !isset($query->query['posts_per_page']) ) { |
|
137 | + $query->set('posts_per_page', $query->query['numberposts']); |
|
138 | 138 | } |
139 | 139 | return $query; |
140 | 140 | } |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | * @return WP_Query |
146 | 146 | */ |
147 | 147 | static function handle_maybe_custom_posts_page( $query ) { |
148 | - if ($custom_posts_page = get_option('page_for_posts')) { |
|
148 | + if ( $custom_posts_page = get_option('page_for_posts') ) { |
|
149 | 149 | if ( isset($query->query['p']) && $query->query['p'] == $custom_posts_page ) { |
150 | 150 | return new WP_Query(array('post_type' => 'post')); |
151 | 151 | } |
@@ -64,7 +64,7 @@ |
||
64 | 64 | |
65 | 65 | /** @api |
66 | 66 | * @var string for people who like trackback spam |
67 | - */ |
|
67 | + */ |
|
68 | 68 | public $pingback_url; |
69 | 69 | public $siteurl; |
70 | 70 | /** |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | function __construct( $site_name_or_id = null ) { |
105 | 105 | $this->init(); |
106 | 106 | if ( is_multisite() ) { |
107 | - $this->init_as_multisite( $site_name_or_id ); |
|
107 | + $this->init_as_multisite($site_name_or_id); |
|
108 | 108 | } else { |
109 | 109 | $this->init_as_singlesite(); |
110 | 110 | } |
@@ -122,17 +122,17 @@ discard block |
||
122 | 122 | $site_name_or_id = get_current_blog_id(); |
123 | 123 | } |
124 | 124 | } |
125 | - $info = get_blog_details( $site_name_or_id ); |
|
126 | - $this->import( $info ); |
|
125 | + $info = get_blog_details($site_name_or_id); |
|
126 | + $this->import($info); |
|
127 | 127 | $this->ID = $info->blog_id; |
128 | 128 | $this->id = $this->ID; |
129 | 129 | $this->name = $this->blogname; |
130 | 130 | $this->title = $this->blogname; |
131 | 131 | $this->url = $this->siteurl; |
132 | - $theme_slug = get_blog_option( $info->blog_id, 'stylesheet' ); |
|
133 | - $this->theme = new TimberTheme( $theme_slug ); |
|
134 | - $this->description = get_blog_option( $info->blog_id, 'blogdescription' ); |
|
135 | - $this->admin_email = get_blog_option( $info->blog_id, 'admin_email' ); |
|
132 | + $theme_slug = get_blog_option($info->blog_id, 'stylesheet'); |
|
133 | + $this->theme = new TimberTheme($theme_slug); |
|
134 | + $this->description = get_blog_option($info->blog_id, 'blogdescription'); |
|
135 | + $this->admin_email = get_blog_option($info->blog_id, 'admin_email'); |
|
136 | 136 | $this->multisite = true; |
137 | 137 | } |
138 | 138 | |
@@ -141,13 +141,13 @@ discard block |
||
141 | 141 | * @internal |
142 | 142 | */ |
143 | 143 | protected function init_as_singlesite() { |
144 | - $this->admin_email = get_bloginfo( 'admin_email' ); |
|
145 | - $this->name = get_bloginfo( 'name' ); |
|
144 | + $this->admin_email = get_bloginfo('admin_email'); |
|
145 | + $this->name = get_bloginfo('name'); |
|
146 | 146 | $this->title = $this->name; |
147 | - $this->description = get_bloginfo( 'description' ); |
|
148 | - $this->url = get_bloginfo( 'url' ); |
|
147 | + $this->description = get_bloginfo('description'); |
|
148 | + $this->url = get_bloginfo('url'); |
|
149 | 149 | $this->theme = new TimberTheme(); |
150 | - $this->language_attributes = TimberHelper::function_wrapper( 'language_attributes' ); |
|
150 | + $this->language_attributes = TimberHelper::function_wrapper('language_attributes'); |
|
151 | 151 | $this->multisite = false; |
152 | 152 | } |
153 | 153 | |
@@ -156,16 +156,16 @@ discard block |
||
156 | 156 | * @internal |
157 | 157 | */ |
158 | 158 | protected function init() { |
159 | - $this->rdf = get_bloginfo( 'rdf_url' ); |
|
160 | - $this->rss = get_bloginfo( 'rss_url' ); |
|
161 | - $this->rss2 = get_bloginfo( 'rss2_url' ); |
|
162 | - $this->atom = get_bloginfo( 'atom_url' ); |
|
163 | - $this->language = get_bloginfo( 'language' ); |
|
164 | - $this->charset = get_bloginfo( 'charset' ); |
|
165 | - $this->pingback = get_bloginfo( 'pingback_url' ); |
|
166 | - $this->language_attributes = TimberHelper::function_wrapper( 'language_attributes' ); |
|
159 | + $this->rdf = get_bloginfo('rdf_url'); |
|
160 | + $this->rss = get_bloginfo('rss_url'); |
|
161 | + $this->rss2 = get_bloginfo('rss2_url'); |
|
162 | + $this->atom = get_bloginfo('atom_url'); |
|
163 | + $this->language = get_bloginfo('language'); |
|
164 | + $this->charset = get_bloginfo('charset'); |
|
165 | + $this->pingback = get_bloginfo('pingback_url'); |
|
166 | + $this->language_attributes = TimberHelper::function_wrapper('language_attributes'); |
|
167 | 167 | /* deprecated benath this comment */ |
168 | - $this->pingback_url = get_bloginfo( 'pingback_url' ); |
|
168 | + $this->pingback_url = get_bloginfo('pingback_url'); |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | /** |
@@ -175,11 +175,11 @@ discard block |
||
175 | 175 | * @return mixed |
176 | 176 | */ |
177 | 177 | function __get( $field ) { |
178 | - if ( !isset( $this->$field ) ) { |
|
178 | + if ( !isset($this->$field) ) { |
|
179 | 179 | if ( is_multisite() ) { |
180 | - $this->$field = get_blog_option( $this->ID, $field ); |
|
180 | + $this->$field = get_blog_option($this->ID, $field); |
|
181 | 181 | } else { |
182 | - $this->$field = get_option( $field ); |
|
182 | + $this->$field = get_option($field); |
|
183 | 183 | } |
184 | 184 | } |
185 | 185 | return $this->$field; |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | * @ignore |
228 | 228 | */ |
229 | 229 | public function meta( $field ) { |
230 | - return $this->__get( $field ); |
|
230 | + return $this->__get($field); |
|
231 | 231 | } |
232 | 232 | |
233 | 233 | /** |
@@ -237,11 +237,11 @@ discard block |
||
237 | 237 | * @param mixed $value |
238 | 238 | */ |
239 | 239 | public function update( $key, $value ) { |
240 | - $value = apply_filters( 'timber_site_set_meta', $value, $key, $this->ID, $this ); |
|
240 | + $value = apply_filters('timber_site_set_meta', $value, $key, $this->ID, $this); |
|
241 | 241 | if ( is_multisite() ) { |
242 | - update_blog_option( $this->ID, $key, $value ); |
|
242 | + update_blog_option($this->ID, $key, $value); |
|
243 | 243 | } else { |
244 | - update_option( $key, $value ); |
|
244 | + update_option($key, $value); |
|
245 | 245 | } |
246 | 246 | $this->$key = $value; |
247 | 247 | } |