• 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

0.0
/admin/class-post-save.php
1
<?php
2
/**
3
 * Class for handling the post save actions.
4
 *
5
 * @since 1.23.0
6
 *
7
 * @package Accessibility_Checker
8
 */
9

10
namespace EDAC\Admin;
11

12
use EDAC\Admin\Purge_Post_Data;
13

14
/**
15
 * Class Post_Save
16
 *
17
 * Handles actions and filters related to saving posts in the accessibility checker.
18
 *
19
 * @package EDAC\Admin
20
 * @since 1.23.0
21
 */
22
class Post_Save {
23

24
        /**
25
         * Post on save
26
         *
27
         * @param int    $post_ID The ID of the post being saved.
28
         * @param object $post    The post object being saved.
29
         * @param bool   $update  Whether this is an update or not.
30
         *
31
         * @modified 1.10.0 to add a return when post_status is trash.
32
         * @modified 1.23.0 moved to new class and then swapped to void return as no longer reading the return values anywhere.
33
         *
34
         * @return void The post ID.
35
         */
36
        public static function delete_issue_data_on_post_trashing( $post_ID, $post, $update ) {
37
                // check post type.
NEW
38
                $post_types = Settings::get_scannable_post_types();
×
39
                if ( is_array( $post_types ) && ! in_array( $post->post_type, $post_types, true ) ) {
×
40
                        return;
×
41
                }
42

43
                // prevents first past of save_post due to meta boxes on post editor in gutenberg.
44
                // phpcs:ignore WordPress.Security.NonceVerification.Missing -- This is used to detect automated saves vs user-initiated saves, not processing form data
45
                if ( empty( $_POST ) ) {
×
46
                        return;
×
47
                }
48

49
                // ignore revisions.
50
                if ( wp_is_post_revision( $post_ID ) ) {
×
51
                        return;
×
52
                }
53

54
                // ignore autosaves.
55
                if ( wp_is_post_autosave( $post_ID ) ) {
×
56
                        return;
×
57
                }
58

59
                // check if update.
60
                if ( ! $update ) {
×
61
                        return;
×
62
                }
63

64
                // Post in, or going to, trash.
65
                if ( 'trash' === $post->post_status ) {
×
66
                        // Gutenberg does not fire the `wp_trash_post` action when moving posts to the
67
                        // trash. Instead, it uses `rest_delete_{$post_type}` which passes a different shape
68
                        // Instead of hooking in there for every post type supported the data gets purged
69
                        // here instead which produces the same result.
70
                        Purge_Post_Data::delete_post( $post_ID );
×
71
                }
72
        }
73
}
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