Issues (76)

Components/GridPostsLatest/functions.php (2 issues)

Labels
Severity
1
<?php
2
3
namespace Flynt\Components\GridPostsLatest;
4
5
use Flynt\FieldVariables;
0 ignored issues
show
The type Flynt\FieldVariables was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
6
use Flynt\Utils\Options;
7
use Timber\Timber;
8
9
const POST_TYPE = 'post';
10
11
add_filter('Flynt/addComponentData?name=GridPostsLatest', function ($data) {
12
    $postType = POST_TYPE;
13
14
    $data['taxonomies'] = $data['taxonomies'] ?: [];
15
16
    $data['items'] = Timber::get_posts([
17
        'post_status' => 'publish',
18
        'post_type' => $postType,
19
        'category' => join(',', array_map(function ($taxonomy) {
20
            return $taxonomy->term_id;
21
        }, $data['taxonomies'])),
22
        'posts_per_page' => $data['options']['columns'],
23
        'ignore_sticky_posts' => 1,
24
        'post__not_in' => array(get_the_ID())
25
    ]);
26
27
    $data['postTypeArchiveLink'] = get_post_type_archive_link($postType);
28
29
    return $data;
30
});
31
32
function getACFLayout()
33
{
34
    return [
35
        'name' => 'GridPostsLatest',
36
        'label' => 'Grid: Posts Latest',
37
        'sub_fields' => [
38
            [
39
                'label' => __('General', 'flynt'),
40
                'name' => 'generalTab',
41
                'type' => 'tab',
42
                'placement' => 'top',
43
                'endpoint' => 0
44
            ],
45
            [
46
                'label' => __('Title', 'flynt'),
47
                'name' => 'preContentHtml',
48
                'type' => 'wysiwyg',
49
                'tabs' => 'visual,text',
50
                'media_upload' => 0,
51
                'delay' => 1,
52
                'instructions' => __('Want to add a headline? And a paragraph? Go ahead! Or just leave it empty and nothing will be shown.', 'flynt'),
53
            ],
54
            [
55
                'label' => __('Categories', 'flynt'),
56
                'name' => 'taxonomies',
57
                'type' => 'taxonomy',
58
                'instructions' => __('Select 1 or more categories or leave empty to show from all posts.', 'flynt'),
59
                'taxonomy' => 'category',
60
                'field_type' => 'multi_select',
61
                'allow_null' => 1,
62
                'multiple' => 1,
63
                'add_term' => 0,
64
                'save_terms' => 0,
65
                'load_terms' => 0,
66
                'return_format' => 'object'
67
            ],
68
            [
69
                'label' => __('Options', 'flynt'),
70
                'name' => 'optionsTab',
71
                'type' => 'tab',
72
                'placement' => 'top',
73
                'endpoint' => 0
74
            ],
75
            [
76
                'label' => '',
77
                'name' => 'options',
78
                'type' => 'group',
79
                'layout' => 'row',
80
                'sub_fields' => [
81
                    FieldVariables\getTheme(),
0 ignored issues
show
The function getTheme was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

81
                    /** @scrutinizer ignore-call */ 
82
                    FieldVariables\getTheme(),
Loading history...
82
                    [
83
                        'label' => __('Columns', 'flynt'),
84
                        'name' => 'columns',
85
                        'type' => 'number',
86
                        'default_value' => 3,
87
                        'min' => 1,
88
                        'max' => 4,
89
                        'step' => 1
90
                    ]
91
                ]
92
            ],
93
        ]
94
    ];
95
}
96
97
Options::addTranslatable('GridPostsLatest', [
98
    [
99
        'label' => __('Labels', 'flynt'),
100
        'name' => 'labelsTab',
101
        'type' => 'tab',
102
        'placement' => 'top',
103
        'endpoint' => 0
104
    ],
105
    [
106
        'label' => '',
107
        'name' => 'labels',
108
        'type' => 'group',
109
        'sub_fields' => [
110
            [
111
                'label' => __('Reading Time', 'flynt'),
112
                'name' => 'readingTime',
113
                'type' => 'text',
114
                'default_value' => 'min',
115
                'required' => 1,
116
                'wrapper' => [
117
                    'width' => 50
118
                ],
119
            ],
120
            [
121
                'label' => __('All Posts', 'flynt'),
122
                'name' => 'allPosts',
123
                'type' => 'text',
124
                'default_value' => 'See More Posts',
125
                'required' => 1,
126
                'wrapper' => [
127
                    'width' => 50
128
                ],
129
            ],
130
            [
131
                'label' => __('Read More', 'flynt'),
132
                'name' => 'readMore',
133
                'type' => 'text',
134
                'default_value' => 'Read More',
135
                'required' => 1,
136
                'wrapper' => [
137
                    'width' => 50
138
                ],
139
            ]
140
        ],
141
    ]
142
]);
143