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 | public function register(): void |
| 14 | { |
| 15 | add_action('pre_get_posts', [$this, 'pre_handle_request']); |
| 16 | } |
| 17 | |
| 18 | public function pre_handle_request(WP_Query $query): void |
| 19 | { |
| 20 | if (! $query->is_main_query()) { |
| 21 | return; |
| 22 | } |
| 23 | |
| 24 | remove_action('pre_get_posts', [$this, __FUNCTION__]); |
| 25 | |
| 26 | parent::handle(new Request()); |
| 27 | } |
| 28 | |
| 29 | } |
| 30 |