astra-sites
Last commit date
admin
3 years ago
assets
2 years ago
classes
1 year ago
inc
1 year ago
languages
1 year ago
astra-sites.php
1 year ago
readme.txt
1 year ago
astra-sites.php
153 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Plugin Name: Starter Templates |
| 4 | * Plugin URI: https://wpastra.com/ |
| 5 | * Description: Starter Templates is all in one solution for complete starter sites, single page templates, blocks & images. This plugin offers the premium library of ready templates & provides quick access to beautiful Pixabay images that can be imported in your website easily. |
| 6 | * Version: 4.4.8 |
| 7 | * Author: Brainstorm Force |
| 8 | * Author URI: https://www.brainstormforce.com |
| 9 | * Text Domain: astra-sites |
| 10 | * |
| 11 | * @package Astra Sites |
| 12 | */ |
| 13 | |
| 14 | // Check PHP version before loading the plugin. |
| 15 | if ( version_compare( PHP_VERSION, '7.4', '<' ) ) { |
| 16 | add_action( 'admin_notices', 'astra_sites_php_version_notice' ); |
| 17 | return; |
| 18 | } |
| 19 | |
| 20 | /** |
| 21 | * Display notice if PHP version is below 7.4 |
| 22 | */ |
| 23 | function astra_sites_php_version_notice() { |
| 24 | $plugin_name = 'Starter Templates'; |
| 25 | ?> |
| 26 | <div class="error"> |
| 27 | <p><?php echo esc_html( $plugin_name . ' requires PHP version 7.4 or higher. Please upgrade your PHP version.' ); ?></p> |
| 28 | </div> |
| 29 | <?php |
| 30 | } |
| 31 | |
| 32 | /** |
| 33 | * Set constants. |
| 34 | */ |
| 35 | if ( ! defined( 'ASTRA_SITES_NAME' ) ) { |
| 36 | define( 'ASTRA_SITES_NAME', __( 'Starter Templates', 'astra-sites' ) ); |
| 37 | } |
| 38 | |
| 39 | if ( ! defined( 'ASTRA_SITES_VER' ) ) { |
| 40 | define( 'ASTRA_SITES_VER', '4.4.8' ); |
| 41 | } |
| 42 | |
| 43 | if ( ! defined( 'ASTRA_SITES_FILE' ) ) { |
| 44 | define( 'ASTRA_SITES_FILE', __FILE__ ); |
| 45 | } |
| 46 | |
| 47 | if ( ! defined( 'ASTRA_SITES_BASE' ) ) { |
| 48 | define( 'ASTRA_SITES_BASE', plugin_basename( ASTRA_SITES_FILE ) ); |
| 49 | } |
| 50 | |
| 51 | if ( ! defined( 'ASTRA_SITES_DIR' ) ) { |
| 52 | define( 'ASTRA_SITES_DIR', plugin_dir_path( ASTRA_SITES_FILE ) ); |
| 53 | } |
| 54 | |
| 55 | if ( ! defined( 'ASTRA_SITES_URI' ) ) { |
| 56 | define( 'ASTRA_SITES_URI', plugins_url( '/', ASTRA_SITES_FILE ) ); |
| 57 | } |
| 58 | |
| 59 | // Load AI Builder. |
| 60 | $ai_builder_path = ASTRA_SITES_DIR . 'inc/lib/ai-builder/ai-builder.php'; |
| 61 | if ( file_exists( $ai_builder_path ) ) { |
| 62 | require_once $ai_builder_path; |
| 63 | } |
| 64 | |
| 65 | // Load ST Importer. |
| 66 | $st_importer_path = ASTRA_SITES_DIR . 'inc/lib/starter-templates-importer/starter-templates-importer.php'; |
| 67 | if ( file_exists( $st_importer_path ) ) { |
| 68 | require_once $st_importer_path; |
| 69 | } |
| 70 | |
| 71 | if ( ! function_exists( 'astra_sites_setup' ) ) : |
| 72 | |
| 73 | /** |
| 74 | * Astra Sites Setup |
| 75 | * |
| 76 | * @since 1.0.5 |
| 77 | */ |
| 78 | function astra_sites_setup() { |
| 79 | require_once ASTRA_SITES_DIR . 'inc/classes/class-astra-sites.php'; |
| 80 | |
| 81 | // Admin. |
| 82 | require_once ASTRA_SITES_DIR . 'classes/class-astra-sites-admin.php'; |
| 83 | } |
| 84 | |
| 85 | add_action( 'plugins_loaded', 'astra_sites_setup' ); |
| 86 | |
| 87 | endif; |
| 88 | |
| 89 | // Astra Notices. |
| 90 | require_once ASTRA_SITES_DIR . 'inc/lib/astra-notices/class-astra-notices.php'; |
| 91 | |
| 92 | // BSF Analytics Tracker. |
| 93 | if ( ! class_exists( 'BSF_Analytics_Loader' ) ) { |
| 94 | require_once ASTRA_SITES_DIR . 'admin/bsf-analytics/class-bsf-analytics-loader.php'; |
| 95 | } |
| 96 | |
| 97 | // BSF_Quick_Links. |
| 98 | if ( ! class_exists( 'BSF_Quick_Links' ) ) { |
| 99 | require_once ASTRA_SITES_DIR . 'inc/lib/bsf-quick-links/class-bsf-quick-links.php'; |
| 100 | } |
| 101 | |
| 102 | $bsf_analytics = BSF_Analytics_Loader::get_instance(); |
| 103 | |
| 104 | $bsf_analytics->set_entity( |
| 105 | array( |
| 106 | 'bsf' => array( |
| 107 | 'product_name' => __( 'Starter Templates', 'astra-sites' ), |
| 108 | 'path' => ASTRA_SITES_DIR . 'admin/bsf-analytics', |
| 109 | 'author' => 'Brainstorm Force', |
| 110 | 'time_to_display' => '+24 hours', |
| 111 | ), |
| 112 | ) |
| 113 | ); |
| 114 | |
| 115 | if ( ! function_exists( 'astra_sites_redirect_to_onboarding' ) ) : |
| 116 | |
| 117 | /** |
| 118 | * Redirect to onboarding. |
| 119 | * |
| 120 | * @since 3.3.0 |
| 121 | * @return void |
| 122 | */ |
| 123 | function astra_sites_redirect_to_onboarding() { |
| 124 | if ( ! get_option( 'st_start_onboarding', false ) ) { |
| 125 | return; |
| 126 | } |
| 127 | |
| 128 | delete_option( 'st_start_onboarding' ); |
| 129 | if ( ! defined( 'WP_CLI' ) || ! WP_CLI ) { |
| 130 | wp_safe_redirect( admin_url( 'themes.php?page=starter-templates' ) ); |
| 131 | exit(); |
| 132 | } |
| 133 | } |
| 134 | |
| 135 | add_action( 'admin_init', 'astra_sites_redirect_to_onboarding' ); |
| 136 | |
| 137 | endif; |
| 138 | |
| 139 | if ( ! function_exists( 'astra_pro_sites_activate' ) ) : |
| 140 | |
| 141 | /** |
| 142 | * Astra pro sites activate. |
| 143 | * |
| 144 | * @since 4.1.2 |
| 145 | * @return void |
| 146 | */ |
| 147 | function astra_pro_sites_activate() { |
| 148 | update_option( 'st_start_onboarding', true ); |
| 149 | } |
| 150 | register_activation_hook( __FILE__, 'astra_pro_sites_activate' ); |
| 151 | |
| 152 | endif; |
| 153 |