diff --git a/Tests/Integration/inc/classes/Media/upload.php b/Tests/Integration/inc/classes/Media/upload.php new file mode 100644 index 00000000..8482f1be --- /dev/null +++ b/Tests/Integration/inc/classes/Media/upload.php @@ -0,0 +1,67 @@ +view_instance) { + + } + parent::tear_down(); + } + + public function set_up() { + + parent::set_up(); + } + + public function testShouldReturnExpected() { + $upload = new \Imagify\Media\Upload\Upload(); + + add_filter( 'imagify_display_library_stats', '__return_true' ); + + $this->mock_imagify_count_functions(); + ob_start(); + $upload->add_imagify_filter_to_attachments_dropdown(); + $output = ob_get_clean(); + + $this->assertStringContainsString( 'Filter by status', $output ); + $this->assertStringContainsString( ''; + echo ''; + + foreach ( $options as $value => $label ) { + $filter_value = isset( $data[ $value ] ) ? ' (' . $data[ $value ] . ')' : ''; + echo ''; + } + echo ' '; + } +} diff --git a/config/providers.php b/config/providers.php index 8c3f4be0..1f29c89f 100644 --- a/config/providers.php +++ b/config/providers.php @@ -8,4 +8,5 @@ 'Imagify\Stats\ServiceProvider', 'Imagify\Webp\ServiceProvider', 'Imagify\ThirdParty\ServiceProvider', + 'Imagify\Media\ServiceProvider', ]; diff --git a/inc/admin/upload.php b/inc/admin/upload.php index b24249a5..d2bb42f0 100755 --- a/inc/admin/upload.php +++ b/inc/admin/upload.php @@ -39,38 +39,6 @@ function _imagify_manage_media_custom_column( $column_name, $attachment_id ) { echo get_imagify_media_column_content( $process ); } -add_action( 'restrict_manage_posts', '_imagify_attachments_filter_dropdown' ); -/** - * Adds a dropdown that allows filtering on the attachments Imagify status. - * - * @since 1.0 - * @author Jonathan Buttigieg - */ -function _imagify_attachments_filter_dropdown() { - if ( ! Imagify_Views::get_instance()->is_wp_library_page() ) { - return; - } - - $optimized = imagify_count_optimized_attachments(); - $unoptimized = imagify_count_unoptimized_attachments(); - $errors = imagify_count_error_attachments(); - $status = isset( $_GET['imagify-status'] ) ? wp_unslash( $_GET['imagify-status'] ) : 0; // WPCS: CSRF ok. - $options = array( - 'optimized' => _x( 'Optimized', 'Media Files', 'imagify' ), - 'unoptimized' => _x( 'Unoptimized', 'Media Files', 'imagify' ), - 'errors' => _x( 'Errors', 'Media Files', 'imagify' ), - ); - - echo ''; - echo ' '; -} - add_filter( 'request', '_imagify_sort_attachments_by_status' ); /** * Modify the query based on the imagify-status variable in $_GET.