Commit 66e602ec authored by Varun Sridharan's avatar Varun Sridharan

changes by varun

* Added Plugin Template versioning #26
* Fixed Template Load Issue
* Renamed WC_TEMPLATE To WC_CORE_TEMPLATE
* Added New WC_QD_THEME_TEMPLATE
parent 4355de06
......@@ -18,11 +18,53 @@ if ( ! defined( 'WPINC' ) ) { die; }
class WooCommerce_Quick_Donation_Admin_Function {
public function __construct(){
$this->check_template_files();
add_action( 'post_row_actions', array($this,'protect_donation_product'),99,2);
add_action( 'parse_query', array( $this, 'hide_donation_order_woocommerce_order' ) );
add_filter( 'wc_order_types',array($this,'add_wc_order_types'),99,2);
}
public function check_template_files(){
$template_files = WC_Admin_Status::scan_template_files( WC_QD_TEMPLATE );
$outdated = false;
if(is_array($template_files)){
foreach($template_files as $file){
$theme_file = false;
if ( file_exists( get_stylesheet_directory() . '/' . $file ) ) {
$theme_file = get_stylesheet_directory() . '/' . $file;
} elseif ( file_exists( get_stylesheet_directory() . WC_QD_THEME_TEMPLATE . $file ) ) {
$theme_file = get_stylesheet_directory() . WC_QD_THEME_TEMPLATE . $file;
} elseif ( file_exists( get_template_directory() . '/' . $file ) ) {
$theme_file = get_template_directory() . '/' . $file;
} elseif( file_exists( get_template_directory() . WC_QD_THEME_TEMPLATE . $file ) ) {
$theme_file = get_template_directory() . WC_QD_THEME_TEMPLATE . $file;
}
if ( $theme_file !== false ) {
$core_version = WC_Admin_Status::get_file_version(WC_QD_TEMPLATE.$file);
$theme_version = WC_Admin_Status::get_file_version( $theme_file );
if ( $core_version && $theme_version && version_compare( $theme_version, $core_version, '<' ) ) {
$outdated = true;
break;
}
}
}
if ( $outdated ) {
$theme = wp_get_theme();
$message = sprintf( __( '<strong>Your theme (%s) contains outdated copies of some WooCommerce Quick Donation template files.</strong> These files may need updating to ensure they are compatible with the current version of WooCommerce Quick Donation. You can see which files are affected from the %ssystem status page%s. If in doubt, check with the author of the theme.', 'woocommerce' ), esc_html( $theme['Name'] ), '<a href="' . esc_url( admin_url( 'admin.php?page=wc-status' ) ) . '">', '</a>' );
wc_qd_notice($message,'error');
}
}
}
public function hide_donation_order_woocommerce_order($query) {
global $pagenow,$post_type;
$query = $query;
......
......@@ -4,4 +4,3 @@ if (empty($send_fields[WC_QD_DB.'payment_gateway'])) {
add_settings_error(WC_QD_DB.'payment_gateway','', __( 'Error: Please Select Atlest 1 Payment Gateway.', WC_QD_TXT ),'error');
}
?>
\ No newline at end of file
\ No newline at end of file
......@@ -151,8 +151,13 @@ class WooCommerce_Quick_Donation_Functions {
$attributes .= $attr_key.'="'.$attr_val.'" ';
}
$this->load_template('field-'.$type.'.php', WC_QD_TEMPLATE.'fields/' );
$field_output = $this->load_template('field-'.$type.'.php', WC_QD_TEMPLATE.'fields/' , array('id' => $id,
'name' => $name,
'class' => $class,
'field_output' => $field_output,
'is_grouped' => $is_grouped,
'project_list' => $project_list,
'attributes' => $attributes));
return $field_output;
}
......@@ -165,27 +170,37 @@ class WooCommerce_Quick_Donation_Functions {
$class = apply_filters('wcqd_project_price_text_class',array(),'text');
$custom_attributes = apply_filters('wcqd_project_price_text_attribute',array(),'text');
$value = '';
$class = implode(' ',$class);
$attributes = '';
foreach($custom_attributes as $attr_key => $attr_val) {
$attributes .= $attr_key.'="'.$attr_val.'" ';
}
$this->load_template('field-text.php',WC_QD_TEMPLATE . 'fields/' );
$field_output = $this->load_template('field-text.php',WC_QD_TEMPLATE . 'fields/' ,array('id' => $id,
'name' => $name,
'class' => $class,
'field_output' => $field_output,
'attributes' => $attributes,
'value' => $value));
return $field_output;
}
public function load_template($file,$path){
public function load_template($file,$path,$args = array()){
$field_output = '';
$wc_get_template = function_exists('wc_get_template') ? 'wc_get_template' : 'woocommerce_get_template';
$wc_get_template( $file,array(), '', $path);
ob_start();
$wc_get_template( $file,$args, '', $path);
$field_output = ob_get_clean();
ob_flush();
return $field_output;
}
public function locate_template($template){
$default_path = WC_QD_TEMPLATE;
$template_path = WC_TEMPLATE.'donation/';
$template_path = WC_CORE_TEMPLATE.'donation/';
$template = $template;
$locate = wc_locate_template($template,$template_path, $default_path);
return $locate;
......
......@@ -42,11 +42,13 @@ class WooCommerce_Quick_Donation_Shortcode {
ob_flush();
}
ob_start();
// ob_start();
do_action('wc_quick_donation_before_doantion_form',$return_value , $settings['type'],$settings['grouped']);
WC_QD()->f()->load_template('donation-form.php',WC_QD_TEMPLATE);
$messages .= WC_QD()->f()->load_template('donation-form.php',WC_QD_TEMPLATE,array('donation_box' => $donation_box,
'donation_price' => $donation_price,
'currency' => $currency));
do_action('wc_quick_donation_after_doantion_form',$return_value , $settings['type'],$settings['grouped']);
$messages .= ob_get_clean();
//$messages .= ob_get_clean();
return $messages;
}
......
......@@ -2,9 +2,9 @@
/**
* Cart item data (when outputting non-flat)
*
* @author WooThemes
* @package WooCommerce/Templates
* @version 2.4.0
* @author Varun Sridharan
* @package WooCommerce Quick Donation/Templates/cart
* @version 0.1
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
......
......@@ -2,11 +2,9 @@
/**
* Shipping Methods Display
*
* In 2.1 we show methods per package. This allows for multiple methods per order if so desired.
*
* @author WooThemes
* @package WooCommerce/Templates
* @version 2.3.0
* @author Varun Sridharan
* @package WooCommerce Quick Donation/Templates/cart
* @version 0.1
*/
if ( ! defined( 'ABSPATH' ) ) {
......
......@@ -2,9 +2,9 @@
/**
* Cart totals
*
* @author WooThemes
* @package WooCommerce/Templates
* @version 2.3.6
* @author Varun Sridharan
* @package WooCommerce Quick Donation/Templates/cart
* @version 0.1
*/
if ( ! defined( 'ABSPATH' ) ) {
......
<?php
/**
* Cart Page
* Donation Cart Template
*
* @author WooThemes
* @package WooCommerce/Templates
* @version 2.3.8
* @author Varun Sridharan
* @package WooCommerce Quick Donation/Templates/cart
* @version 0.1
*/
if ( ! defined( 'ABSPATH' ) ) {
......
......@@ -4,9 +4,9 @@
*
* Contains the markup for the proceed to checkout button on the cart
*
* @author WooThemes
* @package WooCommerce/Templates
* @version 2.4.0
* @author Varun Sridharan
* @package WooCommerce Quick Donation/Templates/cart
* @version 0.1
*/
if ( ! defined( 'ABSPATH' ) ) {
......
......@@ -2,9 +2,9 @@
/**
* Cart errors page
*
* @author WooThemes
* @package WooCommerce/Templates
* @version 2.4.0
* @author Varun Sridharan
* @package WooCommerce Quick Donation/Templates/checkout
* @version 0.1
*/
if ( ! defined( 'ABSPATH' ) ) {
......
......@@ -2,9 +2,9 @@
/**
* Checkout billing information form
*
* @author WooThemes
* @package WooCommerce/Templates
* @version 2.1.2
* @author Varun Sridharan
* @package WooCommerce Quick Donation/Templates/checkout
* @version 0.1
*/
if ( ! defined( 'ABSPATH' ) ) {
......
......@@ -2,9 +2,9 @@
/**
* Checkout Form
*
* @author WooThemes
* @package WooCommerce/Templates
* @version 2.3.0
* @author Varun Sridharan
* @package WooCommerce Quick Donation/Templates/checkout
* @version 0.1
*/
if ( ! defined( 'ABSPATH' ) ) {
......
......@@ -2,9 +2,9 @@
/**
* Checkout coupon form
*
* @author WooThemes
* @package WooCommerce/Templates
* @version 2.2
* @author Varun Sridharan
* @package WooCommerce Quick Donation/Templates/checkout
* @version 0.1
*/
if ( ! defined( 'ABSPATH' ) ) {
......
......@@ -2,9 +2,9 @@
/**
* Checkout login form
*
* @author WooThemes
* @package WooCommerce/Templates
* @version 2.0.0
* @author Varun Sridharan
* @package WooCommerce Quick Donation/Templates/checkout
* @version 0.1
*/
if ( ! defined( 'ABSPATH' ) ) {
......
......@@ -2,9 +2,9 @@
/**
* Pay for order form
*
* @author WooThemes
* @package WooCommerce/Templates
* @version 1.6.4
* @author Varun Sridharan
* @package WooCommerce Quick Donation/Templates/checkout
* @version 0.1
*/
if ( ! defined( 'ABSPATH' ) ) {
......
......@@ -2,9 +2,9 @@
/**
* Checkout shipping information form
*
* @author WooThemes
* @package WooCommerce/Templates
* @version 2.2.0
* @author Varun Sridharan
* @package WooCommerce Quick Donation/Templates/checkout
* @version 0.1
*/
if ( ! defined( 'ABSPATH' ) ) {
......
......@@ -2,9 +2,9 @@
/**
* Output a single payment method
*
* @author WooThemes
* @package WooCommerce/Templates
* @version 2.3.0
* @author Varun Sridharan
* @package WooCommerce Quick Donation/Templates/checkout
* @version 0.1
*/
if ( ! defined( 'ABSPATH' ) ) {
......
......@@ -2,9 +2,9 @@
/**
* Checkout Payment Section
*
* @author WooThemes
* @package WooCommerce/Templates
* @version 2.3.0
* @author Varun Sridharan
* @package WooCommerce Quick Donation/Templates/checkout
* @version 0.1
*/
if ( ! defined( 'ABSPATH' ) ) {
......
......@@ -2,9 +2,9 @@
/**
* Review order table
*
* @author WooThemes
* @package WooCommerce/Templates
* @version 2.3.0
* @author Varun Sridharan
* @package WooCommerce Quick Donation/Templates/checkout
* @version 0.1
*/
if ( ! defined( 'ABSPATH' ) ) {
......
......@@ -2,11 +2,10 @@
/**
* Thankyou page
*
* @author WooThemes
* @package WooCommerce/Templates
* @version 2.2.0
* @author Varun Sridharan
* @package WooCommerce Quick Donation/Templates/checkout
* @version 0.1
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
......
......@@ -2,9 +2,9 @@
/**
* Customer invoice email
*
* @author WooThemes
* @package WooCommerce/Templates/Emails
* @version 2.4.0
* @author Varun Sridharan
* @package WooCommerce Quick Donation/Templates/emails
* @version 0.1
*/
if ( ! defined( 'ABSPATH' ) ) {
......
......@@ -2,9 +2,9 @@
/**
* Customer invoice email (plain text)
*
* @author WooThemes
* @package WooCommerce/Templates/Emails/Plain
* @version 2.2.0
* @author Varun Sridharan
* @package WooCommerce Quick Donation/Templates/emails/plain
* @version 0.1
*/
if ( ! defined( 'ABSPATH' ) ) {
......
<?php
global $id, $name, $class, $field_output, $is_grouped, $project_list,$attributes;
/**
* HTML Radio Field Template
*
* @author Varun Sridharan
* @package WooCommerce Quick Donation/Templates/fields
* @version 0.1
*/
foreach($project_list as $id => $val){
......@@ -14,3 +20,5 @@ foreach($project_list as $id => $val){
}
}
echo $field_output;
?>
\ No newline at end of file
<?php
global $id, $name, $class, $field_output, $is_grouped, $project_list,$attributes;
$field_output = '<select id="'.$id.'" name="'.$name.'" class="'.$class.'" '.$attributes.'>';
/**
* HTML Select Field Template
*
* @author Varun Sridharan
* @package WooCommerce Quick Donation/Templates/fields
* @version 0.1
*/
?>
<select id="<?php echo $id; ?>" name="<?php echo $name; ?>" class="<?php echo $class.' '.$attributes;?>">
<?php
foreach($project_list as $id => $val){
if(is_array($val)){
......@@ -16,4 +23,6 @@ foreach($project_list as $id => $val){
}
}
$field_output .= '</select>';
\ No newline at end of file
echo $field_output;
?>
</select>
\ No newline at end of file
<?php
global $id, $name, $class, $field_output,$attributes,$value;
$field_output = '<input type="text" id="'.$id.'" name="'.$name.'" class="'.$class.'" '.$attributes.' value="'.$value.'" />';
/**
* HTML Text Field Template
*
* @author Varun Sridharan
* @package WooCommerce Quick Donation/Templates/fields
* @version 0.1
*/
?>
<input
type="text"
id="<?php echo $id; ?>"
name="<?php echo $name; ?>"
class="<?php echo $class.' '.$attributes; ?>"
value="<?php echo $value; ?>" />
\ No newline at end of file
<?php
/**
* My Orders
* My Donaions
*
* Shows recent orders on the account page
* Shows recent donaions on the account page
*
* @author WooThemes
* @package WooCommerce/Templates
* @version 2.3.10
* @author Varun Sridharan
* @package WooCommerce Quick Donation/Templates/myaccount
* @version 0.1
*/
if ( ! defined( 'ABSPATH' ) ) {
......
<?php
/**
* View Order
* View Donation
*
* Shows the details of a particular order on the account page
*
* @author WooThemes
* @package WooCommerce/Templates
* @version 2.2.0
* @author Varun Sridharan
* @package WooCommerce Quick Donation/Templates/myaccount
* @version 0.1
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
......
<?php
/**
* Order details
* Donation Details
*
* @author WooThemes
* @package WooCommerce/Templates
* @version 2.4.0
* @author Varun Sridharan
* @package WooCommerce Quick Donation/Templates/order
* @version 0.1
*/
if ( ! defined( 'ABSPATH' ) ) {
......
<?php
/**
* Order tracking form
* Donation Tracking
*
* @author WooThemes
* @package WooCommerce/Templates
* @version 1.6.4
* @author Varun Sridharan
* @package WooCommerce Quick Donation/Templates/order
* @version 0.1
*/
if ( ! defined( 'ABSPATH' ) ) {
......
<?php
/**
* Order again button
* Donate Again
*
* @author WooThemes
* @package WooCommerce/Templates
* @version 2.3.0
* @author Varun Sridharan
* @package WooCommerce Quick Donation/Templates/order
* @version 0.1
*/
if ( ! defined( 'ABSPATH' ) ) {
......
<?php
/**
* Order Customer Details
* Donor Details
*
* @author WooThemes
* @package WooCommerce/Templates
* @version 2.4.0
* @author Varun Sridharan
* @package WooCommerce Quick Donation/Templates/order
* @version 0.1
*/
if ( ! defined( 'ABSPATH' ) ) {
......
<?php
/**
* Order Item Details
* Donation Item Details
*
* @author WooThemes
* @package WooCommerce/Templates
* @version 2.4.0
* @author Varun Sridharan
* @package WooCommerce Quick Donation/Templates/order
* @version 0.1
*/
if ( ! defined( 'ABSPATH' ) ) {
......@@ -18,8 +18,6 @@ if ( ! defined( 'ABSPATH' ) ) {
$is_visible = $product && $product->is_visible();
$project_id = WC_QD()->db()->get_project_id($order->id);
echo sprintf( '<a href="%s">%s</a>', get_permalink( $project_id ), get_the_title($project_id ));
?>
</td>
<td class="product-total">
......
<?php
/**
* Order tracking
* Donation tracking
*
* @author WooThemes
* @package WooCommerce/Templates
* @version 2.2.0
* @author Varun Sridharan
* @package WooCommerce Quick Donation/Templates/order
* @version 0.1
*/
if ( ! defined( 'ABSPATH' ) ) {
......
......@@ -226,7 +226,8 @@ class WooCommerce_Quick_Donation {
$this->define('WC_QD_CSS',WC_QD_URL.'/includes/css/');
$this->define('WC_QD_TEMPLATE',WC_QD_PATH.'template/'); # Plugin Template DIR
$this->define('WC_TEMPLATE','woocommerce/');
$this->define('WC_CORE_TEMPLATE','woocommerce/');
$this->define('WC_QD_THEME_TEMPLATE','/'.WC_CORE_TEMPLATE.'donation/');
$this->define('WC_QD_LANG',WC_QD_PATH.'languages');
$this->define('WC_QD_TXT','woocommerce-quick-donation'); #plugin lang Domain
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment