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

SystemInfoPage   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 98
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 60
dl 0
loc 98
ccs 0
cts 51
cp 0
rs 10
c 0
b 0
f 0
wmc 9

5 Methods

Rating   Name   Duplication   Size   Complexity  
A register() 0 7 1
A initialize() 0 8 1
A download_system_info() 0 2 1
A render_body() 0 9 1
A render_header() 0 42 5
1
<?php namespace BulkWP\BulkDelete\Core\SystemInfo;
2
3
use BulkWP\BulkDelete\Core\Base\BasePage;
4
5
defined( 'ABSPATH' ) || exit; // Exit if accessed directly.
6
7
/**
8
 * System Info Page.
9
 *
10
 * This page displays information about the current WordPress install that can be used in support requests.
11
 *
12
 * @since 6.0.0
13
 */
14
class SystemInfoPage extends BasePage {
15
	/**
16
	 * SystemInfo class.
17
	 *
18
	 * @var BulkDeleteSystemInfo
19
	 */
20
	protected $system_info;
21
22
	/**
23
	 * Action.
24
	 *
25
	 * Use for nonce verification.
26
	 *
27
	 * @var string
28
	 */
29
	protected $action = 'download-system-info';
30
31
	protected function initialize() {
32
		$this->page_slug  = 'bulk-delete-system-info';
33
		$this->capability = 'manage_options';
34
		$this->actions[]  = $this->action;
35
36
		$this->label = array(
37
			'page_title' => __( 'Bulk Delete - System Info', 'bulk-delete' ),
38
			'menu_title' => __( 'System Info', 'bulk-delete' ),
39
		);
40
	}
41
42
	public function register() {
43
		parent::register();
44
45
		add_action( 'bd_' . $this->action, array( $this, 'download_system_info' ) );
46
47
		$this->system_info = new BulkDeleteSystemInfo( 'bulk-delete' );
48
		$this->system_info->load();
49
	}
50
51
	protected function render_header() {
52
		?>
53
		<div class="updated">
54
			<p>
55
				<strong>
56
					<?php _e( 'Please include this information when posting support requests.', 'bulk-delete' ); ?>
57
				</strong>
58
			</p>
59
		</div>
60
61
		<?php if ( defined( 'SAVEQUERIES' ) && SAVEQUERIES ) : ?>
0 ignored issues
show
Bug introduced by
The constant BulkWP\BulkDelete\Core\SystemInfo\SAVEQUERIES was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
62
			<div class="notice notice-warning">
63
				<p>
64
					<strong>
65
						<?php
66
						printf(
67
							/* translators: 1 Codex URL */
68
							__( 'SAVEQUERIES is <a href="%s" target="_blank">enabled</a>. This puts additional load on the memory and will restrict the number of items that can be deleted.', 'bulk-delete' ),
69
							'https://codex.wordpress.org/Editing_wp-config.php#Save_queries_for_analysis'
70
						);
71
						?>
72
					</strong>
73
				</p>
74
			</div>
75
		<?php endif; ?>
76
77
		<?php if ( defined( 'DISABLE_WP_CRON' ) && DISABLE_WP_CRON ) : ?>
0 ignored issues
show
Bug introduced by
The constant BulkWP\BulkDelete\Core\SystemInfo\DISABLE_WP_CRON was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
78
			<div class="notice notice-warning">
79
				<p>
80
					<strong>
81
						<?php
82
						printf(
83
							/* translators: 1 Codex URL. */
84
							__( 'DISABLE_WP_CRON is <a href="%s" rel="noopener" target="_blank">enabled</a>. Scheduled deletion will not work if WP Cron is disabled. Please disable it to enable scheduled deletion.', 'bulk-delete' ),
85
							'https://codex.wordpress.org/Editing_wp-config.php#Disable_Cron_and_Cron_Timeout'
86
						);
87
						?>
88
					</strong>
89
				</p>
90
			</div>
91
		<?php endif; ?>
92
		<?php
93
	}
94
95
	public function render_body() {
96
		$this->system_info->render();
97
		?>
98
			<p class="submit">
99
				<input type="hidden" name="bd_action" value="<?php echo esc_attr( $this->action ); ?>">
100
				<?php
101
					submit_button( __( 'Download System Info File', 'bulk-delete' ), 'primary', 'bd-download-system-info', false );
102
				?>
103
			</p>
104
		<?php
105
	}
106
107
	/**
108
	 * Download System info file.
109
	 */
110
	public function download_system_info() {
111
		$this->system_info->download_as_file();
112
	}
113
}
114