|
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
|
|
View Code Duplication |
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
|
|
|
* |
|
63
|
|
|
* @param array $pages Lst of pages. |
|
64
|
|
|
* |
|
65
|
|
|
* @return array |
|
66
|
|
|
*/ |
|
67
|
|
|
public function add_settings_page( $pages ) { |
|
68
|
|
|
$pages[ $this->id ] = $this->label; |
|
69
|
|
|
|
|
70
|
|
|
return $pages; |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
/** |
|
74
|
|
|
* Output the settings. |
|
75
|
|
|
* |
|
76
|
|
|
* @since 1.8 |
|
77
|
|
|
* @return void |
|
78
|
|
|
*/ |
|
79
|
|
|
public function output() { |
|
80
|
|
|
$GLOBALS['give_hide_save_button'] = true; |
|
81
|
|
|
include_once( 'views/html-admin-page-system-info.php' ); |
|
82
|
|
|
} |
|
83
|
|
|
} |
|
84
|
|
|
|
|
85
|
|
|
endif; |
|
86
|
|
|
|
|
87
|
|
|
return new Give_Settings_System_Info(); |
|
88
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.