| 1 |
<?php |
| 2 |
/** |
| 3 |
* Exit if accessed directly. |
| 4 |
* |
| 5 |
* @link https://posimyth.com/ |
| 6 |
* @since 1.0.0 |
| 7 |
* |
| 8 |
* @package Wdesignkit |
| 9 |
* @subpackage Wdesignkit/elementor/ |
| 10 |
* */ |
| 11 |
|
| 12 |
namespace wdkit\wdkit_wbcontroller; |
| 13 |
|
| 14 |
/**Exit if accessed directly.*/ |
| 15 |
if ( ! defined( 'ABSPATH' ) ) { |
| 16 |
exit; |
| 17 |
} |
| 18 |
|
| 19 |
if ( ! class_exists( 'Wdkit_Wb_Elementor_Controller' ) ) { |
| 20 |
|
| 21 |
/** |
| 22 |
* This class used for only load elementor custom controler |
| 23 |
* |
| 24 |
* @since 1.0.0 |
| 25 |
*/ |
| 26 |
class Wdkit_Wb_Elementor_Controller { |
| 27 |
|
| 28 |
/** |
| 29 |
* |
| 30 |
* Ensures only one instance of the class is loaded or can be loaded. |
| 31 |
* |
| 32 |
* @var instance |
| 33 |
* @since 1.0.0 |
| 34 |
*/ |
| 35 |
private static $instance = null; |
| 36 |
|
| 37 |
/** |
| 38 |
* Instance |
| 39 |
* |
| 40 |
* Ensures only one instance of the class is loaded or can be loaded. |
| 41 |
* |
| 42 |
* @since 1.0.0 |
| 43 |
* @access public |
| 44 |
* @static |
| 45 |
* @return \Wdkit_Wb_Elementor_Controller\Plugin An instance of the class. |
| 46 |
*/ |
| 47 |
public static function instance() { |
| 48 |
if ( is_null( self::$instance ) ) { |
| 49 |
self::$instance = new self(); |
| 50 |
} |
| 51 |
return self::$instance; |
| 52 |
} |
| 53 |
|
| 54 |
/** |
| 55 |
* Constructor |
| 56 |
* |
| 57 |
* Perform some compatibility checks to make sure basic requirements are meet. |
| 58 |
* If all compatibility checks pass, initialize the functionality. |
| 59 |
* |
| 60 |
* @since 1.0.0 |
| 61 |
* @access public |
| 62 |
*/ |
| 63 |
public function __construct() { |
| 64 |
} |
| 65 |
|
| 66 |
/** |
| 67 |
* |
| 68 |
* Add Elementor library and get template in widget controller |
| 69 |
* |
| 70 |
* @since 1.0.0 |
| 71 |
* @access public |
| 72 |
*/ |
| 73 |
public static function wdkit_elementor() { |
| 74 |
return \Elementor\Plugin::$instance; |
| 75 |
} |
| 76 |
|
| 77 |
/** |
| 78 |
* Wdkit_get_templates function |
| 79 |
* |
| 80 |
* This function retrieves a list of templates from the Elementor controller. |
| 81 |
* |
| 82 |
* @since 1.0.0 |
| 83 |
* @access public |
| 84 |
* @return array An array of template options |
| 85 |
*/ |
| 86 |
public static function wdkit_get_templates() { |
| 87 |
|
| 88 |
$templates = self::wdkit_elementor()->templates_manager->get_source( 'local' )->get_items(); |
| 89 |
$types = array(); |
| 90 |
if ( empty( $templates ) ) { |
| 91 |
$options = array( |
| 92 |
'0' => esc_html__( "You Haven't Saved Templates Yet.", 'wdesignkit' ), |
| 93 |
); |
| 94 |
} else { |
| 95 |
$options = array( |
| 96 |
'0' => esc_html__( 'Select Template', 'wdesignkit' ), |
| 97 |
); |
| 98 |
|
| 99 |
foreach ( $templates as $template ) { |
| 100 |
$options[ $template['template_id'] ] = $template['title'] . ' (' . $template['type'] . ')'; |
| 101 |
$types[ $template['template_id'] ] = $template['type']; |
| 102 |
} |
| 103 |
} |
| 104 |
|
| 105 |
return $options; |
| 106 |
} |
| 107 |
} |
| 108 |
|
| 109 |
Wdkit_Wb_Elementor_Controller::instance(); |
| 110 |
} |
| 111 |
|