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.../public_h.../clone/wp-conte.../plugins/network-.../componen.../resizer
File: NetsPostsThumbnailsResizer.php
<?php
[0] Fix | Delete
/*
[1] Fix | Delete
Plugin Name: Network Posts Ext Thumbnails
[2] Fix | Delete
Plugin URI: https://wp-plugins.johncardell.com/network-posts-extended/
[3] Fix | Delete
Description: Network Posts Extended plugin enables you to share posts over WP Multi Site network. You can display on any blog in your network the posts selected by taxonomy from any blogs including main.
[4] Fix | Delete
Version: 0.1.0
[5] Fix | Delete
Author: John Cardell
[6] Fix | Delete
Author URI: http://www.johncardell.com
[7] Fix | Delete
Copyright 2014 John Cardell
[8] Fix | Delete
*/
[9] Fix | Delete
namespace NetworkPosts\Components\Resizer;
[10] Fix | Delete
require_once 'NetsPostsThumbnailSizeSettings.php';
[11] Fix | Delete
class NetsPostsThumbnailsResizer {
[12] Fix | Delete
private $blog_sizes = array();
[13] Fix | Delete
protected $resizer_client;
[14] Fix | Delete
public function set_local_sizes( array $sizes ){
[15] Fix | Delete
$this->blog_sizes = $sizes;
[16] Fix | Delete
}
[17] Fix | Delete
public function get_sizes(){
[18] Fix | Delete
return $this->blog_sizes;
[19] Fix | Delete
}
[20] Fix | Delete
public function create_size( $name, $size ){
[21] Fix | Delete
$count = 0;
[22] Fix | Delete
if( isset( $size['data']['alias'] ) ){
[23] Fix | Delete
$name = $size['data']['alias'];
[24] Fix | Delete
}
[25] Fix | Delete
do {
[26] Fix | Delete
$alias = $this->create_alias( $name, $count );
[27] Fix | Delete
$id = $this->generate_id( $alias );
[28] Fix | Delete
$count++;
[29] Fix | Delete
}
[30] Fix | Delete
while( $this->find_by_id( $id ) );
[31] Fix | Delete
$size['id'] = $id;
[32] Fix | Delete
$size['data']['alias'] = $alias;
[33] Fix | Delete
$this->set_blog_size( $id, $size );
[34] Fix | Delete
return $size;
[35] Fix | Delete
}
[36] Fix | Delete
private function create_alias( $name, $count = 0 ){
[37] Fix | Delete
$str = esc_attr( str_replace( ' ', '-', strtolower( $name ) ) );
[38] Fix | Delete
if( $count ){
[39] Fix | Delete
$str .= "-s{$count}";
[40] Fix | Delete
}
[41] Fix | Delete
return $str;
[42] Fix | Delete
}
[43] Fix | Delete
public function set_blog_size( $id, array $size ){
[44] Fix | Delete
$this->blog_sizes[$id] = $size;
[45] Fix | Delete
$this->save_local();
[46] Fix | Delete
}
[47] Fix | Delete
protected function generate_id( $alias ){
[48] Fix | Delete
return md5( $alias );
[49] Fix | Delete
}
[50] Fix | Delete
public function count_all(){
[51] Fix | Delete
return count( $this->get_sizes() );
[52] Fix | Delete
}
[53] Fix | Delete
public function update_size( $id, $size ){
[54] Fix | Delete
$old = $this->find_by_id( $id );
[55] Fix | Delete
if( $old ){
[56] Fix | Delete
$size['data']['alias'] = $old['data']['alias'];
[57] Fix | Delete
$this->set_blog_size( $id, $size );
[58] Fix | Delete
return true;
[59] Fix | Delete
}
[60] Fix | Delete
return false;
[61] Fix | Delete
}
[62] Fix | Delete
public function find_by_id( $id ){
[63] Fix | Delete
if( array_key_exists( $id, $this->blog_sizes ) ){
[64] Fix | Delete
return $this->blog_sizes[$id];
[65] Fix | Delete
}
[66] Fix | Delete
return null;
[67] Fix | Delete
}
[68] Fix | Delete
public function delete( $id ){
[69] Fix | Delete
$this->delete_local_size( $id );
[70] Fix | Delete
}
[71] Fix | Delete
public function delete_local_size( $id ){
[72] Fix | Delete
unset( $this->blog_sizes[$id] );
[73] Fix | Delete
$this->save_local();
[74] Fix | Delete
}
[75] Fix | Delete
public function generate_image( $size_id, $file ){
[76] Fix | Delete
$size = $this->find_by_id( $size_id );
[77] Fix | Delete
if( $size ) {
[78] Fix | Delete
if ( isset( $size['crop'] ) ) {
[79] Fix | Delete
$result = image_make_intermediate_size( $file, $size['data']['width'],
[80] Fix | Delete
$size['data']['height'], array( $size['crop_x'], $size['crop_y'] ) );
[81] Fix | Delete
} else {
[82] Fix | Delete
$result = image_make_intermediate_size( $file, $size['data']['width'], $size['data']['height'], false );
[83] Fix | Delete
}
[84] Fix | Delete
if ( $result ) {
[85] Fix | Delete
//$image_meta = wp_get_attachment_metadata( $attachment_id );
[86] Fix | Delete
//$result['file'] = substr( $file, strrpos( '/', $file ) );
[87] Fix | Delete
return $result;
[88] Fix | Delete
}
[89] Fix | Delete
}
[90] Fix | Delete
return false;
[91] Fix | Delete
}
[92] Fix | Delete
protected function save_local(){
[93] Fix | Delete
NetsPostsThumbnailSizeSettings::set_blog_image_sizes( $this->blog_sizes );
[94] Fix | Delete
}
[95] Fix | Delete
}
[96] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function