0

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 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

2 Comments

I tried with condition and isset before but failed. Will try your idea when I reach home, @tuongpg.jz . Thank you.
That is great when heard that from you.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.