Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/263.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 致命错误未捕获错误:调用未定义的方法WP\u错误_Php_Wordpress_Php 8 - Fatal编程技术网

Php 致命错误未捕获错误:调用未定义的方法WP\u错误

Php 致命错误未捕获错误:调用未定义的方法WP\u错误,php,wordpress,php-8,Php,Wordpress,Php 8,错误消息 <b>Fatal error</b>: Uncaught Error: Call to undefined method WP_Error::resize() in C:\Users\User\Documents\xampp\htdocs\WordPress1\wp-content\themes\elina\framework\php\PeTheme\PeThemeImage.php:144 Stack trace: #0 C:\Users\User\Docu

错误消息

<b>Fatal error</b>:  Uncaught Error: Call to undefined method WP_Error::resize() in C:\Users\User\Documents\xampp\htdocs\WordPress1\wp-content\themes\elina\framework\php\PeTheme\PeThemeImage.php:144
Stack trace:
#0 C:\Users\User\Documents\xampp\htdocs\WordPress1\wp-content\themes\elina\framework\php\PeTheme\PeThemeImage.php(282): 
PeThemeImage-&gt;iresize('C:\\Users\\User\\D...', 320, 240, true)
#1 C:\Users\User\Documents\xampp\htdocs\WordPress1\wp-content\themes\elina\framework\php\PeTheme\PeThemeImage.php(364):
 PeThemeImage-&gt;aq_resize('http://localhos...', 320, 240, true, false)
#2 C:\Users\User\Documents\xampp\htdocs\WordPress1\wp-content\themes\elina\framework\php\PeTheme\PeThemeImage.php(369): PeThemeImage-&gt;resize('http://localhos...', 320, 240, true)
致命错误:未捕获错误:调用C:\Users\User\Documents\xampp\htdocs\WordPress1\WP content\themes\elina\framework\php\PeTheme\PeThemeImage.php中未定义的方法WP\u error::resize()
堆栈跟踪:
#0 C:\Users\User\Documents\xampp\htdocs\WordPress1\wp content\themes\elina\framework\php\PeTheme\pethemaimage.php(282):
PeThemeImage iresize('C:\\Users\\User\\D...,320240,true)
#1 C:\Users\User\Documents\xampp\htdocs\WordPress1\wp content\themes\elina\framework\php\PeTheme\pethemaimage.php(364):
PETHEMEMAGE-aq_http://localhos...’,320,240,对,错)
#2 C:\Users\User\Documents\xampp\htdocs\WordPress1\wp content\themes\elina\framework\php\PeTheme\PeThemeImage.php(369):PeThemeImagehttp://localhos...’,320,240,对)
源代码

类PeThemeImage{
受保护的$basedir;
受保护的$baseurl;
受保护的$blanks=array();
受保护的$u已启用;
受保护的$lazyload_已启用;
受保护的$optkey;
产生的公共资金;
受保护的md5美元;
受保护的$image\u大小;
公共函数构造(){
$wp_upload=wp_upload_dir();
$this->basedir=$wp_upload[“basedir”];
$this->baseurl=$wp_upload[“baseurl”];
$this->retina\u enabled=peTheme()->options->get(“retina”)=“yes”;
$this->lazyload_enabled=peTheme()->options->get(“lazymages”)=“yes”;
$this->optkey=“pe\U主题”。pe\U主题名称。“\U缩略图”;
//删除_选项($this->optkey);
$this->generated=get_选项($this->optkey,array(“index”=>array());
$this->md5=md5(序列化($this->generated));
//peTheme()->缩略图->清洁();
}
公共功能和空白($w,$h){
$key=“{$w}x{$h}”;
if(设置($this->空白[$key])){
返回$this->空格[$key];
}
$external=“/img/blank/$key.gif”;
如果(文件存在(PE主题路径$external)){
//存在具有请求大小的空白img
$this->blanks[$key]=PE_主题_URL.$external;
}否则{
//创建空白img
$image=imagecreate($w,$h);
imagesavealpha($image,true);
imagecolortransparent($image,imagecolorallocatealpha($image,0,0,0));
ob_start();
imagegif($image);
$this->blanks[$key]=“data:image/gif;base64,”.base64_encode(ob_get_clean());
图像销毁($图像);
}
返回$this->空格[$key];
}
公共函数占位符($w,$h){
返回sprintf(“”,$this->blank($w,$h),$w,$h);
}
公共功能获取大小($img){
返回stripos($img,“http”)==0?false:getimagesize($img);
}
公共函数是_url($url){
返回stripos($url,'http://')==0 | | strpos($url,'http://')==0;
}
公共函数get_retina($url){
$ret=$this->retina\u已启用;
$lazy=$ret | |$this->lazyload|u enabled;
$common=sprintf('src=“%s”alt=“”,$url);
$img=str\u replace(主题URL,主题路径,$URL);
如果($this->is_url($img)){
$burl=$this->baseurl;
$bdir=$this->basedir;
$img=str_替换($burl、$bdir、$img);
如果($this->is_url($img)){
//该死…让我们试试添加/删除www
if(stripos(“://www.”,$url)>-1){
//www在那里,请尝试删除它
$burl=str_替换(“://www.”,“://”,$burl);
}否则{
//不,请尝试添加它
$burl=str_替换(“:/”,“://www.”,$burl);
}
$img=str_替换($burl、$bdir、$img);
}
}
如果($ret | |$lazy){
如果($ret){
$ret=preg\u replace(“/\(\w+)$/”、“@2x.$1”、$img);
$ret=是否可读($ret)?preg\u replace(“/\.(\w+)$/”,“@2x.$1”,$url):false;
}
如果($ret | |$lazy){
//尝试获取图像大小
$size=$this->get\u size($img);
若有($尺寸){
列表($w,$h)=$size;
$common=sprintf('src=“%s”width=“%s”height=“%s”alt=“”,$this->blank($w,$h),$w,$h);
}否则{
$common=sprintf('src=“%s”alt=“”,$this->blank(1,1));
}
$lazy=sprintf('data original=“%s”,$url);
$ret=$ret?sprintf('data original hires=“%s]”,$ret):“”;
}
}否则{
$size=$this->get\u size($img);
若有($尺寸){
列表($w,$h)=$size;
$common=sprintf('src=“%s”width=“%s”height=“%s”alt=“”,$url,$w,$h);
} 
}
返回sprintf(“,$url,$w,$h,$unscaled);
}
公共函数resizedImgUrl($url,$w,$h=null,$crop=true){
返回$this->aq_resize($url、$w、$h、$crop,true);
}
公共函数stats(){
如果($this->md5!=md5(序列化($this->generated))){
更新选项($this->optkey,$this->generated);
}
}
公共函数获取图像大小(){
//制作缩略图和其他中间尺寸
全局$\u wp\u附加图像\u大小;
$this->image_size=array();
foreach(获取中间图像大小()为$s){
$size[$s]=数组('width'=>'','height'=>'','crop'=>false);
如果(isset($\u wp\u附加图像大小[$s]['width']))
$size[$s]['width']=intval($\u wp\u其他图像大小[$s]['width']);//用于主题添加的大小
其他的
$size[$s]['width']=get_option(“{$s}_size_w”);//用于选项中设置的默认大小
如果(isset($\u wp\u附加图像大小[$s]['height']))
$size[$s]['height']=intval($\u wp\u其他图像大小[$s]['height']);//用于主题添加的大小
其他的
$sizes[$s]['height']=get_选项(“{$s}_size_h”);//用于选项中设置的默认大小
如果(isset($\u wp\u附加图像大小[$s]['crop']))
$sizes[$s]['crop']=intval($\u wp\u其他图像大小[$s]['crop']);//用于主题添加的大小
其他的
$sizes[$s]['crop']=get_选项(“{$s}_crop”);//用于选项中设置的默认大小
}
$this->image\u size=应用过滤器('intermediate\u image\u size\u advanc
$editor = wp_get_image_editor($file);
$editor = wp_get_image_editor($file);

if( ! is_wp_error( $editor ) ) {
    $editor->resize($width,$height,$crop);
    $dest_file = $editor->generate_filename();
    $editor->save($dest_file);
    return $dest_file;
}
else
{
    return $file;
}