@@ -38,26 +38,55 @@ function register_rest_route( $route_namespace, $route, $args = array(), $overri
3838 * and namespace indexes. If you really need to register a
3939 * non-namespaced route, call `WP_REST_Server::register_route` directly.
4040 */
41- _doing_it_wrong ( 'register_rest_route ' , __ ( 'Routes must be namespaced with plugin or theme name and version. ' ), '4.4.0 ' );
41+ _doing_it_wrong (
42+ __FUNCTION__ ,
43+ sprintf (
44+ /* translators: 1: string value of the namespace, 2: string value of the route. */
45+ __ ( 'Routes must be namespaced with plugin or theme name and version. Instead there seems to be an empty namespace \'%1$s \' for route \'%2$s \'. ' ),
46+ '<code> ' . $ route_namespace . '</code> ' ,
47+ '<code> ' . $ route . '</code> '
48+ ),
49+ '4.4.0 '
50+ );
4251 return false ;
4352 } elseif ( empty ( $ route ) ) {
44- _doing_it_wrong ( 'register_rest_route ' , __ ( 'Route must be specified. ' ), '4.4.0 ' );
53+ _doing_it_wrong (
54+ __FUNCTION__ ,
55+ sprintf (
56+ /* translators: 1: string value of the namespace, 2: string value of the route. */
57+ __ ( 'Route must be specified. Instead within the namespace \'%1$s \', there seems to be an empty route \'%2$s \'. ' ),
58+ '<code> ' . $ route_namespace . '</code> ' ,
59+ '<code> ' . $ route . '</code> '
60+ ),
61+ '4.4.0 '
62+ );
4563 return false ;
4664 }
4765
4866 $ clean_namespace = trim ( $ route_namespace , '/ ' );
4967
5068 if ( $ clean_namespace !== $ route_namespace ) {
51- _doing_it_wrong ( __FUNCTION__ , __ ( 'Namespace must not start or end with a slash. ' ), '5.4.2 ' );
69+ _doing_it_wrong (
70+ __FUNCTION__ ,
71+ sprintf (
72+ /* translators: 1: string value of the namespace, 2: string value of the route. */
73+ __ ( 'Namespace must not start or end with a slash. Instead namespace \'%1$s \' for route \'%2$s \' seems to contain a slash. ' ),
74+ '<code> ' . $ route_namespace . '</code> ' ,
75+ '<code> ' . $ route . '</code> '
76+ ),
77+ '5.4.2 '
78+ );
5279 }
5380
5481 if ( ! did_action ( 'rest_api_init ' ) ) {
5582 _doing_it_wrong (
56- ' register_rest_route ' ,
83+ __FUNCTION__ ,
5784 sprintf (
58- /* translators: %s: rest_api_init */
59- __ ( 'REST API routes must be registered on the %s action. ' ),
60- '<code>rest_api_init</code> '
85+ /* translators: 1: rest_api_init, 2: string value of the route, 3: string value of the namespace. */
86+ __ ( 'REST API routes must be registered on the %1$s action. Instead route \'%2$s \' with namespace \'%3$s \' was not registered on this action. ' ),
87+ '<code>rest_api_init</code> ' ,
88+ '<code> ' . $ route . '</code> ' ,
89+ '<code> ' . $ route_namespace . '</code> '
6190 ),
6291 '5.1.0 '
6392 );
0 commit comments