Blocks
1 year ago
Contracts
1 year ago
Database
1 year ago
Integrations
1 year ago
Libraries
1 year ago
Models
1 year ago
Seeds
1 year ago
Services
1 year ago
Support
1 year ago
config
1 year ago
Activator.php
1 year ago
Attachment.php
1 year ago
Controller.php
1 year ago
Core.php
1 year ago
Deactivator.php
1 year ago
Factory.php
1 year ago
Files.php
1 year ago
Playlist.php
1 year ago
Plugin.php
1 year ago
Requirements.php
1 year ago
support.php
1 year ago
Core.php
53 lines
| 1 | <?php |
| 2 | |
| 3 | namespace PrestoPlayer; |
| 4 | |
| 5 | class Core { |
| 6 | |
| 7 | /** |
| 8 | * The singleton instance. |
| 9 | * |
| 10 | * @var Core |
| 11 | */ |
| 12 | private static $instance; |
| 13 | |
| 14 | /** |
| 15 | * Retrieves (and if necessary creates) the API instance. Should not be called outside of plugin set-up. |
| 16 | * |
| 17 | * @internal |
| 18 | * |
| 19 | * @since 1.0.0 |
| 20 | * |
| 21 | * @param Core $instance Only used for plugin initialization. Don't ever pass a value in user code. |
| 22 | * |
| 23 | * @return void |
| 24 | * |
| 25 | * @throws \BadMethodCallException Thrown when Avatar_Privacy_Core::set_instance after plugin initialization. |
| 26 | */ |
| 27 | public static function set_instance( Core $instance ) { |
| 28 | if ( null === self::$instance ) { |
| 29 | self::$instance = $instance; |
| 30 | } else { |
| 31 | // throw new \BadMethodCallException(__METHOD__ . ' called more than once.'); |
| 32 | } |
| 33 | } |
| 34 | |
| 35 | |
| 36 | /** |
| 37 | * Retrieves the plugin instance. |
| 38 | * |
| 39 | * @since 1.0.0 |
| 40 | * |
| 41 | * @throws \BadMethodCallException Thrown when Avatar_Privacy_Core::get_instance is called before plugin initialization. |
| 42 | * |
| 43 | * @return Core |
| 44 | */ |
| 45 | public static function get_instance() { |
| 46 | if ( null === self::$instance ) { |
| 47 | throw new \BadMethodCallException( __METHOD__ . ' called without prior plugin intialization.' ); |
| 48 | } |
| 49 | |
| 50 | return self::$instance; |
| 51 | } |
| 52 | } |
| 53 |