From 326efbb416f9de7c6a45afd1f2fc1cfb77a9920c Mon Sep 17 00:00:00 2001 From: Jonathan Daggerhart Date: Fri, 12 Jan 2018 11:34:15 -0500 Subject: [PATCH] prefixing generic classes with oidcg comment class names. adjusting autoloading to look for the standardized prefix. --- .../openid-connect-generic-client-wrapper.php | 12 ++++++------ ... => openid-connect-generic-option-logger.php} | 16 +++++++--------- ...> openid-connect-generic-option-settings.php} | 10 ++++------ .../openid-connect-generic-settings-page.php | 16 ++++++++++------ openid-connect-generic.php | 16 +++++++++++----- 5 files changed, 38 insertions(+), 32 deletions(-) rename includes/{wp-option-logger.php => openid-connect-generic-option-logger.php} (97%) rename includes/{wp-option-settings.php => openid-connect-generic-option-settings.php} (91%) diff --git a/includes/openid-connect-generic-client-wrapper.php b/includes/openid-connect-generic-client-wrapper.php index 7f07ed4..f3ebbec 100644 --- a/includes/openid-connect-generic-client-wrapper.php +++ b/includes/openid-connect-generic-client-wrapper.php @@ -24,10 +24,10 @@ class OpenID_Connect_Generic_Client_Wrapper { * Inject necessary objects and services into the client * * @param \OpenID_Connect_Generic_Client $client - * @param \WP_Option_Settings $settings - * @param \WP_Option_Logger $logger + * @param \OpenID_Connect_Generic_Option_Settings $settings + * @param \OpenID_Connect_Generic_Option_Logger $logger */ - function __construct( OpenID_Connect_Generic_Client $client, WP_Option_Settings $settings, WP_Option_Logger $logger ){ + function __construct( OpenID_Connect_Generic_Client $client, OpenID_Connect_Generic_Option_Settings $settings, OpenID_Connect_Generic_Option_Logger $logger ){ $this->client = $client; $this->settings = $settings; $this->logger = $logger; @@ -37,12 +37,12 @@ class OpenID_Connect_Generic_Client_Wrapper { * Hook the client into WP * * @param \OpenID_Connect_Generic_Client $client - * @param \WP_Option_Settings $settings - * @param \WP_Option_Logger $logger + * @param \OpenID_Connect_Generic_Option_Settings $settings + * @param \OpenID_Connect_Generic_Option_Logger $logger * * @return \OpenID_Connect_Generic_Client_Wrapper */ - static public function register( OpenID_Connect_Generic_Client $client, WP_Option_Settings $settings, WP_Option_Logger $logger ){ + static public function register( OpenID_Connect_Generic_Client $client, OpenID_Connect_Generic_Option_Settings $settings, OpenID_Connect_Generic_Option_Logger $logger ){ $client_wrapper = new self( $client, $settings, $logger ); // integrated logout diff --git a/includes/wp-option-logger.php b/includes/openid-connect-generic-option-logger.php similarity index 97% rename from includes/wp-option-logger.php rename to includes/openid-connect-generic-option-logger.php index cbb6d4f..1f72b18 100644 --- a/includes/wp-option-logger.php +++ b/includes/openid-connect-generic-option-logger.php @@ -2,9 +2,7 @@ /** * Simple class for logging messages to the options table */ -if ( !class_exists( 'WP_Option_Logger' ) ) : - -class WP_Option_Logger { +class OpenID_Connect_Generic_Option_Logger { // wp option name/key private $option_name; @@ -82,7 +80,7 @@ class WP_Option_Logger { /** * Save an array of data to the logs * - * @param $data array + * @param $data mixed * @return bool */ public function log( $data, $type = null ) { @@ -117,11 +115,13 @@ class WP_Option_Logger { public function get_option_name(){ return $this->option_name; } - + /** * Create a message array containing the data and other information - * - * @param $data (mixed) + * + * @param $data mixed + * @param $type + * * @return array */ private function make_message( $data, $type ){ @@ -244,5 +244,3 @@ class WP_Option_Logger { return $output; } } - -endif; diff --git a/includes/wp-option-settings.php b/includes/openid-connect-generic-option-settings.php similarity index 91% rename from includes/wp-option-settings.php rename to includes/openid-connect-generic-option-settings.php index e290e90..b88e0f9 100644 --- a/includes/wp-option-settings.php +++ b/includes/openid-connect-generic-option-settings.php @@ -1,8 +1,8 @@ option_name, $this->values ); } } - -endif; \ No newline at end of file diff --git a/includes/openid-connect-generic-settings-page.php b/includes/openid-connect-generic-settings-page.php index 2d9ca50..b445924 100644 --- a/includes/openid-connect-generic-settings-page.php +++ b/includes/openid-connect-generic-settings-page.php @@ -1,5 +1,9 @@ settings = $settings; $this->logger = $logger; $this->settings_field_group = $this->settings->get_option_name() . '-group'; @@ -196,12 +200,12 @@ class OpenID_Connect_Generic_Settings_Page { } /** - * @param \WP_Option_Settings $settings - * @param \WP_Option_Logger $logger + * @param \OpenID_Connect_Generic_Option_Settings $settings + * @param \OpenID_Connect_Generic_Option_Logger $logger * * @return \OpenID_Connect_Generic_Settings_Page */ - static public function register( WP_Option_Settings $settings, WP_Option_Logger $logger ){ + static public function register( OpenID_Connect_Generic_Option_Settings $settings, OpenID_Connect_Generic_Option_Logger $logger ){ $settings_page = new self( $settings, $logger ); // add our options page the the admin menu diff --git a/openid-connect-generic.php b/openid-connect-generic.php index 7ac9493..45e029c 100644 --- a/openid-connect-generic.php +++ b/openid-connect-generic.php @@ -61,10 +61,10 @@ class OpenID_Connect_Generic { /** * Setup the plugin * - * @param \WP_Option_Settings $settings - * @param \WP_Option_Logger $logger + * @param OpenID_Connect_Generic_Option_Settings $settings + * @param OpenID_Connect_Generic_Option_Logger $logger */ - function __construct( WP_Option_Settings $settings, WP_Option_Logger $logger ){ + function __construct( OpenID_Connect_Generic_Option_Settings $settings, OpenID_Connect_Generic_Option_Logger $logger ){ $this->settings = $settings; $this->logger = $logger; } @@ -157,6 +157,12 @@ class OpenID_Connect_Generic { * @param $class */ static public function autoload( $class ) { + $prefix = 'OpenID_Connect_Generic_'; + + if ( stripos($class, $prefix) !== 0 ) { + return; + } + $filename = $class . '.php'; // internal files are all lowercase and use dashes in filenames @@ -180,7 +186,7 @@ class OpenID_Connect_Generic { static public function bootstrap(){ spl_autoload_register( array( 'OpenID_Connect_Generic', 'autoload' ) ); - $settings = new WP_Option_Settings( + $settings = new OpenID_Connect_Generic_Option_Settings( 'openid_connect_generic_settings', // default settings values array( @@ -214,7 +220,7 @@ class OpenID_Connect_Generic { ) ); - $logger = new WP_Option_Logger( 'openid-connect-generic-logs', 'error', $settings->enable_logging, $settings->log_limit ); + $logger = new OpenID_Connect_Generic_Option_Logger( 'openid-connect-generic-logs', 'error', $settings->enable_logging, $settings->log_limit ); $plugin = new self( $settings, $logger );