Commit ac36be3c authored by Varun Sridharan's avatar Varun Sridharan

Removed Unwanted Files

parent 1469941b
*.log
.htaccess
sitemap.xml
sitemap.xml.gz
wp-config.php
wp-content/advanced-cache.php
wp-content/backup-db/
wp-content/backups/
wp-content/blogs.dir/
wp-content/cache/
wp-content/upgrade/
wp-content/uploads/
wp-content/wp-cache-config.php
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc., <http://fsf.org/>
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Lesser General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
{description}
Copyright (C) {year} {fullname}
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
{signature of Ty Coon}, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License.
woocomerce-quick-donation
=========================
Online Donation Using Woocoomerce. for woocommerce user's
File deleted
=== WooCommerce Quick Donation ===
Contributors: varunms
Donate link: http://varunsridharan.in
Tags: WooCommerce,Quick Dontion,quick donation,online donation,wordpress donation,simple donation,donation form,WC donation,Online Payment,Payment,Online,Donate,Monthly Goal,affiliate, cart, checkout, commerce, configurable, digital, download, downloadable, e-commerce, ecommerce, inventory, reports, sales, sell, shipping, shop, shopping, stock, store, tax, variable, widgets, woothemes, wordpress ecommerce
Requires at least: 3.0 or higher
Tested up to: 4.1.1
WC requires at least: 1.0
WC tested up to: 2.3.5
Stable tag: 1.2
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Turns WooCommerce Into Online Donation.
== Description ==
<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>
<h3> What's New In 1.2 </h3>
* Donation Widget
* Get Project's By Function
* Added 2 Actions
* Minor Bug Fixes
<h3> Feature Will Be Implemented In Next Release </h3>
* Separate Donation Report Page
<h3> <blink> Features </blink></h3>
* Redirect User After Donation Added To Cart [Cart Page / Checkout Page]
* Select Your Preferred Payment Gateway For Donation
* Custom Email Template For Donation Processing
* Custom Email Template For Donation Completed
* Configurable Min & Max Donation Amount
* Donation From Widget
* Custom Error Messages
WooCommerce Shopping Cart Donation which makes WooComerce to use for online donation purpose.
This plugin will create a new product in the name of **donation**.
This Plugin Can called by using the below short code
`[wc_quick_donation]`
**Plugin Template List** *[You Can Modify The Template Buy Copying To Your Theme's Folder]*
1. Donation Form Template
`wc-quick-donation/template/donation_form.php`
2. Donation Processing Email Template
`wc-quick-donation/template/donation_processing_html.php
wc-quick-donation/template/donation_processing_plain.php`
3. Donation Completed Email Template
`wc-quick-donation/template/donation_completed_html.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***
Email Template Settings : ***WooCommerce Settings => Emails => Donation Processing & Completed***
== Upgrade Notice ==
We have updated ***donation-form.php*** template. so please replace the template if you have modified
please update the settings.
== Installation ==
= Minimum Requirements =
* WordPress 3.8 or greater
* PHP version 5.2.4 or greater
* MySQL version 5.0 or greater
= Automatic installation =
Automatic installation is the easiest option as WordPress handles the file transfers itself and you don't need to leave your web browser. To do an automatic install of WooCommerce Quick Donation, log in to your WordPress dashboard, navigate to the Plugins menu and click Add New.
In the search field type "WooCommerce Quick Donation" and click Search Plugins. Once you've found our eCommerce plugin you can view details about it such as the the point release, rating and description. Most importantly of course, you can install it by simply clicking "Install Now"
= Manual installation =
The manual installation method involves downloading our plugin and uploading it to your Web Server via your favourite FTP application. The WordPress codex contains [instructions on how to do this here](http://codex.wordpress.org/Managing_Plugins#Manual_Plugin_Installation).
1. Installing alternatives:
* *via Admin Dashboard:* Go to 'Plugins > Add New', search for "WooCommerce Quick Donation", click "install"
* *OR via direct ZIP upload:* Upload the ZIP package via 'Plugins > Add New > Upload' in your WP Admin
* *OR via FTP upload:* Upload `WooCommerce-quick-donation` folder to the `/wp-content/plugins/` directory
2. Activate the plugin through the 'Plugins' menu in WordPress
3. For Settings Look at your `WooCommerce => Settings => WC Quick Donation`
== Frequently Asked Questions ==
**How To Call / Use This Plugin ?**
This Plugin Can Be Called Using `[wc_quick_donation]`
**Can I Modify The Donation Form ?**
Yes. Its Possible By Copying To Your Theme's Folder `wp-content/plugins/wc-quick-donation/template/donation_form.php`
**What Is The Use Of Project Field ?**
Project is like [category / division]. for which you donation. multiple can be entered by `,` separated eg : `Project 1,Project 2`
**Donation Plugin Not Working After Upgrading To 0.2**
As we have updated ***donation-form.php*** template. it may not be working with the old one. so please replace the template if you have modified or contact us.
**How I can get project name in email template**
You can get the name by calling the variable `$project_name`
**Where can I request new features**
Please open an issue at <a href="https://github.com/technofreaky/woocomerce-quick-donation/"> GitHub </a> and we will look into it
**I have an idea for your plugin!**
That's great. We are always open to your input, and we would like to add anything we think will be useful to a lot of people. Please send your comment/idea to varunsridharan23@gmail.com
**I found a bug!**
Oops. Please User github / WordPress to post bugs. <a href="https://github.com/technofreaky/woocomerce-quick-donation/"> Open an Issue </a>
**WooCommerce Quick Donation is awesome! Can I contribute?**
Yes you can! Join in on our <a href="https://github.com/technofreaky/woocomerce-quick-donation/">GitHub repository :)</a>
== Screenshots ==
1. General Settings
2. Donation Settings
3. Custom Error Message
4. Email Template Settings For Donation Processing
5. Email Template Settings For Donation Completed.
== 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 =
* Plugin Activation Issue Fixed.
= 1.0 =
* Configurable Min & Max Donation Amount
* Custom Error Messages
* Separate Menu with donation order listings
* Fixed Order Notes And Order Meta Added For All Products
* Fixed Saving Donation Order Id In DB [Before It Stored All Order IDS]
* Minor performance fixes
* Code Clean Up
* Removed Row Action [Quick Edit , Trash & Duplicate] Options For Donation Product In Product Listing
= 0.4 =
* Internal Server Error / php error fixed while adding donation to cart [WP : 4.1 | WC : 2.3.3]
* Added Generator Meta Tag
* Minor Bug Fix
= 0.3 =
* Plugin Activation Issue Fixed.
= 0.2 =
* Redirect User After Donation Added To Cart [Cart Page / Checkout Page]
* Select Your Preferred Payment Gateway For Donation
* Custom Email Template For Donation Processing
* Custom Email Template For Donation Completed
* Some Minor Bug Fix
= 0.1 =
* Base Version
<?php
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly ?>
<?php do_action( 'woocommerce_email_header', $email_heading ); ?>
<p><?php printf( __( 'Thanks For Your Donation %s. Their order is as follows:', 'woocommerce' ), $order->billing_first_name . ' ' . $order->billing_last_name ); ?></p>
<?php do_action( 'woocommerce_email_before_order_table', $order, true, false ); ?>
<h2><a href="<?php echo admin_url( 'post.php?post=' . $order->id . '&action=edit' ); ?>"><?php printf( __( 'Order: %s', 'woocommerce'), $order->get_order_number() ); ?></a> <?php echo $project_name; ?> (<?php printf( '<time datetime="%s">%s</time>', date_i18n( 'c', strtotime( $order->order_date ) ), date_i18n( wc_date_format(), strtotime( $order->order_date ) ) ); ?>)</h2>
<table cellspacing="0" cellpadding="6" style="width: 100%; border: 1px solid #eee;" border="1" bordercolor="#eee">
<thead>
<tr>
<th scope="col" style="text-align:left; border: 1px solid #eee;"><?php _e( 'Product', 'woocommerce' ); ?></th>
<th scope="col" style="text-align:left; border: 1px solid #eee;"><?php _e( 'Quantity', 'woocommerce' ); ?></th>
<th scope="col" style="text-align:left; border: 1px solid #eee;"><?php _e( 'Price', 'woocommerce' ); ?></th>
</tr>
</thead>
<tbody>
<?php echo $order->email_order_items_table( false, true ); ?>
</tbody>
<tfoot>
<?php
if ( $totals = $order->get_order_item_totals() ) {
$i = 0;
foreach ( $totals as $total ) {
$i++;
?><tr>
<th scope="row" colspan="2" style="text-align:left; border: 1px solid #eee; <?php if ( $i == 1 ) echo 'border-top-width: 4px;'; ?>"><?php echo $total['label']; ?></th>
<td style="text-align:left; border: 1px solid #eee; <?php if ( $i == 1 ) echo 'border-top-width: 4px;'; ?>"><?php echo $total['value']; ?></td>
</tr><?php
}
}
?>
</tfoot>
</table>
<?php do_action( 'woocommerce_email_after_order_table', $order, true, false ); ?>
<?php do_action( 'woocommerce_email_order_meta', $order, true, false ); ?>
<h2><?php _e( 'Customer details', 'woocommerce' ); ?></h2>
<?php if ( $order->billing_email ) : ?>
<p><strong><?php _e( 'Email:', 'woocommerce' ); ?></strong> <?php echo $order->billing_email; ?></p>
<?php endif; ?>
<?php if ( $order->billing_phone ) : ?>
<p><strong><?php _e( 'Tel:', 'woocommerce' ); ?></strong> <?php echo $order->billing_phone; ?></p>
<?php endif; ?>
<?php wc_get_template( 'emails/email-addresses.php', array( 'order' => $order ) ); ?>
<?php do_action( 'woocommerce_email_footer' ); ?>
<?php
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
echo $email_heading . "\n\n";
echo sprintf( __( 'You have received an order from %s. Their order is as follows:', 'woocommerce' ), $order->billing_first_name . ' ' . $order->billing_last_name ) . "\n\n";
echo "****************************************************\n\n";
do_action( 'woocommerce_email_before_order_table', $order, $sent_to_admin, $plain_text );
echo sprintf( __( 'Order number: %s', 'woocommerce'), $order->get_order_number() ) . "\n";
echo sprintf( __( 'Order link: %s', 'woocommerce'), admin_url( 'post.php?post=' . $order->id . '&action=edit' ) ) . "\n";
echo sprintf( __( 'Order date: %s', 'woocommerce'), date_i18n( __( 'jS F Y', 'woocommerce' ), strtotime( $order->order_date ) ) ) . "\n";
do_action( 'woocommerce_email_order_meta', $order, $sent_to_admin, $plain_text );
echo "\n" . $order->email_order_items_table( false, true, '', '', '', true );
echo "----------\n\n";
if ( $totals = $order->get_order_item_totals() ) {
foreach ( $totals as $total ) {
echo $total['label'] . "\t " . $total['value'] . "\n";
}
}
echo "\n****************************************************\n\n";
do_action( 'woocommerce_email_after_order_table', $order, $sent_to_admin, $plain_text );
echo __( 'Customer details', 'woocommerce' ) . "\n";
if ( $order->billing_email )
echo __( 'Email:', 'woocommerce' ); echo $order->billing_email . "\n";
if ( $order->billing_phone )
echo __( 'Tel:', 'woocommerce' ); ?> <?php echo $order->billing_phone . "\n";
wc_get_template( 'emails/plain/email-addresses.php', array( 'order' => $order ) );
echo "\n****************************************************\n\n";
echo apply_filters( 'woocommerce_email_footer_text', get_option( 'woocommerce_email_footer_text' ) );
\ No newline at end of file
<?php
/**
* Single Product Image
*
* @author Varun Sridharan
* @package WC Quick Donation/Templates
* @version 0.1
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
global $donate;
?>
<form method="post">
<table>
<tr class="donation-block">
<td colspan="6">
<div class="donation">
<p class="message"><strong>Add a donation to your order:</strong></p>
<?php do_action('wc_qd_show_projects_list'); ?>
<div class="input text">
<label>Donation (<?php echo get_woocommerce_currency_symbol(); ?>):</label>
<input type="text" name="donation_ammount" value="<?php echo $donate; ?>"/>
</div>
<div class="submit_btn">
<input type="submit" name="donation_add" value="Add Donation"/>
</div>
</div>
</td>
</tr>
</table>
</form>
\ No newline at end of file
<?php
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly ?>
<?php do_action( 'woocommerce_email_header', $email_heading ); ?>
<p><?php printf( __( 'Thanks For Your Donation %s. Their order is as follows:', 'woocommerce' ), $order->billing_first_name . ' ' . $order->billing_last_name ); ?></p>
<?php do_action( 'woocommerce_email_before_order_table', $order, true, false ); ?>
<h2><a href="<?php echo admin_url( 'post.php?post=' . $order->id . '&action=edit' ); ?>"><?php printf( __( 'Order: %s', 'woocommerce'), $order->get_order_number() ); ?></a> <?php echo $project_name; ?> (<?php printf( '<time datetime="%s">%s</time>', date_i18n( 'c', strtotime( $order->order_date ) ), date_i18n( wc_date_format(), strtotime( $order->order_date ) ) ); ?>)</h2>
<table cellspacing="0" cellpadding="6" style="width: 100%; border: 1px solid #eee;" border="1" bordercolor="#eee">
<thead>
<tr>
<th scope="col" style="text-align:left; border: 1px solid #eee;"><?php _e( 'Product', 'woocommerce' ); ?></th>
<th scope="col" style="text-align:left; border: 1px solid #eee;"><?php _e( 'Quantity', 'woocommerce' ); ?></th>
<th scope="col" style="text-align:left; border: 1px solid #eee;"><?php _e( 'Price', 'woocommerce' ); ?></th>
</tr>
</thead>
<tbody>
<?php echo $order->email_order_items_table( false, true ); ?>
</tbody>
<tfoot>
<?php
if ( $totals = $order->get_order_item_totals() ) {
$i = 0;
foreach ( $totals as $total ) {
$i++;
?><tr>
<th scope="row" colspan="2" style="text-align:left; border: 1px solid #eee; <?php if ( $i == 1 ) echo 'border-top-width: 4px;'; ?>"><?php echo $total['label']; ?></th>
<td style="text-align:left; border: 1px solid #eee; <?php if ( $i == 1 ) echo 'border-top-width: 4px;'; ?>"><?php echo $total['value']; ?></td>
</tr><?php
}
}
?>
</tfoot>
</table>
<?php do_action( 'woocommerce_email_after_order_table', $order, true, false ); ?>
<?php do_action( 'woocommerce_email_order_meta', $order, true, false ); ?>
<h2><?php _e( 'Customer details', 'woocommerce' ); ?></h2>
<?php if ( $order->billing_email ) : ?>
<p><strong><?php _e( 'Email:', 'woocommerce' ); ?></strong> <?php echo $order->billing_email; ?></p>
<?php endif; ?>
<?php if ( $order->billing_phone ) : ?>
<p><strong><?php _e( 'Tel:', 'woocommerce' ); ?></strong> <?php echo $order->billing_phone; ?></p>
<?php endif; ?>
<?php wc_get_template( 'emails/email-addresses.php', array( 'order' => $order ) ); ?>
<?php do_action( 'woocommerce_email_footer' ); ?>
<?php
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
echo $email_heading . "\n\n";
echo sprintf( __( 'You have received an order from %s. Their order is as follows:', 'woocommerce' ), $order->billing_first_name . ' ' . $order->billing_last_name ) . "\n\n";
echo "****************************************************\n\n";
do_action( 'woocommerce_email_before_order_table', $order, $sent_to_admin, $plain_text );
echo sprintf( __( 'Order number: %s', 'woocommerce'), $order->get_order_number() ) . "\n";
echo sprintf( __( 'Order link: %s', 'woocommerce'), admin_url( 'post.php?post=' . $order->id . '&action=edit' ) ) . "\n";
echo sprintf( __( 'Order date: %s', 'woocommerce'), date_i18n( __( 'jS F Y', 'woocommerce' ), strtotime( $order->order_date ) ) ) . "\n";
do_action( 'woocommerce_email_order_meta', $order, $sent_to_admin, $plain_text );
echo "\n" . $order->email_order_items_table( false, true, '', '', '', true );
echo "----------\n\n";
if ( $totals = $order->get_order_item_totals() ) {
foreach ( $totals as $total ) {
echo $total['label'] . "\t " . $total['value'] . "\n";
}
}
echo "\n****************************************************\n\n";
do_action( 'woocommerce_email_after_order_table', $order, $sent_to_admin, $plain_text );
echo __( 'Customer details', 'woocommerce' ) . "\n";
if ( $order->billing_email )
echo __( 'Email:', 'woocommerce' ); echo $order->billing_email . "\n";
if ( $order->billing_phone )
echo __( 'Tel:', 'woocommerce' ); ?> <?php echo $order->billing_phone . "\n";
wc_get_template( 'emails/plain/email-addresses.php', array( 'order' => $order ) );
echo "\n****************************************************\n\n";
echo apply_filters( 'woocommerce_email_footer_text', get_option( 'woocommerce_email_footer_text' ) );
\ No newline at end of file
<?php
/* Copyright 2015 Varun Sridharan (email : varunsridharan23@gmail.com)
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
published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
if ( !defined( 'WP_UNINSTALL_PLUGIN' ) )
exit();
$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){
delete_option( $option_name );
delete_site_option( $option_name );
}
?>
<?php
/**
* Package : WooCommerce Quick Donation
* Since : 1.0
* Usage : Custom Report Page For Donation
*/
class wc_quick_donation_report {
private $donation_orderids;
private $status_count;
private $menu_name;
private $menu_slug;
/**
* Setup WC Quick Donation Report Page
*/
function __construct(){
$this->status_count = 0;
$this->donation_orderids = json_decode(get_option('wc_quick_donation_ids'));
$this->get_status_count();
$this->menu_name = 'Donations';
$this->menu_slug = 'wc-quick-donations-orders';
add_action('admin_menu', array($this,'register_menu'));
add_action('admin_menu', array($this,'add_donation_notification_bubble'),99);
add_filter('woocommerce_screen_ids',array($this,'set_wc_screen_ids'));
}
public function set_wc_screen_ids($screen){
$screen[] = 'woocommerce_page_wc-quick-donations-orders';
return $screen;
}
/**
* Registers A Menu In Admin
*/
public function register_menu(){
add_submenu_page( 'woocommerce', $this->menu_name,$this->menu_name, 'view_woocommerce_reports', $this->menu_slug, array( $this, 'donation_orders_listing' ) );
}
public function add_donation_notification_bubble() {
global $submenu;
if(isset($submenu['woocommerce'])){
foreach($submenu['woocommerce'] as $menuK => $menu){
if($menu[2] === $this->menu_slug ){
$submenu['woocommerce'][$menuK][0] .= "<span class='update-plugins count-1'><span class='update-count'>$this->status_count </span></span>";
}
}
}
}
public function donation_orders_listing(){
global $wpdb;
$args = array( 'post_type' => 'shop_order', 'post_status' => array_keys(wc_get_order_statuses()),'post__in' => $this->donation_orderids );
$wp_query = new WP_Query($args);
require('wc_quick_donation_listing_table.php');
tt_render_list_page($wp_query);
}
private function get_status_count(){
if(!empty($this->donation_orderids)){
foreach($this->donation_orderids as $id){
$order_status = get_post_status($id);
if($order_status == 'wc-on-hold' || $order_status == 'wc-processing'){
$this->status_count++;
}
}
return $this->status_count;
}
return '';
}
private function generate_data(){
foreach($this->donation_orderids as $id){
$order_details = $this->get_order_info($id);
$order_meta = $this->get_order_meta($id);
$order_info = array_merge($order_details,$order_meta);
unset($order_details,$order_meta);
$user_details = $this->get_user_info($order_info['by_user']);
$order = array_merge($order_info,$user_details);
}
}
/* private function _generate_data(){
require(wc_qd_p.'views/report_tbl_header.php');
global $i;
$i = 1;
foreach($this->donation_orderids as $id){
$order_details = $this->get_order_info($id);
$order_meta = $this->get_order_meta($id);
$order_info = array_merge($order_details,$order_meta);
unset($order_details,$order_meta);
$user_details = $this->get_user_info($order_info['by_user']);
global $order;
$order = array_merge($order_info,$user_details);
require(wc_qd_p.'views/report_tbl_content.php');
$i++;
}
require(wc_qd_p.'views/report_tbl_footer.php');
}*/
/**
* Gets Order Details
* @param INT $id Order Post ID
* @returns [[Type]] [[Description]]
*/
private function get_order_info($id){
global $wc_quick_donation;
$return_details = array();
$order = new WC_Order($id);
$items = $order->get_items();
$order_details = $order->post;
foreach($items as $item){
if($wc_quick_donation->donation_id == $item['product_id']){
$return_details['amount'] = floatval($item['item_meta']['_line_total'][0]);
}
}
$return_details['ID'] = $order_details->ID;
$return_details['by_user'] = $order->user_id;
$return_details['date_gmt'] = $order_details->post_date_gmt;
$return_details['date'] = $order_details->post_date;
$return_details['address'] = $order->get_formatted_billing_address();
unset($order);
return $return_details;
}
/**
* Gets Order Meta Data Like pay_method, currency
* @param [[Type]] $id [[Description]]
* @since 1.0
*/
private function get_order_meta($id){
$return_details = array();
$meta = get_post_meta($id);
$return_details['currency'] = $meta['_order_currency'][0];
$return_details['pay_method'] = $meta['_payment_method'][0];
$return_details['pay_method_title'] = $meta['_payment_method_title'][0];
$return_details['order_amount'] = $meta['_order_total'][0];
#$return_details['project_details'] = $meta['project_details'];
#$return_details['is_donation'] = $meta['is_donation'];
unset($meta);
return $return_details;
}
/**
* Gets User Info By User ID
* @param USERID $id
* @returns Array User INFO
* @since 1.0
*/
private function get_user_info($id){
$return_details = array();
$user = get_user_by('id',$id);
$userM = get_user_meta($id);
$return_details['uname'] = $user->data->user_login;
$return_details['email'] = $user->data->user_email;
$return_details['dname'] = $user->data->display_name;
$return_details['nickname'] = $userM['nickname'][0];
$return_details['fname'] = $userM['first_name'][0];
$return_details['lname'] = $userM['last_name'][0];
unset($user,$userM);
return $return_details;
}
}
new wc_quick_donation_report;
?>
\ No newline at end of file
<?php
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
/**
* A custom Expedited Order WooCommerce Email class
*
* @since 0.1
* @extends \WC_Email
*/
class wc_quick_donation_completed_donation_email extends WC_Email {
/**
* Set email defaults
*
* @since 0.1
*/
public function __construct() {
$this->project_name = '';
$this->id = 'wc_quick_donation_completed_donation_email';
$this->title = 'Donation completed';
$this->description = 'Email Sent When New Donation Is Placed';
$this->subject = 'Thank you for your donation {project_name}';
$this->heading = 'Thank you for your donation {project_name}';
$this->template_base = wc_qd_p.'template/';
$this->template_html = 'donation_completed_html.php';
$this->template_plain = 'donation_completed_plain.php';
// Trigger on new paid orders
add_action( 'woocommerce_order_status_completed_notification', array( $this, 'trigger' ) );
parent::__construct();
}
/**
* Determine if the email should actually be sent and setup email merge variables
*
* @since 0.1
* @param int $order_id
*/
public function trigger( $order_id ) {
if ( ! $order_id )
return;
$this->project_name = get_post_meta($order_id, 'project_details', true );
$order = new WC_Order( $order_id );
$this->object = $order;
$this->recipient = $this->object->billing_email;
$products_in_order = array();
foreach ( $order->get_items() as $item ) {
foreach($item['item_meta']['_product_id'] as $id){ $products_in_order[] = $id; }
}
if(in_array(get_option('wc_quick_donation_product_id'),$products_in_order)){
$this->find[] = '{order_date}';
$this->replace[] = date_i18n( woocommerce_date_format(), strtotime( $this->object->order_date ) );
$this->find[] = '{project_name}';
$this->replace[] = get_post_meta($order_id, 'project_details', true );
$this->find[] = '{order_number}';
$this->replace[] = $this->object->get_order_number();
if ( ! $this->is_enabled())
return;
$this->send( $this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() );
}
}
/**
* Initialize Settings Form Fields
*
* @since 0.1
*/
public function init_form_fields() {
$this->form_fields = array(
'enabled' => array(
'title' => 'Enable/Disable',
'type' => 'checkbox',
'label' => 'Enable this email notification',
'default' => 'yes'
),
'subject' => array(
'title' => 'Subject',
'type' => 'text',
'description' => sprintf( 'This controls the email subject line. Leave blank to use the default subject: <code>%s</code>.', $this->subject ),
'placeholder' => '',
'default' => ''
),
'heading' => array(
'title' => 'Email Heading',
'type' => 'text',
'description' => sprintf( __( 'This controls the main heading contained within the email notification. Leave blank to use the default heading: <code>%s</code>.' ), $this->heading ),
'placeholder' => '',
'default' => ''
),
'email_type' => array(
'title' => 'Email type',
'type' => 'select',
'description' => 'Choose which format of email to send.',
'default' => 'html',
'class' => 'email_type',
'options' => array(
'plain' => 'Plain text',
'html' => 'HTML',
'multipart' => 'Multipart'
)
)
);
}
/**
* get_content_html function.
*
* @since 0.1
* @return string
*/
public function get_content_html() {
ob_start();
woocommerce_get_template($this->template_html,array('project_name'=>$this->project_name,'order' => $this->object, 'email_heading' => $this->get_heading()),'',$this->template_base);
return ob_get_clean();
}
/**
* get_content_plain function.
*
* @since 0.1
* @return string
*/
public function get_content_plain() {
ob_start();
woocommerce_get_template($this->template_plain,array('project_name'=>$this->project_name,'order' => $this->object, 'email_heading' => $this->get_heading()),'',$this->template_base);
return ob_get_clean();
}
}
<?php
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
/**
* A custom Expedited Order WooCommerce Email class
*
* @since 0.1
* @extends \WC_Email
*/
class wc_quick_donation_processing_donation_email extends WC_Email {
/**
* Set email defaults
*
* @since 0.1
*/
public function __construct() {
$this->project_name = '';
$this->id = 'wc_quick_donation_processing_donation_email_processing';
$this->title = 'Donation Processing';
$this->description = 'Email Sent When New Donation Is Placed';
$this->subject = 'Thank you for your donation {project_name}';
$this->heading = 'Thank you for your donation {project_name}';
$this->template_base = wc_qd_p.'template/';
$this->template_html = 'donation_processing_html.php';
$this->template_plain = 'donation_processing_plain.php';
// Trigger on new paid orders
add_action( 'woocommerce_order_status_pending_to_processing_notification', array( $this, 'trigger' ) );
add_action( 'woocommerce_order_status_pending_to_on-hold_notification', array( $this, 'trigger' ) );
parent::__construct();
}
/**
* Determine if the email should actually be sent and setup email merge variables
*
* @since 0.1
* @param int $order_id
*/
public function trigger( $order_id ) {
if ( ! $order_id )
return;
$this->project_name = get_post_meta($order_id, 'project_details', true );
$order = new WC_Order( $order_id );
$this->object = $order;
$this->recipient = $this->object->billing_email;
$products_in_order = array();
foreach ( $order->get_items() as $item ) {
foreach($item['item_meta']['_product_id'] as $id){ $products_in_order[] = $id; }
}
if(in_array(get_option('wc_quick_donation_product_id'),$products_in_order)){
$this->find[] = '{order_date}';
$this->replace[] = date_i18n( woocommerce_date_format(), strtotime( $this->object->order_date ) );
$this->find[] = '{project_name}';
$this->replace[] = $this->project;
$this->find[] = '{order_number}';
$this->replace[] = $this->object->get_order_number();
if ( ! $this->is_enabled())
return;
$this->send( $this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() );
}
}
/**
* Initialize Settings Form Fields
*
* @since 0.1
*/
public function init_form_fields() {
$this->form_fields = array(
'enabled' => array(
'title' => 'Enable/Disable',
'type' => 'checkbox',
'label' => 'Enable this email notification',
'default' => 'yes'
),
'subject' => array(
'title' => 'Subject',
'type' => 'text',
'description' => sprintf( 'This controls the email subject line. Leave blank to use the default subject: <code>%s</code>.', $this->subject ),
'placeholder' => '',
'default' => ''
),
'heading' => array(
'title' => 'Email Heading',
'type' => 'text',
'description' => sprintf( __( 'This controls the main heading contained within the email notification. Leave blank to use the default heading: <code>%s</code>.' ), $this->heading ),
'placeholder' => '',
'default' => ''
),
'email_type' => array(
'title' => 'Email type',
'type' => 'select',
'description' => 'Choose which format of email to send.',
'default' => 'html',
'class' => 'email_type',
'options' => array(
'plain' => 'Plain text',
'html' => 'HTML',
'multipart' => 'Multipart'
)
)
);
}
/**
* get_content_html function.
*
* @since 0.1
* @return string
*/
public function get_content_html() {
ob_start();
woocommerce_get_template($this->template_html,array('project_name'=>$this->project_name,'order' => $this->object, 'email_heading' => $this->get_heading()),'',$this->template_base);
return ob_get_clean();
}
/**
* get_content_plain function.
*
* @since 0.1
* @return string
*/
public function get_content_plain() {
ob_start();
woocommerce_get_template($this->template_plain,array('project_name'=>$this->project_name,'order' => $this->object, 'email_heading' => $this->get_heading()),'',$this->template_base);
return ob_get_clean();
}
}
<?php
class WC_Quick_Donation_Settings extends WC_Settings_Page {
/**
* Constructor
*/
public function __construct() {
$this->id = 'wc_quick_donation';
add_filter( 'woocommerce_settings_tabs_array', array( $this, 'add_settings_tab' ), 50 );
add_action( 'woocommerce_sections_' . $this->id, array( $this, 'output_sections' ) );
add_action( 'woocommerce_settings_' . $this->id, array( $this, 'output' ) );
add_action( 'woocommerce_settings_save_' . $this->id, array( $this, 'save' ) );
}
/**
* Add plugin options tab
*
* @return array
*/
public function add_settings_tab( $settings_tabs ) {
$settings_tabs[$this->id] = 'WC Quick Donation';
return $settings_tabs;
}
/**
* Get sections
*
* @return array
*/
public function get_sections() {
$sections = array(
'general' => __( 'General Settings', $this->id ),
'donation' => __( 'Donation Settings', $this->id ),
'message' => __( 'Message Settings', $this->id )
);
return apply_filters( 'woocommerce_get_sections_' . $this->id, $sections );
}
/**
* Get sections
*
* @return array
*/
public function get_settings( $section = null ) {
global $wc_quick_donation;
$width = "width:50% !important;";
switch( $section ){
case 'general' :
case '' :
$settings = array(
'section_title' => array(
'name' => 'Woocommerce Quick Donation Settings',
'type' => 'title',
'desc' => 'Just Call <code><strong>[wc_quick_donation]</strong></code> short code any where in your page,post,widgets or template <br/>
To Customize the <strong>Donation Form</strong> copy the template file from <code>woocommerce-quick-donation/template/donation_form.php</code> to your <code>theme/woocommerce</code> folder.
',
'id' => 'wc_quick_donation_general_start'
),
'remove_cart_items' => array(
'name' => 'Auto Remove Cart Items',
'desc' => 'Removes Other Cart Items If Donation Aded To Cart.',
'id' => 'wc_quick_donation_cart_remove',
'type' => 'select',
'class' =>'chosen_select',
'css' => $width,
'options' => array('false' => 'Keep All Items','true'=>'Remove All Items')
),
'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(
'name' => 'Redirect User To',
'desc' => 'After Donation Added To Cart.',
'id' => 'wc_quick_donation_redirect',
'type' => 'select',
'class' =>'chosen_select',
'css' => $width,
'options' => array('checkout' => 'Checkout Page','cart'=>'Cart Page','false' => 'None')
),
'payment_gateway' => array(
'name' => 'Allowed Payment Gateway\'s',
'desc' => 'Select Payment Gateway for donation..',
'id' => 'wc_quick_donation_payment_gateway',
'type' => 'multiselect',
'class' =>'chosen_select',
'css' => $width,
'options' => $wc_quick_donation->get_payments_gateway()
),
'section_end' => array(
'type' => 'sectionend',
'id' => 'wc_quick_donation_general_end'
)
);
break;
case 'donation' :
$settings = array(
'section_title' => array(
'name' => 'Donation Releated Settings',
'type' => 'title',
'desc' => '',
'id' => 'wc_quick_donation_donation_start'
),
'project_names' => array(
'name' => 'Project Names',
'type' => 'textarea',
'desc_tip' => 'Add Names By <code>,</code> Seperated ',
'css' => 'width:50%; height: 105px;',
'std' => '', // for woocommerce < 2.0
'id' => 'wc_quick_donation_projects',
'default' => 'Project1,Project2' // for woocommerce >= 2.0
),
'min_required_donation' => array(
'name' => 'Minium Required Amount',
'type' => 'text',
'desc' => 'Minium Required Amount For Donation. Enter Only Numerical Eg : 100',
'id' => 'wc_quick_donation_min_required_donation',
'default' =>'50'
),
'max_required_donation' => array(
'name' => 'Maximum Allowed Amount',
'type' => 'text',
'desc' => 'Maximum Allowed Amount For Donation. Enter Only Numerical Eg : 1000',
'id' => 'wc_quick_donation_max_required_donation',
'default' =>'1000'
),
'order_project_title' => array(
'name' => 'Order Project Title',
'type' => 'text',
'desc_tip' => 'Title to view in order edit page',
'css' => $width,
'id' => 'wc_quick_donation_project_section_title',
'default' =>'For Project'
),
'order_notes_title' => array(
'name' => 'Order Notes Title',
'type' => 'text',
'desc_tip' => 'to display project name use <code>Project Name : %s</code>',
'id' => 'wc_quick_donation_order_notes_title',
'css' => $width,
'default' =>'Project Name %s'
),
'section_end' => array(
'type' => 'sectionend',
'id' => 'wc_quick_donation_donation_end'
)
);
break;
case 'message' :
$settings = array(
'section_title' => array(
'name' => 'Plugin Message Text',
'type' => 'title',
'desc' => '',
'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(
'name' => 'Invalid / No Project Selected',
'type' => 'textarea',
'desc_tip' => 'Message Displayed When No Project Is Selected | HTML Tags Allowed',
'css' => 'width:75%; height:75px;',
'id' => 'wc_quick_donation_msg_project_invalid',
'default' =>'<h2> No Project Selected </h2>'
),
'donation_amount_empty_message' => array(
'name' => 'Empty Donation Amount',
'type' => 'textarea',
'desc_tip' => 'Message Displayed When No Donation Entered | HTML Tags Allowed',
'css' => 'width:75%; height:75px;',
'id' => 'wc_quick_donation_msg_amount_empty',
'default' =>'<h2> Please Enter A Donation Amount </h2>'
),
'donation_amount_invalid_message' => array(
'name' => 'Invalid Donation Amount',
'type' => 'textarea',
'desc_tip' => 'Message Displayed When Invalid Donation Entered | HTML Tags Allowed',
'desc' => 'Add <code>{donation_amount}</code> For Entered Donation Amount',
'css' => 'width:75%; height:75px;',
'id' => 'wc_quick_donation_msg_amount_invalid',
'default' =>'<h2> Invalid Donation Amount [{donation_amount}] </h2>'
),
'donation_min_required' => array(
'name' => 'Minium Required Donation Amount',
'type' => 'textarea',
'desc_tip' => 'Message Displayed When Donation Amount Is Less than required amount | HTML Tags Allowed',
'desc' => 'Add <code>{donation_amount}</code> For Entered Donation Amount And Add <code>{min_amount}</code> For Minium Required Amount ',
'css' => 'width:75%; height:75px;',
'id' => 'wc_quick_donation_msg_amount_min_required',
'default' =>'<h2> Minium Required is {min_amount} And you have entered is {donation_amount} </h2>'
),
'donation_max_allowed' => array(
'name' => 'Maximum Allowed Donation Amount',
'type' => 'textarea',
'desc_tip' => 'Message Displayed When Donation Amount Is Greater than allowed amount | HTML Tags Allowed',
'desc' => 'Add <code>{donation_amount}</code> For Entered Donation Amount And Add <code>{max_amount}</code> For Maximum Allowed Amount ',
'css' => 'width:75%; height:75px;',
'id' => 'wc_quick_donation_msg_amount_max_allowed',
'default' =>'<h2> Maximum Allowed Is {max_amount} And you have entered is {donation_amount} </h2>'
),
'section_end' => array(
'type' => 'sectionend',
'id' => 'wc_quick_donation_message_end'
)
);
break;
}
return apply_filters( 'wc_settings_tab_'.$this->id.'_settings', $settings, $section );
}
/**
* Output the settings
*/
public function output() {
global $current_section;
$settings = $this->get_settings( $current_section );
WC_Admin_Settings::output_fields( $settings );
}
/**
* Save settings
*/
public function save() {
global $current_section;
$settings = $this->get_settings( $current_section );
WC_Admin_Settings::save_fields( $settings );
}
}
return new WC_Quick_Donation_Settings();
?>
\ No newline at end of file
<?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
<?php
/**
* Posts List Table class.
*
* @package WordPress
* @subpackage List_Table
* @since 3.1.0
* @access private
*/
class WC_Quick_Donation_Listing_Table extends WP_List_Table {
protected $hierarchical_display;
protected $comment_pending_count;
private $user_posts_count;
private $sticky_posts_count = 0;
private $post_query;
public function __construct($query) {
global $post_type_object, $wpdb;
parent::__construct( array(
'plural' => 'posts',
'screen' => get_current_screen(),
) );
$this->screen->post_type = 'shop_order';
$post_type = $this->screen->post_type;
$post_type_object = get_post_type_object( $post_type );
$this->user_posts_count = 0;
$this->sticky_posts_count = 0;
$this->post_query = $query;
}
public function ajax_user_can() {
return current_user_can( get_post_type_object( $this->screen->post_type )->cap->edit_posts );
}
public function prepare_items() {
global $avail_post_stati, $per_page, $mode;
$avail_post_stati = wp_edit_posts_query();
$this->hierarchical_display = ( is_post_type_hierarchical( $this->screen->post_type ) && 'menu_order title' == $this->post_query->query['orderby'] );
$total_items = $this->hierarchical_display ? $this->post_query->post_count : $this->post_query->found_posts;
$post_type = $this->screen->post_type;
$per_page = $this->get_items_per_page( 'edit_' . $post_type . '_per_page' );
/** This filter is documented in wp-admin/includes/post.php */
$per_page = apply_filters( 'edit_posts_per_page', $per_page, $post_type );
if ( $this->hierarchical_display )
$total_pages = ceil( $total_items / $per_page );
else
$total_pages = $this->post_query->max_num_pages;
if ( ! empty( $_REQUEST['mode'] ) ) {
$mode = $_REQUEST['mode'] == 'excerpt' ? 'excerpt' : 'list';
set_user_setting ( 'posts_list_mode', $mode );
} else {
$mode = get_user_setting ( 'posts_list_mode', 'list' );
}
$columns = $this->get_columns();
$hidden = array();
$sortable = $this->get_sortable_columns();
$this->_column_headers = array($columns, $hidden, $sortable);
$this->is_trash = isset( $_REQUEST['post_status'] ) && $_REQUEST['post_status'] == 'trash';
$this->set_pagination_args( array(
'total_items' => $total_items,
'total_pages' => $total_pages,
'per_page' => $per_page
) );
}
public function has_items() {
return have_posts();
}
public function no_items() {
if ( isset( $_REQUEST['post_status'] ) && 'trash' == $_REQUEST['post_status'] )
echo get_post_type_object( $this->screen->post_type )->labels->not_found_in_trash;
else
echo get_post_type_object( $this->screen->post_type )->labels->not_found;
}
protected function get_views() {
global $locked_post_status, $avail_post_stati;
$post_type = $this->screen->post_type;
if ( !empty($locked_post_status) )
return array();
$status_links = array();
$num_posts = wp_count_posts( $post_type, 'readable' );
$class = '';
$allposts = '';
$current_user_id = get_current_user_id();
if ( $this->user_posts_count ) {
if ( isset( $_GET['author'] ) && ( $_GET['author'] == $current_user_id ) )
$class = ' class="current"';
$status_links['mine'] = "<a href='edit.php?post_type=$post_type&author=$current_user_id'$class>" . sprintf( _nx( 'Mine <span class="count">(%s)</span>', 'Mine <span class="count">(%s)</span>', $this->user_posts_count, 'posts' ), number_format_i18n( $this->user_posts_count ) ) . '</a>';
$allposts = '&all_posts=1';
}
$total_posts = array_sum( (array) $num_posts );
// Subtract post types that are not included in the admin all list.
foreach ( get_post_stati( array('show_in_admin_all_list' => false) ) as $state )
$total_posts -= $num_posts->$state;
$class = empty( $class ) && empty( $_REQUEST['post_status'] ) && empty( $_REQUEST['show_sticky'] ) ? ' class="current"' : '';
$status_links['all'] = "<a href='edit.php?post_type=$post_type{$allposts}'$class>" . sprintf( _nx( 'All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $total_posts, 'posts' ), number_format_i18n( $total_posts ) ) . '</a>';
foreach ( get_post_stati(array('show_in_admin_status_list' => true), 'objects') as $status ) {
$class = '';
$status_name = $status->name;
if ( !in_array( $status_name, $avail_post_stati ) )
continue;
if ( empty( $num_posts->$status_name ) )
continue;
if ( isset($_REQUEST['post_status']) && $status_name == $_REQUEST['post_status'] )
$class = ' class="current"';
$status_links[$status_name] = "<a href='edit.php?post_status=$status_name&amp;post_type=$post_type'$class>" . sprintf( translate_nooped_plural( $status->label_count, $num_posts->$status_name ), number_format_i18n( $num_posts->$status_name ) ) . '</a>';
}
if ( ! empty( $this->sticky_posts_count ) ) {
$class = ! empty( $_REQUEST['show_sticky'] ) ? ' class="current"' : '';
$sticky_link = array( 'sticky' => "<a href='edit.php?post_type=$post_type&amp;show_sticky=1'$class>" . sprintf( _nx( 'Sticky <span class="count">(%s)</span>', 'Sticky <span class="count">(%s)</span>', $this->sticky_posts_count, 'posts' ), number_format_i18n( $this->sticky_posts_count ) ) . '</a>' );
// Sticky comes after Publish, or if not listed, after All.
$split = 1 + array_search( ( isset( $status_links['publish'] ) ? 'publish' : 'all' ), array_keys( $status_links ) );
$status_links = array_merge( array_slice( $status_links, 0, $split ), $sticky_link, array_slice( $status_links, $split ) );
}
return $status_links;
}
protected function get_bulk_actions() {
$actions = array();
$post_type_obj = get_post_type_object( $this->screen->post_type );
if ( $this->is_trash ) {
$actions['untrash'] = __( 'Restore' );
} else {
$actions['edit'] = __( 'Edit' );
}
if ( current_user_can( $post_type_obj->cap->delete_posts ) ) {
if ( $this->is_trash || ! EMPTY_TRASH_DAYS ) {
$actions['delete'] = __( 'Delete Permanently' );
} else {
$actions['trash'] = __( 'Move to Trash' );
}
}
return $actions;
}
/**
* @global int $cat
* @param string $which
*/
protected function extra_tablenav( $which ) {
global $cat;
?>
<div class="alignleft actions">
<?php
if ( 'top' == $which && !is_singular() ) {
$this->months_dropdown( $this->screen->post_type );
if ( is_object_in_taxonomy( $this->screen->post_type, 'category' ) ) {
$dropdown_options = array(
'show_option_all' => __( 'All categories' ),
'hide_empty' => 0,
'hierarchical' => 1,
'show_count' => 0,
'orderby' => 'name',
'selected' => $cat
);
echo '<label class="screen-reader-text" for="cat">' . __( 'Filter by category' ) . '</label>';
wp_dropdown_categories( $dropdown_options );
}
/**
* Fires before the Filter button on the Posts and Pages list tables.
*
* The Filter button allows sorting by date and/or category on the
* Posts list table, and sorting by date on the Pages list table.
*
* @since 2.1.0
*/
do_action( 'restrict_manage_posts' );
submit_button( __( 'Filter' ), 'button', 'filter_action', false, array( 'id' => 'post-query-submit' ) );
}
if ( $this->is_trash && current_user_can( get_post_type_object( $this->screen->post_type )->cap->edit_others_posts ) ) {
submit_button( __( 'Empty Trash' ), 'apply', 'delete_all', false );
}
?>
</div>
<?php
}
public function current_action() {
if ( isset( $_REQUEST['delete_all'] ) || isset( $_REQUEST['delete_all2'] ) )
return 'delete_all';
return parent::current_action();
}
/**
* @global string $mode
* @param string $which
*/
protected function pagination( $which ) {
global $mode;
parent::pagination( $which );
if ( 'top' == $which && ! is_post_type_hierarchical( $this->screen->post_type ) )
$this->view_switcher( $mode );
}
protected function get_table_classes() {
return array( 'widefat', 'fixed', is_post_type_hierarchical( $this->screen->post_type ) ? 'pages' : 'posts' );
}
public function get_columns() {
$post_type = $this->screen->post_type;
$posts_columns = array();
$posts_columns['cb'] = '<input type="checkbox" />';
/* translators: manage posts column name */
$posts_columns['title'] = _x( 'Title', 'column name' );
if ( post_type_supports( $post_type, 'author' ) ) {
$posts_columns['author'] = __( 'Author' );
}
$taxonomies = get_object_taxonomies( $post_type, 'objects' );
$taxonomies = wp_filter_object_list( $taxonomies, array( 'show_admin_column' => true ), 'and', 'name' );
/**
* Filter the taxonomy columns in the Posts list table.
*
* The dynamic portion of the hook name, `$post_type`, refers to the post
* type slug.
*
* @since 3.5.0
*
* @param array $taxonomies Array of taxonomies to show columns for.
* @param string $post_type The post type.
*/
$taxonomies = apply_filters( "manage_taxonomies_for_{$post_type}_columns", $taxonomies, $post_type );
$taxonomies = array_filter( $taxonomies, 'taxonomy_exists' );
foreach ( $taxonomies as $taxonomy ) {
if ( 'category' == $taxonomy )
$column_key = 'categories';
elseif ( 'post_tag' == $taxonomy )
$column_key = 'tags';
else
$column_key = 'taxonomy-' . $taxonomy;
$posts_columns[ $column_key ] = get_taxonomy( $taxonomy )->labels->name;
}
$post_status = !empty( $_REQUEST['post_status'] ) ? $_REQUEST['post_status'] : 'all';
if ( post_type_supports( $post_type, 'comments' ) && !in_array( $post_status, array( 'pending', 'draft', 'future' ) ) )
$posts_columns['comments'] = '<span class="vers"><span title="' . esc_attr__( 'Comments' ) . '" class="comment-grey-bubble"></span></span>';
$posts_columns['date'] = __( 'Date' );
if ( 'page' == $post_type ) {
/**
* Filter the columns displayed in the Pages list table.
*
* @since 2.5.0
*
* @param array $post_columns An array of column names.
*/
$posts_columns = apply_filters( 'manage_pages_columns', $posts_columns );
} else {
/**
* Filter the columns displayed in the Posts list table.
*
* @since 1.5.0
*
* @param array $posts_columns An array of column names.
* @param string $post_type The post type slug.
*/
$posts_columns = apply_filters( 'manage_posts_columns', $posts_columns, $post_type );
}
/**
* Filter the columns displayed in the Posts list table for a specific post type.
*
* The dynamic portion of the hook name, `$post_type`, refers to the post type slug.
*
* @since 3.0.0
*
* @param array $post_columns An array of column names.
*/
$posts_columns = apply_filters( "manage_{$post_type}_posts_columns", $posts_columns );
return $posts_columns;
}
protected function get_sortable_columns() {
return array(
'title' => 'title',
'parent' => 'parent',
'comments' => 'comment_count',
'date' => array( 'date', true )
);
}
/**
* @global WP_Query $wp_query
* @global int $per_page
* @param array $posts
* @param int $level
*/
public function display_rows( $posts = array(), $level = 0 ) {
global $wp_query, $per_page;
if ( empty( $posts ) )
$posts = $this->post_query->posts;
add_filter( 'the_title', 'esc_html' );
if ( $this->hierarchical_display ) {
$this->_display_rows_hierarchical( $posts, $this->get_pagenum(), $per_page );
} else {
$this->_display_rows( $posts, $level );
}
}
/**
* @global string $mode
* @param array $posts
* @param int $level
*/
private function _display_rows( $posts, $level = 0 ) {
global $mode;
// Create array of post IDs.
$post_ids = array();
foreach ( $posts as $a_post )
$post_ids[] = $a_post->ID;
$this->comment_pending_count = get_pending_comments_num( $post_ids );
foreach ( $posts as $post )
$this->single_row( $post, $level );
}
/**
* @global wpdb $wpdb
* @param array $pages
* @param int $pagenum
* @param int $per_page
* @return bool|null
*/
private function _display_rows_hierarchical( $pages, $pagenum = 1, $per_page = 20 ) {
global $wpdb;
$level = 0;
if ( ! $pages ) {
$pages = get_pages( array( 'sort_column' => 'menu_order' ) );
if ( ! $pages )
return false;
}
/*
* Arrange pages into two parts: top level pages and children_pages
* children_pages is two dimensional array, eg.
* children_pages[10][] contains all sub-pages whose parent is 10.
* It only takes O( N ) to arrange this and it takes O( 1 ) for subsequent lookup operations
* If searching, ignore hierarchy and treat everything as top level
*/
if ( empty( $_REQUEST['s'] ) ) {
$top_level_pages = array();
$children_pages = array();
foreach ( $pages as $page ) {
// Catch and repair bad pages.
if ( $page->post_parent == $page->ID ) {
$page->post_parent = 0;
$this->post_query->update( $this->post_query->posts, array( 'post_parent' => 0 ), array( 'ID' => $page->ID ) );
clean_post_cache( $page );
}
if ( 0 == $page->post_parent )
$top_level_pages[] = $page;
else
$children_pages[ $page->post_parent ][] = $page;
}
$pages = &$top_level_pages;
}
$count = 0;
$start = ( $pagenum - 1 ) * $per_page;
$end = $start + $per_page;
foreach ( $pages as $page ) {
if ( $count >= $end )
break;
if ( $count >= $start ) {
echo "\t";
$this->single_row( $page, $level );
}
$count++;
if ( isset( $children_pages ) )
$this->_page_rows( $children_pages, $count, $page->ID, $level + 1, $pagenum, $per_page );
}
// If it is the last pagenum and there are orphaned pages, display them with paging as well.
if ( isset( $children_pages ) && $count < $end ){
foreach ( $children_pages as $orphans ){
foreach ( $orphans as $op ) {
if ( $count >= $end )
break;
if ( $count >= $start ) {
echo "\t";
$this->single_row( $op, 0 );
}
$count++;
}
}
}
}
/**
* Given a top level page ID, display the nested hierarchy of sub-pages
* together with paging support
*
* @since 3.1.0 (Standalone function exists since 2.6.0)
*
* @param array $children_pages
* @param int $count
* @param int $parent
* @param int $level
* @param int $pagenum
* @param int $per_page
*/
private function _page_rows( &$children_pages, &$count, $parent, $level, $pagenum, $per_page ) {
if ( ! isset( $children_pages[$parent] ) )
return;
$start = ( $pagenum - 1 ) * $per_page;
$end = $start + $per_page;
foreach ( $children_pages[$parent] as $page ) {
if ( $count >= $end )
break;
// If the page starts in a subtree, print the parents.
if ( $count == $start && $page->post_parent > 0 ) {
$my_parents = array();
$my_parent = $page->post_parent;
while ( $my_parent ) {
$my_parent = get_post( $my_parent );
$my_parents[] = $my_parent;
if ( !$my_parent->post_parent )
break;
$my_parent = $my_parent->post_parent;
}
$num_parents = count( $my_parents );
while ( $my_parent = array_pop( $my_parents ) ) {
echo "\t";
$this->single_row( $my_parent, $level - $num_parents );
$num_parents--;
}
}
if ( $count >= $start ) {
echo "\t";
$this->single_row( $page, $level );
}
$count++;
$this->_page_rows( $children_pages, $count, $page->ID, $level + 1, $pagenum, $per_page );
}
unset( $children_pages[$parent] ); //required in order to keep track of orphans
}
/**
* @global string $mode
* @staticvar string $alternate
* @param WP_Post $post
* @param int $level
*/
public function single_row( $post, $level = 0 ) {
global $mode;
static $alternate;
$global_post = get_post();
$GLOBALS['post'] = $post;
setup_postdata( $post );
$edit_link = get_edit_post_link( $post->ID );
$title = _draft_or_post_title();
$post_type_object = get_post_type_object( $post->post_type );
$can_edit_post = current_user_can( 'edit_post', $post->ID );
$alternate = 'alternate' == $alternate ? '' : 'alternate';
$classes = $alternate . ' iedit author-' . ( get_current_user_id() == $post->post_author ? 'self' : 'other' );
$lock_holder = wp_check_post_lock( $post->ID );
if ( $lock_holder ) {
$classes .= ' wp-locked';
$lock_holder = get_userdata( $lock_holder );
}
if ( $post->post_parent ) {
$count = count( get_post_ancestors( $post->ID ) );
$classes .= ' level-'. $count;
} else {
$classes .= ' level-0';
}
?>
<tr id="post-<?php echo $post->ID; ?>" class="<?php echo implode( ' ', get_post_class( $classes, $post->ID ) ); ?>">
<?php
list( $columns, $hidden ) = $this->get_column_info();
foreach ( $columns as $column_name => $column_display_name ) {
$class = "class=\"$column_name column-$column_name\"";
$style = '';
if ( in_array( $column_name, $hidden ) )
$style = ' style="display:none;"';
$attributes = "$class$style";
switch ( $column_name ) {
case 'cb':
?>
<th scope="row" class="check-column">
<?php
if ( $can_edit_post ) {
?>
<label class="screen-reader-text" for="cb-select-<?php the_ID(); ?>"><?php printf( __( 'Select %s' ), $title ); ?></label>
<input id="cb-select-<?php the_ID(); ?>" type="checkbox" name="post[]" value="<?php the_ID(); ?>" />
<div class="locked-indicator"></div>
<?php
}
?>
</th>
<?php
break;
case 'title':
$attributes = 'class="post-title page-title column-title"' . $style;
if ( $this->hierarchical_display ) {
if ( 0 == $level && (int) $post->post_parent > 0 ) {
// Sent level 0 by accident, by default, or because we don't know the actual level.
$find_main_page = (int) $post->post_parent;
while ( $find_main_page > 0 ) {
$parent = get_post( $find_main_page );
if ( is_null( $parent ) )
break;
$level++;
$find_main_page = (int) $parent->post_parent;
if ( !isset( $parent_name ) ) {
/** This filter is documented in wp-includes/post-template.php */
$parent_name = apply_filters( 'the_title', $parent->post_title, $parent->ID );
}
}
}
}
$pad = str_repeat( '&#8212; ', $level );
echo "<td $attributes><strong>";
if ( $format = get_post_format( $post->ID ) ) {
$label = get_post_format_string( $format );
echo '<a href="' . esc_url( add_query_arg( array( 'post_format' => $format, 'post_type' => $post->post_type ), 'edit.php' ) ) . '" class="post-state-format post-format-icon post-format-' . $format . '" title="' . $label . '">' . $label . ":</a> ";
}
if ( $can_edit_post && $post->post_status != 'trash' ) {
echo '<a class="row-title" href="' . $edit_link . '" title="' . esc_attr( sprintf( __( 'Edit &#8220;%s&#8221;' ), $title ) ) . '">' . $pad . $title . '</a>';
} else {
echo $pad . $title;
}
_post_states( $post );
if ( isset( $parent_name ) )
echo ' | ' . $post_type_object->labels->parent_item_colon . ' ' . esc_html( $parent_name );
echo "</strong>\n";
if ( $can_edit_post && $post->post_status != 'trash' ) {
if ( $lock_holder ) {
$locked_avatar = get_avatar( $lock_holder->ID, 18 );
$locked_text = esc_html( sprintf( __( '%s is currently editing' ), $lock_holder->display_name ) );
} else {
$locked_avatar = $locked_text = '';
}
echo '<div class="locked-info"><span class="locked-avatar">' . $locked_avatar . '</span> <span class="locked-text">' . $locked_text . "</span></div>\n";
}
if ( ! $this->hierarchical_display && 'excerpt' == $mode && current_user_can( 'read_post', $post->ID ) )
the_excerpt();
$actions = array();
if ( $can_edit_post && 'trash' != $post->post_status ) {
$actions['edit'] = '<a href="' . get_edit_post_link( $post->ID, true ) . '" title="' . esc_attr__( 'Edit this item' ) . '">' . __( 'Edit' ) . '</a>';
$actions['inline hide-if-no-js'] = '<a href="#" class="editinline" title="' . esc_attr__( 'Edit this item inline' ) . '">' . __( 'Quick&nbsp;Edit' ) . '</a>';
}
if ( current_user_can( 'delete_post', $post->ID ) ) {
if ( 'trash' == $post->post_status )
$actions['untrash'] = "<a title='" . esc_attr__( 'Restore this item from the Trash' ) . "' href='" . wp_nonce_url( admin_url( sprintf( $post_type_object->_edit_link . '&amp;action=untrash', $post->ID ) ), 'untrash-post_' . $post->ID ) . "'>" . __( 'Restore' ) . "</a>";
elseif ( EMPTY_TRASH_DAYS )
$actions['trash'] = "<a class='submitdelete' title='" . esc_attr__( 'Move this item to the Trash' ) . "' href='" . get_delete_post_link( $post->ID ) . "'>" . __( 'Trash' ) . "</a>";
if ( 'trash' == $post->post_status || !EMPTY_TRASH_DAYS )
$actions['delete'] = "<a class='submitdelete' title='" . esc_attr__( 'Delete this item permanently' ) . "' href='" . get_delete_post_link( $post->ID, '', true ) . "'>" . __( 'Delete Permanently' ) . "</a>";
}
if ( $post_type_object->public ) {
if ( in_array( $post->post_status, array( 'pending', 'draft', 'future' ) ) ) {
if ( $can_edit_post ) {
$preview_link = set_url_scheme( get_permalink( $post->ID ) );
/** This filter is documented in wp-admin/includes/meta-boxes.php */
$preview_link = apply_filters( 'preview_post_link', add_query_arg( 'preview', 'true', $preview_link ), $post );
$actions['view'] = '<a href="' . esc_url( $preview_link ) . '" title="' . esc_attr( sprintf( __( 'Preview &#8220;%s&#8221;' ), $title ) ) . '" rel="permalink">' . __( 'Preview' ) . '</a>';
}
} elseif ( 'trash' != $post->post_status ) {
$actions['view'] = '<a href="' . get_permalink( $post->ID ) . '" title="' . esc_attr( sprintf( __( 'View &#8220;%s&#8221;' ), $title ) ) . '" rel="permalink">' . __( 'View' ) . '</a>';
}
}
if ( is_post_type_hierarchical( $post->post_type ) ) {
/**
* Filter the array of row action links on the Pages list table.
*
* The filter is evaluated only for hierarchical post types.
*
* @since 2.8.0
*
* @param array $actions An array of row action links. Defaults are
* 'Edit', 'Quick Edit', 'Restore, 'Trash',
* 'Delete Permanently', 'Preview', and 'View'.
* @param WP_Post $post The post object.
*/
$actions = apply_filters( 'page_row_actions', $actions, $post );
} else {
/**
* Filter the array of row action links on the Posts list table.
*
* The filter is evaluated only for non-hierarchical post types.
*
* @since 2.8.0
*
* @param array $actions An array of row action links. Defaults are
* 'Edit', 'Quick Edit', 'Restore, 'Trash',
* 'Delete Permanently', 'Preview', and 'View'.
* @param WP_Post $post The post object.
*/
$actions = apply_filters( 'post_row_actions', $actions, $post );
}
echo $this->row_actions( $actions );
get_inline_data( $post );
echo '</td>';
break;
case 'date':
if ( '0000-00-00 00:00:00' == $post->post_date ) {
$t_time = $h_time = __( 'Unpublished' );
$time_diff = 0;
} else {
$t_time = get_the_time( __( 'Y/m/d g:i:s A' ) );
$m_time = $post->post_date;
$time = get_post_time( 'G', true, $post );
$time_diff = time() - $time;
if ( $time_diff > 0 && $time_diff < DAY_IN_SECONDS )
$h_time = sprintf( __( '%s ago' ), human_time_diff( $time ) );
else
$h_time = mysql2date( __( 'Y/m/d' ), $m_time );
}
echo '<td ' . $attributes . '>';
if ( 'excerpt' == $mode ) {
/**
* Filter the published time of the post.
*
* If $mode equals 'excerpt', the published time and date are both displayed.
* If $mode equals 'list' (default), the publish date is displayed, with the
* time and date together available as an abbreviation definition.
*
* @since 2.5.1
*
* @param array $t_time The published time.
* @param WP_Post $post Post object.
* @param string $column_name The column name.
* @param string $mode The list display mode ('excerpt' or 'list').
*/
echo apply_filters( 'post_date_column_time', $t_time, $post, $column_name, $mode );
} else {
/** This filter is documented in wp-admin/includes/class-wp-posts-list-table.php */
echo '<abbr title="' . $t_time . '">' . apply_filters( 'post_date_column_time', $h_time, $post, $column_name, $mode ) . '</abbr>';
}
echo '<br />';
if ( 'publish' == $post->post_status ) {
_e( 'Published' );
} elseif ( 'future' == $post->post_status ) {
if ( $time_diff > 0 )
echo '<strong class="attention">' . __( 'Missed schedule' ) . '</strong>';
else
_e( 'Scheduled' );
} else {
_e( 'Last Modified' );
}
echo '</td>';
break;
case 'comments':
?>
<td <?php echo $attributes ?>><div class="post-com-count-wrapper">
<?php
$pending_comments = isset( $this->comment_pending_count[$post->ID] ) ? $this->comment_pending_count[$post->ID] : 0;
$this->comments_bubble( $post->ID, $pending_comments );
?>
</div></td>
<?php
break;
case 'author':
?>
<td <?php echo $attributes ?>><?php
printf( '<a href="%s">%s</a>',
esc_url( add_query_arg( array( 'post_type' => $post->post_type, 'author' => get_the_author_meta( 'ID' ) ), 'edit.php' )),
get_the_author()
);
?></td>
<?php
break;
default:
if ( 'categories' == $column_name )
$taxonomy = 'category';
elseif ( 'tags' == $column_name )
$taxonomy = 'post_tag';
elseif ( 0 === strpos( $column_name, 'taxonomy-' ) )
$taxonomy = substr( $column_name, 9 );
else
$taxonomy = false;
if ( $taxonomy ) {
$taxonomy_object = get_taxonomy( $taxonomy );
echo '<td ' . $attributes . '>';
if ( $terms = get_the_terms( $post->ID, $taxonomy ) ) {
$out = array();
foreach ( $terms as $t ) {
$posts_in_term_qv = array();
if ( 'post' != $post->post_type )
$posts_in_term_qv['post_type'] = $post->post_type;
if ( $taxonomy_object->query_var ) {
$posts_in_term_qv[ $taxonomy_object->query_var ] = $t->slug;
} else {
$posts_in_term_qv['taxonomy'] = $taxonomy;
$posts_in_term_qv['term'] = $t->slug;
}
$out[] = sprintf( '<a href="%s">%s</a>',
esc_url( add_query_arg( $posts_in_term_qv, 'edit.php' ) ),
esc_html( sanitize_term_field( 'name', $t->name, $t->term_id, $taxonomy, 'display' ) )
);
}
/* translators: used between list items, there is a space after the comma */
echo join( __( ', ' ), $out );
} else {
echo '&#8212;';
}
echo '</td>';
break;
}
?>
<td <?php echo $attributes ?>><?php
if ( is_post_type_hierarchical( $post->post_type ) ) {
/**
* Fires in each custom column on the Posts list table.
*
* This hook only fires if the current post type is hierarchical,
* such as pages.
*
* @since 2.5.0
*
* @param string $column_name The name of the column to display.
* @param int $post_id The current post ID.
*/
do_action( 'manage_pages_custom_column', $column_name, $post->ID );
} else {
/**
* Fires in each custom column in the Posts list table.
*
* This hook only fires if the current post type is non-hierarchical,
* such as posts.
*
* @since 1.5.0
*
* @param string $column_name The name of the column to display.
* @param int $post_id The current post ID.
*/
do_action( 'manage_posts_custom_column', $column_name, $post->ID );
}
/**
* Fires for each custom column of a specific post type in the Posts list table.
*
* The dynamic portion of the hook name, `$post->post_type`, refers to the post type.
*
* @since 3.1.0
*
* @param string $column_name The name of the column to display.
* @param int $post_id The current post ID.
*/
do_action( "manage_{$post->post_type}_posts_custom_column", $column_name, $post->ID );
?></td>
<?php
break;
}
}
?>
</tr>
<?php
$GLOBALS['post'] = $global_post;
}
/**
* Outputs the hidden row displayed when inline editing
*
* @since 3.1.0
*/
public function inline_edit() {
global $mode;
$screen = $this->screen;
$post = get_default_post_to_edit( $screen->post_type );
$post_type_object = get_post_type_object( $screen->post_type );
$taxonomy_names = get_object_taxonomies( $screen->post_type );
$hierarchical_taxonomies = array();
$flat_taxonomies = array();
foreach ( $taxonomy_names as $taxonomy_name ) {
$taxonomy = get_taxonomy( $taxonomy_name );
if ( !$taxonomy->show_ui )
continue;
if ( $taxonomy->hierarchical )
$hierarchical_taxonomies[] = $taxonomy;
else
$flat_taxonomies[] = $taxonomy;
}
$m = ( isset( $mode ) && 'excerpt' == $mode ) ? 'excerpt' : 'list';
$can_publish = current_user_can( $post_type_object->cap->publish_posts );
$core_columns = array( 'cb' => true, 'date' => true, 'title' => true, 'categories' => true, 'tags' => true, 'comments' => true, 'author' => true );
?>
<form method="get" action=""><table style="display: none"><tbody id="inlineedit">
<?php
$hclass = count( $hierarchical_taxonomies ) ? 'post' : 'page';
$bulk = 0;
while ( $bulk < 2 ) { ?>
<tr id="<?php echo $bulk ? 'bulk-edit' : 'inline-edit'; ?>" class="inline-edit-row inline-edit-row-<?php echo "$hclass inline-edit-" . $screen->post_type;
echo $bulk ? " bulk-edit-row bulk-edit-row-$hclass bulk-edit-{$screen->post_type}" : " quick-edit-row quick-edit-row-$hclass inline-edit-{$screen->post_type}";
?>" style="display: none"><td colspan="<?php echo $this->get_column_count(); ?>" class="colspanchange">
<fieldset class="inline-edit-col-left"><div class="inline-edit-col">
<h4><?php echo $bulk ? __( 'Bulk Edit' ) : __( 'Quick Edit' ); ?></h4>
<?php
if ( post_type_supports( $screen->post_type, 'title' ) ) :
if ( $bulk ) : ?>
<div id="bulk-title-div">
<div id="bulk-titles"></div>
</div>
<?php else : // $bulk ?>
<label>
<span class="title"><?php _e( 'Title' ); ?></span>
<span class="input-text-wrap"><input type="text" name="post_title" class="ptitle" value="" /></span>
</label>
<label>
<span class="title"><?php _e( 'Slug' ); ?></span>
<span class="input-text-wrap"><input type="text" name="post_name" value="" /></span>
</label>
<?php endif; // $bulk
endif; // post_type_supports title ?>
<?php if ( !$bulk ) : ?>
<label><span class="title"><?php _e( 'Date' ); ?></span></label>
<div class="inline-edit-date">
<?php touch_time( 1, 1, 0, 1 ); ?>
</div>
<br class="clear" />
<?php endif; // $bulk
if ( post_type_supports( $screen->post_type, 'author' ) ) :
$authors_dropdown = '';
if ( is_super_admin() || current_user_can( $post_type_object->cap->edit_others_posts ) ) :
$users_opt = array(
'hide_if_only_one_author' => false,
'who' => 'authors',
'name' => 'post_author',
'class'=> 'authors',
'multi' => 1,
'echo' => 0
);
if ( $bulk )
$users_opt['show_option_none'] = __( '&mdash; No Change &mdash;' );
if ( $authors = wp_dropdown_users( $users_opt ) ) :
$authors_dropdown = '<label class="inline-edit-author">';
$authors_dropdown .= '<span class="title">' . __( 'Author' ) . '</span>';
$authors_dropdown .= $authors;
$authors_dropdown .= '</label>';
endif;
endif; // authors
?>
<?php if ( !$bulk ) echo $authors_dropdown;
endif; // post_type_supports author
if ( !$bulk && $can_publish ) :
?>
<div class="inline-edit-group">
<label class="alignleft">
<span class="title"><?php _e( 'Password' ); ?></span>
<span class="input-text-wrap"><input type="text" name="post_password" class="inline-edit-password-input" value="" /></span>
</label>
<em style="margin:5px 10px 0 0" class="alignleft">
<?php
/* translators: Between password field and private checkbox on post quick edit interface */
echo __( '&ndash;OR&ndash;' );
?>
</em>
<label class="alignleft inline-edit-private">
<input type="checkbox" name="keep_private" value="private" />
<span class="checkbox-title"><?php echo __( 'Private' ); ?></span>
</label>
</div>
<?php endif; ?>
</div></fieldset>
<?php if ( count( $hierarchical_taxonomies ) && !$bulk ) : ?>
<fieldset class="inline-edit-col-center inline-edit-categories"><div class="inline-edit-col">
<?php foreach ( $hierarchical_taxonomies as $taxonomy ) : ?>
<span class="title inline-edit-categories-label"><?php echo esc_html( $taxonomy->labels->name ) ?></span>
<input type="hidden" name="<?php echo ( $taxonomy->name == 'category' ) ? 'post_category[]' : 'tax_input[' . esc_attr( $taxonomy->name ) . '][]'; ?>" value="0" />
<ul class="cat-checklist <?php echo esc_attr( $taxonomy->name )?>-checklist">
<?php wp_terms_checklist( null, array( 'taxonomy' => $taxonomy->name ) ) ?>
</ul>
<?php endforeach; //$hierarchical_taxonomies as $taxonomy ?>
</div></fieldset>
<?php endif; // count( $hierarchical_taxonomies ) && !$bulk ?>
<fieldset class="inline-edit-col-right"><div class="inline-edit-col">
<?php
if ( post_type_supports( $screen->post_type, 'author' ) && $bulk )
echo $authors_dropdown;
if ( post_type_supports( $screen->post_type, 'page-attributes' ) ) :
if ( $post_type_object->hierarchical ) :
?>
<label>
<span class="title"><?php _e( 'Parent' ); ?></span>
<?php
$dropdown_args = array(
'post_type' => $post_type_object->name,
'selected' => $post->post_parent,
'name' => 'post_parent',
'show_option_none' => __( 'Main Page (no parent)' ),
'option_none_value' => 0,
'sort_column' => 'menu_order, post_title',
);
if ( $bulk )
$dropdown_args['show_option_no_change'] = __( '&mdash; No Change &mdash;' );
/**
* Filter the arguments used to generate the Quick Edit page-parent drop-down.
*
* @since 2.7.0
*
* @see wp_dropdown_pages()
*
* @param array $dropdown_args An array of arguments.
*/
$dropdown_args = apply_filters( 'quick_edit_dropdown_pages_args', $dropdown_args );
wp_dropdown_pages( $dropdown_args );
?>
</label>
<?php
endif; // hierarchical
if ( !$bulk ) : ?>
<label>
<span class="title"><?php _e( 'Order' ); ?></span>
<span class="input-text-wrap"><input type="text" name="menu_order" class="inline-edit-menu-order-input" value="<?php echo $post->menu_order ?>" /></span>
</label>
<?php endif; // !$bulk
if ( 'page' == $screen->post_type ) :
?>
<label>
<span class="title"><?php _e( 'Template' ); ?></span>
<select name="page_template">
<?php if ( $bulk ) : ?>
<option value="-1"><?php _e( '&mdash; No Change &mdash;' ); ?></option>
<?php endif; // $bulk ?>
<?php
/** This filter is documented in wp-admin/includes/meta-boxes.php */
$default_title = apply_filters( 'default_page_template_title', __( 'Default Template' ), 'quick-edit' );
?>
<option value="default"><?php echo esc_html( $default_title ); ?></option>
<?php page_template_dropdown() ?>
</select>
</label>
<?php
endif; // page post_type
endif; // page-attributes
?>
<?php if ( count( $flat_taxonomies ) && !$bulk ) : ?>
<?php foreach ( $flat_taxonomies as $taxonomy ) : ?>
<?php if ( current_user_can( $taxonomy->cap->assign_terms ) ) : ?>
<label class="inline-edit-tags">
<span class="title"><?php echo esc_html( $taxonomy->labels->name ) ?></span>
<textarea cols="22" rows="1" name="tax_input[<?php echo esc_attr( $taxonomy->name )?>]" class="tax_input_<?php echo esc_attr( $taxonomy->name )?>"></textarea>
</label>
<?php endif; ?>
<?php endforeach; //$flat_taxonomies as $taxonomy ?>
<?php endif; // count( $flat_taxonomies ) && !$bulk ?>
<?php if ( post_type_supports( $screen->post_type, 'comments' ) || post_type_supports( $screen->post_type, 'trackbacks' ) ) :
if ( $bulk ) : ?>
<div class="inline-edit-group">
<?php if ( post_type_supports( $screen->post_type, 'comments' ) ) : ?>
<label class="alignleft">
<span class="title"><?php _e( 'Comments' ); ?></span>
<select name="comment_status">
<option value=""><?php _e( '&mdash; No Change &mdash;' ); ?></option>
<option value="open"><?php _e( 'Allow' ); ?></option>
<option value="closed"><?php _e( 'Do not allow' ); ?></option>
</select>
</label>
<?php endif; if ( post_type_supports( $screen->post_type, 'trackbacks' ) ) : ?>
<label class="alignright">
<span class="title"><?php _e( 'Pings' ); ?></span>
<select name="ping_status">
<option value=""><?php _e( '&mdash; No Change &mdash;' ); ?></option>
<option value="open"><?php _e( 'Allow' ); ?></option>
<option value="closed"><?php _e( 'Do not allow' ); ?></option>
</select>
</label>
<?php endif; ?>
</div>
<?php else : // $bulk ?>
<div class="inline-edit-group">
<?php if ( post_type_supports( $screen->post_type, 'comments' ) ) : ?>
<label class="alignleft">
<input type="checkbox" name="comment_status" value="open" />
<span class="checkbox-title"><?php _e( 'Allow Comments' ); ?></span>
</label>
<?php endif; if ( post_type_supports( $screen->post_type, 'trackbacks' ) ) : ?>
<label class="alignleft">
<input type="checkbox" name="ping_status" value="open" />
<span class="checkbox-title"><?php _e( 'Allow Pings' ); ?></span>
</label>
<?php endif; ?>
</div>
<?php endif; // $bulk
endif; // post_type_supports comments or pings ?>
<div class="inline-edit-group">
<label class="inline-edit-status alignleft">
<span class="title"><?php _e( 'Status' ); ?></span>
<select name="_status">
<?php if ( $bulk ) : ?>
<option value="-1"><?php _e( '&mdash; No Change &mdash;' ); ?></option>
<?php endif; // $bulk ?>
<?php if ( $can_publish ) : // Contributors only get "Unpublished" and "Pending Review" ?>
<option value="publish"><?php _e( 'Published' ); ?></option>
<option value="future"><?php _e( 'Scheduled' ); ?></option>
<?php if ( $bulk ) : ?>
<option value="private"><?php _e( 'Private' ) ?></option>
<?php endif; // $bulk ?>
<?php endif; ?>
<option value="pending"><?php _e( 'Pending Review' ); ?></option>
<option value="draft"><?php _e( 'Draft' ); ?></option>
</select>
</label>
<?php if ( 'post' == $screen->post_type && $can_publish && current_user_can( $post_type_object->cap->edit_others_posts ) ) : ?>
<?php if ( $bulk ) : ?>
<label class="alignright">
<span class="title"><?php _e( 'Sticky' ); ?></span>
<select name="sticky">
<option value="-1"><?php _e( '&mdash; No Change &mdash;' ); ?></option>
<option value="sticky"><?php _e( 'Sticky' ); ?></option>
<option value="unsticky"><?php _e( 'Not Sticky' ); ?></option>
</select>
</label>
<?php else : // $bulk ?>
<label class="alignleft">
<input type="checkbox" name="sticky" value="sticky" />
<span class="checkbox-title"><?php _e( 'Make this post sticky' ); ?></span>
</label>
<?php endif; // $bulk ?>
<?php endif; // 'post' && $can_publish && current_user_can( 'edit_others_cap' ) ?>
</div>
<?php
if ( $bulk && current_theme_supports( 'post-formats' ) && post_type_supports( $screen->post_type, 'post-formats' ) ) {
$post_formats = get_theme_support( 'post-formats' );
?>
<label class="alignleft" for="post_format">
<span class="title"><?php _ex( 'Format', 'post format' ); ?></span>
<select name="post_format">
<option value="-1"><?php _e( '&mdash; No Change &mdash;' ); ?></option>
<option value="0"><?php echo get_post_format_string( 'standard' ); ?></option>
<?php
foreach ( $post_formats[0] as $format ) {
?>
<option value="<?php echo esc_attr( $format ); ?>"><?php echo esc_html( get_post_format_string( $format ) ); ?></option>
<?php
}
?>
</select></label>
<?php
}
?>
</div></fieldset>
<?php
list( $columns ) = $this->get_column_info();
foreach ( $columns as $column_name => $column_display_name ) {
if ( isset( $core_columns[$column_name] ) )
continue;
if ( $bulk ) {
/**
* Fires once for each column in Bulk Edit mode.
*
* @since 2.7.0
*
* @param string $column_name Name of the column to edit.
* @param WP_Post $post_type The post type slug.
*/
do_action( 'bulk_edit_custom_box', $column_name, $screen->post_type );
} else {
/**
* Fires once for each column in Quick Edit mode.
*
* @since 2.7.0
*
* @param string $column_name Name of the column to edit.
* @param WP_Post $post_type The post type slug.
*/
do_action( 'quick_edit_custom_box', $column_name, $screen->post_type );
}
}
?>
<p class="submit inline-edit-save">
<a accesskey="c" href="#inline-edit" class="button-secondary cancel alignleft"><?php _e( 'Cancel' ); ?></a>
<?php if ( ! $bulk ) {
wp_nonce_field( 'inlineeditnonce', '_inline_edit', false );
?>
<a accesskey="s" href="#inline-edit" class="button-primary save alignright"><?php _e( 'Update' ); ?></a>
<span class="spinner"></span>
<?php } else {
submit_button( __( 'Update' ), 'button-primary alignright', 'bulk_edit', false, array( 'accesskey' => 's' ) );
} ?>
<input type="hidden" name="post_view" value="<?php echo esc_attr( $m ); ?>" />
<input type="hidden" name="screen" value="<?php echo esc_attr( $screen->id ); ?>" />
<?php if ( ! $bulk && ! post_type_supports( $screen->post_type, 'author' ) ) { ?>
<input type="hidden" name="post_author" value="<?php echo esc_attr( $post->post_author ); ?>" />
<?php } ?>
<span class="error" style="display:none"></span>
<br class="clear" />
</p>
</td></tr>
<?php
$bulk++;
}
?>
</tbody></table></form>
<?php
}
}
function tt_render_list_page($shop){
$testListTable = new WC_Quick_Donation_Listing_Table($shop);
$testListTable->prepare_items();
?>
<div class="wrap">
<div id="icon-users" class="icon32"><br/></div>
<h2>Donations</h2>
<form id="movies-filter" method="get"> <input type="hidden" name="page" value="<?php echo $_REQUEST['page'] ?>" />
<?php $testListTable->display() ?>
</form>
</div>
<?php } ?>
\ No newline at end of file
<?php
/* Copyright 2014 Varun Sridharan (email : varunsridharan23@gmail.com)
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
published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Plugin Name: Woocommerce Quick Donation
Plugin URI: http://varunsridharan.in/
Description: Woocommerce Quick Donation
Version: 1.2
Author: Varun Sridharan
Author URI: http://varunsridharan.in/
License: GPL2
*/
defined('ABSPATH') or die("No script kiddies please!");
define( 'wc_qd_u', plugin_dir_url( __FILE__ ) );
define( 'wc_qd_p', plugin_dir_path( __FILE__ ) );
class wc_quick_donation{
public $donation_id;
private $plugin_v;
/**
* Setup The Plugin Class
*/
function __construct() {
$this->donation_id = get_option('wc_quick_donation_product_id');
$this->plugin_v = '1.2';
add_shortcode( 'wc_quick_donation', array($this,'shortcode_handler' ));
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_xhtml', array($this,'generate_meta_tags'), 15, 2 );
add_action( 'wp_loaded',array($this,'process_donation'),20);
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_add_order_item_meta', array($this,'add_order_meta'),99,3);
add_action( 'woocommerce_admin_order_data_after_billing_address', array($this,'custom_order_details_page_info'), 10, 1 );
add_action( 'woocommerce_available_payment_gateways',array($this,'remove_gateway'));
add_filter('woocommerce_hidden_order_itemmeta',array($this,'hide_core_fields'));
add_filter( 'woocommerce_get_price', array($this,'get_price'),10,2);
add_filter( 'woocommerce_get_settings_pages', array($this,'settings_page') );
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;
}
/**
* Adds Donation Meta Tag
* @param String $gen Refer WP.ORG
* @param String $type Refer WP.ORG
* @returns String
* @since 0.4
*/
public function generate_meta_tags( $gen, $type ) {
switch ( $type ) {
case 'html':
$gen .= "\n" . '<meta name="generator" content="WooCommerce Quick Donation '.$this->plugin_v.'">';
break;
case 'xhtml':
$gen .= "\n" . '<meta name="generator" content="WooCommerce Quick Donation '.$this->plugin_v.'" />';
break;
}
return $gen;
}
/**
* Hides Some Important Fields
* @since 1.0
* @param [[Type]] $fields [[Description]]
* @returns [[Type]] [[Description]]
*/
public function hide_core_fields($fields){
$fields[] = '_is_donation';
$fields[] = '_project_details';
return $fields;
}
/**
* Adds Settings Page
*/
public function settings_page( $settings ) {
$settings[] = include( wc_qd_p.'wc_qd_settings.php' );
return $settings;
}
/**
* Adds Email Classes
*/
public function email_classes($email_classes){
require_once( wc_qd_p.'wc_qd_email_processing.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_completed_donation_email'] = new wc_quick_donation_completed_donation_email();
return $email_classes;
}
/**
* Adds Donation Order Meta. [Project Name]
* @param [[Type]] $order_id [[Description]]
* @since 0.2
* @updated 1.0
*/
public function add_order_meta( $item_id, $values, $cart_item_key) {
if($this->donation_id == $values['product_id']){
global $woocommerce;
wc_add_order_item_meta( $item_id, "_project_details",$woocommerce->session->projects);
wc_add_order_item_meta( $item_id, "_is_donation",'yes');
}
}
/**
* Saves Donation Order ID and adds order notes...
* @param [[Type]] $order_id [[Description]]
* @since 1.0
* @adopedFrom add_order_meta
*/
public function save_order_id_db($order_id){
$order = new WC_Order($order_id);
$items = $order->get_items();
foreach($items as $item){
$order_product_id = floatval($item['product_id']);
if($this->donation_id == $order_product_id){
$this->update_order_id($order_id);
$format = sprintf(get_option('wc_quick_donation_order_notes_title'), $woocommerce->session->projects);
$order->add_order_note($format);
update_post_meta($order_id,'_is_donation',true);
}
}
unset($order);
return $order_id;
}
/**
* Updates Order ID to [wc_quick_donation_ids] when donation is ordered
* @param [int] $order_id [Donation Order ID]
* @since 1.0
*/
private function update_order_id($order_id){
$ordersID = get_option('wc_quick_donation_ids');
$save_order_id = array();
if(empty($ordersID)){
$save_order_id[] = $order_id;
} else {
$save_order_id = json_decode($ordersID,true);
$save_order_id[] = $order_id;
}
update_option('wc_quick_donation_ids',json_encode($save_order_id));
}
/**
* Custom Title In Order View Page
* @since 1.0
*/
public function custom_order_details_page_info($order){
$is_donation = wc_get_order_item_meta($order->id, '_is_donation');
if($is_donation === true){
echo '<p><strong>'.get_option('wc_quick_donation_project_section_title').' :</strong>'.wc_get_order_item_meta($order->id, '_project_details') . '</p>';
}
}
/**
* Get All Enabled And Avaiable Payment Gateway To List In Settings Page
* @returns array [Aviable Gateways]
*/
public function get_payments_gateway(){
$payment = WC()->payment_gateways->payment_gateways();
$gateways = array();
foreach($payment as $gateway){
if ( $gateway->enabled == 'yes' ){
$gateways[$gateway->id] = $gateway->title;
}
}
return $gateways;
}
/**
* Check's For Donation Product Exist In Cart
* @returns Boolean True|False
*/
public function donation_exsits(){
global $woocommerce;
if(is_object($woocommerce->cart) && sizeof($woocommerce->cart->get_cart()) > 0){
foreach($woocommerce->cart->get_cart() as $cart_item_key => $values){
$_product = $values['data'];
if($_product->id == $this->donation_id){
return true;
}
}
}
return false;
}
/**
* Check's For Donation Product Exist In Cart
* @returns Boolean True|False
*/
public function only_donation_exsits(){
global $woocommerce;
if( sizeof($woocommerce->cart->get_cart()) == 1 && $this->donation_exsits()){
return true;
}
return false;
}
/**
* Gets Donation Current Price
* @param $price
* @param $product
* @returns 0 | price
*/
public function get_price($price, $product){
global $woocommerce;
if($product->id == $this->donation_id){
return isset($woocommerce->session->jc_donation) ? floatval($woocommerce->session->jc_donation) : 0;
}
return $price;
}
/**
* Process The Given Donation
*/
public function process_donation(){
global $woocommerce;
if(isset($_POST['donation_add'])){
$error = 0;
$found = false;
$donation = isset($_POST['donation_ammount']) ? $_POST['donation_ammount'] : false;
$projects = isset($_POST['projects']) && !empty($_POST['projects']) ? $_POST['projects'] : false;
$_SESSION['wc_qd_projects'] = $projects;
$min = get_option('wc_quick_donation_min_required_donation');
$max = get_option('wc_quick_donation_max_required_donation');
if(isset($_POST['projects']) && $_POST['projects'] == '' ){
wc_add_notice(get_option('wc_quick_donation_msg_project_invalid'), 'error' );
$error += 1;
}
if(! empty($donation)){
$donate_price = floatval($donation);
if($donate_price != 0 || $donate_price != null){
if($donate_price < $min){
$message = str_replace(array('{donation_amount}','{min_amount}'),array($donation,$min),get_option('wc_quick_donation_msg_amount_min_required'));
wc_add_notice($message, 'error' );
$error += 1;
}
if($donate_price > $max){
$message = str_replace(array('{donation_amount}','{max_amount}'),array($donation,$max),get_option('wc_quick_donation_msg_amount_max_allowed'));
wc_add_notice($message, 'error' );
$error += 1;
}
} else {
$message = str_replace('{donation_amount}',$donation,get_option('wc_quick_donation_msg_amount_invalid'));
wc_add_notice($message, 'error' );
$error += 1;
}
} else {
wc_add_notice(get_option('wc_quick_donation_msg_amount_empty'), 'error' );
$error += 1;
}
if($error ==0 ) {
if($donation >= 0){
$woocommerce->session->jc_donation = $donation;
$woocommerce->session->projects = $projects;
if( sizeof($woocommerce->cart->get_cart()) > 0){
foreach($woocommerce->cart->get_cart() as $cart_item_key=>$values){
$_product = $values['data'];
if($_product->id == $this->donation_id)
$found = true;
}
if(! $found){
$this->add_donation_cart();
} else {
wc_add_notice(get_option('wc_quick_donation_msg_donation_exist'), 'error' );
}
}else{
$this->add_donation_cart();
}
}
}
}
}
/**
* Adds Donation Product To Cart
*/
private function add_donation_cart(){
global $woocommerce;
$this->remove_cart_items();
$woocommerce->cart->add_to_cart($this->donation_id);
$this->redirectCART();
}
/**
* Redirect To Checkout Page After Donation is Added
*/
public function redirectCART(){
global $woocommerce;
$redirect_op = get_option('wc_quick_donation_redirect');
if($redirect_op == 'cart'){
wp_safe_redirect(WC()->cart->get_cart_url() );exit;
} else if($redirect_op == 'checkout'){
wp_safe_redirect(WC()->cart->get_checkout_url() );exit;
}
}
/**
* Allowes only selected payment gateway for donation product.
* @since 0.2
* @access public
*/
public function remove_gateway($gateway){
if($this->donation_exsits() && $this->only_donation_exsits()){
$payments = get_option('wc_quick_donation_payment_gateway');
if(!empty($payments)){
foreach($gateway as $val){
if(! in_array($val->id,$payments)){
unset($gateway[$val->id]);
}
}
}
return $gateway;
}
return $gateway;
}
/**
* Removes Cart ITEM if donation is added
* @returns Boolean [[Description]]
*/
private function remove_cart_items(){
$cart_remove = get_option('wc_quick_donation_cart_remove');
if(isset($cart_remove) && $cart_remove == 'true'){
global $woocommerce;
$woocommerce->cart->empty_cart();
return true;
}
return true;
}
/**
* Gets Donation Form.
* @updated 1.2
*/
public function wc_qd_form(){
global $woocommerce;
$donate = isset($woocommerce->session->jc_donation) ? floatval($woocommerce->session->jc_donation) : 0;
if(!$this->donation_exsits()){
unset($woocommerce->session->jc_donation);
unset($woocommerce->session->projects);
}
// $donate = jc_round_donation($woocommerce->cart->total );
$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( '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
* @updated 1.2
*/
public function get_projects_list(){
$projects_db = $this->donation_projects();
if($projects_db){
$project_list = '';
$project_list .= '<option value="" > Select A Project </option>';
foreach($projects_db as $proj){
$project_list .= '<option value="'.$proj.'" > '.$proj.'</option>';
}
echo '<select name="projects">'.$project_list.'</select>';
}
}
/**
* wc_quick_donation shortcode Handler
*/
public function shortcode_handler(){
return $this->wc_qd_form();
}
/**
* Install The Plugin
*/
public static function install() {
$exist = get_option('wc_quick_donation_product_id');
if($exist){
if ( get_post_status ( $exist ) ) {
return true;
} else {
$post_id = create_donation();
add_option('wc_quick_donation_product_id',$post_id);
add_site_option( 'wc_quick_donation_product_id', $post_id) ;
}
} else {
$post_id = create_donation();
add_option('wc_quick_donation_product_id',$post_id);
add_option('wc_quick_donation_ids','');
add_site_option( 'wc_quick_donation_product_id', $post_id) ;
}
}
/**
* Protects Donation Product By
* @filter_user post_row_actions
* @param Array $actions Refer WP.org
* @param Array $post Refer WP.org
* @return Array Refer WP.org
* @since 1.0
*/
public function protect_donation_product($actions,$post) {
if('product' == $post->post_type) {
if($post->ID == $this->donation_id){
unset($actions['inline hide-if-no-js']);
unset($actions['trash']);
unset($actions['duplicate']);
$actions['trash'] = '<a href="javascript:alert(\'Remove Woocommerce Quick Donation Plugin To Remove This Product \');"> Trash </a>';
}
}
return $actions;
}
}
function create_donation(){
$userID = 1;
if(get_current_user_id()){
$userID = get_current_user_id();
}
$post = array(
'post_author' => $userID,
'post_content' => 'Used For Donation',
'post_status' => 'publish',
'post_title' => 'Donation',
'post_type' => 'product',
);
$post_id = wp_insert_post($post);
update_post_meta($post_id, '_stock_status', 'instock');
update_post_meta($post_id, '_tax_status', 'none');
update_post_meta($post_id, '_tax_class', 'zero-rate');
update_post_meta($post_id, '_visibility', 'hidden');
update_post_meta($post_id, '_stock', '');
update_post_meta($post_id, '_virtual', 'yes');
update_post_meta($post_id, '_featured', 'no');
update_post_meta($post_id, '_manage_stock', "no" );
update_post_meta($post_id, '_sold_individually', "yes" );
update_post_meta($post_id, '_sku', 'checkout-donation');
return $post_id;
}
/**
* Check if WooCommerce is active
* if yes then call the class
*/
if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) {
register_activation_hook( __FILE__, array( 'wc_quick_donation', 'install' ) );
$wc_quick_donation = new wc_quick_donation;
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 {
add_action( 'admin_notices', 'wc_quick_donation_notice' );
}
function wc_quick_donation_notice() {
echo '<div class="error"><p><strong> <i> Woocommerce Quick Donation </i> </strong> Requires <a href="'.admin_url( 'plugin-install.php?tab=plugin-information&plugin=woocommerce').'"> <strong> <u>Woocommerce</u></strong> </a> To Be Installed And Activated </p></div>';
}
?>
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