|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Auto Load Next Post Settings Page |
|
4
|
|
|
* |
|
5
|
|
|
* @since 1.0.0 |
|
6
|
|
|
* @version 1.4.10 |
|
7
|
|
|
* @author Sébastien Dumont |
|
8
|
|
|
* @category Admin |
|
9
|
|
|
* @package Auto Load Next Post |
|
10
|
|
|
* @license GPL-2.0+ |
|
11
|
|
|
*/ |
|
12
|
|
|
|
|
13
|
|
|
if ( ! defined('ABSPATH')) { |
|
14
|
|
|
exit; // Exit if accessed directly. |
|
15
|
|
|
} |
|
16
|
|
|
|
|
17
|
|
|
if ( ! class_exists( 'Auto_Load_Next_Post_Settings_Page' ) ) { |
|
18
|
|
|
|
|
19
|
|
|
abstract class Auto_Load_Next_Post_Settings_Page { |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* Setting page id. |
|
23
|
|
|
* |
|
24
|
|
|
* @access protected |
|
25
|
|
|
* @var string $id |
|
26
|
|
|
*/ |
|
27
|
|
|
protected $id = ''; |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* Setting page label. |
|
31
|
|
|
* |
|
32
|
|
|
* @access protected |
|
33
|
|
|
* @var string $label |
|
34
|
|
|
*/ |
|
35
|
|
|
protected $label = ''; |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* Constructor. |
|
39
|
|
|
* |
|
40
|
|
|
* @access public |
|
41
|
|
|
* @since 1.4.10 |
|
42
|
|
|
*/ |
|
43
|
|
|
public function __construct() { |
|
44
|
|
|
add_filter( 'auto_load_next_post_settings_tabs_array', array( $this, 'add_settings_page' ), 20 ); |
|
45
|
|
|
add_action( 'auto_load_next_post_settings_' . $this->id, array( $this, 'output' ) ); |
|
46
|
|
|
add_action( 'auto_load_next_post_settings_save_' . $this->id, array( $this, 'save' ) ); |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* Get settings page ID. |
|
51
|
|
|
* |
|
52
|
|
|
* @access public |
|
53
|
|
|
* @since 1.4.10 |
|
54
|
|
|
* @return string |
|
55
|
|
|
*/ |
|
56
|
|
|
public function get_id() { |
|
57
|
|
|
return $this->id; |
|
58
|
|
|
} // END get_id() |
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* Get settings page label. |
|
62
|
|
|
* |
|
63
|
|
|
* @access public |
|
64
|
|
|
* @since 1.4.10 |
|
65
|
|
|
* @return string |
|
66
|
|
|
*/ |
|
67
|
|
|
public function get_label() { |
|
68
|
|
|
return $this->label; |
|
69
|
|
|
} // END get_label() |
|
70
|
|
|
|
|
71
|
|
|
/** |
|
72
|
|
|
* Add this page to settings. |
|
73
|
|
|
* |
|
74
|
|
|
* @access public |
|
75
|
|
|
* @since 1.0.0 |
|
76
|
|
|
* @param array $pages |
|
77
|
|
|
* @return array $pages |
|
78
|
|
|
*/ |
|
79
|
|
|
public function add_settings_page( $pages ) { |
|
80
|
|
|
$pages[$this->id] = $this->label; |
|
81
|
|
|
|
|
82
|
|
|
return $pages; |
|
83
|
|
|
} // END add_settings_page() |
|
84
|
|
|
|
|
85
|
|
|
/** |
|
86
|
|
|
* Add this settings page to plugin menu. |
|
87
|
|
|
* |
|
88
|
|
|
* @access public |
|
89
|
|
|
* @since 1.0.0 |
|
90
|
|
|
* @param array $pages |
|
91
|
|
|
* @return array $pages |
|
92
|
|
|
*/ |
|
93
|
|
|
public function add_menu_page( $pages ) { |
|
94
|
|
|
$pages[$this->id] = $this->label; |
|
95
|
|
|
|
|
96
|
|
|
return $pages; |
|
97
|
|
|
} // END add_menu_page() |
|
98
|
|
|
|
|
99
|
|
|
/** |
|
100
|
|
|
* Get settings array |
|
101
|
|
|
* |
|
102
|
|
|
* @access public |
|
103
|
|
|
* @since 1.0.0 |
|
104
|
|
|
* @return array |
|
105
|
|
|
*/ |
|
106
|
|
|
public function get_settings() { |
|
107
|
|
|
return array(); |
|
108
|
|
|
} // END get_settings() |
|
109
|
|
|
|
|
110
|
|
|
/** |
|
111
|
|
|
* Output the settings. |
|
112
|
|
|
* |
|
113
|
|
|
* @access public |
|
114
|
|
|
* @since 1.0.0 |
|
115
|
|
|
*/ |
|
116
|
|
|
public function output() { |
|
117
|
|
|
$settings = $this->get_settings(); |
|
118
|
|
|
|
|
119
|
|
|
Auto_Load_Next_Post_Admin_Settings::output_fields( $settings ); |
|
120
|
|
|
} // END output() |
|
121
|
|
|
|
|
122
|
|
|
/** |
|
123
|
|
|
* Save settings. |
|
124
|
|
|
* |
|
125
|
|
|
* @access public |
|
126
|
|
|
* @since 1.0.0 |
|
127
|
|
|
* @global $current_tab |
|
128
|
|
|
*/ |
|
129
|
|
|
public function save() { |
|
130
|
|
|
global $current_tab; |
|
131
|
|
|
|
|
132
|
|
|
$settings = $this->get_settings(); |
|
133
|
|
|
|
|
134
|
|
|
Auto_Load_Next_Post_Admin_Settings::save_fields( $settings, $current_tab ); |
|
135
|
|
|
} // END save() |
|
136
|
|
|
|
|
137
|
|
|
} // END class |
|
138
|
|
|
|
|
139
|
|
|
} // END if class exists. |
|
140
|
|
|
|