initialize plugin at init to allow custom post type support
This commit is contained in:
parent
99913abed1
commit
e43294eb66
2 changed files with 39 additions and 32 deletions
|
@ -114,33 +114,10 @@ if (!class_exists('WP_Plugins_Abstract')) {
|
|||
/* 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') );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -208,6 +185,36 @@ if (!class_exists('WP_Plugins_Abstract')) {
|
|||
*/
|
||||
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
|
||||
*
|
||||
|
|
|
@ -136,17 +136,17 @@ if ( ! class_exists( 'WP_FFPC' ) ) {
|
|||
|
||||
/* 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);
|
||||
|
|
Loading…
Reference in a new issue