-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathsettings.php
217 lines (198 loc) · 8.14 KB
/
settings.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
<?php
if(!class_exists('WP_igniter_Settings'))
{
class WP_igniter_Settings
{
/**
* Construct the plugin object
*/
public function __construct()
{
// register actions
add_action('admin_init', array(&$this, 'admin_init'));
add_action('admin_menu', array(&$this, 'add_menu'));
} // END public function __construct
/**
* hook into WP's admin_init action hook
*/
public function admin_init()
{
// register your plugin's settings
register_setting('wp_igniter-group', 'wp_igniter_shortcode_posts');
register_setting('wp_igniter-group', 'wp_igniter_page_override');
register_setting('wp_igniter-group', 'wp_igniter_ci_path');
register_setting('wp_igniter-group', 'wp_igniter_handle_404');
register_setting('wp_igniter-group', 'wp_igniter_native_constants');
register_setting('wp_igniter-group', 'wp_igniter_custom_apppath');
register_setting('wp_igniter-group', 'wp_igniter_custom_sysfolder');
register_setting('wp_igniter-group', 'wp_igniter_ci_urihook');
// add your settings section
add_settings_section(
'wp_igniter-section',
'WordPressIgniter Settings',
array(&$this, 'settings_section_wp_igniter'),
'wp_igniter'
);
add_settings_field(
'wp_igniter_shortcode_posts',
'Trigger with [wordpressigniter] shortcode in posts, too.',
array(&$this, 'settings_field_input_checkbox'),
'wp_igniter',
'wp_igniter-section',
array(
'field' => 'wp_igniter_shortcode_posts'
)
);
add_settings_field(
'wp_igniter-page_override',
'Page Override',
array(&$this, 'settings_field_input_text'),
'wp_igniter',
'wp_igniter-section',
array(
'field' => 'wp_igniter_page_override'
)
);
add_settings_field(
'wp_igniter-ci_path',
'CodeIgniter Path',
array(&$this, 'settings_field_input_text'),
'wp_igniter',
'wp_igniter-section',
array(
'field' => 'wp_igniter_ci_path'
)
);
add_settings_field(
'wp_igniter-handle_404',
'Divert 404s to WordPressIgniter',
array(&$this, 'settings_field_input_checkbox'),
'wp_igniter',
'wp_igniter-section',
array(
'field' => 'wp_igniter_handle_404'
)
);
add_settings_field(
'wp_igniter-ci_uri_hook',
'CodeIgniter grabs all SEO urls<br />(use with caution!!)',
array(&$this, 'settings_field_input_checkbox'),
'wp_igniter',
'wp_igniter-section',
array(
'field' => 'wp_igniter_ci_urihook'
)
);
add_settings_field(
'wp_igniter-native_constants',
'Use CodeIgniter\'s native index.php to generate constants (i.e. APPPATH, BASEPATH)',
array(&$this, 'settings_field_input_checkbox'),
'wp_igniter',
'wp_igniter-section',
array(
'field' => 'wp_igniter_native_constants'
)
);
add_settings_field(
null,
'The settings below have no effect if the "native index.php..." box above is checked',
array(&$this, 'settings_field_null'),
'wp_igniter',
'wp_igniter-section',
null
);
add_settings_field(
'wp_igniter-custom_apppath',
'Customize APPPATH',
array(&$this, 'settings_field_input_text'),
'wp_igniter',
'wp_igniter-section',
array(
'field' => 'wp_igniter_custom_apppath'
)
);
add_settings_field(
'wp_igniter-custom_sysfolder',
'Customize BASEPATH',
array(&$this, 'settings_field_input_text'),
'wp_igniter',
'wp_igniter-section',
array(
'field' => 'wp_igniter_custom_sysfolder'
)
);
// Possibly do additional admin_init tasks
} // END public static function activate
public function settings_section_wp_igniter()
{
// Think of this as help text for the section.
?>
These settings control how WordPressIgniter loads CodeIgniter.
<ul style="list-style:initial;list-style-position:inside;">
<li>Engage CodeIgniter content into your blog by inserting the [wordpressigniter] shortcode into pages.</li>
<li>Check the "Trigger with [wordpressigniter] shortcode in posts, too" box so that CI content shows in posts. (Most useful with the shortcode after the "read more" tag.)</li>
<li>Page Override setting is deprecated and will disappear in future versions. Leave this blank and use the [wordpressigniter] shortcode instead.</li>
<li>The CI Path points to CI's index.php front controller.</li>
<li>The CI Path can be relative, but depending on your server settings, but you may need to edit the CI's index.php if you choose to use CI's index.php to generate constants.</li>
<ul>
<?php
}
/**
* This function provides text inputs for settings fields
*/
public function settings_field_null($args)
{
echo ' ';
}
/**
* This function provides text inputs for settings fields
*/
public function settings_field_input_text($args)
{
// Get the field name from the $args array
$field = $args['field'];
// Get the value of this setting
$value = get_option($field);
// echo a proper input type="text"
echo sprintf('<input type="text" name="%s" id="%s" value="%s" />', $field, $field, $value);
} // END public function settings_field_input_text($args)
/**
* This function provides checkbox inputs for settings fields
*/
public function settings_field_input_checkbox($args)
{
// Get the field name from the $args array
$field = $args['field'];
// Get the value of this setting
$value = get_option($field);
// echo a proper input type="text"
echo '<input type="checkbox" name="'.$field.'" id="'.$field.'" '.($value == true ? 'checked="checked"':'').' />';
} // END public function settings_field_input_text($args)
/**
* add a menu
*/
public function add_menu()
{
// Add a page to manage this plugin's settings
add_options_page(
'WordPressIgniter Settings',
'WordPressIgniter',
'manage_options',
'wp_igniter',
array(&$this, 'plugin_settings_page')
);
} // END public function add_menu()
/**
* Menu Callback
*/
public function plugin_settings_page()
{
if(!current_user_can('manage_options'))
{
wp_die(__('You do not have sufficient permissions to access this page.'));
}
// Render the settings template
include(sprintf("%s/templates/settings.php", dirname(__FILE__)));
} // END public function plugin_settings_page()
} // END class WP_igniter_Settings
} // END if(!class_exists('WP_igniter_Settings'))