Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93
/home/sportsfe.../httpdocs/wp-conte.../plugins/wp-smush.../core/modules/async
File: class-async.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* Class Async
[2] Fix | Delete
*
[3] Fix | Delete
* @package Smush\Core\Modules\Async
[4] Fix | Delete
* @since 2.5
[5] Fix | Delete
*
[6] Fix | Delete
* @author Umesh Kumar <umesh@incsub.com>
[7] Fix | Delete
*
[8] Fix | Delete
* @copyright (c) 2016, Incsub (http://incsub.com)
[9] Fix | Delete
*/
[10] Fix | Delete
[11] Fix | Delete
namespace Smush\Core\Modules\Async;
[12] Fix | Delete
use Exception;
[13] Fix | Delete
use WP_Smush;
[14] Fix | Delete
[15] Fix | Delete
if ( ! defined( 'WPINC' ) ) {
[16] Fix | Delete
die;
[17] Fix | Delete
}
[18] Fix | Delete
[19] Fix | Delete
/**
[20] Fix | Delete
* Class Async
[21] Fix | Delete
*/
[22] Fix | Delete
class Async extends Abstract_Async {
[23] Fix | Delete
[24] Fix | Delete
/**
[25] Fix | Delete
* Argument count.
[26] Fix | Delete
*
[27] Fix | Delete
* @var int $argument_count
[28] Fix | Delete
*/
[29] Fix | Delete
protected $argument_count = 2;
[30] Fix | Delete
[31] Fix | Delete
/**
[32] Fix | Delete
* Priority.
[33] Fix | Delete
*
[34] Fix | Delete
* @var int $priority
[35] Fix | Delete
*/
[36] Fix | Delete
protected $priority = 12;
[37] Fix | Delete
[38] Fix | Delete
/**
[39] Fix | Delete
* Whenever a attachment metadata is generated
[40] Fix | Delete
* Had to be hooked on generate and not update, else it goes in infinite loop
[41] Fix | Delete
*
[42] Fix | Delete
* @var string
[43] Fix | Delete
*/
[44] Fix | Delete
protected $action = 'wp_generate_attachment_metadata';
[45] Fix | Delete
[46] Fix | Delete
/**
[47] Fix | Delete
* Prepare data for the asynchronous request
[48] Fix | Delete
*
[49] Fix | Delete
* @throws Exception If for any reason the request should not happen.
[50] Fix | Delete
*
[51] Fix | Delete
* @param array $data An array of data sent to the hook.
[52] Fix | Delete
*
[53] Fix | Delete
* @return array
[54] Fix | Delete
*/
[55] Fix | Delete
protected function prepare_data( $data ) {
[56] Fix | Delete
// We don't have the data, bail out.
[57] Fix | Delete
if ( empty( $data ) ) {
[58] Fix | Delete
return $data;
[59] Fix | Delete
}
[60] Fix | Delete
[61] Fix | Delete
// Return a associative array.
[62] Fix | Delete
$image_meta = array();
[63] Fix | Delete
$image_meta['metadata'] = ! empty( $data[0] ) ? $data[0] : '';
[64] Fix | Delete
$image_meta['id'] = ! empty( $data[1] ) ? $data[1] : '';
[65] Fix | Delete
[66] Fix | Delete
/**
[67] Fix | Delete
* AJAX Thumbnail Rebuild integration.
[68] Fix | Delete
*
[69] Fix | Delete
* @see https://app.asana.com/0/14491813218786/730814863045197/f
[70] Fix | Delete
*/
[71] Fix | Delete
if ( ! empty( $_POST['action'] ) && 'ajax_thumbnail_rebuild' === $_POST['action'] && ! empty( $_POST['thumbnails'] ) ) { // Input var ok.
[72] Fix | Delete
$image_meta['regen'] = wp_unslash( $_POST['thumbnails'] ); // Input var ok.
[73] Fix | Delete
}
[74] Fix | Delete
[75] Fix | Delete
return $image_meta;
[76] Fix | Delete
}
[77] Fix | Delete
[78] Fix | Delete
/**
[79] Fix | Delete
* Run the async task action
[80] Fix | Delete
*
[81] Fix | Delete
* TODO: See if auto smush is enabled or not.
[82] Fix | Delete
* TODO: Check if async is enabled or not.
[83] Fix | Delete
*/
[84] Fix | Delete
protected function run_action() {
[85] Fix | Delete
// Nonce validated in parent method.
[86] Fix | Delete
$id = ! empty( $_POST['id'] ) ? (int) $_POST['id'] : ''; // phpcs:ignore WordPress.Security.NonceVerification.Missing
[87] Fix | Delete
[88] Fix | Delete
// Get metadata from $_POST.
[89] Fix | Delete
if ( ! empty( $_POST['metadata'] ) && wp_attachment_is_image( $id ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
[90] Fix | Delete
// Allow the Asynchronous task to run.
[91] Fix | Delete
do_action( "wp_async_$this->action", $id );
[92] Fix | Delete
}
[93] Fix | Delete
}
[94] Fix | Delete
[95] Fix | Delete
protected function should_run( $data ) {
[96] Fix | Delete
if ( empty( $data['metadata'] ) && empty( $data['id'] ) ) {
[97] Fix | Delete
return false;
[98] Fix | Delete
}
[99] Fix | Delete
[100] Fix | Delete
$attachment_id = $data['id'];
[101] Fix | Delete
$smush = WP_Smush::get_instance()->core()->mod->smush;
[102] Fix | Delete
[103] Fix | Delete
return $smush->should_auto_smush( $attachment_id );
[104] Fix | Delete
}
[105] Fix | Delete
}
[106] Fix | Delete
[107] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function