register settings and label option inputs
This commit is contained in:
parent
8b5e2c55aa
commit
df93dd00ab
|
@ -123,10 +123,18 @@ function ff_meta_admin_menu() {
|
||||||
|
|
||||||
add_action( 'admin_init', 'ff_meta_admin_init' );
|
add_action( 'admin_init', 'ff_meta_admin_init' );
|
||||||
function ff_meta_admin_init() {
|
function ff_meta_admin_init() {
|
||||||
|
register_setting(
|
||||||
|
'ff_meta_settings-group', // group name
|
||||||
|
'ff_meta_cachetime' // option name
|
||||||
|
);
|
||||||
register_setting(
|
register_setting(
|
||||||
'ff_meta_settings-group', // group name
|
'ff_meta_settings-group', // group name
|
||||||
'ff_meta_url' // option name
|
'ff_meta_url' // option name
|
||||||
);
|
);
|
||||||
|
register_setting(
|
||||||
|
'ff_meta_settings-group', // group name
|
||||||
|
'ff_meta_dir' // option name
|
||||||
|
);
|
||||||
add_settings_section(
|
add_settings_section(
|
||||||
'ff_meta_section-one', // ID
|
'ff_meta_section-one', // ID
|
||||||
'Section One', // Title
|
'Section One', // Title
|
||||||
|
@ -138,21 +146,24 @@ function ff_meta_admin_init() {
|
||||||
'Cache time', // Title
|
'Cache time', // Title
|
||||||
'ff_meta_cachetime_callback', // callback to fill field
|
'ff_meta_cachetime_callback', // callback to fill field
|
||||||
'ff_meta_plugin', // menu page=slug to display field on
|
'ff_meta_plugin', // menu page=slug to display field on
|
||||||
'ff_meta_section-one' // section to display the field in
|
'ff_meta_section-one', // section to display the field in
|
||||||
|
array('label_for' => 'ff_meta_cachetime_id') // ID of input element
|
||||||
);
|
);
|
||||||
add_settings_field(
|
add_settings_field(
|
||||||
'ff_meta_url', // ID
|
'ff_meta_url', // ID
|
||||||
'URL of meta.json', // Title
|
'URL of meta.json', // Title
|
||||||
'ff_meta_url_callback', // callback to fill field
|
'ff_meta_url_callback', // callback to fill field
|
||||||
'ff_meta_plugin', // menu page=slug to display field on
|
'ff_meta_plugin', // menu page=slug to display field on
|
||||||
'ff_meta_section-one' // section to display the field in
|
'ff_meta_section-one', // section to display the field in
|
||||||
|
array('label_for' => 'ff_meta_url_id') // ID of input element
|
||||||
);
|
);
|
||||||
add_settings_field(
|
add_settings_field(
|
||||||
'ff_meta_dir', // ID
|
'ff_meta_dir', // ID
|
||||||
'URL of directory.json', // Title
|
'URL of directory.json', // Title
|
||||||
'ff_meta_dir_callback', // callback to fill field
|
'ff_meta_dir_callback', // callback to fill field
|
||||||
'ff_meta_plugin', // menu page=slug to display field on
|
'ff_meta_plugin', // menu page=slug to display field on
|
||||||
'ff_meta_section-one' // section to display the field in
|
'ff_meta_section-one', // section to display the field in
|
||||||
|
array('label_for' => 'ff_meta_dir_id') // ID of input element
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -165,7 +176,7 @@ function ff_meta_cachetime_callback() {
|
||||||
if (empty($time)) {
|
if (empty($time)) {
|
||||||
$time = "15";
|
$time = "15";
|
||||||
}
|
}
|
||||||
echo "<input type='number' name='ff_meta_cachetime' class='small-text code' value='$time' /> minutes"
|
echo "<input type='number' name='ff_meta_cachetime' id='ff_meta_cachetime_id' class='small-text code' value='$time' /> minutes"
|
||||||
."<p class='description'>Data from external URLs is cached for this number of minutes.</p>";
|
."<p class='description'>Data from external URLs is cached for this number of minutes.</p>";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -174,7 +185,7 @@ function ff_meta_dir_callback() {
|
||||||
if (empty($url)) {
|
if (empty($url)) {
|
||||||
$url = "https://raw.githubusercontent.com/freifunk/directory.api.freifunk.net/master/directory.json";
|
$url = "https://raw.githubusercontent.com/freifunk/directory.api.freifunk.net/master/directory.json";
|
||||||
}
|
}
|
||||||
echo "<input type='text' name='ff_meta_dir' class='large-text code' value='$url' />"
|
echo "<input type='text' name='ff_meta_dir' id='ff_meta_dir_id' class='large-text code' value='$url' />"
|
||||||
."<p class='description'>Please keep the default unless you really know what you are doing.</p>";
|
."<p class='description'>Please keep the default unless you really know what you are doing.</p>";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -183,7 +194,7 @@ function ff_meta_url_callback() {
|
||||||
if (empty($url)) {
|
if (empty($url)) {
|
||||||
$url = "http://meta.hamburg.freifunk.net/ffhh.json";
|
$url = "http://meta.hamburg.freifunk.net/ffhh.json";
|
||||||
}
|
}
|
||||||
echo "<input type='text' name='ff_meta_url' class='large-text code' value='$url' />"
|
echo "<input type='text' name='ff_meta_url' id='ff_meta_url_id' class='large-text code' value='$url' />"
|
||||||
."<p class='description'>This will be the default for all tags without url=\"xyz\" parameter.</p>";
|
."<p class='description'>This will be the default for all tags without url=\"xyz\" parameter.</p>";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue