Last active
October 19, 2023 01:10
-
-
Save haze83/3120675bc51dba66a4bf187ede77d08b to your computer and use it in GitHub Desktop.
WP/WC Hooks
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 | |
function debug_wp_rewrite_dump(&$wp) { | |
echo '<pre>'; | |
global $wp_rewrite; | |
echo '<h2>rewrite rules</h2>'; | |
echo var_export($wp_rewrite->wp_rewrite_rules(), true); | |
echo '<h2>permalink structure</h2>'; | |
echo var_export($wp_rewrite->permalink_structure, true); | |
echo '<h2>page permastruct</h2>'; | |
echo var_export($wp_rewrite->get_page_permastruct(), true); | |
echo '<h2>matched rule and query</h2>'; | |
echo var_export($wp->matched_rule, true); | |
echo '<h2>matched query</h2>'; | |
echo var_export($wp->matched_query, true); | |
echo '<h2>request</h2>'; | |
echo var_export($wp->request, true); | |
global $wp_the_query; | |
echo '<h2>the query</h2>'; | |
echo var_export($wp_the_query, true); | |
echo '</pre>'; | |
} | |
add_action('parse_request', 'debug_wp_rewrite_dump'); |
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 | |
$logger = wc_get_logger(); | |
$logger_context = ['source' => 'f4t']; | |
$logger->debug(wc_print_r(['key' => 'value'], true), $logger_context); |
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 | |
add_action('wp_mail_failed', 'f4t_mail_error_log', 10, 1); | |
function f4t_mail_error_log($wp_error) { | |
$fn = WP_CONTENT_DIR . DS . 'mail.log'; // say you've got a mail.log file in your wp-content dir | |
$fp = fopen($fn, 'a'); | |
fputs($fp, date('[Y-m-d H:i:s] ') . 'Mailer error: ' . $wp_error->get_error_message() ."\n"); | |
fclose($fp); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment