From 5e207d6e3c6c2bac0e00be9e54758ecd69255b73 Mon Sep 17 00:00:00 2001 From: Marko Heijnen Date: Sun, 22 Nov 2015 13:13:40 +0100 Subject: [PATCH] Only load features on our screens. See #42 --- tabify-edit-screen.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/tabify-edit-screen.php b/tabify-edit-screen.php index 69ce7aa..72b9852 100644 --- a/tabify-edit-screen.php +++ b/tabify-edit-screen.php @@ -49,14 +49,24 @@ public function load() { new Tabify_Edit_Screen_Edit_Screen(); new Tabify_Edit_Screen_Settings_Page(); - $this->load_features(); + add_action( 'current_screen', array( $this, 'load_features' ), 1 ); } public function load_translation() { load_plugin_textdomain( 'tabify-edit-screen', false, basename( dirname( __FILE__ ) ) . '/languages' ); } - private function load_features() { + public function load_features( $screen ) { + $valid_screens = array( + 'settings_page_tabify-edit-screen', + 'post', + 'media' + ); + + if ( ! in_array( $screen->base, $valid_screens ) ) { + return; + } + $features = array( 'detection', 'permissions'