Code Duplication    Length = 32-32 lines in 2 locations

includes/class-give-stats.php 2 locations

@@ 234-265 (lines=32) @@
231
232
					break;
233
234
				case 'this_week' :
235
236
					$days_to_week_start = ( date( 'w', current_time( 'timestamp' ) ) - 1 ) * 60 * 60 * 24;
237
					$today              = date( 'j', current_time( 'timestamp' ) ) * 60 * 60 * 24;
238
239
					if ( $today <= $days_to_week_start ) {
240
241
						if ( $month > 1 ) {
242
							$month -= 1;
243
						} else {
244
							$month = 12;
245
						}
246
247
					}
248
249
					if ( ! $end_date ) {
250
251
						// Getting the start day
252
253
						$day = date( 'd', current_time( 'timestamp' ) - $days_to_week_start ) - 1;
254
						$day += get_option( 'start_of_week' );
255
256
					} else {
257
258
						// Getting the end day
259
260
						$day = date( 'd', current_time( 'timestamp' ) - $days_to_week_start ) - 1;
261
						$day += get_option( 'start_of_week' ) + 6;
262
263
					}
264
265
					break;
266
267
				case 'last_week' :
268
@@ 267-298 (lines=32) @@
264
265
					break;
266
267
				case 'last_week' :
268
269
					$days_to_week_start = ( date( 'w', current_time( 'timestamp' ) ) - 1 ) * 60 * 60 * 24;
270
					$today              = date( 'j', current_time( 'timestamp' ) ) * 60 * 60 * 24;
271
272
					if ( $today <= $days_to_week_start ) {
273
274
						if ( $month > 1 ) {
275
							$month -= 1;
276
						} else {
277
							$month = 12;
278
						}
279
280
					}
281
282
					if ( ! $end_date ) {
283
284
						// Getting the start day
285
286
						$day = date( 'd', current_time( 'timestamp' ) - $days_to_week_start ) - 8;
287
						$day += get_option( 'start_of_week' );
288
289
					} else {
290
291
						// Getting the end day
292
293
						$day = date( 'd', current_time( 'timestamp' ) - $days_to_week_start ) - 8;
294
						$day += get_option( 'start_of_week' ) + 6;
295
296
					}
297
298
					break;
299
300
				case 'this_quarter' :
301