File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed
content/plugins/f-api/inc Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -27,6 +27,7 @@ function bootstrap() : void {
27
27
28
28
// Register our own rewrites.
29
29
add_action ( 'init ' , __NAMESPACE__ . '\\register_rewrites ' );
30
+ add_action ( 'parse_request ' , __NAMESPACE__ . '\\redirect_old_namespace ' , 0 );
30
31
31
32
Events \bootstrap ();
32
33
}
@@ -44,3 +45,14 @@ function register_rewrites() : void {
44
45
add_rewrite_rule ( '$ ' , 'index.php?rest_route=/ ' , 'bottom ' );
45
46
add_rewrite_rule ( '^(.*)? ' , 'index.php?rest_route=/$matches[1] ' , 'bottom ' );
46
47
}
48
+
49
+ /**
50
+ * Redirect the wp-json default prefix.
51
+ */
52
+ function redirect_old_namespace () : void {
53
+ if ( strpos ( $ _SERVER ['REQUEST_URI ' ], '/wp-json/ ' ) !== false ) {
54
+ $ new_url = substr ( $ _SERVER ['REQUEST_URI ' ], 8 );
55
+ wp_safe_redirect ( rest_url ( $ new_url ), 301 );
56
+ exit ;
57
+ }
58
+ }
You can’t perform that action at this time.
0 commit comments