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