PluginProbe
Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF / 1.9.8
Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF v1.9.8
2.3.4 2.3.3 2.3.2 2.3.1 2.3.0 2.2.9 2.2.8 trunk 1.10 1.3.3 1.3.4 1.3.5 1.3.5.1 1.3.5.2 1.3.6 1.3.6.1 1.4 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.5 All 103 releases
imagify / classes / Traits / InstanceGetterTrait.php

InstanceGetterTrait.php in Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF 1.9.8, at classes/Traits/InstanceGetterTrait.php

44 lines 879 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace Imagify\Traits;
3
4 defined( 'ABSPATH' ) || die( 'Cheatin’ uh?' );
5
6 /**
7 * Trait that simulates a singleton pattern.
8 * The idea is more to ease the instance retrieval than to prevent multiple instances.
9 * This is temporary, until we get a DI container.
10 *
11 * @since 1.9
12 * @since 1.9.4 Renamed into InstanceGetterTrait.
13 * @author Grégory Viguier
14 */
15 trait InstanceGetterTrait {
16
17 /**
18 * The "not-so-single" instance of the class.
19 *
20 * @var object
21 * @since 1.9
22 * @access protected
23 * @author Grégory Viguier
24 */
25 protected static $instance;
26
27 /**
28 * Get the main Instance.
29 *
30 * @since 1.9
31 * @access protected
32 * @author Grégory Viguier
33 *
34 * @return object Main instance.
35 */
36 public static function get_instance() {
37 if ( ! isset( static::$instance ) ) {
38 static::$instance = new static();
39 }
40
41 return static::$instance;
42 }
43 }
44