Compare commits
1 commit
master
...
vendor-pre
Author | SHA1 | Date | |
---|---|---|---|
28d2092244 |
|
@ -3,7 +3,6 @@
|
||||||
Plugin Name: Freifunk Hamburg Firmware List Shortcode
|
Plugin Name: Freifunk Hamburg Firmware List Shortcode
|
||||||
Plugin URI: http://mschuette.name/
|
Plugin URI: http://mschuette.name/
|
||||||
Description: Defines shortcodes to display Freifunk Hamburg Firmware versions
|
Description: Defines shortcodes to display Freifunk Hamburg Firmware versions
|
||||||
Version: 0.5dev
|
|
||||||
Author: Martin Schuette
|
Author: Martin Schuette
|
||||||
Author URI: http://mschuette.name/
|
Author URI: http://mschuette.name/
|
||||||
Licence: 2-clause BSD
|
Licence: 2-clause BSD
|
||||||
|
@ -91,11 +90,11 @@ if ( ! shortcode_exists( 'ff_hh_versions' ) ) {
|
||||||
}
|
}
|
||||||
// Example:
|
// Example:
|
||||||
// [ff_hh_versions]
|
// [ff_hh_versions]
|
||||||
// [ff_hh_versions domain="ffhh-sued" branch="experimental" grep="ubiquiti"]
|
// [ff_hh_versions domain="ffhh-sued" branch="experimental" prefix="ubiquiti"]
|
||||||
function ff_hh_shortcode_versions( $atts, $content, $name ) {
|
function ff_hh_shortcode_versions( $atts, $content, $name ) {
|
||||||
$domain = 'ffhh';
|
$domain = 'ffhh';
|
||||||
$branch = 'stable';
|
$branch = 'stable';
|
||||||
$grep = false;
|
$prefix = false;
|
||||||
$filter = false;
|
$filter = false;
|
||||||
if ( is_array( $atts ) ) {
|
if ( is_array( $atts ) ) {
|
||||||
if ( array_key_exists( 'domain', $atts ) && ! empty( $atts['domain'] ) ) {
|
if ( array_key_exists( 'domain', $atts ) && ! empty( $atts['domain'] ) ) {
|
||||||
|
@ -104,8 +103,8 @@ function ff_hh_shortcode_versions( $atts, $content, $name ) {
|
||||||
if ( array_key_exists( 'branch', $atts ) && ! empty( $atts['branch'] ) ) {
|
if ( array_key_exists( 'branch', $atts ) && ! empty( $atts['branch'] ) ) {
|
||||||
$branch = $atts['branch'];
|
$branch = $atts['branch'];
|
||||||
}
|
}
|
||||||
if ( array_key_exists( 'grep', $atts ) && ! empty( $atts['grep'] ) ) {
|
if ( array_key_exists( 'prefix', $atts ) && ! empty( $atts['prefix'] ) ) {
|
||||||
$grep = $atts['grep'];
|
$prefix = explode ( ',', $atts['prefix'] );
|
||||||
}
|
}
|
||||||
if ( array_key_exists( 'filter', $atts ) && ! empty( $atts['filter'] ) ) {
|
if ( array_key_exists( 'filter', $atts ) && ! empty( $atts['filter'] ) ) {
|
||||||
$filter = explode ( ',', $atts['filter'] );
|
$filter = explode ( ',', $atts['filter'] );
|
||||||
|
@ -122,9 +121,18 @@ function ff_hh_shortcode_versions( $atts, $content, $name ) {
|
||||||
ksort($manifest);
|
ksort($manifest);
|
||||||
foreach ( $manifest as $hw => $versions ) {
|
foreach ( $manifest as $hw => $versions ) {
|
||||||
// select some models
|
// select some models
|
||||||
if ( $grep && ( false === strpos( $hw, $grep ) ) ) {
|
if ( $prefix ) {
|
||||||
|
$matched = false;
|
||||||
|
foreach ( $prefix as $pfx ) {
|
||||||
|
if ( strpos ( $hw, $pfx ) === 0 ) {
|
||||||
|
$matched = $pfx;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( $matched === false ) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// filter others
|
// filter others
|
||||||
if ( $filter ) {
|
if ( $filter ) {
|
||||||
$filtered = false;
|
$filtered = false;
|
||||||
|
@ -139,7 +147,7 @@ function ff_hh_shortcode_versions( $atts, $content, $name ) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$hw = ff_hh_beautify_hw_name( $hw, $grep );
|
$hw = ff_hh_beautify_hw_name( $hw, $matched );
|
||||||
$outstr .= sprintf( "\n<tr><td>%s</td>", $hw );
|
$outstr .= sprintf( "\n<tr><td>%s</td>", $hw );
|
||||||
|
|
||||||
// factory versions
|
// factory versions
|
||||||
|
|
Loading…
Reference in a new issue