diff --git a/syntaxhighlighter.php b/syntaxhighlighter.php index ee3b9d0..823cece 100644 --- a/syntaxhighlighter.php +++ b/syntaxhighlighter.php @@ -101,6 +101,7 @@ function_exists( 'parse_blocks' ) // WordPress 5.0+ 'collapse' => 0, 'firstline' => 1, 'gutter' => 1, + 'maxheight' => 0, // 0 disables the max-height cap 'htmlscript' => 0, 'light' => 0, 'padlinenumbers' => 'false', @@ -1138,6 +1139,14 @@ function maybe_output_scripts() { echo " SyntaxHighlighter.defaults['quick-code'] = false;\n"; } + if ( ! empty( $this->settings['maxheight'] ) ) { + $maxheight = (int) $this->settings['maxheight']; + echo " var maxheightcss = document.createElement( 'style' );\n"; + echo " maxheightcss.setAttribute( 'type', 'text/css' );\n"; + echo " maxheightcss.appendChild( document.createTextNode( '" . esc_attr( ".syntaxhighlighter { max-height: {$maxheight}px !important; overflow-y: auto !important; }" ) . "' ) );\n"; + echo " document.head.appendChild( maxheightcss );\n"; + } + ?> SyntaxHighlighter.all(); // Infinite scroll support @@ -1490,6 +1499,14 @@ function settings_page() { ?> +