Skip to content
Snippets Groups Projects
Commit 1f9d460b authored by Erick Hitter's avatar Erick Hitter
Browse files

Merge pull request #2 from mjangda/master

Convert to traditional Singleton
parents 58df69de be80cda8
No related branches found
No related tags found
No related merge requests found
...@@ -26,10 +26,18 @@ class external_permalinks_redux { ...@@ -26,10 +26,18 @@ class external_permalinks_redux {
/* /*
* Class variables * Class variables
*/ */
protected static $instance;
var $meta_key_target = '_links_to'; var $meta_key_target = '_links_to';
var $meta_key_type = '_links_to_type'; var $meta_key_type = '_links_to_type';
var $status_codes; var $status_codes;
static function get_instance() {
if ( ! isset( self::$instance ) )
self::$instance = new external_permalinks_redux;
return self::$instance;
}
/* /*
* Register actions and filters * Register actions and filters
* @uses add_action, add_filter * @uses add_action, add_filter
...@@ -191,9 +199,9 @@ class external_permalinks_redux { ...@@ -191,9 +199,9 @@ class external_permalinks_redux {
} }
} }
} }
global $external_permalinks_redux;
if( !is_a( $external_permalinks_redux, 'external_permalinks_redux' ) ) // Initialize the plugin if it hasn't already
$external_permalinks_redux = new external_permalinks_redux; external_permalinks_redux::get_instance();
/* /*
* Wrapper for meta box function * Wrapper for meta box function
...@@ -203,10 +211,6 @@ if( !is_a( $external_permalinks_redux, 'external_permalinks_redux' ) ) ...@@ -203,10 +211,6 @@ if( !is_a( $external_permalinks_redux, 'external_permalinks_redux' ) )
* @return string * @return string
*/ */
function external_permalinks_redux_meta_box( $post ) { function external_permalinks_redux_meta_box( $post ) {
global $external_permalinks_redux; external_permalinks_redux::get_instance()->meta_box( $post );
if( !is_a( $external_permalinks_redux, 'external_permalinks_redux' ) )
$external_permalinks_redux = new external_permalinks_redux;
$external_permalinks_redux->meta_box( $post );
} }
?> ?>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment