PluginProbe
Modern Cart – WooCommerce Side Cart & Popup Cart / 1.0.3
Modern Cart – WooCommerce Side Cart & Popup Cart v1.0.3
1.0.10 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9
modern-cart / modern-cart.php

modern-cart.php in Modern Cart – WooCommerce Side Cart & Popup Cart 1.0.3, at modern-cart.php

141 lines 4.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Plugin Name: Modern Cart Starter for WooCommerce
4 * Description: The Modern Cart Starter enhances your WooCommerce cart with more features and customization options.
5 * Author: CartFlows
6 * Author URI: https://cartflows.com/
7 * Version: 1.0.3
8 * License: GPL v2
9 * License URI: https://www.gnu.org/licenses/gpl-2.0.html
10 * Text Domain: modern-cart
11 * WC requires at least: 3.0
12 * WC tested up to: 9.8.4
13 *
14 * Requires Plugins: woocommerce
15 *
16 * @package modern-cart
17 */
18
19 if ( ! defined( 'ABSPATH' ) ) {
20 exit; // Exit if accessed directly.
21 }
22
23 /**
24 * Checks if it is safe to initialize the Modern Cart Starter plugin.
25 *
26 * This function determines whether the Modern Cart Starter plugin can be safely initialized
27 * based on the presence and version of the Modern Cart Pro plugin. If the Pro plugin is not
28 * installed, or if it is installed and its version is 1.2.0 or higher, it is considered safe
29 * to initialize the Starter plugin.
30 *
31 * @return bool True if safe to initialize, false otherwise.
32 */
33 function moderncart_is_safe_to_init() {
34 // Ensure the get_file_data function is available.
35 if ( ! function_exists( 'get_file_data' ) ) {
36 require_once ABSPATH . 'wp-includes/functions.php';
37 }
38
39 $modern_cart_woo_file = untrailingslashit( WP_PLUGIN_DIR ) . '/modern-cart-woo/modern-cart-woo.php';
40
41 if ( ! file_exists( $modern_cart_woo_file ) ) {
42 // Pro plugin is not installed on this site.
43 return true;
44 }
45
46 // Retrieve the version of the Pro plugin, if installed.
47 $pro_plugin_data = get_file_data(
48 $modern_cart_woo_file,
49 [ 'Version' => 'Version' ],
50 'plugin'
51 );
52 $pro_plugin_version = $pro_plugin_data['Version'];
53
54 if ( version_compare( $pro_plugin_version, '1.2.0', '>=' ) ) {
55 // Pro plugin version is 1.2.0 or higher; safe to initialize.
56 return true;
57 }
58
59 // Pro plugin is installed but version is less than 1.2.0; not safe to initialize.
60 return false;
61 }
62
63 if ( ! moderncart_is_safe_to_init() ) {
64 add_action(
65 'admin_notices',
66 function() {
67 ?>
68 <div class="notice notice-error">
69 <p>
70 <strong><?php esc_html_e( 'Modern Cart for WooCommerce: Update Required', 'modern-cart' ); ?></strong><br>
71 <?php
72 echo wp_kses_post(
73 sprintf(
74 /* translators: %1$s and %2$s are opening and closing <strong> tags for emphasis. */
75 __( 'You\'re using an older version of %1$sModern Cart for WooCommerce%2$s. Please update to version %1$s1.2.0 or higher%2$s so it works smoothly with %1$sModern Cart Starter%2$s.', 'modern-cart' ),
76 '<strong>',
77 '</strong>'
78 )
79 );
80 ?>
81 </p>
82 </div>
83 <?php
84 }
85 );
86
87 // Return from here early and stop the further execution, this will make sure that user don't get any fatal errors due to version incompatibility.
88 return;
89 }
90
91
92 /**
93 * Set constants
94 */
95 if ( ! defined( 'MODERNCART_FILE' ) ) {
96 define( 'MODERNCART_FILE', __FILE__ );
97 }
98 if ( ! defined( 'MODERNCART_BASE' ) ) {
99 define( 'MODERNCART_BASE', plugin_basename( MODERNCART_FILE ) );
100 }
101 if ( ! defined( 'MODERNCART_DIR' ) ) {
102 define( 'MODERNCART_DIR', (string) plugin_dir_path( MODERNCART_FILE ) );
103 }
104 if ( ! defined( 'MODERNCART_URL' ) ) {
105 define( 'MODERNCART_URL', plugins_url( '/', MODERNCART_FILE ) );
106 }
107 if ( ! defined( 'MODERNCART_PLUGIN_PATH' ) ) {
108 define( 'MODERNCART_PLUGIN_PATH', untrailingslashit( MODERNCART_DIR ) );
109 }
110 if ( ! defined( 'MODERNCART_VER' ) ) {
111 define( 'MODERNCART_VER', '1.0.3' );
112 }
113 if ( ! defined( 'MODERNCART_MAIN_SETTINGS' ) ) {
114 define( 'MODERNCART_MAIN_SETTINGS', 'moderncart_setting' );
115 }
116 if ( ! defined( 'MODERNCART_SETTINGS' ) ) {
117 define( 'MODERNCART_SETTINGS', 'moderncart_cart' );
118 }
119 if ( ! defined( 'MODERNCART_FLOATING_SETTINGS' ) ) {
120 define( 'MODERNCART_FLOATING_SETTINGS', 'moderncart_floating' );
121 }
122 if ( ! defined( 'MODERNCART_APPEARANCE_SETTINGS' ) ) {
123 define( 'MODERNCART_APPEARANCE_SETTINGS', 'moderncart_appearance' );
124 }
125 if ( ! defined( 'CARTFLOWS_DOMAIN_URL' ) ) {
126 define( 'CARTFLOWS_DOMAIN_URL', 'https://cartflows.com' );
127 }
128 if ( ! defined( 'CARTFLOWS_API_ROUTE' ) ) {
129 define( 'CARTFLOWS_API_ROUTE', '/wp-json/powerful-docs/v1' );
130 }
131 if ( ! defined( 'CARTFLOWS_DOCS_ENDPOINT' ) ) {
132 define( 'CARTFLOWS_DOCS_ENDPOINT', '/get-docs' );
133 }
134
135 if ( ! defined( 'MODERNCART_DEBUG' ) ) {
136 define( 'MODERNCART_DEBUG', false );
137 }
138
139 require_once 'inc/functions.php';
140 require_once 'plugin-loader.php';
141