| 1 |
<?php |
| 2 |
/** |
| 3 |
* Exit if accessed directly. |
| 4 |
* |
| 5 |
* @link https://posimyth.com/ |
| 6 |
* @since 1.0.1 |
| 7 |
* |
| 8 |
* @package Wdesignkit |
| 9 |
* @subpackage Wdesignkit/includes/bricks |
| 10 |
* */ |
| 11 |
|
| 12 |
/** |
| 13 |
* Exit if accessed directly. |
| 14 |
*/ |
| 15 |
if ( ! defined( 'ABSPATH' ) ) { |
| 16 |
exit; |
| 17 |
} |
| 18 |
|
| 19 |
if ( ! class_exists( 'Wdkit_Bricks_Files_Load' ) ) { |
| 20 |
|
| 21 |
/** |
| 22 |
* This class used for only bricks widget load |
| 23 |
* |
| 24 |
* @since 1.0.1 |
| 25 |
*/ |
| 26 |
class Wdkit_Bricks_Files_Load { |
| 27 |
|
| 28 |
/** |
| 29 |
* Instance |
| 30 |
* |
| 31 |
* @since 1.0.1 |
| 32 |
* @var \Bricks\Plugin The single instance of the class. |
| 33 |
*/ |
| 34 |
private static $instance = null; |
| 35 |
|
| 36 |
/** |
| 37 |
* Instance |
| 38 |
* |
| 39 |
* Ensures only one instance of the class is loaded or can be loaded. |
| 40 |
* |
| 41 |
* @since 1.0.1 |
| 42 |
* @return \Bricks\Plugin An instance of the class. |
| 43 |
*/ |
| 44 |
public static function instance() { |
| 45 |
if ( is_null( self::$instance ) ) { |
| 46 |
self::$instance = new self(); |
| 47 |
} |
| 48 |
return self::$instance; |
| 49 |
} |
| 50 |
|
| 51 |
/** |
| 52 |
* Perform some compatibility checks to make sure basic requirements are meet. |
| 53 |
* |
| 54 |
* @since 1.0.1 |
| 55 |
*/ |
| 56 |
public function __construct() { |
| 57 |
add_action( 'init', array( $this, 'wdkit_init' ), 99 ); |
| 58 |
} |
| 59 |
|
| 60 |
/** |
| 61 |
* Initialize |
| 62 |
* |
| 63 |
* Load the addons functionality only after bricks is initialized. |
| 64 |
* |
| 65 |
* Fired by `bricks/init` action hook. |
| 66 |
* |
| 67 |
* @since 1.0.1 |
| 68 |
*/ |
| 69 |
public function wdkit_init() { |
| 70 |
if ( ! defined( 'WDKIT_BUILDER_PATH' ) || ! function_exists( 'wdesignkit_get_widget_registry' ) || ! class_exists( 'Bricks\Elements' ) ) { |
| 71 |
return false; |
| 72 |
} |
| 73 |
|
| 74 |
foreach ( wdesignkit_get_widget_registry( 'bricks' ) as $entry ) { |
| 75 |
if ( file_exists( $entry['file'] ) ) { |
| 76 |
Bricks\Elements::register_element( $entry['file'] ); |
| 77 |
} |
| 78 |
} |
| 79 |
} |
| 80 |
|
| 81 |
} |
| 82 |
|
| 83 |
Wdkit_Bricks_Files_Load::instance(); |
| 84 |
} |
| 85 |
|