diff --git a/admin/AdminPage/FixesPage.php b/admin/AdminPage/FixesPage.php index 208751e6c..230608f6b 100644 --- a/admin/AdminPage/FixesPage.php +++ b/admin/AdminPage/FixesPage.php @@ -50,6 +50,8 @@ public function __construct( $settings_capability ) { /** * Add the settings sections and fields and setup it's tabs and filter in for the content. + * + * @return void */ public function add_page() { @@ -116,6 +118,8 @@ public function add_slug_to_admin_notices( $slugs ) { /** * Render the page. + * + * @return void */ public function render_page() { include_once EDAC_PLUGIN_DIR . 'partials/admin-page/fixes-page.php'; @@ -125,6 +129,8 @@ public function render_page() { * Register the settings sections for this options page. * * Sections are passed through a filter so that other plugins can add their own. + * + * @return void */ public function register_settings_sections() { @@ -172,6 +178,8 @@ public function register_settings_sections() { * Register the settings fields and settings for this options page. * * It passed through a filter so that other plugins can add their own settings. + * + * @return void */ public function register_fields_and_settings() { /** @@ -215,6 +223,8 @@ public function register_fields_and_settings() { /** * Callback for the general settings section that renders a description for it. + * + * @return void */ public function fixes_section_general_cb() { echo '

' . esc_html__( 'These fixes help improve accessibility by modifying HTML elements and behaviors on your site.', 'accessibility-checker' ) . '

'; diff --git a/admin/AdminPage/FixesSettingType/Checkbox.php b/admin/AdminPage/FixesSettingType/Checkbox.php index 266330254..b81c276f2 100644 --- a/admin/AdminPage/FixesSettingType/Checkbox.php +++ b/admin/AdminPage/FixesSettingType/Checkbox.php @@ -16,6 +16,7 @@ trait Checkbox { * Render a checkbox input. * * @param array $args The arguments for the checkbox. This is expected to have a name and a description. + * @return void */ public static function checkbox( $args ) { diff --git a/admin/AdminPage/FixesSettingType/Text.php b/admin/AdminPage/FixesSettingType/Text.php index 9c877b9d9..d997ed7f1 100644 --- a/admin/AdminPage/FixesSettingType/Text.php +++ b/admin/AdminPage/FixesSettingType/Text.php @@ -16,6 +16,7 @@ trait Text { * Render a text input. * * @param array $args The arguments for the text input. This is expected to have a name and a description. + * @return void */ public static function text( $args ) { // We need a name and a description or the text field is useless. diff --git a/admin/AdminPage/PageInterface.php b/admin/AdminPage/PageInterface.php index f2408212e..079cd1f80 100644 --- a/admin/AdminPage/PageInterface.php +++ b/admin/AdminPage/PageInterface.php @@ -18,11 +18,15 @@ public function __construct( $settings_capability ); /** * Add the page to the admin menu and register any settings. + * + * @return void */ public function add_page(); /** * Render the page. + * + * @return void */ public function render_page(); } diff --git a/admin/class-activation-redirect.php b/admin/class-activation-redirect.php index 930b801ee..c1fa6ca38 100644 --- a/admin/class-activation-redirect.php +++ b/admin/class-activation-redirect.php @@ -32,6 +32,7 @@ class Activation_Redirect { * Initialize the activation redirect. * * @since 1.36.0 + * @return void */ public function init(): void { add_action( 'admin_init', [ $this, 'maybe_redirect_to_welcome' ] ); diff --git a/admin/class-admin-footer-text.php b/admin/class-admin-footer-text.php index ef5ee97ce..3d6042d77 100644 --- a/admin/class-admin-footer-text.php +++ b/admin/class-admin-footer-text.php @@ -23,6 +23,7 @@ class Admin_Footer_Text { * Initialize the admin footer text filter. * * @since 1.27.0 + * @return void */ public function init() { add_filter( 'admin_footer_text', [ $this, 'filter_footer_text' ] ); diff --git a/admin/class-enqueue-admin.php b/admin/class-enqueue-admin.php index 137374432..63cb58bae 100644 --- a/admin/class-enqueue-admin.php +++ b/admin/class-enqueue-admin.php @@ -25,6 +25,8 @@ public function __construct() { /** * Enqueue the scripts and styles. + * + * @return void */ public static function enqueue() { self::enqueue_styles(); @@ -108,7 +110,7 @@ public static function maybe_enqueue_admin_and_editor_app_scripts() { $debug = false; } - wp_enqueue_script( 'edac-editor-app', plugin_dir_url( EDAC_PLUGIN_FILE ) . 'build/editorApp.bundle.js', false, EDAC_VERSION, false ); + wp_enqueue_script( 'edac-editor-app', plugin_dir_url( EDAC_PLUGIN_FILE ) . 'build/editorApp.bundle.js', [], EDAC_VERSION, false ); wp_set_script_translations( 'edac-editor-app', 'accessibility-checker', plugin_dir_path( EDAC_PLUGIN_FILE ) . 'languages' ); // If this is the frontpage or homepage, preview URLs won't work. Use the live URL. diff --git a/admin/class-frontend-highlight.php b/admin/class-frontend-highlight.php index 3478437e1..cd06f1f85 100644 --- a/admin/class-frontend-highlight.php +++ b/admin/class-frontend-highlight.php @@ -75,6 +75,8 @@ public function get_issues( $post_id ) { /** * AJAX handler function for frontend highlighting requests. + * + * @return void */ public function ajax() { diff --git a/admin/class-helpers.php b/admin/class-helpers.php index 70b67db3e..357cfe14d 100644 --- a/admin/class-helpers.php +++ b/admin/class-helpers.php @@ -37,9 +37,9 @@ function ( $item ) { /** * Localizes the format of a number. * - * @param int $number number to format. - * @param integer $precision number of decimals. - * @return integer + * @param int|float $number number to format. + * @param integer $precision number of decimals. + * @return string|false */ public static function format_number( $number, $precision = 0 ) { @@ -62,9 +62,9 @@ public static function format_number( $number, $precision = 0 ) { /** * Localizes the format of a percentage. * - * @param init $number number to format. - * @param integer $precision number of decimals. - * @return integer + * @param int|float $number number to format. + * @param integer $precision number of decimals. + * @return string|int|float */ public static function format_percentage( $number, $precision = 2 ) { @@ -91,9 +91,9 @@ public static function format_percentage( $number, $precision = 2 ) { /** * Localizes the format of a date. * - * @param string $date date to format. - * @param boolean $include_time whether to include time in the formatted date. - * @return integer + * @param int|string $date date to format, as a Unix timestamp or date string. + * @param boolean $include_time whether to include time in the formatted date. + * @return string */ public static function format_date( $date, $include_time = false ) { @@ -191,6 +191,7 @@ public static function is_domain_loopback( $domain ) { * Filter out inactive rules from the results returned. * * @param array $results The results to filter. + * @return array */ public static function filter_results_to_only_active_rules( $results ): array { // determine which rules are active. diff --git a/admin/class-issues-query.php b/admin/class-issues-query.php index e442399c0..693baf79b 100644 --- a/admin/class-issues-query.php +++ b/admin/class-issues-query.php @@ -58,7 +58,7 @@ class Issues_Query { * * @param array $filter [post_types, rule_types, rule_slugs]. * @param integer $record_limit Max number of records we'll query. - * @param string $flags Flag used to determine how ignored issues sould be handled. + * @param int $flags Flag used to determine how ignored issues sould be handled. */ public function __construct( $filter = [], $record_limit = 100000, $flags = self::FLAG_EXCLUDE_IGNORED ) { $valid_filters = [ diff --git a/admin/class-orphaned-issues-cleanup.php b/admin/class-orphaned-issues-cleanup.php index f9abc5505..753206f4c 100644 --- a/admin/class-orphaned-issues-cleanup.php +++ b/admin/class-orphaned-issues-cleanup.php @@ -165,6 +165,7 @@ public function get_orphaned_post_ids(): array { * @since 1.29.0 * * @param int $post_id The orphaned post ID. + * @return void */ public function delete_orphaned_post( int $post_id ) { Purge_Post_Data::delete_post( $post_id ); diff --git a/admin/class-settings.php b/admin/class-settings.php index 2e5385c74..53f5da493 100644 --- a/admin/class-settings.php +++ b/admin/class-settings.php @@ -15,7 +15,7 @@ class Settings { /** * Gets a list of post statuses that are scannable. * - * @var array + * @return array */ public static function get_scannable_post_statuses() { /** diff --git a/admin/class-update-database.php b/admin/class-update-database.php index 81cadff3b..47647a278 100644 --- a/admin/class-update-database.php +++ b/admin/class-update-database.php @@ -27,6 +27,8 @@ public function __construct() { /** * Initialize WordPress hooks + * + * @return void */ public function init_hooks() { add_action( 'admin_init', [ $this, 'edac_update_database' ], 10 ); diff --git a/admin/class-widgets.php b/admin/class-widgets.php index 729845e04..9b7811418 100644 --- a/admin/class-widgets.php +++ b/admin/class-widgets.php @@ -286,7 +286,7 @@ public function render_dashboard_scan_summary() { Edit Accessibility Checker Settings '; - $meetup_html = edac_get_upcoming_meetups_html( 'wordpress-accessibility-meetup-group', 2, 4 ); + $meetup_html = edac_get_upcoming_meetups_html( 'wordpress-accessibility-meetup-group', 2, '4' ); if ( ! empty( $meetup_html ) ) { $html .= '
diff --git a/admin/opt-in/class-email-opt-in.php b/admin/opt-in/class-email-opt-in.php index 92f6661d4..00d500e64 100644 --- a/admin/opt-in/class-email-opt-in.php +++ b/admin/opt-in/class-email-opt-in.php @@ -23,6 +23,8 @@ class Email_Opt_In { /** * Checks if the current user already opted in. + * + * @return bool */ public static function user_already_subscribed(): bool { return (bool) get_user_meta( @@ -57,8 +59,8 @@ public static function should_show_modal(): bool { */ public function enqueue_scripts() { - wp_enqueue_style( 'email-opt-in-form', plugin_dir_url( EDAC_PLUGIN_FILE ) . 'build/css/emailOptIn.css', false, EDAC_VERSION, 'all' ); - wp_enqueue_script( 'email-opt-in-form', plugin_dir_url( EDAC_PLUGIN_FILE ) . 'build/emailOptIn.bundle.js', false, EDAC_VERSION, true ); + wp_enqueue_style( 'email-opt-in-form', plugin_dir_url( EDAC_PLUGIN_FILE ) . 'build/css/emailOptIn.css', [], EDAC_VERSION, 'all' ); + wp_enqueue_script( 'email-opt-in-form', plugin_dir_url( EDAC_PLUGIN_FILE ) . 'build/emailOptIn.bundle.js', [], EDAC_VERSION, true ); wp_set_script_translations( 'email-opt-in-form', 'accessibility-checker', plugins_url( 'languages', EDAC_PLUGIN_FILE ) ); wp_localize_script( diff --git a/includes/classes/Fixes/Fix/AddFileSizeAndTypeToLinkedFilesFix.php b/includes/classes/Fixes/Fix/AddFileSizeAndTypeToLinkedFilesFix.php index c22e293bc..67dcd7368 100644 --- a/includes/classes/Fixes/Fix/AddFileSizeAndTypeToLinkedFilesFix.php +++ b/includes/classes/Fixes/Fix/AddFileSizeAndTypeToLinkedFilesFix.php @@ -65,6 +65,8 @@ public static function get_type(): string { /** * Register anything needed for the fix. + * + * @return void */ public function register(): void { add_filter( @@ -97,6 +99,8 @@ public function get_fields_array( array $fields = [] ): array { /** * Run the fix. + * + * @return void */ public function run(): void { // Intentionally left empty. diff --git a/includes/classes/Fixes/Fix/AddLabelToUnlabelledFormFieldsFix.php b/includes/classes/Fixes/Fix/AddLabelToUnlabelledFormFieldsFix.php index 8cb78455a..b80dcad8e 100644 --- a/includes/classes/Fixes/Fix/AddLabelToUnlabelledFormFieldsFix.php +++ b/includes/classes/Fixes/Fix/AddLabelToUnlabelledFormFieldsFix.php @@ -114,6 +114,8 @@ public function get_fields_array( array $fields = [] ): array { /** * Run the fix for adding the comment and search form labels. + * + * @return void */ public function run(): void { diff --git a/includes/classes/Fixes/Fix/AddNewWindowWarningFix.php b/includes/classes/Fixes/Fix/AddNewWindowWarningFix.php index 59cd6aab6..459c1d164 100644 --- a/includes/classes/Fixes/Fix/AddNewWindowWarningFix.php +++ b/includes/classes/Fixes/Fix/AddNewWindowWarningFix.php @@ -89,6 +89,8 @@ public function get_fields_array( array $fields = [] ): array { /** * Run the fix for adding the comment and search form labels. + * + * @return void */ public function run(): void { if ( ! get_option( 'edac_fix_' . $this->get_slug(), false ) ) { @@ -125,6 +127,8 @@ function ( $data ) { /** * Add the styles for the new window warning. + * + * @return void */ public function add_styles() { $font_url = EDAC_PLUGIN_URL . 'assets/fonts'; diff --git a/includes/classes/Fixes/Fix/BlockPDFUploadsFix.php b/includes/classes/Fixes/Fix/BlockPDFUploadsFix.php index e1040163a..fb162840e 100644 --- a/includes/classes/Fixes/Fix/BlockPDFUploadsFix.php +++ b/includes/classes/Fixes/Fix/BlockPDFUploadsFix.php @@ -58,6 +58,8 @@ public static function get_type(): string { /** * Register setting. + * + * @return void */ public function register(): void { // Add the settings field for the fix. @@ -91,6 +93,8 @@ public function get_fields_array( array $fields = [] ): array { /** * Run the fix. + * + * @return void */ public function run() { // Intentionally empty - this run method should be implemented in an extension class. diff --git a/includes/classes/Fixes/Fix/CommentSearchLabelFix.php b/includes/classes/Fixes/Fix/CommentSearchLabelFix.php index adbf1cd3e..b3d1dbc91 100644 --- a/includes/classes/Fixes/Fix/CommentSearchLabelFix.php +++ b/includes/classes/Fixes/Fix/CommentSearchLabelFix.php @@ -116,6 +116,8 @@ public function get_fields_array( array $fields = [] ): array { /** * Run the fix for adding the comment and search form labels. + * + * @return void */ public function run(): void { diff --git a/includes/classes/Fixes/Fix/MetaViewportScalableFix.php b/includes/classes/Fixes/Fix/MetaViewportScalableFix.php index c88375f48..2bee8a30e 100644 --- a/includes/classes/Fixes/Fix/MetaViewportScalableFix.php +++ b/includes/classes/Fixes/Fix/MetaViewportScalableFix.php @@ -81,6 +81,8 @@ public function get_fields_array( array $fields = [] ): array { /** * Run the fix setting a scalable meta viewport tag. + * + * @return void */ public function run(): void { diff --git a/includes/classes/Fixes/Fix/PreventLinksOpeningNewWindowFix.php b/includes/classes/Fixes/Fix/PreventLinksOpeningNewWindowFix.php index 2cc7d8692..f750aca53 100644 --- a/includes/classes/Fixes/Fix/PreventLinksOpeningNewWindowFix.php +++ b/includes/classes/Fixes/Fix/PreventLinksOpeningNewWindowFix.php @@ -87,6 +87,8 @@ public function get_fields_array( array $fields = [] ): array { /** * Run the fix for adding the comment and search form labels. + * + * @return void */ public function run(): void { if ( ! get_option( 'edac_fix_' . $this->get_slug(), false ) ) { diff --git a/includes/classes/Fixes/Fix/SkipLinkFix.php b/includes/classes/Fixes/Fix/SkipLinkFix.php index 030ef5a57..ca16ed24d 100644 --- a/includes/classes/Fixes/Fix/SkipLinkFix.php +++ b/includes/classes/Fixes/Fix/SkipLinkFix.php @@ -120,10 +120,12 @@ public function get_fields_array( array $fields = [] ): array { /** * Run the fix for adding the skip link to the site. + * + * @return void */ public function run() { if ( ! get_option( 'edac_fix_add_skip_link', false ) ) { - return null; + return; } add_action( 'wp_body_open', [ $this, 'add_skip_link' ] ); @@ -133,6 +135,7 @@ public function run() { return; } + $targets = []; $targets_list = explode( ',', $targets_string ); foreach ( $targets_list as $target ) { diff --git a/includes/classes/Fixes/FixInterface.php b/includes/classes/Fixes/FixInterface.php index 8c0792eaa..9cd959bb2 100644 --- a/includes/classes/Fixes/FixInterface.php +++ b/includes/classes/Fixes/FixInterface.php @@ -40,6 +40,8 @@ public static function get_type(): string; * * Fixes are responsible for implementing their own 'run' method and binding it in here * if they are not just simple hooks. + * + * @return void */ public function register(): void; @@ -59,6 +61,8 @@ public function get_fields_array( array $fields = [] ): array; * Run the fix. * * This will be called in admin only, frontend only or everywhere depending on the fix type. + * + * @return void */ public function run(); } diff --git a/includes/classes/Fixes/FixesManager.php b/includes/classes/Fixes/FixesManager.php index 9edc20f89..39e1c3070 100644 --- a/includes/classes/Fixes/FixesManager.php +++ b/includes/classes/Fixes/FixesManager.php @@ -70,6 +70,8 @@ private function __construct() { * Maybe enqueue the thickbox script. * * This powers the modal that is used to display fix settings in the editor. + * + * @return void */ public function maybe_enqueue_thickbox() { add_action( @@ -94,6 +96,8 @@ public static function get_instance() { /** * Maybe enqueue the frontend scripts. + * + * @return void */ private function maybe_enqueue_frontend_scripts() { @@ -124,6 +128,8 @@ function () { /** * Load the fixes. + * + * @return void */ private function load_fixes() { $fixes = apply_filters( @@ -198,6 +204,8 @@ public function get_fixes_settings() { /** * Register the fixes. + * + * @return void */ public function register_fixes() { $this->load_fixes(); @@ -212,6 +220,7 @@ public function register_fixes() { * Maybe run a fix depending on current context. * * @param FixInterface $fix The fix to maybe run. + * @return void */ public function maybe_run_fix( $fix ) { if ( 'backend' === $fix::get_type() && is_admin() ) { @@ -244,6 +253,8 @@ public static function is_theme_accessibility_ready() { /** * Maybe show a notice if the theme is accessibility-ready. + * + * @return void */ public static function maybe_show_accessibility_ready_conflict_notice() { if ( self::is_theme_accessibility_ready() ) { diff --git a/includes/classes/MyDot/Connector.php b/includes/classes/MyDot/Connector.php index af32c5929..ec74becd9 100644 --- a/includes/classes/MyDot/Connector.php +++ b/includes/classes/MyDot/Connector.php @@ -135,6 +135,7 @@ public static function get_free_product_id(): int { * Sets up the license page and handlers. * * @since 1.xx.x + * @return void */ public function init() { $connected_services = new ConnectedServicesPage( 'manage_options' ); @@ -1190,6 +1191,8 @@ private static function safe_remote_get( string $url, array $args = [] ) { /** * Display transient-based admin notices for the current user. + * + * @return void */ public function display_admin_notices() { $key = $this->get_notice_transient_key(); diff --git a/includes/classes/class-accessibility-statement.php b/includes/classes/class-accessibility-statement.php index 9cd91a970..ffddfb67a 100644 --- a/includes/classes/class-accessibility-statement.php +++ b/includes/classes/class-accessibility-statement.php @@ -24,6 +24,8 @@ public function __construct() { /** * Initialize WordPress hooks. + * + * @return void */ public function init_hooks() { add_action( 'wp_footer', [ $this, 'output_accessibility_statement' ] ); diff --git a/includes/classes/class-enqueue-frontend.php b/includes/classes/class-enqueue-frontend.php index 64f349526..4867d4287 100644 --- a/includes/classes/class-enqueue-frontend.php +++ b/includes/classes/class-enqueue-frontend.php @@ -24,6 +24,8 @@ public function __construct() { /** * Enqueue the scripts and styles. + * + * @return void */ public static function enqueue() { self::maybe_enqueue_frontend_highlighter(); @@ -142,8 +144,8 @@ public static function maybe_enqueue_frontend_highlighter() { if ( $active ) { - wp_enqueue_style( 'edac-frontend-highlighter-app', plugin_dir_url( EDAC_PLUGIN_FILE ) . 'build/css/frontendHighlighterApp.css', false, EDAC_VERSION, 'all' ); - wp_enqueue_script( 'edac-frontend-highlighter-app', plugin_dir_url( EDAC_PLUGIN_FILE ) . 'build/frontendHighlighterApp.bundle.js', false, EDAC_VERSION, false ); + wp_enqueue_style( 'edac-frontend-highlighter-app', plugin_dir_url( EDAC_PLUGIN_FILE ) . 'build/css/frontendHighlighterApp.css', [], EDAC_VERSION, 'all' ); + wp_enqueue_script( 'edac-frontend-highlighter-app', plugin_dir_url( EDAC_PLUGIN_FILE ) . 'build/frontendHighlighterApp.bundle.js', [], EDAC_VERSION, false ); wp_localize_script( 'edac-frontend-highlighter-app', diff --git a/includes/classes/class-lazyload-filter.php b/includes/classes/class-lazyload-filter.php index 284335c8b..c9e059433 100644 --- a/includes/classes/class-lazyload-filter.php +++ b/includes/classes/class-lazyload-filter.php @@ -21,6 +21,8 @@ class Lazyload_Filter { /** * Initialize WordPress hooks. + * + * @return void */ public function init_hooks() { add_filter( 'perfmatters_lazyload', [ $this, 'perfmatters' ] ); diff --git a/includes/classes/class-rest-api.php b/includes/classes/class-rest-api.php index 3af861d19..68da32b55 100644 --- a/includes/classes/class-rest-api.php +++ b/includes/classes/class-rest-api.php @@ -32,6 +32,8 @@ public function __construct() { /** * Add the class the hooks. + * + * @return void */ public function init_hooks() { add_action( 'init', [ $this, 'init_rest_routes' ] ); @@ -443,7 +445,7 @@ public function filter_js_validation_html( string $html, string $rule_id, array /** * REST handler that saves to the DB a list of js rule violations for a post. * - * @param WP_REST_Request $request The request passed from the REST call. + * @param \WP_REST_Request $request The request passed from the REST call. * * @return \WP_REST_Response */ @@ -706,7 +708,7 @@ public function get_scans_stats() { /** * REST handler that gets stats about the scans by post type * - * @param WP_REST_Request $request The request passed from the REST call. + * @param \WP_REST_Request $request The request passed from the REST call. * * @return \WP_REST_Response */ @@ -747,7 +749,7 @@ public function get_scans_stats_by_post_type( $request ) { /** * REST handler that gets stats about the scans by post types * - * @param WP_REST_Request $request The request passed from the REST call. + * @param \WP_REST_Request $request The request passed from the REST call. * * @return \WP_REST_Response */ diff --git a/includes/classes/class-simplified-summary.php b/includes/classes/class-simplified-summary.php index ca3fc6e5b..83b3663dc 100644 --- a/includes/classes/class-simplified-summary.php +++ b/includes/classes/class-simplified-summary.php @@ -24,6 +24,8 @@ public function __construct() { /** * Initialize WordPress hooks. + * + * @return void */ public function init_hooks() { add_filter( 'the_content', [ $this, 'output_simplified_summary' ] ); diff --git a/includes/classes/class-summary-generator.php b/includes/classes/class-summary-generator.php index ac64a4d7e..b2feb1411 100644 --- a/includes/classes/class-summary-generator.php +++ b/includes/classes/class-summary-generator.php @@ -124,7 +124,7 @@ private function calculate_passed_tests( $rules ) { } // Calculate the percentage of passed tests. - return round( ( $passed_count / count( $rules ) ) * 100 ); + return (int) round( ( $passed_count / count( $rules ) ) * 100 ); } /** @@ -246,6 +246,7 @@ private function count_contrast_errors() { * @param array $summary An associative array containing the summary of accessibility checks. * * @since 1.9.0 + * @return void */ private function update_issue_density( $summary ) { $issue_density_array = get_post_meta( $this->post_id, '_edac_density_data', false ); @@ -322,6 +323,7 @@ private function get_readability( $summary ) { * @param array $summary An associative array containing the summary of accessibility checks. * * @since 1.9.0 + * @return void */ private function save_summary_meta_data( $summary ) { update_post_meta( $this->post_id, '_edac_summary', $this->sanitize_summary_meta_data( $summary ) ); diff --git a/includes/helper-functions.php b/includes/helper-functions.php index 370113a68..53a5c290d 100644 --- a/includes/helper-functions.php +++ b/includes/helper-functions.php @@ -427,7 +427,7 @@ function edac_get_upcoming_meetups_html( $meetup, $count = 5, $heading = '3' ) { * @param int $issue_count number of issues. * @param int $element_count number of elements. * @param int $content_length length of content. - * @return int + * @return float */ function edac_get_issue_density( $issue_count, $element_count, $content_length ) { @@ -446,7 +446,7 @@ function edac_get_issue_density( $issue_count, $element_count, $content_length ) ( $error_content_percentage * $content_weight ) ); - return round( $score * 100, 2 ); + return (float) round( $score * 100, 2 ); } /** diff --git a/includes/options-page.php b/includes/options-page.php index a27721cf6..c1f75e7b0 100644 --- a/includes/options-page.php +++ b/includes/options-page.php @@ -36,6 +36,8 @@ function edac_user_can_ignore() { /** * Add an options page under the Settings submenu + * + * @return void */ function edac_add_options_page() { @@ -92,6 +94,8 @@ function () { /** * Render the welcome page for plugin + * + * @return void */ function edac_display_welcome_page() { include_once plugin_dir_path( __DIR__ ) . 'partials/welcome-page.php'; @@ -99,6 +103,8 @@ function edac_display_welcome_page() { /** * Render the options page for plugin + * + * @return void */ function edac_display_options_page() { include_once plugin_dir_path( __DIR__ ) . 'partials/settings-page.php'; @@ -106,6 +112,8 @@ function edac_display_options_page() { /** * Register settings + * + * @return void */ function edac_register_setting() { @@ -288,10 +296,10 @@ function edac_register_setting() { ); // Register settings. - register_setting( 'edac_settings', 'edac_post_types', 'edac_sanitize_post_types' ); + register_setting( 'edac_settings', 'edac_post_types', [ 'sanitize_callback' => 'edac_sanitize_post_types' ] ); - register_setting( 'edac_settings', 'edac_delete_data', 'edac_sanitize_checkbox' ); - register_setting( 'edac_settings', 'edac_show_metabox_in_block_editor', 'edac_sanitize_checkbox' ); + register_setting( 'edac_settings', 'edac_delete_data', [ 'sanitize_callback' => 'edac_sanitize_checkbox' ] ); + register_setting( 'edac_settings', 'edac_show_metabox_in_block_editor', [ 'sanitize_callback' => 'edac_sanitize_checkbox' ] ); register_setting( 'edac_settings', 'edac_simplified_summary_prompt', @@ -310,22 +318,24 @@ function edac_register_setting() { 'default' => 'after', ] ); - register_setting( 'edac_settings', 'edac_add_footer_accessibility_statement', 'edac_sanitize_checkbox' ); - register_setting( 'edac_settings', 'edac_include_accessibility_statement_link', 'edac_sanitize_checkbox' ); - register_setting( 'edac_settings', 'edac_accessibility_policy_page', 'edac_sanitize_accessibility_policy_page' ); + register_setting( 'edac_settings', 'edac_add_footer_accessibility_statement', [ 'sanitize_callback' => 'edac_sanitize_checkbox' ] ); + register_setting( 'edac_settings', 'edac_include_accessibility_statement_link', [ 'sanitize_callback' => 'edac_sanitize_checkbox' ] ); + register_setting( 'edac_settings', 'edac_accessibility_policy_page', [ 'sanitize_callback' => 'edac_sanitize_accessibility_policy_page' ] ); - register_setting( 'edac_settings', 'edac_frontend_highlighter_position', 'edac_sanitize_frontend_highlighter_position' ); + register_setting( 'edac_settings', 'edac_frontend_highlighter_position', [ 'sanitize_callback' => 'edac_sanitize_frontend_highlighter_position' ] ); // Upsell settings - these are using edacp prefix for backwards compatibility. - register_setting( 'edac_settings', 'edacp_full_site_scan_speed', 'edac_sanitize_pro_scan_speed' ); - register_setting( 'edac_settings', 'edacp_enable_archive_scanning', 'edac_sanitize_pro_archive_scanning' ); - register_setting( 'edac_settings', 'edacp_scan_all_taxonomy_terms', 'edac_sanitize_pro_taxonomy_terms' ); - register_setting( 'edac_settings', 'edacp_ignore_user_roles', 'edac_sanitize_pro_ignore_roles' ); - register_setting( 'edac_settings', 'edacp_simplified_summary_heading', 'edac_sanitize_pro_summary_heading' ); + register_setting( 'edac_settings', 'edacp_full_site_scan_speed', [ 'sanitize_callback' => 'edac_sanitize_pro_scan_speed' ] ); + register_setting( 'edac_settings', 'edacp_enable_archive_scanning', [ 'sanitize_callback' => 'edac_sanitize_pro_archive_scanning' ] ); + register_setting( 'edac_settings', 'edacp_scan_all_taxonomy_terms', [ 'sanitize_callback' => 'edac_sanitize_pro_taxonomy_terms' ] ); + register_setting( 'edac_settings', 'edacp_ignore_user_roles', [ 'sanitize_callback' => 'edac_sanitize_pro_ignore_roles' ] ); + register_setting( 'edac_settings', 'edacp_simplified_summary_heading', [ 'sanitize_callback' => 'edac_sanitize_pro_summary_heading' ] ); } /** * Render the text for the general section + * + * @return void */ function edac_general_cb() { echo '

'; @@ -363,6 +373,8 @@ function edac_frontend_highlighter_section_cb() { /** * Render the text for the simplified summary section + * + * @return void */ function edac_simplified_summary_cb() { printf( @@ -383,6 +395,8 @@ function edac_simplified_summary_cb() { /** * Render the text for the footer accessiblity statement section + * + * @return void */ function edac_footer_accessibility_statement_cb() { echo '

'; @@ -392,6 +406,8 @@ function edac_footer_accessibility_statement_cb() { /** * Render the text for the system settings section + * + * @return void */ function edac_system_cb() { echo '

'; @@ -403,6 +419,8 @@ function edac_system_cb() { * Render the dropdown input field for scan speed option. * * Note: this setting is purposefully using edacp as prefix for back compat reasons. + * + * @return void */ function edac_full_site_scan_speed_cb() { @@ -516,6 +534,8 @@ function edac_sanitize_scan_speed( $speed ) { /** * Render the radio input field for position option + * + * @return void */ function edac_simplified_summary_position_cb() { $position = get_option( 'edac_simplified_summary_position' ); @@ -581,6 +601,7 @@ function edac_sanitize_simplified_summary_position( $position ) { if ( in_array( $position, [ 'before', 'after', 'none' ], true ) ) { return $position; } + return ''; } /** @@ -599,6 +620,8 @@ function edac_sanitize_frontend_highlighter_position( string $position ): string /** * Render the radio input field for position option + * + * @return void */ function edac_simplified_summary_prompt_cb() { $prompt = get_option( 'edac_simplified_summary_prompt' ); @@ -634,10 +657,13 @@ function edac_sanitize_simplified_summary_prompt( $prompt ) { if ( in_array( $prompt, [ 'when required', 'always', 'none' ], true ) ) { return $prompt; } + return ''; } /** * Render the checkbox input field for post_types option + * + * @return void */ function edac_post_types_cb() { @@ -740,6 +766,8 @@ function edac_sanitize_post_types( $selected_post_types ) { /** * Render the checkbox input field for add footer accessibility statement option + * + * @return void */ function edac_add_footer_accessibility_statement_cb() { @@ -756,7 +784,9 @@ function edac_add_footer_accessibility_statement_cb() { } /** - * Render the checkbox input field for add footer accessibility statement option + * Render the checkbox input field for include accessibility statement link option + * + * @return void */ function edac_include_accessibility_statement_link_cb() { @@ -780,6 +810,8 @@ function edac_include_accessibility_statement_link_cb() { /** * Render the select field for accessibility policy page option + * + * @return void */ function edac_accessibility_policy_page_cb() { @@ -802,10 +834,13 @@ function edac_sanitize_accessibility_policy_page( $page ) { if ( $page ) { return esc_url( $page ); } + return ''; } /** * Render the accessibility statement preview + * + * @return void */ function edac_accessibility_statement_preview_cb() { echo wp_kses_post( @@ -815,6 +850,8 @@ function edac_accessibility_statement_preview_cb() { /** * Render the checkbox input field for delete data option + * + * @return void */ function edac_delete_data_cb() { @@ -833,6 +870,8 @@ function edac_delete_data_cb() { /** * Render the checkbox input field for toggling metabox visibility in the block editor. + * + * @return void */ function edac_show_metabox_in_block_editor_cb() { @@ -1030,6 +1069,8 @@ function edac_sanitize_ignore_user_roles( $selected_roles ) { /** * Render the text for the permissions section + * + * @return void */ function edac_permissions_section_cb() { ?>