Skip to main content

Autoloader

Can be used to load from parent or child theme.

Overview​

Methods​

NameReturn TypeSummary/Returns
child()Loader for child folder in library directory.
child_blocks()Loader for child theme blocks.
fields()voidFields loader
getLoadedFiles()array or voidUse this function to get all loaded files and manually include them in your theme.
parent()Loader for parent folder in lib directory.

Class Methods​

child()​

Loader for child folder in library directory.

child( array $dirs_to_load )

NameTypeDescription
$dirs_to_loadarrayarray of directories to load

child_blocks()​

Loader for child theme blocks.

since 3.3.0


fields()​

Fields loader

This function looks into the library/models/fields/ directory for files to load.

This process starts by checking for the existence of the filtered folder and loading any PHP files found within it. That way we will load the files first that modify the existing fields in wp-lemon.

After that, we will search for the fields/reusable folder and load all PHP files from that folder. This ensures that any reusable fields are loaded before any other fields. Make sure to not include full field groups, including locations here.

Finally, it will load all other PHP files in the fields directory within the acf/init action.

since 5.7.0

Returns: void


getLoadedFiles()​

Use this function to get all loaded files and manually include them in your theme.

That way we can skip the autoloading, that will lead to a more performant theme.

getLoadedFiles( bool $return = false )

Returns: array|void

NameTypeDescription
$returnboolWhether to return the files array or echo them

parent()​

Loader for parent folder in lib directory.

parent( array|false $dirs_to_load = false )

NameTypeDescription
$dirs_to_loadarray or falsearray of directories to load