| 1 |
<?php |
| 2 |
declare(strict_types=1); |
| 3 |
|
| 4 |
namespace Imagify\Media; |
| 5 |
|
| 6 |
use Imagify\EventManagement\SubscriberInterface; |
| 7 |
use Imagify\Media\Upload\Upload; |
| 8 |
|
| 9 |
/** |
| 10 |
* Media Subscriber |
| 11 |
*/ |
| 12 |
class Subscriber implements SubscriberInterface { |
| 13 |
|
| 14 |
/** |
| 15 |
* Upload instance. |
| 16 |
* |
| 17 |
* @var Upload |
| 18 |
*/ |
| 19 |
private $upload; |
| 20 |
/** |
| 21 |
* Constructor |
| 22 |
* |
| 23 |
* @param Upload $upload Upload Instance. |
| 24 |
*/ |
| 25 |
public function __construct( Upload $upload ) { |
| 26 |
$this->upload = $upload; |
| 27 |
} |
| 28 |
|
| 29 |
/** |
| 30 |
* Returns an array of events that this subscriber wants to listen to. |
| 31 |
* |
| 32 |
* @return array |
| 33 |
*/ |
| 34 |
public static function get_subscribed_events(): array { |
| 35 |
return [ |
| 36 |
// @action |
| 37 |
'restrict_manage_posts' => 'imagify_attachments_filter_dropdown', |
| 38 |
]; |
| 39 |
} |
| 40 |
|
| 41 |
/** |
| 42 |
* Adds a dropdown that allows filtering on the attachments Imagify status. |
| 43 |
* |
| 44 |
* @return void |
| 45 |
*/ |
| 46 |
public function imagify_attachments_filter_dropdown() { |
| 47 |
if ( ! \Imagify_Views::get_instance()->is_wp_library_page() ) { |
| 48 |
return; |
| 49 |
} |
| 50 |
$this->upload->add_imagify_filter_to_attachments_dropdown(); |
| 51 |
} |
| 52 |
} |
| 53 |
|