From 5da0f11d1394bbc956e6b2628926312b5150195d Mon Sep 17 00:00:00 2001 From: Phil Date: Sun, 10 Aug 2014 10:28:05 +1000 Subject: [PATCH 1/2] Added support for 'line-no-highlight' class on lines that do not have highlighting within an embed that contains highlighted lines. --- includes/class-gistpress.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/includes/class-gistpress.php b/includes/class-gistpress.php index 62b6a0b..4a4793f 100644 --- a/includes/class-gistpress.php +++ b/includes/class-gistpress.php @@ -477,6 +477,7 @@ public function process_gist_html( $html, array $args ) { if ( ! empty( $args['highlight'] ) ) { // Flip to use isset() when looping through the lines. $highlight = array_flip( $args['highlight'] ); + $no_highlight = true; } // Extract and cleanup the individual lines from the Gist HTML into an array for processing. @@ -502,6 +503,9 @@ public function process_gist_html( $html, array $args ) { $style = ' style="background-color: ' . $args['highlight_color'] . ' !important"'; } } + elseif( isset($no_highlight) ){ + $classes[] = 'line-no-highlight'; + } /** * Filter the classes applied to a line of the Gist. From 321655f3721f23759a5767ad38bd52d0328b1b10 Mon Sep 17 00:00:00 2001 From: Phil Date: Mon, 11 Aug 2014 09:04:36 +1000 Subject: [PATCH 2/2] Modified code to reflect Wordpress coding standards. Also modified conditional check for a lines validity for the 'line-no-highlight' class so that it is easier to understand. --- includes/class-gistpress.php | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/includes/class-gistpress.php b/includes/class-gistpress.php index 4a4793f..2cda5dc 100644 --- a/includes/class-gistpress.php +++ b/includes/class-gistpress.php @@ -477,7 +477,6 @@ public function process_gist_html( $html, array $args ) { if ( ! empty( $args['highlight'] ) ) { // Flip to use isset() when looping through the lines. $highlight = array_flip( $args['highlight'] ); - $no_highlight = true; } // Extract and cleanup the individual lines from the Gist HTML into an array for processing. @@ -496,16 +495,15 @@ public function process_gist_html( $html, array $args ) { //$classes[] = ( $key % 2 ) ? 'line-odd' : 'line-even'; $style = ''; - if ( isset( $highlight[ $key + 1 ] ) ) { + if ( isset( $highlight[$key + 1] ) ) { $classes[] = 'line-highlight'; if ( ! empty( $args['highlight_color'] ) ) { $style = ' style="background-color: ' . $args['highlight_color'] . ' !important"'; } + } elseif ( ! empty( $args['highlight'] ) ) { + $classes[] = 'line-no-highlight'; } - elseif( isset($no_highlight) ){ - $classes[] = 'line-no-highlight'; - } /** * Filter the classes applied to a line of the Gist.