September improvements

@bhance Combined the two patches into one branch - looked like there was some interdependence between the two - I think this combined one will be easier to work on together
ok, cool. This is where my PHP knowledge begins to fall down - all I needed
to be able to do was call that function from the rest of the code. So, if
the new updates just use

$background = Bike_Index_Sync_Background::get_instance();

... when attempting to call those functions contained in the background
code, that works for me


On Fri, Sep 12, 2014 at 5:31 PM, Bryan Purcell <notifications@github.com>
wrote:

> In background/class-bike-index-sync-background.php:
>
> > @@ -31,8 +31,10 @@ class Bike_Index_Sync_Background {
> >  	 *
> >  	 * @since     1.0.0
> >  	 */
> > -	private function __construct() {
> > -
> > +	// bdh made public so can be called by admin checkboxes
> > +	// purcebr if theres a better way for this, lmk
> > +	// private function __construct() {
> > +	public function __construct() {
>
> @bhance <https://github.com/bhance> regarding your comment about a
> "better way" :
>
> This is the singleton pattern, where we want to make sure that there's
> only one instance of the class at any given time. That private __construct
> is what ensures this. There's no way to instantiate the class outside the
> class itself!
>
> that's where the static method get_instance comes into play. You can use
> that anywhere throughout the plugin to get the single instance of the
> class. so to get the background instance (I just pushed this update) an
> equivalent statement to the $background = new Bike_Index_Sync_Background;
> would be $background = Bike_Index_Sync_Background::get_instance();
>
> It does the same thing, and keeps that protection in place.
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/purcebr/bike-index-sync/pull/3/files#r17508902>.
>