| @@ -33,8 +33,36 @@ | ||
| 33 | 33 | * @param InlineTableScanner $scanner Scanner used to locate inline table blocks. |
| 34 | 34 | */ |
| 35 | 35 | public function __construct( InlineTableScanner $scanner ) { |
| 36 | 36 | $this->scanner = $scanner; |
| 37 | + add_filter( 'post_row_actions', array( $this, 'strip_incompatible_row_actions' ), 1, 2 ); | |
| 38 | + } | |
| 39 | + | |
| 40 | + /** | |
| 41 | + * @param array $actions Row action links, keyed by action name. | |
| 42 | + * @param WP_Post $post The row's post (real or virtual). | |
| 43 | + * @return array Unmodified row actions (only third-party hook state is changed). | |
| 44 | + */ | |
| 45 | + public function strip_incompatible_row_actions( array $actions, WP_Post $post ): array { | |
| 46 | + if ( empty( $post->tablekit_is_virtual ) ) { | |
| 47 | + return $actions; | |
| 48 | + } | |
| 49 | + | |
| 50 | + global $wp_filter; | |
| 51 | + if ( ! isset( $wp_filter['post_row_actions'] ) || ! ( $wp_filter['post_row_actions'] instanceof \WP_Hook ) ) { | |
| 52 | + return $actions; | |
| 53 | + } | |
| 54 | + | |
| 55 | + foreach ( $wp_filter['post_row_actions']->callbacks as $priority => $callbacks ) { | |
| 56 | + foreach ( $callbacks as $callback ) { | |
| 57 | + $fn = $callback['function']; | |
| 58 | + if ( is_string( $fn ) && false !== strpos( $fn, '_collaboration_row_actions' ) ) { | |
| 59 | + remove_filter( 'post_row_actions', $fn, $priority ); | |
| 60 | + } | |
| 61 | + } | |
| 62 | + } | |
| 63 | + | |
| 64 | + return $actions; | |
| 37 | 65 | } |
| 38 | 66 | |
| 39 | 67 | /** |
| 40 | 68 | * Append synthetic "virtual" WP_Post rows to a query's results — one per |