Skip to content

Commit 082f791

Browse files
author
gitlost
committed
Version 1.0.6.
1 parent fa6d985 commit 082f791

14 files changed

+175
-178
lines changed

.travis.yml

+3-4
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ php:
1414
env:
1515
- WP_VERSION=nightly
1616
- WP_VERSION=latest
17+
- WP_VERSION=4.7
1718
- WP_VERSION=4.6.1
1819
- WP_VERSION=4.5.4
1920
- WP_VERSION=4.4.5
@@ -25,8 +26,6 @@ env:
2526

2627
matrix:
2728
exclude:
28-
- php: 7.1
29-
env: WP_VERSION=latest
3029
- php: 7.1
3130
env: WP_VERSION=4.6.1
3231
- php: 7.1
@@ -63,9 +62,9 @@ before_script:
6362
- bash bin/install-wp-tests.sh wordpress_test root '' localhost $WP_VERSION
6463

6564
script:
66-
- PHPRC=. WP_TESTS_DIR=/tmp/wordpress-tests-lib phpunit
65+
- PHPRC=. WP_TESTS_DIR=/tmp/wordpress-tests-lib phpunit --verbose
6766

6867
after_success:
69-
- if [[ ( $TRAVIS_PHP_VERSION = '7' || $TRAVIS_PHP_VERSION > '7' ) && $WP_VERSION = 'latest' ]] then
68+
- if [[ $TRAVIS_PHP_VERSION = '7.1' && $WP_VERSION = 'latest' ]] then
7069
- PHPRC=. WP_TESTS_DIR=/tmp/wordpress-tests-lib phpunit --coverage-clover clover.xml && bash <(curl -s https://codecov.io/bash)
7170
- fi

README.md

+25-29
Original file line numberDiff line numberDiff line change
@@ -5,54 +5,42 @@
55
**Contributors:** [gitlost](https://profiles.wordpress.org/gitlost), [zodiac1978](https://profiles.wordpress.org/zodiac1978)
66
**Tags:** Unicode, Normalization, Form C, Unicode Normalization Form C, Normalize, Normalizer, UTF-8, NFC
77
**Requires at least:** 3.9.13
8-
**Tested up to:** 4.7.0
9-
**Stable tag:** 1.0.5
8+
**Tested up to:** 4.7.1
9+
**Stable tag:** 1.0.6
1010
**License:** GPLv2 or later
1111
**License URI:** http://www.gnu.org/licenses/gpl-2.0.html
1212

1313
Normalizes UTF-8 input to Normalization Form C.
1414

1515
## Description ##
1616

17-
This is a souped-up version of the [Normalizer plugin](https://wordpress.org/plugins/normalizer/ "Normalizer - WordPress Plugins") by
18-
[Torsten Landsiedel](https://profiles.wordpress.org/zodiac1978/).
17+
This is a souped-up version of the [Normalizer plugin](https://wordpress.org/plugins/normalizer/ "Normalizer - WordPress Plugins") by [Torsten Landsiedel](https://profiles.wordpress.org/zodiac1978/).
1918

20-
It adds WP filters to normalize UTF-8 data coming into the system to the
21-
[de facto web standard Normalization Form C](https://www.w3.org/International/docs/charmod-norm/#choice-of-normalization-form "Choice of Normalization Form").
22-
The Unicode Consortium report is at [Unicode Normalization Forms](http://www.unicode.org/reports/tr15/).
19+
It adds WP filters to normalize UTF-8 data coming into the system to the [de facto web standard Normalization Form C](https://www.w3.org/International/docs/charmod-norm/#choice-of-normalization-form "Choice of Normalization Form"). The Unicode Consortium report is at [Unicode Normalization Forms](http://www.unicode.org/reports/tr15/).
2320

2421
### Polyfills ###
2522

26-
For best performance [install](http://php.net/manual/en/intl.installation.php) (if possible)
27-
the [PHP Internationalization extension `Intl`](http://php.net/manual/en/intro.intl.php),
28-
which includes the PHP class `Normalizer`.
23+
For best performance [install](http://php.net/manual/en/intl.installation.php) (if possible) the [PHP Internationalization extension `Intl`](http://php.net/manual/en/intro.intl.php), which includes the PHP class `Normalizer`.
2924

30-
However the plugin works without the PHP `Intl` extension being installed, as it uses (a modified version of)
31-
the [Symfony `Normalizer` polyfill](https://github.com/symfony/polyfill/tree/master/src/Intl/Normalizer).
25+
However the plugin works without the PHP `Intl` extension being installed, as it uses (a modified version of) the [Symfony `Normalizer` polyfill](https://github.com/symfony/polyfill/tree/master/src/Intl/Normalizer).
3226

33-
Also text pasted into (most) inputs is normalized immediately using the JavaScript [`normalize()` method](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/String/normalize).
34-
For browsers without normalization support, the [unorm polyfill](https://github.com/walling/unorm) is used.
27+
Also text pasted into (most) inputs is normalized immediately using the JavaScript [`normalize()` method](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/String/normalize). For browsers without normalization support, the [unorm polyfill](https://github.com/walling/unorm) is used.
3528

3629
### Background ###
3730

38-
For further info, see the WP Trac ticket [#30130 Normalize characters with combining marks to precomposed characters](https://core.trac.wordpress.org/ticket/30130)
39-
and this [Make WP Core comment](https://make.wordpress.org/core/2016/05/17/may-17-feature-projects-chat-and-prompt/#comment-30300).
31+
For further info, see the WP Trac ticket [#30130 Normalize characters with combining marks to precomposed characters](https://core.trac.wordpress.org/ticket/30130) and this [Make WP Core comment](https://make.wordpress.org/core/2016/05/17/may-17-feature-projects-chat-and-prompt/#comment-30300).
4032

4133
The plugin also works around the Safari-specific issues raised by the WP Trac ticket [#22363 Accents in attachment filenames should be sanitized](https://core.trac.wordpress.org/ticket/22363).
4234

4335
### Scanner ###
4436

45-
For existing data, the plugin includes an administration tool to scan and normalize the database.
46-
**Important:** before using this tool to normalize, please [backup your database](https://codex.wordpress.org/WordPress_Backups).
47-
This is especially important if your database contains non-normalized serialized data, as this plugin uses the same suck-and-see technique as interconnect/it's
48-
[Database Search and Replace Script in PHP](https://interconnectit.com/products/search-and-replace-for-wordpress-databases/) to deal with serialized
49-
data, and is fallible.
37+
For existing data, the plugin includes an administration tool to scan and normalize the database. **Important:** before using this tool to normalize, please [backup your database](https://codex.wordpress.org/WordPress_Backups). This is especially important if your database contains non-normalized serialized data, as this plugin uses the same suck-and-see technique as interconnect/it's [Database Search and Replace Script in PHP](https://interconnectit.com/products/search-and-replace-for-wordpress-databases/) to deal with serialized data, and is fallible.
5038

5139
### And ###
5240

5341
A google-cheating schoolboy French translation is supplied.
5442

55-
The plugin should run on PHP 5.2.17 to 7.0.13, and on WP 3.9.13 to 4.7.0.
43+
The plugin should run on PHP 5.2.17 to 7.1, and on WP 3.9.13 to 4.7.1.
5644

5745
The project is on [github](https://github.com/gitlost/unfc-normalize).
5846

@@ -64,23 +52,23 @@ Install in the standard way via the 'Plugins' menu in WordPress and then activat
6452

6553
### How can I normalize extra stuff? ###
6654

67-
You can add normalization to anything that passes its content through a filter. The canonical way is to use the `unfc_extra_filters` filter which returns an array of filter names -
68-
for instance, in your theme's `functions.php` file, add:
55+
You can add normalization to anything that passes its content through a filter. The canonical way is to use the `unfc_extra_filters` filter which returns an array of filter names - for instance, in your theme's `functions.php` file, add:
6956

7057
function mytheme_unfc_extra_filters( $extra_filters ) {
7158
$extra_filters[] = 'myfilter';
7259
return $extra_filters;
7360
}
7461
add_filter( 'unfc_extra_filters', 'mytheme_unfc_extra_filters' );
7562

76-
Note that the `unfc_extra_filters` filter is only called in the administration backend. You can also add a filter directly, to be called in the frontend or backend, by referencing the
77-
global PHP variable `unfc_normalize`, but you should ensure that the `Normalizer` polyfill is loaded if you don't have the PHP `Intl` extension installed:
63+
Note that the `unfc_extra_filters` filter is only called in the administration backend. You can also add a filter directly, to be called in the frontend or backend, by referencing the global PHP variable `unfc_normalize`, but you should ensure that the `Normalizer` polyfill is loaded if you don't have the PHP `Intl` extension installed:
7864

7965
global $unfc_normalize;
80-
if ( ! function_exists( 'normalizer_is_normalized' ) ) { // If the "Intl" extension is not installed...
81-
$unfc_normalize->load_unfc_normalizer_class(); // ...load the polyfill.
66+
if ( $unfc_normalize ) {
67+
if ( ! function_exists( 'normalizer_is_normalized' ) ) { // If the "Intl" extension is not installed...
68+
$unfc_normalize->load_unfc_normalizer_class(); // ...load the polyfill.
69+
}
70+
add_filter( 'myfilter', array( $unfc_normalize, 'normalize' ), 6 /* Or whatever priority you choose */ );
8271
}
83-
add_filter( 'myfilter', array( $unfc_normalize, 'normalize' ), 6 /* Or whatever priority you choose */ );
8472

8573
### Does it have a tool to normalize the filenames of files uploaded prior to its enabling? ###
8674

@@ -103,6 +91,11 @@ No, it doesn't. Alas, such files would have to re-uploaded. However if (enough -
10391

10492
## Changelog ##
10593

94+
### 1.0.6 ###
95+
* Require explicit define of UNFC_DEBUG. Move load of debug file to 'init'.
96+
* Safari submit workaround.
97+
* WP 4.7.1 compatible.
98+
10699
### 1.0.5 ###
107100
* Do load of normalizer in slugs list constructor not items list. Fixes slugs listing crash when Intl extension not installed.
108101
* Ignore case when checking charset (UNFC_Normalize::is_blog_utf8()).
@@ -144,6 +137,9 @@ No, it doesn't. Alas, such files would have to re-uploaded. However if (enough -
144137

145138
## Upgrade Notice ##
146139

140+
### 1.0.6 ###
141+
Less noisy when WP_DEBUG set.
142+
147143
### 1.0.5 ###
148144
Fixes fatal error on check slugs listing in DB check tool when Intl extension not available.
149145

dist/unfc-normalize-1.0.5.zip

-13 Bytes
Binary file not shown.

dist/unfc-normalize-1.0.6.zip

160 KB
Binary file not shown.

includes/class-unfc-normalize.php

+10-11
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,11 @@ static function tested_wp_version() {
346346
* Called on 'init' action.
347347
*/
348348
function init() {
349-
//unfc_debug_log( "dont_js=", $this->dont_js, ", dont_paste=", $this->dont_paste, ", dont_filter=", $this->dont_filter, ", no_normalizer=", $this->no_normalizer );
349+
// Debug functions - no-ops unless UNFC_DEBUG is set.
350+
if ( ! function_exists( 'unfc_debug_log' ) ) {
351+
require dirname( __FILE__ ) . '/debug.php';
352+
}
353+
unfc_debug_log( "dont_js=", $this->dont_js, ", dont_paste=", $this->dont_paste, ", dont_filter=", $this->dont_filter, ", no_normalizer=", $this->no_normalizer );
350354

351355
$this->base = '';
352356
// TODO: Reset $this->added_filters ??
@@ -558,7 +562,7 @@ function init() {
558562
}
559563
}
560564

561-
//unfc_debug_log( "base=", $this->base, ", added_filters=", $this->added_filters );
565+
unfc_debug_log( "base=", $this->base, ", added_filters=", $this->added_filters );
562566
}
563567

564568
/**
@@ -823,8 +827,8 @@ function sanitize_meta( $meta_value, $meta_key, $meta_type ) {
823827
* Called on 'admin_enqueue_scripts' and 'wp_enqueue_scripts' actions.
824828
*/
825829
function enqueue_scripts() {
826-
$suffix = defined( "SCRIPT_DEBUG" ) && SCRIPT_DEBUG ? '' : '.min';
827-
$rangyinputs_suffix = defined( "SCRIPT_DEBUG" ) && SCRIPT_DEBUG ? '-src' : '';
830+
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
831+
$rangyinputs_suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '-src' : '';
828832

829833
// Load IE8 Array.prototype.reduceRight polyfill for unorm.
830834
wp_enqueue_script( 'unfc-ie8', plugins_url( "js/ie8{$suffix}.js", UNFC_FILE ), array(), UNFC_VERSION );
@@ -844,10 +848,10 @@ function enqueue_scripts() {
844848
// Our parameters.
845849
$params = array(
846850
'please_wait_msg' => '<div class="notice notice-warning inline"><p>' . __( 'Please wait...', 'unfc-normalize' )
847-
. '<span class="spinner is-active" style="float:none;margin-top:0;"></span></p></div>',
851+
. '<span class="spinner is-active" style="float:none;margin-top:-2px;"></span></p></div>',
848852
'no_items_selected_msg' => '<div class="notice notice-warning is-dismissible inline"><p>' . $this->db_check_error_msg( UNFC_DB_CHECK_SELECT_ERROR ) . '</p></div>',
849853
'is' => array( // Gets around stringification of direct localize elements.
850-
'script_debug' => defined( "SCRIPT_DEBUG" ) && SCRIPT_DEBUG,
854+
'script_debug' => defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG && defined( 'UNFC_DEBUG' ) && UNFC_DEBUG,
851855
'dont_paste' => $this->dont_paste,
852856
'db_check_loaded' => $this->db_check_loaded,
853857
),
@@ -2480,8 +2484,3 @@ static function get_post_meta( $post_id, $key = '', $single = false /*ignore*/ )
24802484
return $ret;
24812485
}
24822486
}
2483-
2484-
// Debug functions - no-ops unless WP_DEBUG is set.
2485-
if ( ! function_exists( 'unfc_debug_log' ) ) {
2486-
require dirname( __FILE__ ) . '/debug.php';
2487-
}

includes/debug.php

+2-3
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@
66
// Exit if accessed directly.
77
if ( ! defined( 'ABSPATH' ) ) exit;
88

9-
if ( ! defined( 'UNFC_DEBUG' ) ) define( 'UNFC_DEBUG', defined( 'WP_DEBUG' ) ? WP_DEBUG : false );
10-
11-
if ( UNFC_DEBUG ) :
9+
if ( defined( 'UNFC_DEBUG' ) && UNFC_DEBUG ) :
1210

1311
if ( ! defined( 'UNFC_DEBUG_PRINT_LIMIT' ) ) define( 'UNFC_DEBUG_PRINT_LIMIT', 256 );
1412

@@ -31,6 +29,7 @@ function unfc_error_log() {
3129
*/
3230
function unfc_debug_log() {
3331
if ( ! UNFC_DEBUG ) return '';
32+
if ( defined( 'DOING_AJAX' ) && DOING_AJAX && isset( $_REQUEST['action'] ) && is_string( $_REQUEST['action'] ) && 'heartbeat' === $_REQUEST['action'] ) return '';
3433
$func_get_args = func_get_args();
3534
$ret = unfc_debug_trace( debug_backtrace(), $func_get_args );
3635
$ret[0] = $ret[0] . "\n\t";

js/unfc-normalize.js

+10-2
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,14 @@ var unfc_normalize = unfc_normalize || {}; // Our namespace.
158158
$msgs.hide();
159159
$( 'h1', $db_check ).first().after( $msg );
160160
unfc_normalize.makeNoticesDismissible( $db_check );
161+
if ( $.browser && $.browser.safari ) {
162+
// Safari apparently suspends rendering in a submit handler, so hack around it. See http://stackoverflow.com/a/1164177/664741
163+
// Still no spinner, but better than nothing.
164+
e.preventDefault();
165+
$( '.spinner', $msg ).removeClass( 'is-active' ); // Hide as it doesn't spin.
166+
$this.unbind( 'click' );
167+
setTimeout( function() { $this.click(); }, 0 );
168+
}
161169
} );
162170
}
163171
};
@@ -170,12 +178,12 @@ var unfc_normalize = unfc_normalize || {}; // Our namespace.
170178
if ( $db_check_list.length ) {
171179
$form = $( 'form.unfc_db_check_list_form', $db_check_list );
172180
if ( $form.length ) {
173-
// Remove the "wp-admin/common.js" #17685 submit handler which doesn't apply here & is buggy anyway.
181+
// Remove the "wp-admin/js/common.js" #17685 submit handler which doesn't apply here & is buggy anyway.
174182
$form.off( 'submit' );
175183
// Save some round-tripping to the server for nowt.
176184
$( '#doaction, #doaction2', $db_check_list ).click( function ( e ) {
177185
var $bulk_action = $( '#bulk-action-selector-' + ( 'doaction' === this.id ? 'top' : 'bottom' ) + ' option:selected', $db_check_list ),
178-
action = $bulk_action.val(), $current_page = $( 'input#current-page-selector', $db_check_list ), $msg, $msgs, checkeds;
186+
action = $bulk_action.val(), $msg, $msgs, checkeds;
179187
if ( '-1' !== action ) {
180188
checkeds = $.makeArray( $( 'input[name="item[]"]:checked', $db_check_list ).map( function () {
181189
return this.value;

0 commit comments

Comments
 (0)