Last active

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

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 essentials so the reader can understand the technique without concern for the best plugin code architecture which is a much bigger question. If you'd like to learn more about plugin code architecture check out our blog at HardcoreWP.com.

View child-class-plugin-loader.php
1 2 3 4 5 6 7 8 9 10 11
<?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.
}
View child-class-plugin-loader.php
1 2 3 4 5 6 7 8 9 10 11 12
<?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';
}
View child-class-plugin-loader.php
1 2 3 4 5 6 7 8 9
<?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
Something went wrong with that request. Please try again.