-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow developer to external access to plugin instance
Instead create new instance by `new Loader()` use new instance container `Simpleshop::getInstance()`. It makes container to prevent re-create it twice. Developer still can force create new instance via argument $instanceId (`Simpleshop::getInstance('test')`).
- Loading branch information
1 parent
c0157fd
commit d684e1e
Showing
2 changed files
with
35 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,4 +29,4 @@ | |
/** | ||
* Start plugin | ||
*/ | ||
new Plugin(); | ||
SimpleShop::getInstance(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
/** | ||
* @package Redbit\SimpleShop\WpPlugin | ||
* @license MIT | ||
* @copyright 2016-2019 Redbit s.r.o. | ||
* @author Redbit s.r.o. <[email protected]> | ||
*/ | ||
|
||
namespace Redbit\SimpleShop\WpPlugin; | ||
|
||
class SimpleShop { | ||
/** | ||
* @var Plugin | ||
*/ | ||
private static $instance = []; | ||
|
||
/** | ||
* @return Plugin | ||
*/ | ||
public static function getInstance() { | ||
if ( self::$instance === null ) { | ||
self::$instance = self::factory(); | ||
} | ||
|
||
return self::$instance; | ||
} | ||
|
||
/** | ||
* @return Plugin | ||
*/ | ||
protected static function factory() { | ||
return new Plugin(); | ||
} | ||
} |