@@ -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 | } |
@@ -117,6 +117,13 @@ discard block |
||
117 | 117 | // usage: OptionPages::getOption('globalOptions', 'feature', 'myFeatureName', 'myFieldName'); |
118 | 118 | // usage: OptionPages::getOption('translatableOptions', 'component', 'myComponentName', 'myFieldName'); |
119 | 119 | // all params expected to be camelCase |
120 | + |
|
121 | + /** |
|
122 | + * @param string $optionType |
|
123 | + * @param string $optionCategory |
|
124 | + * @param string $subPageName |
|
125 | + * @param string $fieldName |
|
126 | + */ |
|
120 | 127 | public static function getOption($optionType, $optionCategory, $subPageName, $fieldName) |
121 | 128 | { |
122 | 129 | $options = self::getOptions($optionType, $optionCategory, $subPageName); |
@@ -272,6 +279,9 @@ discard block |
||
272 | 279 | }); |
273 | 280 | } |
274 | 281 | |
282 | + /** |
|
283 | + * @param string $optionCategoryName |
|
284 | + */ |
|
275 | 285 | protected static function createSubPageFromConfig($filePath, $optionCategoryName, $subPageName) |
276 | 286 | { |
277 | 287 | $fields = json_decode(file_get_contents($filePath), true); |
@@ -288,6 +298,9 @@ discard block |
||
288 | 298 | } |
289 | 299 | } |
290 | 300 | |
301 | + /** |
|
302 | + * @param string $subPageName |
|
303 | + */ |
|
291 | 304 | protected static function addOptionSubPage($optionCategoryName, $subPageName, $optionType, $fields) |
292 | 305 | { |
293 | 306 | $prettySubPageName = StringHelpers::splitCamelCase($subPageName); |
@@ -316,6 +329,9 @@ discard block |
||
316 | 329 | ); |
317 | 330 | } |
318 | 331 | |
332 | + /** |
|
333 | + * @param string $menuSlug |
|
334 | + */ |
|
319 | 335 | protected static function addFieldGroupToSubPage($parentMenuSlug, $menuSlug, $prettySubPageName, $fields) |
320 | 336 | { |
321 | 337 | $fieldGroup = ACFComposer\ResolveConfig::forFieldGroup( |
@@ -339,6 +355,10 @@ discard block |
||
339 | 355 | acf_add_local_field_group($fieldGroup); |
340 | 356 | } |
341 | 357 | |
358 | + /** |
|
359 | + * @param string $optionCategory |
|
360 | + * @param string $feature |
|
361 | + */ |
|
342 | 362 | protected static function checkFeature($optionCategory, $feature) |
343 | 363 | { |
344 | 364 | if (array_key_exists($optionCategory, self::$optionCategories) && !Feature::isRegistered($feature)) { |
@@ -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 |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | |
103 | 103 | // find and replace relevant keys, then return an array of all options for this Sub-Page |
104 | 104 | $optionKeys = is_array($options) ? array_keys($options) : []; |
105 | - return array_reduce($optionKeys, function ($carry, $key) use ($options, $prefix) { |
|
105 | + return array_reduce($optionKeys, function($carry, $key) use ($options, $prefix) { |
|
106 | 106 | $count = 0; |
107 | 107 | $option = $options[$key]; |
108 | 108 | $key = str_replace($prefix, '', $key, $count); |
@@ -135,10 +135,10 @@ discard block |
||
135 | 135 | 12 |
136 | 136 | ); |
137 | 137 | |
138 | - add_filter('Flynt/addComponentData', function ($data, $parentData, $config) { |
|
138 | + add_filter('Flynt/addComponentData', function($data, $parentData, $config) { |
|
139 | 139 | |
140 | 140 | // get fields for this component |
141 | - $options = array_reduce(array_keys(self::$optionTypes), function ($carry, $optionType) use ($config) { |
|
141 | + $options = array_reduce(array_keys(self::$optionTypes), function($carry, $optionType) use ($config) { |
|
142 | 142 | return array_merge($carry, self::getOptions($optionType, 'Component', $config['name'])); |
143 | 143 | }, []); |
144 | 144 | |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | ]; |
250 | 250 | } |
251 | 251 | |
252 | - add_action('current_screen', function ($currentScreen) { |
|
252 | + add_action('current_screen', function($currentScreen) { |
|
253 | 253 | foreach (self::$optionTypes as $optionType => $option) { |
254 | 254 | $isTranslatable = $option['translatable']; |
255 | 255 | $toplevelPageId = 'toplevel_page_' . $optionType; |
@@ -263,7 +263,7 @@ discard block |
||
263 | 263 | add_filter('acf/settings/current_language', 'Flynt\Features\Acf\OptionPages::getDefaultAcfLanguage', 101); |
264 | 264 | |
265 | 265 | // hide language selector in admin bar |
266 | - add_action('wp_before_admin_bar_render', function () { |
|
266 | + add_action('wp_before_admin_bar_render', function() { |
|
267 | 267 | $adminBar = $GLOBALS['wp_admin_bar']; |
268 | 268 | $adminBar->remove_menu('WPML_ALS'); |
269 | 269 | }); |
@@ -359,7 +359,7 @@ discard block |
||
359 | 359 | |
360 | 360 | protected static function prefixFields($fields, $prefix) |
361 | 361 | { |
362 | - return array_map(function ($field) use ($prefix) { |
|
362 | + return array_map(function($field) use ($prefix) { |
|
363 | 363 | $field['name'] = $prefix . '_' . $field['name']; |
364 | 364 | return $field; |
365 | 365 | }, $fields); |
@@ -410,7 +410,7 @@ discard block |
||
410 | 410 | |
411 | 411 | protected static function combineArrayDefaults(array $array, array $defaults) |
412 | 412 | { |
413 | - return array_map(function ($value) use ($defaults) { |
|
413 | + return array_map(function($value) use ($defaults) { |
|
414 | 414 | return is_array($value) ? array_merge($defaults, $value) : []; |
415 | 415 | }, $array); |
416 | 416 | } |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | add_action('admin_enqueue_scripts', NS . 'enqueueComponentScripts'); |
40 | 40 | |
41 | 41 | // add image to the flexible content component name |
42 | - add_filter('acf/fields/flexible_content/layout_title', function ($title, $field, $layout, $i) { |
|
42 | + add_filter('acf/fields/flexible_content/layout_title', function($title, $field, $layout, $i) { |
|
43 | 43 | $componentPath = "/Components/$layout[name]/"; |
44 | 44 | $componentPreviewDesktopPath = get_template_directory() . $componentPath . 'preview-desktop.jpg'; |
45 | 45 | $componentPreviewDesktopUrl = get_template_directory_uri() . $componentPath . 'preview-desktop.jpg'; |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | } else { |
57 | 57 | add_action('wp_enqueue_scripts', NS . 'enqueueComponentScripts'); |
58 | 58 | // adds Component Previews button to admin bar on front-end when logged in |
59 | - add_action('admin_bar_menu', function ($wpAdminBar) { |
|
59 | + add_action('admin_bar_menu', function($wpAdminBar) { |
|
60 | 60 | $title = __('Component Previews', 'flynt-starter-theme'); |
61 | 61 | $wpAdminBar->add_menu([ |
62 | 62 | 'id' => 'toggleComponentPreviews', |
@@ -36,13 +36,16 @@ |
||
36 | 36 | console.log('GoogleAnalytics: ' + [].slice.call(arguments)); |
37 | 37 | } |
38 | 38 | <?php |
39 | - else : ?> |
|
39 | + else { |
|
40 | + : ?> |
|
40 | 41 | (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ |
41 | 42 | (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), |
42 | 43 | m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) |
43 | 44 | })(window,document,'script','https://www.google-analytics.com/analytics.js','ga'); |
44 | 45 | <?php |
45 | - endif; ?> |
|
46 | + endif; |
|
47 | + } |
|
48 | + ?> |
|
46 | 49 | ga('create','<?php echo $this->gaId; ?>','auto');ga('send','pageview'); |
47 | 50 | <?php if ($this->anonymizeIp == 1) : ?> |
48 | 51 | ga('set', 'anonymizeIp', true); |
@@ -10,7 +10,7 @@ |
||
10 | 10 | * TODO add local fallback |
11 | 11 | * TODO add cdn again just removed it because internet so slow |
12 | 12 | */ |
13 | -add_action('wp_enqueue_scripts', function () { |
|
13 | +add_action('wp_enqueue_scripts', function() { |
|
14 | 14 | $jqueryVersion = wp_scripts()->registered['jquery']->ver; |
15 | 15 | wp_deregister_script('jquery'); |
16 | 16 | wp_register_script( |
@@ -5,7 +5,7 @@ discard block |
||
5 | 5 | // Clean Up TinyMCE Buttons |
6 | 6 | |
7 | 7 | // First Bar |
8 | -add_filter('mce_buttons', function ($buttons) { |
|
8 | +add_filter('mce_buttons', function($buttons) { |
|
9 | 9 | return [ |
10 | 10 | 'formatselect', |
11 | 11 | // 'styleselect', |
@@ -46,11 +46,11 @@ discard block |
||
46 | 46 | }); |
47 | 47 | |
48 | 48 | // Second Bar |
49 | -add_filter('mce_buttons_2', function ($buttons) { |
|
49 | +add_filter('mce_buttons_2', function($buttons) { |
|
50 | 50 | return []; |
51 | 51 | }); |
52 | 52 | |
53 | -add_filter('tiny_mce_before_init', function ($init) { |
|
53 | +add_filter('tiny_mce_before_init', function($init) { |
|
54 | 54 | // Add block format elements you want to show in dropdown |
55 | 55 | $init['block_formats'] = 'Paragraph=p;Heading 1=h1;Heading 2=h2;Heading 3=h3;Heading 4=h4;Heading 5=h5;Heading 6=h6'; |
56 | 56 | return $init; |
@@ -6,7 +6,7 @@ |
||
6 | 6 | { |
7 | 7 | public static function init() |
8 | 8 | { |
9 | - add_filter('acf/fields/google_map/api', function ($api) { |
|
9 | + add_filter('acf/fields/google_map/api', function($api) { |
|
10 | 10 | $apiKey = OptionPages::getOption('globalOptions', 'feature', 'Acf', 'googleMapsApiKey'); |
11 | 11 | if ($apiKey) { |
12 | 12 | $api['key'] = $apiKey; |
@@ -9,7 +9,7 @@ |
||
9 | 9 | use Flynt\Features\CustomPostTypes\CustomPostTypeRegister; |
10 | 10 | |
11 | 11 | // NOTE: this needs to happen on init to allow taxonomies to register |
12 | -add_action('init', function () { |
|
12 | +add_action('init', function() { |
|
13 | 13 | $featureOptions = Feature::getOption('flynt-custom-post-types', 0); |
14 | 14 | $dir = isset($featureOptions['dir']) ? $featureOptions['dir'] : null; |
15 | 15 | $fileName = isset($featureOptions['fileName']) ? $featureOptions['fileName'] : null; |
@@ -12,9 +12,9 @@ discard block |
||
12 | 12 | // register all components |
13 | 13 | $componentPath = trailingslashit(Feature::getOption('flynt-components', 0)); |
14 | 14 | |
15 | -add_action('Flynt/afterRegisterFeatures', function () use ($componentPath) { |
|
15 | +add_action('Flynt/afterRegisterFeatures', function() use ($componentPath) { |
|
16 | 16 | if (is_dir($componentPath)) { |
17 | - FileLoader::iterateDir($componentPath, function ($dir) { |
|
17 | + FileLoader::iterateDir($componentPath, function($dir) { |
|
18 | 18 | if ($dir->isDir()) { |
19 | 19 | Flynt\registerComponent($dir->getFilename()); |
20 | 20 | } |
@@ -23,6 +23,6 @@ discard block |
||
23 | 23 | }); |
24 | 24 | |
25 | 25 | // set Component Path |
26 | -add_filter('Flynt/componentPath', function ($defaultPath, $componentName) use ($componentPath) { |
|
26 | +add_filter('Flynt/componentPath', function($defaultPath, $componentName) use ($componentPath) { |
|
27 | 27 | return $componentPath . $componentName; |
28 | 28 | }, 10, 2); |