yith-woocommerce-compare
Last commit date
assets
3 years ago
includes
3 years ago
languages
3 years ago
plugin-fw
3 years ago
plugin-options
3 years ago
templates
3 years ago
widgets
3 years ago
init.php
3 years ago
license.txt
3 years ago
readme.txt
3 years ago
wpml-config.xml
3 years ago
init.php
145 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Plugin Name: YITH WooCommerce Compare |
| 4 | * Plugin URI: https://yithemes.com/themes/plugins/yith-woocommerce-compare/ |
| 5 | * Description: The <code><strong>YITH WooCommerce Compare</strong></code> plugin allow you to compare in a simple and efficient way products on sale in your shop and analyze their main features in a single table. <a href="https://yithemes.com/" target="_blank">Get more plugins for your e-commerce shop on <strong>YITH</strong></a>. |
| 6 | * Version: 2.20.0 |
| 7 | * Author: YITH |
| 8 | * Author URI: https://yithemes.com/ |
| 9 | * Text Domain: yith-woocommerce-compare |
| 10 | * Domain Path: /languages/ |
| 11 | * WC requires at least: 6.4 |
| 12 | * WC tested up to: 7.1 |
| 13 | * |
| 14 | * @author YITH |
| 15 | * @package YITH WooCommerce Compare |
| 16 | * @version 2.20.0 |
| 17 | */ |
| 18 | |
| 19 | /* |
| 20 | Copyright 2013-2022 Your Inspiration Solutions (email : plugins@yithemes.com) |
| 21 | |
| 22 | This program is free software; you can redistribute it and/or modify |
| 23 | it under the terms of the GNU General Public License, version 2, as |
| 24 | published by the Free Software Foundation. |
| 25 | |
| 26 | This program is distributed in the hope that it will be useful, |
| 27 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 28 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 29 | GNU General Public License for more details. |
| 30 | |
| 31 | You should have received a copy of the GNU General Public License |
| 32 | along with this program; if not, write to the Free Software |
| 33 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 34 | */ |
| 35 | |
| 36 | defined( 'ABSPATH' ) || exit; // Exit if accessed directly. |
| 37 | |
| 38 | if ( ! function_exists( 'is_plugin_active' ) ) { |
| 39 | require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
| 40 | } |
| 41 | |
| 42 | /** |
| 43 | * Error message if WooCommerce is not installed |
| 44 | * |
| 45 | * @since 1.0.0 |
| 46 | * @author Francesco Licandro |
| 47 | * @return void |
| 48 | */ |
| 49 | function yith_woocompare_install_woocommerce_admin_notice() { |
| 50 | ?> |
| 51 | <div class="error"> |
| 52 | <p><?php esc_html_e( 'YITH WooCommerce Compare is enabled but not effective. It requires WooCommerce in order to work.', 'yith-woocommerce-compare' ); ?></p> |
| 53 | </div> |
| 54 | <?php |
| 55 | } |
| 56 | |
| 57 | /** |
| 58 | * Error message if premium version is installed |
| 59 | * |
| 60 | * @since 1.0.0 |
| 61 | * @author Francesco Licandro |
| 62 | * @return void |
| 63 | */ |
| 64 | function yith_woocompare_install_free_admin_notice() { |
| 65 | ?> |
| 66 | <div class="error"> |
| 67 | <p><?php esc_html_e( 'You can\'t activate the free version of YITH WooCommerce Compare while you are using the premium one.', 'yith-woocommerce-compare' ); ?></p> |
| 68 | </div> |
| 69 | <?php |
| 70 | } |
| 71 | |
| 72 | if ( ! function_exists( 'yith_plugin_registration_hook' ) ) { |
| 73 | require_once 'plugin-fw/yit-plugin-registration-hook.php'; |
| 74 | } |
| 75 | register_activation_hook( __FILE__, 'yith_plugin_registration_hook' ); |
| 76 | |
| 77 | if ( ! defined( 'YITH_WOOCOMPARE_VERSION' ) ) { |
| 78 | define( 'YITH_WOOCOMPARE_VERSION', '2.20.0' ); |
| 79 | } |
| 80 | if ( ! defined( 'YITH_WOOCOMPARE_FREE_INIT' ) ) { |
| 81 | define( 'YITH_WOOCOMPARE_FREE_INIT', plugin_basename( __FILE__ ) ); |
| 82 | } |
| 83 | if ( ! defined( 'YITH_WOOCOMPARE_INIT' ) ) { |
| 84 | define( 'YITH_WOOCOMPARE_INIT', plugin_basename( __FILE__ ) ); |
| 85 | } |
| 86 | if ( ! defined( 'YITH_WOOCOMPARE' ) ) { |
| 87 | define( 'YITH_WOOCOMPARE', true ); |
| 88 | } |
| 89 | if ( ! defined( 'YITH_WOOCOMPARE_FILE' ) ) { |
| 90 | define( 'YITH_WOOCOMPARE_FILE', __FILE__ ); |
| 91 | } |
| 92 | if ( ! defined( 'YITH_WOOCOMPARE_URL' ) ) { |
| 93 | define( 'YITH_WOOCOMPARE_URL', plugin_dir_url( __FILE__ ) ); |
| 94 | } |
| 95 | if ( ! defined( 'YITH_WOOCOMPARE_DIR' ) ) { |
| 96 | define( 'YITH_WOOCOMPARE_DIR', plugin_dir_path( __FILE__ ) ); |
| 97 | } |
| 98 | if ( ! defined( 'YITH_WOOCOMPARE_TEMPLATE_PATH' ) ) { |
| 99 | define( 'YITH_WOOCOMPARE_TEMPLATE_PATH', YITH_WOOCOMPARE_DIR . 'templates' ); |
| 100 | } |
| 101 | if ( ! defined( 'YITH_WOOCOMPARE_ASSETS_URL' ) ) { |
| 102 | define( 'YITH_WOOCOMPARE_ASSETS_URL', YITH_WOOCOMPARE_URL . 'assets' ); |
| 103 | } |
| 104 | if ( ! defined( 'YITH_WOOCOMPARE_SLUG' ) ) { |
| 105 | define( 'YITH_WOOCOMPARE_SLUG', 'yith-woocommerce-compare' ); |
| 106 | } |
| 107 | /* Plugin Framework Version Check */ |
| 108 | if ( ! function_exists( 'yit_maybe_plugin_fw_loader' ) && file_exists( YITH_WOOCOMPARE_DIR . 'plugin-fw/init.php' ) ) { |
| 109 | require_once YITH_WOOCOMPARE_DIR . 'plugin-fw/init.php'; |
| 110 | } |
| 111 | yit_maybe_plugin_fw_loader( YITH_WOOCOMPARE_DIR ); |
| 112 | |
| 113 | /** |
| 114 | * Init plugin |
| 115 | * |
| 116 | * @since 1.0.0 |
| 117 | * @author Francesco Licandro |
| 118 | * @return void |
| 119 | */ |
| 120 | function yith_woocompare_constructor() { |
| 121 | |
| 122 | global $woocommerce; |
| 123 | |
| 124 | if ( ! isset( $woocommerce ) || ! function_exists( 'WC' ) ) { |
| 125 | add_action( 'admin_notices', 'yith_woocompare_install_woocommerce_admin_notice' ); |
| 126 | return; |
| 127 | } elseif ( defined( 'YITH_WOOCOMPARE_PREMIUM' ) ) { |
| 128 | add_action( 'admin_notices', 'yith_woocompare_install_free_admin_notice' ); |
| 129 | deactivate_plugins( plugin_basename( __FILE__ ) ); |
| 130 | return; |
| 131 | } |
| 132 | |
| 133 | load_plugin_textdomain( 'yith-woocommerce-compare', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' ); |
| 134 | |
| 135 | // Load required classes and functions. |
| 136 | require_once 'includes/class.yith-woocompare-helper.php'; |
| 137 | require_once 'widgets/class.yith-woocompare-widget.php'; |
| 138 | require_once 'includes/class.yith-woocompare.php'; |
| 139 | |
| 140 | // Let's start the game! |
| 141 | global $yith_woocompare; |
| 142 | $yith_woocompare = new YITH_Woocompare(); |
| 143 | } |
| 144 | add_action( 'plugins_loaded', 'yith_woocompare_constructor', 11 ); |
| 145 |