@@ -6,11 +6,11 @@ discard block |
||
6 | 6 | use Flynt\ComponentManager; |
7 | 7 | use Flynt\Utils\Asset; |
8 | 8 | |
9 | -add_filter('Flynt/addComponentData?name=ListComponents', function ($data) { |
|
9 | +add_filter('Flynt/addComponentData?name=ListComponents', function($data) { |
|
10 | 10 | if (!empty($data['componentBlocks'])) { |
11 | - $data['componentBlocks'] = array_map(function ($block) { |
|
11 | + $data['componentBlocks'] = array_map(function($block) { |
|
12 | 12 | $componentPaths = explode('/', $block['component']); |
13 | - $block['component'] = implode('/', array_slice($componentPaths, count($componentPaths)-3, 3)); |
|
13 | + $block['component'] = implode('/', array_slice($componentPaths, count($componentPaths) - 3, 3)); |
|
14 | 14 | |
15 | 15 | if (file_exists(Asset::requirePath($block['component'] . 'preview-desktop.jpg'))) { |
16 | 16 | $src = Asset::requireUrl($block['component'] . 'preview-desktop.jpg'); |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | ]; |
23 | 23 | } |
24 | 24 | |
25 | - if (file_exists(Asset::requirePath($block['component']."preview-mobile.jpg"))) { |
|
25 | + if (file_exists(Asset::requirePath($block['component'] . "preview-mobile.jpg"))) { |
|
26 | 26 | $src = Asset::requireUrl($block['component'] . 'preview-mobile.jpg'); |
27 | 27 | list($width, $height) = getimagesize(Asset::requirePath($block['component'] . 'preview-mobile.jpg')); |
28 | 28 | |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | }); |
46 | 46 | |
47 | 47 | |
48 | -add_filter('acf/load_field/name=component', function ($field) { |
|
48 | +add_filter('acf/load_field/name=component', function($field) { |
|
49 | 49 | $componentManager = ComponentManager::getInstance(); |
50 | 50 | $field['choices'] = array_flip($componentManager->getAll()); |
51 | 51 | return $field; |
@@ -5,7 +5,7 @@ discard block |
||
5 | 5 | |
6 | 6 | define(__NAMESPACE__ . '\NS', __NAMESPACE__ . '\\'); |
7 | 7 | |
8 | -add_action('wp_enqueue_scripts', function () { |
|
8 | +add_action('wp_enqueue_scripts', function() { |
|
9 | 9 | if (is_user_logged_in()) { |
10 | 10 | Asset::register([ |
11 | 11 | 'type' => 'script', |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | wp_localize_script('Flynt/assets/auth', 'wpData', $data); |
21 | 21 | }); |
22 | 22 | |
23 | -add_action('admin_enqueue_scripts', function () { |
|
23 | +add_action('admin_enqueue_scripts', function() { |
|
24 | 24 | $data = [ |
25 | 25 | 'templateDirectoryUri' => get_template_directory_uri() . '/dist', |
26 | 26 | ]; |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | if (is_user_logged_in() || is_admin()) { |
32 | 32 | if (is_admin()) { |
33 | 33 | // add image to the flexible content component name |
34 | - add_filter('acf/fields/flexible_content/layout_title', function ($title, $field, $layout, $i) { |
|
34 | + add_filter('acf/fields/flexible_content/layout_title', function($title, $field, $layout, $i) { |
|
35 | 35 | $componentName = ucfirst($layout['name']); |
36 | 36 | $componentPath = "Components/{$componentName}"; |
37 | 37 | $componentPreviewDesktopPath = Asset::requirePath("{$componentPath}/preview-desktop.jpg"); |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | }, 11, 4); |
48 | 48 | } else { |
49 | 49 | // adds Component Previews button to admin bar on front-end when logged in |
50 | - add_action('admin_bar_menu', function ($wpAdminBar) { |
|
50 | + add_action('admin_bar_menu', function($wpAdminBar) { |
|
51 | 51 | $title = __('Component Previews', 'flynt-starter-theme'); |
52 | 52 | $wpAdminBar->add_node([ |
53 | 53 | 'id' => 'toggleComponentPreviews', |
@@ -5,7 +5,7 @@ |
||
5 | 5 | use Flynt; |
6 | 6 | use Timber\Timber; |
7 | 7 | |
8 | -add_filter('Flynt/addComponentData?name=GridPostsSlider', function ($data) { |
|
8 | +add_filter('Flynt/addComponentData?name=GridPostsSlider', function($data) { |
|
9 | 9 | $posts = Timber::get_posts([ |
10 | 10 | 'post_type' => 'post', |
11 | 11 | 'posts_per_page' => -1, |
@@ -2,7 +2,7 @@ discard block |
||
2 | 2 | |
3 | 3 | use Flynt\Utils\Asset; |
4 | 4 | |
5 | -add_action('wp_enqueue_scripts', function () { |
|
5 | +add_action('wp_enqueue_scripts', function() { |
|
6 | 6 | Asset::register([ |
7 | 7 | 'name' => 'vendor', |
8 | 8 | 'type' => 'script', |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | } |
65 | 65 | }); |
66 | 66 | |
67 | -add_action('admin_enqueue_scripts', function () { |
|
67 | +add_action('admin_enqueue_scripts', function() { |
|
68 | 68 | Asset::register([ |
69 | 69 | 'name' => 'vendorAdmin', |
70 | 70 | 'type' => 'script', |
@@ -32,6 +32,9 @@ |
||
32 | 32 | return $output; |
33 | 33 | } |
34 | 34 | |
35 | + /** |
|
36 | + * @param string $componentName |
|
37 | + */ |
|
35 | 38 | public function renderComponent(Twig_Environment $env, $context, $componentName, $data = [], $withContext = true, $ignoreMissing = false, $sandboxed = false) |
36 | 39 | { |
37 | 40 | $data = $data === false ? [] : $data; |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | acf_add_local_field_group($fieldGroup); |
88 | 88 | } |
89 | 89 | |
90 | - add_action('current_screen', function ($currentScreen) { |
|
90 | + add_action('current_screen', function($currentScreen) { |
|
91 | 91 | foreach (static::OPTION_TYPES as $optionType => $option) { |
92 | 92 | $isTranslatable = $option['translatable']; |
93 | 93 | $toplevelPageId = 'toplevel_page_' . $optionType; |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | add_filter('acf/settings/current_language', 'Flynt\Utils\Options::getDefaultAcfLanguage', 101); |
102 | 102 | |
103 | 103 | // hide language selector in admin bar |
104 | - add_action('wp_before_admin_bar_render', function () { |
|
104 | + add_action('wp_before_admin_bar_render', function() { |
|
105 | 105 | $adminBar = $GLOBALS['wp_admin_bar']; |
106 | 106 | $adminBar->remove_menu('WPML_ALS'); |
107 | 107 | }); |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | $optionNames = (((static::$registeredOptions[$optionType] ?? [])[lcfirst($optionCategory)] ?? [])[$subPageName] ?? []); |
152 | 152 | return array_combine( |
153 | 153 | $optionNames, |
154 | - array_map(function ($optionName) use ($prefix, $isTranslatable) { |
|
154 | + array_map(function($optionName) use ($prefix, $isTranslatable) { |
|
155 | 155 | $fieldKey = $prefix . $optionName; |
156 | 156 | return static::getOptionField($fieldKey, $isTranslatable); |
157 | 157 | }, $optionNames) |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | |
236 | 236 | protected static function prefixFields($fields, $prefix) |
237 | 237 | { |
238 | - return array_map(function ($field) use ($prefix) { |
|
238 | + return array_map(function($field) use ($prefix) { |
|
239 | 239 | $field['name'] = $prefix . '_' . $field['name']; |
240 | 240 | return $field; |
241 | 241 | }, $fields); |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | |
7 | 7 | define(__NAMESPACE__ . '\NS', __NAMESPACE__ . '\\'); |
8 | 8 | |
9 | -add_action('Flynt/afterRegisterComponents', function () { |
|
9 | +add_action('Flynt/afterRegisterComponents', function() { |
|
10 | 10 | if ((WP_ENV === 'development' || current_user_can('editor') || current_user_can('administrator')) && isset($_GET['log'])) { |
11 | 11 | if (isset($_GET['component']) && !empty($_GET['component'])) { |
12 | 12 | define(__NAMESPACE__ . '\COMPONENT_WHITELIST', explode(',', $_GET['component'])); |
@@ -32,21 +32,21 @@ discard block |
||
32 | 32 | { |
33 | 33 | $type = gettype($data); |
34 | 34 | $output = json_encode($data); |
35 | - $result = "<script>console.log({$output});</script>\n"; |
|
35 | + $result = "<script>console.log({$output});</script>\n"; |
|
36 | 36 | echoDebug($result, $postpone); |
37 | 37 | } |
38 | 38 | |
39 | 39 | function consoleTable($data, $postpone = true) |
40 | 40 | { |
41 | 41 | $output = json_encode($data); |
42 | - $result = "<script>console.table({$output});</script>\n"; |
|
42 | + $result = "<script>console.table({$output});</script>\n"; |
|
43 | 43 | echoDebug($result, $postpone); |
44 | 44 | } |
45 | 45 | |
46 | 46 | function echoDebug($data, $postpone) |
47 | 47 | { |
48 | 48 | if ($postpone) { |
49 | - add_action('wp_footer', function () use ($data) { |
|
49 | + add_action('wp_footer', function() use ($data) { |
|
50 | 50 | echo $data; |
51 | 51 | }, 30); |
52 | 52 | } else { |
@@ -6,7 +6,7 @@ |
||
6 | 6 | use Flynt\Utils\Options; |
7 | 7 | use Timber\Timber; |
8 | 8 | |
9 | -add_filter('Flynt/addComponentData?name=ListSearchResults', function ($data) { |
|
9 | +add_filter('Flynt/addComponentData?name=ListSearchResults', function($data) { |
|
10 | 10 | $data['prevIcon'] = Asset::getContents('Components/ListSearchResults/Assets/navigation-prev.svg'); |
11 | 11 | $data['nextIcon'] = Asset::getContents('Components/ListSearchResults/Assets/navigation-next.svg'); |
12 | 12 | $data['searchIcon'] = Asset::getContents('Components/ListSearchResults/Assets/search.svg'); |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | |
23 | 23 | // Convert ACF Field of type relationship to a Timber\Post and add all ACF Fields of that Post |
24 | 24 | add_filter('acf/format_value/type=relationship', NS . 'formatPostObject', 100); |
25 | -add_filter('get_twig', function ($twig) { |
|
25 | +add_filter('get_twig', function($twig) { |
|
26 | 26 | $twig->addExtension(new TwigExtensionFlynt()); |
27 | 27 | return $twig; |
28 | 28 | }); |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | function formatGallery($value) |
39 | 39 | { |
40 | 40 | if (!empty($value)) { |
41 | - $value = array_map(function ($image) { |
|
41 | + $value = array_map(function($image) { |
|
42 | 42 | return new Image($image); |
43 | 43 | }, $value); |
44 | 44 | } |
@@ -63,8 +63,8 @@ discard block |
||
63 | 63 | return $value; |
64 | 64 | } |
65 | 65 | |
66 | -add_action('timber/twig/filters', function ($twig) { |
|
67 | - $twig->addFunction(new \Twig_SimpleFunction('placeholderImage', function ($width, $height, $color = null) { |
|
66 | +add_action('timber/twig/filters', function($twig) { |
|
67 | + $twig->addFunction(new \Twig_SimpleFunction('placeholderImage', function($width, $height, $color = null) { |
|
68 | 68 | $width = round($width); |
69 | 69 | $height = round($height); |
70 | 70 | $colorRect = $color ? "<rect width='{$width}' height='{$height}' style='fill:$color' />" : ''; |