ai-builder
1 week ago
astra-notices
1 month ago
bsf-quick-links
3 years ago
getting-started
3 weeks ago
gutenberg-templates
1 month ago
nps-survey
1 month ago
onboarding
1 week ago
one-onboarding
1 month ago
starter-templates-importer
1 month ago
zip-ai
3 weeks ago
zipwp-images
1 month ago
class-astra-sites-ast-block-templates.php
1 year ago
class-astra-sites-nps-survey.php
1 year ago
class-astra-sites-zip-ai.php
1 year ago
class-astra-sites-zipwp-images.php
1 year ago
class-astra-sites-ast-block-templates.php
106 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Init |
| 4 | * |
| 5 | * @since 1.0.0 |
| 6 | * @package Ast Block Templates |
| 7 | */ |
| 8 | |
| 9 | if ( ! defined( 'ABSPATH' ) ) { |
| 10 | exit; |
| 11 | } |
| 12 | |
| 13 | if ( ! class_exists( 'Astra_Sites_Ast_Block_Templates' ) ) : |
| 14 | |
| 15 | /** |
| 16 | * Admin |
| 17 | */ |
| 18 | class Astra_Sites_Ast_Block_Templates { |
| 19 | |
| 20 | /** |
| 21 | * Instance |
| 22 | * |
| 23 | * @since 4.0.4 |
| 24 | * @access private |
| 25 | * @var object Class object. |
| 26 | */ |
| 27 | private static $instance = null; |
| 28 | |
| 29 | /** |
| 30 | * Initiator |
| 31 | * |
| 32 | * @since 4.0.4 |
| 33 | * @return mixed |
| 34 | */ |
| 35 | public static function get_instance() { |
| 36 | if ( null === self::$instance ) { |
| 37 | self::$instance = new self(); |
| 38 | } |
| 39 | return self::$instance; |
| 40 | } |
| 41 | |
| 42 | /** |
| 43 | * Constructor. |
| 44 | * |
| 45 | * @since 1.0.0 |
| 46 | */ |
| 47 | private function __construct() { |
| 48 | $this->version_check(); |
| 49 | add_action( 'init', array( $this, 'load' ), 999 ); |
| 50 | } |
| 51 | |
| 52 | /** |
| 53 | * Version Check |
| 54 | * |
| 55 | * @return void |
| 56 | */ |
| 57 | public function version_check() { |
| 58 | |
| 59 | $file = realpath( dirname( __FILE__ ) . '/gutenberg-templates/version.json' ); |
| 60 | |
| 61 | // Is file exist? |
| 62 | if ( is_string( $file ) && is_file( $file ) ) { |
| 63 | // @codingStandardsIgnoreStart |
| 64 | $file_data = json_decode( (string)file_get_contents( $file ), true ); |
| 65 | // @codingStandardsIgnoreEnd |
| 66 | global $ast_block_templates_version, $ast_block_templates_init; |
| 67 | $path = realpath( dirname( __FILE__ ) . '/gutenberg-templates/ast-block-templates.php' ); |
| 68 | $version = isset( $file_data['ast-block-templates'] ) ? $file_data['ast-block-templates'] : 0; |
| 69 | |
| 70 | if ( null === $ast_block_templates_version ) { |
| 71 | $ast_block_templates_version = '1.0.0'; |
| 72 | } |
| 73 | |
| 74 | // Compare versions. |
| 75 | if ( version_compare( $version, $ast_block_templates_version, '>' ) ) { |
| 76 | $ast_block_templates_version = $version; |
| 77 | $ast_block_templates_init = $path; |
| 78 | } |
| 79 | } |
| 80 | } |
| 81 | |
| 82 | /** |
| 83 | * Load latest plugin |
| 84 | * |
| 85 | * @return void |
| 86 | */ |
| 87 | public function load() { |
| 88 | |
| 89 | if ( apply_filters( 'astra_sites_disable_design_kit', false ) ) { |
| 90 | return; |
| 91 | } |
| 92 | global $ast_block_templates_version, $ast_block_templates_init; |
| 93 | if ( is_file( (string) realpath( $ast_block_templates_init ) ) ) { |
| 94 | include_once realpath( $ast_block_templates_init ); |
| 95 | } |
| 96 | } |
| 97 | |
| 98 | } |
| 99 | |
| 100 | /** |
| 101 | * Kicking this off by calling 'get_instance()' method |
| 102 | */ |
| 103 | Astra_Sites_Ast_Block_Templates::get_instance(); |
| 104 | |
| 105 | endif; |
| 106 |