$sw_ver"; return $outstr; } if ( ! shortcode_exists( 'ff_hh_versions' ) ) { add_shortcode( 'ff_hh_versions', 'ff_hh_shortcode_versions' ); } // Example: // [ff_hh_versions] // [ff_hh_versions grep="ubiquiti"] function ff_hh_shortcode_versions( $atts, $content, $name ) { $manifest = ff_hh_getmanifest( FF_HH_STABLE_BASEDIR ); $outstr = "
"; $outstr .= ''; # optionally filter output by given substring if ( is_array( $atts ) && array_key_exists( 'grep', $atts ) && ! empty( $atts['grep'] ) ) { $grep = $atts['grep']; } else { $grep = false; } foreach ( $manifest as $hw => $versions ) { // filter if ( $grep && ( false === strpos( $hw, $grep ) ) ) { continue; } $hw = ff_hh_beautify_hw_name( $hw, $grep ); $outstr .= sprintf( "\n", $hw ); // factory versions $hw_ver_links = array(); foreach ( $versions as $hw_ver => $filename ) { $filename = str_replace( '-sysupgrade', '', $filename ); $hw_ver_links[] = sprintf( '%s.x', FF_HH_STABLE_BASEDIR.'factory/', $filename, $hw_ver ); } $outstr .= ''; // sysupgrade versions $hw_ver_links = array(); foreach ( $versions as $hw_ver => $filename ) { $hw_ver_links[] = sprintf( '%s.x', FF_HH_STABLE_BASEDIR.'sysupgrade/', $filename, $hw_ver ); } $outstr .= ''; // link to Geizhals $outstr .= sprintf( "\n", $hw ); $outstr .= ''; } $outstr .= '
ModellErstinstallationAktualisierungPreissuche
%sHardware Version ' . join( ', ', $hw_ver_links ) . 'Hardware Version ' . join( ', ', $hw_ver_links ) . '
Suchen
'; $outstr .= '
'; // $outstr .= '
'.print_r( $manifest, true ).'
'; return $outstr; } // some crude rules to add capitalization and whitespace to the // hardware model name. // set $discard_vendor to strip the vendor name // (used for single-vendor lists, e.g. $discard_vendor = 'tp-link' ) function ff_hh_beautify_hw_name( $hw, $discard_vendor = '' ) { if ( ! strncmp( $hw, 'tp-link', 7 ) ) { if ( $discard_vendor ) $hw = str_replace( $discard_vendor, '', $hw ); $hw = strtoupper( $hw ); $hw = str_replace( '-', ' ', $hw ); $hw = str_replace( 'TP LINK ', 'TP-Link ', $hw ); $hw = str_replace( ' TL ', ' TL-', $hw ); } elseif ( ! strncmp( $hw, 'ubiquiti', 8 ) ) { if ( $discard_vendor ) $hw = str_replace( $discard_vendor, '', $hw ); $hw = str_replace( 'bullet-m', 'bullet-m / nanostation-loco-m', $hw ); $hw = str_replace( '-m', ' M2', $hw ); $hw = str_replace( '-', ' ', $hw ); $hw = ucwords( $hw ); } elseif ( ! strncmp( $hw, 'd-link', 6 ) ) { if ( $discard_vendor ) $hw = str_replace( $discard_vendor, '', $hw ); $hw = strtoupper( $hw ); $hw = str_replace( '-', ' ', $hw ); $hw = str_replace( 'D LINK ', 'D-Link ', $hw ); $hw = str_replace( ' DIR ', ' DIR-', $hw ); } elseif ( ! strncmp( $hw, 'linksys', 7 ) ) { if ( $discard_vendor ) $hw = str_replace( $discard_vendor, '', $hw ); $hw = strtoupper( $hw ); $hw = str_replace( '-', ' ', $hw ); $hw = str_replace( 'LINKSYS', 'Linksys ', $hw ); $hw = str_replace( ' WRT', ' WRT-', $hw ); } elseif ( ! strncmp( $hw, 'buffalo', 7 ) ) { if ( $discard_vendor ) $hw = str_replace( $discard_vendor, '', $hw ); $hw = strtoupper( $hw ); $hw = str_replace('BUFFALO', 'Buffalo', $hw ); $hw = str_replace( 'HP-AG300H-WZR-600DHP', 'HP-AG300H & WZR-600DHP', $hw ); $hw = str_replace( '-WZR', 'WZR', $hw ); } return $hw; }