PluginProbe
Code Engine – PHP Snippets, AI Functions & Automation for WordPress / 0.4.3
Code Engine – PHP Snippets, AI Functions & Automation for WordPress v0.4.3
0.5.7 0.5.6 0.5.5 0.5.4 0.5.3 0.5.2 0.5.1 0.5.0 0.4.9 0.4.8 0.4.7 0.4.6 trunk 0.0.1 0.0.2 0.2.8 0.2.9 0.3.0 0.3.1 0.3.2 0.3.3 0.3.4 0.3.5 0.3.6 0.3.7 All 33 releases
← All changes | common/helpers.php +7 -11 0.4.20.4.3 View file →
@@ -117,21 +117,17 @@
117 117 // Pretty permalinks: compare request PATH to the site's REST base path, without using rest_url().
118 118 // This works early in the bootstrap (no dependency on $wp_rewrite).
119 119 $req_path = isset( $_SERVER['REQUEST_URI'] ) ? wp_parse_url( $_SERVER['REQUEST_URI'], PHP_URL_PATH ) : null;
120 120 if ( $req_path ) {
121 - $home_path = wp_parse_url( home_url( '/' ), PHP_URL_PATH ); // e.g. '/' or '/blog/'
122 - $home_path = trailingslashit( $home_path ? $home_path : '/' );
121 + $prefix = rest_get_url_prefix(); // e.g. 'wp-json' or custom
123 122
124 - $prefix = trim( rest_get_url_prefix(), '/' ); // e.g. 'wp-json' or custom
123 + // Check if the path contains /wp-json/ or /index.php/wp-json/
124 + // This handles multilingual plugins (WPML, Polylang) that add language prefixes like /fr/wp-json/
125 + $path = trailingslashit( $req_path );
126 + $rest_pattern = '/' . trim( $prefix, '/' ) . '/';
127 + $rest_pattern_index = '/index.php/' . trim( $prefix, '/' ) . '/';
125 128
126 - // /wp-json/ or /blog/wp-json/
127 - $base = $home_path . trailingslashit( $prefix );
128 -
129 - // /index.php/wp-json/ or /blog/index.php/wp-json/ (index permalinks)
130 - $base_index = $home_path . 'index.php/' . trailingslashit( $prefix );
131 -
132 - $path = trailingslashit( $req_path );
133 - if ( strpos( $path, $base ) === 0 || strpos( $path, $base_index ) === 0 ) {
129 + if ( strpos( $path, $rest_pattern ) !== false || strpos( $path, $rest_pattern_index ) !== false ) {
134 130 MeowKit_MWCODE_Rest::init_once();
135 131 return true;
136 132 }
137 133 }