Initializing eo after ajax call

This topic contains 2 replies, has 2 voices, and was last updated by  Adrian Maleska 10 years, 4 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #8727

    I’m using the Central-theme that’s using ajax to loading pages. Unfortunately the makers don’t seem to go the usual worpress codex ajax-way
    so checks like the following one will fail:

    if (defined('DOING_AJAX') && DOING_AJAX) 

    Still I can do a general ajax check which works fine but I’m not sure how exactly and which eo files I should load. The code’s placed inside my configuration plugin.

      define( 'EVENT_ORGANISER_DIR', '../event-organiser/' );
    
      if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && 
        !empty($_SERVER['HTTP_X_REQUESTED_WITH']) && 
        strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest')
        { 
          require_once(EVENT_ORGANISER_DIR.'event-organiser.php');
        }

    Actually the only case where I have to initialize eo by myself is before calling the booking form via shortcode [event_booking_form]. The Datepicker isn’t there…

    Adrian Maleska
    #8729

    Central-theme is doing it wrong then I’m afraid 🙂 Ajax requests should go to ../wp-admin/admin-ajax.php (for frontend or admin originated ajax calls), as that loads WordPress properly.

    In any case to load Event Organiser, you must first load WordPress – in fact if you load WordPress it’ll automatically load Event Organiser (if activated).

    This what WordPress does it: https://github.com/WordPress/WordPress/blob/3.8-branch/wp-admin/admin-ajax.php

    • Bootstraps WP via wp-load.php
    • Sets appropriate headers
    • Triggers the appropriate reaction so plug-ins can respond.

    But obviously you’d need to determine where wp-load.php is in order to load it. If using a custom file to handle ajax then there’s no real point in implementing (3).

    But really this a massive but with the theme..

    Stephen Harris
    #8734

    Thank you Stephen for this interesting insights. I’m new to wp so I still have to learn what the right way is to do certain things. On my own old webpage I would just load the init php files and done. In this case it’s tougher. Fortunatelly the theme is doing one good thing (besides looking great) – it allows to exclude certain uri’s from being loaded . This is my option for now. I will fight against ajax an other day … after xmas 😉

    Adrian Maleska
Viewing 3 posts - 1 through 3 (of 3 total)
To enable me to focus on Pro customers, only users who have a valid license for the Pro add-on may post new topics or replies in this forum. If you have a valid license, please log-in or register an account using the e-mail address you purchased the license with. If you don't you can purchase one here. Or there's always the WordPress repository forum.