Merge pull request #1 from ohrensessel/master

add ff_state shortcode to get number of online nodes
This commit is contained in:
Martin Schütte 2014-04-03 13:34:48 +02:00
commit 0e3aefd62a

View file

@ -21,6 +21,27 @@ function ff_meta_getmetadata ($url) {
return $metadata; return $metadata;
} }
if ( ! shortcode_exists( 'ff_state' ) ) {
add_shortcode( 'ff_state', 'ff_meta_shortcode_state');
}
// Example:
// [ff_state]
// [ff_state url="http://meta.hamburg.freifunk.net/ffhh.json"]
function ff_meta_shortcode_state( $atts ) {
$default_url = get_option( 'ff_meta_url' );
extract(shortcode_atts( array(
'url' => $default_url,
), $atts));
$metadata = ff_meta_getmetadata ($url);
$state = $metadata['state'];
// Output
$outstr = sprintf('%s',
$state['nodes']);
return $outstr;
}
if ( ! shortcode_exists( 'ff_services' ) ) { if ( ! shortcode_exists( 'ff_services' ) ) {
add_shortcode( 'ff_services', 'ff_meta_shortcode_services'); add_shortcode( 'ff_services', 'ff_meta_shortcode_services');
} }