all repos — wp-ffpc @ e43294eb662ea645591169ca1b17522cfaa5e21c

initialize plugin at init to allow custom post type support
Harold Kyle harold@boxcarpress.com
Sat, 30 Mar 2013 00:54:08 -0400
commit

e43294eb662ea645591169ca1b17522cfaa5e21c

parent

99913abed19b8161427d0aad72c5b71b93e005f2

2 files changed, 39 insertions(+), 32 deletions(-)

jump to
M wp-ffpc-abstract.phpwp-ffpc-abstract.php

@@ -114,33 +114,10 @@

/* set the settings page link string */ $this->settings_link = $this->settings_slug . '?page=' . $this->plugin_settings_page; - /* initialize plugin, plugin specific init functions */ - $this->plugin_init(); - - /* get the options */ - $this->plugin_options_read(); - - /* setup plugin, plugin specific setup functions that need options */ - $this->plugin_setup(); - + add_action( 'init', array(&$this,'init')); add_action( 'admin_enqueue_scripts', array(&$this,'enqueue_admin_css_js')); - register_activation_hook( $this->plugin_file , 'plugin_activate' ); - register_deactivation_hook( $this->plugin_file , 'plugin_deactivate' ); - register_uninstall_hook( $this->plugin_file , 'plugin_uninstall' ); - - /* register settings pages */ - if ( $this->network ) - add_filter( "network_admin_plugin_action_links_" . $this->plugin_file, array( &$this, 'plugin_settings_link' ) ); - else - add_filter( "plugin_action_links_" . $this->plugin_file, array( &$this, 'plugin_settings_link' ) ); - - /* register admin init, catches $_POST and adds submenu to admin menu */ - if ( $this->network ) - add_action('network_admin_menu', array( &$this , 'plugin_admin_init') ); - else - add_action('admin_menu', array( &$this , 'plugin_admin_init') ); } /**

@@ -207,6 +184,36 @@ * to be extended

* */ abstract function plugin_hook_admin_init(); + + + public function init(){ + /* initialize plugin, plugin specific init functions */ + $this->plugin_init(); + + /* get the options */ + $this->plugin_options_read(); + + /* setup plugin, plugin specific setup functions that need options */ + $this->plugin_setup(); + + register_activation_hook( $this->plugin_file , 'plugin_activate' ); + register_deactivation_hook( $this->plugin_file , 'plugin_deactivate' ); + register_uninstall_hook( $this->plugin_file , 'plugin_uninstall' ); + + /* register settings pages */ + if ( $this->network ) + add_filter( "network_admin_plugin_action_links_" . $this->plugin_file, array( &$this, 'plugin_settings_link' ) ); + else + add_filter( "plugin_action_links_" . $this->plugin_file, array( &$this, 'plugin_settings_link' ) ); + + /* register admin init, catches $_POST and adds submenu to admin menu */ + if ( $this->network ) + add_action('network_admin_menu', array( &$this , 'plugin_admin_init') ); + else + add_action('admin_menu', array( &$this , 'plugin_admin_init') ); + + + } /** * callback function to add settings link to plugins page
M wp-ffpc-class.phpwp-ffpc-class.php

@@ -136,17 +136,17 @@ $post_types = get_post_types( );

/* cache invalidation hooks */ foreach ( $post_types as $post_type ) { - add_action( 'new_to_publish_' .$post_type , array( $this->backend , 'clear' ), 0 ); - add_action( 'draft_to_publish' .$post_type , array( $this->backend , 'clear' ), 0 ); - add_action( 'pending_to_publish' .$post_type , array( $this->backend , 'clear' ), 0 ); - add_action( 'private_to_publish' .$post_type , array( $this->backend , 'clear' ), 0 ); - add_action( 'publish_' . $post_type , array( $this->backend , 'clear' ), 0 ); + add_action( 'new_to_publish_' .$post_type , array( &$this->backend , 'clear' ), 0 ); + add_action( 'draft_to_publish' .$post_type , array( &$this->backend , 'clear' ), 0 ); + add_action( 'pending_to_publish' .$post_type , array( &$this->backend , 'clear' ), 0 ); + add_action( 'private_to_publish' .$post_type , array( &$this->backend , 'clear' ), 0 ); + add_action( 'publish_' . $post_type , array( &$this->backend , 'clear' ), 0 ); } /* invalidation on some other ocasions as well */ - add_action( 'switch_theme', array( $this->backend , 'clear' ), 0 ); - add_action( 'deleted_post', array( $this->backend , 'clear' ), 0 ); - add_action( 'edit_post', array( $this->backend , 'clear' ), 0 ); + add_action( 'switch_theme', array( &$this->backend , 'clear' ), 0 ); + add_action( 'deleted_post', array( &$this->backend , 'clear' ), 0 ); + add_action( 'edit_post', array( &$this->backend , 'clear' ), 0 ); /* add filter for catching canonical redirects */ add_filter('redirect_canonical', 'wp_ffpc_redirect_callback', 10, 2);