@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | // Exit if accessed directly. |
| 13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 13 | +if ( ! defined('ABSPATH')) { |
|
| 14 | 14 | exit; |
| 15 | 15 | } |
| 16 | 16 | |
@@ -21,10 +21,10 @@ discard block |
||
| 21 | 21 | */ |
| 22 | 22 | public function __construct() { |
| 23 | 23 | |
| 24 | - $this->shortcode['title'] = esc_html__( 'Register', 'give' ); |
|
| 25 | - $this->shortcode['label'] = esc_html__( 'Register', 'give' ); |
|
| 24 | + $this->shortcode['title'] = esc_html__('Register', 'give'); |
|
| 25 | + $this->shortcode['label'] = esc_html__('Register', 'give'); |
|
| 26 | 26 | |
| 27 | - parent::__construct( 'give_register' ); |
|
| 27 | + parent::__construct('give_register'); |
|
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | /** |
@@ -37,13 +37,13 @@ discard block |
||
| 37 | 37 | return array( |
| 38 | 38 | array( |
| 39 | 39 | 'type' => 'container', |
| 40 | - 'html' => sprintf( '<p class="no-margin">%s</p>', esc_html__( 'Redirect URL (optional):', 'give' ) ), |
|
| 40 | + 'html' => sprintf('<p class="no-margin">%s</p>', esc_html__('Redirect URL (optional):', 'give')), |
|
| 41 | 41 | ), |
| 42 | 42 | array( |
| 43 | 43 | 'type' => 'textbox', |
| 44 | 44 | 'name' => 'redirect', |
| 45 | 45 | 'minWidth' => 320, |
| 46 | - 'tooltip' => esc_attr__( 'Enter an URL here to redirect to after registering.', 'give' ), |
|
| 46 | + 'tooltip' => esc_attr__('Enter an URL here to redirect to after registering.', 'give'), |
|
| 47 | 47 | ), |
| 48 | 48 | ); |
| 49 | 49 | } |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | // Exit if accessed directly. |
| 13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 13 | +if ( ! defined('ABSPATH')) { |
|
| 14 | 14 | exit; |
| 15 | 15 | } |
| 16 | 16 | |
@@ -21,9 +21,9 @@ discard block |
||
| 21 | 21 | */ |
| 22 | 22 | public function __construct() { |
| 23 | 23 | |
| 24 | - $this->shortcode['label'] = esc_html__( 'Donation History', 'give' ); |
|
| 24 | + $this->shortcode['label'] = esc_html__('Donation History', 'give'); |
|
| 25 | 25 | |
| 26 | - parent::__construct( 'donation_history' ); |
|
| 26 | + parent::__construct('donation_history'); |
|
| 27 | 27 | } |
| 28 | 28 | } |
| 29 | 29 | |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | // Exit if accessed directly. |
| 13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 13 | +if ( ! defined('ABSPATH')) { |
|
| 14 | 14 | exit; |
| 15 | 15 | } |
| 16 | 16 | |
@@ -23,19 +23,19 @@ discard block |
||
| 23 | 23 | * |
| 24 | 24 | * @return array An array of updated action links. |
| 25 | 25 | */ |
| 26 | -function give_plugin_action_links( $actions ) { |
|
| 26 | +function give_plugin_action_links($actions) { |
|
| 27 | 27 | $new_actions = array( |
| 28 | 28 | 'settings' => sprintf( |
| 29 | 29 | '<a href="%1$s">%2$s</a>', |
| 30 | - admin_url( 'edit.php?post_type=give_forms&page=give-settings' ), |
|
| 31 | - esc_html__( 'Settings', 'give' ) |
|
| 30 | + admin_url('edit.php?post_type=give_forms&page=give-settings'), |
|
| 31 | + esc_html__('Settings', 'give') |
|
| 32 | 32 | ), |
| 33 | 33 | ); |
| 34 | 34 | |
| 35 | - return array_merge( $new_actions, $actions ); |
|
| 35 | + return array_merge($new_actions, $actions); |
|
| 36 | 36 | } |
| 37 | 37 | |
| 38 | -add_filter( 'plugin_action_links_' . GIVE_PLUGIN_BASENAME, 'give_plugin_action_links' ); |
|
| 38 | +add_filter('plugin_action_links_'.GIVE_PLUGIN_BASENAME, 'give_plugin_action_links'); |
|
| 39 | 39 | |
| 40 | 40 | |
| 41 | 41 | /** |
@@ -48,35 +48,35 @@ discard block |
||
| 48 | 48 | * |
| 49 | 49 | * @return array |
| 50 | 50 | */ |
| 51 | -function give_plugin_row_meta( $plugin_meta, $plugin_file ) { |
|
| 52 | - if ( $plugin_file != GIVE_PLUGIN_BASENAME ) { |
|
| 51 | +function give_plugin_row_meta($plugin_meta, $plugin_file) { |
|
| 52 | + if ($plugin_file != GIVE_PLUGIN_BASENAME) { |
|
| 53 | 53 | return $plugin_meta; |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | $new_meta_links = array( |
| 57 | 57 | sprintf( |
| 58 | 58 | '<a href="%1$s" target="_blank">%2$s</a>', |
| 59 | - esc_url( add_query_arg( array( |
|
| 59 | + esc_url(add_query_arg(array( |
|
| 60 | 60 | 'utm_source' => 'plugins-page', |
| 61 | 61 | 'utm_medium' => 'plugin-row', |
| 62 | 62 | 'utm_campaign' => 'admin', |
| 63 | - ), 'https://givewp.com/documentation/' ) |
|
| 63 | + ), 'https://givewp.com/documentation/') |
|
| 64 | 64 | ), |
| 65 | - esc_html__( 'Documentation', 'give' ) |
|
| 65 | + esc_html__('Documentation', 'give') |
|
| 66 | 66 | ), |
| 67 | 67 | sprintf( |
| 68 | 68 | '<a href="%1$s" target="_blank">%2$s</a>', |
| 69 | - esc_url( add_query_arg( array( |
|
| 69 | + esc_url(add_query_arg(array( |
|
| 70 | 70 | 'utm_source' => 'plugins-page', |
| 71 | 71 | 'utm_medium' => 'plugin-row', |
| 72 | 72 | 'utm_campaign' => 'admin', |
| 73 | - ), 'https://givewp.com/addons/' ) |
|
| 73 | + ), 'https://givewp.com/addons/') |
|
| 74 | 74 | ), |
| 75 | - esc_html__( 'Add-ons', 'give' ) |
|
| 75 | + esc_html__('Add-ons', 'give') |
|
| 76 | 76 | ), |
| 77 | 77 | ); |
| 78 | 78 | |
| 79 | - return array_merge( $plugin_meta, $new_meta_links ); |
|
| 79 | + return array_merge($plugin_meta, $new_meta_links); |
|
| 80 | 80 | } |
| 81 | 81 | |
| 82 | -add_filter( 'plugin_row_meta', 'give_plugin_row_meta', 10, 2 ); |
|
| 82 | +add_filter('plugin_row_meta', 'give_plugin_row_meta', 10, 2); |
|
@@ -66,23 +66,23 @@ discard block |
||
| 66 | 66 | * @param $args |
| 67 | 67 | * |
| 68 | 68 | */ |
| 69 | - public function __construct( $args ) { |
|
| 69 | + public function __construct($args) { |
|
| 70 | 70 | |
| 71 | 71 | //Only for admins. |
| 72 | - if ( ! is_admin() ) { |
|
| 72 | + if ( ! is_admin()) { |
|
| 73 | 73 | return; |
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | //This plugin is en_US native. |
| 77 | 77 | $this->locale = get_locale(); |
| 78 | - if ( 'en_US' === $this->locale ) { |
|
| 78 | + if ('en_US' === $this->locale) { |
|
| 79 | 79 | return; |
| 80 | 80 | } |
| 81 | 81 | |
| 82 | - $this->init( $args ); |
|
| 82 | + $this->init($args); |
|
| 83 | 83 | |
| 84 | - if ( ! $this->hide_promo() ) { |
|
| 85 | - add_action( $this->hook, array( $this, 'promo' ) ); |
|
| 84 | + if ( ! $this->hide_promo()) { |
|
| 85 | + add_action($this->hook, array($this, 'promo')); |
|
| 86 | 86 | } |
| 87 | 87 | } |
| 88 | 88 | |
@@ -93,8 +93,8 @@ discard block |
||
| 93 | 93 | * |
| 94 | 94 | * @param array $args |
| 95 | 95 | */ |
| 96 | - private function init( $args ) { |
|
| 97 | - foreach ( $args as $key => $arg ) { |
|
| 96 | + private function init($args) { |
|
| 97 | + foreach ($args as $key => $arg) { |
|
| 98 | 98 | $this->$key = $arg; |
| 99 | 99 | } |
| 100 | 100 | |
@@ -108,11 +108,11 @@ discard block |
||
| 108 | 108 | * @return bool |
| 109 | 109 | */ |
| 110 | 110 | private function hide_promo() { |
| 111 | - $hide_promo = get_transient( 'give_i18n_give_promo_hide' ); |
|
| 112 | - if ( ! $hide_promo ) { |
|
| 113 | - if ( filter_input( INPUT_GET, 'remove_i18n_promo', FILTER_VALIDATE_INT ) === 1 ) { |
|
| 111 | + $hide_promo = get_transient('give_i18n_give_promo_hide'); |
|
| 112 | + if ( ! $hide_promo) { |
|
| 113 | + if (filter_input(INPUT_GET, 'remove_i18n_promo', FILTER_VALIDATE_INT) === 1) { |
|
| 114 | 114 | // No expiration time, so this would normally not expire, but it wouldn't be copied to other sites etc. |
| 115 | - set_transient( 'give_i18n_give_promo_hide', true ); |
|
| 115 | + set_transient('give_i18n_give_promo_hide', true); |
|
| 116 | 116 | $hide_promo = true; |
| 117 | 117 | } |
| 118 | 118 | } |
@@ -131,20 +131,20 @@ discard block |
||
| 131 | 131 | $message = false; |
| 132 | 132 | |
| 133 | 133 | //Using a translation less than 90% complete. |
| 134 | - if ( $this->translation_exists && $this->translation_loaded && $this->percent_translated < 90 ) { |
|
| 135 | - $message = __( 'As you can see, there is a translation of this plugin in %1$s. This translation is currently %3$d%% complete. We need your help to make it complete and to fix any errors. Please register at %4$s to help %5$s to %1$s!', 'give' ); |
|
| 136 | - } elseif ( ! $this->translation_loaded && $this->translation_exists ) { |
|
| 137 | - $message = __( 'You\'re using WordPress in %1$s. While %2$s has been %3$d%% translated to %1$s, it has not been shipped with the plugin yet. You can help! Register at %4$s to help complete the translation to %1$s!', 'give' ); |
|
| 138 | - } elseif ( ! $this->translation_exists ) { |
|
| 139 | - $message = __( 'You\'re using WordPress in a language we don\'t support yet. We\'d love for %2$s to be translated in that language too, but unfortunately, it isn\'t right now. You can change that! Register at %4$s to help translate it!', 'give' ); |
|
| 134 | + if ($this->translation_exists && $this->translation_loaded && $this->percent_translated < 90) { |
|
| 135 | + $message = __('As you can see, there is a translation of this plugin in %1$s. This translation is currently %3$d%% complete. We need your help to make it complete and to fix any errors. Please register at %4$s to help %5$s to %1$s!', 'give'); |
|
| 136 | + } elseif ( ! $this->translation_loaded && $this->translation_exists) { |
|
| 137 | + $message = __('You\'re using WordPress in %1$s. While %2$s has been %3$d%% translated to %1$s, it has not been shipped with the plugin yet. You can help! Register at %4$s to help complete the translation to %1$s!', 'give'); |
|
| 138 | + } elseif ( ! $this->translation_exists) { |
|
| 139 | + $message = __('You\'re using WordPress in a language we don\'t support yet. We\'d love for %2$s to be translated in that language too, but unfortunately, it isn\'t right now. You can change that! Register at %4$s to help translate it!', 'give'); |
|
| 140 | 140 | } |
| 141 | 141 | |
| 142 | 142 | //Links. |
| 143 | - $registration_link = sprintf( '<a href="%1$s" target="_blank">%2$s</a>', 'https://wordpress.org/support/register.php', esc_html__( 'WordPress.org', 'give' ) ); |
|
| 144 | - $translations_link = sprintf( '<a href="%1$s" target="_blank">%2$s</a>', 'https://translate.wordpress.org/projects/wp-plugins/give', esc_html__( 'complete the translation', 'give' ) ); |
|
| 143 | + $registration_link = sprintf('<a href="%1$s" target="_blank">%2$s</a>', 'https://wordpress.org/support/register.php', esc_html__('WordPress.org', 'give')); |
|
| 144 | + $translations_link = sprintf('<a href="%1$s" target="_blank">%2$s</a>', 'https://translate.wordpress.org/projects/wp-plugins/give', esc_html__('complete the translation', 'give')); |
|
| 145 | 145 | |
| 146 | 146 | //Message. |
| 147 | - $message = sprintf( $message, $this->locale_name, 'Give', $this->percent_translated, $registration_link, $translations_link ); |
|
| 147 | + $message = sprintf($message, $this->locale_name, 'Give', $this->percent_translated, $registration_link, $translations_link); |
|
| 148 | 148 | |
| 149 | 149 | |
| 150 | 150 | return $message; |
@@ -159,7 +159,7 @@ discard block |
||
| 159 | 159 | $this->translation_details(); |
| 160 | 160 | $message = $this->promo_message(); |
| 161 | 161 | |
| 162 | - if ( $message ) { ?> |
|
| 162 | + if ($message) { ?> |
|
| 163 | 163 | |
| 164 | 164 | <style> |
| 165 | 165 | /* Banner specific styles */ |
@@ -212,12 +212,12 @@ discard block |
||
| 212 | 212 | <a href="https://wordpress.org/support/register.php" class="alignleft give-i18n-icon" style="margin:0" target="_blank"><span class="dashicons dashicons-translation" style="font-size: 110px; text-decoration: none;"></span></a> |
| 213 | 213 | |
| 214 | 214 | <div class="give-i18n-notice-content"> |
| 215 | - <a href="<?php echo esc_url( add_query_arg( array( 'remove_i18n_promo' => '1' ) ) ); ?>" class="dismiss"><span class="dashicons dashicons-dismiss"></span></a> |
|
| 215 | + <a href="<?php echo esc_url(add_query_arg(array('remove_i18n_promo' => '1'))); ?>" class="dismiss"><span class="dashicons dashicons-dismiss"></span></a> |
|
| 216 | 216 | |
| 217 | - <h2 style="margin: 10px 0;"><?php printf( esc_html__( 'Help Translate Give to %s', 'give' ), $this->locale_name ); ?></h2> |
|
| 217 | + <h2 style="margin: 10px 0;"><?php printf(esc_html__('Help Translate Give to %s', 'give'), $this->locale_name); ?></h2> |
|
| 218 | 218 | <p><?php echo $message; ?></p> |
| 219 | 219 | <p> |
| 220 | - <a href="https://wordpress.org/support/register.php" target="_blank"><?php _e( 'Register now »', 'give' ); ?></a> |
|
| 220 | + <a href="https://wordpress.org/support/register.php" target="_blank"><?php _e('Register now »', 'give'); ?></a> |
|
| 221 | 221 | </p> |
| 222 | 222 | </div> |
| 223 | 223 | </div> |
@@ -234,11 +234,11 @@ discard block |
||
| 234 | 234 | */ |
| 235 | 235 | private function find_or_initialize_translation_details() { |
| 236 | 236 | |
| 237 | - $set = get_transient( 'give_i18n_give_' . $this->locale ); |
|
| 237 | + $set = get_transient('give_i18n_give_'.$this->locale); |
|
| 238 | 238 | |
| 239 | - if ( ! $set ) { |
|
| 239 | + if ( ! $set) { |
|
| 240 | 240 | $set = $this->retrieve_translation_details(); |
| 241 | - set_transient( 'give_i18n_give_' . $this->locale, $set, DAY_IN_SECONDS ); |
|
| 241 | + set_transient('give_i18n_give_'.$this->locale, $set, DAY_IN_SECONDS); |
|
| 242 | 242 | } |
| 243 | 243 | |
| 244 | 244 | return $set; |
@@ -252,10 +252,10 @@ discard block |
||
| 252 | 252 | private function translation_details() { |
| 253 | 253 | $set = $this->find_or_initialize_translation_details(); |
| 254 | 254 | |
| 255 | - $this->translation_exists = ! is_null( $set ); |
|
| 256 | - $this->translation_loaded = is_textdomain_loaded( 'give' ); |
|
| 255 | + $this->translation_exists = ! is_null($set); |
|
| 256 | + $this->translation_loaded = is_textdomain_loaded('give'); |
|
| 257 | 257 | |
| 258 | - $this->parse_translation_set( $set ); |
|
| 258 | + $this->parse_translation_set($set); |
|
| 259 | 259 | } |
| 260 | 260 | |
| 261 | 261 | /** |
@@ -267,26 +267,26 @@ discard block |
||
| 267 | 267 | */ |
| 268 | 268 | private function retrieve_translation_details() { |
| 269 | 269 | |
| 270 | - $api_url = trailingslashit( $this->glotpress_url ); |
|
| 270 | + $api_url = trailingslashit($this->glotpress_url); |
|
| 271 | 271 | |
| 272 | - $resp = wp_remote_get( $api_url ); |
|
| 272 | + $resp = wp_remote_get($api_url); |
|
| 273 | 273 | |
| 274 | - if ( is_wp_error( $resp ) || wp_remote_retrieve_response_code( $resp ) === '404' ) { |
|
| 274 | + if (is_wp_error($resp) || wp_remote_retrieve_response_code($resp) === '404') { |
|
| 275 | 275 | return null; |
| 276 | 276 | } |
| 277 | 277 | |
| 278 | - $body = wp_remote_retrieve_body( $resp ); |
|
| 279 | - unset( $resp ); |
|
| 278 | + $body = wp_remote_retrieve_body($resp); |
|
| 279 | + unset($resp); |
|
| 280 | 280 | |
| 281 | - if ( $body ) { |
|
| 282 | - $body = json_decode( $body ); |
|
| 281 | + if ($body) { |
|
| 282 | + $body = json_decode($body); |
|
| 283 | 283 | |
| 284 | - foreach ( $body->translation_sets as $set ) { |
|
| 285 | - if ( ! property_exists( $set, 'wp_locale' ) ) { |
|
| 284 | + foreach ($body->translation_sets as $set) { |
|
| 285 | + if ( ! property_exists($set, 'wp_locale')) { |
|
| 286 | 286 | continue; |
| 287 | 287 | } |
| 288 | 288 | |
| 289 | - if ( $this->locale == $set->wp_locale ) { |
|
| 289 | + if ($this->locale == $set->wp_locale) { |
|
| 290 | 290 | return $set; |
| 291 | 291 | } |
| 292 | 292 | } |
@@ -302,8 +302,8 @@ discard block |
||
| 302 | 302 | * |
| 303 | 303 | * @access private |
| 304 | 304 | */ |
| 305 | - private function parse_translation_set( $set ) { |
|
| 306 | - if ( $this->translation_exists && is_object( $set ) ) { |
|
| 305 | + private function parse_translation_set($set) { |
|
| 306 | + if ($this->translation_exists && is_object($set)) { |
|
| 307 | 307 | $this->locale_name = $set->name; |
| 308 | 308 | $this->percent_translated = $set->percent_translated; |
| 309 | 309 | } else { |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | // Exit if accessed directly. |
| 13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 13 | +if ( ! defined('ABSPATH')) { |
|
| 14 | 14 | exit; |
| 15 | 15 | } |
| 16 | 16 | |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | * |
| 24 | 24 | * @return array The altered list of views |
| 25 | 25 | */ |
| 26 | -function give_register_default_customer_views( $views ) { |
|
| 26 | +function give_register_default_customer_views($views) { |
|
| 27 | 27 | |
| 28 | 28 | $default_views = array( |
| 29 | 29 | 'overview' => 'give_customers_view', |
@@ -31,11 +31,11 @@ discard block |
||
| 31 | 31 | 'notes' => 'give_customer_notes_view' |
| 32 | 32 | ); |
| 33 | 33 | |
| 34 | - return array_merge( $views, $default_views ); |
|
| 34 | + return array_merge($views, $default_views); |
|
| 35 | 35 | |
| 36 | 36 | } |
| 37 | 37 | |
| 38 | -add_filter( 'give_customer_views', 'give_register_default_customer_views', 1, 1 ); |
|
| 38 | +add_filter('give_customer_views', 'give_register_default_customer_views', 1, 1); |
|
| 39 | 39 | |
| 40 | 40 | /** |
| 41 | 41 | * Register a tab for the single customer view |
@@ -46,17 +46,17 @@ discard block |
||
| 46 | 46 | * |
| 47 | 47 | * @return array The altered list of tabs |
| 48 | 48 | */ |
| 49 | -function give_register_default_customer_tabs( $tabs ) { |
|
| 49 | +function give_register_default_customer_tabs($tabs) { |
|
| 50 | 50 | |
| 51 | 51 | $default_tabs = array( |
| 52 | - 'overview' => array( 'dashicon' => 'dashicons-admin-users', 'title' => esc_html__( 'Donor Profile', 'give' ) ), |
|
| 53 | - 'notes' => array( 'dashicon' => 'dashicons-admin-comments', 'title' => esc_html__( 'Donor Notes', 'give' ) ) |
|
| 52 | + 'overview' => array('dashicon' => 'dashicons-admin-users', 'title' => esc_html__('Donor Profile', 'give')), |
|
| 53 | + 'notes' => array('dashicon' => 'dashicons-admin-comments', 'title' => esc_html__('Donor Notes', 'give')) |
|
| 54 | 54 | ); |
| 55 | 55 | |
| 56 | - return array_merge( $tabs, $default_tabs ); |
|
| 56 | + return array_merge($tabs, $default_tabs); |
|
| 57 | 57 | } |
| 58 | 58 | |
| 59 | -add_filter( 'give_customer_tabs', 'give_register_default_customer_tabs', 1, 1 ); |
|
| 59 | +add_filter('give_customer_tabs', 'give_register_default_customer_tabs', 1, 1); |
|
| 60 | 60 | |
| 61 | 61 | /** |
| 62 | 62 | * Register the Delete icon as late as possible so it's at the bottom |
@@ -67,11 +67,11 @@ discard block |
||
| 67 | 67 | * |
| 68 | 68 | * @return array The altered list of tabs, with 'delete' at the bottom |
| 69 | 69 | */ |
| 70 | -function give_register_delete_customer_tab( $tabs ) { |
|
| 70 | +function give_register_delete_customer_tab($tabs) { |
|
| 71 | 71 | |
| 72 | - $tabs['delete'] = array( 'dashicon' => 'dashicons-trash', 'title' => esc_html__( 'Delete Donor', 'give' ) ); |
|
| 72 | + $tabs['delete'] = array('dashicon' => 'dashicons-trash', 'title' => esc_html__('Delete Donor', 'give')); |
|
| 73 | 73 | |
| 74 | 74 | return $tabs; |
| 75 | 75 | } |
| 76 | 76 | |
| 77 | -add_filter( 'give_customer_tabs', 'give_register_delete_customer_tab', PHP_INT_MAX, 1 ); |
|
| 77 | +add_filter('give_customer_tabs', 'give_register_delete_customer_tab', PHP_INT_MAX, 1); |
|
@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | 14 | // Exit if accessed directly. |
| 15 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 15 | +if ( ! defined('ABSPATH')) { |
|
| 16 | 16 | exit; |
| 17 | 17 | } |
| 18 | 18 | |
@@ -38,16 +38,16 @@ discard block |
||
| 38 | 38 | * @return void |
| 39 | 39 | */ |
| 40 | 40 | public function headers() { |
| 41 | - ignore_user_abort( true ); |
|
| 41 | + ignore_user_abort(true); |
|
| 42 | 42 | |
| 43 | - if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) { |
|
| 44 | - set_time_limit( 0 ); |
|
| 43 | + if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) { |
|
| 44 | + set_time_limit(0); |
|
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | nocache_headers(); |
| 48 | - header( 'Content-Type: text/csv; charset=utf-8' ); |
|
| 49 | - header( 'Content-Disposition: attachment; filename=' . apply_filters( 'give_earnings_export_filename', 'give-export-' . $this->export_type . '-' . date( 'n' ) . '-' . date( 'Y' ) ) . '.csv' ); |
|
| 50 | - header( "Expires: 0" ); |
|
| 48 | + header('Content-Type: text/csv; charset=utf-8'); |
|
| 49 | + header('Content-Disposition: attachment; filename='.apply_filters('give_earnings_export_filename', 'give-export-'.$this->export_type.'-'.date('n').'-'.date('Y')).'.csv'); |
|
| 50 | + header("Expires: 0"); |
|
| 51 | 51 | |
| 52 | 52 | } |
| 53 | 53 | |
@@ -61,10 +61,10 @@ discard block |
||
| 61 | 61 | public function csv_cols() { |
| 62 | 62 | |
| 63 | 63 | $cols = array( |
| 64 | - 'date' => esc_html__( 'Date', 'give' ), |
|
| 65 | - 'donations' => esc_html__( 'Donations', 'give' ), |
|
| 64 | + 'date' => esc_html__('Date', 'give'), |
|
| 65 | + 'donations' => esc_html__('Donations', 'give'), |
|
| 66 | 66 | /* translators: %s: currency */ |
| 67 | - 'earnings' => sprintf( esc_html__( 'Income (%s)', 'give' ), html_entity_decode( give_currency_filter( '' ) ) ) |
|
| 67 | + 'earnings' => sprintf(esc_html__('Income (%s)', 'give'), html_entity_decode(give_currency_filter(''))) |
|
| 68 | 68 | ); |
| 69 | 69 | |
| 70 | 70 | return $cols; |
@@ -79,28 +79,28 @@ discard block |
||
| 79 | 79 | */ |
| 80 | 80 | public function get_data() { |
| 81 | 81 | |
| 82 | - $start_year = isset( $_POST['start_year'] ) ? absint( $_POST['start_year'] ) : date( 'Y' ); |
|
| 83 | - $end_year = isset( $_POST['end_year'] ) ? absint( $_POST['end_year'] ) : date( 'Y' ); |
|
| 84 | - $start_month = isset( $_POST['start_month'] ) ? absint( $_POST['start_month'] ) : date( 'n' ); |
|
| 85 | - $end_month = isset( $_POST['end_month'] ) ? absint( $_POST['end_month'] ) : date( 'n' ); |
|
| 82 | + $start_year = isset($_POST['start_year']) ? absint($_POST['start_year']) : date('Y'); |
|
| 83 | + $end_year = isset($_POST['end_year']) ? absint($_POST['end_year']) : date('Y'); |
|
| 84 | + $start_month = isset($_POST['start_month']) ? absint($_POST['start_month']) : date('n'); |
|
| 85 | + $end_month = isset($_POST['end_month']) ? absint($_POST['end_month']) : date('n'); |
|
| 86 | 86 | |
| 87 | 87 | $data = array(); |
| 88 | 88 | $year = $start_year; |
| 89 | 89 | $stats = new Give_Payment_Stats; |
| 90 | 90 | |
| 91 | - while ( $year <= $end_year ) { |
|
| 91 | + while ($year <= $end_year) { |
|
| 92 | 92 | |
| 93 | - if ( $year == $start_year && $year == $end_year ) { |
|
| 93 | + if ($year == $start_year && $year == $end_year) { |
|
| 94 | 94 | |
| 95 | 95 | $m1 = $start_month; |
| 96 | 96 | $m2 = $end_month; |
| 97 | 97 | |
| 98 | - } elseif ( $year == $start_year ) { |
|
| 98 | + } elseif ($year == $start_year) { |
|
| 99 | 99 | |
| 100 | 100 | $m1 = $start_month; |
| 101 | 101 | $m2 = 12; |
| 102 | 102 | |
| 103 | - } elseif ( $year == $end_year ) { |
|
| 103 | + } elseif ($year == $end_year) { |
|
| 104 | 104 | |
| 105 | 105 | $m1 = 1; |
| 106 | 106 | $m2 = $end_month; |
@@ -112,28 +112,28 @@ discard block |
||
| 112 | 112 | |
| 113 | 113 | } |
| 114 | 114 | |
| 115 | - while ( $m1 <= $m2 ) { |
|
| 115 | + while ($m1 <= $m2) { |
|
| 116 | 116 | |
| 117 | - $date1 = mktime( 0, 0, 0, $m1, 1, $year ); |
|
| 118 | - $date2 = mktime( 0, 0, 0, $m1, cal_days_in_month( CAL_GREGORIAN, $m1, $year ), $year ); |
|
| 117 | + $date1 = mktime(0, 0, 0, $m1, 1, $year); |
|
| 118 | + $date2 = mktime(0, 0, 0, $m1, cal_days_in_month(CAL_GREGORIAN, $m1, $year), $year); |
|
| 119 | 119 | |
| 120 | 120 | $data[] = array( |
| 121 | - 'date' => date_i18n( 'F Y', $date1 ), |
|
| 122 | - 'donations' => $stats->get_sales( 0, $date1, $date2 ), |
|
| 123 | - 'earnings' => give_format_amount( $stats->get_earnings( 0, $date1, $date2 ) ), |
|
| 121 | + 'date' => date_i18n('F Y', $date1), |
|
| 122 | + 'donations' => $stats->get_sales(0, $date1, $date2), |
|
| 123 | + 'earnings' => give_format_amount($stats->get_earnings(0, $date1, $date2)), |
|
| 124 | 124 | ); |
| 125 | 125 | |
| 126 | - $m1 ++; |
|
| 126 | + $m1++; |
|
| 127 | 127 | |
| 128 | 128 | } |
| 129 | 129 | |
| 130 | 130 | |
| 131 | - $year ++; |
|
| 131 | + $year++; |
|
| 132 | 132 | |
| 133 | 133 | } |
| 134 | 134 | |
| 135 | - $data = apply_filters( 'give_export_get_data', $data ); |
|
| 136 | - $data = apply_filters( "give_export_get_data_{$this->export_type}", $data ); |
|
| 135 | + $data = apply_filters('give_export_get_data', $data); |
|
| 136 | + $data = apply_filters("give_export_get_data_{$this->export_type}", $data); |
|
| 137 | 137 | |
| 138 | 138 | return $data; |
| 139 | 139 | } |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | */ |
| 12 | 12 | |
| 13 | 13 | // Exit if accessed directly. |
| 14 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 14 | +if ( ! defined('ABSPATH')) { |
|
| 15 | 15 | exit; |
| 16 | 16 | } |
| 17 | 17 | |
@@ -53,50 +53,50 @@ discard block |
||
| 53 | 53 | */ |
| 54 | 54 | public function get_data() { |
| 55 | 55 | |
| 56 | - if ( $this->step == 1 ) { |
|
| 57 | - $this->delete_data( 'give_temp_recount_income' ); |
|
| 56 | + if ($this->step == 1) { |
|
| 57 | + $this->delete_data('give_temp_recount_income'); |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | - $total = get_option( 'give_temp_recount_income', false ); |
|
| 60 | + $total = get_option('give_temp_recount_income', false); |
|
| 61 | 61 | |
| 62 | - if ( false === $total ) { |
|
| 62 | + if (false === $total) { |
|
| 63 | 63 | $total = (float) 0; |
| 64 | - $this->store_data( 'give_temp_recount_income', $total ); |
|
| 64 | + $this->store_data('give_temp_recount_income', $total); |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | - $accepted_statuses = apply_filters( 'give_recount_accepted_statuses', array( 'publish' ) ); |
|
| 67 | + $accepted_statuses = apply_filters('give_recount_accepted_statuses', array('publish')); |
|
| 68 | 68 | |
| 69 | - $args = apply_filters( 'give_recount_income_args', array( |
|
| 69 | + $args = apply_filters('give_recount_income_args', array( |
|
| 70 | 70 | 'number' => $this->per_step, |
| 71 | 71 | 'page' => $this->step, |
| 72 | 72 | 'status' => $accepted_statuses, |
| 73 | 73 | 'fields' => 'ids' |
| 74 | - ) ); |
|
| 74 | + )); |
|
| 75 | 75 | |
| 76 | - $payments = give_get_payments( $args ); |
|
| 76 | + $payments = give_get_payments($args); |
|
| 77 | 77 | |
| 78 | - if ( ! empty( $payments ) ) { |
|
| 78 | + if ( ! empty($payments)) { |
|
| 79 | 79 | |
| 80 | - foreach ( $payments as $payment ) { |
|
| 80 | + foreach ($payments as $payment) { |
|
| 81 | 81 | |
| 82 | - $total += give_get_payment_amount( $payment ); |
|
| 82 | + $total += give_get_payment_amount($payment); |
|
| 83 | 83 | |
| 84 | 84 | } |
| 85 | 85 | |
| 86 | - if ( $total < 0 ) { |
|
| 86 | + if ($total < 0) { |
|
| 87 | 87 | $totals = 0; |
| 88 | 88 | } |
| 89 | 89 | |
| 90 | - $total = round( $total, give_currency_decimal_filter() ); |
|
| 90 | + $total = round($total, give_currency_decimal_filter()); |
|
| 91 | 91 | |
| 92 | - $this->store_data( 'give_temp_recount_income', $total ); |
|
| 92 | + $this->store_data('give_temp_recount_income', $total); |
|
| 93 | 93 | |
| 94 | 94 | return true; |
| 95 | 95 | |
| 96 | 96 | } |
| 97 | 97 | |
| 98 | - update_option( 'give_income_total', $total ); |
|
| 99 | - set_transient( 'give_income_total', $total, 86400 ); |
|
| 98 | + update_option('give_income_total', $total); |
|
| 99 | + set_transient('give_income_total', $total, 86400); |
|
| 100 | 100 | |
| 101 | 101 | return false; |
| 102 | 102 | |
@@ -110,25 +110,25 @@ discard block |
||
| 110 | 110 | */ |
| 111 | 111 | public function get_percentage_complete() { |
| 112 | 112 | |
| 113 | - $total = $this->get_stored_data( 'give_recount_income_total' ); |
|
| 113 | + $total = $this->get_stored_data('give_recount_income_total'); |
|
| 114 | 114 | |
| 115 | - if ( false === $total ) { |
|
| 116 | - $args = apply_filters( 'give_recount_income_total_args', array() ); |
|
| 115 | + if (false === $total) { |
|
| 116 | + $args = apply_filters('give_recount_income_total_args', array()); |
|
| 117 | 117 | |
| 118 | - $counts = give_count_payments( $args ); |
|
| 119 | - $total = absint( $counts->publish ); |
|
| 120 | - $total = apply_filters( 'give_recount_store_income_total', $total ); |
|
| 118 | + $counts = give_count_payments($args); |
|
| 119 | + $total = absint($counts->publish); |
|
| 120 | + $total = apply_filters('give_recount_store_income_total', $total); |
|
| 121 | 121 | |
| 122 | - $this->store_data( 'give_recount_income_total', $total ); |
|
| 122 | + $this->store_data('give_recount_income_total', $total); |
|
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | $percentage = 100; |
| 126 | 126 | |
| 127 | - if ( $total > 0 ) { |
|
| 128 | - $percentage = ( ( $this->per_step * $this->step ) / $total ) * 100; |
|
| 127 | + if ($total > 0) { |
|
| 128 | + $percentage = (($this->per_step * $this->step) / $total) * 100; |
|
| 129 | 129 | } |
| 130 | 130 | |
| 131 | - if ( $percentage > 100 ) { |
|
| 131 | + if ($percentage > 100) { |
|
| 132 | 132 | $percentage = 100; |
| 133 | 133 | } |
| 134 | 134 | |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | * |
| 143 | 143 | * @param array $request The Form Data passed into the batch processing |
| 144 | 144 | */ |
| 145 | - public function set_properties( $request ) { |
|
| 145 | + public function set_properties($request) { |
|
| 146 | 146 | } |
| 147 | 147 | |
| 148 | 148 | /** |
@@ -153,31 +153,31 @@ discard block |
||
| 153 | 153 | */ |
| 154 | 154 | public function process_step() { |
| 155 | 155 | |
| 156 | - if ( ! $this->can_export() ) { |
|
| 157 | - wp_die( esc_html__( 'You do not have permission to recount stats.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
| 156 | + if ( ! $this->can_export()) { |
|
| 157 | + wp_die(esc_html__('You do not have permission to recount stats.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
| 158 | 158 | } |
| 159 | 159 | |
| 160 | 160 | $had_data = $this->get_data(); |
| 161 | 161 | |
| 162 | - if ( $had_data ) { |
|
| 162 | + if ($had_data) { |
|
| 163 | 163 | $this->done = false; |
| 164 | 164 | |
| 165 | 165 | return true; |
| 166 | 166 | } else { |
| 167 | - $this->delete_data( 'give_recount_income_total' ); |
|
| 168 | - $this->delete_data( 'give_temp_recount_income' ); |
|
| 167 | + $this->delete_data('give_recount_income_total'); |
|
| 168 | + $this->delete_data('give_temp_recount_income'); |
|
| 169 | 169 | $this->done = true; |
| 170 | - $this->message = esc_html__( 'Income stats have been successfully recounted.', 'give' ); |
|
| 170 | + $this->message = esc_html__('Income stats have been successfully recounted.', 'give'); |
|
| 171 | 171 | |
| 172 | 172 | return false; |
| 173 | 173 | } |
| 174 | 174 | } |
| 175 | 175 | |
| 176 | 176 | public function headers() { |
| 177 | - ignore_user_abort( true ); |
|
| 177 | + ignore_user_abort(true); |
|
| 178 | 178 | |
| 179 | - if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) { |
|
| 180 | - set_time_limit( 0 ); |
|
| 179 | + if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) { |
|
| 180 | + set_time_limit(0); |
|
| 181 | 181 | } |
| 182 | 182 | } |
| 183 | 183 | |
@@ -205,11 +205,11 @@ discard block |
||
| 205 | 205 | * |
| 206 | 206 | * @return mixed Returns the data from the database |
| 207 | 207 | */ |
| 208 | - private function get_stored_data( $key ) { |
|
| 208 | + private function get_stored_data($key) { |
|
| 209 | 209 | global $wpdb; |
| 210 | - $value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) ); |
|
| 210 | + $value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key)); |
|
| 211 | 211 | |
| 212 | - return empty( $value ) ? false : maybe_unserialize( $value ); |
|
| 212 | + return empty($value) ? false : maybe_unserialize($value); |
|
| 213 | 213 | } |
| 214 | 214 | |
| 215 | 215 | /** |
@@ -222,10 +222,10 @@ discard block |
||
| 222 | 222 | * |
| 223 | 223 | * @return void |
| 224 | 224 | */ |
| 225 | - private function store_data( $key, $value ) { |
|
| 225 | + private function store_data($key, $value) { |
|
| 226 | 226 | global $wpdb; |
| 227 | 227 | |
| 228 | - $value = maybe_serialize( $value ); |
|
| 228 | + $value = maybe_serialize($value); |
|
| 229 | 229 | |
| 230 | 230 | $data = array( |
| 231 | 231 | 'option_name' => $key, |
@@ -239,7 +239,7 @@ discard block |
||
| 239 | 239 | '%s', |
| 240 | 240 | ); |
| 241 | 241 | |
| 242 | - $wpdb->replace( $wpdb->options, $data, $formats ); |
|
| 242 | + $wpdb->replace($wpdb->options, $data, $formats); |
|
| 243 | 243 | } |
| 244 | 244 | |
| 245 | 245 | /** |
@@ -251,9 +251,9 @@ discard block |
||
| 251 | 251 | * |
| 252 | 252 | * @return void |
| 253 | 253 | */ |
| 254 | - private function delete_data( $key ) { |
|
| 254 | + private function delete_data($key) { |
|
| 255 | 255 | global $wpdb; |
| 256 | - $wpdb->delete( $wpdb->options, array( 'option_name' => $key ) ); |
|
| 256 | + $wpdb->delete($wpdb->options, array('option_name' => $key)); |
|
| 257 | 257 | } |
| 258 | 258 | |
| 259 | 259 | } |
@@ -49,7 +49,7 @@ |
||
| 49 | 49 | * @access public |
| 50 | 50 | * @since 1.5 |
| 51 | 51 | * |
| 52 | - * @return array $data The data for the CSV file |
|
| 52 | + * @return boolean $data The data for the CSV file |
|
| 53 | 53 | */ |
| 54 | 54 | public function get_data() { |
| 55 | 55 | |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | */ |
| 12 | 12 | |
| 13 | 13 | // Exit if accessed directly. |
| 14 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 14 | +if ( ! defined('ABSPATH')) { |
|
| 15 | 15 | exit; |
| 16 | 16 | } |
| 17 | 17 | |
@@ -58,16 +58,16 @@ discard block |
||
| 58 | 58 | public function get_data() { |
| 59 | 59 | global $wpdb; |
| 60 | 60 | |
| 61 | - $items = $this->get_stored_data( 'give_temp_reset_ids' ); |
|
| 61 | + $items = $this->get_stored_data('give_temp_reset_ids'); |
|
| 62 | 62 | |
| 63 | - if ( ! is_array( $items ) ) { |
|
| 63 | + if ( ! is_array($items)) { |
|
| 64 | 64 | return false; |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | - $offset = ( $this->step - 1 ) * $this->per_step; |
|
| 68 | - $step_items = array_slice( $items, $offset, $this->per_step ); |
|
| 67 | + $offset = ($this->step - 1) * $this->per_step; |
|
| 68 | + $step_items = array_slice($items, $offset, $this->per_step); |
|
| 69 | 69 | |
| 70 | - if ( $step_items ) { |
|
| 70 | + if ($step_items) { |
|
| 71 | 71 | |
| 72 | 72 | $step_ids = array( |
| 73 | 73 | 'customers' => array(), |
@@ -75,9 +75,9 @@ discard block |
||
| 75 | 75 | 'other' => array(), |
| 76 | 76 | ); |
| 77 | 77 | |
| 78 | - foreach ( $step_items as $item ) { |
|
| 78 | + foreach ($step_items as $item) { |
|
| 79 | 79 | |
| 80 | - switch ( $item['type'] ) { |
|
| 80 | + switch ($item['type']) { |
|
| 81 | 81 | case 'customer': |
| 82 | 82 | $step_ids['customers'][] = $item['id']; |
| 83 | 83 | break; |
@@ -85,25 +85,25 @@ discard block |
||
| 85 | 85 | $step_ids['give_forms'][] = $item['id']; |
| 86 | 86 | break; |
| 87 | 87 | default: |
| 88 | - $item_type = apply_filters( 'give_reset_item_type', 'other', $item ); |
|
| 89 | - $step_ids[ $item_type ][] = $item['id']; |
|
| 88 | + $item_type = apply_filters('give_reset_item_type', 'other', $item); |
|
| 89 | + $step_ids[$item_type][] = $item['id']; |
|
| 90 | 90 | break; |
| 91 | 91 | } |
| 92 | 92 | } |
| 93 | 93 | |
| 94 | 94 | $sql = array(); |
| 95 | 95 | |
| 96 | - foreach ( $step_ids as $type => $ids ) { |
|
| 96 | + foreach ($step_ids as $type => $ids) { |
|
| 97 | 97 | |
| 98 | - if ( empty( $ids ) ) { |
|
| 98 | + if (empty($ids)) { |
|
| 99 | 99 | continue; |
| 100 | 100 | } |
| 101 | 101 | |
| 102 | - $ids = implode( ',', $ids ); |
|
| 102 | + $ids = implode(',', $ids); |
|
| 103 | 103 | |
| 104 | - switch ( $type ) { |
|
| 104 | + switch ($type) { |
|
| 105 | 105 | case 'customers': |
| 106 | - $table_name = $wpdb->prefix . 'give_customers'; |
|
| 106 | + $table_name = $wpdb->prefix.'give_customers'; |
|
| 107 | 107 | $sql[] = "DELETE FROM $table_name WHERE id IN ($ids)"; |
| 108 | 108 | break; |
| 109 | 109 | case 'forms': |
@@ -118,16 +118,16 @@ discard block |
||
| 118 | 118 | break; |
| 119 | 119 | } |
| 120 | 120 | |
| 121 | - if ( ! in_array( $type, array( 'customers', 'forms', 'other' ) ) ) { |
|
| 121 | + if ( ! in_array($type, array('customers', 'forms', 'other'))) { |
|
| 122 | 122 | // Allows other types of custom post types to filter on their own post_type |
| 123 | 123 | // and add items to the query list, for the IDs found in their post type. |
| 124 | - $sql = apply_filters( "give_reset_add_queries_{$type}", $sql, $ids ); |
|
| 124 | + $sql = apply_filters("give_reset_add_queries_{$type}", $sql, $ids); |
|
| 125 | 125 | } |
| 126 | 126 | } |
| 127 | 127 | |
| 128 | - if ( ! empty( $sql ) ) { |
|
| 129 | - foreach ( $sql as $query ) { |
|
| 130 | - $wpdb->query( $query ); |
|
| 128 | + if ( ! empty($sql)) { |
|
| 129 | + foreach ($sql as $query) { |
|
| 130 | + $wpdb->query($query); |
|
| 131 | 131 | } |
| 132 | 132 | } |
| 133 | 133 | |
@@ -147,16 +147,16 @@ discard block |
||
| 147 | 147 | */ |
| 148 | 148 | public function get_percentage_complete() { |
| 149 | 149 | |
| 150 | - $items = $this->get_stored_data( 'give_temp_reset_ids', false ); |
|
| 151 | - $total = count( $items ); |
|
| 150 | + $items = $this->get_stored_data('give_temp_reset_ids', false); |
|
| 151 | + $total = count($items); |
|
| 152 | 152 | |
| 153 | 153 | $percentage = 100; |
| 154 | 154 | |
| 155 | - if ( $total > 0 ) { |
|
| 156 | - $percentage = ( ( $this->per_step * $this->step ) / $total ) * 100; |
|
| 155 | + if ($total > 0) { |
|
| 156 | + $percentage = (($this->per_step * $this->step) / $total) * 100; |
|
| 157 | 157 | } |
| 158 | 158 | |
| 159 | - if ( $percentage > 100 ) { |
|
| 159 | + if ($percentage > 100) { |
|
| 160 | 160 | $percentage = 100; |
| 161 | 161 | } |
| 162 | 162 | |
@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | * |
| 171 | 171 | * @param array $request The Form Data passed into the batch processing |
| 172 | 172 | */ |
| 173 | - public function set_properties( $request ) { |
|
| 173 | + public function set_properties($request) { |
|
| 174 | 174 | } |
| 175 | 175 | |
| 176 | 176 | /** |
@@ -181,30 +181,30 @@ discard block |
||
| 181 | 181 | */ |
| 182 | 182 | public function process_step() { |
| 183 | 183 | |
| 184 | - if ( ! $this->can_export() ) { |
|
| 185 | - wp_die( esc_html__( 'You do not have permission to reset data.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
| 184 | + if ( ! $this->can_export()) { |
|
| 185 | + wp_die(esc_html__('You do not have permission to reset data.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
| 186 | 186 | } |
| 187 | 187 | |
| 188 | 188 | $had_data = $this->get_data(); |
| 189 | 189 | |
| 190 | - if ( $had_data ) { |
|
| 190 | + if ($had_data) { |
|
| 191 | 191 | $this->done = false; |
| 192 | 192 | |
| 193 | 193 | return true; |
| 194 | 194 | } else { |
| 195 | - update_option( 'give_earnings_total', 0 ); |
|
| 196 | - delete_transient( 'give_earnings_total' ); |
|
| 197 | - delete_transient( 'give_estimated_monthly_stats' . true ); |
|
| 198 | - delete_transient( 'give_estimated_monthly_stats' . false ); |
|
| 199 | - $this->delete_data( 'give_temp_reset_ids' ); |
|
| 195 | + update_option('give_earnings_total', 0); |
|
| 196 | + delete_transient('give_earnings_total'); |
|
| 197 | + delete_transient('give_estimated_monthly_stats'.true); |
|
| 198 | + delete_transient('give_estimated_monthly_stats'.false); |
|
| 199 | + $this->delete_data('give_temp_reset_ids'); |
|
| 200 | 200 | |
| 201 | 201 | // Reset the sequential order numbers |
| 202 | - if ( give_get_option( 'enable_sequential' ) ) { |
|
| 203 | - delete_option( 'give_last_payment_number' ); |
|
| 202 | + if (give_get_option('enable_sequential')) { |
|
| 203 | + delete_option('give_last_payment_number'); |
|
| 204 | 204 | } |
| 205 | 205 | |
| 206 | 206 | $this->done = true; |
| 207 | - $this->message = esc_html__( 'Donation forms, income, donations counts, and logs successfully reset.', 'give' ); |
|
| 207 | + $this->message = esc_html__('Donation forms, income, donations counts, and logs successfully reset.', 'give'); |
|
| 208 | 208 | |
| 209 | 209 | return false; |
| 210 | 210 | } |
@@ -214,10 +214,10 @@ discard block |
||
| 214 | 214 | * Headers |
| 215 | 215 | */ |
| 216 | 216 | public function headers() { |
| 217 | - ignore_user_abort( true ); |
|
| 217 | + ignore_user_abort(true); |
|
| 218 | 218 | |
| 219 | - if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) { |
|
| 220 | - set_time_limit( 0 ); |
|
| 219 | + if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) { |
|
| 220 | + set_time_limit(0); |
|
| 221 | 221 | } |
| 222 | 222 | } |
| 223 | 223 | |
@@ -241,35 +241,35 @@ discard block |
||
| 241 | 241 | */ |
| 242 | 242 | public function pre_fetch() { |
| 243 | 243 | |
| 244 | - if ( $this->step == 1 ) { |
|
| 245 | - $this->delete_data( 'give_temp_reset_ids' ); |
|
| 244 | + if ($this->step == 1) { |
|
| 245 | + $this->delete_data('give_temp_reset_ids'); |
|
| 246 | 246 | } |
| 247 | 247 | |
| 248 | - $items = get_option( 'give_temp_reset_ids', false ); |
|
| 248 | + $items = get_option('give_temp_reset_ids', false); |
|
| 249 | 249 | |
| 250 | - if ( false === $items ) { |
|
| 250 | + if (false === $items) { |
|
| 251 | 251 | $items = array(); |
| 252 | 252 | |
| 253 | - $give_types_for_reset = array( 'give_forms', 'give_log', 'give_payment' ); |
|
| 254 | - $give_types_for_reset = apply_filters( 'give_reset_store_post_types', $give_types_for_reset ); |
|
| 253 | + $give_types_for_reset = array('give_forms', 'give_log', 'give_payment'); |
|
| 254 | + $give_types_for_reset = apply_filters('give_reset_store_post_types', $give_types_for_reset); |
|
| 255 | 255 | |
| 256 | - $args = apply_filters( 'give_tools_reset_stats_total_args', array( |
|
| 256 | + $args = apply_filters('give_tools_reset_stats_total_args', array( |
|
| 257 | 257 | 'post_type' => $give_types_for_reset, |
| 258 | 258 | 'post_status' => 'any', |
| 259 | - 'posts_per_page' => - 1, |
|
| 260 | - ) ); |
|
| 259 | + 'posts_per_page' => -1, |
|
| 260 | + )); |
|
| 261 | 261 | |
| 262 | - $posts = get_posts( $args ); |
|
| 263 | - foreach ( $posts as $post ) { |
|
| 262 | + $posts = get_posts($args); |
|
| 263 | + foreach ($posts as $post) { |
|
| 264 | 264 | $items[] = array( |
| 265 | 265 | 'id' => (int) $post->ID, |
| 266 | 266 | 'type' => $post->post_type, |
| 267 | 267 | ); |
| 268 | 268 | } |
| 269 | 269 | |
| 270 | - $customer_args = array( 'number' => - 1 ); |
|
| 271 | - $customers = Give()->customers->get_customers( $customer_args ); |
|
| 272 | - foreach ( $customers as $customer ) { |
|
| 270 | + $customer_args = array('number' => -1); |
|
| 271 | + $customers = Give()->customers->get_customers($customer_args); |
|
| 272 | + foreach ($customers as $customer) { |
|
| 273 | 273 | $items[] = array( |
| 274 | 274 | 'id' => (int) $customer->id, |
| 275 | 275 | 'type' => 'customer', |
@@ -278,9 +278,9 @@ discard block |
||
| 278 | 278 | |
| 279 | 279 | // Allow filtering of items to remove with an unassociative array for each item |
| 280 | 280 | // The array contains the unique ID of the item, and a 'type' for you to use in the execution of the get_data method |
| 281 | - $items = apply_filters( 'give_reset_items', $items ); |
|
| 281 | + $items = apply_filters('give_reset_items', $items); |
|
| 282 | 282 | |
| 283 | - $this->store_data( 'give_temp_reset_ids', $items ); |
|
| 283 | + $this->store_data('give_temp_reset_ids', $items); |
|
| 284 | 284 | } |
| 285 | 285 | |
| 286 | 286 | } |
@@ -294,11 +294,11 @@ discard block |
||
| 294 | 294 | * |
| 295 | 295 | * @return mixed Returns the data from the database. |
| 296 | 296 | */ |
| 297 | - private function get_stored_data( $key ) { |
|
| 297 | + private function get_stored_data($key) { |
|
| 298 | 298 | global $wpdb; |
| 299 | - $value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) ); |
|
| 299 | + $value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key)); |
|
| 300 | 300 | |
| 301 | - return empty( $value ) ? false : maybe_unserialize( $value ); |
|
| 301 | + return empty($value) ? false : maybe_unserialize($value); |
|
| 302 | 302 | } |
| 303 | 303 | |
| 304 | 304 | /** |
@@ -311,10 +311,10 @@ discard block |
||
| 311 | 311 | * |
| 312 | 312 | * @return void |
| 313 | 313 | */ |
| 314 | - private function store_data( $key, $value ) { |
|
| 314 | + private function store_data($key, $value) { |
|
| 315 | 315 | global $wpdb; |
| 316 | 316 | |
| 317 | - $value = maybe_serialize( $value ); |
|
| 317 | + $value = maybe_serialize($value); |
|
| 318 | 318 | |
| 319 | 319 | $data = array( |
| 320 | 320 | 'option_name' => $key, |
@@ -328,7 +328,7 @@ discard block |
||
| 328 | 328 | '%s', |
| 329 | 329 | ); |
| 330 | 330 | |
| 331 | - $wpdb->replace( $wpdb->options, $data, $formats ); |
|
| 331 | + $wpdb->replace($wpdb->options, $data, $formats); |
|
| 332 | 332 | } |
| 333 | 333 | |
| 334 | 334 | /** |
@@ -340,9 +340,9 @@ discard block |
||
| 340 | 340 | * |
| 341 | 341 | * @return void |
| 342 | 342 | */ |
| 343 | - private function delete_data( $key ) { |
|
| 343 | + private function delete_data($key) { |
|
| 344 | 344 | global $wpdb; |
| 345 | - $wpdb->delete( $wpdb->options, array( 'option_name' => $key ) ); |
|
| 345 | + $wpdb->delete($wpdb->options, array('option_name' => $key)); |
|
| 346 | 346 | } |
| 347 | 347 | |
| 348 | 348 | } |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | // Exit if accessed directly.. |
| 13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 13 | +if ( ! defined('ABSPATH')) { |
|
| 14 | 14 | exit; |
| 15 | 15 | } |
| 16 | 16 | |
@@ -25,82 +25,82 @@ discard block |
||
| 25 | 25 | * |
| 26 | 26 | * @uses give_pdf |
| 27 | 27 | */ |
| 28 | -function give_generate_pdf( $data ) { |
|
| 28 | +function give_generate_pdf($data) { |
|
| 29 | 29 | |
| 30 | - if ( ! current_user_can( 'view_give_reports' ) ) { |
|
| 31 | - wp_die( esc_html__( 'You do not have permission to generate PDF sales reports.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
| 30 | + if ( ! current_user_can('view_give_reports')) { |
|
| 31 | + wp_die(esc_html__('You do not have permission to generate PDF sales reports.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
| 32 | 32 | } |
| 33 | 33 | |
| 34 | - if ( ! wp_verify_nonce( $_GET['_wpnonce'], 'give_generate_pdf' ) ) { |
|
| 35 | - wp_die( esc_html__( 'Nonce verification failed.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
| 34 | + if ( ! wp_verify_nonce($_GET['_wpnonce'], 'give_generate_pdf')) { |
|
| 35 | + wp_die(esc_html__('Nonce verification failed.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
| 36 | 36 | } |
| 37 | 37 | |
| 38 | - require_once GIVE_PLUGIN_DIR . '/includes/libraries/fpdf/fpdf.php'; |
|
| 39 | - require_once GIVE_PLUGIN_DIR . '/includes/libraries/fpdf/give_pdf.php'; |
|
| 38 | + require_once GIVE_PLUGIN_DIR.'/includes/libraries/fpdf/fpdf.php'; |
|
| 39 | + require_once GIVE_PLUGIN_DIR.'/includes/libraries/fpdf/give_pdf.php'; |
|
| 40 | 40 | |
| 41 | 41 | $daterange = utf8_decode( |
| 42 | 42 | sprintf( |
| 43 | 43 | /* translators: 1: start date 2: end date */ |
| 44 | - esc_html__( '%1$s to %2$s', 'give' ), |
|
| 45 | - date_i18n( give_date_format(), mktime( 0, 0, 0, 1, 1, date( 'Y' ) ) ), |
|
| 46 | - date_i18n( give_date_format() ) |
|
| 44 | + esc_html__('%1$s to %2$s', 'give'), |
|
| 45 | + date_i18n(give_date_format(), mktime(0, 0, 0, 1, 1, date('Y'))), |
|
| 46 | + date_i18n(give_date_format()) |
|
| 47 | 47 | ) |
| 48 | 48 | ); |
| 49 | 49 | |
| 50 | 50 | $pdf = new give_pdf(); |
| 51 | - $pdf->AddPage( 'L', 'A4' ); |
|
| 51 | + $pdf->AddPage('L', 'A4'); |
|
| 52 | 52 | |
| 53 | - $pdf->SetTitle( utf8_decode( __( 'Donation report for the current year for all forms', 'give' ) ) ); |
|
| 54 | - $pdf->SetAuthor( utf8_decode( __( 'Give - Democratizing Generosity', 'give' ) ) ); |
|
| 55 | - $pdf->SetCreator( utf8_decode( __( 'Give - Democratizing Generosity', 'give' ) ) ); |
|
| 53 | + $pdf->SetTitle(utf8_decode(__('Donation report for the current year for all forms', 'give'))); |
|
| 54 | + $pdf->SetAuthor(utf8_decode(__('Give - Democratizing Generosity', 'give'))); |
|
| 55 | + $pdf->SetCreator(utf8_decode(__('Give - Democratizing Generosity', 'give'))); |
|
| 56 | 56 | |
| 57 | - $pdf->Image( apply_filters( 'give_pdf_export_logo', GIVE_PLUGIN_URL . 'assets/images/give-logo-small.png' ), 247, 8 ); |
|
| 57 | + $pdf->Image(apply_filters('give_pdf_export_logo', GIVE_PLUGIN_URL.'assets/images/give-logo-small.png'), 247, 8); |
|
| 58 | 58 | |
| 59 | - $pdf->SetMargins( 8, 8, 8 ); |
|
| 60 | - $pdf->SetX( 8 ); |
|
| 59 | + $pdf->SetMargins(8, 8, 8); |
|
| 60 | + $pdf->SetX(8); |
|
| 61 | 61 | |
| 62 | - $pdf->SetFont( 'Helvetica', '', 16 ); |
|
| 63 | - $pdf->SetTextColor( 50, 50, 50 ); |
|
| 64 | - $pdf->Cell( 0, 3, utf8_decode( __( 'Donation report for the current year for all forms', 'give' ) ), 0, 2, 'L', false ); |
|
| 62 | + $pdf->SetFont('Helvetica', '', 16); |
|
| 63 | + $pdf->SetTextColor(50, 50, 50); |
|
| 64 | + $pdf->Cell(0, 3, utf8_decode(__('Donation report for the current year for all forms', 'give')), 0, 2, 'L', false); |
|
| 65 | 65 | |
| 66 | - $pdf->SetFont( 'Helvetica', '', 13 ); |
|
| 66 | + $pdf->SetFont('Helvetica', '', 13); |
|
| 67 | 67 | $pdf->Ln(); |
| 68 | - $pdf->SetTextColor( 150, 150, 150 ); |
|
| 69 | - $pdf->Cell( 0, 6, utf8_decode( __( 'Date Range: ', 'give' ) ) . $daterange, 0, 2, 'L', false ); |
|
| 68 | + $pdf->SetTextColor(150, 150, 150); |
|
| 69 | + $pdf->Cell(0, 6, utf8_decode(__('Date Range: ', 'give')).$daterange, 0, 2, 'L', false); |
|
| 70 | 70 | $pdf->Ln(); |
| 71 | - $pdf->SetTextColor( 50, 50, 50 ); |
|
| 72 | - $pdf->SetFont( 'Helvetica', '', 14 ); |
|
| 73 | - $pdf->Cell( 0, 10, utf8_decode( __( 'Table View', 'give' ) ), 0, 2, 'L', false ); |
|
| 74 | - $pdf->SetFont( 'Helvetica', '', 12 ); |
|
| 71 | + $pdf->SetTextColor(50, 50, 50); |
|
| 72 | + $pdf->SetFont('Helvetica', '', 14); |
|
| 73 | + $pdf->Cell(0, 10, utf8_decode(__('Table View', 'give')), 0, 2, 'L', false); |
|
| 74 | + $pdf->SetFont('Helvetica', '', 12); |
|
| 75 | 75 | |
| 76 | - $pdf->SetFillColor( 238, 238, 238 ); |
|
| 77 | - $pdf->Cell( 70, 6, utf8_decode( __( 'Form Name', 'give' ) ), 1, 0, 'L', true ); |
|
| 78 | - $pdf->Cell( 30, 6, utf8_decode( __( 'Price', 'give' ) ), 1, 0, 'L', true ); |
|
| 79 | - $pdf->Cell( 50, 6, utf8_decode( __( 'Categories', 'give' ) ), 1, 0, 'L', true ); |
|
| 80 | - $pdf->Cell( 50, 6, utf8_decode( __( 'Tags', 'give' ) ), 1, 0, 'L', true ); |
|
| 81 | - $pdf->Cell( 45, 6, utf8_decode( __( 'Number of Donations', 'give' ) ), 1, 0, 'L', true ); |
|
| 82 | - $pdf->Cell( 35, 6, utf8_decode( __( 'Income to Date', 'give' ) ), 1, 1, 'L', true ); |
|
| 76 | + $pdf->SetFillColor(238, 238, 238); |
|
| 77 | + $pdf->Cell(70, 6, utf8_decode(__('Form Name', 'give')), 1, 0, 'L', true); |
|
| 78 | + $pdf->Cell(30, 6, utf8_decode(__('Price', 'give')), 1, 0, 'L', true); |
|
| 79 | + $pdf->Cell(50, 6, utf8_decode(__('Categories', 'give')), 1, 0, 'L', true); |
|
| 80 | + $pdf->Cell(50, 6, utf8_decode(__('Tags', 'give')), 1, 0, 'L', true); |
|
| 81 | + $pdf->Cell(45, 6, utf8_decode(__('Number of Donations', 'give')), 1, 0, 'L', true); |
|
| 82 | + $pdf->Cell(35, 6, utf8_decode(__('Income to Date', 'give')), 1, 1, 'L', true); |
|
| 83 | 83 | |
| 84 | - $year = date( 'Y' ); |
|
| 85 | - $give_forms = get_posts( array( 'post_type' => 'give_forms', 'year' => $year, 'posts_per_page' => - 1 ) ); |
|
| 84 | + $year = date('Y'); |
|
| 85 | + $give_forms = get_posts(array('post_type' => 'give_forms', 'year' => $year, 'posts_per_page' => -1)); |
|
| 86 | 86 | |
| 87 | - if ( $give_forms ) { |
|
| 88 | - $pdf->SetWidths( array( 70, 30, 50, 50, 45, 35 ) ); |
|
| 87 | + if ($give_forms) { |
|
| 88 | + $pdf->SetWidths(array(70, 30, 50, 50, 45, 35)); |
|
| 89 | 89 | |
| 90 | - foreach ( $give_forms as $form ): |
|
| 91 | - $pdf->SetFillColor( 255, 255, 255 ); |
|
| 90 | + foreach ($give_forms as $form): |
|
| 91 | + $pdf->SetFillColor(255, 255, 255); |
|
| 92 | 92 | |
| 93 | 93 | $title = $form->post_title; |
| 94 | 94 | |
| 95 | - if ( give_has_variable_prices( $form->ID ) ) { |
|
| 95 | + if (give_has_variable_prices($form->ID)) { |
|
| 96 | 96 | |
| 97 | - $prices = give_get_variable_prices( $form->ID ); |
|
| 97 | + $prices = give_get_variable_prices($form->ID); |
|
| 98 | 98 | |
| 99 | 99 | $first = $prices[0]['_give_amount']; |
| 100 | - $last = array_pop( $prices ); |
|
| 100 | + $last = array_pop($prices); |
|
| 101 | 101 | $last = $last['_give_amount']; |
| 102 | 102 | |
| 103 | - if ( $first < $last ) { |
|
| 103 | + if ($first < $last) { |
|
| 104 | 104 | $min = $first; |
| 105 | 105 | $max = $last; |
| 106 | 106 | } else { |
@@ -108,51 +108,51 @@ discard block |
||
| 108 | 108 | $max = $first; |
| 109 | 109 | } |
| 110 | 110 | |
| 111 | - $price = html_entity_decode( give_currency_filter( give_format_amount( $min ) ) . ' - ' . give_currency_filter( give_format_amount( $max ) ) ); |
|
| 111 | + $price = html_entity_decode(give_currency_filter(give_format_amount($min)).' - '.give_currency_filter(give_format_amount($max))); |
|
| 112 | 112 | } else { |
| 113 | - $price = html_entity_decode( give_currency_filter( give_get_form_price( $form->ID ) ) ); |
|
| 113 | + $price = html_entity_decode(give_currency_filter(give_get_form_price($form->ID))); |
|
| 114 | 114 | } |
| 115 | 115 | |
| 116 | - $categories = get_the_term_list( $form->ID, 'give_forms_category', '', ', ', '' ); |
|
| 117 | - $categories = ! is_wp_error( $categories ) ? strip_tags( $categories ) : ''; |
|
| 116 | + $categories = get_the_term_list($form->ID, 'give_forms_category', '', ', ', ''); |
|
| 117 | + $categories = ! is_wp_error($categories) ? strip_tags($categories) : ''; |
|
| 118 | 118 | |
| 119 | - $tags = get_the_term_list( $form->ID, 'give_forms_tag', '', ', ', '' ); |
|
| 120 | - $tags = ! is_wp_error( $tags ) ? strip_tags( $tags ) : ''; |
|
| 119 | + $tags = get_the_term_list($form->ID, 'give_forms_tag', '', ', ', ''); |
|
| 120 | + $tags = ! is_wp_error($tags) ? strip_tags($tags) : ''; |
|
| 121 | 121 | |
| 122 | - $sales = give_get_form_sales_stats( $form->ID ); |
|
| 123 | - $link = get_permalink( $form->ID ); |
|
| 124 | - $earnings = html_entity_decode( give_currency_filter( give_get_form_earnings_stats( $form->ID ) ) ); |
|
| 122 | + $sales = give_get_form_sales_stats($form->ID); |
|
| 123 | + $link = get_permalink($form->ID); |
|
| 124 | + $earnings = html_entity_decode(give_currency_filter(give_get_form_earnings_stats($form->ID))); |
|
| 125 | 125 | |
| 126 | - if ( function_exists( 'iconv' ) ) { |
|
| 126 | + if (function_exists('iconv')) { |
|
| 127 | 127 | // Ensure characters like euro; are properly converted. |
| 128 | - $price = iconv( 'UTF-8', 'windows-1252', utf8_encode( $price ) ); |
|
| 129 | - $earnings = iconv( 'UTF-8', 'windows-1252', utf8_encode( $earnings ) ); |
|
| 128 | + $price = iconv('UTF-8', 'windows-1252', utf8_encode($price)); |
|
| 129 | + $earnings = iconv('UTF-8', 'windows-1252', utf8_encode($earnings)); |
|
| 130 | 130 | } |
| 131 | 131 | |
| 132 | - $pdf->Row( array( $title, $price, $categories, $tags, $sales, $earnings ) ); |
|
| 132 | + $pdf->Row(array($title, $price, $categories, $tags, $sales, $earnings)); |
|
| 133 | 133 | endforeach; |
| 134 | 134 | } else { |
| 135 | - $pdf->SetWidths( array( 280 ) ); |
|
| 136 | - $title = utf8_decode( esc_html__( 'No forms found.', 'give' ) ); |
|
| 137 | - $pdf->Row( array( $title ) ); |
|
| 135 | + $pdf->SetWidths(array(280)); |
|
| 136 | + $title = utf8_decode(esc_html__('No forms found.', 'give')); |
|
| 137 | + $pdf->Row(array($title)); |
|
| 138 | 138 | } |
| 139 | 139 | |
| 140 | 140 | $pdf->Ln(); |
| 141 | - $pdf->SetTextColor( 50, 50, 50 ); |
|
| 142 | - $pdf->SetFont( 'Helvetica', '', 14 ); |
|
| 143 | - $pdf->Cell( 0, 10, utf8_decode( __( 'Graph View', 'give' ) ), 0, 2, 'L', false ); |
|
| 144 | - $pdf->SetFont( 'Helvetica', '', 12 ); |
|
| 145 | - |
|
| 146 | - $image = html_entity_decode( urldecode( give_draw_chart_image() ) ); |
|
| 147 | - $image = str_replace( ' ', '%20', $image ); |
|
| 148 | - |
|
| 149 | - $pdf->SetX( 25 ); |
|
| 150 | - $pdf->Image( $image . '&file=.png' ); |
|
| 151 | - $pdf->Ln( 7 ); |
|
| 152 | - $pdf->Output( apply_filters( 'give_sales_earnings_pdf_export_filename', 'give-report-' . date_i18n( 'Y-m-d' ) ) . '.pdf', 'D' ); |
|
| 141 | + $pdf->SetTextColor(50, 50, 50); |
|
| 142 | + $pdf->SetFont('Helvetica', '', 14); |
|
| 143 | + $pdf->Cell(0, 10, utf8_decode(__('Graph View', 'give')), 0, 2, 'L', false); |
|
| 144 | + $pdf->SetFont('Helvetica', '', 12); |
|
| 145 | + |
|
| 146 | + $image = html_entity_decode(urldecode(give_draw_chart_image())); |
|
| 147 | + $image = str_replace(' ', '%20', $image); |
|
| 148 | + |
|
| 149 | + $pdf->SetX(25); |
|
| 150 | + $pdf->Image($image.'&file=.png'); |
|
| 151 | + $pdf->Ln(7); |
|
| 152 | + $pdf->Output(apply_filters('give_sales_earnings_pdf_export_filename', 'give-report-'.date_i18n('Y-m-d')).'.pdf', 'D'); |
|
| 153 | 153 | } |
| 154 | 154 | |
| 155 | -add_action( 'give_generate_pdf', 'give_generate_pdf' ); |
|
| 155 | +add_action('give_generate_pdf', 'give_generate_pdf'); |
|
| 156 | 156 | |
| 157 | 157 | /** |
| 158 | 158 | * Draws Chart for PDF Report. |
@@ -169,38 +169,38 @@ discard block |
||
| 169 | 169 | * @return string $chart->getUrl() URL for the Google Chart |
| 170 | 170 | */ |
| 171 | 171 | function give_draw_chart_image() { |
| 172 | - require_once GIVE_PLUGIN_DIR . '/includes/libraries/googlechartlib/GoogleChart.php'; |
|
| 173 | - require_once GIVE_PLUGIN_DIR . '/includes/libraries/googlechartlib/markers/GoogleChartShapeMarker.php'; |
|
| 174 | - require_once GIVE_PLUGIN_DIR . '/includes/libraries/googlechartlib/markers/GoogleChartTextMarker.php'; |
|
| 172 | + require_once GIVE_PLUGIN_DIR.'/includes/libraries/googlechartlib/GoogleChart.php'; |
|
| 173 | + require_once GIVE_PLUGIN_DIR.'/includes/libraries/googlechartlib/markers/GoogleChartShapeMarker.php'; |
|
| 174 | + require_once GIVE_PLUGIN_DIR.'/includes/libraries/googlechartlib/markers/GoogleChartTextMarker.php'; |
|
| 175 | 175 | |
| 176 | - $chart = new GoogleChart( 'lc', 900, 330 ); |
|
| 176 | + $chart = new GoogleChart('lc', 900, 330); |
|
| 177 | 177 | |
| 178 | 178 | $i = 1; |
| 179 | 179 | $earnings = ""; |
| 180 | 180 | $sales = ""; |
| 181 | 181 | |
| 182 | - while ( $i <= 12 ) : |
|
| 183 | - $earnings .= give_get_earnings_by_date( null, $i, date( 'Y' ) ) . ","; |
|
| 184 | - $sales .= give_get_sales_by_date( null, $i, date( 'Y' ) ) . ","; |
|
| 185 | - $i ++; |
|
| 182 | + while ($i <= 12) : |
|
| 183 | + $earnings .= give_get_earnings_by_date(null, $i, date('Y')).","; |
|
| 184 | + $sales .= give_get_sales_by_date(null, $i, date('Y')).","; |
|
| 185 | + $i++; |
|
| 186 | 186 | endwhile; |
| 187 | 187 | |
| 188 | - $earnings_array = explode( ",", $earnings ); |
|
| 189 | - $sales_array = explode( ",", $sales ); |
|
| 188 | + $earnings_array = explode(",", $earnings); |
|
| 189 | + $sales_array = explode(",", $sales); |
|
| 190 | 190 | |
| 191 | 191 | $i = 0; |
| 192 | - while ( $i <= 11 ) { |
|
| 193 | - if ( empty( $sales_array[ $i ] ) ) { |
|
| 194 | - $sales_array[ $i ] = 0; |
|
| 192 | + while ($i <= 11) { |
|
| 193 | + if (empty($sales_array[$i])) { |
|
| 194 | + $sales_array[$i] = 0; |
|
| 195 | 195 | } |
| 196 | - $i ++; |
|
| 196 | + $i++; |
|
| 197 | 197 | } |
| 198 | 198 | |
| 199 | 199 | $min_earnings = 0; |
| 200 | - $max_earnings = max( $earnings_array ); |
|
| 201 | - $earnings_scale = round( $max_earnings, - 1 ); |
|
| 200 | + $max_earnings = max($earnings_array); |
|
| 201 | + $earnings_scale = round($max_earnings, - 1); |
|
| 202 | 202 | |
| 203 | - $data = new GoogleChartData( array( |
|
| 203 | + $data = new GoogleChartData(array( |
|
| 204 | 204 | $earnings_array[0], |
| 205 | 205 | $earnings_array[1], |
| 206 | 206 | $earnings_array[2], |
@@ -213,25 +213,25 @@ discard block |
||
| 213 | 213 | $earnings_array[9], |
| 214 | 214 | $earnings_array[10], |
| 215 | 215 | $earnings_array[11] |
| 216 | - ) ); |
|
| 216 | + )); |
|
| 217 | 217 | |
| 218 | - $data->setLegend( esc_html__( 'Income', 'give' ) ); |
|
| 219 | - $data->setColor( '1b58a3' ); |
|
| 220 | - $chart->addData( $data ); |
|
| 218 | + $data->setLegend(esc_html__('Income', 'give')); |
|
| 219 | + $data->setColor('1b58a3'); |
|
| 220 | + $chart->addData($data); |
|
| 221 | 221 | |
| 222 | - $shape_marker = new GoogleChartShapeMarker( GoogleChartShapeMarker::CIRCLE ); |
|
| 223 | - $shape_marker->setColor( '000000' ); |
|
| 224 | - $shape_marker->setSize( 7 ); |
|
| 225 | - $shape_marker->setBorder( 2 ); |
|
| 226 | - $shape_marker->setData( $data ); |
|
| 227 | - $chart->addMarker( $shape_marker ); |
|
| 222 | + $shape_marker = new GoogleChartShapeMarker(GoogleChartShapeMarker::CIRCLE); |
|
| 223 | + $shape_marker->setColor('000000'); |
|
| 224 | + $shape_marker->setSize(7); |
|
| 225 | + $shape_marker->setBorder(2); |
|
| 226 | + $shape_marker->setData($data); |
|
| 227 | + $chart->addMarker($shape_marker); |
|
| 228 | 228 | |
| 229 | - $value_marker = new GoogleChartTextMarker( GoogleChartTextMarker::VALUE ); |
|
| 230 | - $value_marker->setColor( '000000' ); |
|
| 231 | - $value_marker->setData( $data ); |
|
| 232 | - $chart->addMarker( $value_marker ); |
|
| 229 | + $value_marker = new GoogleChartTextMarker(GoogleChartTextMarker::VALUE); |
|
| 230 | + $value_marker->setColor('000000'); |
|
| 231 | + $value_marker->setData($data); |
|
| 232 | + $chart->addMarker($value_marker); |
|
| 233 | 233 | |
| 234 | - $data = new GoogleChartData( array( |
|
| 234 | + $data = new GoogleChartData(array( |
|
| 235 | 235 | $sales_array[0], |
| 236 | 236 | $sales_array[1], |
| 237 | 237 | $sales_array[2], |
@@ -244,46 +244,46 @@ discard block |
||
| 244 | 244 | $sales_array[9], |
| 245 | 245 | $sales_array[10], |
| 246 | 246 | $sales_array[11] |
| 247 | - ) ); |
|
| 248 | - $data->setLegend( esc_html__( 'Donations', 'give' ) ); |
|
| 249 | - $data->setColor( 'ff6c1c' ); |
|
| 250 | - $chart->addData( $data ); |
|
| 251 | - |
|
| 252 | - $chart->setTitle( esc_html__( 'Donations by Month for all Give Forms', 'give' ), '336699', 18 ); |
|
| 253 | - |
|
| 254 | - $chart->setScale( 0, $max_earnings ); |
|
| 255 | - |
|
| 256 | - $y_axis = new GoogleChartAxis( 'y' ); |
|
| 257 | - $y_axis->setDrawTickMarks( true )->setLabels( array( 0, $max_earnings ) ); |
|
| 258 | - $chart->addAxis( $y_axis ); |
|
| 259 | - |
|
| 260 | - $x_axis = new GoogleChartAxis( 'x' ); |
|
| 261 | - $x_axis->setTickMarks( 5 ); |
|
| 262 | - $x_axis->setLabels( array( |
|
| 263 | - esc_html__( 'Jan', 'give' ), |
|
| 264 | - esc_html__( 'Feb', 'give' ), |
|
| 265 | - esc_html__( 'Mar', 'give' ), |
|
| 266 | - esc_html__( 'Apr', 'give' ), |
|
| 267 | - esc_html__( 'May', 'give' ), |
|
| 268 | - esc_html__( 'June', 'give' ), |
|
| 269 | - esc_html__( 'July', 'give' ), |
|
| 270 | - esc_html__( 'Aug', 'give' ), |
|
| 271 | - esc_html__( 'Sept', 'give' ), |
|
| 272 | - esc_html__( 'Oct', 'give' ), |
|
| 273 | - esc_html__( 'Nov', 'give' ), |
|
| 274 | - esc_html__( 'Dec', 'give' ) |
|
| 275 | - ) ); |
|
| 276 | - $chart->addAxis( $x_axis ); |
|
| 277 | - |
|
| 278 | - $shape_marker = new GoogleChartShapeMarker( GoogleChartShapeMarker::CIRCLE ); |
|
| 279 | - $shape_marker->setSize( 6 ); |
|
| 280 | - $shape_marker->setBorder( 2 ); |
|
| 281 | - $shape_marker->setData( $data ); |
|
| 282 | - $chart->addMarker( $shape_marker ); |
|
| 283 | - |
|
| 284 | - $value_marker = new GoogleChartTextMarker( GoogleChartTextMarker::VALUE ); |
|
| 285 | - $value_marker->setData( $data ); |
|
| 286 | - $chart->addMarker( $value_marker ); |
|
| 247 | + )); |
|
| 248 | + $data->setLegend(esc_html__('Donations', 'give')); |
|
| 249 | + $data->setColor('ff6c1c'); |
|
| 250 | + $chart->addData($data); |
|
| 251 | + |
|
| 252 | + $chart->setTitle(esc_html__('Donations by Month for all Give Forms', 'give'), '336699', 18); |
|
| 253 | + |
|
| 254 | + $chart->setScale(0, $max_earnings); |
|
| 255 | + |
|
| 256 | + $y_axis = new GoogleChartAxis('y'); |
|
| 257 | + $y_axis->setDrawTickMarks(true)->setLabels(array(0, $max_earnings)); |
|
| 258 | + $chart->addAxis($y_axis); |
|
| 259 | + |
|
| 260 | + $x_axis = new GoogleChartAxis('x'); |
|
| 261 | + $x_axis->setTickMarks(5); |
|
| 262 | + $x_axis->setLabels(array( |
|
| 263 | + esc_html__('Jan', 'give'), |
|
| 264 | + esc_html__('Feb', 'give'), |
|
| 265 | + esc_html__('Mar', 'give'), |
|
| 266 | + esc_html__('Apr', 'give'), |
|
| 267 | + esc_html__('May', 'give'), |
|
| 268 | + esc_html__('June', 'give'), |
|
| 269 | + esc_html__('July', 'give'), |
|
| 270 | + esc_html__('Aug', 'give'), |
|
| 271 | + esc_html__('Sept', 'give'), |
|
| 272 | + esc_html__('Oct', 'give'), |
|
| 273 | + esc_html__('Nov', 'give'), |
|
| 274 | + esc_html__('Dec', 'give') |
|
| 275 | + )); |
|
| 276 | + $chart->addAxis($x_axis); |
|
| 277 | + |
|
| 278 | + $shape_marker = new GoogleChartShapeMarker(GoogleChartShapeMarker::CIRCLE); |
|
| 279 | + $shape_marker->setSize(6); |
|
| 280 | + $shape_marker->setBorder(2); |
|
| 281 | + $shape_marker->setData($data); |
|
| 282 | + $chart->addMarker($shape_marker); |
|
| 283 | + |
|
| 284 | + $value_marker = new GoogleChartTextMarker(GoogleChartTextMarker::VALUE); |
|
| 285 | + $value_marker->setData($data); |
|
| 286 | + $chart->addMarker($value_marker); |
|
| 287 | 287 | |
| 288 | 288 | return $chart->getUrl(); |
| 289 | 289 | } |