Issues (11)

src/MetaBox.php (9 issues)

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

19
        /** @scrutinizer ignore-call */ 
20
        add_action('add_meta_boxes', [$self, 'replace']);
Loading history...
20
    }
21
22
    /**
23
     * Replace the default post excerpt meta box.
24
     *
25
     * @return void
26
     */
27
    public function replace(): void
28
    {
29
        $postTypes = get_post_types_by_support('excerpt');
0 ignored issues
show
The function get_post_types_by_support 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

29
        $postTypes = /** @scrutinizer ignore-call */ get_post_types_by_support('excerpt');
Loading history...
30
31
        /**
32
         * Control the supported post types.
33
         *
34
         * @param array $postTypes
35
         */
36
        $postTypes = apply_filters('helick_better_excerpt_supported_post_types', $postTypes);
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

36
        $postTypes = /** @scrutinizer ignore-call */ apply_filters('helick_better_excerpt_supported_post_types', $postTypes);
Loading history...
37
38
        // Remove the default post excerpt meta box
39
        remove_meta_box('postexcerpt', (array)$postTypes, 'normal');
0 ignored issues
show
The function remove_meta_box 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

39
        /** @scrutinizer ignore-call */ 
40
        remove_meta_box('postexcerpt', (array)$postTypes, 'normal');
Loading history...
40
41
        // Register the new meta box
42
        add_meta_box(
0 ignored issues
show
The function add_meta_box 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

42
        /** @scrutinizer ignore-call */ 
43
        add_meta_box(
Loading history...
43
            'postexcerpt',
44
            _x('Excerpt', 'meta box heading', DOMAIN),
0 ignored issues
show
The function _x 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

44
            /** @scrutinizer ignore-call */ 
45
            _x('Excerpt', 'meta box heading', DOMAIN),
Loading history...
45
            [$this, 'render'],
46
            (array)$postTypes,
47
            'normal',
48
            'high',
49
            ['__back_compat_meta_box' => false]
50
        );
51
    }
52
53
    /**
54
     * Render the new meta box contents.
55
     *
56
     * @param WP_Post $post
57
     *
58
     * @return void
59
     */
60
    public function render(WP_Post $post): void
61
    {
62
        $settings = [
63
            'teeny'         => true,
64
            'media_buttons' => false,
65
            'textarea_rows' => 7,
66
        ];
67
68
        /**
69
         * Control the editor settings.
70
         *
71
         * @param array $settings
72
         */
73
        $settings = apply_filters('helick_better_excerpt_editor_settings', $settings);
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

73
        $settings = /** @scrutinizer ignore-call */ apply_filters('helick_better_excerpt_editor_settings', $settings);
Loading history...
74
75
        wp_editor(html_entity_decode($post->post_excerpt), 'excerpt', (array)$settings);
0 ignored issues
show
The function wp_editor 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

75
        /** @scrutinizer ignore-call */ 
76
        wp_editor(html_entity_decode($post->post_excerpt), 'excerpt', (array)$settings);
Loading history...
76
    }
77
}
78