|
32 | 32 | require_once __DIR__ . '/src/xml-api/WP_XML_Decoder.php';
|
33 | 33 | require_once __DIR__ . '/src/xml-api/WP_XML_Processor.php';
|
34 | 34 | require_once __DIR__ . '/src/WP_WXR_URL_Rewrite_Processor.php';
|
35 |
| - |
| 35 | +require_once __DIR__ . '/src/WP_WXR_Reader.php'; |
| 36 | +require_once __DIR__ . '/src/utf8_decoder.php'; |
36 | 37 | require_once __DIR__ . '/vendor/autoload.php';
|
37 | 38 |
|
38 |
| - |
39 | 39 | // Polyfill WordPress core functions
|
| 40 | +$GLOBALS['_doing_it_wrong_messages'] = []; |
40 | 41 | function _doing_it_wrong($method, $message, $version) {
|
| 42 | + $GLOBALS['_doing_it_wrong_messages'][] = $message; |
41 | 43 | }
|
42 | 44 |
|
43 | 45 | function __($input) {
|
@@ -77,3 +79,37 @@ function wp_kses_uri_attributes() {
|
77 | 79 | 'xmlns',
|
78 | 80 | );
|
79 | 81 | }
|
| 82 | + |
| 83 | +function mbstring_binary_safe_encoding( $reset = false ) { |
| 84 | + static $encodings = array(); |
| 85 | + static $overloaded = null; |
| 86 | + |
| 87 | + if ( is_null( $overloaded ) ) { |
| 88 | + if ( function_exists( 'mb_internal_encoding' ) |
| 89 | + && ( (int) ini_get( 'mbstring.func_overload' ) & 2 ) // phpcs:ignore PHPCompatibility.IniDirectives.RemovedIniDirectives.mbstring_func_overloadDeprecated |
| 90 | + ) { |
| 91 | + $overloaded = true; |
| 92 | + } else { |
| 93 | + $overloaded = false; |
| 94 | + } |
| 95 | + } |
| 96 | + |
| 97 | + if ( false === $overloaded ) { |
| 98 | + return; |
| 99 | + } |
| 100 | + |
| 101 | + if ( ! $reset ) { |
| 102 | + $encoding = mb_internal_encoding(); |
| 103 | + array_push( $encodings, $encoding ); |
| 104 | + mb_internal_encoding( 'ISO-8859-1' ); |
| 105 | + } |
| 106 | + |
| 107 | + if ( $reset && $encodings ) { |
| 108 | + $encoding = array_pop( $encodings ); |
| 109 | + mb_internal_encoding( $encoding ); |
| 110 | + } |
| 111 | +} |
| 112 | + |
| 113 | +function reset_mbstring_encoding() { |
| 114 | + mbstring_binary_safe_encoding( true ); |
| 115 | +} |
0 commit comments