From c8f4f620d9e7d6af24128839c0ce9c2c6c2af799 Mon Sep 17 00:00:00 2001 From: Harold Kyle Date: Thu, 28 Mar 2013 00:11:01 -0400 Subject: [PATCH] squelched various php and wp notices and warnings, enqueuing admin css and js better --- wp-ffpc-abstract.php | 40 ++++++++++++++++++++++------------------ wp-ffpc-acache.php | 2 +- wp-ffpc-backend.php | 2 +- wp-ffpc-class.php | 9 +++++---- 4 files changed, 29 insertions(+), 24 deletions(-) diff --git a/wp-ffpc-abstract.php b/wp-ffpc-abstract.php index 2c58953..875f9e6 100644 --- a/wp-ffpc-abstract.php +++ b/wp-ffpc-abstract.php @@ -123,26 +123,12 @@ if (!class_exists('WP_Plugins_Abstract')) { /* setup plugin, plugin specific setup functions that need options */ $this->plugin_setup(); - /* add admin styling */ - if( is_admin() ) { - /* jquery ui tabs is provided by WordPress */ - wp_enqueue_script ( "jquery-ui-tabs" ); - wp_enqueue_script ( "jquery-ui-slider" ); - /* additional admin styling */ - $css_handle = $this->plugin_constant . '-admin-css'; - $css_file = $this->plugin_constant . '-admin.css'; - if ( @file_exists ( $this->plugin_dir . $css_file ) ) - { - $css_src = $this->plugin_url . $css_file; - wp_register_style( $css_handle, $css_src, false, false, 'all' ); - wp_enqueue_style( $css_handle ); - } - } + add_action( 'admin_enqueue_scripts', array(&$this,'enqueue_admin_css_js')); - register_activation_hook( $this->plugin_file , array( $this , 'plugin_activate') ); - register_deactivation_hook( $this->plugin_file , array( $this , 'plugin_deactivate') ); - register_uninstall_hook( $this->plugin_file , array( $this , 'plugin_uninstall') ); + 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 ) @@ -234,6 +220,23 @@ if (!class_exists('WP_Plugins_Abstract')) { return $links; } + /* add admin styling */ + public function enqueue_admin_css_js(){ + /* jquery ui tabs is provided by WordPress */ + wp_enqueue_script ( "jquery-ui-tabs" ); + wp_enqueue_script ( "jquery-ui-slider" ); + + /* additional admin styling */ + $css_handle = $this->plugin_constant . '-admin-css'; + $css_file = $this->plugin_constant . '-admin.css'; + if ( @file_exists ( $this->plugin_dir . $css_file ) ) + { + $css_src = $this->plugin_url . $css_file; + wp_register_style( $css_handle, $css_src, false, false, 'all' ); + wp_enqueue_style( $css_handle ); + } + } + /** * deletes saved options from database */ @@ -462,6 +465,7 @@ if (!class_exists('WP_Plugins_Abstract')) { else $check_disabled = false; + $opt = ''; foreach ($elements as $value => $name ) { //$disabled .= ( @array_key_exists( $valid[ $value ] ) && $valid[ $value ] == false ) ? ' disabled="disabled"' : ''; $opt .= '