-
AuthorPosts
-
February 20, 2017 at 6:49 pm #749516
Hello,
I’m developing a small plugin which displays a 404 page instead of wp-login page to visitors coming from some user defined countries.
Everything works fine, except for this notice (viewable only with WPdebug set to true) and i guess it is related to the way Enfold handles the style:
Notice: Undefined index: box_class in /var/www/vhosts/christiangatti.it/one.christiangatti.it/wp-content/themes/enfold/header.php on line 6
Could you please help me to get rid of it?
Thanks,
ChristianFebruary 23, 2017 at 1:48 pm #750918Let me be more specific: of course I can define a box_class index and forget about the notice, but the fact is that the style is someway not fully loaded so that the 404 page is not rendered as correctly as it should. To avoid this problem, I need to know how to deal with style when a 404 page is forced to be displayed with:
status_header(404);
global $wp_query;
$wp_query->set_404();
include(get_query_template( ‘404’ ));
exit;Thanks in advance,
ChristianFebruary 24, 2017 at 2:15 am #751162Hi Christian,
I think you haven’t added this global variable:
global $avia_config;
Hope this would help.
Best regards,
NikkoFebruary 24, 2017 at 12:47 pm #751371Thanks Nikko, but unfortunately the suggested procedure doesn’t solve my problem: “global $avia_config” is already declared in header.php which is correctly invoked and included.
Regards,
ChristianMarch 1, 2017 at 8:36 am #753507Hi,
What kind of plugin are you developing? I’m sorry but we can’t help much because we have no idea how you created the plugin and what it’s supposed to do. If you can provide more info or give access to the plugin files, we’ll try to debug the issue.
Best regards,
IsmaelMarch 1, 2017 at 1:15 pm #753664Hi Ismael,
thanks for spending your time to help me to solve this weird problem.
My plugin is very simple: it checks if the current url contains “wp-login.php” and in some conditions it forces a 404 page (through the code written above). The above process is included into a WordPress ‘init’ function.
That’s all.Bye,
ChristianMarch 2, 2017 at 8:06 am #754128Hey!
What if you use the “wp_loaded” hook instead of “init”? Or the “after_setup_theme” hook.
// https://codex.wordpress.org/Plugin_API/Action_Reference
Cheers!
IsmaelMarch 2, 2017 at 11:40 am #754292I was sure to have tried it before, with no luck, but clearly I was wrong because your suggestion works flawlessly!
Thanks a lot Ismael, ‘wp_loaded’ solves my problem.Regards,
ChristianMarch 3, 2017 at 5:33 am #754802 -
AuthorPosts
- The topic ‘undefined box_class’ is closed to new replies.