| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* @link https://www.madebytribe.com |
| 5 |
* @since 1.0.0 |
| 6 |
* @package Caddy |
| 7 |
* |
| 8 |
* @wordpress-plugin |
| 9 |
* Plugin Name: Caddy |
| 10 |
* Plugin URI: https://usecaddy.com |
| 11 |
* Description: Enhanced mini-cart drawer for WooCommerce with up-selling, free shipping meter and save for later list. |
| 12 |
* Version: 1.1 |
| 13 |
* Author: Tribe Interactive |
| 14 |
* Author URI: https://www.madebytribe.com |
| 15 |
* License: GPL-2.0+ |
| 16 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt |
| 17 |
* Text Domain: caddy |
| 18 |
* Domain Path: /languages |
| 19 |
* |
| 20 |
* WC requires at least: 3.0 |
| 21 |
* WC tested up to: 4.0.1 |
| 22 |
*/ |
| 23 |
|
| 24 |
// If this file is called directly, abort. |
| 25 |
if ( ! defined( 'WPINC' ) ) { |
| 26 |
die; |
| 27 |
} |
| 28 |
|
| 29 |
/* |
| 30 |
* Define all constants for the plugin |
| 31 |
*/ |
| 32 |
if ( ! defined( 'CADDY_VERSION' ) ) { |
| 33 |
define( 'CADDY_VERSION', '1.1' ); |
| 34 |
} |
| 35 |
if ( ! defined( 'CADDY_PLUGIN_FILE' ) ) { |
| 36 |
define( 'CADDY_PLUGIN_FILE', __FILE__ ); |
| 37 |
} |
| 38 |
|
| 39 |
/** |
| 40 |
* Checks if the WC requirements are met |
| 41 |
* |
| 42 |
* @return bool True if system requirements are met, false if not |
| 43 |
*/ |
| 44 |
function caddy_wc_requirements_met() { |
| 45 |
|
| 46 |
/** |
| 47 |
* Check if WooCommerce is active |
| 48 |
**/ |
| 49 |
if ( ! in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) { |
| 50 |
return false; |
| 51 |
} |
| 52 |
|
| 53 |
return true; |
| 54 |
} |
| 55 |
|
| 56 |
if ( caddy_wc_requirements_met() ) { |
| 57 |
|
| 58 |
/** |
| 59 |
* The code that runs during plugin activation. |
| 60 |
* This action is documented in includes/class-caddy-activator.php |
| 61 |
*/ |
| 62 |
function activate_caddy() { |
| 63 |
require_once plugin_dir_path( __FILE__ ) . 'includes/class-caddy-activator.php'; |
| 64 |
Caddy_Activator::activate(); |
| 65 |
} |
| 66 |
|
| 67 |
/** |
| 68 |
* The code that runs during plugin deactivation. |
| 69 |
* This action is documented in includes/class-caddy-deactivator.php |
| 70 |
*/ |
| 71 |
function deactivate_caddy() { |
| 72 |
require_once plugin_dir_path( __FILE__ ) . 'includes/class-caddy-deactivator.php'; |
| 73 |
Caddy_Deactivator::deactivate(); |
| 74 |
} |
| 75 |
|
| 76 |
register_activation_hook( __FILE__, 'activate_caddy' ); |
| 77 |
register_deactivation_hook( __FILE__, 'deactivate_caddy' ); |
| 78 |
|
| 79 |
/** |
| 80 |
* The core plugin class that is used to define internationalization, |
| 81 |
* admin-specific hooks, and public-facing site hooks. |
| 82 |
*/ |
| 83 |
require plugin_dir_path( __FILE__ ) . 'includes/class-caddy.php'; |
| 84 |
|
| 85 |
/** |
| 86 |
* Begins execution of the plugin. |
| 87 |
* |
| 88 |
* Since everything within the plugin is registered via hooks, |
| 89 |
* then kicking off the plugin from this point in the file does |
| 90 |
* not affect the page life cycle. |
| 91 |
* |
| 92 |
* @since 1.0.0 |
| 93 |
*/ |
| 94 |
function run_caddy() { |
| 95 |
|
| 96 |
$plugin = new Caddy(); |
| 97 |
$plugin->run(); |
| 98 |
|
| 99 |
} |
| 100 |
|
| 101 |
run_caddy(); |
| 102 |
|
| 103 |
/** |
| 104 |
* Add plugin settings link. |
| 105 |
* |
| 106 |
* @param $links |
| 107 |
* |
| 108 |
* @return mixed |
| 109 |
*/ |
| 110 |
function cc_add_settings_link( $links ) { |
| 111 |
$settings_link = '<a href="admin.php?page=caddy&tab=settings">' . __( 'Settings' ) . '</a>'; |
| 112 |
array_push( $links, $settings_link ); |
| 113 |
|
| 114 |
return $links; |
| 115 |
} |
| 116 |
|
| 117 |
$plugin = plugin_basename( __FILE__ ); |
| 118 |
add_filter( "plugin_action_links_$plugin", 'cc_add_settings_link' ); |
| 119 |
|
| 120 |
} else { |
| 121 |
|
| 122 |
add_action( 'admin_notices', 'caddy_wc_requirements_error' ); |
| 123 |
|
| 124 |
} |
| 125 |
|
| 126 |
/** |
| 127 |
* If WC requirements are not match |
| 128 |
*/ |
| 129 |
function caddy_wc_requirements_error() { |
| 130 |
?> |
| 131 |
<div class="error notice"><p> |
| 132 |
<strong><?php _e( 'The WooCommerce plugin needs to be installed and activated in order for Caddy to work properly.', 'caddy' ); ?></strong> <?php _e( 'Please activate WooCommerce to enable Caddy.', 'caddy' ); ?> |
| 133 |
</p></div> |
| 134 |
<?php |
| 135 |
} |
| 136 |
|