flyntwp / flynt-starter-theme

The starter theme for building Flynt projects.
MIT License
69 stars 4 forks source link

Features: Order problem #152

Closed vandebled closed 7 years ago

vandebled commented 7 years ago

Trying to access a CustomPostType options field (globalOptions) inside a component, figured out it was not working. This caused by the action hook change on Features/CustomPostTypes/functions.php, from Flynt/afterRegisterFeatures to init. Fixed it temporarily by adding a low priority to the init action hook of the GoogleAnalytics Feature: add_action('init', 'Flynt\Features\GoogleAnalytics\init', 100);

dgrdl commented 7 years ago

This is caused by the nature of the ACF OptionPages sub-feature. Since it only runs a single get_fields('options') call and then caches the result, it can happen that at that point in time not all option page fields have been registered yet and therefore no values are returned for those fields.

As soon as #166 and #167 are merged, I will see if I can add a check if all option pages have been registered yet before getting the values from the database and at least issue a warning.