Last active
March 2, 2018 19:56
-
-
Save justinswelch/1fc02241006843fd1f08452634ea6566 to your computer and use it in GitHub Desktop.
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 | |
// Log Beaver Builder status notes to js console | |
// Reference: /bb-plugin/classes/class-fl-builder-model.php | |
add_action( 'wp_footer', 'pxb_log_bb_status_to_console' ); | |
function pxb_log_bb_status_to_console() { | |
if( ! WP_DEBUG ) return; | |
// defaults | |
$bb_status = array( | |
'enabled_status' => 'not enabled', | |
'active_status' => 'not active', | |
); | |
// check if builder is enabled (used on the current page) | |
if( FLBuilderModel::is_builder_enabled() ) { | |
$bb_status[ 'enabled_status' ] = 'enabled'; | |
// is builder UI currently active? | |
if( FLBuilderModel::is_builder_active() ) | |
$bb_status[ 'active_status' ] = 'active'; | |
// is this a BB template? | |
if( is_singular( 'fl-builder-template' ) ) | |
$bb_status[ 'is_bb_template' ] = 'post is a BB template'; | |
} | |
// output results to js console | |
echo '<script>'; | |
printf( 'console.log("builder is %s");', $bb_status[ 'enabled_status' ] ); | |
printf( 'console.log("builder UI is %s");', $bb_status[ 'active_status' ] ); | |
printf( 'console.log("%s");', $bb_status[ 'is_bb_template' ] ); | |
echo '</script>'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment