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