Changeset 2555307
- Timestamp:
- 06/28/2021 02:02:10 PM (5 years ago)
- Location:
- hatch
- Files:
-
- 1 edited
- 6 copied
-
tags/0.6.0 (copied) (copied from hatch/trunk)
-
tags/0.6.0/LICENSE.md (copied) (copied from hatch/trunk/LICENSE.md)
-
tags/0.6.0/abe-hatch.php (copied) (copied from hatch/trunk/abe-hatch.php)
-
tags/0.6.0/inc (copied) (copied from hatch/trunk/inc)
-
tags/0.6.0/readme.md (copied) (copied from hatch/trunk/readme.md)
-
tags/0.6.0/readme.txt (copied) (copied from hatch/trunk/readme.txt)
-
trunk/abe-hatch.php (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
hatch/trunk/abe-hatch.php
r2553568 r2555307 3 3 * Plugin name: Hatch 4 4 * Author: A Big Egg 5 * Version: 0.6. 05 * Version: 0.6.1 6 6 * Description: Provides helper functions for working with Timber and ACF. Requires Timber (timber-library) and works well with Advanced Custom Fields Pro and Gravity Forms. 7 7 */ … … 17 17 static $taxonomy_transformers = []; 18 18 static $main_transformer = false; 19 20 static $post_cache = []; 19 21 20 22 function __construct() { … … 269 271 */ 270 272 static function get_post( $post = false ) { 271 $the_post = Timber::get_post( $post ); 272 273 return self::construct_post( $the_post ); 273 return self::construct_post( $post ); 274 274 } 275 275 … … 278 278 * 279 279 * @param mixed $post_id 280 * @return void280 * @return mixed 281 281 */ 282 282 static function construct_post( $post_id = 0 ) { 283 if ( ! $post_id ) { 284 return $post_id; 285 } 286 283 if ( ! empty( $post_id ) ) { 284 285 // we have a TimberPost or WP_Post 286 if ( is_object( $post_id ) ) { 287 $post_id = $post_id->ID; 288 } 289 290 if ( isset( self::$post_cache[$post_id] ) ) { 291 return self::$post_cache[$post_id]; 292 } 293 } 294 295 // cache did not hit 287 296 $post = new Timber\Post( $post_id ); 288 297 289 $thumb_id = get_post_thumbnail_id( $post );298 $thumb_id = get_post_thumbnail_id( $post->ID ); 290 299 291 300 if ( $thumb_id ) { … … 296 305 $post = self::transform_post( $post ); 297 306 } 298 307 308 self::$post_cache[$post->ID] = $post; 299 309 300 310 return $post;
Note: See TracChangeset
for help on using the changeset viewer.