Commit ceedeef6 authored by Tech No Freaky's avatar Tech No Freaky

1.2

Added Widget For Donation Form
Added Seperate function to get Donation Projects donation_projects()
Added 2 Actions wc_quick_donation_before_form &
wc_quick_donation_after_form for donation form.
Minor Bug Fix.
parent 5d0b725a
File added
...@@ -6,7 +6,7 @@ Requires at least: 3.0 or higher ...@@ -6,7 +6,7 @@ Requires at least: 3.0 or higher
Tested up to: 4.1.1 Tested up to: 4.1.1
WC requires at least: 1.0 WC requires at least: 1.0
WC tested up to: 2.3.5 WC tested up to: 2.3.5
Stable tag: 1.1 Stable tag: 1.2
License: GPLv2 or later License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html License URI: http://www.gnu.org/licenses/gpl-2.0.html
...@@ -14,14 +14,18 @@ Turns WooCommerce Into Online Donation. ...@@ -14,14 +14,18 @@ Turns WooCommerce Into Online Donation.
== Description == == Description ==
<h3> What's New In 1.0 </h3> <div class="plugin-notice plugin-notice-requested"> <span>!</span><span class="plugin-notice-banner-msg">Dear User, We are still trying to make this plugin a stable and prefect.. if you find any bug / any feature is required please open an issue at <a href="https://github.com/technofreaky/woocomerce-quick-donation/issues">GitHub</a> or <a href="https://wordpress.org/support/plugin/woocommerce-quick-donation">WordPress Support</a> </span></div>
* Configurable Min & Max Donation Amount
* Custom Error Messages <h3> What's New In 1.2 </h3>
* Separate Menu with donation order listings * Donation Widget
* Get Project's By Function
* Added 2 Actions
* Minor Bug Fixes
<h3> Feature Will Be Implemented In Next Release </h3> <h3> Feature Will Be Implemented In Next Release </h3>
* Separate Donation Report Page * Separate Donation Report Page
* Useful Filters
<h3> <blink> Features </blink></h3> <h3> <blink> Features </blink></h3>
* Redirect User After Donation Added To Cart [Cart Page / Checkout Page] * Redirect User After Donation Added To Cart [Cart Page / Checkout Page]
...@@ -29,6 +33,7 @@ Turns WooCommerce Into Online Donation. ...@@ -29,6 +33,7 @@ Turns WooCommerce Into Online Donation.
* Custom Email Template For Donation Processing * Custom Email Template For Donation Processing
* Custom Email Template For Donation Completed * Custom Email Template For Donation Completed
* Configurable Min & Max Donation Amount * Configurable Min & Max Donation Amount
* Donation From Widget
* Custom Error Messages * Custom Error Messages
...@@ -50,6 +55,13 @@ This Plugin Can called by using the below short code ...@@ -50,6 +55,13 @@ This Plugin Can called by using the below short code
`wc-quick-donation/template/donation_completed_html.php `wc-quick-donation/template/donation_completed_html.php
wc-quick-donation/template/donation_completed_plain.php` wc-quick-donation/template/donation_completed_plain.php`
**Plugin Filters, Actions & Functions**
1. Before Donation Prints
`wc_quick_donation_before_form`
2. After Donation Prints
`wc_quick_donation_after_form`
3. Get Project's By Function
`global $wc_quick_donation; $wc_quick_donation->donation_projects();`
Plugin Settings : ***Woocoomerce Settings => Quick Donation*** Plugin Settings : ***Woocoomerce Settings => Quick Donation***
...@@ -57,6 +69,7 @@ Email Template Settings : ***WooCommerce Settings => Emails => Donation Processi ...@@ -57,6 +69,7 @@ Email Template Settings : ***WooCommerce Settings => Emails => Donation Processi
== Upgrade Notice == == Upgrade Notice ==
We have updated ***donation-form.php*** template. so please replace the template if you have modified We have updated ***donation-form.php*** template. so please replace the template if you have modified
please update the settings.
== Installation == == Installation ==
...@@ -127,6 +140,12 @@ Yes you can! Join in on our <a href="https://github.com/technofreaky/woocomerce- ...@@ -127,6 +140,12 @@ Yes you can! Join in on our <a href="https://github.com/technofreaky/woocomerce-
5. Email Template Settings For Donation Completed. 5. Email Template Settings For Donation Completed.
== Changelog == == Changelog ==
= 1.2 =
* Added Widget For Donation Form
* Added Seperate function to get Donation Projects `donation_projects()`
* Added 2 Actions `wc_quick_donation_before_form` & `wc_quick_donation_after_form` for donation form.
* Minor Bug Fix.
= 1.1 = = 1.1 =
* Plugin Activation Issue Fixed. * Plugin Activation Issue Fixed.
......
...@@ -21,7 +21,7 @@ global $donate; ...@@ -21,7 +21,7 @@ global $donate;
<?php do_action('wc_qd_show_projects_list'); ?> <?php do_action('wc_qd_show_projects_list'); ?>
<div class="input text"> <div class="input text">
<label>Donation (&pound;):</label> <label>Donation (<?php echo get_woocommerce_currency_symbol(); ?>):</label>
<input type="text" name="donation_ammount" value="<?php echo $donate; ?>"/> <input type="text" name="donation_ammount" value="<?php echo $donate; ?>"/>
</div> </div>
<div class="submit_btn"> <div class="submit_btn">
......
<?php <?php
/* Copyright 2014 Varun Sridharan (email : varunsridharan23@gmail.com) /* Copyright 2015 Varun Sridharan (email : varunsridharan23@gmail.com)
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2, as it under the terms of the GNU General Public License, version 2, as
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
if ( !defined( 'WP_UNINSTALL_PLUGIN' ) ) if ( !defined( 'WP_UNINSTALL_PLUGIN' ) )
exit(); exit();
$options = array('wc_quick_donation_redirect','wc_quick_donation_cart_remove','wc_quick_donation_projects','wc_quick_donation_project_section_title','wc_quick_donation_order_notes_title'); $options = array('wc_quick_donation_cart_remove','wc_quick_donation_hide_form','wc_quick_donation_hide_order_notes','wc_quick_donation_redirect','wc_quick_donation_payment_gateway','wc_quick_donation_projects','wc_quick_donation_min_required_donation','wc_quick_donation_max_required_donation','wc_quick_donation_project_section_title','wc_quick_donation_order_notes_title','wc_quick_donation_msg_donation_exist','wc_quick_donation_msg_project_invalid','wc_quick_donation_msg_amount_empty','wc_quick_donation_msg_amount_invalid','wc_quick_donation_msg_amount_min_required','wc_quick_donation_msg_amount_max_allowed');
foreach($options as $option_name){ foreach($options as $option_name){
delete_option( $option_name ); delete_option( $option_name );
delete_site_option( $option_name ); delete_site_option( $option_name );
...@@ -25,3 +25,4 @@ foreach($options as $option_name){ ...@@ -25,3 +25,4 @@ foreach($options as $option_name){
?> ?>
...@@ -73,6 +73,27 @@ class WC_Quick_Donation_Settings extends WC_Settings_Page { ...@@ -73,6 +73,27 @@ class WC_Quick_Donation_Settings extends WC_Settings_Page {
), ),
'auto_hide_donation_form' => array(
'name' => 'Hide Donation Form When Donation Exist In Cart',
'desc' => '',
'id' => 'wc_quick_donation_hide_form',
'type' => 'select',
'class' =>'chosen_select',
'css' => $width,
'options' => array('false' => 'Yes','true'=>'No')
),
'hide_order_notes' => array(
'name' => 'Hide Order Notes When Donation Checkout',
'desc' => '',
'id' => 'wc_quick_donation_hide_order_notes',
'type' => 'select',
'class' =>'chosen_select',
'css' => $width,
'options' => array('true' => 'Yes','false'=>'No')
),
'redirect' => array( 'redirect' => array(
'name' => 'Redirect User To', 'name' => 'Redirect User To',
'desc' => 'After Donation Added To Cart.', 'desc' => 'After Donation Added To Cart.',
...@@ -165,6 +186,14 @@ class WC_Quick_Donation_Settings extends WC_Settings_Page { ...@@ -165,6 +186,14 @@ class WC_Quick_Donation_Settings extends WC_Settings_Page {
'type' => 'title', 'type' => 'title',
'desc' => '', 'desc' => '',
'id' => 'wc_quick_donation_message_start' 'id' => 'wc_quick_donation_message_start'
),
'donation_exist' => array(
'name' => 'Donation Exist Error Message',
'type' => 'textarea',
'desc_tip' => 'Message Displayed When Donation Already Exist In Cart',
'css' => 'width:75%; height:75px;',
'id' => 'wc_quick_donation_msg_donation_exist',
'default' =>'<h2> Donation Already Exist </h2>'
), ),
'project_invalid_message' => array( 'project_invalid_message' => array(
'name' => 'Invalid / No Project Selected', 'name' => 'Invalid / No Project Selected',
......
<?php
class woocommerce_quick_donation_widget extends WP_Widget {
/**
* Register widget with WordPress.
*/
function __construct() {
parent::__construct(
'wc_qd_widget', // Base ID
__( 'WooCommerce Quick Donation Form', 'text_domain' ), // Name
array( 'description' => __( 'Display WC Donation Form', 'text_domain' ), ) // Args
);
}
/**
* Front-end display of widget.
*
* @see WP_Widget::widget()
*
* @param array $args Widget arguments.
* @param array $instance Saved values from database.
*/
public function widget( $args, $instance ) {
global $wc_quick_donation;
echo $args['before_widget'];
if ( ! empty( $instance['title'] ) ) {
echo $args['before_title'] . apply_filters( 'widget_title', $instance['title'] ). $args['after_title'];
}
echo $wc_quick_donation->wc_qd_form();
echo $args['after_widget'];
}
/**
* Back-end widget form.
*
* @see WP_Widget::form()
*
* @param array $instance Previously saved values from database.
*/
public function form( $instance ) {
$title = ! empty( $instance['title'] ) ? $instance['title'] : '';
?>
<p>
<label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:' ); ?></label>
<input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>">
</p>
<?php
}
/**
* Sanitize widget form values as they are saved.
*
* @see WP_Widget::update()
*
* @param array $new_instance Values just sent to be saved.
* @param array $old_instance Previously saved values from database.
*
* @return array Updated safe values to be saved.
*/
public function update( $new_instance, $old_instance ) {
$instance = array();
$instance['title'] = ( ! empty( $new_instance['title'] ) ) ? strip_tags( $new_instance['title'] ) : '';
return $instance;
}
}
?>
\ No newline at end of file
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
Plugin Name: Woocommerce Quick Donation Plugin Name: Woocommerce Quick Donation
Plugin URI: http://varunsridharan.in/ Plugin URI: http://varunsridharan.in/
Description: Woocommerce Quick Donation Description: Woocommerce Quick Donation
Version: 1.1 Version: 1.2
Author: Varun Sridharan Author: Varun Sridharan
Author URI: http://varunsridharan.in/ Author URI: http://varunsridharan.in/
License: GPL2 License: GPL2
...@@ -36,13 +36,13 @@ class wc_quick_donation{ ...@@ -36,13 +36,13 @@ class wc_quick_donation{
*/ */
function __construct() { function __construct() {
$this->donation_id = get_option('wc_quick_donation_product_id'); $this->donation_id = get_option('wc_quick_donation_product_id');
$this->plugin_v = '1.0'; $this->plugin_v = '1.2';
add_shortcode( 'wc_quick_donation', array($this,'shortcode_handler' )); add_shortcode( 'wc_quick_donation', array($this,'shortcode_handler' ));
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( 'get_the_generator_html', array($this,'generate_meta_tags'), 15, 2 ); add_action( 'get_the_generator_html', array($this,'generate_meta_tags'), 15, 2 );
add_action( 'get_the_generator_xhtml', array($this,'generate_meta_tags'), 15, 2 ); add_action( 'get_the_generator_xhtml', array($this,'generate_meta_tags'), 15, 2 );
add_action( 'wp_loaded',array($this,'process_donation')); add_action( 'wp_loaded',array($this,'process_donation'),20);
add_action( 'wc_qd_show_projects_list',array($this,'get_projects_list')); add_action( 'wc_qd_show_projects_list',array($this,'get_projects_list'));
add_action( 'woocommerce_checkout_update_order_meta', array($this,'save_order_id_db')); add_action( 'woocommerce_checkout_update_order_meta', array($this,'save_order_id_db'));
...@@ -56,6 +56,21 @@ class wc_quick_donation{ ...@@ -56,6 +56,21 @@ class wc_quick_donation{
add_filter( 'woocommerce_get_price', array($this,'get_price'),10,2); add_filter( 'woocommerce_get_price', array($this,'get_price'),10,2);
add_filter( 'woocommerce_get_settings_pages', array($this,'settings_page') ); add_filter( 'woocommerce_get_settings_pages', array($this,'settings_page') );
add_filter( 'woocommerce_email_classes', array($this,'email_classes')); add_filter( 'woocommerce_email_classes', array($this,'email_classes'));
add_filter('woocommerce_enable_order_notes_field',array($this,'order_notes'));
}
/**
* Hides Order Notes
* @return boolean [[Description]]
* @since 1.2
*/
public function order_notes(){
if($this->donation_exsits() && $this->only_donation_exsits()){
if(get_option('wc_quick_donation_hide_order_notes') === true){
return false;
}
}
return true;
} }
/** /**
...@@ -93,7 +108,7 @@ class wc_quick_donation{ ...@@ -93,7 +108,7 @@ class wc_quick_donation{
* Adds Settings Page * Adds Settings Page
*/ */
public function settings_page( $settings ) { public function settings_page( $settings ) {
$settings[] = include( wc_qd_p.'woocommerce-quick-donation-settings.php' ); $settings[] = include( wc_qd_p.'wc_qd_settings.php' );
return $settings; return $settings;
} }
...@@ -101,8 +116,8 @@ class wc_quick_donation{ ...@@ -101,8 +116,8 @@ class wc_quick_donation{
* Adds Email Classes * Adds Email Classes
*/ */
public function email_classes($email_classes){ public function email_classes($email_classes){
require_once( wc_qd_p.'woocommerce-quick-donation-email-processing.php' ); require_once( wc_qd_p.'wc_qd_email_processing.php' );
require_once( wc_qd_p.'woocommerce-quick-donation-email-completed.php' ); require_once( wc_qd_p.'wc_qd_email_completed.php' );
$email_classes['wc_quick_donation_processing_donation_email'] = new wc_quick_donation_processing_donation_email(); $email_classes['wc_quick_donation_processing_donation_email'] = new wc_quick_donation_processing_donation_email();
$email_classes['wc_quick_donation_completed_donation_email'] = new wc_quick_donation_completed_donation_email(); $email_classes['wc_quick_donation_completed_donation_email'] = new wc_quick_donation_completed_donation_email();
return $email_classes; return $email_classes;
...@@ -298,8 +313,14 @@ class wc_quick_donation{ ...@@ -298,8 +313,14 @@ class wc_quick_donation{
$found = true; $found = true;
} }
if(!$found) if(! $found){
$this->add_donation_cart(); $this->add_donation_cart();
} else {
wc_add_notice(get_option('wc_quick_donation_msg_donation_exist'), 'error' );
}
}else{ }else{
$this->add_donation_cart(); $this->add_donation_cart();
} }
...@@ -374,6 +395,7 @@ class wc_quick_donation{ ...@@ -374,6 +395,7 @@ class wc_quick_donation{
/** /**
* Gets Donation Form. * Gets Donation Form.
* @updated 1.2
*/ */
public function wc_qd_form(){ public function wc_qd_form(){
global $woocommerce; global $woocommerce;
...@@ -385,28 +407,52 @@ class wc_quick_donation{ ...@@ -385,28 +407,52 @@ class wc_quick_donation{
} }
// $donate = jc_round_donation($woocommerce->cart->total ); // $donate = jc_round_donation($woocommerce->cart->total );
if(!$this->donation_exsits()){ $show_form_donatio_exist = get_option('wc_quick_donation_hide_form');
if($this->donation_exsits() && $show_form_donatio_exist){
$this->_load_donation_form();
}else if(! $this->donation_exsits()){
$this->_load_donation_form();
}
}
/**
* Requires Donation Form
* Actions 1 wc_quick_donation_before_form
* Actions 2 wc_quick_donation_after_form
* @since 1.2
*/
private function _load_donation_form(){
do_action('wc_quick_donation_before_form');
$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( 'donation_form.php', array(), '', wc_qd_p . 'template/' ); $wc_get_template( 'donation_form.php', array(), '', wc_qd_p . 'template/' );
do_action('wc_quick_donation_after_form');
}
public function donation_projects(){
$projects_db = get_option('wc_quick_donation_projects');
if(!empty($projects_db) && $projects_db != null){
$project = explode(',',$projects_db);
return $project;
} }
return false;
} }
/** /**
* Generates Select Box For Projects List * Generates Select Box For Projects List
* @updated 1.2
*/ */
public function get_projects_list(){ public function get_projects_list(){
$projects_db = get_option('wc_quick_donation_projects'); $projects_db = $this->donation_projects();
if($projects_db){ if($projects_db){
$project = explode(',',$projects_db);
$project_list = ''; $project_list = '';
$project_list .= '<option value="" > Select A Project </option>'; $project_list .= '<option value="" > Select A Project </option>';
foreach($projects_db as $proj){
foreach($project as $proj){
$project_list .= '<option value="'.$proj.'" > '.$proj.'</option>'; $project_list .= '<option value="'.$proj.'" > '.$proj.'</option>';
} }
echo '<select name="projects">'.$project_list.'</select>'; echo '<select name="projects">'.$project_list.'</select>';
} }
} }
...@@ -416,7 +462,7 @@ class wc_quick_donation{ ...@@ -416,7 +462,7 @@ class wc_quick_donation{
* wc_quick_donation shortcode Handler * wc_quick_donation shortcode Handler
*/ */
public function shortcode_handler(){ public function shortcode_handler(){
echo $this->wc_qd_form(); return $this->wc_qd_form();
} }
...@@ -501,7 +547,14 @@ function create_donation(){ ...@@ -501,7 +547,14 @@ function create_donation(){
if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) { if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) {
register_activation_hook( __FILE__, array( 'wc_quick_donation', 'install' ) ); register_activation_hook( __FILE__, array( 'wc_quick_donation', 'install' ) );
$wc_quick_donation = new wc_quick_donation; $wc_quick_donation = new wc_quick_donation;
require(wc_qd_p.'woocommerce-quick-donation-report.php'); require(wc_qd_p.'wc_qd_donation_orders.php');
require(wc_qd_p.'wc_qd_widget.php');
function register_foo_widget() {
register_widget( 'woocommerce_quick_donation_widget' );
}
add_action( 'widgets_init', 'register_foo_widget' );
} else { } else {
add_action( 'admin_notices', 'wc_quick_donation_notice' ); add_action( 'admin_notices', 'wc_quick_donation_notice' );
} }
......
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