@@ -15,8 +15,8 @@ discard block |
||
| 15 | 15 | * @codeCoverageIgnore |
| 16 | 16 | */ |
| 17 | 17 | function __construct() { |
| 18 | - add_action( 'timber/twig/filters', array( $this, 'add_timber_filters_deprecated' ) ); |
|
| 19 | - add_action( 'timber/twig/filters', array( $this, 'add_timber_filters' ) ); |
|
| 18 | + add_action('timber/twig/filters', array($this, 'add_timber_filters_deprecated')); |
|
| 19 | + add_action('timber/twig/filters', array($this, 'add_timber_filters')); |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | /** |
@@ -27,13 +27,13 @@ discard block |
||
| 27 | 27 | * @return Twig_Environment |
| 28 | 28 | */ |
| 29 | 29 | function add_timber_filters_deprecated( $twig ) { |
| 30 | - $twig->addFilter( new Twig_SimpleFilter( 'get_src_from_attachment_id', 'twig_get_src_from_attachment_id' ) ); |
|
| 31 | - $twig->addFilter( new Twig_SimpleFilter( 'wp_body_class', array( $this, 'body_class' ) ) ); |
|
| 32 | - $twig->addFilter( new Twig_SimpleFilter( 'twitterify', array( 'TimberHelper', 'twitterify' ) ) ); |
|
| 33 | - $twig->addFilter( new Twig_SimpleFilter( 'twitterfy', array( 'TimberHelper', 'twitterify' ) ) ); |
|
| 34 | - $twig->addFilter( new Twig_SimpleFilter( 'string', function($arr, $glue = ' '){ |
|
| 30 | + $twig->addFilter(new Twig_SimpleFilter('get_src_from_attachment_id', 'twig_get_src_from_attachment_id')); |
|
| 31 | + $twig->addFilter(new Twig_SimpleFilter('wp_body_class', array($this, 'body_class'))); |
|
| 32 | + $twig->addFilter(new Twig_SimpleFilter('twitterify', array('TimberHelper', 'twitterify'))); |
|
| 33 | + $twig->addFilter(new Twig_SimpleFilter('twitterfy', array('TimberHelper', 'twitterify'))); |
|
| 34 | + $twig->addFilter(new Twig_SimpleFilter('string', function( $arr, $glue = ' ' ) { |
|
| 35 | 35 | return twig_join_filter($arr, $glue); |
| 36 | - } ) ); |
|
| 36 | + } )); |
|
| 37 | 37 | return $twig; |
| 38 | 38 | } |
| 39 | 39 | |
@@ -45,149 +45,149 @@ discard block |
||
| 45 | 45 | */ |
| 46 | 46 | function add_timber_filters( $twig ) { |
| 47 | 47 | /* image filters */ |
| 48 | - $twig->addFilter( new Twig_SimpleFilter( 'resize', array( 'TimberImageHelper', 'resize' ) ) ); |
|
| 49 | - $twig->addFilter( new Twig_SimpleFilter( 'retina', array( 'TimberImageHelper', 'retina_resize' ) ) ); |
|
| 50 | - $twig->addFilter( new Twig_SimpleFilter( 'letterbox', array( 'TimberImageHelper', 'letterbox' ) ) ); |
|
| 51 | - $twig->addFilter( new Twig_SimpleFilter( 'tojpg', array( 'TimberImageHelper', 'img_to_jpg' ) ) ); |
|
| 48 | + $twig->addFilter(new Twig_SimpleFilter('resize', array('TimberImageHelper', 'resize'))); |
|
| 49 | + $twig->addFilter(new Twig_SimpleFilter('retina', array('TimberImageHelper', 'retina_resize'))); |
|
| 50 | + $twig->addFilter(new Twig_SimpleFilter('letterbox', array('TimberImageHelper', 'letterbox'))); |
|
| 51 | + $twig->addFilter(new Twig_SimpleFilter('tojpg', array('TimberImageHelper', 'img_to_jpg'))); |
|
| 52 | 52 | |
| 53 | 53 | /* debugging filters */ |
| 54 | - $twig->addFilter( new Twig_SimpleFilter( 'docs', 'twig_object_docs' ) ); |
|
| 55 | - $twig->addFilter( new Twig_SimpleFilter( 'get_class', 'get_class' ) ); |
|
| 56 | - $twig->addFilter( new Twig_SimpleFilter( 'get_type', 'get_type' ) ); |
|
| 57 | - $twig->addFilter( new Twig_SimpleFilter( 'print_r', function( $arr ) { |
|
| 58 | - return print_r( $arr, true ); |
|
| 59 | - } ) ); |
|
| 60 | - $twig->addFilter( new Twig_SimpleFilter( 'print_a', function( $arr ) { |
|
| 61 | - return '<pre>' . self::object_docs( $arr, true ) . '</pre>'; |
|
| 62 | - } ) ); |
|
| 54 | + $twig->addFilter(new Twig_SimpleFilter('docs', 'twig_object_docs')); |
|
| 55 | + $twig->addFilter(new Twig_SimpleFilter('get_class', 'get_class')); |
|
| 56 | + $twig->addFilter(new Twig_SimpleFilter('get_type', 'get_type')); |
|
| 57 | + $twig->addFilter(new Twig_SimpleFilter('print_r', function( $arr ) { |
|
| 58 | + return print_r($arr, true); |
|
| 59 | + } )); |
|
| 60 | + $twig->addFilter(new Twig_SimpleFilter('print_a', function( $arr ) { |
|
| 61 | + return '<pre>' . self::object_docs($arr, true) . '</pre>'; |
|
| 62 | + } )); |
|
| 63 | 63 | |
| 64 | 64 | /* other filters */ |
| 65 | - $twig->addFilter( new Twig_SimpleFilter( 'stripshortcodes', 'strip_shortcodes' ) ); |
|
| 66 | - $twig->addFilter( new Twig_SimpleFilter( 'array', array( $this, 'to_array' ) ) ); |
|
| 67 | - $twig->addFilter( new Twig_SimpleFilter( 'excerpt', 'wp_trim_words' ) ); |
|
| 68 | - $twig->addFilter( new Twig_SimpleFilter( 'function', array( $this, 'exec_function' ) ) ); |
|
| 69 | - $twig->addFilter( new Twig_SimpleFilter( 'pretags', array( $this, 'twig_pretags' ) ) ); |
|
| 70 | - $twig->addFilter( new Twig_SimpleFilter( 'sanitize', 'sanitize_title' ) ); |
|
| 71 | - $twig->addFilter( new Twig_SimpleFilter( 'shortcodes', 'do_shortcode' ) ); |
|
| 72 | - $twig->addFilter( new Twig_SimpleFilter( 'time_ago', array( $this, 'time_ago' ) ) ); |
|
| 73 | - $twig->addFilter( new Twig_SimpleFilter( 'wpautop', 'wpautop' ) ); |
|
| 74 | - $twig->addFilter( new Twig_SimpleFilter( 'list', array( $this, 'add_list_separators' ) ) ); |
|
| 75 | - |
|
| 76 | - $twig->addFilter( new Twig_SimpleFilter( 'relative', function ( $link ) { |
|
| 77 | - return TimberURLHelper::get_rel_url( $link, true ); |
|
| 78 | - } ) ); |
|
| 79 | - |
|
| 80 | - $twig->addFilter( new Twig_SimpleFilter( 'date', array( $this, 'intl_date' ) ) ); |
|
| 81 | - |
|
| 82 | - $twig->addFilter( new Twig_SimpleFilter( 'truncate', function ( $text, $len ) { |
|
| 83 | - return TimberHelper::trim_words( $text, $len ); |
|
| 84 | - } ) ); |
|
| 65 | + $twig->addFilter(new Twig_SimpleFilter('stripshortcodes', 'strip_shortcodes')); |
|
| 66 | + $twig->addFilter(new Twig_SimpleFilter('array', array($this, 'to_array'))); |
|
| 67 | + $twig->addFilter(new Twig_SimpleFilter('excerpt', 'wp_trim_words')); |
|
| 68 | + $twig->addFilter(new Twig_SimpleFilter('function', array($this, 'exec_function'))); |
|
| 69 | + $twig->addFilter(new Twig_SimpleFilter('pretags', array($this, 'twig_pretags'))); |
|
| 70 | + $twig->addFilter(new Twig_SimpleFilter('sanitize', 'sanitize_title')); |
|
| 71 | + $twig->addFilter(new Twig_SimpleFilter('shortcodes', 'do_shortcode')); |
|
| 72 | + $twig->addFilter(new Twig_SimpleFilter('time_ago', array($this, 'time_ago'))); |
|
| 73 | + $twig->addFilter(new Twig_SimpleFilter('wpautop', 'wpautop')); |
|
| 74 | + $twig->addFilter(new Twig_SimpleFilter('list', array($this, 'add_list_separators'))); |
|
| 75 | + |
|
| 76 | + $twig->addFilter(new Twig_SimpleFilter('relative', function( $link ) { |
|
| 77 | + return TimberURLHelper::get_rel_url($link, true); |
|
| 78 | + } )); |
|
| 79 | + |
|
| 80 | + $twig->addFilter(new Twig_SimpleFilter('date', array($this, 'intl_date'))); |
|
| 81 | + |
|
| 82 | + $twig->addFilter(new Twig_SimpleFilter('truncate', function( $text, $len ) { |
|
| 83 | + return TimberHelper::trim_words($text, $len); |
|
| 84 | + } )); |
|
| 85 | 85 | |
| 86 | 86 | /* actions and filters */ |
| 87 | - $twig->addFunction( new Twig_SimpleFunction( 'action', function ( $context ) { |
|
| 87 | + $twig->addFunction(new Twig_SimpleFunction('action', function( $context ) { |
|
| 88 | 88 | $args = func_get_args(); |
| 89 | - array_shift( $args ); |
|
| 89 | + array_shift($args); |
|
| 90 | 90 | $args[] = $context; |
| 91 | - call_user_func_array( 'do_action', $args ); |
|
| 92 | - }, array( 'needs_context' => true ) ) ); |
|
| 91 | + call_user_func_array('do_action', $args); |
|
| 92 | + }, array('needs_context' => true))); |
|
| 93 | 93 | |
| 94 | - $twig->addFilter( new Twig_SimpleFilter( 'apply_filters', function () { |
|
| 94 | + $twig->addFilter(new Twig_SimpleFilter('apply_filters', function() { |
|
| 95 | 95 | $args = func_get_args(); |
| 96 | - $tag = current( array_splice( $args, 1, 1 ) ); |
|
| 96 | + $tag = current(array_splice($args, 1, 1)); |
|
| 97 | 97 | |
| 98 | - return apply_filters_ref_array( $tag, $args ); |
|
| 99 | - } ) ); |
|
| 100 | - $twig->addFunction( new Twig_SimpleFunction( 'function', array( &$this, 'exec_function' ) ) ); |
|
| 101 | - $twig->addFunction( new Twig_SimpleFunction( 'fn', array( &$this, 'exec_function' ) ) ); |
|
| 98 | + return apply_filters_ref_array($tag, $args); |
|
| 99 | + } )); |
|
| 100 | + $twig->addFunction(new Twig_SimpleFunction('function', array(&$this, 'exec_function'))); |
|
| 101 | + $twig->addFunction(new Twig_SimpleFunction('fn', array(&$this, 'exec_function'))); |
|
| 102 | 102 | |
| 103 | - $twig->addFunction( new Twig_SimpleFunction( 'shortcode', 'do_shortcode' ) ); |
|
| 103 | + $twig->addFunction(new Twig_SimpleFunction('shortcode', 'do_shortcode')); |
|
| 104 | 104 | |
| 105 | 105 | /* TimberObjects */ |
| 106 | - $twig->addFunction( new Twig_SimpleFunction( 'TimberPost', function ( $pid, $PostClass = 'TimberPost' ) { |
|
| 107 | - if ( is_array( $pid ) && !TimberHelper::is_array_assoc( $pid ) ) { |
|
| 106 | + $twig->addFunction(new Twig_SimpleFunction('TimberPost', function( $pid, $PostClass = 'TimberPost' ) { |
|
| 107 | + if ( is_array($pid) && !TimberHelper::is_array_assoc($pid) ) { |
|
| 108 | 108 | foreach ( $pid as &$p ) { |
| 109 | - $p = new $PostClass( $p ); |
|
| 109 | + $p = new $PostClass($p); |
|
| 110 | 110 | } |
| 111 | 111 | return $pid; |
| 112 | 112 | } |
| 113 | - return new $PostClass( $pid ); |
|
| 114 | - } ) ); |
|
| 115 | - $twig->addFunction( new Twig_SimpleFunction( 'TimberImage', function ( $pid, $ImageClass = 'TimberImage' ) { |
|
| 116 | - if ( is_array( $pid ) && !TimberHelper::is_array_assoc( $pid ) ) { |
|
| 113 | + return new $PostClass($pid); |
|
| 114 | + } )); |
|
| 115 | + $twig->addFunction(new Twig_SimpleFunction('TimberImage', function( $pid, $ImageClass = 'TimberImage' ) { |
|
| 116 | + if ( is_array($pid) && !TimberHelper::is_array_assoc($pid) ) { |
|
| 117 | 117 | foreach ( $pid as &$p ) { |
| 118 | - $p = new $ImageClass( $p ); |
|
| 118 | + $p = new $ImageClass($p); |
|
| 119 | 119 | } |
| 120 | 120 | return $pid; |
| 121 | 121 | } |
| 122 | - return new $ImageClass( $pid ); |
|
| 123 | - } ) ); |
|
| 124 | - $twig->addFunction( new Twig_SimpleFunction( 'TimberTerm', function ( $pid, $TermClass = 'TimberTerm' ) { |
|
| 125 | - if ( is_array( $pid ) && !TimberHelper::is_array_assoc( $pid ) ) { |
|
| 122 | + return new $ImageClass($pid); |
|
| 123 | + } )); |
|
| 124 | + $twig->addFunction(new Twig_SimpleFunction('TimberTerm', function( $pid, $TermClass = 'TimberTerm' ) { |
|
| 125 | + if ( is_array($pid) && !TimberHelper::is_array_assoc($pid) ) { |
|
| 126 | 126 | foreach ( $pid as &$p ) { |
| 127 | - $p = new $TermClass( $p ); |
|
| 127 | + $p = new $TermClass($p); |
|
| 128 | 128 | } |
| 129 | 129 | return $pid; |
| 130 | 130 | } |
| 131 | - return new $TermClass( $pid ); |
|
| 132 | - } ) ); |
|
| 133 | - $twig->addFunction( new Twig_SimpleFunction( 'TimberUser', function ( $pid, $UserClass = 'TimberUser' ) { |
|
| 134 | - if ( is_array( $pid ) && !TimberHelper::is_array_assoc( $pid ) ) { |
|
| 131 | + return new $TermClass($pid); |
|
| 132 | + } )); |
|
| 133 | + $twig->addFunction(new Twig_SimpleFunction('TimberUser', function( $pid, $UserClass = 'TimberUser' ) { |
|
| 134 | + if ( is_array($pid) && !TimberHelper::is_array_assoc($pid) ) { |
|
| 135 | 135 | foreach ( $pid as &$p ) { |
| 136 | - $p = new $UserClass( $p ); |
|
| 136 | + $p = new $UserClass($p); |
|
| 137 | 137 | } |
| 138 | 138 | return $pid; |
| 139 | 139 | } |
| 140 | - return new $UserClass( $pid ); |
|
| 141 | - } ) ); |
|
| 140 | + return new $UserClass($pid); |
|
| 141 | + } )); |
|
| 142 | 142 | |
| 143 | 143 | /* TimberObjects Alias */ |
| 144 | - $twig->addFunction( new Twig_SimpleFunction( 'Post', function ( $pid, $PostClass = 'TimberPost' ) { |
|
| 145 | - if ( is_array( $pid ) && !TimberHelper::is_array_assoc( $pid ) ) { |
|
| 144 | + $twig->addFunction(new Twig_SimpleFunction('Post', function( $pid, $PostClass = 'TimberPost' ) { |
|
| 145 | + if ( is_array($pid) && !TimberHelper::is_array_assoc($pid) ) { |
|
| 146 | 146 | foreach ( $pid as &$p ) { |
| 147 | - $p = new $PostClass( $p ); |
|
| 147 | + $p = new $PostClass($p); |
|
| 148 | 148 | } |
| 149 | 149 | return $pid; |
| 150 | 150 | } |
| 151 | - return new $PostClass( $pid ); |
|
| 152 | - } ) ); |
|
| 153 | - $twig->addFunction( new Twig_SimpleFunction( 'Image', function ( $pid, $ImageClass = 'TimberImage' ) { |
|
| 154 | - if ( is_array( $pid ) && !TimberHelper::is_array_assoc( $pid ) ) { |
|
| 151 | + return new $PostClass($pid); |
|
| 152 | + } )); |
|
| 153 | + $twig->addFunction(new Twig_SimpleFunction('Image', function( $pid, $ImageClass = 'TimberImage' ) { |
|
| 154 | + if ( is_array($pid) && !TimberHelper::is_array_assoc($pid) ) { |
|
| 155 | 155 | foreach ( $pid as &$p ) { |
| 156 | - $p = new $ImageClass( $p ); |
|
| 156 | + $p = new $ImageClass($p); |
|
| 157 | 157 | } |
| 158 | 158 | return $pid; |
| 159 | 159 | } |
| 160 | - return new $ImageClass( $pid ); |
|
| 161 | - } ) ); |
|
| 162 | - $twig->addFunction( new Twig_SimpleFunction( 'Term', function ( $pid, $TermClass = 'TimberTerm' ) { |
|
| 163 | - if ( is_array( $pid ) && !TimberHelper::is_array_assoc( $pid ) ) { |
|
| 160 | + return new $ImageClass($pid); |
|
| 161 | + } )); |
|
| 162 | + $twig->addFunction(new Twig_SimpleFunction('Term', function( $pid, $TermClass = 'TimberTerm' ) { |
|
| 163 | + if ( is_array($pid) && !TimberHelper::is_array_assoc($pid) ) { |
|
| 164 | 164 | foreach ( $pid as &$p ) { |
| 165 | - $p = new $TermClass( $p ); |
|
| 165 | + $p = new $TermClass($p); |
|
| 166 | 166 | } |
| 167 | 167 | return $pid; |
| 168 | 168 | } |
| 169 | - return new $TermClass( $pid ); |
|
| 170 | - } ) ); |
|
| 171 | - $twig->addFunction( new Twig_SimpleFunction( 'User', function ( $pid, $UserClass = 'TimberUser' ) { |
|
| 172 | - if ( is_array( $pid ) && !TimberHelper::is_array_assoc( $pid ) ) { |
|
| 169 | + return new $TermClass($pid); |
|
| 170 | + } )); |
|
| 171 | + $twig->addFunction(new Twig_SimpleFunction('User', function( $pid, $UserClass = 'TimberUser' ) { |
|
| 172 | + if ( is_array($pid) && !TimberHelper::is_array_assoc($pid) ) { |
|
| 173 | 173 | foreach ( $pid as &$p ) { |
| 174 | - $p = new $UserClass( $p ); |
|
| 174 | + $p = new $UserClass($p); |
|
| 175 | 175 | } |
| 176 | 176 | return $pid; |
| 177 | 177 | } |
| 178 | - return new $UserClass( $pid ); |
|
| 179 | - } ) ); |
|
| 178 | + return new $UserClass($pid); |
|
| 179 | + } )); |
|
| 180 | 180 | |
| 181 | 181 | /* bloginfo and translate */ |
| 182 | - $twig->addFunction( 'bloginfo', new Twig_SimpleFunction( 'bloginfo', function ( $show = '', $filter = 'raw' ) { |
|
| 183 | - return get_bloginfo( $show, $filter ); |
|
| 184 | - } ) ); |
|
| 185 | - $twig->addFunction( '__', new Twig_SimpleFunction( '__', function ( $text, $domain = 'default' ) { |
|
| 186 | - return __( $text, $domain ); |
|
| 187 | - } ) ); |
|
| 182 | + $twig->addFunction('bloginfo', new Twig_SimpleFunction('bloginfo', function( $show = '', $filter = 'raw' ) { |
|
| 183 | + return get_bloginfo($show, $filter); |
|
| 184 | + } )); |
|
| 185 | + $twig->addFunction('__', new Twig_SimpleFunction('__', function( $text, $domain = 'default' ) { |
|
| 186 | + return __($text, $domain); |
|
| 187 | + } )); |
|
| 188 | 188 | /* get_twig is deprecated, use timber/twig */ |
| 189 | - $twig = apply_filters( 'get_twig', $twig ); |
|
| 190 | - $twig = apply_filters( 'timber/twig', $twig ); |
|
| 189 | + $twig = apply_filters('get_twig', $twig); |
|
| 190 | + $twig = apply_filters('timber/twig', $twig); |
|
| 191 | 191 | return $twig; |
| 192 | 192 | } |
| 193 | 193 | |
@@ -198,10 +198,10 @@ discard block |
||
| 198 | 198 | * @return array |
| 199 | 199 | */ |
| 200 | 200 | function to_array( $arr ) { |
| 201 | - if ( is_array( $arr ) ) { |
|
| 201 | + if ( is_array($arr) ) { |
|
| 202 | 202 | return $arr; |
| 203 | 203 | } |
| 204 | - $arr = array( $arr ); |
|
| 204 | + $arr = array($arr); |
|
| 205 | 205 | return $arr; |
| 206 | 206 | } |
| 207 | 207 | |
@@ -213,11 +213,11 @@ discard block |
||
| 213 | 213 | */ |
| 214 | 214 | function exec_function( $function_name ) { |
| 215 | 215 | $args = func_get_args(); |
| 216 | - array_shift( $args ); |
|
| 216 | + array_shift($args); |
|
| 217 | 217 | if ( is_string($function_name) ) { |
| 218 | - $function_name = trim( $function_name ); |
|
| 218 | + $function_name = trim($function_name); |
|
| 219 | 219 | } |
| 220 | - return call_user_func_array( $function_name, ( $args ) ); |
|
| 220 | + return call_user_func_array($function_name, ($args)); |
|
| 221 | 221 | } |
| 222 | 222 | |
| 223 | 223 | /** |
@@ -227,7 +227,7 @@ discard block |
||
| 227 | 227 | * @return string |
| 228 | 228 | */ |
| 229 | 229 | function twig_pretags( $content ) { |
| 230 | - return preg_replace_callback( '|<pre.*>(.*)</pre|isU', array( &$this, 'convert_pre_entities' ), $content ); |
|
| 230 | + return preg_replace_callback('|<pre.*>(.*)</pre|isU', array(&$this, 'convert_pre_entities'), $content); |
|
| 231 | 231 | } |
| 232 | 232 | |
| 233 | 233 | /** |
@@ -237,7 +237,7 @@ discard block |
||
| 237 | 237 | * @return string |
| 238 | 238 | */ |
| 239 | 239 | function convert_pre_entities( $matches ) { |
| 240 | - return str_replace( $matches[1], htmlentities( $matches[1] ), $matches[0] ); |
|
| 240 | + return str_replace($matches[1], htmlentities($matches[1]), $matches[0]); |
|
| 241 | 241 | } |
| 242 | 242 | |
| 243 | 243 | /** |
@@ -247,10 +247,10 @@ discard block |
||
| 247 | 247 | */ |
| 248 | 248 | function body_class( $body_classes ) { |
| 249 | 249 | ob_start(); |
| 250 | - if ( is_array( $body_classes ) ) { |
|
| 251 | - $body_classes = explode( ' ', $body_classes ); |
|
| 250 | + if ( is_array($body_classes) ) { |
|
| 251 | + $body_classes = explode(' ', $body_classes); |
|
| 252 | 252 | } |
| 253 | - body_class( $body_classes ); |
|
| 253 | + body_class($body_classes); |
|
| 254 | 254 | $return = ob_get_contents(); |
| 255 | 255 | ob_end_clean(); |
| 256 | 256 | return $return; |
@@ -265,18 +265,18 @@ discard block |
||
| 265 | 265 | */ |
| 266 | 266 | function intl_date( $date, $format = null ) { |
| 267 | 267 | if ( $format === null ) { |
| 268 | - $format = get_option( 'date_format' ); |
|
| 268 | + $format = get_option('date_format'); |
|
| 269 | 269 | } |
| 270 | 270 | |
| 271 | 271 | if ( $date instanceof DateTime ) { |
| 272 | 272 | $timestamp = $date->getTimestamp() + $date->getOffset(); |
| 273 | - } else if (is_numeric( $date ) && strtotime( $date ) === false ) { |
|
| 274 | - $timestamp = intval( $date ); |
|
| 273 | + } else if ( is_numeric($date) && strtotime($date) === false ) { |
|
| 274 | + $timestamp = intval($date); |
|
| 275 | 275 | } else { |
| 276 | - $timestamp = strtotime( $date ); |
|
| 276 | + $timestamp = strtotime($date); |
|
| 277 | 277 | } |
| 278 | 278 | |
| 279 | - return date_i18n( $format, $timestamp ); |
|
| 279 | + return date_i18n($format, $timestamp); |
|
| 280 | 280 | } |
| 281 | 281 | |
| 282 | 282 | //debug |
@@ -290,16 +290,16 @@ discard block |
||
| 290 | 290 | * @return string |
| 291 | 291 | */ |
| 292 | 292 | function object_docs( $obj, $methods = true ) { |
| 293 | - $class = get_class( $obj ); |
|
| 294 | - $properties = (array)$obj; |
|
| 293 | + $class = get_class($obj); |
|
| 294 | + $properties = (array) $obj; |
|
| 295 | 295 | if ( $methods ) { |
| 296 | 296 | /** @var array $methods */ |
| 297 | 297 | $methods = $obj->get_method_values(); |
| 298 | 298 | } |
| 299 | - $rets = array_merge( $properties, $methods ); |
|
| 300 | - ksort( $rets ); |
|
| 301 | - $str = print_r( $rets, true ); |
|
| 302 | - $str = str_replace( 'Array', $class . ' Object', $str ); |
|
| 299 | + $rets = array_merge($properties, $methods); |
|
| 300 | + ksort($rets); |
|
| 301 | + $str = print_r($rets, true); |
|
| 302 | + $str = str_replace('Array', $class . ' Object', $str); |
|
| 303 | 303 | return $str; |
| 304 | 304 | } |
| 305 | 305 | |
@@ -312,13 +312,13 @@ discard block |
||
| 312 | 312 | */ |
| 313 | 313 | function time_ago( $from, $to = null, $format_past = '%s ago', $format_future = '%s from now' ) { |
| 314 | 314 | $to = $to === null ? time() : $to; |
| 315 | - $to = is_int( $to ) ? $to : strtotime( $to ); |
|
| 316 | - $from = is_int( $from ) ? $from : strtotime( $from ); |
|
| 315 | + $to = is_int($to) ? $to : strtotime($to); |
|
| 316 | + $from = is_int($from) ? $from : strtotime($from); |
|
| 317 | 317 | |
| 318 | 318 | if ( $from < $to ) { |
| 319 | - return sprintf( $format_past, human_time_diff( $from, $to ) ); |
|
| 319 | + return sprintf($format_past, human_time_diff($from, $to)); |
|
| 320 | 320 | } else { |
| 321 | - return sprintf( $format_future, human_time_diff( $to, $from ) ); |
|
| 321 | + return sprintf($format_future, human_time_diff($to, $from)); |
|
| 322 | 322 | } |
| 323 | 323 | } |
| 324 | 324 | |
@@ -329,17 +329,17 @@ discard block |
||
| 329 | 329 | * @return string |
| 330 | 330 | */ |
| 331 | 331 | function add_list_separators( $arr, $first_delimiter = ',', $second_delimiter = 'and' ) { |
| 332 | - $length = count( $arr ); |
|
| 332 | + $length = count($arr); |
|
| 333 | 333 | $list = ''; |
| 334 | - foreach( $arr as $index => $item ) { |
|
| 334 | + foreach ( $arr as $index => $item ) { |
|
| 335 | 335 | if ( $index < $length - 2 ) { |
| 336 | - $delimiter = $first_delimiter.' '; |
|
| 336 | + $delimiter = $first_delimiter . ' '; |
|
| 337 | 337 | } elseif ( $index == $length - 2 ) { |
| 338 | - $delimiter = ' '.$second_delimiter.' '; |
|
| 338 | + $delimiter = ' ' . $second_delimiter . ' '; |
|
| 339 | 339 | } else { |
| 340 | 340 | $delimiter = ''; |
| 341 | 341 | } |
| 342 | - $list = $list.$item.$delimiter; |
|
| 342 | + $list = $list . $item . $delimiter; |
|
| 343 | 343 | } |
| 344 | 344 | return $list; |
| 345 | 345 | } |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | /** |
| 41 | 41 | * @param int $cid |
| 42 | 42 | */ |
| 43 | - function __construct($cid) { |
|
| 43 | + function __construct( $cid ) { |
|
| 44 | 44 | $this->init($cid); |
| 45 | 45 | } |
| 46 | 46 | |
@@ -52,9 +52,9 @@ discard block |
||
| 52 | 52 | * @internal |
| 53 | 53 | * @param integer $cid |
| 54 | 54 | */ |
| 55 | - function init($cid) { |
|
| 55 | + function init( $cid ) { |
|
| 56 | 56 | $comment_data = $cid; |
| 57 | - if (is_integer($cid)) { |
|
| 57 | + if ( is_integer($cid) ) { |
|
| 58 | 58 | $comment_data = get_comment($cid); |
| 59 | 59 | } |
| 60 | 60 | $this->import($comment_data); |
@@ -86,11 +86,11 @@ discard block |
||
| 86 | 86 | * @return TimberUser |
| 87 | 87 | */ |
| 88 | 88 | public function author() { |
| 89 | - if ($this->user_id) { |
|
| 89 | + if ( $this->user_id ) { |
|
| 90 | 90 | return new TimberUser($this->user_id); |
| 91 | 91 | } else { |
| 92 | 92 | $author = new TimberUser(0); |
| 93 | - if (isset($this->comment_author) && $this->comment_author) { |
|
| 93 | + if ( isset($this->comment_author) && $this->comment_author ) { |
|
| 94 | 94 | $author->name = $this->comment_author; |
| 95 | 95 | } else { |
| 96 | 96 | $author->name = 'Anonymous'; |
@@ -113,22 +113,22 @@ discard block |
||
| 113 | 113 | * @param string $default |
| 114 | 114 | * @return bool|mixed|string |
| 115 | 115 | */ |
| 116 | - public function avatar($size = 92, $default = '') { |
|
| 117 | - if (!get_option('show_avatars')) { |
|
| 116 | + public function avatar( $size = 92, $default = '' ) { |
|
| 117 | + if ( !get_option('show_avatars') ) { |
|
| 118 | 118 | return false; |
| 119 | 119 | } |
| 120 | - if (!is_numeric($size)) { |
|
| 120 | + if ( !is_numeric($size) ) { |
|
| 121 | 121 | $size = '92'; |
| 122 | 122 | } |
| 123 | 123 | |
| 124 | 124 | $email = $this->avatar_email(); |
| 125 | 125 | $email_hash = ''; |
| 126 | - if (!empty($email)) { |
|
| 126 | + if ( !empty($email) ) { |
|
| 127 | 127 | $email_hash = md5(strtolower(trim($email))); |
| 128 | 128 | } |
| 129 | 129 | $host = $this->avatar_host($email_hash); |
| 130 | 130 | $default = $this->avatar_default($default, $email, $size, $host); |
| 131 | - if (!empty($email)) { |
|
| 131 | + if ( !empty($email) ) { |
|
| 132 | 132 | $avatar = $this->avatar_out($default, $host, $email_hash, $size); |
| 133 | 133 | } else { |
| 134 | 134 | $avatar = $default; |
@@ -181,7 +181,7 @@ discard block |
||
| 181 | 181 | */ |
| 182 | 182 | public function date( $date_format = '' ) { |
| 183 | 183 | $df = $date_format ? $date_format : get_option('date_format'); |
| 184 | - $the_date = (string)mysql2date($df, $this->comment_date); |
|
| 184 | + $the_date = (string) mysql2date($df, $this->comment_date); |
|
| 185 | 185 | return apply_filters('get_comment_date ', $the_date, $df); |
| 186 | 186 | } |
| 187 | 187 | |
@@ -206,7 +206,7 @@ discard block |
||
| 206 | 206 | */ |
| 207 | 207 | public function time( $time_format = '' ) { |
| 208 | 208 | $tf = $time_format ? $time_format : get_option('time_format'); |
| 209 | - $the_time = (string)mysql2date($tf, $this->comment_date); |
|
| 209 | + $the_time = (string) mysql2date($tf, $this->comment_date); |
|
| 210 | 210 | return apply_filters('get_comment_time', $the_time, $tf); |
| 211 | 211 | } |
| 212 | 212 | |
@@ -214,7 +214,7 @@ discard block |
||
| 214 | 214 | * @param string $field_name |
| 215 | 215 | * @return mixed |
| 216 | 216 | */ |
| 217 | - public function meta($field_name) { |
|
| 217 | + public function meta( $field_name ) { |
|
| 218 | 218 | return $this->get_meta_field($field_name); |
| 219 | 219 | } |
| 220 | 220 | |
@@ -231,15 +231,15 @@ discard block |
||
| 231 | 231 | * @param int $comment_id |
| 232 | 232 | * @return mixed |
| 233 | 233 | */ |
| 234 | - protected function get_meta_fields($comment_id = null) { |
|
| 235 | - if ($comment_id === null) { |
|
| 234 | + protected function get_meta_fields( $comment_id = null ) { |
|
| 235 | + if ( $comment_id === null ) { |
|
| 236 | 236 | $comment_id = $this->ID; |
| 237 | 237 | } |
| 238 | 238 | //Could not find a WP function to fetch all comment meta data, so I made one. |
| 239 | 239 | apply_filters('timber_comment_get_meta_pre', array(), $comment_id); |
| 240 | 240 | $comment_metas = get_comment_meta($comment_id); |
| 241 | - foreach ($comment_metas as &$cm) { |
|
| 242 | - if (is_array($cm) && count($cm) == 1) { |
|
| 241 | + foreach ( $comment_metas as &$cm ) { |
|
| 242 | + if ( is_array($cm) && count($cm) == 1 ) { |
|
| 243 | 243 | $cm = $cm[0]; |
| 244 | 244 | } |
| 245 | 245 | } |
@@ -252,9 +252,9 @@ discard block |
||
| 252 | 252 | * @param string $field_name |
| 253 | 253 | * @return mixed |
| 254 | 254 | */ |
| 255 | - protected function get_meta_field($field_name) { |
|
| 255 | + protected function get_meta_field( $field_name ) { |
|
| 256 | 256 | $value = apply_filters('timber_comment_get_meta_field_pre', null, $this->ID, $field_name, $this); |
| 257 | - if ($value === null) { |
|
| 257 | + if ( $value === null ) { |
|
| 258 | 258 | $value = get_comment_meta($this->ID, $field_name, true); |
| 259 | 259 | } |
| 260 | 260 | $value = apply_filters('timber_comment_get_meta_field', $value, $this->ID, $field_name, $this); |
@@ -269,7 +269,7 @@ discard block |
||
| 269 | 269 | */ |
| 270 | 270 | public function reply_link( $reply_text = 'Reply' ) { |
| 271 | 271 | if ( is_singular() && comments_open() && get_option('thread_comments') ) { |
| 272 | - wp_enqueue_script( 'comment-reply' ); |
|
| 272 | + wp_enqueue_script('comment-reply'); |
|
| 273 | 273 | } |
| 274 | 274 | |
| 275 | 275 | // Get the comments depth option from the admin panel |
@@ -284,7 +284,7 @@ discard block |
||
| 284 | 284 | 'max_depth' => $max_depth, |
| 285 | 285 | ); |
| 286 | 286 | |
| 287 | - return get_comment_reply_link( $args, $this->ID, $this->post_id ); |
|
| 287 | + return get_comment_reply_link($args, $this->ID, $this->post_id); |
|
| 288 | 288 | } |
| 289 | 289 | |
| 290 | 290 | /* AVATAR Stuff |
@@ -295,9 +295,9 @@ discard block |
||
| 295 | 295 | * @return string |
| 296 | 296 | */ |
| 297 | 297 | protected function avatar_email() { |
| 298 | - $id = (int)$this->user_id; |
|
| 298 | + $id = (int) $this->user_id; |
|
| 299 | 299 | $user = get_userdata($id); |
| 300 | - if ($user) { |
|
| 300 | + if ( $user ) { |
|
| 301 | 301 | $email = $user->user_email; |
| 302 | 302 | } else { |
| 303 | 303 | $email = $this->comment_author_email; |
@@ -310,11 +310,11 @@ discard block |
||
| 310 | 310 | * @param string $email_hash |
| 311 | 311 | * @return string |
| 312 | 312 | */ |
| 313 | - protected function avatar_host($email_hash) { |
|
| 314 | - if (is_ssl()) { |
|
| 313 | + protected function avatar_host( $email_hash ) { |
|
| 314 | + if ( is_ssl() ) { |
|
| 315 | 315 | $host = 'https://secure.gravatar.com'; |
| 316 | 316 | } else { |
| 317 | - if (!empty($email_hash)) { |
|
| 317 | + if ( !empty($email_hash) ) { |
|
| 318 | 318 | $host = sprintf("http://%d.gravatar.com", (hexdec($email_hash[0]) % 2)); |
| 319 | 319 | } else { |
| 320 | 320 | $host = 'http://0.gravatar.com'; |
@@ -332,29 +332,29 @@ discard block |
||
| 332 | 332 | * @param string $host |
| 333 | 333 | * @return string |
| 334 | 334 | */ |
| 335 | - protected function avatar_default($default, $email, $size, $host) { |
|
| 336 | - if (substr($default, 0, 1) == '/') { |
|
| 335 | + protected function avatar_default( $default, $email, $size, $host ) { |
|
| 336 | + if ( substr($default, 0, 1) == '/' ) { |
|
| 337 | 337 | $default = home_url() . $default; |
| 338 | 338 | } |
| 339 | 339 | |
| 340 | - if (empty($default)) { |
|
| 340 | + if ( empty($default) ) { |
|
| 341 | 341 | $avatar_default = get_option('avatar_default'); |
| 342 | - if (empty($avatar_default)) { |
|
| 342 | + if ( empty($avatar_default) ) { |
|
| 343 | 343 | $default = 'mystery'; |
| 344 | 344 | } else { |
| 345 | 345 | $default = $avatar_default; |
| 346 | 346 | } |
| 347 | 347 | } |
| 348 | - if ('mystery' == $default) { |
|
| 348 | + if ( 'mystery' == $default ) { |
|
| 349 | 349 | $default = $host . '/avatar/ad516503a11cd5ca435acc9bb6523536?s=' . $size; |
| 350 | 350 | // ad516503a11cd5ca435acc9bb6523536 == md5('[email protected]') |
| 351 | - } else if ('blank' == $default) { |
|
| 351 | + } else if ( 'blank' == $default ) { |
|
| 352 | 352 | $default = $email ? 'blank' : includes_url('images/blank.gif'); |
| 353 | - } else if (!empty($email) && 'gravatar_default' == $default) { |
|
| 353 | + } else if ( !empty($email) && 'gravatar_default' == $default ) { |
|
| 354 | 354 | $default = ''; |
| 355 | - } else if ('gravatar_default' == $default) { |
|
| 355 | + } else if ( 'gravatar_default' == $default ) { |
|
| 356 | 356 | $default = $host . '/avatar/?s=' . $size; |
| 357 | - } else if (empty($email) && !strstr($default, 'http://')) { |
|
| 357 | + } else if ( empty($email) && !strstr($default, 'http://') ) { |
|
| 358 | 358 | $default = $host . '/avatar/?d=' . $default . '&s=' . $size; |
| 359 | 359 | } |
| 360 | 360 | return $default; |
@@ -368,10 +368,10 @@ discard block |
||
| 368 | 368 | * @param string $size |
| 369 | 369 | * @return mixed |
| 370 | 370 | */ |
| 371 | - protected function avatar_out($default, $host, $email_hash, $size) { |
|
| 371 | + protected function avatar_out( $default, $host, $email_hash, $size ) { |
|
| 372 | 372 | $out = $host . '/avatar/' . $email_hash . '?s=' . $size . '&d=' . urlencode($default); |
| 373 | 373 | $rating = get_option('avatar_rating'); |
| 374 | - if (!empty($rating)) { |
|
| 374 | + if ( !empty($rating) ) { |
|
| 375 | 375 | $out .= '&r=' . $rating; |
| 376 | 376 | } |
| 377 | 377 | return str_replace('&', '&', esc_url($out)); |
@@ -8,7 +8,7 @@ discard block |
||
| 8 | 8 | * @param string $TermClass |
| 9 | 9 | * @return mixed |
| 10 | 10 | */ |
| 11 | - public static function get_terms($args = null, $maybe_args = array(), $TermClass = 'TimberTerm') { |
|
| 11 | + public static function get_terms( $args = null, $maybe_args = array(), $TermClass = 'TimberTerm' ) { |
|
| 12 | 12 | if ( is_string($maybe_args) && !strstr($maybe_args, '=') ) { |
| 13 | 13 | //the user is sending the $TermClass in the second argument |
| 14 | 14 | $TermClass = $maybe_args; |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | * @param string $TermClass |
| 54 | 54 | * @return mixed |
| 55 | 55 | */ |
| 56 | - public static function handle_term_query($taxonomies, $args, $TermClass) { |
|
| 56 | + public static function handle_term_query( $taxonomies, $args, $TermClass ) { |
|
| 57 | 57 | if ( !isset($args['hide_empty']) ) { |
| 58 | 58 | $args['hide_empty'] = false; |
| 59 | 59 | } |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | $args['include'] = $args['term_id']; |
| 65 | 65 | } |
| 66 | 66 | $terms = get_terms($taxonomies, $args); |
| 67 | - foreach ($terms as &$term) { |
|
| 67 | + foreach ( $terms as &$term ) { |
|
| 68 | 68 | $term = new $TermClass($term->term_id, $term->taxonomy); |
| 69 | 69 | } |
| 70 | 70 | return $terms; |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | * @param string $query_string |
| 75 | 75 | * @return stdClass |
| 76 | 76 | */ |
| 77 | - protected static function get_term_query_from_query_string($query_string) { |
|
| 77 | + protected static function get_term_query_from_query_string( $query_string ) { |
|
| 78 | 78 | $args = array(); |
| 79 | 79 | parse_str($query_string, $args); |
| 80 | 80 | $ret = self::get_term_query_from_assoc_array($args); |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | * @param string $taxs |
| 86 | 86 | * @return stdClass |
| 87 | 87 | */ |
| 88 | - protected static function get_term_query_from_string($taxs) { |
|
| 88 | + protected static function get_term_query_from_string( $taxs ) { |
|
| 89 | 89 | $ret = new stdClass(); |
| 90 | 90 | $ret->args = array(); |
| 91 | 91 | if ( is_string($taxs) ) { |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | * @param array $args |
| 100 | 100 | * @return stdClass |
| 101 | 101 | */ |
| 102 | - public static function get_term_query_from_assoc_array($args) { |
|
| 102 | + public static function get_term_query_from_assoc_array( $args ) { |
|
| 103 | 103 | $ret = new stdClass(); |
| 104 | 104 | $ret->args = $args; |
| 105 | 105 | if ( isset($ret->args['tax']) ) { |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | * @param array $args |
| 127 | 127 | * @return stdClass |
| 128 | 128 | */ |
| 129 | - public static function get_term_query_from_array($args) { |
|
| 129 | + public static function get_term_query_from_array( $args ) { |
|
| 130 | 130 | if ( is_array($args) && !empty($args) ) { |
| 131 | 131 | //okay its an array with content |
| 132 | 132 | if ( is_int($args[0]) ) { |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | * @param integer[] $args |
| 143 | 143 | * @return stdClass |
| 144 | 144 | */ |
| 145 | - public static function get_term_query_from_array_of_ids($args) { |
|
| 145 | + public static function get_term_query_from_array_of_ids( $args ) { |
|
| 146 | 146 | $ret = new stdClass(); |
| 147 | 147 | $ret->taxonomies = get_taxonomies(); |
| 148 | 148 | $ret->args['include'] = $args; |
@@ -153,7 +153,7 @@ discard block |
||
| 153 | 153 | * @param string[] $args |
| 154 | 154 | * @return stdClass |
| 155 | 155 | */ |
| 156 | - public static function get_term_query_from_array_of_strings($args) { |
|
| 156 | + public static function get_term_query_from_array_of_strings( $args ) { |
|
| 157 | 157 | $ret = new stdClass(); |
| 158 | 158 | $ret->taxonomies = self::correct_taxonomy_names($args); |
| 159 | 159 | $ret->args = array(); |
@@ -164,11 +164,11 @@ discard block |
||
| 164 | 164 | * @param string|array $taxs |
| 165 | 165 | * @return array |
| 166 | 166 | */ |
| 167 | - private static function correct_taxonomy_names($taxs) { |
|
| 167 | + private static function correct_taxonomy_names( $taxs ) { |
|
| 168 | 168 | if ( is_string($taxs) ) { |
| 169 | 169 | $taxs = array($taxs); |
| 170 | 170 | } |
| 171 | - foreach ($taxs as &$tax) { |
|
| 171 | + foreach ( $taxs as &$tax ) { |
|
| 172 | 172 | if ( $tax == 'tags' || $tax == 'tag' ) { |
| 173 | 173 | $tax = 'post_tag'; |
| 174 | 174 | } else if ( $tax == 'categories' ) { |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | /** |
| 54 | 54 | * @param int|bool $uid |
| 55 | 55 | */ |
| 56 | - function __construct($uid = false) { |
|
| 56 | + function __construct( $uid = false ) { |
|
| 57 | 57 | $this->init($uid); |
| 58 | 58 | } |
| 59 | 59 | |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | * @param string $field_name |
| 85 | 85 | * @return null |
| 86 | 86 | */ |
| 87 | - function get_meta($field_name) { |
|
| 87 | + function get_meta( $field_name ) { |
|
| 88 | 88 | return $this->get_meta_field($field_name); |
| 89 | 89 | } |
| 90 | 90 | |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | * @param string $field |
| 94 | 94 | * @param mixed $value |
| 95 | 95 | */ |
| 96 | - function __set($field, $value) { |
|
| 96 | + function __set( $field, $value ) { |
|
| 97 | 97 | if ( $field == 'name' ) { |
| 98 | 98 | $this->display_name = $value; |
| 99 | 99 | } |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | * @internal |
| 105 | 105 | * @param int|bool $uid The user ID to use |
| 106 | 106 | */ |
| 107 | - protected function init($uid = false) { |
|
| 107 | + protected function init( $uid = false ) { |
|
| 108 | 108 | if ( $uid === false ) { |
| 109 | 109 | $uid = get_current_user_id(); |
| 110 | 110 | } |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | * @param string $field_name |
| 138 | 138 | * @return mixed |
| 139 | 139 | */ |
| 140 | - function get_meta_field($field_name) { |
|
| 140 | + function get_meta_field( $field_name ) { |
|
| 141 | 141 | $value = null; |
| 142 | 142 | $value = apply_filters('timber_user_get_meta_field_pre', $value, $this->ID, $field_name, $this); |
| 143 | 143 | if ( $value === null ) { |
@@ -158,7 +158,7 @@ discard block |
||
| 158 | 158 | $um = get_user_meta($this->ID); |
| 159 | 159 | } |
| 160 | 160 | $custom = array(); |
| 161 | - foreach ($um as $key => $value) { |
|
| 161 | + foreach ( $um as $key => $value ) { |
|
| 162 | 162 | if ( is_array($value) && count($value) == 1 ) { |
| 163 | 163 | $value = $value[0]; |
| 164 | 164 | } |
@@ -193,7 +193,7 @@ discard block |
||
| 193 | 193 | * @param string $field_name |
| 194 | 194 | * @return mixed |
| 195 | 195 | */ |
| 196 | - function meta($field_name) { |
|
| 196 | + function meta( $field_name ) { |
|
| 197 | 197 | return $this->get_meta_field($field_name); |
| 198 | 198 | } |
| 199 | 199 | |
@@ -12,16 +12,16 @@ |
||
| 12 | 12 | */ |
| 13 | 13 | private $timberloader; |
| 14 | 14 | |
| 15 | - public function __construct(TimberLoader $timberloader, $cache_group = 'timber') { |
|
| 15 | + public function __construct( TimberLoader $timberloader, $cache_group = 'timber' ) { |
|
| 16 | 16 | $this->cache_group = $cache_group; |
| 17 | 17 | $this->timberloader = $timberloader; |
| 18 | 18 | } |
| 19 | 19 | |
| 20 | - public function fetch($key) { |
|
| 20 | + public function fetch( $key ) { |
|
| 21 | 21 | return $this->timberloader->get_cache($key, $this->cache_group, TimberLoader::CACHE_USE_DEFAULT); |
| 22 | 22 | } |
| 23 | 23 | |
| 24 | - public function save($key, $value, $expire = 0) { |
|
| 24 | + public function save( $key, $value, $expire = 0 ) { |
|
| 25 | 25 | return $this->timberloader->set_cache($key, $value, $this->cache_group, $expire, TimberLoader::CACHE_USE_DEFAULT); |
| 26 | 26 | } |
| 27 | 27 | |
@@ -10,17 +10,17 @@ |
||
| 10 | 10 | * @param mixed $value |
| 11 | 11 | * @return string |
| 12 | 12 | */ |
| 13 | - public function generateKey($value) { |
|
| 14 | - if (is_a($value, 'TimberKeyGeneratorInterface')) { |
|
| 13 | + public function generateKey( $value ) { |
|
| 14 | + if ( is_a($value, 'TimberKeyGeneratorInterface') ) { |
|
| 15 | 15 | return $value->_get_cache_key(); |
| 16 | 16 | } |
| 17 | 17 | |
| 18 | - if (is_array($value) && isset($value['_cache_key'])) { |
|
| 18 | + if ( is_array($value) && isset($value['_cache_key']) ) { |
|
| 19 | 19 | return $value['_cache_key']; |
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | $key = md5(json_encode($value)); |
| 23 | - if (is_object($value)) { |
|
| 23 | + if ( is_object($value) ) { |
|
| 24 | 24 | $key = get_class($value) . '|' . $key; |
| 25 | 25 | } |
| 26 | 26 | |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | * We are currently using the My Theme theme. |
| 63 | 63 | * ``` |
| 64 | 64 | */ |
| 65 | - function __construct($slug = null) { |
|
| 65 | + function __construct( $slug = null ) { |
|
| 66 | 66 | $this->init($slug); |
| 67 | 67 | } |
| 68 | 68 | |
@@ -70,13 +70,13 @@ discard block |
||
| 70 | 70 | * @internal |
| 71 | 71 | * @param string $slug |
| 72 | 72 | */ |
| 73 | - protected function init($slug = null) { |
|
| 73 | + protected function init( $slug = null ) { |
|
| 74 | 74 | $data = wp_get_theme($slug); |
| 75 | 75 | $this->name = $data->get('Name'); |
| 76 | 76 | $ss = $data->get_stylesheet(); |
| 77 | 77 | $this->slug = $ss; |
| 78 | 78 | |
| 79 | - if ( ! function_exists( 'get_home_path' ) ) { |
|
| 79 | + if ( !function_exists('get_home_path') ) { |
|
| 80 | 80 | require_once(ABSPATH . 'wp-admin/includes/file.php'); |
| 81 | 81 | } |
| 82 | 82 | |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | * @return string the relative path to the theme (ex: `/wp-content/themes/my-timber-theme`) |
| 104 | 104 | */ |
| 105 | 105 | public function path() { |
| 106 | - return TimberURLHelper::get_rel_url( $this->link() ); |
|
| 106 | + return TimberURLHelper::get_rel_url($this->link()); |
|
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | /** |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | * @param bool $default |
| 112 | 112 | * @return string |
| 113 | 113 | */ |
| 114 | - public function theme_mod($name, $default = false) { |
|
| 114 | + public function theme_mod( $name, $default = false ) { |
|
| 115 | 115 | return get_theme_mod($name, $default); |
| 116 | 116 | } |
| 117 | 117 | |