Skip to content

Commit

Permalink
Improve display of cached pattern source #4
Browse files Browse the repository at this point in the history
  • Loading branch information
bobbingwide committed Jan 23, 2022
1 parent 768ba2e commit 0d89508
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions libs/class-oik-patterns-import.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,32 @@ function display_pattern( $pattern ) {

h3( $pattern->title );
sdiv( 'pattern');

sdiv( 'cached');
$cached_pattern = $this->get_cached_file( $pattern );

e( $cached_pattern );
ediv();
p( $pattern->name );
if ( isset( $pattern->categories )) {
p(implode(',', $pattern->categories));
p( "Categories: " . implode(',', $pattern->categories));
}
stag( 'pre', 'pattern', null, 'style="font-size:12px;"');
e( esc_html( $cached_pattern ));
etag( 'pre');
$this->display_cached_pattern_source( $cached_pattern );

ediv();
}

function display_cached_pattern_source( $cached_pattern ) {
stag( 'pre', 'pattern', null, 'style="font-size:12px;"');
$escaped = esc_html( $cached_pattern );
$lines = explode( "\n", $escaped );
$reformed = '';
foreach ( $lines as $line ) {
$reformed .= trim( $line ) . "\n";
}
e( $reformed );
etag( 'pre');
}

function get_cached_file( $pattern ) {
$file = $this->get_pattern_filename( $pattern );
if ( file_exists( $file )) {
Expand Down

0 comments on commit 0d89508

Please sign in to comment.