Last active
October 6, 2016 05:23
-
-
Save azhararmar/808e0d967655ae27522ea71f0272b5ca to your computer and use it in GitHub Desktop.
Wordpress Functions
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
<?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