version_check(); add_action( 'init', array( $this, 'load' ), 999 ); add_filter( 'ast_block_templates_localize_vars', array( $this, 'update_vars' ) ); } /** * Add support to change template button text. * * @since 1.21.0 * @param array $vars localize array of button. */ public function update_vars( $vars = array() ) { if ( defined( 'ASTRA_SITES_VER' ) ) { return $vars; } $vars['button_text'] = __( 'Template Kits', 'ultimate-addons-for-gutenberg' ); $vars['display_button_logo'] = true; $vars['popup_logo_uri'] = UAGB_URL . 'admin-core/assets/images/uag-logo.svg'; $vars['button_logo'] = UAGB_URL . 'admin-core/assets/images/btn-spectra.svg'; $vars['button_class'] = 'uagb-template-button-logo'; return $vars; } /** * Version Check * * @return void */ public function version_check() { $file = realpath( dirname( __FILE__ ) . '/gutenberg-templates/version.json' ); // Is file exist? if ( is_file( $file ) ) { // @codingStandardsIgnoreStart $file_data = json_decode( file_get_contents( $file ), true ); // @codingStandardsIgnoreEnd global $ast_block_templates_version, $ast_block_templates_init; $path = realpath( dirname( __FILE__ ) . '/gutenberg-templates/ast-block-templates.php' ); $version = isset( $file_data['ast-block-templates'] ) ? $file_data['ast-block-templates'] : 0; if ( null === $ast_block_templates_version ) { $ast_block_templates_version = '1.0.0'; } // Compare versions. if ( version_compare( $version, $ast_block_templates_version, '>' ) ) { $ast_block_templates_version = $version; $ast_block_templates_init = $path; } } } /** * Load latest plugin * * @return void */ public function load() { global $ast_block_templates_version, $ast_block_templates_init; if ( is_file( realpath( $ast_block_templates_init ) ) ) { include_once realpath( $ast_block_templates_init ); } } } /** * Kicking this off by calling 'get_instance()' method */ UAGB_Ast_Block_Templates::get_instance(); endif;