Skip to content

Commit

Permalink
Merge branch 'release/1.9.6'
Browse files Browse the repository at this point in the history
  • Loading branch information
JiveDig committed Jan 19, 2024
2 parents 4402dc3 + d8687a0 commit 9b7ca83
Show file tree
Hide file tree
Showing 8 changed files with 122 additions and 93 deletions.
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

## 1.9.6 (1/19/24)
* Fixed: Encoded special characters were displaying on the front end in some configurations.

## 1.9.5 (1/18/24)
* Fixed: Custom post type archive conditions not working in some configurations.
* Fixed: Remove unnecessary encoding in PHP's DOMDocument which was unintentionally encoding some special characters from non-English languages.
Expand Down
2 changes: 1 addition & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 20 additions & 1 deletion includes/utilities.php
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,9 @@ function maicca_get_dom_document( $html ) {
// Modify state.
$libxml_previous_state = libxml_use_internal_errors( true );

// Encode.
$html = mb_encode_numericentity( $html, [0x80, 0x10FFFF, 0, ~0], 'UTF-8' );

// Load the content in the document HTML.
$dom->loadHTML( "<div>$html</div>" );

Expand All @@ -270,6 +273,22 @@ function maicca_get_dom_document( $html ) {
return $dom;
}

/**
* Saves HTML from DOMDocument and decode entities.
*
* @since TBD
*
* @param DOMDocument $dom
*
* @return string
*/
function maicca_get_dom_html( $dom ) {
$html = $dom->saveHTML();
$html = mb_convert_encoding( $html, 'UTF-8', 'HTML-ENTITIES' );

return $html;
}

/**
* Adds content area to existing content/HTML.
*
Expand Down Expand Up @@ -387,7 +406,7 @@ function maicca_add_cca( $content, $cca_content, $args ) {
}

// Save new HTML.
$content = $dom->saveHTML();
$content = maicca_get_dom_html( $dom );

return $content;
}
Expand Down
4 changes: 2 additions & 2 deletions mai-custom-content-areas.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Plugin Name: Mai Custom Content Areas
* Plugin URI: https://bizbudding.com/mai-theme/plugins/mai-custom-content-areas/
* Description: Display content, calls to action, ads, etc. on posts, pages, and custom post types conditionally by category, tag, taxonomy, entry title, and more.
* Version: 1.9.5
* Version: 1.9.6
*
* Author: BizBudding
* Author URI: https://bizbudding.com
Expand Down Expand Up @@ -92,7 +92,7 @@ public function __wakeup() {
private function setup_constants() {
// Plugin version.
if ( ! defined( 'MAI_CCA_VERSION' ) ) {
define( 'MAI_CCA_VERSION', '1.9.5' );
define( 'MAI_CCA_VERSION', '1.9.6' );
}

// Plugin Folder Path.
Expand Down
Loading

0 comments on commit 9b7ca83

Please sign in to comment.