Issues (11)

src/Editor.php (2 issues)

Labels
Severity
1
<?php
2
3
namespace Helick\BetterExcerpt;
4
5
use Helick\Contracts\Bootable;
6
7
final class Editor implements Bootable
8
{
9
    /**
10
     * Boot the service.
11
     *
12
     * @return void
13
     */
14
    public static function boot(): void
15
    {
16
        $self = new static;
17
18
        add_filter('teeny_mce_buttons', [$self, 'buttons'], 10, 2);
0 ignored issues
show
The function add_filter 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

18
        /** @scrutinizer ignore-call */ 
19
        add_filter('teeny_mce_buttons', [$self, 'buttons'], 10, 2);
Loading history...
19
    }
20
21
    /**
22
     * Remove unused buttons from the post excerpt editor.
23
     *
24
     * @param array  $buttons
25
     * @param string $editorId
26
     *
27
     * @return array
28
     */
29
    public function buttons(array $buttons, string $editorId): array
30
    {
31
        if ($editorId !== 'excerpt') {
32
            return $buttons;
33
        }
34
35
        $buttons = array_values(array_diff($buttons, [
36
            'blockquote',
37
            'bullist',
38
            'numlist',
39
            'alignleft',
40
            'alignright',
41
            'aligncenter',
42
            'fullscreen',
43
        ]));
44
45
        /**
46
         * Control the editor buttons.
47
         *
48
         * @param array $buttons
49
         */
50
        $buttons = apply_filters('helick_better_excerpt_editor_buttons', $buttons);
0 ignored issues
show
The function apply_filters 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

50
        $buttons = /** @scrutinizer ignore-call */ apply_filters('helick_better_excerpt_editor_buttons', $buttons);
Loading history...
51
52
        return (array)$buttons;
53
    }
54
}
55