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/smart-sl.../Nextend/Framewor.../Image/WordPres...
File: WordPressImage.php
<?php
[0] Fix | Delete
[1] Fix | Delete
namespace Nextend\Framework\Image\WordPress;
[2] Fix | Delete
[3] Fix | Delete
use Nextend\Framework\Image\AbstractPlatformImage;
[4] Fix | Delete
use Nextend\Framework\Platform\Platform;
[5] Fix | Delete
use Nextend\Framework\ResourceTranslator\ResourceTranslator;
[6] Fix | Delete
use function wp_check_filetype;
[7] Fix | Delete
use function wp_upload_dir;
[8] Fix | Delete
[9] Fix | Delete
class WordPressImage extends AbstractPlatformImage {
[10] Fix | Delete
[11] Fix | Delete
public function __construct() {
[12] Fix | Delete
$wp_upload_dir = wp_upload_dir();
[13] Fix | Delete
[14] Fix | Delete
ResourceTranslator::createResource('$upload$', rtrim(Platform::getPublicDirectory(), "/\\"), rtrim($wp_upload_dir['baseurl'], "/\\"));
[15] Fix | Delete
}
[16] Fix | Delete
[17] Fix | Delete
public function initLightbox() {
[18] Fix | Delete
[19] Fix | Delete
wp_enqueue_media();
[20] Fix | Delete
}
[21] Fix | Delete
[22] Fix | Delete
public function onImageUploaded($filename) {
[23] Fix | Delete
$filename = str_replace(DIRECTORY_SEPARATOR, '/', $filename); // fix for Windows servers
[24] Fix | Delete
[25] Fix | Delete
// Check the type of file. We'll use this as the 'post_mime_type'.
[26] Fix | Delete
$filetype = wp_check_filetype(basename($filename), null);
[27] Fix | Delete
[28] Fix | Delete
// Get the path to the upload directory.
[29] Fix | Delete
$wp_upload_dir = wp_upload_dir();
[30] Fix | Delete
[31] Fix | Delete
// Prepare an array of post data for the attachment.
[32] Fix | Delete
$attachment = array(
[33] Fix | Delete
'guid' => $wp_upload_dir['url'] . '/' . basename($filename),
[34] Fix | Delete
'post_mime_type' => $filetype['type'],
[35] Fix | Delete
'post_title' => preg_replace('/\.[^.]+$/', '', basename($filename)),
[36] Fix | Delete
'post_content' => '',
[37] Fix | Delete
'post_status' => 'inherit'
[38] Fix | Delete
);
[39] Fix | Delete
[40] Fix | Delete
// Insert the attachment.
[41] Fix | Delete
$attach_id = wp_insert_attachment($attachment, $filename);
[42] Fix | Delete
[43] Fix | Delete
// Make sure that this file is included, as wp_generate_attachment_metadata() depends on it.
[44] Fix | Delete
require_once(ABSPATH . 'wp-admin/includes/image.php');
[45] Fix | Delete
[46] Fix | Delete
// Generate the metadata for the attachment, and update the database record.
[47] Fix | Delete
$attach_data = wp_generate_attachment_metadata($attach_id, $filename);
[48] Fix | Delete
wp_update_attachment_metadata($attach_id, $attach_data);
[49] Fix | Delete
}
[50] Fix | Delete
}
[51] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function