Since 2.0, you need BOTH Core and Pro (2.0) packages installed and activated.

', 'woo-discount-rules'); $message .= __('

Why we made this change?

', 'woo-discount-rules'); $message .= __('

This arrangement is to avoid the confusion in the installation and upgrade process. Many users first install the core free version. Then purchase the PRO version and try to install it over the free version. Since both free and pro packages have same names, wordpress asks them to uninstall free and then install pro. As you can see, this is quite confusing for the end users.

', 'woo-discount-rules'); $message .= __('

As a result, starting from 2.0, we now have two packs: 1. Core 2. PRO.

', 'woo-discount-rules'); $message .= '

'; $return['message'] = $message; } else { $return['message'] = __('Since 2.0, you need BOTH Core and Pro (2.0) packages installed and activated. Please download the Pro 2.0 pack from My Downloads page in our site, install and activate it. Here is a guide and video tutorial', 'woo-discount-rules'); $return['type'] = 'manual_install'; } } } } wp_send_json_success($return); }); /** * Action sto show the toggle button */ add_action('advanced_woo_discount_rules_on_settings_head', function () { $has_switch = true; $page = NULL; if (isset($_GET['page'])) { $page = sanitize_text_field($_GET['page']); } global $awdr_load_version; $version = ($awdr_load_version == "v1") ? "v2" : "v1"; $url = admin_url('admin.php?page=' . $page . '&awdr_switch_plugin_to=' . $version); $message = __('Switch to Discount Rules V2 which comes with a better UI and advanced rules. (You can switch back any time. Your settings and rules in V1 are kept as is)', 'woo-discount-rules'); $button_text = __("Switch to v2", 'woo-discount-rules'); if($version == "v1"){ $has_switch = \Wdr\App\Helpers\Migration::hasSwitchBackOption(); $message = __('Would you like to switch to older Woo Discount Rules?', 'woo-discount-rules'); $button_text = __("Click here to Switch back", 'woo-discount-rules'); } if($has_switch){ if($version == "v1"){ $nounce = \Wdr\App\Helpers\Helper::create_nonce('wdr_ajax_switch_version'); } else { $nounce = FlycartWooDiscountRulesGeneralHelper::createNonce('wdr_ajax_switch_version'); } echo '
' . $message . '
'; echo "
"; echo ''; } }); add_action('advanced_woo_discount_rules_content_next_to_tabs', function () { $has_switch = true; $page = NULL; if (isset($_GET['page'])) { $page = sanitize_text_field($_GET['page']); } global $awdr_load_version; $version = ($awdr_load_version == "v1") ? "v2" : "v1"; if($version == "v1"){ $has_switch = \Wdr\App\Helpers\Migration::hasSwitchBackOption(); } if($version == "v1"){ $nounce = \Wdr\App\Helpers\Helper::create_nonce('wdr_ajax_switch_version'); } else { $nounce = FlycartWooDiscountRulesGeneralHelper::createNonce('wdr_ajax_switch_version'); } if($has_switch){ $button_text = __("Switch back to Discount Rules 1.x", 'woo-discount-rules'); echo ''; } }); /** * Determines if the server environment is compatible with this plugin. * * @return bool * @since 1.0.0 * */ if(!function_exists('isAWDREnvironmentCompatible')){ function isAWDREnvironmentCompatible() { return version_compare(PHP_VERSION, WDR_REQUIRED_PHP_VERSION, '>='); } } /** * Check the woocommerce is active or not * @return bool */ if(!function_exists('isAWDRWooActive')){ function isAWDRWooActive() { $active_plugins = apply_filters('active_plugins', get_option('active_plugins', array())); if (is_multisite()) { $active_plugins = array_merge($active_plugins, get_site_option('active_sitewide_plugins', array())); } return in_array('woocommerce/woocommerce.php', $active_plugins, false) || array_key_exists('woocommerce/woocommerce.php', $active_plugins); } } /** * Check woocommerce version is compatibility * @return bool */ if(!function_exists('isAWDRWooCompatible')){ function isAWDRWooCompatible() { $current_wc_version = getAWDRWooVersion(); return version_compare($current_wc_version, WDR_WC_REQUIRED_VERSION, '>='); } } /** * get the version of woocommerce * @return mixed|null */ if(!function_exists('getAWDRWooVersion')){ function getAWDRWooVersion() { if (defined('WC_VERSION')) { return WC_VERSION; } if (!function_exists('get_plugins')) { require_once(ABSPATH . 'wp-admin/includes/plugin.php'); } $plugin_folder = get_plugins('/woocommerce'); $plugin_file = 'woocommerce.php'; $wc_installed_version = NULL; if (isset($plugin_folder[$plugin_file]['Version'])) { $wc_installed_version = $plugin_folder[$plugin_file]['Version']; } return $wc_installed_version; } } /** * Determines if the WordPress compatible. * * @return bool * @since 1.0.0 * */ if(!function_exists('isAWDRWpCompatible')){ function isAWDRWpCompatible() { $required_wp_version = 4.9; return version_compare(get_bloginfo('version'), $required_wp_version, '>='); } } if(!function_exists('awdr_check_compatible')){ function awdr_check_compatible(){ if (!isAWDREnvironmentCompatible()) { exit(__('This plugin can not be activated because it requires minimum PHP version of ', 'woo-discount-rules') . ' ' . WDR_REQUIRED_PHP_VERSION); } if (!isAWDRWooActive()) { exit(__('Woocommerce must installed and activated in-order to use Advanced woo discount rules!', 'woo-discount-rules')); } if (!isAWDRWooCompatible()) { exit(__(' Advanced woo discount rules requires at least Woocommerce', 'woo-discount-rules') . ' ' . WDR_WC_REQUIRED_VERSION); } } } /** * For plugin translation * */ add_action( 'plugins_loaded', function (){ if(function_exists('load_plugin_textdomain')){ load_plugin_textdomain( 'woo-discount-rules', FALSE, basename( dirname( __FILE__ ) ) . '/i18n/languages/' ); } });