astra-sites
Last commit date
admin
1 year ago
assets
2 years ago
classes
1 year ago
inc
11 months ago
languages
11 months ago
SECURITY.md
11 months ago
astra-sites.php
11 months ago
readme.txt
11 months ago
systemprompt.txt
1 year ago
astra-sites.php
185 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.27 |
| 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 | * @return void |
| 24 | */ |
| 25 | function astra_sites_php_version_notice() { |
| 26 | $plugin_name = 'Starter Templates'; |
| 27 | ?> |
| 28 | <div class="error"> |
| 29 | <p><?php echo esc_html( $plugin_name . ' requires PHP version 7.4 or higher. Please upgrade your PHP version.' ); ?></p> |
| 30 | </div> |
| 31 | <?php |
| 32 | } |
| 33 | |
| 34 | /** |
| 35 | * Set constants. |
| 36 | */ |
| 37 | if ( ! defined( 'ASTRA_SITES_NAME' ) ) { |
| 38 | define( 'ASTRA_SITES_NAME', 'Starter Templates' ); |
| 39 | } |
| 40 | |
| 41 | if ( ! defined( 'ASTRA_SITES_VER' ) ) { |
| 42 | define( 'ASTRA_SITES_VER', '4.4.27' ); |
| 43 | } |
| 44 | |
| 45 | if ( ! defined( 'ASTRA_SITES_FILE' ) ) { |
| 46 | define( 'ASTRA_SITES_FILE', __FILE__ ); |
| 47 | } |
| 48 | |
| 49 | if ( ! defined( 'ASTRA_SITES_BASE' ) ) { |
| 50 | define( 'ASTRA_SITES_BASE', plugin_basename( ASTRA_SITES_FILE ) ); |
| 51 | } |
| 52 | |
| 53 | if ( ! defined( 'ASTRA_SITES_DIR' ) ) { |
| 54 | define( 'ASTRA_SITES_DIR', plugin_dir_path( ASTRA_SITES_FILE ) ); |
| 55 | } |
| 56 | |
| 57 | if ( ! defined( 'ASTRA_SITES_URI' ) ) { |
| 58 | define( 'ASTRA_SITES_URI', plugins_url( '/', ASTRA_SITES_FILE ) ); |
| 59 | } |
| 60 | |
| 61 | // Load AI Builder. |
| 62 | $ai_builder_path = ASTRA_SITES_DIR . 'inc/lib/ai-builder/ai-builder.php'; |
| 63 | if ( file_exists( $ai_builder_path ) ) { |
| 64 | require_once $ai_builder_path; |
| 65 | } |
| 66 | |
| 67 | // Load ST Importer. |
| 68 | $st_importer_path = ASTRA_SITES_DIR . 'inc/lib/starter-templates-importer/starter-templates-importer.php'; |
| 69 | if ( file_exists( $st_importer_path ) ) { |
| 70 | require_once $st_importer_path; |
| 71 | } |
| 72 | |
| 73 | if ( ! function_exists( 'astra_sites_setup' ) ) : |
| 74 | |
| 75 | /** |
| 76 | * Astra Sites Setup |
| 77 | * |
| 78 | * @since 1.0.5 |
| 79 | * @return void |
| 80 | */ |
| 81 | function astra_sites_setup() { |
| 82 | require_once ASTRA_SITES_DIR . 'inc/classes/class-astra-sites.php'; |
| 83 | |
| 84 | // Admin. |
| 85 | require_once ASTRA_SITES_DIR . 'classes/class-astra-sites-admin.php'; |
| 86 | } |
| 87 | |
| 88 | add_action( 'plugins_loaded', 'astra_sites_setup' ); |
| 89 | |
| 90 | endif; |
| 91 | |
| 92 | // Astra Notices. |
| 93 | require_once ASTRA_SITES_DIR . 'inc/lib/astra-notices/class-astra-notices.php'; |
| 94 | |
| 95 | // BSF Analytics Tracker. |
| 96 | if ( ! class_exists( 'BSF_Analytics_Loader' ) ) { |
| 97 | require_once ASTRA_SITES_DIR . 'admin/bsf-analytics/class-bsf-analytics-loader.php'; |
| 98 | } |
| 99 | |
| 100 | // BSF_Quick_Links. |
| 101 | if ( ! class_exists( 'BSF_Quick_Links' ) ) { |
| 102 | require_once ASTRA_SITES_DIR . 'inc/lib/bsf-quick-links/class-bsf-quick-links.php'; |
| 103 | } |
| 104 | |
| 105 | add_action( 'init', 'astra_sites_init_bsf_analytics', 5 ); |
| 106 | |
| 107 | /** |
| 108 | * Initializes BSF Analytics. |
| 109 | * |
| 110 | * @since 4.4.14 |
| 111 | * @return void |
| 112 | */ |
| 113 | function astra_sites_init_bsf_analytics() { |
| 114 | if ( ! class_exists( 'BSF_Analytics_Loader' ) || ! is_callable( 'BSF_Analytics_Loader::get_instance' ) ) { |
| 115 | return; |
| 116 | } |
| 117 | |
| 118 | $bsf_analytics = BSF_Analytics_Loader::get_instance(); |
| 119 | |
| 120 | $bsf_analytics->set_entity( |
| 121 | array( |
| 122 | 'bsf' => array( |
| 123 | 'product_name' => __( 'Starter Templates', 'astra-sites' ), |
| 124 | 'path' => ASTRA_SITES_DIR . 'admin/bsf-analytics', |
| 125 | 'author' => 'Brainstorm Force', |
| 126 | 'time_to_display' => '+24 hours', |
| 127 | 'deactivation_survey' => apply_filters( |
| 128 | 'astra_sites_bsf_analytics_deactivation_survey_data', |
| 129 | array( |
| 130 | array( |
| 131 | 'id' => 'deactivation-survey-astra-sites', |
| 132 | 'popup_logo' => ASTRA_SITES_URI . 'inc/lib/onboarding/assets/images/logo.svg', |
| 133 | 'plugin_slug' => 'astra-sites', |
| 134 | 'plugin_version' => ASTRA_SITES_VER, |
| 135 | 'popup_title' => __( 'Quick Feedback', 'astra-sites' ), |
| 136 | 'support_url' => 'https://wpastra.com/starter-templates-support/', |
| 137 | 'popup_description' => __( 'If you have a moment, please share why you are deactivating Starter Templates:', 'astra-sites' ), |
| 138 | 'show_on_screens' => array( 'plugins' ), |
| 139 | ), |
| 140 | ) |
| 141 | ), |
| 142 | ), |
| 143 | ) |
| 144 | ); |
| 145 | } |
| 146 | |
| 147 | if ( ! function_exists( 'astra_sites_redirect_to_onboarding' ) ) : |
| 148 | |
| 149 | /** |
| 150 | * Redirect to onboarding. |
| 151 | * |
| 152 | * @since 3.3.0 |
| 153 | * @return void |
| 154 | */ |
| 155 | function astra_sites_redirect_to_onboarding() { |
| 156 | if ( ! get_option( 'st_start_onboarding', false ) ) { |
| 157 | return; |
| 158 | } |
| 159 | |
| 160 | delete_option( 'st_start_onboarding' ); |
| 161 | if ( ! defined( 'WP_CLI' ) || ! WP_CLI ) { |
| 162 | wp_safe_redirect( admin_url( 'themes.php?page=starter-templates' ) ); |
| 163 | exit(); |
| 164 | } |
| 165 | } |
| 166 | |
| 167 | add_action( 'admin_init', 'astra_sites_redirect_to_onboarding' ); |
| 168 | |
| 169 | endif; |
| 170 | |
| 171 | if ( ! function_exists( 'astra_pro_sites_activate' ) ) : |
| 172 | |
| 173 | /** |
| 174 | * Astra pro sites activate. |
| 175 | * |
| 176 | * @since 4.1.2 |
| 177 | * @return void |
| 178 | */ |
| 179 | function astra_pro_sites_activate() { |
| 180 | update_option( 'st_start_onboarding', true ); |
| 181 | } |
| 182 | register_activation_hook( __FILE__, 'astra_pro_sites_activate' ); |
| 183 | |
| 184 | endif; |
| 185 |