Last active
August 6, 2019 17:37
-
-
Save karlazz/a8caeab9f44cf9b3b712056eb27f80fc to your computer and use it in GitHub Desktop.
Gutenberg shortcode demo code
This file contains hidden or 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
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