1
|
|
|
<?php |
|
|
|
|
2
|
|
|
/** |
3
|
|
|
* Give Settings Page/Tab |
4
|
|
|
* |
5
|
|
|
* @package Give |
6
|
|
|
* @subpackage Classes/Give_Settings_System_Info |
7
|
|
|
* @copyright Copyright (c) 2016, WordImpress |
8
|
|
|
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License |
9
|
|
|
* @since 1.8 |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
if ( ! defined( 'ABSPATH' ) ) { |
13
|
|
|
exit; // Exit if accessed directly |
14
|
|
|
} |
15
|
|
|
|
16
|
|
|
if ( ! class_exists( 'Give_Settings_System_Info' ) ) : |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* Give_Settings_System_Info. |
20
|
|
|
* |
21
|
|
|
* @sine 1.8 |
22
|
|
|
*/ |
23
|
|
|
class Give_Settings_System_Info { |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* Setting page id. |
27
|
|
|
* |
28
|
|
|
* @since 1.8 |
29
|
|
|
* @var string |
30
|
|
|
*/ |
31
|
|
|
protected $id = ''; |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* Setting page label. |
35
|
|
|
* |
36
|
|
|
* @since 1.8 |
37
|
|
|
* @var string |
38
|
|
|
*/ |
39
|
|
|
protected $label = ''; |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* Constructor. |
43
|
|
|
*/ |
44
|
|
|
public function __construct() { |
45
|
|
|
$this->id = 'system-info'; |
46
|
|
|
$this->label = esc_html__( 'System Info', 'give' ); |
47
|
|
|
|
48
|
|
|
add_filter( 'give-tools_tabs_array', array( $this, 'add_settings_page' ), 20 ); |
49
|
|
|
add_action( "give-tools_settings_{$this->id}_page", array( $this, 'output' ) ); |
50
|
|
|
|
51
|
|
|
// Do not use main form for this tab. |
52
|
|
|
if( give_get_current_setting_tab() === $this->id ) { |
53
|
|
|
add_action( "give-tools_open_form", '__return_empty_string' ); |
54
|
|
|
add_action( "give-tools_close_form", '__return_empty_string' ); |
55
|
|
|
} |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* Add this page to settings. |
60
|
|
|
* |
61
|
|
|
* @since 1.8 |
62
|
|
|
* @param array $pages Lst of pages. |
63
|
|
|
* @return array |
64
|
|
|
*/ |
65
|
|
|
public function add_settings_page( $pages ) { |
66
|
|
|
$pages[ $this->id ] = $this->label; |
67
|
|
|
|
68
|
|
|
return $pages; |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* Output the settings. |
73
|
|
|
* |
74
|
|
|
* @since 1.8 |
75
|
|
|
* @return void |
76
|
|
|
*/ |
77
|
|
|
public function output() { |
78
|
|
|
$GLOBALS['give_hide_save_button'] = true; |
79
|
|
|
include_once( 'views/html-admin-page-system-info.php' ); |
80
|
|
|
} |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
endif; |
84
|
|
|
|
85
|
|
|
return new Give_Settings_System_Info(); |
86
|
|
|
|
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.