Description
Validate the language for GeSHiUse 'none' when you want the output to be displayed ASIS; GeSHi is not used for this. 'html' is an alias for 'html5'. It uses the same GeSHi code.
Usage
$string = oik_css_validate_lang( $lang, $text );Parameters
- $lang
- ( string ) required – the required languange ( case insensitive )
- $text
- ( string ) required – alternative parameter for language ( case sensitive )
Returns
string the validated language, or nullSource
File name: oik-css/shortcodes/oik-geshi.phpLines:
1 to 19 of 19
function oik_css_validate_lang( $lang, &$text ) { if ( null !== $lang ) { $lang=strtolower( $lang ); } $valid = bw_assoc( bw_as_array( "css,html,javascript,jquery,php,html5,none,mysql" )); $vlang = bw_array_get( $valid, $lang, null ); if ( !$vlang ) { $vlang = bw_array_get( $valid, $text, null ); if ( $vlang ) { $text = $lang; } } if ( !$vlang ) { /* translators: %1: Hardcoded string lang=, not translatable, %2: language parameter passed */ BW_::p( sprintf( __( 'Invalid %1$s parameter for GeSHi. %2$s', "oik-css" ), "lang=", $lang ) ); BW_::p( "$vlang,$text" ); } return( $vlang ); }View on GitHub View on Trac
Called by
1 to 4 of 4
- bw_format_content() – Format the content for the chosen language
- Tests_shortcodes_oik_geshi::test_oik_css_validate_lang() – Tests oik_css_validate_lang
- Tests_shortcodes_oik_geshi::test_oik_css_validate_lang_bb_BB() – Tests invalid language – when user forgets it in the shortcode
- Tests_shortcodes_oik_geshi::test_oik_css_validate_lang_en_GB() – Tests invalid language – when user forgets it in the shortcode
Invoked by
Calls
1 to 5 of 5
- BW_::p() – Outputs a paragraph of translated text
- bw_array_get() – Return the array[index] or array->index (for an object) or a default value if not set
- bw_assoc() – Convert a simple array into an associative array keyed on the value
- bw_as_array() – Split a string into an array if necessary
- p() – Output a paragraph of translatable text
