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; } ...@@ -18,11 +18,53 @@ if ( ! defined( 'WPINC' ) ) { die; }
class WooCommerce_Quick_Donation_Admin_Function { class WooCommerce_Quick_Donation_Admin_Function {
public function __construct(){ public function __construct(){
$this->check_template_files();
add_action( 'post_row_actions', array($this,'protect_donation_product'),99,2); add_action( 'post_row_actions', array($this,'protect_donation_product'),99,2);
add_action( 'parse_query', array( $this, 'hide_donation_order_woocommerce_order' ) ); add_action( 'parse_query', array( $this, 'hide_donation_order_woocommerce_order' ) );
add_filter( 'wc_order_types',array($this,'add_wc_order_types'),99,2); 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) { public function hide_donation_order_woocommerce_order($query) {
global $pagenow,$post_type; global $pagenow,$post_type;
$query = $query; $query = $query;
......
...@@ -4,4 +4,3 @@ if (empty($send_fields[WC_QD_DB.'payment_gateway'])) { ...@@ -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'); 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
...@@ -151,8 +151,13 @@ class WooCommerce_Quick_Donation_Functions { ...@@ -151,8 +151,13 @@ class WooCommerce_Quick_Donation_Functions {
$attributes .= $attr_key.'="'.$attr_val.'" '; $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; return $field_output;
} }
...@@ -165,27 +170,37 @@ class WooCommerce_Quick_Donation_Functions { ...@@ -165,27 +170,37 @@ class WooCommerce_Quick_Donation_Functions {
$class = apply_filters('wcqd_project_price_text_class',array(),'text'); $class = apply_filters('wcqd_project_price_text_class',array(),'text');
$custom_attributes = apply_filters('wcqd_project_price_text_attribute',array(),'text'); $custom_attributes = apply_filters('wcqd_project_price_text_attribute',array(),'text');
$value = ''; $value = '';
$class = implode(' ',$class); $class = implode(' ',$class);
$attributes = ''; $attributes = '';
foreach($custom_attributes as $attr_key => $attr_val) { foreach($custom_attributes as $attr_key => $attr_val) {
$attributes .= $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; 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 = 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){ public function locate_template($template){
$default_path = WC_QD_TEMPLATE; $default_path = WC_QD_TEMPLATE;
$template_path = WC_TEMPLATE.'donation/'; $template_path = WC_CORE_TEMPLATE.'donation/';
$template = $template; $template = $template;
$locate = wc_locate_template($template,$template_path, $default_path); $locate = wc_locate_template($template,$template_path, $default_path);
return $locate; return $locate;
......
...@@ -42,11 +42,13 @@ class WooCommerce_Quick_Donation_Shortcode { ...@@ -42,11 +42,13 @@ class WooCommerce_Quick_Donation_Shortcode {
ob_flush(); ob_flush();
} }
ob_start(); // ob_start();
do_action('wc_quick_donation_before_doantion_form',$return_value , $settings['type'],$settings['grouped']); 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']); do_action('wc_quick_donation_after_doantion_form',$return_value , $settings['type'],$settings['grouped']);
$messages .= ob_get_clean(); //$messages .= ob_get_clean();
return $messages; return $messages;
} }
......
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
/** /**
* Cart item data (when outputting non-flat) * Cart item data (when outputting non-flat)
* *
* @author WooThemes * @author Varun Sridharan
* @package WooCommerce/Templates * @package WooCommerce Quick Donation/Templates/cart
* @version 2.4.0 * @version 0.1
*/ */
if ( ! defined( 'ABSPATH' ) ) { if ( ! defined( 'ABSPATH' ) ) {
exit; exit;
......
...@@ -2,11 +2,9 @@ ...@@ -2,11 +2,9 @@
/** /**
* Shipping Methods Display * Shipping Methods Display
* *
* In 2.1 we show methods per package. This allows for multiple methods per order if so desired. * @author Varun Sridharan
* * @package WooCommerce Quick Donation/Templates/cart
* @author WooThemes * @version 0.1
* @package WooCommerce/Templates
* @version 2.3.0
*/ */
if ( ! defined( 'ABSPATH' ) ) { if ( ! defined( 'ABSPATH' ) ) {
......
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
/** /**
* Cart totals * Cart totals
* *
* @author WooThemes * @author Varun Sridharan
* @package WooCommerce/Templates * @package WooCommerce Quick Donation/Templates/cart
* @version 2.3.6 * @version 0.1
*/ */
if ( ! defined( 'ABSPATH' ) ) { if ( ! defined( 'ABSPATH' ) ) {
......
<?php <?php
/** /**
* Cart Page * Donation Cart Template
* *
* @author WooThemes * @author Varun Sridharan
* @package WooCommerce/Templates * @package WooCommerce Quick Donation/Templates/cart
* @version 2.3.8 * @version 0.1
*/ */
if ( ! defined( 'ABSPATH' ) ) { if ( ! defined( 'ABSPATH' ) ) {
......
...@@ -4,9 +4,9 @@ ...@@ -4,9 +4,9 @@
* *
* Contains the markup for the proceed to checkout button on the cart * Contains the markup for the proceed to checkout button on the cart
* *
* @author WooThemes * @author Varun Sridharan
* @package WooCommerce/Templates * @package WooCommerce Quick Donation/Templates/cart
* @version 2.4.0 * @version 0.1
*/ */
if ( ! defined( 'ABSPATH' ) ) { if ( ! defined( 'ABSPATH' ) ) {
......
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
/** /**
* Cart errors page * Cart errors page
* *
* @author WooThemes * @author Varun Sridharan
* @package WooCommerce/Templates * @package WooCommerce Quick Donation/Templates/checkout
* @version 2.4.0 * @version 0.1
*/ */
if ( ! defined( 'ABSPATH' ) ) { if ( ! defined( 'ABSPATH' ) ) {
......
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
/** /**
* Checkout billing information form * Checkout billing information form
* *
* @author WooThemes * @author Varun Sridharan
* @package WooCommerce/Templates * @package WooCommerce Quick Donation/Templates/checkout
* @version 2.1.2 * @version 0.1
*/ */
if ( ! defined( 'ABSPATH' ) ) { if ( ! defined( 'ABSPATH' ) ) {
......
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
/** /**
* Checkout Form * Checkout Form
* *
* @author WooThemes * @author Varun Sridharan
* @package WooCommerce/Templates * @package WooCommerce Quick Donation/Templates/checkout
* @version 2.3.0 * @version 0.1
*/ */
if ( ! defined( 'ABSPATH' ) ) { if ( ! defined( 'ABSPATH' ) ) {
......
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
/** /**
* Checkout coupon form * Checkout coupon form
* *
* @author WooThemes * @author Varun Sridharan
* @package WooCommerce/Templates * @package WooCommerce Quick Donation/Templates/checkout
* @version 2.2 * @version 0.1
*/ */
if ( ! defined( 'ABSPATH' ) ) { if ( ! defined( 'ABSPATH' ) ) {
......
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
/** /**
* Checkout login form * Checkout login form
* *
* @author WooThemes * @author Varun Sridharan
* @package WooCommerce/Templates * @package WooCommerce Quick Donation/Templates/checkout
* @version 2.0.0 * @version 0.1
*/ */
if ( ! defined( 'ABSPATH' ) ) { if ( ! defined( 'ABSPATH' ) ) {
......
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
/** /**
* Pay for order form * Pay for order form
* *
* @author WooThemes * @author Varun Sridharan
* @package WooCommerce/Templates * @package WooCommerce Quick Donation/Templates/checkout
* @version 1.6.4 * @version 0.1
*/ */
if ( ! defined( 'ABSPATH' ) ) { if ( ! defined( 'ABSPATH' ) ) {
......
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
/** /**
* Checkout shipping information form * Checkout shipping information form
* *
* @author WooThemes * @author Varun Sridharan
* @package WooCommerce/Templates * @package WooCommerce Quick Donation/Templates/checkout
* @version 2.2.0 * @version 0.1
*/ */
if ( ! defined( 'ABSPATH' ) ) { if ( ! defined( 'ABSPATH' ) ) {
......
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
/** /**
* Output a single payment method * Output a single payment method
* *
* @author WooThemes * @author Varun Sridharan
* @package WooCommerce/Templates * @package WooCommerce Quick Donation/Templates/checkout
* @version 2.3.0 * @version 0.1
*/ */
if ( ! defined( 'ABSPATH' ) ) { if ( ! defined( 'ABSPATH' ) ) {
......
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
/** /**
* Checkout Payment Section * Checkout Payment Section
* *
* @author WooThemes * @author Varun Sridharan
* @package WooCommerce/Templates * @package WooCommerce Quick Donation/Templates/checkout
* @version 2.3.0 * @version 0.1
*/ */
if ( ! defined( 'ABSPATH' ) ) { if ( ! defined( 'ABSPATH' ) ) {
......
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
/** /**
* Review order table * Review order table
* *
* @author WooThemes * @author Varun Sridharan
* @package WooCommerce/Templates * @package WooCommerce Quick Donation/Templates/checkout
* @version 2.3.0 * @version 0.1
*/ */
if ( ! defined( 'ABSPATH' ) ) { if ( ! defined( 'ABSPATH' ) ) {
......
...@@ -2,11 +2,10 @@ ...@@ -2,11 +2,10 @@
/** /**
* Thankyou page * Thankyou page
* *
* @author WooThemes * @author Varun Sridharan
* @package WooCommerce/Templates * @package WooCommerce Quick Donation/Templates/checkout
* @version 2.2.0 * @version 0.1
*/ */
if ( ! defined( 'ABSPATH' ) ) { if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly exit; // Exit if accessed directly
} }
......
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
/** /**
* Customer invoice email * Customer invoice email
* *
* @author WooThemes * @author Varun Sridharan
* @package WooCommerce/Templates/Emails * @package WooCommerce Quick Donation/Templates/emails
* @version 2.4.0 * @version 0.1
*/ */
if ( ! defined( 'ABSPATH' ) ) { if ( ! defined( 'ABSPATH' ) ) {
......
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
/** /**
* Customer invoice email (plain text) * Customer invoice email (plain text)
* *
* @author WooThemes * @author Varun Sridharan
* @package WooCommerce/Templates/Emails/Plain * @package WooCommerce Quick Donation/Templates/emails/plain
* @version 2.2.0 * @version 0.1
*/ */
if ( ! defined( 'ABSPATH' ) ) { if ( ! defined( 'ABSPATH' ) ) {
......
<?php <?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){ foreach($project_list as $id => $val){
...@@ -14,3 +20,5 @@ 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 <?php
global $id, $name, $class, $field_output, $is_grouped, $project_list,$attributes; /**
* HTML Select Field Template
$field_output = '<select id="'.$id.'" name="'.$name.'" class="'.$class.'" '.$attributes.'>'; *
* @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){ foreach($project_list as $id => $val){
if(is_array($val)){ if(is_array($val)){
...@@ -16,4 +23,6 @@ foreach($project_list as $id => $val){ ...@@ -16,4 +23,6 @@ foreach($project_list as $id => $val){
} }
} }
$field_output .= '</select>'; echo $field_output;
\ No newline at end of file ?>
</select>
\ No newline at end of file
<?php <?php
global $id, $name, $class, $field_output,$attributes,$value; /**
* HTML Text Field Template
*
$field_output = '<input type="text" id="'.$id.'" name="'.$name.'" class="'.$class.'" '.$attributes.' value="'.$value.'" />'; * @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 <?php
/** /**
* My Orders * My Donaions
* *
* Shows recent orders on the account page * Shows recent donaions on the account page
* *
* @author WooThemes * @author Varun Sridharan
* @package WooCommerce/Templates * @package WooCommerce Quick Donation/Templates/myaccount
* @version 2.3.10 * @version 0.1
*/ */
if ( ! defined( 'ABSPATH' ) ) { if ( ! defined( 'ABSPATH' ) ) {
......
<?php <?php
/** /**
* View Order * View Donation
* *
* Shows the details of a particular order on the account page * Shows the details of a particular order on the account page
* * @author Varun Sridharan
* @author WooThemes * @package WooCommerce Quick Donation/Templates/myaccount
* @package WooCommerce/Templates * @version 0.1
* @version 2.2.0
*/ */
if ( ! defined( 'ABSPATH' ) ) { if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly exit; // Exit if accessed directly
} }
......
<?php <?php
/** /**
* Order details * Donation Details
* *
* @author WooThemes * @author Varun Sridharan
* @package WooCommerce/Templates * @package WooCommerce Quick Donation/Templates/order
* @version 2.4.0 * @version 0.1
*/ */
if ( ! defined( 'ABSPATH' ) ) { if ( ! defined( 'ABSPATH' ) ) {
......
<?php <?php
/** /**
* Order tracking form * Donation Tracking
* *
* @author WooThemes * @author Varun Sridharan
* @package WooCommerce/Templates * @package WooCommerce Quick Donation/Templates/order
* @version 1.6.4 * @version 0.1
*/ */
if ( ! defined( 'ABSPATH' ) ) { if ( ! defined( 'ABSPATH' ) ) {
......
<?php <?php
/** /**
* Order again button * Donate Again
* *
* @author WooThemes * @author Varun Sridharan
* @package WooCommerce/Templates * @package WooCommerce Quick Donation/Templates/order
* @version 2.3.0 * @version 0.1
*/ */
if ( ! defined( 'ABSPATH' ) ) { if ( ! defined( 'ABSPATH' ) ) {
......
<?php <?php
/** /**
* Order Customer Details * Donor Details
* *
* @author WooThemes * @author Varun Sridharan
* @package WooCommerce/Templates * @package WooCommerce Quick Donation/Templates/order
* @version 2.4.0 * @version 0.1
*/ */
if ( ! defined( 'ABSPATH' ) ) { if ( ! defined( 'ABSPATH' ) ) {
......
<?php <?php
/** /**
* Order Item Details * Donation Item Details
* *
* @author WooThemes * @author Varun Sridharan
* @package WooCommerce/Templates * @package WooCommerce Quick Donation/Templates/order
* @version 2.4.0 * @version 0.1
*/ */
if ( ! defined( 'ABSPATH' ) ) { if ( ! defined( 'ABSPATH' ) ) {
...@@ -18,8 +18,6 @@ if ( ! defined( 'ABSPATH' ) ) { ...@@ -18,8 +18,6 @@ if ( ! defined( 'ABSPATH' ) ) {
$is_visible = $product && $product->is_visible(); $is_visible = $product && $product->is_visible();
$project_id = WC_QD()->db()->get_project_id($order->id); $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 )); echo sprintf( '<a href="%s">%s</a>', get_permalink( $project_id ), get_the_title($project_id ));
?> ?>
</td> </td>
<td class="product-total"> <td class="product-total">
......
<?php <?php
/** /**
* Order tracking * Donation tracking
* *
* @author WooThemes * @author Varun Sridharan
* @package WooCommerce/Templates * @package WooCommerce Quick Donation/Templates/order
* @version 2.2.0 * @version 0.1
*/ */
if ( ! defined( 'ABSPATH' ) ) { if ( ! defined( 'ABSPATH' ) ) {
......
...@@ -226,7 +226,8 @@ class WooCommerce_Quick_Donation { ...@@ -226,7 +226,8 @@ class WooCommerce_Quick_Donation {
$this->define('WC_QD_CSS',WC_QD_URL.'/includes/css/'); $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_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_LANG',WC_QD_PATH.'languages');
$this->define('WC_QD_TXT','woocommerce-quick-donation'); #plugin lang Domain $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