1 | <?php |
||
2 | |||
3 | namespace Flynt\Components\FeatureAdminComponentScreenshots; |
||
4 | |||
5 | use Flynt\ComponentManager; |
||
6 | use Flynt\Utils\Asset; |
||
7 | |||
8 | add_action('admin_enqueue_scripts', function () { |
||
9 | $componentManager = ComponentManager::getInstance(); |
||
10 | $templateDirectory = get_template_directory(); |
||
11 | $data = [ |
||
12 | 'templateDirectoryUri' => get_template_directory_uri(), |
||
13 | 'components' => array_map(function ($componentPath) use ($templateDirectory) { |
||
14 | return str_replace($templateDirectory, '', $componentPath); |
||
15 | }, $componentManager->getAll()), |
||
16 | ]; |
||
17 | wp_localize_script('Flynt/assets/admin', 'FlyntComponentScreenshots', $data); |
||
18 | }); |
||
19 | |||
20 | if (class_exists('acf')) { |
||
21 | if (is_admin()) { |
||
22 | // add image to the flexible content component name |
||
23 | add_filter('acf/fields/flexible_content/layout_title', function ($title, $field, $layout, $i) { |
||
0 ignored issues
–
show
|
|||
24 | $componentManager = ComponentManager::getInstance(); |
||
25 | $componentName = ucfirst($layout['name']); |
||
26 | $componentPathFull = $componentManager->getComponentDirPath($componentName); |
||
27 | $componentPath = str_replace(get_template_directory(), '', $componentPathFull); |
||
28 | $templateDirectoryUri = get_template_directory_uri(); |
||
29 | $componentScreenshotPath = "{$componentPathFull}/screenshot.png"; |
||
30 | $componentScreenshotUrl = "{$templateDirectoryUri}/{$componentPath}/screenshot.png"; |
||
31 | if (is_file($componentScreenshotPath)) { |
||
32 | $newTitle = '<span class="flyntComponentScreenshot">'; |
||
33 | $newTitle .= '<img class="flyntComponentScreenshot-imageElement" src="' . $componentScreenshotUrl . '" height="36px">'; |
||
34 | $newTitle .= '<span class="flyntComponentScreenshot-label">' . $title . '</span>'; |
||
35 | $newTitle .= '</span>'; |
||
36 | $title = $newTitle; |
||
37 | } |
||
38 | return $title; |
||
39 | }, 11, 4); |
||
40 | } |
||
41 | } |
||
42 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.