0
votes

I have the following code for a php admin. This code placed on my WordPress theme, related to a plugin:

$custom_css_style = mytheme_custom_css();
/* Enqueue The Font CSS */
$custom_font_css_style = upfw_enqueue_font_css();
//add custom style
wp_add_inline_style( 'main-stylesheet', $custom_css_style );
wp_add_inline_style( 'main-stylesheet', $custom_font_css_style );

Everything working fine, but when plugin deactivate, I got 2 error:

Fatal error: Call to undefined function upfw_enqueue_font_css() in D:\mytheme\SERVER-mytheme\InstantWP_4.3.1\iwpserver\htdocs\wordpress\wp-content\themes\mytheme\library\bones.php on line 198

line 198 is:

 $custom_font_css_style = upfw_enqueue_font_css();

and the second notify:

Notice: Undefined variable: custom_font_css_style in D:\mytheme\SERVER-mytheme\InstantWP_4.3.1\iwpserver\htdocs\wordpress\wp-content\themes\mytheme\library\bones.php on line 201

line 201 is:

wp_add_inline_style( 'main-stylesheet', $custom_font_css_style );

Need an idea and help to fix my problem.

Thanks for any helps.

Regards

1

1 Answers

1
votes

I think you just need to check is that function exists before do more stuff.

So the example code can be :

$custom_css_style = mytheme_custom_css();

//add custom style
wp_add_inline_style( 'main-stylesheet', $custom_css_style );

/* Enqueue The Font CSS */
if( function_exists('upfw_enqueue_font_css') )
{
    $custom_font_css_style = upfw_enqueue_font_css();
    wp_add_inline_style( 'main-stylesheet', $custom_font_css_style );
}

Hope that make sense.