0

I have created a simplistic PHP playground plugin to run PHP without saving it, but if I write global $wpdb; in the playground it's null. I have tried including it before the code actually ran but it's still null.

This is my code that executes the PHP code:

<?php

if ( isset( $_POST['code'] ) ) {
    ob_start();
    eval( $_POST['code'] );
    $output = ob_get_contents();
    ob_end_clean();
    echo $output;
}

So, how I am supposed to include $wpdb to be able to use it within the PHP editor?

Maramal
  • 3,145
  • 9
  • 46
  • 90

0 Answers0