• 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 Reply Cancel reply

0 Comments
Inline Feedbacks
View all comments

Primary Sidebar

Popular

  • Testing Event Listeners In Jest (Without Using A Library)
  • How To Get The Hash of A File In Node.js
  • Waiting for an Element to Exist With JavaScript
  • Thoughts on the Flipper Zero
  • How To Get Last 4 Digits of A Credit Card Number in Javascript
  • How To Paginate An Array In Javascript
  • How To Mock uuid In Jest
  • How to Copy Files Using the Copy Webpack Plugin (without copying the entire folder structure)
  • Reliably waiting for network responses in Playwright
  • Wild Natural Deodorant Review

Recent Comments

  • Dwayne on Is Asking Developers How to Write FizzBuzz Outdated?
  • kevmeister68 on Is Asking Developers How to Write FizzBuzz Outdated?
  • Kevmeister68 on Start-Ups and Companies That Embrace Work From Anywhere Will Be More Likely to Survive the Coming Recession in 2023
  • kevmeister68 on What Would Get People Back Into the Office?
  • Dwayne on PHP Will Not Die

Copyright © 2023 · Dwayne Charrington · Log in

wpDiscuz