yith-woocommerce-compare
Last commit date
assets
1 year ago
includes
8 months ago
languages
8 months ago
plugin-fw
8 months ago
plugin-options
1 year ago
templates
1 year ago
init.php
8 months ago
license.txt
1 year ago
readme.txt
8 months ago
webpack.config.js
1 year ago
wpml-config.xml
11 years ago
init.php
133 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: 3.5.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: 10.1 |
| 12 | * WC tested up to: 10.3 |
| 13 | * Requires Plugins: woocommerce |
| 14 | * |
| 15 | * @author YITH <plugins@yithemes.com> |
| 16 | * @package YITH\Compare |
| 17 | * @version 3.5.0 |
| 18 | */ |
| 19 | |
| 20 | /* |
| 21 | Copyright 2013-2025 Your Inspiration Solutions (email : plugins@yithemes.com) |
| 22 | |
| 23 | This program is free software; you can redistribute it and/or modify |
| 24 | it under the terms of the GNU General Public License, version 2, as |
| 25 | published by the Free Software Foundation. |
| 26 | |
| 27 | This program is distributed in the hope that it will be useful, |
| 28 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 29 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 30 | GNU General Public License for more details. |
| 31 | |
| 32 | You should have received a copy of the GNU General Public License |
| 33 | along with this program; if not, write to the Free Software |
| 34 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 35 | */ |
| 36 | |
| 37 | defined( 'ABSPATH' ) || exit; // Exit if accessed directly. |
| 38 | |
| 39 | /** |
| 40 | * === Define constants. === |
| 41 | */ |
| 42 | |
| 43 | defined( 'YITH_WOOCOMPARE_VERSION' ) || define( 'YITH_WOOCOMPARE_VERSION', '3.5.0' ); |
| 44 | defined( 'YITH_WOOCOMPARE' ) || define( 'YITH_WOOCOMPARE', true ); |
| 45 | defined( 'YITH_WOOCOMPARE_FREE_INIT' ) || define( 'YITH_WOOCOMPARE_FREE_INIT', plugin_basename( __FILE__ ) ); |
| 46 | defined( 'YITH_WOOCOMPARE_SLUG' ) || define( 'YITH_WOOCOMPARE_SLUG', 'yith-woocommerce-compare' ); |
| 47 | defined( 'YITH_WOOCOMPARE_URL' ) || define( 'YITH_WOOCOMPARE_URL', plugin_dir_url( __FILE__ ) ); |
| 48 | defined( 'YITH_WOOCOMPARE_DIR' ) || define( 'YITH_WOOCOMPARE_DIR', plugin_dir_path( __FILE__ ) ); |
| 49 | defined( 'YITH_WOOCOMPARE_FILE' ) || define( 'YITH_WOOCOMPARE_FILE', __FILE__ ); |
| 50 | defined( 'YITH_WOOCOMPARE_ASSETS_URL' ) || define( 'YITH_WOOCOMPARE_ASSETS_URL', YITH_WOOCOMPARE_URL . 'assets/' ); |
| 51 | defined( 'YITH_WOOCOMPARE_ASSETS_PATH' ) || define( 'YITH_WOOCOMPARE_ASSETS_PATH', YITH_WOOCOMPARE_DIR . 'assets/' ); |
| 52 | defined( 'YITH_WOOCOMPARE_INCLUDE_PATH' ) || define( 'YITH_WOOCOMPARE_INCLUDE_PATH', YITH_WOOCOMPARE_DIR . 'includes/' ); |
| 53 | defined( 'YITH_WOOCOMPARE_TEMPLATE_PATH' ) || define( 'YITH_WOOCOMPARE_TEMPLATE_PATH', YITH_WOOCOMPARE_DIR . 'templates/' ); |
| 54 | |
| 55 | /** |
| 56 | * === Start the plugin up. === |
| 57 | */ |
| 58 | |
| 59 | if ( ! function_exists( 'is_plugin_active' ) ) { |
| 60 | require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
| 61 | } |
| 62 | |
| 63 | if ( ! function_exists( 'yith_plugin_registration_hook' ) ) { |
| 64 | require_once 'plugin-fw/yit-plugin-registration-hook.php'; |
| 65 | } |
| 66 | register_activation_hook( __FILE__, 'yith_plugin_registration_hook' ); |
| 67 | |
| 68 | // Plugin Framework Loader. |
| 69 | if ( file_exists( plugin_dir_path( __FILE__ ) . 'plugin-fw/init.php' ) ) { |
| 70 | require_once plugin_dir_path( __FILE__ ) . 'plugin-fw/init.php'; |
| 71 | } |
| 72 | |
| 73 | /** |
| 74 | * Prints error message if WooCommerce is not installed |
| 75 | * |
| 76 | * @since 1.0.0 |
| 77 | * @return void |
| 78 | */ |
| 79 | function yith_woocompare_install_woocommerce_admin_notice() { |
| 80 | ?> |
| 81 | <div class="error"> |
| 82 | <p><?php esc_html_e( 'YITH WooCommerce Compare is enabled but not effective. It requires WooCommerce in order to work.', 'yith-woocommerce-compare' ); ?></p> |
| 83 | </div> |
| 84 | <?php |
| 85 | } |
| 86 | |
| 87 | /** |
| 88 | * Error message if premium version is installed |
| 89 | * |
| 90 | * @since 1.0.0 |
| 91 | * @return void |
| 92 | */ |
| 93 | function yith_woocompare_install_free_admin_notice() { |
| 94 | ?> |
| 95 | <div class="error"> |
| 96 | <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> |
| 97 | </div> |
| 98 | <?php |
| 99 | } |
| 100 | |
| 101 | /** |
| 102 | * Init plugin |
| 103 | * |
| 104 | * @since 1.0.0 |
| 105 | * @return void |
| 106 | */ |
| 107 | function yith_woocompare_constructor() { |
| 108 | |
| 109 | global $woocommerce; |
| 110 | |
| 111 | if ( ! isset( $woocommerce ) || ! function_exists( 'WC' ) ) { |
| 112 | add_action( 'admin_notices', 'yith_woocompare_install_woocommerce_admin_notice' ); |
| 113 | return; |
| 114 | } elseif ( defined( 'YITH_WOOCOMPARE_PREMIUM' ) ) { |
| 115 | add_action( 'admin_notices', 'yith_woocompare_install_free_admin_notice' ); |
| 116 | deactivate_plugins( plugin_basename( __FILE__ ) ); |
| 117 | return; |
| 118 | } |
| 119 | |
| 120 | if ( function_exists( 'yith_plugin_fw_load_plugin_textdomain' ) ) { |
| 121 | yith_plugin_fw_load_plugin_textdomain( 'yith-woocommerce-compare', basename( __DIR__ ) . '/languages' ); |
| 122 | } |
| 123 | |
| 124 | // Load required classes and functions. |
| 125 | require_once 'includes/functions.yith-woocompare.php'; |
| 126 | require_once 'includes/class-yith-woocompare-autoloader.php'; |
| 127 | |
| 128 | // Let's start the game! |
| 129 | global $yith_woocompare; |
| 130 | $yith_woocompare = YITH_WooCompare::instance(); |
| 131 | } |
| 132 | add_action( 'plugins_loaded', 'yith_woocompare_constructor', 11 ); |
| 133 |