| 1 |
<?php |
| 2 |
/** |
| 3 |
* Plugin Name: YayPricing - WooCommerce Dynamic Pricing And Discounts |
| 4 |
* Plugin URI: https://woocommerce.com/products/dynamic-pricing-discounts/ |
| 5 |
* Description: Create automatic product pricing rules and cart discounts to design a powerful marketing strategy for your WooCommerce store. |
| 6 |
* Version: 1.9 |
| 7 |
* Author: YayCommerce |
| 8 |
* Author URI: https://yaycommerce.com/ |
| 9 |
* Text Domain: yaydp |
| 10 |
* WC requires at least: 3.0.0 |
| 11 |
* WC tested up to: 7.5.1 |
| 12 |
* Requires PHP: 5.7 |
| 13 |
* Domain Path: /languages |
| 14 |
* |
| 15 |
* @package YayPricing |
| 16 |
*/ |
| 17 |
|
| 18 |
namespace YAYDP; |
| 19 |
|
| 20 |
defined( 'ABSPATH' ) || exit; |
| 21 |
|
| 22 |
if ( function_exists( 'YAYDP\\YAYDP' ) ) { |
| 23 |
require_once plugin_dir_path( __FILE__ ) . 'includes/yaydp-duplicate-fallback.php'; |
| 24 |
add_action( |
| 25 |
'admin_init', |
| 26 |
function() { |
| 27 |
deactivate_plugins( plugin_basename( __FILE__ ) ); |
| 28 |
} |
| 29 |
); |
| 30 |
return; |
| 31 |
} |
| 32 |
|
| 33 |
|
| 34 |
if ( ! defined( 'YAYDP_PLUGIN_FILE' ) ) { |
| 35 |
define( 'YAYDP_PLUGIN_FILE', __FILE__ ); |
| 36 |
} |
| 37 |
|
| 38 |
if ( ! defined( 'YAYDP_ABSPATH' ) ) { |
| 39 |
define( 'YAYDP_ABSPATH', dirname( __FILE__ ) . '/' ); |
| 40 |
} |
| 41 |
if ( ! defined( 'YAYDP_PLUGIN_PATH' ) ) { |
| 42 |
define( 'YAYDP_PLUGIN_PATH', plugin_dir_path( __FILE__ ) ); |
| 43 |
} |
| 44 |
if ( ! defined( 'YAYDP_PLUGIN_URL' ) ) { |
| 45 |
define( 'YAYDP_PLUGIN_URL', plugin_dir_url( __FILE__ ) ); |
| 46 |
} |
| 47 |
if ( ! defined( 'YAYDP_PLUGIN_BASENAME' ) ) { |
| 48 |
define( 'YAYDP_PLUGIN_BASENAME', plugin_basename( __FILE__ ) ); |
| 49 |
} |
| 50 |
if ( ! defined( 'YAYDP_MINIMUM_PHP_VERSION' ) ) { |
| 51 |
define( 'YAYDP_MINIMUM_PHP_VERSION', 5.7 ); |
| 52 |
} |
| 53 |
|
| 54 |
spl_autoload_register( |
| 55 |
function ( $class_name ) { |
| 56 |
|
| 57 |
if ( strncmp( __NAMESPACE__, $class_name, strlen( __NAMESPACE__ ) ) !== 0 ) { |
| 58 |
return; |
| 59 |
} |
| 60 |
|
| 61 |
$class_name = strtolower( str_replace( '_', '-', $class_name ) ); |
| 62 |
|
| 63 |
$namespace_arr = \explode( '\\', $class_name ); |
| 64 |
|
| 65 |
$class_name_without_namespace = $namespace_arr[ count( $namespace_arr ) - 1 ]; |
| 66 |
$class_name_without_namespace = str_replace( '\\', '-', $class_name_without_namespace ); |
| 67 |
|
| 68 |
$file_name_prefix = 'class'; |
| 69 |
if ( false !== strpos( $class_name, 'traits' ) ) { |
| 70 |
$file_name_prefix = 'trait'; |
| 71 |
} |
| 72 |
if ( false !== strpos( $class_name, 'abstracts' ) ) { |
| 73 |
$file_name_prefix = 'abstract'; |
| 74 |
} |
| 75 |
$file_name = $file_name_prefix . '-' . $class_name_without_namespace . '.php'; |
| 76 |
|
| 77 |
$namespace_arr[ count( $namespace_arr ) - 1 ] = $file_name; |
| 78 |
$namespace_arr[0] = 'includes'; |
| 79 |
|
| 80 |
$file = __DIR__ . '/' . \implode( '/', $namespace_arr ); |
| 81 |
|
| 82 |
if ( file_exists( $file ) ) { |
| 83 |
require $file; |
| 84 |
} |
| 85 |
} |
| 86 |
); |
| 87 |
|
| 88 |
add_action( 'plugins_loaded', '\\YAYDP\\load_plugin' ); |
| 89 |
|
| 90 |
if ( ! function_exists( 'YAYDP\\load_plugin' ) ) { |
| 91 |
/** |
| 92 |
* Initialize plugin instance |
| 93 |
*/ |
| 94 |
function load_plugin() { //phpcs:ignore |
| 95 |
if ( function_exists( 'WC' ) && \version_compare( phpversion(), YAYDP_MINIMUM_PHP_VERSION, '>=' ) ) { |
| 96 |
\YAYDP\YayPricing::get_instance(); |
| 97 |
} else { |
| 98 |
\YAYDP\YAYDP_Fallback::get_instance(); |
| 99 |
} |
| 100 |
} |
| 101 |
} |
| 102 |
|
| 103 |
register_activation_hook( __FILE__, array( 'YAYDP\\YAYDP_Activation', 'initialize' ) ); |
| 104 |
register_deactivation_hook( __FILE__, array( 'YAYDP\\YAYDP_Deactivation', 'initialize' ) ); |
| 105 |
|
| 106 |
|
| 107 |
|