Skip to content

Instantly share code, notes, and snippets.

@azhararmar
Last active October 6, 2016 05:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save azhararmar/808e0d967655ae27522ea71f0272b5ca to your computer and use it in GitHub Desktop.
Save azhararmar/808e0d967655ae27522ea71f0272b5ca to your computer and use it in GitHub Desktop.
Wordpress Functions
<?php
// SQL Logger
function sql_logger() {
global $wpdb;
$log_file = fopen(ABSPATH.'/sql_log.txt', 'a');
fwrite($log_file, "//////////////////////////////////////////\n\n" . date("F j, Y, g:i:s a")."\n");
foreach($wpdb->queries as $q) {
fwrite($log_file, $q[0] . " - ($q[1] s)" . "\n\n");
}
fclose($log_file);
}
add_action('shutdown', 'sql_logger');
// Add shortcode
function function_callback_name($atts) { }
add_shortcode('shortcode_name', 'function_callback_name');
// Load custom js from child theme
function load_scripts() {
wp_enqueue_script(
'custom',
get_stylesheet_directory_uri() . '/custom.js',
array( 'jquery' )
);
}
add_action( 'wp_enqueue_scripts', 'load_scripts' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment