Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #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,
    Christian

    #750918

    Let 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,
    Christian

    #751162

    Hi Christian,

    I think you haven’t added this global variable:

    global $avia_config;

    Hope this would help.

    Best regards,
    Nikko

    #751371

    Thanks 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,
    Christian

    #753507

    Hi,

    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,
    Ismael

    #753664

    Hi 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,
    Christian

    #754128

    Hey!

    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!
    Ismael

    #754292

    I 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,
    Christian

    #754802

    Hi!

    Great! Glad we could help. :)

    Cheers!
    Ismael

Viewing 9 posts - 1 through 9 (of 9 total)
  • The topic ‘undefined box_class’ is closed to new replies.