| Conditions | 4 |
| Paths | 3 |
| Total Lines | 25 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 26 | public static function loadFieldGroups() |
||
| 27 | { |
||
| 28 | // prevent this running more than once |
||
| 29 | if (self::$fieldGroupsLoaded) { |
||
| 30 | return; |
||
| 31 | } |
||
| 32 | |||
| 33 | // Load field groups from files after ACF initializes |
||
| 34 | $dir = get_template_directory() . self::FIELD_GROUPS_DIR; |
||
| 35 | |||
| 36 | if (!is_dir($dir)) { |
||
| 37 | trigger_error("[ACF] Cannot load field groups: {$dir} is not a valid directory!", E_USER_WARNING); |
||
| 38 | return; |
||
| 39 | } |
||
| 40 | |||
| 41 | FileLoader::iterateDir($dir, function ($file) { |
||
| 42 | if ($file->getExtension() === 'json') { |
||
| 43 | $filePath = $file->getPathname(); |
||
| 44 | $config = json_decode(file_get_contents($filePath), true); |
||
| 45 | ACFComposer::registerFieldGroup($config); |
||
| 46 | } |
||
| 47 | }); |
||
| 48 | |||
| 49 | self::$fieldGroupsLoaded = true; |
||
| 50 | } |
||
| 51 | } |
||
| 52 |