diff --git a/README.md b/README.md index d8dbcab..d7a6d5b 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ Text: Contact Jena: - [ff_contact url="http://freifunk-jena.de/jena.json"] + [ff_contact jena] Output: diff --git a/freifunkmeta.php b/freifunkmeta.php index 8125be5..c86ae37 100644 --- a/freifunkmeta.php +++ b/freifunkmeta.php @@ -33,6 +33,7 @@ if ( ! shortcode_exists( 'ff_contact' ) ) { } // Example: // [ff_state] +// [ff_state hamburg] // [ff_state url="http://meta.hamburg.freifunk.net/ffhh.json"] function ff_meta_shortcode_handler( $atts, $content, $name ) { $default_url = get_option( 'ff_meta_url' ); @@ -40,6 +41,16 @@ function ff_meta_shortcode_handler( $atts, $content, $name ) { 'url' => $default_url, ), $atts)); + // check for city name + if (!empty($atts[0])) { + $city = $atts[0]; + if (false === ($directory = ff_meta_getmetadata (get_option( 'ff_meta_dir' ))) + || empty($directory[$city])) { + return ''; + } + $url = $directory[$city]; + } + if (empty($url) || false === ($metadata = ff_meta_getmetadata ($url))) { return ''; } @@ -195,7 +206,7 @@ function ff_meta_url_callback() { $url = "http://meta.hamburg.freifunk.net/ffhh.json"; } echo "" - ."

This will be the default for all tags without url=\"xyz\" parameter.

"; + ."

This will be the default for all tags without url=\"xyz\" or city parameter.

"; } function ff_meta_options_page() {