Skip to content

Commit

Permalink
Issue #9 - Update message for bad lang= parameter to GeSHi
Browse files Browse the repository at this point in the history
  • Loading branch information
bobbingwide committed Dec 15, 2019
1 parent c531095 commit 6b1f807
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
12 changes: 9 additions & 3 deletions oik-css.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Plugin Name: oik-css
Plugin URI: https://www.oik-plugins.com/oik-plugins/oik-css
Description: Implements [bw_css] shortcode for internal CSS styling and to help document CSS examples and [bw_geshi] for other languages
Version: 1.0.0-alpha-20191213
Version: 1.0.0-alpha-20191214
Author: bobbingwide
Author URI: https://bobbingwide.com/about-bobbing-wide
Text Domain: oik-css
Expand Down Expand Up @@ -250,9 +250,10 @@ function oik_css_plugin_loaded() {
* This logic is expected to run independent of oik and oik-blocks
*/
function oik_css_init_blocks() {
oik_css_boot_libs();
//oik_css_boot_libs();
oik_css_plugins_loaded();
$library_file = oik_require_lib( 'oik-blocks');
bw_trace2( $library_file, "library_file", false );
//bw_trace2( $library_file, "library_file", false );
oik\oik_blocks\oik_blocks_register_editor_scripts( 'oik-css', 'oik-css');
oik\oik_blocks\oik_blocks_register_block_styles( 'oik-css' );
//oik_css_register_editor_scripts();
Expand Down Expand Up @@ -377,6 +378,11 @@ function oik_css_dynamic_block_css( $attributes ) {
function oik_css_dynamic_block_geshi( $attributes ) {
$html = \oik\oik_blocks\oik_blocks_check_server_func( 'shortcodes/oik-geshi.php', 'oik-css', 'oik_geshi' );
if ( ! $html ) {
$lang = bw_array_get( $attributes, 'lang', null );
if ( empty( $lang ) ) {
$attributes['lang'] = 'none';
}

$content = bw_array_get( $attributes, 'content', null );
$html = oik_geshi( $attributes, $content );
if ( ! $html ) {
Expand Down
14 changes: 3 additions & 11 deletions shortcodes/oik-geshi.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php // (C) Copyright Bobbing Wide 2013-2017
<?php // (C) Copyright Bobbing Wide 2013-2019

/**
* Validate the language for GeSHi
Expand All @@ -12,18 +12,17 @@
*
*/
function oik_css_validate_lang( $lang, &$text ) {
//bw_trace2();
$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 ) {
BW_::p( sprintf( __( 'Invalid %1$s parameter for bw_geshi shortcode. %2$s', "oik-css" ), "lang=", $lang ) );
BW_::p( sprintf( __( 'Invalid %1$s parameter for GeSHi. %2$s', "oik-css" ), "lang=", $lang ) );
BW_::p( "$vlang,$text" );
}
return( $vlang );
Expand Down Expand Up @@ -133,10 +132,3 @@ function bw_geshi__example( $shortcode="bw_css" ) {
$expanded = apply_filters( 'the_content', $example );
e( $expanded );
}







0 comments on commit 6b1f807

Please sign in to comment.