Skip to content

Instantly share code, notes, and snippets.

@karlazz
Last active August 6, 2019 17:37
Show Gist options
  • Save karlazz/a8caeab9f44cf9b3b712056eb27f80fc to your computer and use it in GitHub Desktop.
Save karlazz/a8caeab9f44cf9b3b712056eb27f80fc to your computer and use it in GitHub Desktop.
Gutenberg shortcode demo code
add_shortcode( 'gutenberg_test', 'send_request' ); // for testing
function send_request() {
trace('GB test underway');
$value=rand(10,100);
return 'I ran';
}
//* add a trace file
$upload_dir = wp_upload_dir();
define('TRACEFILE', $upload_dir['basedir'] . '/trace.log');
function trace($log) {
$prefix = current_time( 'mysql' ) . ": " ;
$suffix = "\n" ;
if ( is_array( $log ) || is_object( $log ) ) {
error_log( $prefix, 3, TRACEFILE);
error_log( print_r( $log, true ) , 3, TRACEFILE );
error_log( $suffix, 3, TRACEFILE ) ;
}
else {
error_log( $prefix . $log . $suffix, 3, TRACEFILE );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment