Passed
Push — 567-fix/refactor-system-info-w... ( 1d64a1 )
by
unknown
11:45
created

SystemInfoPage::render_page()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 39
Code Lines 37

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 37
nc 2
nop 0
dl 0
loc 39
rs 9.328
c 0
b 0
f 0
1
<?php namespace BulkWP\BulkDelete\Core\SystemInfo;
2
3
use BulkWP\BulkDelete\Core\SystemInfo\BulkDeleteSystemInfo;
4
use BulkWP\BulkDelete\Core\Base\BasePage;
5
6
defined( 'ABSPATH' ) || exit; // Exit if accessed directly.
7
8
/**
9
 * System Info Page.
10
 *
11
 * This page displays information about the current WordPress install that can be used in support requests.
12
 *
13
 * @since 6.0.0
14
 */
15
class SystemInfoPage extends BasePage {
16
	const PAGE_SLUG = 'bulk-delete-system-info';
17
18
	/**
19
	 * Capability to Manage system info.
20
	 */
21
	const CAPABILITY = 'manage_options';
22
23
	/**
24
	 * SystemInfo class.
25
	 *
26
	 * @var BulkDeleteSystemInfo
27
	 */
28
	protected $system_info;
29
30
	public function load() {
31
		parent::load();
0 ignored issues
show
Bug introduced by
The method load() does not exist on BulkWP\BulkDelete\Core\Base\BasePage. It seems like you code against a sub-type of BulkWP\BulkDelete\Core\Base\BasePage such as BulkWP\BulkDelete\Core\SystemInfo\SystemInfoPage. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

31
		parent::/** @scrutinizer ignore-call */ 
32
          load();
Loading history...
32
33
		add_action( 'bd-download-system-info', array( $this, 'download_system_info' ) );
34
35
		$this->system_info = new BulkDeleteSystemInfo( 'bulk-delete' );
36
		$this->system_info->load();
37
	}
38
39
	public function register_page() {
40
		$this->page = add_submenu_page(
0 ignored issues
show
Bug Best Practice introduced by
The property page does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
41
			LogListPage::PAGE_SLUG,
0 ignored issues
show
Bug introduced by
The type BulkWP\BulkDelete\Core\SystemInfo\LogListPage was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
42
			__( 'System Info', 'bulk-delete' ),
43
			__( 'System Info', 'bulk-delete' ),
44
			self::CAPABILITY,
45
			self::PAGE_SLUG,
46
			array( $this, 'render_page' )
47
		);
48
49
		add_action( "load-{$this->page}", array( $this, 'render_help_tab' ) );
50
51
		/**
52
		 * Fires before loading Sytem Info page.
53
		 *
54
		 * @since 2.3.0
55
		 *
56
		 * @param string $page Page slug.
57
		 */
58
		do_action( 'bd_load_system_info_page', $this->page );
59
	}
60
61
	/**
62
	 * Render the page.
63
	 */
64
	public function render_page() {
65
		?>
66
67
		<form method="post">
68
			<div class="updated">
69
				<p>
70
					<strong>
71
						<?php _e( 'Please include this information when posting support requests.', 'bulk-delete' ); ?>
72
					</strong>
73
				</p>
74
			</div>
75
76
			<?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...
77
				<div class="notice notice-warning">
78
					<p><strong>
79
						<?php printf( __( 'DISABLE_WP_CRON is <a href="%s" rel="noopener" target="_blank">enabled</a>. This prevents scheduler from running.', 'bulk-delete' ), 'https://codex.wordpress.org/Editing_wp-config.php#Disable_Cron_and_Cron_Timeout' ); ?>
80
					</strong></p>
81
				</div>
82
			<?php endif; ?>
83
84
			<div class="wrap">
85
				<h1><?php _e( 'Bulk Delete - System Info', 'bulk-delete' ); ?></h1>
86
87
				<?php
88
					$this->system_info->render();
89
				?>
90
91
				<p class="submit">
92
					<input type="hidden" name="bd-action" value="bd-download-system-info">
93
					<?php
94
						wp_nonce_field( 'bd-download-system-info', 'bd-download-system-info_nonce', false );
95
						submit_button( __( 'Download System Info File', 'bulk-delete' ), 'primary', 'bd-download-system-info', false );
96
					?>
97
				</p>
98
			</div>
99
		</form>
100
101
		<?php
102
		$this->render_page_footer();
0 ignored issues
show
Bug introduced by
The method render_page_footer() does not exist on BulkWP\BulkDelete\Core\SystemInfo\SystemInfoPage. Did you maybe mean render_page()? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

102
		$this->/** @scrutinizer ignore-call */ 
103
         render_page_footer();

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
103
	}
104
105
	/**
106
	 * Download System info file.
107
	 */
108
	public function download_system_info() {
109
		$this->system_info->download_as_file();
110
	}
111
}
112