admin
7 years ago
api
7 years ago
deprecated
7 years ago
donors
7 years ago
emails
7 years ago
forms
7 years ago
gateways
7 years ago
libraries
7 years ago
payments
7 years ago
actions.php
7 years ago
ajax-functions.php
7 years ago
class-give-async-process.php
8 years ago
class-give-background-updater.php
7 years ago
class-give-cache.php
7 years ago
class-give-cli-commands.php
8 years ago
class-give-comment.php
7 years ago
class-give-cron.php
8 years ago
class-give-db-donor-meta.php
8 years ago
class-give-db-donors.php
7 years ago
class-give-db-form-meta.php
8 years ago
class-give-db-logs-meta.php
8 years ago
class-give-db-logs.php
7 years ago
class-give-db-meta.php
7 years ago
class-give-db-payment-meta.php
7 years ago
class-give-db-sequential-ordering.php
7 years ago
class-give-db-sessions.php
7 years ago
class-give-db.php
8 years ago
class-give-donate-form.php
8 years ago
class-give-donor-wall-widget.php
7 years ago
class-give-donor.php
7 years ago
class-give-email-access.php
8 years ago
class-give-html-elements.php
7 years ago
class-give-license-handler.php
7 years ago
class-give-logging.php
8 years ago
class-give-readme-parser.php
8 years ago
class-give-roles.php
8 years ago
class-give-scripts.php
7 years ago
class-give-session.php
7 years ago
class-give-stats.php
8 years ago
class-give-template-loader.php
8 years ago
class-give-tooltips.php
8 years ago
class-give-translation.php
8 years ago
class-notices.php
7 years ago
country-functions.php
8 years ago
currency-functions.php
7 years ago
error-tracking.php
8 years ago
filters.php
7 years ago
formatting.php
7 years ago
import-functions.php
7 years ago
install.php
7 years ago
login-register.php
8 years ago
misc-functions.php
7 years ago
plugin-compatibility.php
8 years ago
post-types.php
8 years ago
price-functions.php
7 years ago
process-donation.php
7 years ago
shortcodes.php
7 years ago
template-functions.php
8 years ago
user-functions.php
7 years ago
class-give-donor-wall-widget.php
165 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Donors Gravatars |
| 4 | * |
| 5 | * @package Give |
| 6 | * @subpackage Classes/Give_Donors_Gravatars |
| 7 | * @copyright Copyright (c) 2016, WordImpress |
| 8 | * @license https://opensource.org/licenses/gpl-license GNU Public License |
| 9 | * @since 1.0 |
| 10 | */ |
| 11 | |
| 12 | // Exit if accessed directly. |
| 13 | if ( ! defined( 'ABSPATH' ) ) { |
| 14 | exit; |
| 15 | } |
| 16 | |
| 17 | /** |
| 18 | * Give_Donor_Wall_Widget Class |
| 19 | * |
| 20 | * This class handles donors gravatars |
| 21 | * |
| 22 | * @since 1.0 |
| 23 | */ |
| 24 | class Give_Donor_Wall_Widget extends WP_Widget { |
| 25 | |
| 26 | /** |
| 27 | * Widget constructor |
| 28 | * |
| 29 | * @since 1.0 |
| 30 | * @access public |
| 31 | */ |
| 32 | public function __construct() { |
| 33 | |
| 34 | // widget settings |
| 35 | $widget_ops = array( |
| 36 | 'classname' => 'give-donors-gravatars', |
| 37 | 'description' => esc_html__( 'Displays gravatars of people who have donated using your your form. Will only show on the single form page.', 'give' ), |
| 38 | ); |
| 39 | |
| 40 | // widget control settings |
| 41 | $control_ops = array( |
| 42 | 'width' => 250, |
| 43 | 'height' => 350, |
| 44 | 'id_base' => 'give_gravatars_widget' |
| 45 | ); |
| 46 | |
| 47 | // create the widget |
| 48 | parent::__construct( |
| 49 | 'give_donors_gravatars_widget', |
| 50 | esc_html__( 'Give Donors Gravatars', 'give' ), |
| 51 | $widget_ops, |
| 52 | $control_ops |
| 53 | ); |
| 54 | |
| 55 | } |
| 56 | |
| 57 | /** |
| 58 | * Donors gravatars widget content |
| 59 | * |
| 60 | * Outputs the content of the widget |
| 61 | * |
| 62 | * @since 1.0 |
| 63 | * @access public |
| 64 | * |
| 65 | * @param array $args Display arguments including 'before_title', 'after_title', 'before_widget', and 'after_widget'. |
| 66 | * @param array $instance Settings for the current Links widget instance. |
| 67 | * |
| 68 | * @return void |
| 69 | */ |
| 70 | public function widget( $args, $instance ) { |
| 71 | |
| 72 | //@TODO: Don't extract it!!! |
| 73 | extract( $args ); |
| 74 | |
| 75 | if ( ! is_singular( 'give_forms' ) ) { |
| 76 | return; |
| 77 | } |
| 78 | |
| 79 | // Variables from widget settings |
| 80 | $title = apply_filters( 'widget_title', $instance['title'] ); |
| 81 | |
| 82 | // Used by themes. Opens the widget |
| 83 | echo $before_widget; |
| 84 | |
| 85 | // Display the widget title |
| 86 | if ( $title ) { |
| 87 | echo $before_title . $title . $after_title; |
| 88 | } |
| 89 | |
| 90 | $gravatars = new Give_Donor_Wall(); |
| 91 | |
| 92 | echo $gravatars->gravatars( get_the_ID(), null ); // remove title |
| 93 | |
| 94 | // Used by themes. Closes the widget |
| 95 | echo $after_widget; |
| 96 | |
| 97 | } |
| 98 | |
| 99 | /** |
| 100 | * Update donors gravatars |
| 101 | * |
| 102 | * Processes widget options to be saved. |
| 103 | * |
| 104 | * @since 1.0 |
| 105 | * @access public |
| 106 | * |
| 107 | * @param array $new_instance New settings for this instance as input by the user via WP_Widget::form(). |
| 108 | * @param array $old_instance Old settings for this instance. |
| 109 | * |
| 110 | * @return array Updated settings to save. |
| 111 | */ |
| 112 | public function update( $new_instance, $old_instance ) { |
| 113 | |
| 114 | $instance = $old_instance; |
| 115 | |
| 116 | $instance['title'] = strip_tags( $new_instance['title'] ); |
| 117 | |
| 118 | return $instance; |
| 119 | |
| 120 | } |
| 121 | |
| 122 | /** |
| 123 | * Output donors |
| 124 | * |
| 125 | * Displays the actual form on the widget page. |
| 126 | * |
| 127 | * @since 1.0 |
| 128 | * @access public |
| 129 | * |
| 130 | * @param array $instance Current settings. |
| 131 | * |
| 132 | * @return void |
| 133 | */ |
| 134 | public function form( $instance ) { |
| 135 | |
| 136 | // Set up some default widget settings. |
| 137 | $defaults = array( |
| 138 | 'title' => '', |
| 139 | ); |
| 140 | |
| 141 | $instance = wp_parse_args( (array) $instance, $defaults ); ?> |
| 142 | |
| 143 | <!-- Title --> |
| 144 | <p> |
| 145 | <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php esc_html_e( 'Title:', 'give' ) ?></label> |
| 146 | <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo $instance['title']; ?>" /> |
| 147 | </p> |
| 148 | |
| 149 | <?php |
| 150 | } |
| 151 | |
| 152 | /** |
| 153 | * Register the widget |
| 154 | * |
| 155 | * @return void |
| 156 | */ |
| 157 | function widget_init(){ |
| 158 | register_widget( $this->self ); |
| 159 | } |
| 160 | |
| 161 | } |
| 162 | |
| 163 | |
| 164 | |
| 165 |