From a88fb04f84332f3e2aa52f85e1b0273a0aba95db Mon Sep 17 00:00:00 2001 From: Martin Schuette Date: Thu, 3 Apr 2014 21:37:51 +0000 Subject: [PATCH] add directory option and option default values --- freifunkmeta.php | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/freifunkmeta.php b/freifunkmeta.php index 0be2974..528d903 100644 --- a/freifunkmeta.php +++ b/freifunkmeta.php @@ -132,6 +132,13 @@ function ff_meta_admin_init() { 'ff_meta_section_one_callback', // callback to fill 'ff_meta_plugin' // page to display on ); + add_settings_field( + 'ff_meta_dir', // ID + 'URL of directory.json', // Title + 'ff_meta_dir_callback', // callback to fill field + 'ff_meta_plugin', // menu page=slug to display field on + 'ff_meta_section-one' // section to display the field in + ); add_settings_field( 'ff_meta_url', // ID 'URL of meta.json', // Title @@ -145,9 +152,20 @@ function ff_meta_section_one_callback() { echo 'This Plugin provides shortcodes to display information from the Freifunk meta.json.'; } +function ff_meta_dir_callback() { + $url = get_option( 'ff_meta_dir' ); + if (empty($url)) { + $url = "https://raw.githubusercontent.com/freifunk/directory.api.freifunk.net/master/directory.json"; + } + echo ""; +} + function ff_meta_url_callback() { $url = get_option( 'ff_meta_url' ); - echo ""; + if (empty($url)) { + $url = "http://meta.hamburg.freifunk.net/ffhh.json"; + } + echo ""; } function ff_meta_options_page() {