@@ -92,6 +92,9 @@ |
||
92 | 92 | } |
93 | 93 | } |
94 | 94 | |
95 | + /** |
|
96 | + * @param string $parentFilterName |
|
97 | + */ |
|
95 | 98 | protected static function addFilterForSubFields($parentFilterName, $subFields) |
96 | 99 | { |
97 | 100 | foreach ($subFields as $subField) { |
@@ -2,7 +2,6 @@ |
||
2 | 2 | |
3 | 3 | namespace Flynt\Features\Acf; |
4 | 4 | |
5 | -use RecursiveDirectoryIterator; |
|
6 | 5 | use ACFComposer\ACFComposer; |
7 | 6 | use Flynt\Utils\ArrayHelpers; |
8 | 7 | use Flynt\Utils\FileLoader; |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | return; |
45 | 45 | } |
46 | 46 | |
47 | - FileLoader::iterateDir($dir, function ($file) { |
|
47 | + FileLoader::iterateDir($dir, function($file) { |
|
48 | 48 | if ($file->getExtension() === 'json') { |
49 | 49 | $filePath = $file->getPathname(); |
50 | 50 | $config = json_decode(file_get_contents($filePath), true); |
@@ -75,14 +75,14 @@ discard block |
||
75 | 75 | $groupKey = ucfirst($groupKey); |
76 | 76 | $filterName = self::FILTER_NAMESPACE . "/{$componentName}/Fields/{$groupKey}"; |
77 | 77 | |
78 | - add_filter($filterName, function ($config) use ($groupValue) { |
|
78 | + add_filter($filterName, function($config) use ($groupValue) { |
|
79 | 79 | return $groupValue; |
80 | 80 | }); |
81 | 81 | if (ArrayHelpers::isAssoc($groupValue) && array_key_exists('sub_fields', $groupValue)) { |
82 | 82 | $filterName .= '/SubFields'; |
83 | 83 | $subFields = $groupValue['sub_fields']; |
84 | 84 | |
85 | - add_filter($filterName, function ($subFieldsconfig) use ($subFields) { |
|
85 | + add_filter($filterName, function($subFieldsconfig) use ($subFields) { |
|
86 | 86 | return $subFields; |
87 | 87 | }); |
88 | 88 | self::addFilterForSubFields($filterName, $subFields); |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | $subFieldName = ucfirst($subField['name']); |
106 | 106 | $subFilterName = $parentFilterName . "/{$subFieldName}"; |
107 | 107 | |
108 | - add_filter($subFilterName, function ($subFieldConfig) use ($subField) { |
|
108 | + add_filter($subFilterName, function($subFieldConfig) use ($subField) { |
|
109 | 109 | return $subField; |
110 | 110 | }); |
111 | 111 | } |
@@ -11,9 +11,7 @@ |
||
11 | 11 | use ACFComposer; |
12 | 12 | use Flynt\ComponentManager; |
13 | 13 | use Flynt\Features\AdminNotices\AdminNoticeManager; |
14 | -use Flynt\Features\CustomPostTypes\CustomPostTypeRegister; |
|
15 | 14 | use Flynt\Utils\Feature; |
16 | -use Flynt\Utils\FileLoader; |
|
17 | 15 | use Flynt\Utils\StringHelpers; |
18 | 16 | |
19 | 17 | class OptionPages |
@@ -270,6 +270,9 @@ discard block |
||
270 | 270 | }); |
271 | 271 | } |
272 | 272 | |
273 | + /** |
|
274 | + * @param string $optionCategoryName |
|
275 | + */ |
|
273 | 276 | protected static function createSubPageFromConfig($filePath, $optionCategoryName, $subPageName) |
274 | 277 | { |
275 | 278 | $fields = json_decode(file_get_contents($filePath), true); |
@@ -286,6 +289,9 @@ discard block |
||
286 | 289 | } |
287 | 290 | } |
288 | 291 | |
292 | + /** |
|
293 | + * @param string $subPageName |
|
294 | + */ |
|
289 | 295 | protected static function addOptionSubPage($optionCategoryName, $subPageName, $optionType, $fields) |
290 | 296 | { |
291 | 297 | $prettySubPageName = StringHelpers::splitCamelCase($subPageName); |
@@ -314,6 +320,9 @@ discard block |
||
314 | 320 | ); |
315 | 321 | } |
316 | 322 | |
323 | + /** |
|
324 | + * @param string $menuSlug |
|
325 | + */ |
|
317 | 326 | protected static function addFieldGroupToSubPage($parentMenuSlug, $menuSlug, $prettySubPageName, $fields) |
318 | 327 | { |
319 | 328 | $fieldGroup = ACFComposer\ResolveConfig::forFieldGroup( |
@@ -337,6 +346,10 @@ discard block |
||
337 | 346 | acf_add_local_field_group($fieldGroup); |
338 | 347 | } |
339 | 348 | |
349 | + /** |
|
350 | + * @param string $optionCategory |
|
351 | + * @param string $feature |
|
352 | + */ |
|
340 | 353 | protected static function checkFeature($optionCategory, $feature) |
341 | 354 | { |
342 | 355 | if (array_key_exists($optionCategory, self::$optionCategories) && !Feature::isRegistered($feature)) { |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | |
116 | 116 | // find and replace relevant keys, then return an array of all options for this Sub-Page |
117 | 117 | $optionKeys = is_array($options) ? array_keys($options) : []; |
118 | - $options = array_reduce($optionKeys, function ($carry, $key) use ($options, $prefix) { |
|
118 | + $options = array_reduce($optionKeys, function($carry, $key) use ($options, $prefix) { |
|
119 | 119 | $count = 0; |
120 | 120 | $option = $options[$key]; |
121 | 121 | $key = str_replace($prefix, '', $key, $count); |
@@ -144,10 +144,10 @@ discard block |
||
144 | 144 | 12 |
145 | 145 | ); |
146 | 146 | |
147 | - add_filter('Flynt/addComponentData', function ($data, $parentData, $config) { |
|
147 | + add_filter('Flynt/addComponentData', function($data, $parentData, $config) { |
|
148 | 148 | |
149 | 149 | // get fields for this component |
150 | - $options = array_reduce(array_keys(self::$optionTypes), function ($carry, $optionType) use ($config) { |
|
150 | + $options = array_reduce(array_keys(self::$optionTypes), function($carry, $optionType) use ($config) { |
|
151 | 151 | return array_merge($carry, self::get($optionType, 'Component', $config['name'])); |
152 | 152 | }, []); |
153 | 153 | |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | ]; |
248 | 248 | } |
249 | 249 | |
250 | - add_action('current_screen', function ($currentScreen) { |
|
250 | + add_action('current_screen', function($currentScreen) { |
|
251 | 251 | foreach (self::$optionTypes as $optionType => $option) { |
252 | 252 | $isTranslatable = $option['translatable']; |
253 | 253 | $toplevelPageId = 'toplevel_page_' . $optionType; |
@@ -261,7 +261,7 @@ discard block |
||
261 | 261 | add_filter('acf/settings/current_language', 'Flynt\Features\Acf\OptionPages::getDefaultAcfLanguage', 101); |
262 | 262 | |
263 | 263 | // hide language selector in admin bar |
264 | - add_action('wp_before_admin_bar_render', function () { |
|
264 | + add_action('wp_before_admin_bar_render', function() { |
|
265 | 265 | $adminBar = $GLOBALS['wp_admin_bar']; |
266 | 266 | $adminBar->remove_menu('WPML_ALS'); |
267 | 267 | }); |
@@ -357,7 +357,7 @@ discard block |
||
357 | 357 | |
358 | 358 | protected static function prefixFields($fields, $prefix) |
359 | 359 | { |
360 | - return array_map(function ($field) use ($prefix) { |
|
360 | + return array_map(function($field) use ($prefix) { |
|
361 | 361 | $field['name'] = $prefix . '_' . $field['name']; |
362 | 362 | return $field; |
363 | 363 | }, $fields); |
@@ -408,7 +408,7 @@ discard block |
||
408 | 408 | |
409 | 409 | protected static function combineArrayDefaults(array $array, array $defaults) |
410 | 410 | { |
411 | - return array_map(function ($value) use ($defaults) { |
|
411 | + return array_map(function($value) use ($defaults) { |
|
412 | 412 | return is_array($value) ? array_merge($defaults, $value) : []; |
413 | 413 | }, $array); |
414 | 414 | } |
@@ -8,7 +8,7 @@ |
||
8 | 8 | use Flynt\Utils\Feature; |
9 | 9 | use Flynt\Features\CustomTaxonomies\CustomTaxonomyRegister; |
10 | 10 | |
11 | -add_action('init', function () { |
|
11 | +add_action('init', function() { |
|
12 | 12 | $featureOptions = Feature::getOption('flynt-custom-taxonomies', 0); |
13 | 13 | $dir = isset($featureOptions['dir']) ? $featureOptions['dir'] : null; |
14 | 14 | $fileName = isset($featureOptions['fileName']) ? $featureOptions['fileName'] : null; |
@@ -51,7 +51,7 @@ |
||
51 | 51 | if (is_array($value)) { |
52 | 52 | // Loop through array and apply translations while keeping keys intact |
53 | 53 | // NOTE: assuming it's a single dimensional array |
54 | - return array_reduce(array_keys($value), function ($carry, $key) use ($value) { |
|
54 | + return array_reduce(array_keys($value), function($carry, $key) use ($value) { |
|
55 | 55 | return array_merge($carry, [ |
56 | 56 | $key => _x($value[$key], $key, 'flynt-starter-theme') |
57 | 57 | ]); |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | |
59 | 59 | protected static function cleanConfig($config) |
60 | 60 | { |
61 | - $cleanConfig = array_map(function ($value) { |
|
61 | + $cleanConfig = array_map(function($value) { |
|
62 | 62 | if (is_array($value)) { |
63 | 63 | return self::cleanConfig($value); |
64 | 64 | } |
@@ -67,14 +67,14 @@ discard block |
||
67 | 67 | }, $config); |
68 | 68 | |
69 | 69 | // remove null values or empty arrays |
70 | - return array_filter($cleanConfig, function ($value) { |
|
70 | + return array_filter($cleanConfig, function($value) { |
|
71 | 71 | return !(is_null($value) || (is_array($value) && empty($value))); |
72 | 72 | }); |
73 | 73 | } |
74 | 74 | |
75 | 75 | protected static function getConfigs($dir) |
76 | 76 | { |
77 | - $configs = FileLoader::iterateDir($dir, function ($file) { |
|
77 | + $configs = FileLoader::iterateDir($dir, function($file) { |
|
78 | 78 | if ($file->isFile() && $file->getExtension() == 'json') { |
79 | 79 | $configPath = $file->getPathname(); |
80 | 80 | $name = StringHelpers::camelCaseToKebap($file->getBasename('.json')); |
@@ -9,8 +9,8 @@ |
||
9 | 9 | $context = Timber::get_context(); |
10 | 10 | $post = new Post(); |
11 | 11 | $context['form'] = [ |
12 | - 'url' => site_url('/wp-login.php?action=postpass', 'login_post'), |
|
13 | - 'inputId' => empty($post->id) ? mt_rand() : $post->id |
|
12 | + 'url' => site_url('/wp-login.php?action=postpass', 'login_post'), |
|
13 | + 'inputId' => empty($post->id) ? mt_rand() : $post->id |
|
14 | 14 | ]; |
15 | 15 | |
16 | 16 | return Timber::fetch('index.twig', $context); |
@@ -5,7 +5,7 @@ |
||
5 | 5 | use Timber\Timber; |
6 | 6 | use Timber\Post; |
7 | 7 | |
8 | -add_filter('the_password_form', function ($output) { |
|
8 | +add_filter('the_password_form', function($output) { |
|
9 | 9 | $context = Timber::get_context(); |
10 | 10 | $post = new Post(); |
11 | 11 | $context['form'] = [ |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | define(__NAMESPACE__ . '\NS', __NAMESPACE__ . '\\'); |
12 | 12 | |
13 | 13 | // Render Component with Timber (Twig) |
14 | -add_filter('Flynt/renderComponent', function ($output, $componentName, $componentData, $areaHtml) { |
|
14 | +add_filter('Flynt/renderComponent', function($output, $componentName, $componentData, $areaHtml) { |
|
15 | 15 | // get index file |
16 | 16 | $componentManager = Flynt\ComponentManager::getInstance(); |
17 | 17 | $filePath = $componentManager->getComponentFilePath($componentName, 'index.twig'); |
@@ -21,9 +21,9 @@ discard block |
||
21 | 21 | return $output; |
22 | 22 | } |
23 | 23 | |
24 | - $addArea = function ($twig) use ($areaHtml) { |
|
24 | + $addArea = function($twig) use ($areaHtml) { |
|
25 | 25 | |
26 | - $twig->addFunction(new Twig_SimpleFunction('area', function ($areaName) use ($areaHtml) { |
|
26 | + $twig->addFunction(new Twig_SimpleFunction('area', function($areaName) use ($areaHtml) { |
|
27 | 27 | if (array_key_exists($areaName, $areaHtml)) { |
28 | 28 | return $areaHtml[$areaName]; |
29 | 29 | } |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | |
35 | 35 | add_filter('get_twig', $addArea); |
36 | 36 | |
37 | - $returnTimberPaths = function ($paths) use ($filePath) { |
|
37 | + $returnTimberPaths = function($paths) use ($filePath) { |
|
38 | 38 | array_unshift($paths, dirname($filePath)); |
39 | 39 | return $paths; |
40 | 40 | }; |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | }, 10, 4); |
52 | 52 | |
53 | 53 | // Convert ACF Images to Timber Images |
54 | -add_filter('acf/format_value/type=image', function ($value) { |
|
54 | +add_filter('acf/format_value/type=image', function($value) { |
|
55 | 55 | if (!empty($value)) { |
56 | 56 | $value = new Image($value); |
57 | 57 | } |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | }, 100); |
60 | 60 | |
61 | 61 | // Convert ACF Field of type post_object to a Timber\Post and add all ACF Fields of that Post |
62 | -add_filter('acf/format_value/type=post_object', function ($value) { |
|
62 | +add_filter('acf/format_value/type=post_object', function($value) { |
|
63 | 63 | if (is_array($value)) { |
64 | 64 | $value = array_map(NS . 'convertToTimberPost', $value); |
65 | 65 | } else { |
@@ -26,7 +26,7 @@ |
||
26 | 26 | self::setupHelpers(); |
27 | 27 | |
28 | 28 | // add styles for admin area |
29 | - add_action('admin_enqueue_scripts', function () { |
|
29 | + add_action('admin_enqueue_scripts', function() { |
|
30 | 30 | Asset::enqueue([ |
31 | 31 | 'type' => 'style', |
32 | 32 | 'name' => 'Flynt/Features/Acf/AdminCss', |
@@ -14,7 +14,7 @@ |
||
14 | 14 | { |
15 | 15 | if (is_admin()) { |
16 | 16 | // adds buttons to collapse/expand components |
17 | - add_filter('acf/get_field_label', function ($label, $field) { |
|
17 | + add_filter('acf/get_field_label', function($label, $field) { |
|
18 | 18 | if ($field['type'] === 'flexible_content') { |
19 | 19 | $label .= '<span class="flexible-content-controls">'; |
20 | 20 | $label .= '<a class="acf-icon small -collapse collapse-all" title="collapse all"></a>'; |