MyBB Community Forums
[1.8] Convenient Script for Displaying $mybb and $theme - Printable Version

+- MyBB Community Forums (https://community.mybb.com)
+-- Forum: Extensions (https://community.mybb.com/forum-201.html)
+--- Forum: Plugins (https://community.mybb.com/forum-73.html)
+---- Forum: Plugin Development (https://community.mybb.com/forum-68.html)
+---- Thread: [1.8] Convenient Script for Displaying $mybb and $theme (/thread-210859.html)



[1.8] Convenient Script for Displaying $mybb and $theme - fizz - 2017-06-03

This simple little script will display all the contents of the $mybb and $theme globals, which I find extremely useful when developing so you don't have to print_r and find what you're looking for. I always like having something like this on hand when I'm making plugins so I figured I'd post it here to help new (or seasoned and maybe lazy Big Grin ) developers. Just copy this code into a file named test.php or something and put it in the root directory of your board (name doesn't matter, just make sure it's a .php and is in the board's root directory).
<?php
/**
* REMEMBER TO DELETE THIS FILE ON LIVE BOARDS (OR AT LEAST COMMENT OUT DEFINE(IN_MYBB))
* Forum thread: https://community.mybb.com/thread-210859.html
**/
define('IN_MYBB', 1);

require_once("./global.php");

// **If you really need to use this on a live board, change the 1 to your uid and uncomment the line below**
# ($mybb->user['uid'] === 1) ?: die();

// Just add a pound symbol (#) before either of these lines to hide the output
showMybb();
showTheme();

function showMybb()
{
    global $mybb;
    echo "<b>\$mybb object:</b>\n";
    print("<pre>".print_r($mybb, true)."</pre>");
}

function showTheme()
{
    global $theme;
    echo "<b>\$theme</b>:\n";
    print("<pre>".print_r($theme, true)."</pre>");
}


***Make sure you either delete this file or comment out line 5
define('IN_MYBB', 1);
on a live board because this file poses a huge security risk if someone else finds it!***

This thread also displays some of the more commonly used properties so you don't have to spool through the whole list if you think you know what you're looking for.

Hope this is helpful! Any suggestions for edits/additions are welcome!

-fizz


RE: Convenient Script for Displaying $mybb and $theme - WallBB - 2017-06-03

I think this has been shared a lot before as well but none the less glad you shared it for 1.8 series. Smile


RE: Convenient Script for Displaying $mybb and $theme - fizz - 2017-06-03

(2017-06-03, 04:52 PM)WallBB Wrote: I think this has been shared a lot before as well but none the less glad you shared it for 1.8 series. Smile

Oh I'm sure it has in a variety of ways, but as you said nice making one for 1.8 and getting it back to the front of the development section. I at least wanted to split the print_r into functions so users could easily comment out blocks for visibility.


RE: [1.8] Convenient Script for Displaying $mybb and $theme - Tactrus - 2017-06-22

First I've heard of this. This should be a pinned thread, thanks for the share!


RE: [1.8] Convenient Script for Displaying $mybb and $theme - fizz - 2017-07-08

(2017-06-22, 09:06 AM)Tactrus Wrote: First I've heard of this. This should be a pinned thread, thanks for the share!

Happy to help! Feel free to suggest other useful snippets if you come across them!