title: FullCalendar on Wordpress integration - wpdb and json issue
body: <p>I'm looking for help to use fullcalendar in Wordpress.</p>
  
  <p>I'm integrating a schedule from a custom table in phpmyadmin called wp_evenement</p>
  
  <p>So, I've two files</p>
  
  <p>One with template page, where the calendar is displaying and with the script from fullcalendar.
  This call an other file called 'events.php' where I'm trying to get json result from database.</p>
  
  <p>I tried to use $wpdb but it doesn't work (or I can't make it work).
  And I tried to connect to database with new PDO but it only works when I'm connected as admin...</p>
  
  <p>Does someone help me with global $wpdb solution ? </p>
  
  <p>Here is my code :</p>
  
  <p><strong>Template :</strong></p>
  
  <pre><code>&lt;div id='calendar' style="margin-top:100px;"&gt;&lt;/div&gt;    
  &lt;script&gt;
              var $ = jQuery;
              $(document).ready(function() {
                var date = new Date();
                var d = date.getDate();
                var m = date.getMonth();
                var y = date.getFullYear();
  
  
                var calendar = $('#calendar').fullCalendar({
                 editable: true,
                 header: {
                  left: 'prev,next today',
                  center: 'title',
                  right: 'month,agendaWeek,agendaDay'
                 },
  
  
                 events: "https://www.exemple.org/wp-content/mytheme/fullcalendar/events.php/",
  
  
                 eventRender: function(event, element, view) {
                  if (event.allDay === 'true') {
                   event.allDay = true;
                  } else {
                   event.allDay = true;
                  }
                 }
  
                });
  
               });
  
              &lt;/script&gt;
  </code></pre>
  
  <p><strong>events.php</strong></p>
  
  <pre><code>  &lt;?php
  
  
  // List of events
   $json = array();
  
   // Query that retrieves events
   $requete = "SELECT * FROM wp_evenement ORDER BY id";
  
   // connection to the database
   try {
   $bdd = new PDO('mysql:host=***.mysql.db;dbname=****', '***', '***');
   } catch(Exception $e) {
    exit('Unable to connect to database.');
   }
   // Execute the query
   $resultat = $bdd-&gt;query($requete) or die(print_r($bdd-&gt;errorInfo()));
  
   // sending the encoded result to success page
   echo json_encode($resultat-&gt;fetchAll(PDO::FETCH_ASSOC));
  
  ?&gt;
  </code></pre>
  
  <p><strong>Try with $wpdb</strong>
  Works !</p>
  
  <pre><code>    &lt;?php
  
      include_once $_SERVER['DOCUMENT_ROOT'] . '/wp-config.php';
      include_once $_SERVER['DOCUMENT_ROOT'] . '/wp-load.php';
      include_once $_SERVER['DOCUMENT_ROOT'] . '/wp-includes/wp-db.php';
  
  
      // List of events
      $json = array();
  
      // Query that retrieves events
      global $wpdb;
      $requete = "SELECT * FROM wp_evenement ORDER BY id";
  
      // Execute the query
      $resultat = $wpdb-&gt;get_results($requete);
  
      // sending the encoded result to success page
      echo json_encode($resultat);
  
  ?&gt;
  </code></pre>