Skip to content

Instantly share code, notes, and snippets.

@mikeschinkel
Last active December 11, 2015 09:59
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save mikeschinkel/4584006 to your computer and use it in GitHub Desktop.
Answering the question on Quora: "How do I specify the loading order of plugins?" by changing the question to "How do you ensure that you declare your child class after the plugin's class is declared?" - http://www.quora.com/WordPress-Plugin-Development/How-do-I-specify-the-loading-order-of-plugins. Note I've boiled this example down to its bare…
<?php
/**
* class_exists() is a fail-safe.
*/
if ( ! class_exists( 'Parent_Class_Plugin' ) )
return;
class Child_Class_Plugin extends Parent_Class_Plugin {
// Your plugin code goes here.
}
<?php
/**
* Plugin Name: @Child Plugin
*/
add_action( 'plugins_loaded', 'child_class_plugin_loader' );
function child_class_plugin_loader() {
include dirname( __FILE__ ) . '/child-class-plugin-loader.php';
}
<?php
/**
* Plugin Name: @Parent Plugin
*/
class Parent_Class_Plugin {
// Their plugin code went here.
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment