Created
December 2, 2014 22:27
-
-
Save elimn/d3483854e8e9399e449e to your computer and use it in GitHub Desktop.
MT | TEC | Tribe Query Debug
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Checks the URL for the debug parameter | |
// example.com/event/event-name/?tribe_query_debug=true | |
function tribe_events_pre_get_posts_dumper ($query) { | |
$show_debug_info = isset($_GET['tribe_query_debug']) ? $_GET['tribe_query_debug'] : false; | |
if(($show_debug_info == "true" && $query->is_main_query() === true) || $show_debug_info == "full") { | |
echo "<h3><Tribe Events Query></h3>"; | |
tribe_spit_it_out($query); | |
add_filter('the_posts', 'tribe_dump_return_query', 100, 1); | |
} | |
} | |
add_action('pre_get_posts', 'tribe_events_pre_get_posts_dumper'); | |
function tribe_dump_return_query($query) { | |
echo '<p>Query Results:</p>'; | |
tribe_spit_it_out($query); | |
echo '<p>is_404() = </p>'; | |
var_dump(is_404()); | |
echo '<h3></Tribe Events Query></h3>'; | |
// Only run this once | |
remove_filter('the_posts', 'tribe_dump_return_query', 100, 1); | |
return $query; | |
} | |
function tribe_spit_it_out($var_for_dumping) { | |
echo '<pre>'; | |
var_dump($var_for_dumping); | |
echo '</pre>'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment