| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* The plugin bootstrap file |
| 5 |
* |
| 6 |
* This file is read by WordPress to generate the plugin information in the plugin |
| 7 |
* admin area. This file also includes all of the dependencies used by the plugin, |
| 8 |
* registers the activation and deactivation functions, and defines a function |
| 9 |
* that starts the plugin. |
| 10 |
* |
| 11 |
* @link https://www.madebytribe.com |
| 12 |
* @since 1.0.0 |
| 13 |
* @package Caddy |
| 14 |
* |
| 15 |
* @wordpress-plugin |
| 16 |
* Plugin Name: Caddy for WooCommerce |
| 17 |
* Plugin URI: https://www.madebytribe.com |
| 18 |
* Description: Enhanced mini-cart replacement for WooCommerce. |
| 19 |
* Version: 1.0.0 |
| 20 |
* Author: Tribe Interactive |
| 21 |
* Author URI: https://www.madebytribe.com |
| 22 |
* License: GPL-2.0+ |
| 23 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt |
| 24 |
* Text Domain: caddy |
| 25 |
* Domain Path: /languages |
| 26 |
*/ |
| 27 |
|
| 28 |
// If this file is called directly, abort. |
| 29 |
if ( ! defined( 'WPINC' ) ) { |
| 30 |
die; |
| 31 |
} |
| 32 |
|
| 33 |
/** |
| 34 |
* Currently plugin version. |
| 35 |
* Start at version 1.0.0 and use SemVer - https://semver.org |
| 36 |
* Rename this for your plugin and update it as you release new versions. |
| 37 |
*/ |
| 38 |
define( 'CADDY_VERSION', '1.0.0' ); |
| 39 |
|
| 40 |
// Load Caddy_License class if it exists. |
| 41 |
//if ( ! class_exists( 'Caddy_License' ) ) { |
| 42 |
// require_once( plugin_dir_path( __FILE__ ) . 'wc-am-client.php' ); |
| 43 |
//} |
| 44 |
|
| 45 |
//if ( class_exists( 'Caddy_License' ) ) { |
| 46 |
// /** |
| 47 |
// * This file is only an example that includes a plugin header, and this code used to instantiate the client object. The variable $wcam_lib |
| 48 |
// * can be used to access the public properties from the WC_AM_Client class, but $wcam_lib must have a unique name. To find data saved by |
| 49 |
// * the WC_AM_Client in the options table, search for wc_am_client_{product_id}, so in this example it would be wc_am_client_13. |
| 50 |
// * |
| 51 |
// * All data here is sent to the WooCommerce API Manager API, except for the $software_title, which is used as a title, and menu label, for |
| 52 |
// * the API Key activation form the client will see. |
| 53 |
// * |
| 54 |
// * **** |
| 55 |
// * NOTE |
| 56 |
// * **** |
| 57 |
// * If $product_id is empty, the customer can manually enter the product_id into a form field on the activation screen. |
| 58 |
// * |
| 59 |
// * @param string $file Must be __FILE__ from the root plugin file, or theme functions, file locations. |
| 60 |
// * @param int $product_id Must match the Product ID number (integer) in the product. |
| 61 |
// * @param string $software_version This product's current software version. |
| 62 |
// * @param string $plugin_or_theme 'plugin' or 'theme' |
| 63 |
// * @param string $api_url The URL to the site that is running the API Manager. Example: https://www.toddlahman.com/ |
| 64 |
// * @param string $software_title The name, or title, of the product. The title is not sent to the API Manager APIs, but is used for menu titles. |
| 65 |
// * |
| 66 |
// * Example: |
| 67 |
// * |
| 68 |
// * $wcam_lib = new WC_AM_Client( $file, $product_id, $software_version, $plugin_or_theme, $api_url, $software_title ); |
| 69 |
// */ |
| 70 |
// |
| 71 |
// // Preferred positive integer product_id. |
| 72 |
// $caddy_api_lib = new Caddy_License( |
| 73 |
// __FILE__, |
| 74 |
// '', |
| 75 |
// '1.0.0', |
| 76 |
// 'plugin', |
| 77 |
// 'https://usecaddy.com', |
| 78 |
// 'Caddy Plugin' |
| 79 |
// ); |
| 80 |
//} |
| 81 |
|
| 82 |
/** |
| 83 |
* The code that runs during plugin activation. |
| 84 |
* This action is documented in includes/class-caddy-activator.php |
| 85 |
*/ |
| 86 |
function activate_caddy() { |
| 87 |
require_once plugin_dir_path( __FILE__ ) . 'includes/class-caddy-activator.php'; |
| 88 |
Caddy_Activator::activate(); |
| 89 |
} |
| 90 |
|
| 91 |
/** |
| 92 |
* The code that runs during plugin deactivation. |
| 93 |
* This action is documented in includes/class-caddy-deactivator.php |
| 94 |
*/ |
| 95 |
function deactivate_caddy() { |
| 96 |
require_once plugin_dir_path( __FILE__ ) . 'includes/class-caddy-deactivator.php'; |
| 97 |
Caddy_Deactivator::deactivate(); |
| 98 |
} |
| 99 |
|
| 100 |
register_activation_hook( __FILE__, 'activate_caddy' ); |
| 101 |
register_deactivation_hook( __FILE__, 'deactivate_caddy' ); |
| 102 |
|
| 103 |
/** |
| 104 |
* The core plugin class that is used to define internationalization, |
| 105 |
* admin-specific hooks, and public-facing site hooks. |
| 106 |
*/ |
| 107 |
require plugin_dir_path( __FILE__ ) . 'includes/class-caddy.php'; |
| 108 |
|
| 109 |
/** |
| 110 |
* Begins execution of the plugin. |
| 111 |
* |
| 112 |
* Since everything within the plugin is registered via hooks, |
| 113 |
* then kicking off the plugin from this point in the file does |
| 114 |
* not affect the page life cycle. |
| 115 |
* |
| 116 |
* @since 1.0.0 |
| 117 |
*/ |
| 118 |
function run_caddy() { |
| 119 |
|
| 120 |
$plugin = new Caddy(); |
| 121 |
$plugin->run(); |
| 122 |
|
| 123 |
} |
| 124 |
|
| 125 |
run_caddy(); |
| 126 |
|
| 127 |
/** |
| 128 |
* Add plugin settings link. |
| 129 |
* |
| 130 |
* @param $links |
| 131 |
* |
| 132 |
* @return mixed |
| 133 |
*/ |
| 134 |
function cc_add_settings_link( $links ) { |
| 135 |
$settings_link = '<a href="admin.php?page=caddy">' . __( 'Settings' ) . '</a>'; |
| 136 |
array_push( $links, $settings_link ); |
| 137 |
|
| 138 |
return $links; |
| 139 |
} |
| 140 |
|
| 141 |
$plugin = plugin_basename( __FILE__ ); |
| 142 |
add_filter( "plugin_action_links_$plugin", 'cc_add_settings_link' ); |
| 143 |
|