Plugin Directory

Changeset 2553568


Ignore:
Timestamp:
06/24/2021 09:03:59 PM (5 years ago)
Author:
abigegg
Message:

Commit 0.6.0 to trunk

Location:
hatch
Files:
1 edited
6 copied

Legend:

Unmodified
Added
Removed
  • hatch/trunk/abe-hatch.php

    r2551418 r2553568  
    33 * Plugin name: Hatch
    44 * Author: A Big Egg
    5  * Version: 0.5.5
     5 * Version: 0.6.0
    66 * 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.
    77 */
     
    104104        }
    105105
    106         self::$context[$key] = self::get_value_from_thing( $value );
     106        $current_post = self::get_post();
     107
     108        self::$context[$key] = self::get_value_from_thing( $value, [ $current_post ] );
    107109    }
    108110
     
    130132     *
    131133     * @param  mixed $thing
    132      * @return void
    133      */
    134     static private function get_value_from_thing( $thing ) {
     134     * @param  mixed Post for context (passed into the callback )
     135     * @return void
     136     */
     137    static private function get_value_from_thing( $thing, $context = [] ) {
    135138        if ( is_callable( $thing ) || function_exists( $thing ) ) {
    136             return call_user_func( $thing );
     139            // we can optionally pass in context to the function
     140            return call_user_func_array( $thing, $context );
    137141        }
    138142
Note: See TracChangeset for help on using the changeset viewer.