PluginProbe
Caddy – WooCommerce Side Cart & Free Shipping Bar / 3.0.1
Caddy – WooCommerce Side Cart & Free Shipping Bar v3.0.1
3.2.0 3.1.1 trunk 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7.1 1.7.2 1.7.3 1.7.4 1.7.5 1.7.6 1.7.7 1.7.8 1.7.9 1.8 1.8.1 1.8.2 1.9 1.9.2 1.9.3 All 46 releases
caddy / caddy.php

caddy.php in Caddy – WooCommerce Side Cart & Free Shipping Bar 3.0.1, at caddy.php

186 lines 5.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Plugin Name: Caddy - Smart Side Cart for WooCommerce
4 * Plugin URI: https://usecaddy.com
5 * Description: A high performance, conversion-boosting side cart for your WooCommerce store that improves the shopping experience & helps grow your sales.
6 * Version: 3.0.1
7 * Author: Tribe Interactive
8 * Author URI: https://usecaddy.com
9 * License: GPL-2.0+
10 * License URI: http://www.gnu.org/licenses/gpl-2.0.txt
11 * Text Domain: caddy
12 * Domain Path: /languages
13 * Requires at least: 6.5
14 * Requires PHP: 7.4
15 *
16 * WC requires at least: 7.0
17 * WC tested up to: 10.2.4
18 */
19
20 // If this file is called directly, abort.
21 if ( ! defined( 'WPINC' ) ) {
22 die;
23 }
24
25 /*
26 * Define all constants for the plugin
27 */
28 if ( ! defined( 'CADDY_VERSION' ) ) {
29 define( 'CADDY_VERSION', '3.0.1' );
30 }
31 if ( ! defined( 'CADDY_PLUGIN_FILE' ) ) {
32 define( 'CADDY_PLUGIN_FILE', __FILE__ );
33 }
34 if ( ! defined( 'CADDY_DIR_URL' ) ) {
35 define( 'CADDY_DIR_URL', untrailingslashit( plugins_url( '/', CADDY_PLUGIN_FILE ) ) );
36 }
37
38 // If Caddy Premium v3+ is active, bail out — Premium replaces all free functionality.
39 // For older Premium versions (< 3.0.0) we must NOT bail, because they depend on
40 // classes from the free plugin (e.g. Caddy_Admin). We show an upgrade notice instead.
41 if ( defined( 'CADDY_PREMIUM_VERSION' ) || defined( 'CADDY_PREMIUM_PLUGIN_FILE' ) ) {
42 $caddy_premium_ver = defined( 'CADDY_PREMIUM_VERSION' ) ? CADDY_PREMIUM_VERSION : '0';
43 if ( version_compare( $caddy_premium_ver, '3.0.0', '>=' ) ) {
44 return;
45 }
46 // Old Premium detected — continue loading so it doesn't crash, and warn the admin.
47 add_action( 'admin_notices', function () {
48 if ( ! current_user_can( 'update_plugins' ) ) {
49 return;
50 }
51 echo '<div class="notice notice-error"><p>';
52 echo '<strong>' . esc_html__( 'Caddy Pro update required:', 'caddy' ) . '</strong> ';
53 echo esc_html__( 'Your version of Caddy Pro is not compatible with Caddy 3.0. Please update Caddy Pro to version 3.0 or later to avoid errors.', 'caddy' );
54 echo '</p></div>';
55 } );
56 }
57
58 if ( ! function_exists( 'is_plugin_active_for_network' ) ) {
59 require_once( ABSPATH . '/wp-admin/includes/plugin.php' );
60 }
61
62 $caddy_wc_missing = false;
63 if ( is_multisite() ) {
64 if ( is_plugin_active_for_network( plugin_basename( __FILE__ ) ) ) {
65 $caddy_wc_missing = ! is_plugin_active_for_network( 'woocommerce/woocommerce.php' );
66 } else {
67 $caddy_wc_missing = ! is_plugin_active( 'woocommerce/woocommerce.php' );
68 }
69 } else {
70 $caddy_wc_missing = ! is_plugin_active( 'woocommerce/woocommerce.php' );
71 }
72
73 if ( $caddy_wc_missing ) {
74 add_action( 'admin_notices', 'caddy_wc_requirements_error' );
75 return;
76 }
77 unset( $caddy_wc_missing );
78
79 /**
80 * If WC requirements are not match
81 */
82 function caddy_wc_requirements_error() {
83 ?>
84 <div class="error notice"><p>
85 <strong><?php esc_html_e( 'The WooCommerce plugin needs to be installed and activated in order for Caddy to work properly.', 'caddy' ); ?></strong> <?php esc_html_e( 'Please activate WooCommerce to enable Caddy.', 'caddy' ); ?>
86 </p></div>
87 <?php
88 }
89
90 /**
91 * The code that runs during plugin activation.
92 * This action is documented in includes/class-caddy-activator.php
93 */
94 function activate_caddy() {
95 require_once plugin_dir_path( __FILE__ ) . 'includes/class-caddy-activator.php';
96 Caddy_Activator::activate();
97 }
98
99 /**
100 * The code that runs during plugin deactivation.
101 * This action is documented in includes/class-caddy-deactivator.php
102 */
103 function deactivate_caddy() {
104 require_once plugin_dir_path( __FILE__ ) . 'includes/class-caddy-deactivator.php';
105 Caddy_Deactivator::deactivate();
106 }
107
108 register_activation_hook( __FILE__, 'activate_caddy' );
109 register_deactivation_hook( __FILE__, 'deactivate_caddy' );
110
111 /**
112 * The core plugin class that is used to define internationalization,
113 * admin-specific hooks, and public-facing site hooks.
114 */
115 require plugin_dir_path( __FILE__ ) . 'includes/class-caddy.php';
116
117 /**
118 * The plugin class that is used to register and load the cart widget.
119 */
120 require plugin_dir_path( __FILE__ ) . 'includes/class-caddy-cart-widget.php';
121
122 /**
123 * The plugin class that is used to register and load the saved items widget.
124 */
125 require plugin_dir_path( __FILE__ ) . 'includes/class-caddy-saved-items-widget.php';
126
127 /**
128 * Load notices
129 */
130 require_once plugin_dir_path( __FILE__ ) . 'includes/class-caddy-notices.php';
131
132 /**
133 * Load composer
134 */
135 if (file_exists(__DIR__ . '/vendor/autoload.php')) {
136 require_once __DIR__ . '/vendor/autoload.php';
137 }
138
139 /**
140 * Begins execution of the plugin.
141 *
142 * Since everything within the plugin is registered via hooks,
143 * then kicking off the plugin from this point in the file does
144 * not affect the page life cycle.
145 *
146 * @since 1.0.0
147 */
148 function run_caddy() {
149
150 $plugin = new Caddy();
151 $plugin->run();
152
153 }
154
155 run_caddy();
156
157 /**
158 * Add plugin settings link.
159 *
160 * @param $caddy_links
161 *
162 * @return mixed
163 */
164 function caddy_add_settings_link( $caddy_links ) {
165
166 $caddy_links = array_merge( array( '<a href="' . esc_url( admin_url( '/admin.php?page=caddy&amp;tab=settings' ) ) . '">' . esc_html__( 'Settings', 'caddy' ) . '</a>' ), $caddy_links );
167
168 return $caddy_links;
169 }
170
171 $caddy_plugin = plugin_basename( __FILE__ );
172 add_filter( "plugin_action_links_$caddy_plugin", 'caddy_add_settings_link' );
173
174 /**
175 * Declaring WooCommerce HPOS support
176 *
177 */
178 add_action( 'before_woocommerce_init', function() {
179 if ( class_exists( \Automattic\WooCommerce\Utilities\FeaturesUtil::class ) ) {
180 \Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'custom_order_tables', __FILE__, true );
181 }
182 } );
183
184 // Initialize the admin notice dismissal library
185 add_action('admin_init', array('PAnD', 'init'));
186