Book Image

WordPress Web Application Development

By : Rakhitha Nimesh Ratnayake
Book Image

WordPress Web Application Development

By: Rakhitha Nimesh Ratnayake

Overview of this book

Table of Contents (19 chapters)
WordPress Web Application Development Second Edition
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Adding the template loader dependencies


We have four classes in the main plugin that depend on the template loader and we have only checked the dependency for the WPWA_Custom_Post_Types_Manager class. Let's define the dependencies for the remaining classes. The following code contains the current code for the wpwa_plugin_init function inside the class-wpwa-portfolio-manager.php file:

function wpwa_plugin_init(){
  if(!class_exists('WPWA_Template_Loader')){
    add_action( 'admin_notices', 'wpwa_plugin_admin_notice' );
  }else{
    global $wpwa_custom_post_types_manager;
    $wpwa_custom_post_types_manager = new WPWA_Custom_Post_Types_Manager();
  }
}

Now, let's add the remaining dependencies inside this function, as shown in the following code:

function wpwa_plugin_init(){
  if(!class_exists('WPWA_Template_Loader')){
    add_action( 'admin_notices', 'wpwa_plugin_admin_notice' );
  }else{
    global $wpwa_custom_post_types_manager, $wpwa_theme, $wpwa_settings, $backbone_projects ;
    $wpwa_custom_post_types_manager...