Media.php
30 lines
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace AC\TableScreen\TableRows; |
| 6 | |
| 7 | use AC\Request; |
| 8 | use AC\TableScreen\TableRows; |
| 9 | use WP_Query; |
| 10 | |
| 11 | final class Media extends TableRows |
| 12 | { |
| 13 | |
| 14 | public function register(): void |
| 15 | { |
| 16 | add_action('pre_get_posts', [$this, 'pre_handle_request']); |
| 17 | } |
| 18 | |
| 19 | public function pre_handle_request(WP_Query $query): void |
| 20 | { |
| 21 | if ( ! $query->is_main_query()) { |
| 22 | return; |
| 23 | } |
| 24 | |
| 25 | remove_action('pre_get_posts', [$this, __FUNCTION__]); |
| 26 | |
| 27 | parent::handle(new Request()); |
| 28 | } |
| 29 | |
| 30 | } |