1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166
<?php
global $DepositsUpdateChecker;
$DepositsUpdateChecker = '1.2';
define( 'EDD_SL_STORE_URL_DEPOSITS', 'https://www.tychesoftwares.com/' );
define( 'EDD_SL_ITEM_NAME_DEPOSITS', 'Deposits For WooCommerce' );
if ( ! defined( 'ABSPATH' ) ) exit;
if( !class_exists( 'EDD_DEPOSITS_Plugin_Updater' ) ) {
include( dirname( __FILE__ ) . '/plugin-updates/EDD_DEPOSITS_Plugin_Updater.php' );
}
$license_key = trim( get_option( 'dfw_edd_license_key' ) );
$edd_updater = new EDD_DEPOSITS_Plugin_Updater( EDD_SL_STORE_URL_DEPOSITS, __FILE__, array(
'version' => '1.2',
'license' => $license_key,
'item_name' => EDD_SL_ITEM_NAME_DEPOSITS,
'author' => 'Ashok Rane'
)
);
function dfw_update_po_file(){
$domain = 'deposits-for-woocommerce';
$locale = apply_filters( 'plugin_locale', get_locale(), $domain );
if ( $loaded = load_textdomain( $domain, trailingslashit( WP_LANG_DIR ) . $domain . '-' . $locale . '.mo' ) ) {
return $loaded;
} else {
load_plugin_textdomain( $domain, FALSE, basename( dirname( __FILE__ ) ) . '/languages/' );
}
}
if( !class_exists( 'DFW_Deposits' ) ){
class DFW_Deposits {
public function __construct(){
global $wpdb;
define( 'DFW_PLUGIN_URL', plugin_dir_url(__FILE__) );
register_activation_hook( __FILE__, array( $this, 'dfw_create_database_tables' ) );
$this->dfw_load_files();
add_action( 'wp_enqueue_scripts' , array( &$this, 'dfw_enqueue_scripts' ) );
add_action( 'admin_init' , array( 'DFW_License', 'dfw_edd_sample_deactivate_license' ) );
add_action( 'admin_init' , array( 'DFW_License', 'dfw_edd_sample_activate_license' ) );
add_action( 'admin_init' , array( 'DFW_Update_DB', 'dfw_update_plans_db' ) );
add_action( 'init' , 'dfw_update_po_file' );
add_action( 'init' , array( 'DFW_Deposits_For_Bookings', 'dfw_add_ajax_for_bookings' ) );
add_action( 'wp_ajax_nopriv_dfw_get_start_date' , array( 'DFW_Deposits_For_Bookings','dfw_get_start_date' ) );
add_action( 'wp_ajax_dfw_get_start_date' , array( 'DFW_Deposits_For_Bookings','dfw_get_start_date' ) );
}
public function dfw_localize_script() {
$js_vars = array();
$schema = is_ssl() ? 'https':'http';
$js_vars['ajaxurl'] = admin_url( 'admin-ajax.php', $schema );
wp_localize_script( 'wc-deposits-script', 'dfw', $js_vars );
}
public function dfw_load_files(){
if( is_admin() ){
include_once( 'includes/class-dfw-deposits-settings.php' );
include_once( 'includes/class-dfw-product-admin-settings.php' );
}
include_once( 'includes/class-dfw-manage-products.php' );
include_once( 'includes/class-dfw-manage-cart.php' );
include_once( 'includes/class-dfw-plans-admin-settings.php' );
include_once( 'includes/class-dfw-manage-plans.php' );
include_once( 'includes/class-dfw-deposits-plan.php' );
include_once( 'includes/class-dfw-manage-orders.php' );
include_once( 'includes/class-dfw-manage-order-items.php');
include_once( 'includes/class-dfw-scheduled-plan-orders.php');
include_once( 'includes/class-dfw-deposits-for-bookings.php');
include_once( 'includes/class-dfw-update-db.php' );
include_once( 'license.php' );
}
public function dfw_enqueue_scripts() {
wp_enqueue_style ( 'wc-deposits-styles' , plugin_dir_url(__FILE__) . '/assets/css/deposit-form.min.css', '', '' );
wp_enqueue_style ( 'wc-deposits-payment-styles' , plugin_dir_url(__FILE__) . '/assets/css/payment-plans.min.css', '', '' );
wp_enqueue_script( 'wc-deposits-styles' );
wp_enqueue_script( 'wc-deposits-script' , plugin_dir_url(__FILE__) . '/assets/js/deposit-form.js', array( 'jquery' ), 1.7 );
$this->dfw_localize_script();
}
public function dfw_create_database_tables() {
global $wpdb, $wp_roles;
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
dbDelta( "
CREATE TABLE {$wpdb->prefix}dfw_deposits_payment_plans (
ID bigint(20) unsigned NOT NULL auto_increment,
name varchar(255) NOT NULL,
description longtext NOT NULL,
PRIMARY KEY (ID)
);
CREATE TABLE {$wpdb->prefix}dfw_deposits_payment_plans_schedule (
schedule_id bigint(20) unsigned NOT NULL auto_increment,
schedule_index bigint(20) unsigned NOT NULL default 0,
plan_id bigint(20) unsigned NOT NULL,
plan_amount varchar(255) NOT NULL,
plan_interval_amount varchar(255) NOT NULL,
plan_interval_time varchar(255) NOT NULL,
PRIMARY KEY (schedule_id),
KEY plan_id (plan_id)
);
" );
}
}
}
$dfw_deposits = new DFW_Deposits();