all repos — wp-ffpc @ 97dca3d3fceea5704334893f57ebcc754667e71a

Merge pull request #1 from haroldkyle/master

squelched various php and wp notices and warnings, enqueuing admin css and js better
Peter Molnar hello@petermolnar.eu
Thu, 28 Mar 2013 02:29:46 -0700
commit

97dca3d3fceea5704334893f57ebcc754667e71a

parent

67b9d0b3f64a32309adcb8fb106cd62403e3736a

4 files changed, 29 insertions(+), 24 deletions(-)

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

@@ -123,26 +123,12 @@

/* 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 )

@@ -232,6 +218,23 @@ public function plugin_settings_link ( $links ) {

$settings_link = '<a href="' . $this->settings_link . '">' . __( 'Settings', $this->plugin_constant ) . '</a>'; array_unshift( $links, $settings_link ); 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 ); + } } /**

@@ -462,6 +465,7 @@ $check_disabled = true;

else $check_disabled = false; + $opt = ''; foreach ($elements as $value => $name ) { //$disabled .= ( @array_key_exists( $valid[ $value ] ) && $valid[ $value ] == false ) ? ' disabled="disabled"' : ''; $opt .= '<option value="' . $value . '" ';
M wp-ffpc-acache.phpwp-ffpc-acache.php

@@ -250,7 +250,7 @@ if ( get_option ( 'default_ping_status' ) == 'open' )

$meta['pingback'] = get_bloginfo('pingback_url'); /* sync all http and https requests if enabled */ - if ( $config['sync_protocols'] == '1' ) { + if ( isset( $config['sync_protocols'] ) && $config['sync_protocols'] == '1' ) { if ( isset( $_SERVER['HTTP_X_FORWARDED_PROTO'] ) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' ) $_SERVER['HTTPS'] = 'on';
M wp-ffpc-backend.phpwp-ffpc-backend.php

@@ -305,7 +305,7 @@ /* error level is real problem, needs to be displayed on the admin panel */

//throw new Exception ( $message ); break; default: - if ( function_exists( 'syslog' ) && $this->options['debug'] ) + if ( function_exists( 'syslog' ) && isset($this->options['debug']) && $this->options['debug'] ) syslog( $log_level , self::plugin_constant . " with " . $this->options['cache_type'] . ' ' . $message ); break; }
M wp-ffpc-class.phpwp-ffpc-class.php

@@ -242,28 +242,28 @@

/** * if options were saved, display saved message */ - if ($_GET[ self::key_save ]=='true' || $this->status == 1) : ?> + if (isset($_GET[ self::key_save ]) && $_GET[ self::key_save ]=='true' || $this->status == 1) : ?> <div class='updated settings-error'><p><strong><?php _e( 'Settings saved.' , $this->plugin_constant ) ?></strong></p></div> <?php endif; /** * if options were delete, display delete message */ - if ($_GET[ self::key_delete ]=='true' || $this->status == 2) : ?> + if (isset($_GET[ self::key_delete ]) && $_GET[ self::key_delete ]=='true' || $this->status == 2) : ?> <div class='error'><p><strong><?php _e( 'Plugin options deleted.' , $this->plugin_constant ) ?></strong></p></div> <?php endif; /** * if options were saved */ - if ($_GET[ self::key_flush ]=='true' || $this->status == 3) : ?> + if (isset($_GET[ self::key_flush ]) && $_GET[ self::key_flush ]=='true' || $this->status == 3) : ?> <div class='updated settings-error'><p><strong><?php _e( "Cache flushed." , $this->plugin_constant ); ?></strong></p></div> <?php endif; /** * if options were saved, display saved message */ - if ($_GET[ self::key_precache ]=='true' || $this->status == 4) : ?> + if (isset($_GET[ self::key_precache ]) && $_GET[ self::key_precache ]=='true' || $this->status == 4) : ?> <div class='updated settings-error'><p><strong><?php _e( 'Precache process was started, it is now running in the background, please be patient, it may take a very long time to finish.' , $this->plugin_constant ) ?></strong></p></div> <?php endif;

@@ -769,6 +769,7 @@ $nginx = str_replace ( 'DATAPREFIX' , $this->options['prefix_data'] , $nginx );

/* set upstream servers from configured servers, best to get from the actual backend */ $servers = $this->backend->get_servers(); + $nginx_servers = ''; foreach ( array_keys( $servers ) as $server ) { $nginx_servers .= " server ". $server .";\n"; }