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