• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

I Like Kill Nerds

The blog of Australian Front End / Aurelia Javascript Developer & brewing aficionado Dwayne Charrington // Aurelia.io Core Team member.

  • Home
  • Aurelia 2
  • Aurelia 1
  • About
  • Aurelia 2 Consulting/Freelance Work

How to debug the output from within WordPress filters

Wordpress · August 25, 2022

WordPress has a great actions and filters system allowing you to create injection points for modifying parts of your code (especially for plugin authors). However, you probably arrived here because you’re trying to echo or print_r something from within a filter and not seeing the output.

Because WordPress operates on a post/redirect approach, it means you’re not seeing the output because the page has been reloaded. You need to kill the script from within your filter callback function to see the output.

add_filter('sh_pre_process_body', function($body, $assets_path, $article_file) {
	$load_file = file_get_contents($article_file);
  
  	echo $assets_path;
  
  	die;

	return shand_fix_content_paths($assets_path, $load_file);
}, 10, 3);

By using die you will be able to see the output or other equivalents that kill script execution. However, the result will mean your site will break until you remove this script killer.

Dwayne

Leave a ReplyCancel reply

0 Comments
Inline Feedbacks
View all comments

Primary Sidebar

Popular

  • Handling Errors with the Fetch API
  • How To Get The Hash of A File In Node.js
  • How To Make Slime
  • Wild Natural Deodorant Review
  • A review of the Neural DSP Quad Cortex: is this the future of amp-modelling?

Copyright © 2023 · Dwayne Charrington · Log in

wpDiscuz