Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/280.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 函数_存在,无法重新声明新函数_Php_Wordpress - Fatal编程技术网

Php 函数_存在,无法重新声明新函数

Php 函数_存在,无法重新声明新函数,php,wordpress,Php,Wordpress,我使用wp jalali wordpress插件,它有一个函数farsi_num。我使用这个函数,但是如果插件没有安装,这个函数是未定义的 我将以下代码放在functions.php中 但是当一个用户想要安装wp jalali插件时,我们有一个错误 致命错误:无法重新声明以前在中声明的farsi_num F:\xampp\htdocs\wordpress\wp content\themes\khoshkhabar\functions.php:54 在里面 F:\xampp\htdocs\word

我使用wp jalali wordpress插件,它有一个函数farsi_num。我使用这个函数,但是如果插件没有安装,这个函数是未定义的

我将以下代码放在functions.php中

但是当一个用户想要安装wp jalali插件时,我们有一个错误

致命错误:无法重新声明以前在中声明的farsi_num F:\xampp\htdocs\wordpress\wp content\themes\khoshkhabar\functions.php:54 在里面 F:\xampp\htdocs\wordpress\wp content\plugins\wp jalali\lib\deprecated_fns.php 在线119


在wp admin/plugins.php中,我理解您的问题。在文件deprecated_fns.php中引发的错误,而不是在functions.php中。因为前面包含functions.php。因此,您必须检查文件deprecated_fns.php中的函数_exits,或为函数中的函数使用其他名称。php

尝试使用添加过滤器:

在function.php中


在你的if语句周围加上一些卷曲的引号我用这段代码来服务器不要说函数_exists是unfind函数如果插件没有安装如果你所做的只是复制函数…为什么你要使用相同的函数名?当插件需要安装时有以下错误:致命错误:无法重新声明之前声明的farsi_num在F:\xampp\htdocs\wordpress\wp content\themes\khoshkhabar\functions.php中:在F:\xampp\htdocs\wordpress\wp content\plugins\wp jalali\lib\deprecated_fns.php的第119行,是否建议将此代码放入footer.php中!
if(!function_exists('farsi_num'))
function farsi_num( $val ) {
    return $val;
}
function pippin_show_fruits() {
    $fruits = array(
        'apples',
        'oranges',
        'kumkwats',
        'dragon fruit',
        'peaches',
        'durians'
    );
    $list = '<ul>';

    if(has_filter('pippin_add_fruits')) {
        $fruits = apply_filters('pippin_add_fruits', $fruits);
    }

    foreach($fruits as $fruit) :
        $list .= '<li>' . $fruit . '</li>';
    endforeach;

    $list .= '</ul>';

    return $list;
}
echo apply_filter('pippin_show_fruits');   //CALL FUNCTION
    function pippin_add_extra_fruits_plugin($fruits) {
        // the $fruits parameter is an array of all fruits from the pippin_show_fruits() function

        $extra_fruits = array(
            'plums',
            'kiwis',
            'tangerines',
            'pepino melons'
        );

        // combine the two arrays
        $fruits = array_merge($extra_fruits, $fruits);

        return $fruits;
    }
    add_filter('pippin_add_fruits', 'pippin_add_extra_fruits_plugin');