Completed
Push — 247-fix/delete-term-meta ( d5f818...2a1fe3 )
by Sudar
67:09 queued 61:16
created

BulkDeleteSystemInfo::print_schedule_jobs()   A

Complexity

Conditions 6
Paths 6

Size

Total Lines 24
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 42

Importance

Changes 0
Metric Value
cc 6
eloc 15
nc 6
nop 0
dl 0
loc 24
ccs 0
cts 20
cp 0
crap 42
rs 9.2222
c 0
b 0
f 0
1
<?php
2
3
namespace BulkWP\BulkDelete\Core\SystemInfo;
4
5
use BulkWP\BulkDelete\Core\BulkDelete;
6
use Sudar\WPSystemInfo\SystemInfo;
7
8
defined( 'ABSPATH' ) || exit; // Exit if accessed directly.
9
10
/**
11
 * Bulk Delete System Info.
12
 *
13
 * Uses the WPSystemInfo library.
14
 *
15
 * @since 6.0.0
16
 * @link  https://github.com/sudar/wp-system-info
17
 */
18
class BulkDeleteSystemInfo extends SystemInfo {
19
	/**
20
	 * Setup hooks and filters.
21
	 */
22
	public function load() {
23
		add_action( 'before_system_info_for_bulk-delete', array( $this, 'print_bulk_delete_details' ) );
24
	}
25
26
	/**
27
	 * Print details about Bulk Delete.
28
	 *
29
	 * PHPCS is disabled for this function since alignment will mess up the system info output.
30
	 * phpcs:disable
31
	 */
32
	public function print_bulk_delete_details() {
33
		echo '-- Bulk Delete Configuration --', "\n";
34
		echo 'Bulk Delete Version:      ', BulkDelete::VERSION, "\n";
35
36
		$this->print_license_details();
37
		$this->print_schedule_jobs();
38
	}
39
	// phpcs:enable
40
41
	/**
42
	 * Print License details.
43
	 */
44
	protected function print_license_details() {
45
		$keys = \BD_License::get_licenses();
46
		if ( ! empty( $keys ) ) {
47
			echo 'BULKWP-LICENSE:          ', "\n";
48
49
			foreach ( $keys as $key ) {
50
				echo $key['addon-name'];
51
				echo ' | ';
52
				echo $key['license'];
53
				echo ' | ';
54
				echo $key['expires'];
55
				echo ' | ';
56
				echo $key['validity'];
57
				echo ' | ';
58
				echo $key['addon-code'];
59
			}
60
		}
61
	}
62
63
	/**
64
	 * Print all schedule jobs.
65
	 */
66
	protected function print_schedule_jobs() {
67
		$cron = _get_cron_array();
68
69
		if ( ! empty( $cron ) ) {
70
			echo "\n", 'SCHEDULED JOBS:          ', "\n";
71
72
			$date_format = _x( 'M j, Y @ G:i', 'Cron table date format', 'bulk-delete' );
73
74
			foreach ( $cron as $timestamp => $cronhooks ) {
75
				foreach ( (array) $cronhooks as $hook => $events ) {
76
					if ( 'do-bulk-delete-' === substr( $hook, 0, 15 ) ) {
77
						foreach ( (array) $events as $key => $event ) {
78
							echo date_i18n( $date_format, $timestamp + ( get_option( 'gmt_offset' ) * 60 * 60 ) ) . ' (' . $timestamp . ')';
79
							echo ' | ';
80
							echo $event['schedule'];
81
							echo ' | ';
82
							echo $hook;
83
							echo "\n";
84
						}
85
					}
86
				}
87
			}
88
89
			echo "\n";
90
		}
91
	}
92
}
93