@@ -71,6 +71,9 @@ |
||
71 | 71 | self::addFilters('feature', $name, $filePath); |
72 | 72 | } |
73 | 73 | |
74 | + /** |
|
75 | + * @param string $type |
|
76 | + */ |
|
74 | 77 | public static function addFilters($type, $name, $filePath) |
75 | 78 | { |
76 | 79 | if (false === $filePath || !file_exists($filePath)) { |
@@ -2,10 +2,8 @@ |
||
2 | 2 | |
3 | 3 | namespace Flynt\Features\Acf; |
4 | 4 | |
5 | -use RecursiveDirectoryIterator; |
|
6 | 5 | use Flynt\Utils\ArrayHelpers; |
7 | 6 | use Flynt\Utils\StringHelpers; |
8 | -use Flynt\Utils\FileLoader; |
|
9 | 7 | use Flynt\ComponentManager; |
10 | 8 | |
11 | 9 | class FieldLoader |
@@ -84,14 +84,14 @@ discard block |
||
84 | 84 | $filterNamespace = self::FILTER_NAMESPACES[$type]; |
85 | 85 | $filterName = "{$filterNamespace}/{$name}/Fields/{$groupKey}"; |
86 | 86 | |
87 | - add_filter($filterName, function ($config) use ($groupValue) { |
|
87 | + add_filter($filterName, function($config) use ($groupValue) { |
|
88 | 88 | return $groupValue; |
89 | 89 | }); |
90 | 90 | if (ArrayHelpers::isAssoc($groupValue) && array_key_exists('sub_fields', $groupValue)) { |
91 | 91 | $filterName .= '/SubFields'; |
92 | 92 | $subFields = $groupValue['sub_fields']; |
93 | 93 | |
94 | - add_filter($filterName, function ($subFieldsconfig) use ($subFields) { |
|
94 | + add_filter($filterName, function($subFieldsconfig) use ($subFields) { |
|
95 | 95 | return $subFields; |
96 | 96 | }); |
97 | 97 | self::addFilterForSubFields($filterName, $subFields); |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | $subFieldName = ucfirst($subField['name']); |
115 | 115 | $subFilterName = $parentFilterName . "/{$subFieldName}"; |
116 | 116 | |
117 | - add_filter($subFilterName, function ($subFieldConfig) use ($subField) { |
|
117 | + add_filter($subFilterName, function($subFieldConfig) use ($subField) { |
|
118 | 118 | return $subField; |
119 | 119 | }); |
120 | 120 | } |
@@ -246,6 +246,9 @@ discard block |
||
246 | 246 | }); |
247 | 247 | } |
248 | 248 | |
249 | + /** |
|
250 | + * @param string $type |
|
251 | + */ |
|
249 | 252 | protected static function createSubPage($type, $name) |
250 | 253 | { |
251 | 254 | $namespace = self::FILTER_NAMESPACES[$type]; |
@@ -263,6 +266,9 @@ discard block |
||
263 | 266 | } |
264 | 267 | } |
265 | 268 | |
269 | + /** |
|
270 | + * @param string $subPageName |
|
271 | + */ |
|
266 | 272 | protected static function addOptionSubPage($optionCategoryName, $subPageName, $optionType, $fields) |
267 | 273 | { |
268 | 274 | $prettySubPageName = StringHelpers::splitCamelCase($subPageName); |
@@ -291,6 +297,9 @@ discard block |
||
291 | 297 | ); |
292 | 298 | } |
293 | 299 | |
300 | + /** |
|
301 | + * @param string $menuSlug |
|
302 | + */ |
|
294 | 303 | protected static function addFieldGroupToSubPage($parentMenuSlug, $menuSlug, $prettySubPageName, $fields) |
295 | 304 | { |
296 | 305 | $fieldGroup = ACFComposer\ResolveConfig::forFieldGroup( |
@@ -314,6 +323,10 @@ discard block |
||
314 | 323 | acf_add_local_field_group($fieldGroup); |
315 | 324 | } |
316 | 325 | |
326 | + /** |
|
327 | + * @param string $optionCategory |
|
328 | + * @param string $feature |
|
329 | + */ |
|
317 | 330 | protected static function checkFeature($optionCategory, $feature) |
318 | 331 | { |
319 | 332 | if (array_key_exists($optionCategory, self::$optionCategories) && !Feature::isRegistered($feature)) { |
@@ -13,7 +13,6 @@ |
||
13 | 13 | use Flynt\Features\AdminNotices\AdminNoticeManager; |
14 | 14 | use Flynt\Features\CustomPostTypes\CustomPostTypeRegister; |
15 | 15 | use Flynt\Utils\Feature; |
16 | -use Flynt\Utils\FileLoader; |
|
17 | 16 | use Flynt\Utils\StringHelpers; |
18 | 17 | |
19 | 18 | class OptionPages |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | self::createOptionPages(); |
72 | 72 | |
73 | 73 | // Register Categories |
74 | - add_action('acf/init', function () { |
|
74 | + add_action('acf/init', function() { |
|
75 | 75 | foreach (self::$optionCategories as $categoryName => $categorySettings) { |
76 | 76 | $name = ucfirst($categoryName); |
77 | 77 | $registerFn = "add{$name}SubPages"; |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | |
132 | 132 | // find and replace relevant keys, then return an array of all options for this Sub-Page |
133 | 133 | $optionKeys = is_array($options) ? array_keys($options) : []; |
134 | - $options = array_reduce($optionKeys, function ($carry, $key) use ($options, $prefix) { |
|
134 | + $options = array_reduce($optionKeys, function($carry, $key) use ($options, $prefix) { |
|
135 | 135 | $count = 0; |
136 | 136 | $option = $options[$key]; |
137 | 137 | $key = str_replace($prefix, '', $key, $count); |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | public static function addComponentData($data, $parentData, $config) |
156 | 156 | { |
157 | 157 | // get fields for this component |
158 | - $options = array_reduce(array_keys(self::$optionTypes), function ($carry, $optionType) use ($config) { |
|
158 | + $options = array_reduce(array_keys(self::$optionTypes), function($carry, $optionType) use ($config) { |
|
159 | 159 | return array_merge($carry, self::get($optionType, 'Component', $config['name'])); |
160 | 160 | }, []); |
161 | 161 | |
@@ -223,7 +223,7 @@ discard block |
||
223 | 223 | ]; |
224 | 224 | } |
225 | 225 | |
226 | - add_action('current_screen', function ($currentScreen) { |
|
226 | + add_action('current_screen', function($currentScreen) { |
|
227 | 227 | foreach (self::$optionTypes as $optionType => $option) { |
228 | 228 | $isTranslatable = $option['translatable']; |
229 | 229 | $toplevelPageId = 'toplevel_page_' . $optionType; |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | add_filter('acf/settings/current_language', 'Flynt\Features\Acf\OptionPages::getDefaultAcfLanguage', 101); |
238 | 238 | |
239 | 239 | // hide language selector in admin bar |
240 | - add_action('wp_before_admin_bar_render', function () { |
|
240 | + add_action('wp_before_admin_bar_render', function() { |
|
241 | 241 | $adminBar = $GLOBALS['wp_admin_bar']; |
242 | 242 | $adminBar->remove_menu('WPML_ALS'); |
243 | 243 | }); |
@@ -334,7 +334,7 @@ discard block |
||
334 | 334 | |
335 | 335 | protected static function prefixFields($fields, $prefix) |
336 | 336 | { |
337 | - return array_map(function ($field) use ($prefix) { |
|
337 | + return array_map(function($field) use ($prefix) { |
|
338 | 338 | $field['name'] = $prefix . '_' . $field['name']; |
339 | 339 | return $field; |
340 | 340 | }, $fields); |
@@ -385,7 +385,7 @@ discard block |
||
385 | 385 | |
386 | 386 | protected static function combineArrayDefaults(array $array, array $defaults) |
387 | 387 | { |
388 | - return array_map(function ($value) use ($defaults) { |
|
388 | + return array_map(function($value) use ($defaults) { |
|
389 | 389 | return is_array($value) ? array_merge($defaults, $value) : []; |
390 | 390 | }, $array); |
391 | 391 | } |
@@ -38,7 +38,7 @@ |
||
38 | 38 | return; |
39 | 39 | } |
40 | 40 | |
41 | - FileLoader::iterateDir($dir, function ($file) { |
|
41 | + FileLoader::iterateDir($dir, function($file) { |
|
42 | 42 | if ($file->getExtension() === 'json') { |
43 | 43 | $filePath = $file->getPathname(); |
44 | 44 | $config = json_decode(file_get_contents($filePath), true); |