| 1 |
<?php |
| 2 |
/** |
| 3 |
* This file is used to load widget builder files and the builder. |
| 4 |
* |
| 5 |
* @link https://posimyth.com/ |
| 6 |
* @since 1.0.0 |
| 7 |
* |
| 8 |
* @package Wdesignkit |
| 9 |
*/ |
| 10 |
|
| 11 |
/** |
| 12 |
* Exit if accessed directly. |
| 13 |
* */ |
| 14 |
if ( ! defined( 'ABSPATH' ) ) { |
| 15 |
exit; |
| 16 |
} |
| 17 |
|
| 18 |
use wdkit\Wdkit_Wdesignkit; |
| 19 |
|
| 20 |
if ( ! class_exists( 'Wdkit_Widget_Load_Files' ) ) { |
| 21 |
|
| 22 |
/** |
| 23 |
* This class used for widget load |
| 24 |
* |
| 25 |
* @since 1.0.0 |
| 26 |
*/ |
| 27 |
class Wdkit_Widget_Load_Files { |
| 28 |
|
| 29 |
/** |
| 30 |
* |
| 31 |
* Ensures only one instance of the class is loaded or can be loaded. |
| 32 |
* |
| 33 |
* @var instance |
| 34 |
* @since 1.0.0 |
| 35 |
*/ |
| 36 |
private static $instance = null; |
| 37 |
|
| 38 |
/** |
| 39 |
* This instance is used to load class |
| 40 |
* |
| 41 |
* @since 1.0.0 |
| 42 |
*/ |
| 43 |
public static function instance() { |
| 44 |
|
| 45 |
if ( is_null( self::$instance ) ) { |
| 46 |
self::$instance = new self(); |
| 47 |
} |
| 48 |
|
| 49 |
return self::$instance; |
| 50 |
} |
| 51 |
|
| 52 |
/** |
| 53 |
* This constructor is used to load builder files. |
| 54 |
* |
| 55 |
* @since 1.0.0 |
| 56 |
*/ |
| 57 |
public function __construct() { |
| 58 |
|
| 59 |
$this->wdkit_default_category(); |
| 60 |
|
| 61 |
$this->wdkit_elementor_load(); |
| 62 |
$this->wdkit_gutenberg_load(); |
| 63 |
$this->wdkit_bricks_load(); |
| 64 |
} |
| 65 |
|
| 66 |
/** |
| 67 |
* This function is called to load Elementor files, categories, and everything needed for WDesignKit to build with Elementor. |
| 68 |
* |
| 69 |
* @since 1.0.0 |
| 70 |
*/ |
| 71 |
public function wdkit_elementor_load() { |
| 72 |
if ( Wdkit_Wdesignkit::wdkit_is_compatible( 'elementor' ) ) { |
| 73 |
require_once WDKIT_INCLUDES . 'widget-load/elementor/class-wdkit-elementor-files-load.php'; |
| 74 |
} |
| 75 |
} |
| 76 |
|
| 77 |
/** |
| 78 |
* This function is called to load Elementor files, categories, and everything needed for WDesignKit to build with Gutenberg. |
| 79 |
* |
| 80 |
* @since 1.0.0 |
| 81 |
*/ |
| 82 |
public function wdkit_gutenberg_load() { |
| 83 |
if ( Wdkit_Wdesignkit::wdkit_is_compatible( 'gutenberg' ) ) { |
| 84 |
require_once WDKIT_INCLUDES . 'widget-load/gutenberg/class-wdkit-gutenberg-files-load.php'; |
| 85 |
} |
| 86 |
} |
| 87 |
|
| 88 |
/** |
| 89 |
* This function is called to load Bricks files, categories, and everything needed for WDesignKit to build with bricks. |
| 90 |
* |
| 91 |
* @since 1.0.0 |
| 92 |
*/ |
| 93 |
public function wdkit_bricks_load() { |
| 94 |
if ( Wdkit_Wdesignkit::wdkit_is_compatible( 'bricks' ) ) { |
| 95 |
require_once WDKIT_INCLUDES . 'widget-load/bricks/class-wdkit-bricks-files-load.php'; |
| 96 |
} |
| 97 |
} |
| 98 |
|
| 99 |
/** |
| 100 |
* Set widget Default Category as WDesignKit |
| 101 |
* |
| 102 |
* @since 1.0.0 |
| 103 |
* @access public |
| 104 |
*/ |
| 105 |
public function wdkit_default_category() { |
| 106 |
$category_list = get_option( 'wkit_builder' ); |
| 107 |
|
| 108 |
$final_category = array( 'WDesignKit' ); |
| 109 |
if ( ! empty( $category_list ) && ! in_array( 'WDesignKit', $category_list, true ) ) { |
| 110 |
$final_category = array_merge( $final_category, $category_list ); |
| 111 |
|
| 112 |
update_option( 'wkit_builder', $final_category ); |
| 113 |
} elseif ( ! is_array( $category_list ) && empty( $category_list ) ) { |
| 114 |
do_action( 'wdkit_admin_create_default' ); |
| 115 |
} |
| 116 |
} |
| 117 |
} |
| 118 |
|
| 119 |
Wdkit_Widget_Load_Files::instance(); |
| 120 |
} |
| 121 |
|