Skip to content

Commit

Permalink
Merge branch '1.x'
Browse files Browse the repository at this point in the history
  • Loading branch information
danbleile committed Nov 1, 2023
2 parents 6becde1 + 17833b3 commit 4bca5f7
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 24 deletions.
9 changes: 0 additions & 9 deletions includes/html-snippet-block.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,6 @@ public static function render( $attrs, $content = '' )
}
}

if ($the_query->have_posts() ) {

while ( $the_query->have_posts() ) {
$the_query->the_post();

the_content();
}
}

// Restore original Post Data.
wp_reset_postdata();

Expand Down
41 changes: 26 additions & 15 deletions wsuwp-html-snippets.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/*
Plugin Name: WSU HTML Snippets
Version: 1.2.5
Version: 1.2.6
Description: Embed common HTML content throughout a WordPress site.
Author: washingtonstateuniversity, jeremyfelt
Author URI: https://web.wsu.edu/
Expand Down Expand Up @@ -135,17 +135,35 @@ public function display_html_snippet( $atts ) {
if ( ( empty( $atts['id'] ) || 0 === absint( $atts['id'] ) ) ) {
return '';
}


$post = get_post( $atts['id'] );
$args = array(
'p' => $atts['id'],
'post_type' => 'wsu_html_snippet',
);

$the_query = new WP_Query( $args );

ob_start();

if ( $the_query->have_posts() ) {

while ( $the_query->have_posts() ) {
$the_query->the_post();

the_content();
}
}

// Restore original Post Data.
wp_reset_postdata();

$content = ob_get_clean();

if ( is_multisite() && ms_is_switched() ) {
restore_current_blog();
}

if ( ! $post || $this::$content_type_slug !== $post->post_type ) {
return '';
}

if ( in_array( $atts['container'], array( 'div', 'span' ) ) ) {
$container_open = '<' . $atts['container'];

Expand All @@ -159,19 +177,12 @@ public function display_html_snippet( $atts ) {

$container_open .= '>';

$content = $container_open . apply_filters( 'the_content', $post->post_content ) . '</' . $atts['container'] . '>';
$content = do_shortcode( $content );
} else {
$content = apply_filters( 'the_content', $post->post_content );
$content = do_shortcode( $content );
}

$content = $container_open . $content . '</' . $atts['container'] . '>';

if ( ! has_filter( 'the_content', 'wpautop' ) ) {
$content = wpautop( $content );
}

return $content;

}

/**
Expand Down

0 comments on commit 4bca5f7

Please sign in to comment.