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

equalizedigital / accessibility-checker / 17205722517

25 Aug 2025 10:05AM UTC coverage: 60.808% (+3.6%) from 57.172%
17205722517

push

github

web-flow
Merge pull request #1206 from equalizedigital/william/no-ticket/enhance-endpoint-checks

Backport v1.30.1

11 of 22 new or added lines in 3 files covered. (50.0%)

9 existing lines in 2 files now uncovered.

4110 of 6759 relevant lines covered (60.81%)

3.53 hits per line

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

83.87
/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
         * @return array
39
         */
40
        public static function get_scannable_post_types() {
41

42
                // Check if the new settings class exists. This is added to allow for backwards compatibility
43
                // with the old settings class. The old settings class check should be removed after a few releases.
44
                $new_settings_class_exists = class_exists( 'EqualizeDigital\AccessibilityCheckerPro\Admin\Settings' );
32✔
45
                if ( ! class_exists( '\EDACP\Settings' ) && ! $new_settings_class_exists ) {
32✔
46

47
                        $post_types = Helpers::get_option_as_array( 'edac_post_types' );
32✔
48

49
                        // remove duplicates.
50
                        $post_types = array_unique( $post_types );
32✔
51

52
                        // validate post types.
53
                        $args             = [
32✔
54
                                'public'   => true,
32✔
55
                                '_builtin' => true,
32✔
56
                        ];
32✔
57
                        $valid_post_types = get_post_types( $args, 'names', 'and' );
32✔
58
                        unset( $valid_post_types['attachment'] );
32✔
59

60
                        foreach ( $post_types as $key => $post_type ) {
32✔
61

62
                                if ( ! post_type_exists( $post_type ) || ! array_key_exists( $post_type, $valid_post_types ) ) {
30✔
63
                                        unset( $post_types[ $key ] );
×
64
                                }
65
                        }
66
                        return $post_types;
32✔
67
                }
68

69
                return $new_settings_class_exists
×
70
                        ? \EqualizeDigital\AccessibilityCheckerPro\Admin\Settings::get_scannable_post_types()
×
71
                        : \EDACP\Settings::get_scannable_post_types();
×
72
        }
73

74

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

82
                global $wpdb;
10✔
83

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

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

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

94
                        // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
95
                        return $wpdb->get_var( $sql );
10✔
96
                }
UNCOV
97
                return 0;
×
98
        }
99
}
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