致命错误:类';插件';在';路径/to/file';-Wordpress插件开发


Fatal error: Class 'plugin' not found in 'path/to/file' - Wordpress plugin development

我正在开发一个Wordpress插件,并通过Wordpress的SVN进行更新。当进入函数以回调函数getLogoUrl时,我得到这个错误:

致命错误:在中找不到类"plugin"/客户/1/6/2/capp-noctem.no/httpd.www/wp-content/plugins/log-switcher/inc/helpers.php在线21

问题是该类根本不存在,并且该文件早已被删除。该文件中的代码已移动到另一个文件,但对于已从系统中删除的文件,会显示错误。

这是一个包含应该回调的类的文件。

<?php
/*
 * This file is part of the logo-switcher package.
 * (c) Iversen - Carpe Noctem <info@carpe-noctem.no>
 * 
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
// Block direct access
if(!defined('ABSPATH'))exit;
/**
 * Logo Switcher
 *
 * @author Iversen - Carpe Noctem
 */
if (class_exists('class_Logo_Switcher')) {
class class_Logo_Switcher
{
    /**
     * Add Theme Customize Support
     * 
     * @param WP_Customize_Manager $manager
     */
    public static function addThemeCustomizeSupport('WP_Customize_Manager $manager)
    {
        // add the image filed
        $manager->add_setting('logo_switcher');
        $manager->add_control(new 'WP_Customize_Image_Control($manager, 'logo_switcher', array(
            'label' => __('Choose your logo', 'logo-switcher')
            , 'section' => 'title_tagline'
            , 'description' => __('Note: Depending on the current theme setting, the choosen logo might be used on the login page.', 'logo-switcher')
        )));
    }
    /**
     * Add the logo to the login page
     * 
     * Change the logo in the login page and also change the url href and title
     * 
     * @return boolean false if the optioh is disabled
     */
    public static function addLoginSupport()
    {
        $setting = self::getOptions();
        if (!$setting['enable-on-login-page'])
            return false;
        add_filter('login_headerurl', function() {
            return get_bloginfo('url');
        });
        add_filter('login_headertitle', function() {
            return get_bloginfo('description');
        });
        $url = static::getLogoUrl();
        if (!empty($url)) {
            list($width, $height, $type, $attr) = getimagesize($url);
            print(
                    '<style type="text/css">'
                    . ".login h1 a {background-image: url('{$url}'); background-size: 100%; width:100%; height:{$height}px;}</style>"
            );
        } else {
            print(
                    '<style type="text/css">.login h1 a {display:none}</style>'
            );
        }
    }
    /**
     * Get options
     *  
     * @return array
     */
    public static function getOptions()
    {
        $default = array(
            // path for default logo image 
            'default' => '/logo.png',
            //the logo url (default to home page)
            'url' => home_url('/'),
            // the logo desciption default to (get_bloginfo('name', 'display')) 
            'description' => get_bloginfo('name', 'display'),
            // enable logo display on the login page
            'enable-on-login-page' => true,
        );
        return apply_filters('logo-switcher.options', $default);
    }
    /**
     * Get the logo url
     * 
     * @return string
     */
    public static function getLogoUrl()
    {
        $setting = self::getOptions();
        ($result = get_theme_mod('logo_switcher')) && !empty($result) ?
                        $result : $setting['default'];
        return esc_url($result);
    }
    /**
     * Print logo url
     * 
     * @param string $path the url target
     * @param string $description the logo image description
     *
     */
    public static function printLogo($path = null, $description = null)
    {
        $setting = static::getOptions();
        $path = !empty($path) ? $path : $setting['url'];
        $description = !empty($description) ? $description : $setting['description'];
        echo sprintf(
                '<a href="%1$s" title="%2$s" rel="home"><img src="%3$s" alt="%2$s"></a>'
                , esc_url($path)
                , esc_attr($description)
                , esc_url(static::getLogoUrl())
        );
    }
}
}
$Logo_Switcher_Plugin = new class_Logo_Switcher;

有什么需要帮助的吗?

不使用class_exists()

if (!class_exists('class_Logo_Switcher')) {
class class_Logo_Switcher { }
}