Reputation: 83
I'm developing a Wordpress plugin, and updating it through Wordpress' SVN. When entering the function to call back function getLogoUrl
, I get this error:
Fatal error: Class 'plugin' not found in /customers/1/6/2/carpe-noctem.no/httpd.www/wp-content/plugins/logo-switcher/inc/helpers.php on line 21
The issue is that the class doesn't exist at all, and that the file is long gone deleted. The code in that file has been moved to a different file, yet the error shows up for a file that has been deleted from the system.
This is the file that has the class that should be called back.
<?php
/*
* This file is part of the logo-switcher package.
* (c) Iversen - Carpe Noctem <[email protected]>
*
* 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;
Any help to get?
Upvotes: 0
Views: 1281
Reputation: 71
Use not class_exists()
if (!class_exists('class_Logo_Switcher')) {
class class_Logo_Switcher { }
}
Upvotes: 0