Skip to content

Instantly share code, notes, and snippets.

@webaware
Created March 2, 2017 21:06
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 webaware/7d04f336633a3d150ded8501c2a32b4e to your computer and use it in GitHub Desktop.
Save webaware/7d04f336633a3d150ded8501c2a32b4e to your computer and use it in GitHub Desktop.
Demonstrate a WooCommerce extension that doesn't catch the `woocommerce_loaded` hook because it fires before the extension had loaded
<?php
/*
Plugin Name: Yams for Woo
Description: A plugin that loads after WooCommerce, so it misses the woocommerce_loaded action
Version: 1
Author: WebAware
Author URI: https://shop.webaware.com.au/
*/
error_log(basename(__FILE__));
error_log("active non-mu plugins =\n" . print_r(wp_get_active_and_valid_plugins(),1));
add_action('plugins_loaded', function() {
error_log(basename(__FILE__) . " plugins_loaded");
});
add_action('woocommerce_loaded', function() {
error_log(basename(__FILE__) . " woocommerce_loaded");
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment