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 = esc_url(admin_url('admin.php?page=' . $page . '&awdr_switch_plugin_to=' . $version)); $message = __('Discount Rules V2 comes with a better UI and advanced options.', 'woo-discount-rules'); $button_text = __("Switch to New User Interface", '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 = WDRV1Deprecated::createNonce('wdr_ajax_switch_version'); } echo '

Important: It seems you are using the V1 User Interface. This UI was deprecated since March 2020. We have now removed it as it is no longer supported. Please switch to the new User Interface to create and manage your discount rules. Click the "Switch" button to start using the new interface.

'; echo '
' . $message . '
'; 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 = WDRV1Deprecated::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/' ); } });