Passed
Pull Request — dev/6.0.0 (#572)
by
unknown
41:10 queued 26:12
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\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
	const PAGE_SLUG = 'bulk-delete-system-info';
16
17
	/**
18
	 * Capability to Manage system info.
19
	 */
20
	const CAPABILITY = 'manage_options';
21
22
	/**
23
	 * SystemInfo class.
24
	 *
25
	 * @var BulkDeleteSystemInfo
26
	 */
27
	protected $system_info;
28
29
	public function load() {
30
		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

30
		parent::/** @scrutinizer ignore-call */ 
31
          load();
Loading history...
31
32
		add_action( 'bd-download-system-info', array( $this, 'download_system_info' ) );
33
34
		$this->system_info = new BulkDeleteSystemInfo( 'bulk-delete' );
35
		$this->system_info->load();
36
	}
37
38
	public function register_page() {
39
		$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...
40
			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...
41
			__( 'System Info', 'bulk-delete' ),
42
			__( 'System Info', 'bulk-delete' ),
43
			self::CAPABILITY,
44
			self::PAGE_SLUG,
45
			array( $this, 'render_page' )
46
		);
47
48
		add_action( "load-{$this->page}", array( $this, 'render_help_tab' ) );
49
50
		/**
51
		 * Fires before loading Sytem Info page.
52
		 *
53
		 * @since 2.3.0
54
		 *
55
		 * @param string $page Page slug.
56
		 */
57
		do_action( 'bd_load_system_info_page', $this->page );
58
	}
59
60
	/**
61
	 * Render the page.
62
	 */
63
	public function render_page() {
64
		?>
65
66
		<form method="post">
67
			<div class="updated">
68
				<p>
69
					<strong>
70
						<?php _e( 'Please include this information when posting support requests.', 'bulk-delete' ); ?>
71
					</strong>
72
				</p>
73
			</div>
74
75
			<?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...
76
				<div class="notice notice-warning">
77
					<p><strong>
78
						<?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' ); ?>
79
					</strong></p>
80
				</div>
81
			<?php endif; ?>
82
83
			<div class="wrap">
84
				<h1><?php _e( 'Bulk Delete - System Info', 'bulk-delete' ); ?></h1>
85
86
				<?php
87
					$this->system_info->render();
88
				?>
89
90
				<p class="submit">
91
					<input type="hidden" name="bd-action" value="bd-download-system-info">
92
					<?php
93
						wp_nonce_field( 'bd-download-system-info', 'bd-download-system-info_nonce', false );
94
						submit_button( __( 'Download System Info File', 'bulk-delete' ), 'primary', 'bd-download-system-info', false );
95
					?>
96
				</p>
97
			</div>
98
		</form>
99
100
		<?php
101
		$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

101
		$this->/** @scrutinizer ignore-call */ 
102
         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...
102
	}
103
104
	/**
105
	 * Download System info file.
106
	 */
107
	public function download_system_info() {
108
		$this->system_info->download_as_file();
109
	}
110
}
111