• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

equalizedigital / accessibility-checker / 17297832630

28 Aug 2025 01:47PM UTC coverage: 59.256% (-1.6%) from 60.808%
17297832630

push

github

web-flow
Merge pull request #1171 from equalizedigital/william/pro-169-filter-post-types-at-save-time

Add initial support for handling of virtual posts

47 of 252 new or added lines in 13 files covered. (18.65%)

2 existing lines in 1 file now uncovered.

4123 of 6958 relevant lines covered (59.26%)

3.52 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

89.66
/admin/class-settings.php
1
<?php
2
/**
3
 * Class file for scan settings
4
 *
5
 * @package Accessibility_Checker
6
 */
7

8
namespace EDAC\Admin;
9

10
/**
11
 * Class that handles plugin settings
12
 */
13
class Settings {
14

15
        /**
16
         * Gets a list of post statuses that are scannable.
17
         *
18
         * @var array
19
         */
20
        public static function get_scannable_post_statuses() {
21
                /**
22
                 * Filters the list of post statuses that are scannable.
23
                 *
24
                 * @since 1.29.0
25
                 *
26
                 * @param array $scannable_post_statuses List of scannable post statuses.
27
                 */
28
                return apply_filters(
10✔
29
                        'edac_scannable_post_statuses',
10✔
30
                        [ 'publish', 'future', 'draft', 'pending', 'private' ]
10✔
31
                );
10✔
32
        }
33

34

35
        /**
36
         * Gets a list of post types that are scannable.
37
         *
38
         * @param bool $skip_filtering Whether to skip filtering when passing through alternative settings class.
39
         *
40
         * @return array
41
         */
42
        public static function get_scannable_post_types( $skip_filtering = false ) {
43

44
                if (
45
                        class_exists( 'EqualizeDigital\AccessibilityCheckerPro\Admin\Settings' ) &&
50✔
46
                        method_exists( 'EqualizeDigital\AccessibilityCheckerPro\Admin\Settings', 'get_scannable_post_types' )
50✔
47
                ) {
NEW
48
                        return \EqualizeDigital\AccessibilityCheckerPro\Admin\Settings::get_scannable_post_types( $skip_filtering );
×
49
                }
50

51
                $post_types = Helpers::get_option_as_array( 'edac_post_types' );
50✔
52

53
                // remove duplicates.
54
                $post_types = array_unique( $post_types );
50✔
55

56
                // validate post types.
57
                $args             = [
50✔
58
                        'public'   => true,
50✔
59
                        '_builtin' => true,
50✔
60
                ];
50✔
61
                $valid_post_types = get_post_types( $args, 'names', 'and' );
50✔
62
                unset( $valid_post_types['attachment'] );
50✔
63

64
                foreach ( $post_types as $key => $post_type ) {
50✔
65

66
                        if ( ! post_type_exists( $post_type ) || ! array_key_exists( $post_type, $valid_post_types ) ) {
48✔
NEW
67
                                unset( $post_types[ $key ] );
×
68
                        }
69
                }
70
                return $post_types;
50✔
71
        }
72

73

74
        /**
75
         * Gets a count of posts that are scannable.
76
         *
77
         * @return integer
78
         */
79
        public static function get_scannable_posts_count() {
80

81
                global $wpdb;
10✔
82

83
                $post_types = self::get_scannable_post_types();
10✔
84

85
                $post_statuses = self::get_scannable_post_statuses();
10✔
86

87
                if ( ! empty( $post_types ) && ! empty( $post_statuses ) ) {
10✔
88
                        $sql = "SELECT COUNT(id) FROM {$wpdb->posts}  WHERE post_type IN(" .
10✔
89
                                Helpers::array_to_sql_safe_list( $post_types ) . ') and post_status IN(' .
10✔
90
                                Helpers::array_to_sql_safe_list( $post_statuses ) .
10✔
91
                        ')';
10✔
92

93
                        // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
94
                        return $wpdb->get_var( $sql );
10✔
95
                }
96
                return 0;
×
97
        }
98
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc