Skip to content

Commit

Permalink
Make Mbstring extension a requirement
Browse files Browse the repository at this point in the history
  • Loading branch information
joppuyo committed Sep 8, 2018
1 parent 39de496 commit 34cac9a
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 4 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ Don't you just hate it when your beautiful HTML markup is mutilated due to a tem

Use this plugin to indent the HTML markup output by WordPress using the [Dindent](https://github.com/gajus/dindent) library. It only does its thing when you are not logged in.

## Requirements

* PHP 5.3 or greater
* Mbstring extension

## Installation

### Composer (with [Bedrock](https://roots.io/bedrock/))
Expand Down
12 changes: 10 additions & 2 deletions html-markup-indenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Plugin Name: HTML Markup Indenter
Plugin URI: https://github.com/joppuyo/html-markup-cleaner
Description: Indents the HTML markup output by WordPress
Version: 1.0.1
Version: 2.0.0
Author: Johannes Siipola
Author URI: https://siipo.la
*/
Expand All @@ -20,7 +20,7 @@
});

add_action('shutdown', function () {
if (html_markup_indenter_is_html() && !is_user_logged_in()) {
if (extension_loaded('mbstring') && html_markup_indenter_is_html() && !is_user_logged_in()) {
$final = '';
$levels = ob_get_level();
for ($i = 0; $i < $levels; $i++) {
Expand All @@ -39,3 +39,11 @@ function html_markup_indenter_is_html() {
}
return false;
}

add_action('admin_notices', function() {
if (!extension_loaded('mbstring')) {
echo '<div class="notice notice-warning"><p>';
echo __("Mbstring PHP extension is not loaded. HTML Markup Indenter has been disabled.", 'html-markup-indenter');
echo '</p></div>';
}
});
12 changes: 10 additions & 2 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,22 @@ Tested up to: 4.9.4
Requires PHP: 5.3.0 or greater
License: License: GPLv3 or later

Indents the HTML markup output by WordPress
Indents the HTML markup output by WordPress.

== Description ==
Indents the HTML markup output by WordPress using the [Dindent](https://github.com/gajus/dindent) library. It only does its thing when you are not logged in.
Indents the HTML markup output by WordPress using the [Dindent](https://github.com/gajus/dindent) library. It only does its thing when you are not logged in. Requires PHP mbstring extension to be installed.

== Installation ==
1. Upload the plugin folder to the /wp-content/plugins/ directory
2. Activate the plugin through the Plugins menu in WordPress

== Changelog ==

= 2.0.0 =
* Make Mbstring extension a requirement

= 1.0.1 =
* Only indent HTML markup

= 1.0.0 =
* Initial release

0 comments on commit 34cac9a

Please sign in to comment.