| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* Plugin Name: Ultimate Store Kit |
| 5 |
* Plugin URI: https://bdthemes.com/ultimate-store-kit/ |
| 6 |
* Description: Build online stores in WordPress with the powerful store builder addon for Elementor. Enjoy a wide range of customizations and easily build product grids, carousels, single product/page elements, checkouts and more. |
| 7 |
* Version: 3.0.7 |
| 8 |
* Author: BdThemes |
| 9 |
* Author URI: https://bdthemes.com/ |
| 10 |
* Text Domain: ultimate-store-kit |
| 11 |
* Domain Path: /languages |
| 12 |
* License: GPL3 |
| 13 |
* Elementor requires at least: 4.0.0 |
| 14 |
* Elementor tested up to: 4.2.0 |
| 15 |
*/ |
| 16 |
|
| 17 |
|
| 18 |
// Check if vendor directory and autoload.php exist |
| 19 |
$ultimate_store_kit_autoload_file = __DIR__ . '/vendor/autoload.php'; |
| 20 |
if (file_exists($ultimate_store_kit_autoload_file)) { |
| 21 |
// Load autoloader (vendor/autoload.php). |
| 22 |
require_once $ultimate_store_kit_autoload_file; |
| 23 |
} |
| 24 |
|
| 25 |
// Some pre define value for easy use |
| 26 |
define('BDTUSK_VER', '3.0.7'); |
| 27 |
define('BDTUSK__FILE__', __FILE__); |
| 28 |
define('BDTUSK_PNAME', basename(dirname(BDTUSK__FILE__))); |
| 29 |
define('BDTUSK_PBNAME', plugin_basename(BDTUSK__FILE__)); |
| 30 |
define('BDTUSK_PATH', plugin_dir_path(BDTUSK__FILE__)); |
| 31 |
define('BDTUSK_URL', plugins_url('/', BDTUSK__FILE__)); |
| 32 |
define('BDTUSK_MODULES_PATH', BDTUSK_PATH . 'modules/'); |
| 33 |
define('BDTUSK_INC_PATH', BDTUSK_PATH . 'includes/'); |
| 34 |
define('BDTUSK_ADMIN_PATH', BDTUSK_PATH . 'admin/'); |
| 35 |
define('BDTUSK_ADMIN_URL', BDTUSK_URL . 'admin/'); |
| 36 |
define('BDTUSK_ASSETS_URL', BDTUSK_URL . 'assets/'); |
| 37 |
define('BDTUSK_ASSETS_PATH', BDTUSK_PATH . 'assets/'); |
| 38 |
define('BDTUSK_MODULES_URL', BDTUSK_URL . 'modules/'); |
| 39 |
define('BDTUSK_ADM_PATH', BDTUSK_PATH . 'admin/'); |
| 40 |
define('BDTUSK_ADM_ASSETS_URL', BDTUSK_URL . 'includes/Admin/assets/'); |
| 41 |
define('BDTUSK_BUILD_URL', BDTUSK_URL . 'build/'); |
| 42 |
|
| 43 |
define('BDTUSK_TITLE', 'Ultimate Store Kit'); |
| 44 |
|
| 45 |
/** |
| 46 |
* Loads translations |
| 47 |
* |
| 48 |
* @return void |
| 49 |
*/ |
| 50 |
|
| 51 |
if (! function_exists('bdthemes_ultimate_store_kit_load_textdomain')) { |
| 52 |
function bdthemes_ultimate_store_kit_load_textdomain() { |
| 53 |
load_plugin_textdomain('ultimate-store-kit', false, basename(dirname(__FILE__)) . '/languages'); |
| 54 |
} |
| 55 |
add_action('init', 'bdthemes_ultimate_store_kit_load_textdomain'); |
| 56 |
} |
| 57 |
|
| 58 |
if (! function_exists('_is_usk_pro_installed')) { |
| 59 |
|
| 60 |
function _is_usk_pro_installed() { |
| 61 |
|
| 62 |
if (! function_exists('get_plugins')) { |
| 63 |
require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
| 64 |
} |
| 65 |
|
| 66 |
$file_path = 'ultimate-store-kit-pro/ultimate-store-kit-pro.php'; |
| 67 |
$installed_plugins = get_plugins(); |
| 68 |
|
| 69 |
return isset($installed_plugins[$file_path]); |
| 70 |
} |
| 71 |
} |
| 72 |
|
| 73 |
if (! function_exists('_is_usk_pro_activated')) { |
| 74 |
|
| 75 |
function _is_usk_pro_activated() { |
| 76 |
|
| 77 |
if (! function_exists('get_plugins')) { |
| 78 |
require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
| 79 |
} |
| 80 |
|
| 81 |
$file_path = 'ultimate-store-kit-pro/ultimate-store-kit-pro.php'; |
| 82 |
$installed_plugins = get_plugins(); |
| 83 |
|
| 84 |
if (is_plugin_active($file_path)) { |
| 85 |
return true; |
| 86 |
} |
| 87 |
|
| 88 |
return false; |
| 89 |
} |
| 90 |
} |
| 91 |
|
| 92 |
// Helper function here |
| 93 |
require(dirname(__FILE__) . '/includes/helper.php'); |
| 94 |
|
| 95 |
if (! _is_usk_pro_activated()) { |
| 96 |
require_once BDTUSK_INC_PATH . 'class-pro-widget-map.php'; |
| 97 |
} |
| 98 |
|
| 99 |
if (function_exists('usk_license_validation') && true !== usk_license_validation()) { |
| 100 |
require_once BDTUSK_INC_PATH . 'class-pro-widget-map.php'; |
| 101 |
} |
| 102 |
|
| 103 |
require(dirname(__FILE__) . '/includes/utils.php'); |
| 104 |
|
| 105 |
|
| 106 |
/** |
| 107 |
* Plugin load here correctly |
| 108 |
* Also loaded the language file from here |
| 109 |
*/ |
| 110 |
function bdthemes_ultimate_store_kit_load_plugin() { |
| 111 |
|
| 112 |
if (! did_action('elementor/loaded')) { |
| 113 |
add_action('admin_notices', 'bdthemes_ultimate_store_kit_fail_load'); |
| 114 |
return; |
| 115 |
} |
| 116 |
|
| 117 |
if ((! class_exists('Easy_Digital_Downloads')) && (! class_exists('woocommerce'))) { |
| 118 |
add_action('admin_notices', 'bdthemes_ultimate_store_kit_dependencies_plugin_fail_load'); |
| 119 |
return; |
| 120 |
} |
| 121 |
|
| 122 |
// Widgets filters here |
| 123 |
require(BDTUSK_INC_PATH . 'ultimate-store-kit-filters.php'); |
| 124 |
|
| 125 |
// Element pack widget and assets loader |
| 126 |
require(BDTUSK_PATH . 'loader.php'); |
| 127 |
} |
| 128 |
add_action('plugins_loaded', 'bdthemes_ultimate_store_kit_load_plugin', 9); |
| 129 |
|
| 130 |
|
| 131 |
/** |
| 132 |
* Check Elementor installed and activated correctly |
| 133 |
*/ |
| 134 |
function bdthemes_ultimate_store_kit_fail_load() { |
| 135 |
$screen = get_current_screen(); |
| 136 |
if (isset($screen->parent_file) && 'plugins.php' === $screen->parent_file && 'update' === $screen->id) { |
| 137 |
return; |
| 138 |
} |
| 139 |
|
| 140 |
$plugin = 'elementor/elementor.php'; |
| 141 |
|
| 142 |
if (_is_dep_plugin_installed($plugin)) { |
| 143 |
if (! current_user_can('activate_plugins')) { |
| 144 |
return; |
| 145 |
} |
| 146 |
$activation_url = wp_nonce_url('plugins.php?action=activate&plugin=' . $plugin . '&plugin_status=all&paged=1&s', 'activate-plugin_' . $plugin); |
| 147 |
$admin_message = '<p>' . esc_html__('Ops! Ultimate Store Kit not working because you need to activate the Elementor plugin first.', 'ultimate-store-kit') . '</p>'; |
| 148 |
$admin_message .= '<p>' . sprintf('<a href="%s" class="button-primary">%s</a>', $activation_url, esc_html__('Activate Elementor Now', 'ultimate-store-kit')) . '</p>'; |
| 149 |
} else { |
| 150 |
if (! current_user_can('install_plugins')) { |
| 151 |
return; |
| 152 |
} |
| 153 |
$install_url = wp_nonce_url(self_admin_url('update.php?action=install-plugin&plugin=elementor'), 'install-plugin_elementor'); |
| 154 |
$admin_message = '<p>' . esc_html__('Ops! Ultimate Store Kit not working because you need to install the Elementor plugin', 'ultimate-store-kit') . '</p>'; |
| 155 |
$admin_message .= '<p>' . sprintf('<a href="%s" class="button-primary">%s</a>', $install_url, esc_html__('Install Elementor Now', 'ultimate-store-kit')) . '</p>'; |
| 156 |
} |
| 157 |
|
| 158 |
printf('<div class="error">%1$s</div>', wp_kses_post($admin_message)); |
| 159 |
} |
| 160 |
|
| 161 |
/** |
| 162 |
* Check Woocommerce installed and activated correctly |
| 163 |
*/ |
| 164 |
function bdthemes_ultimate_store_kit_dependencies_plugin_fail_load() { |
| 165 |
$screen = get_current_screen(); |
| 166 |
if (isset($screen->parent_file) && 'plugins.php' === $screen->parent_file && 'update' === $screen->id) { |
| 167 |
return; |
| 168 |
} |
| 169 |
|
| 170 |
$plugin = 'woocommerce/woocommerce.php'; |
| 171 |
|
| 172 |
if (_is_dep_plugin_installed($plugin)) { |
| 173 |
if (! current_user_can('activate_plugins')) { |
| 174 |
return; |
| 175 |
} |
| 176 |
$activation_url = wp_nonce_url('plugins.php?action=activate&plugin=' . $plugin . '&plugin_status=all&paged=1&s', 'activate-plugin_' . $plugin); |
| 177 |
$admin_message = '<p>' . esc_html__('Ops! Ultimate Store Kit not working because you need to activate a eCommerce plugin like WooCommerce or Easy Digital Downloads first.', 'ultimate-store-kit') . '</p>'; |
| 178 |
$admin_message .= '<p>' . sprintf('<a href="%s" class="button-primary">%s</a>', $activation_url, esc_html__('Activate WooCommerce Now', 'ultimate-store-kit')) . '</p>'; |
| 179 |
} else { |
| 180 |
if (! current_user_can('install_plugins')) { |
| 181 |
return; |
| 182 |
} |
| 183 |
$install_url = wp_nonce_url(self_admin_url('update.php?action=install-plugin&plugin=woocommerce'), 'install-plugin_woocommerce'); |
| 184 |
$admin_message = '<p>' . esc_html__('Ops! Ultimate Store Kit not working because you need to install a eCommerce plugin like WooCommerce or Easy Digital Download first.', 'ultimate-store-kit') . '</p>'; |
| 185 |
$admin_message .= '<p>' . sprintf('<a href="%s" class="button-primary">%s</a>', $install_url, esc_html__('Install WooCommerce Now', 'ultimate-store-kit')) . '</p>'; |
| 186 |
} |
| 187 |
|
| 188 |
printf('<div class="error">%1$s</div>', wp_kses_post($admin_message)); |
| 189 |
} |
| 190 |
|
| 191 |
if (! function_exists('_is_dep_plugin_installed')) { |
| 192 |
|
| 193 |
/** |
| 194 |
* @plug_slug string plugins slug which you want to check installed or not |
| 195 |
*/ |
| 196 |
function _is_dep_plugin_installed($plugin_slug) { |
| 197 |
$file_path = $plugin_slug; |
| 198 |
$installed_plugins = get_plugins(); |
| 199 |
|
| 200 |
return isset($installed_plugins[$file_path]); |
| 201 |
} |
| 202 |
} |
| 203 |
|