@@ -16,7 +16,7 @@ discard block  | 
                                                    ||
| 16 | 16 | */  | 
                                                        
| 17 | 17 | |
| 18 | 18 | // Exit if accessed directly.  | 
                                                        
| 19 | -if ( ! defined( 'ABSPATH' ) ) { | 
                                                        |
| 19 | +if ( ! defined('ABSPATH')) { | 
                                                        |
| 20 | 20 | exit;  | 
                                                        
| 21 | 21 | }  | 
                                                        
| 22 | 22 | |
@@ -29,8 +29,8 @@ discard block  | 
                                                    ||
| 29 | 29 | * @return void  | 
                                                        
| 30 | 30 | */  | 
                                                        
| 31 | 31 |  function give_reports_page() { | 
                                                        
| 32 | - $current_page = admin_url( 'edit.php?post_type=give_forms&page=give-reports' );  | 
                                                        |
| 33 | - $active_tab = isset( $_GET['tab'] ) ? sanitize_text_field( $_GET['tab'] ) : 'earnings';  | 
                                                        |
| 32 | +	$current_page = admin_url('edit.php?post_type=give_forms&page=give-reports'); | 
                                                        |
| 33 | + $active_tab = isset($_GET['tab']) ? sanitize_text_field($_GET['tab']) : 'earnings';  | 
                                                        |
| 34 | 34 | $views = give_reports_default_views();  | 
                                                        
| 35 | 35 | ?>  | 
                                                        
| 36 | 36 | <div class="wrap give-settings-page">  | 
                                                        
@@ -38,17 +38,17 @@ discard block  | 
                                                    ||
| 38 | 38 | <h1 class="screen-reader-text"><?php echo get_admin_page_title(); ?></h1>  | 
                                                        
| 39 | 39 | |
| 40 | 40 | <h2 class="nav-tab-wrapper">  | 
                                                        
| 41 | -			<?php foreach ( $views as $tab => $label ) { ?> | 
                                                        |
| 42 | - <a href="<?php echo esc_url( add_query_arg( array(  | 
                                                        |
| 41 | +			<?php foreach ($views as $tab => $label) { ?> | 
                                                        |
| 42 | + <a href="<?php echo esc_url(add_query_arg(array(  | 
                                                        |
| 43 | 43 | 'tab' => $tab,  | 
                                                        
| 44 | 44 | 'settings-updated' => false,  | 
                                                        
| 45 | - ), $current_page ) ); ?>" class="nav-tab <?php echo $tab === $active_tab ? esc_attr( 'nav-tab-active' ) : ''; ?>"><?php echo esc_html( $label ); ?></a>  | 
                                                        |
| 45 | +				), $current_page)); ?>" class="nav-tab <?php echo $tab === $active_tab ? esc_attr('nav-tab-active') : ''; ?>"><?php echo esc_html($label); ?></a> | 
                                                        |
| 46 | 46 | <?php } ?>  | 
                                                        
| 47 | -			<?php if ( current_user_can( 'export_give_reports' ) ) { ?> | 
                                                        |
| 48 | - <a href="<?php echo esc_url( add_query_arg( array(  | 
                                                        |
| 47 | +			<?php if (current_user_can('export_give_reports')) { ?> | 
                                                        |
| 48 | + <a href="<?php echo esc_url(add_query_arg(array(  | 
                                                        |
| 49 | 49 | 'tab' => 'export',  | 
                                                        
| 50 | 50 | 'settings-updated' => false,  | 
                                                        
| 51 | - ), $current_page ) ); ?>" class="nav-tab <?php echo 'export' === $active_tab ? esc_attr( 'nav-tab-active' ) : ''; ?>"><?php esc_html_e( 'Export', 'give' ); ?></a>  | 
                                                        |
| 51 | +				), $current_page)); ?>" class="nav-tab <?php echo 'export' === $active_tab ? esc_attr('nav-tab-active') : ''; ?>"><?php esc_html_e('Export', 'give'); ?></a> | 
                                                        |
| 52 | 52 | <?php }  | 
                                                        
| 53 | 53 | /**  | 
                                                        
| 54 | 54 | * Fires in the report tabs.  | 
                                                        
@@ -57,7 +57,7 @@ discard block  | 
                                                    ||
| 57 | 57 | *  | 
                                                        
| 58 | 58 | * @since 1.0  | 
                                                        
| 59 | 59 | */  | 
                                                        
| 60 | - do_action( 'give_reports_tabs' );  | 
                                                        |
| 60 | +			do_action('give_reports_tabs'); | 
                                                        |
| 61 | 61 | ?>  | 
                                                        
| 62 | 62 | </h2>  | 
                                                        
| 63 | 63 | |
@@ -67,10 +67,10 @@ discard block  | 
                                                    ||
| 67 | 67 | *  | 
                                                        
| 68 | 68 | * @since 1.0  | 
                                                        
| 69 | 69 | */  | 
                                                        
| 70 | - do_action( 'give_reports_page_top' );  | 
                                                        |
| 70 | +		do_action('give_reports_page_top'); | 
                                                        |
| 71 | 71 | |
| 72 | 72 | // Set $active_tab prior to hook firing.  | 
                                                        
| 73 | -		if ( in_array( $active_tab, array_keys( $views ) ) ) { | 
                                                        |
| 73 | +		if (in_array($active_tab, array_keys($views))) { | 
                                                        |
| 74 | 74 | $active_tab = 'reports';  | 
                                                        
| 75 | 75 | }  | 
                                                        
| 76 | 76 | |
@@ -79,14 +79,14 @@ discard block  | 
                                                    ||
| 79 | 79 | *  | 
                                                        
| 80 | 80 | * @since 1.0  | 
                                                        
| 81 | 81 | */  | 
                                                        
| 82 | -		do_action( "give_reports_tab_{$active_tab}" ); | 
                                                        |
| 82 | +		do_action("give_reports_tab_{$active_tab}"); | 
                                                        |
| 83 | 83 | |
| 84 | 84 | /**  | 
                                                        
| 85 | 85 | * Fires after the report page.  | 
                                                        
| 86 | 86 | *  | 
                                                        
| 87 | 87 | * @since 1.0  | 
                                                        
| 88 | 88 | */  | 
                                                        
| 89 | - do_action( 'give_reports_page_bottom' );  | 
                                                        |
| 89 | +		do_action('give_reports_page_bottom'); | 
                                                        |
| 90 | 90 | ?>  | 
                                                        
| 91 | 91 | </div><!-- .wrap -->  | 
                                                        
| 92 | 92 | <?php  | 
                                                        
@@ -100,12 +100,12 @@ discard block  | 
                                                    ||
| 100 | 100 | */  | 
                                                        
| 101 | 101 |  function give_reports_default_views() { | 
                                                        
| 102 | 102 | $views = array(  | 
                                                        
| 103 | - 'earnings' => esc_html__( 'Income', 'give' ),  | 
                                                        |
| 104 | - 'forms' => esc_html__( 'Forms', 'give' ),  | 
                                                        |
| 105 | - 'gateways' => esc_html__( 'Donation Methods', 'give' ),  | 
                                                        |
| 103 | +		'earnings' => esc_html__('Income', 'give'), | 
                                                        |
| 104 | +		'forms'    => esc_html__('Forms', 'give'), | 
                                                        |
| 105 | +		'gateways' => esc_html__('Donation Methods', 'give'), | 
                                                        |
| 106 | 106 | );  | 
                                                        
| 107 | 107 | |
| 108 | - $views = apply_filters( 'give_report_views', $views );  | 
                                                        |
| 108 | +	$views = apply_filters('give_report_views', $views); | 
                                                        |
| 109 | 109 | |
| 110 | 110 | return $views;  | 
                                                        
| 111 | 111 | }  | 
                                                        
@@ -120,15 +120,15 @@ discard block  | 
                                                    ||
| 120 | 120 | * @since 1.0  | 
                                                        
| 121 | 121 | * @return string $view Report View  | 
                                                        
| 122 | 122 | */  | 
                                                        
| 123 | -function give_get_reporting_view( $default = 'earnings' ) { | 
                                                        |
| 123 | +function give_get_reporting_view($default = 'earnings') { | 
                                                        |
| 124 | 124 | |
| 125 | -	if ( ! isset( $_GET['view'] ) || ! in_array( $_GET['view'], array_keys( give_reports_default_views() ) ) ) { | 
                                                        |
| 125 | +	if ( ! isset($_GET['view']) || ! in_array($_GET['view'], array_keys(give_reports_default_views()))) { | 
                                                        |
| 126 | 126 | $view = $default;  | 
                                                        
| 127 | 127 |  	} else { | 
                                                        
| 128 | 128 | $view = $_GET['view'];  | 
                                                        
| 129 | 129 | }  | 
                                                        
| 130 | 130 | |
| 131 | - return apply_filters( 'give_get_reporting_view', $view );  | 
                                                        |
| 131 | +	return apply_filters('give_get_reporting_view', $view); | 
                                                        |
| 132 | 132 | }  | 
                                                        
| 133 | 133 | |
| 134 | 134 | /**  | 
                                                        
@@ -141,7 +141,7 @@ discard block  | 
                                                    ||
| 141 | 141 | $current_view = 'earnings';  | 
                                                        
| 142 | 142 | $views = give_reports_default_views();  | 
                                                        
| 143 | 143 | |
| 144 | -	if ( isset( $_GET['tab'] ) && array_key_exists( $_GET['tab'], $views ) ) { | 
                                                        |
| 144 | +	if (isset($_GET['tab']) && array_key_exists($_GET['tab'], $views)) { | 
                                                        |
| 145 | 145 | $current_view = $_GET['tab'];  | 
                                                        
| 146 | 146 | }  | 
                                                        
| 147 | 147 | |
@@ -150,10 +150,10 @@ discard block  | 
                                                    ||
| 150 | 150 | *  | 
                                                        
| 151 | 151 | * @since 1.0  | 
                                                        
| 152 | 152 | */  | 
                                                        
| 153 | -	do_action( "give_reports_view_{$current_view}" ); | 
                                                        |
| 153 | +	do_action("give_reports_view_{$current_view}"); | 
                                                        |
| 154 | 154 | }  | 
                                                        
| 155 | 155 | |
| 156 | -add_action( 'give_reports_tab_reports', 'give_reports_tab_reports' );  | 
                                                        |
| 156 | +add_action('give_reports_tab_reports', 'give_reports_tab_reports'); | 
                                                        |
| 157 | 157 | |
| 158 | 158 | /**  | 
                                                        
| 159 | 159 | * Renders the Reports Page Views Drop Downs  | 
                                                        
@@ -163,19 +163,19 @@ discard block  | 
                                                    ||
| 163 | 163 | */  | 
                                                        
| 164 | 164 |  function give_report_views() { | 
                                                        
| 165 | 165 | $views = give_reports_default_views();  | 
                                                        
| 166 | - $current_view = isset( $_GET['view'] ) ? $_GET['view'] : 'earnings';  | 
                                                        |
| 166 | + $current_view = isset($_GET['view']) ? $_GET['view'] : 'earnings';  | 
                                                        |
| 167 | 167 | /**  | 
                                                        
| 168 | 168 | * Fires before the report page actions form.  | 
                                                        
| 169 | 169 | *  | 
                                                        
| 170 | 170 | * @since 1.0  | 
                                                        
| 171 | 171 | */  | 
                                                        
| 172 | - do_action( 'give_report_view_actions_before' );  | 
                                                        |
| 172 | +	do_action('give_report_view_actions_before'); | 
                                                        |
| 173 | 173 | ?>  | 
                                                        
| 174 | 174 | <form id="give-reports-filter" method="get">  | 
                                                        
| 175 | 175 | <select id="give-reports-view" name="view">  | 
                                                        
| 176 | - <option value="-1"><?php esc_html_e( 'Report Type', 'give' ); ?></option>  | 
                                                        |
| 177 | - <?php foreach ( $views as $view_id => $label ) : ?>  | 
                                                        |
| 178 | - <option value="<?php echo esc_attr( $view_id ); ?>" <?php selected( $view_id, $current_view ); ?>><?php echo $label; ?></option>  | 
                                                        |
| 176 | +			<option value="-1"><?php esc_html_e('Report Type', 'give'); ?></option> | 
                                                        |
| 177 | + <?php foreach ($views as $view_id => $label) : ?>  | 
                                                        |
| 178 | + <option value="<?php echo esc_attr($view_id); ?>" <?php selected($view_id, $current_view); ?>><?php echo $label; ?></option>  | 
                                                        |
| 179 | 179 | <?php endforeach; ?>  | 
                                                        
| 180 | 180 | </select>  | 
                                                        
| 181 | 181 | |
@@ -187,12 +187,12 @@ discard block  | 
                                                    ||
| 187 | 187 | *  | 
                                                        
| 188 | 188 | * @since 1.0  | 
                                                        
| 189 | 189 | */  | 
                                                        
| 190 | - do_action( 'give_report_view_actions' );  | 
                                                        |
| 190 | +		do_action('give_report_view_actions'); | 
                                                        |
| 191 | 191 | ?>  | 
                                                        
| 192 | 192 | |
| 193 | 193 | <input type="hidden" name="post_type" value="give_forms"/>  | 
                                                        
| 194 | 194 | <input type="hidden" name="page" value="give-reports"/>  | 
                                                        
| 195 | - <?php submit_button( esc_html__( 'Show', 'give' ), 'secondary', 'submit', false ); ?>  | 
                                                        |
| 195 | +		<?php submit_button(esc_html__('Show', 'give'), 'secondary', 'submit', false); ?> | 
                                                        |
| 196 | 196 | </form>  | 
                                                        
| 197 | 197 | <?php  | 
                                                        
| 198 | 198 | /**  | 
                                                        
@@ -200,7 +200,7 @@ discard block  | 
                                                    ||
| 200 | 200 | *  | 
                                                        
| 201 | 201 | * @since 1.0  | 
                                                        
| 202 | 202 | */  | 
                                                        
| 203 | - do_action( 'give_report_view_actions_after' );  | 
                                                        |
| 203 | +	do_action('give_report_view_actions_after'); | 
                                                        |
| 204 | 204 | }  | 
                                                        
| 205 | 205 | |
| 206 | 206 | /**  | 
                                                        
@@ -213,11 +213,11 @@ discard block  | 
                                                    ||
| 213 | 213 | */  | 
                                                        
| 214 | 214 |  function give_reports_forms_table() { | 
                                                        
| 215 | 215 | |
| 216 | -	if ( isset( $_GET['form-id'] ) ) { | 
                                                        |
| 216 | +	if (isset($_GET['form-id'])) { | 
                                                        |
| 217 | 217 | return;  | 
                                                        
| 218 | 218 | }  | 
                                                        
| 219 | 219 | |
| 220 | - include( dirname( __FILE__ ) . '/class-form-reports-table.php' );  | 
                                                        |
| 220 | + include(dirname(__FILE__).'/class-form-reports-table.php');  | 
                                                        |
| 221 | 221 | |
| 222 | 222 | $give_table = new Give_Form_Reports_Table();  | 
                                                        
| 223 | 223 | $give_table->prepare_items();  | 
                                                        
@@ -229,7 +229,7 @@ discard block  | 
                                                    ||
| 229 | 229 | <?php  | 
                                                        
| 230 | 230 | }  | 
                                                        
| 231 | 231 | |
| 232 | -add_action( 'give_reports_view_forms', 'give_reports_forms_table' );  | 
                                                        |
| 232 | +add_action('give_reports_view_forms', 'give_reports_forms_table'); | 
                                                        |
| 233 | 233 | |
| 234 | 234 | /**  | 
                                                        
| 235 | 235 | * Renders the detailed report for a specific give form.  | 
                                                        
@@ -238,20 +238,20 @@ discard block  | 
                                                    ||
| 238 | 238 | * @return void  | 
                                                        
| 239 | 239 | */  | 
                                                        
| 240 | 240 |  function give_reports_form_details() { | 
                                                        
| 241 | -	if ( ! isset( $_GET['form-id'] ) ) { | 
                                                        |
| 241 | +	if ( ! isset($_GET['form-id'])) { | 
                                                        |
| 242 | 242 | return;  | 
                                                        
| 243 | 243 | }  | 
                                                        
| 244 | 244 | ?>  | 
                                                        
| 245 | 245 | <div class="tablenav top reports-forms-details-wrap">  | 
                                                        
| 246 | 246 | <div class="actions bulkactions">  | 
                                                        
| 247 | - <button onclick="history.go(-1);" class="button-secondary"><?php esc_html_e( 'Go Back', 'give' ); ?></button>  | 
                                                        |
| 247 | +			<button onclick="history.go(-1);" class="button-secondary"><?php esc_html_e('Go Back', 'give'); ?></button> | 
                                                        |
| 248 | 248 | </div>  | 
                                                        
| 249 | 249 | </div>  | 
                                                        
| 250 | 250 | <?php  | 
                                                        
| 251 | - give_reports_graph_of_form( absint( $_GET['form-id'] ) );  | 
                                                        |
| 251 | + give_reports_graph_of_form(absint($_GET['form-id']));  | 
                                                        |
| 252 | 252 | }  | 
                                                        
| 253 | 253 | |
| 254 | -add_action( 'give_reports_view_forms', 'give_reports_form_details' );  | 
                                                        |
| 254 | +add_action('give_reports_view_forms', 'give_reports_form_details'); | 
                                                        |
| 255 | 255 | |
| 256 | 256 | /**  | 
                                                        
| 257 | 257 | * Renders the Gateways Table  | 
                                                        
@@ -262,14 +262,14 @@ discard block  | 
                                                    ||
| 262 | 262 | * @return void  | 
                                                        
| 263 | 263 | */  | 
                                                        
| 264 | 264 |  function give_reports_gateways_table() { | 
                                                        
| 265 | - include( dirname( __FILE__ ) . '/class-gateways-reports-table.php' );  | 
                                                        |
| 265 | + include(dirname(__FILE__).'/class-gateways-reports-table.php');  | 
                                                        |
| 266 | 266 | |
| 267 | 267 | $give_table = new Give_Gateway_Reports_Table();  | 
                                                        
| 268 | 268 | $give_table->prepare_items();  | 
                                                        
| 269 | 269 | $give_table->display();  | 
                                                        
| 270 | 270 | }  | 
                                                        
| 271 | 271 | |
| 272 | -add_action( 'give_reports_view_gateways', 'give_reports_gateways_table' );  | 
                                                        |
| 272 | +add_action('give_reports_view_gateways', 'give_reports_gateways_table'); | 
                                                        |
| 273 | 273 | |
| 274 | 274 | /**  | 
                                                        
| 275 | 275 | * Renders the Reports Earnings Graphs  | 
                                                        
@@ -280,13 +280,13 @@ discard block  | 
                                                    ||
| 280 | 280 |  function give_reports_earnings() { | 
                                                        
| 281 | 281 | ?>  | 
                                                        
| 282 | 282 | <div class="tablenav top reports-table-nav">  | 
                                                        
| 283 | - <h3 class="alignleft reports-earnings-title"><span><?php esc_html_e( 'Income Report', 'give' ); ?></span></h3>  | 
                                                        |
| 283 | +		<h3 class="alignleft reports-earnings-title"><span><?php esc_html_e('Income Report', 'give'); ?></span></h3> | 
                                                        |
| 284 | 284 | </div>  | 
                                                        
| 285 | 285 | <?php  | 
                                                        
| 286 | 286 | give_reports_graph();  | 
                                                        
| 287 | 287 | }  | 
                                                        
| 288 | 288 | |
| 289 | -add_action( 'give_reports_view_earnings', 'give_reports_earnings' );  | 
                                                        |
| 289 | +add_action('give_reports_view_earnings', 'give_reports_earnings'); | 
                                                        |
| 290 | 290 | |
| 291 | 291 | |
| 292 | 292 | /**  | 
                                                        
@@ -297,9 +297,9 @@ discard block  | 
                                                    ||
| 297 | 297 | */  | 
                                                        
| 298 | 298 |  function give_estimated_monthly_stats() { | 
                                                        
| 299 | 299 | |
| 300 | - $estimated = Give_Cache::get( 'give_estimated_monthly_stats', true );  | 
                                                        |
| 300 | +	$estimated = Give_Cache::get('give_estimated_monthly_stats', true); | 
                                                        |
| 301 | 301 | |
| 302 | -	if ( false === $estimated ) { | 
                                                        |
| 302 | +	if (false === $estimated) { | 
                                                        |
| 303 | 303 | |
| 304 | 304 | $estimated = array(  | 
                                                        
| 305 | 305 | 'earnings' => 0,  | 
                                                        
@@ -308,22 +308,22 @@ discard block  | 
                                                    ||
| 308 | 308 | |
| 309 | 309 | $stats = new Give_Payment_Stats;  | 
                                                        
| 310 | 310 | |
| 311 | - $to_date_earnings = $stats->get_earnings( 0, 'this_month' );  | 
                                                        |
| 312 | - $to_date_sales = $stats->get_sales( 0, 'this_month' );  | 
                                                        |
| 311 | + $to_date_earnings = $stats->get_earnings(0, 'this_month');  | 
                                                        |
| 312 | + $to_date_sales = $stats->get_sales(0, 'this_month');  | 
                                                        |
| 313 | 313 | |
| 314 | - $current_day = date( 'd', current_time( 'timestamp' ) );  | 
                                                        |
| 315 | - $current_month = date( 'n', current_time( 'timestamp' ) );  | 
                                                        |
| 316 | - $current_year = date( 'Y', current_time( 'timestamp' ) );  | 
                                                        |
| 317 | - $days_in_month = cal_days_in_month( CAL_GREGORIAN, $current_month, $current_year );  | 
                                                        |
| 314 | +		$current_day   = date('d', current_time('timestamp')); | 
                                                        |
| 315 | +		$current_month = date('n', current_time('timestamp')); | 
                                                        |
| 316 | +		$current_year  = date('Y', current_time('timestamp')); | 
                                                        |
| 317 | + $days_in_month = cal_days_in_month(CAL_GREGORIAN, $current_month, $current_year);  | 
                                                        |
| 318 | 318 | |
| 319 | - $estimated['earnings'] = ( $to_date_earnings / $current_day ) * $days_in_month;  | 
                                                        |
| 320 | - $estimated['sales'] = ( $to_date_sales / $current_day ) * $days_in_month;  | 
                                                        |
| 319 | + $estimated['earnings'] = ($to_date_earnings / $current_day) * $days_in_month;  | 
                                                        |
| 320 | + $estimated['sales'] = ($to_date_sales / $current_day) * $days_in_month;  | 
                                                        |
| 321 | 321 | |
| 322 | 322 | // Cache for one day  | 
                                                        
| 323 | - Give_Cache::set( 'give_estimated_monthly_stats', $estimated, DAY_IN_SECONDS, true );  | 
                                                        |
| 323 | +		Give_Cache::set('give_estimated_monthly_stats', $estimated, DAY_IN_SECONDS, true); | 
                                                        |
| 324 | 324 | }  | 
                                                        
| 325 | 325 | |
| 326 | - return maybe_unserialize( $estimated );  | 
                                                        |
| 326 | + return maybe_unserialize($estimated);  | 
                                                        |
| 327 | 327 | }  | 
                                                        
| 328 | 328 | |
| 329 | 329 | /**  | 
                                                        
@@ -336,7 +336,7 @@ discard block  | 
                                                    ||
| 336 | 336 |  function give_reports_set_form_method() { | 
                                                        
| 337 | 337 | return 'get';  | 
                                                        
| 338 | 338 | }  | 
                                                        
| 339 | -add_filter( 'give-reports_form_method_tab_forms', 'give_reports_set_form_method', 10 );  | 
                                                        |
| 340 | -add_filter( 'give-reports_form_method_tab_donors', 'give_reports_set_form_method', 10 );  | 
                                                        |
| 339 | +add_filter('give-reports_form_method_tab_forms', 'give_reports_set_form_method', 10); | 
                                                        |
| 340 | +add_filter('give-reports_form_method_tab_donors', 'give_reports_set_form_method', 10); | 
                                                        |
| 341 | 341 | |
| 342 | 342 | // @TODO: After release 1.8 Donations -> Reports generates with new setting api, so we can remove some old code from this file.  |