Overview
  • Package
  • Class
  • Tree
  • Deprecated
  • Todo
  • Hook Reference
  • Docs Home

Packages

  • Deposits-for-WooCommerce
    • Bookings
    • Cart
    • Order
    • Other
    • Payment-Plans
      • Views
    • Products
    • Settings

Classes

  • DFW_Deposits
  • DFW_Deposits_For_Bookings
  • DFW_Deposits_Plan
  • DFW_Deposits_Settings
  • DFW_License
  • DFW_Manage_Cart
  • DFW_Manage_Order_Items
  • DFW_Manage_Orders
  • DFW_Manage_Plans
  • DFW_Manage_Products
  • DFW_Payment_Plans_List
  • DFW_Plans_Admin_Settings
  • DFW_Product_Admin_Settings
  • DFW_Scheduled_Plan_Orders
  • DFW_Update_DB
  • EDD_DEPOSITS_Plugin_Updater

Functions

  • dfw_update_po_file
  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
/**
 * Plugin Name: Deposits For WooCommerce
 * Plugin URI: https://www.tychesoftwares.com/store/premium-plugins/deposits-for-woocommerce/
 * Description: Accept deposit payments or full payments from customers for your store items.
 * Version: 1.3
 * Author: Tyche Softwares
 * Author URI: https://tychesoftwares.com
 * Text Domain: deposits-for-woocommerce
 * Requires PHP: 5.6
 * WC requires at least: 3.0.0
 * WC tested up to: 3.2.0
 * 
 * Accept deposits or full amount on products 
 * 
 * @package Deposits-for-WooCommerce
 */

 global $DepositsUpdateChecker;
 $DepositsUpdateChecker = '1.2';
 // this is the URL our updater / license checker pings. This should be the URL of the site with EDD installed
define( 'EDD_SL_STORE_URL_DEPOSITS', 'https://www.tychesoftwares.com/' ); // IMPORTANT: change the name of this constant to something unique to prevent conflicts with other plugins using this system

// the name of your product. This is the title of your product in EDD and should match the download title in EDD exactly
define( 'EDD_SL_ITEM_NAME_DEPOSITS', 'Deposits For WooCommerce' ); // IMPORTANT: change the name of this constant to something unique to prevent conflicts with other plugins using this system

if ( ! defined( 'ABSPATH' ) ) exit;

if( !class_exists( 'EDD_DEPOSITS_Plugin_Updater' ) ) {
    // load our custom updater if it doesn't already exist
    include( dirname( __FILE__ ) . '/plugin-updates/EDD_DEPOSITS_Plugin_Updater.php' );
}

$license_key = trim( get_option( 'dfw_edd_license_key' ) ); 

// setup the updater
$edd_updater = new EDD_DEPOSITS_Plugin_Updater( EDD_SL_STORE_URL_DEPOSITS, __FILE__, array(
        'version'   => '1.2',       // current version number
        'license'   => $license_key,    // license key (used get_option above to retrieve from DB)
        'item_name' => EDD_SL_ITEM_NAME_DEPOSITS,   // name of this plugin
        'author'    => 'Ashok Rane'  // author of this plugin
    )
);

/**
 * Update the translation Files
 */
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' ) ){
    /**
     * Accept deposits or full amount on products 
     */
    class DFW_Deposits {

        /**
         * Constructor function
         */
        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' ) );
        }

        /**
         * Localize the script to use the data in the javascript
         * 
         * @since 1.0
         */
        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 );
        }

        /**
         * Load all the files from the plugin
         * 
         * @since 1.0
         */
        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' );
        }

        /**
         * Load all the css & js files 
         * 
         * @hook wp_enqueue_scripts
         * @since 1.0
         */
        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();
            
        }

        /**
         * Create the database table on plugin activation
         * 
         * @since 1.0
         */
        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();
API documentation generated by ApiGen