Files
WPS3Media/classes/pro/tools/download-and-remover.php

96 lines
2.3 KiB
PHP
Raw Permalink Normal View History

<?php
namespace DeliciousBrains\WP_Offload_Media\Pro\Tools;
use DeliciousBrains\WP_Offload_Media\Pro\Background_Processes\Background_Tool_Process;
use DeliciousBrains\WP_Offload_Media\Pro\Background_Processes\Download_And_Remover_Process;
class Download_And_Remover extends Downloader {
/**
* @var string
*/
protected $tool_key = 'download_and_remover';
/**
* Message for error notice
*
* @param string|null $message Optional message to override the default for the tool.
*
* @return string
*/
protected function get_error_notice_message( $message = null ) {
$title = __( 'Removal Errors', 'amazon-s3-and-cloudfront' );
$message = empty( $message ) ? __( 'Previous attempts at removing your media library from the bucket have resulted in errors.', 'amazon-s3-and-cloudfront' ) : $message;
return sprintf( '<strong>%s</strong> &mdash; %s', $title, $message );
}
/**
* Should render.
*
* @return bool
*/
public function should_render() {
if ( ! $this->as3cf->is_plugin_setup() ) {
return false;
}
return (bool) $this->count_offloaded_media_files();
}
/**
* Get title text.
*
* @return string
*/
public function get_title_text() {
return __( 'Remove all files from bucket', 'amazon-s3-and-cloudfront' );
}
/**
* Get more info text.
*
* @return string
*/
public static function get_more_info_text() {
return __( 'This tool goes through all your media and deletes files from the bucket. If the file doesn\'t exist on your server, it will download it before deleting.', 'amazon-s3-and-cloudfront' );
}
/**
* Get button text.
*
* @return string
*/
public function get_button_text() {
return __( 'Remove Files', 'amazon-s3-and-cloudfront' );
}
/**
* Get queued status text.
*
* @return string
*/
public function get_queued_status(): string {
return __( 'Removing media from bucket', 'amazon-s3-and-cloudfront' );
}
/**
* Get short queued status text.
*
* @return string
*/
public function get_short_queued_status(): string {
return _x( 'Removing…', 'Short tool running message', 'amazon-s3-and-cloudfront' );
}
/**
* Get background process class.
*
* @return Background_Tool_Process|null
*/
protected function get_background_process_class() {
return new Download_And_Remover_Process( $this->as3cf, $this );
}
}