File size: 2,242 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import { __ } from '@wordpress/i18n';

export const useQueryForRoute = ( currentRoute: string ) => {
	const urlMapping = {
		'/advertising/': __( 'advertising' ),
		'/comments/': __( 'comments' ),
		'/discover': __( 'discover blogs' ),
		'/hosting-config/': __( 'hosting configuration' ),
		'/marketing/sharing-buttons/': __( 'social share' ),
		'/me/get-apps': __( 'wordpress apps' ),
		'/me/notifications': __( 'notification settings' ),
		'/me/privacy': __( 'privacy' ),
		'/me/site-blocks': __( 'blocked sites' ),
		'/plugins/manage': __( 'manage plugins' ),
		'/reader': __( 'reader' ),
		'/reader/conversations': __( 'conversations' ),
		'/reader/list': __( 'reader list' ),
		'/reader/notifications': __( 'notifications' ),
		'/reader/search': __( 'search' ),
		'/reader/subscriptions': __( 'manage subscriptions' ),
		'/settings/performance/': __( 'performance settings' ),
		'/settings/podcasting/': __( 'podcasting' ),
		'/settings/reading/': __( 'reading settings' ),
		'/settings/taxonomies/category/': __( 'site categories' ),
		'/settings/taxonomies/post_tag/': __( 'post tag' ),
		'/settings/writing/': __( 'writing settings' ),
		'/tags': __( 'tags' ),
		'/woocommerce': __( 'woocommerce' ),
		'/wp-admin/admin.php?page=akismet-key-config': __( 'site spam' ),
		'/wp-admin/admin.php?page=jetpack-search': __( 'jetpack search' ),
		'/wp-admin/admin.php?page=wc': __( 'woocommerce' ),
		'/wp-admin/admin.php?page=jetpack-forms-admin': __( 'forms' ),
		'/wp-admin/edit.php?post_type=jetpack-testimonial': __( 'testimonials' ),
		'/wp-admin/index.php?page=my-blogs': __( 'my sites' ),
		'/wp-admin/options-general.php?page=debug-bar-extender': __( 'debug bar extender' ),
		'/wp-admin/options-media.php': __( 'media settings' ),
		'/wp-admin/post-new.php?post_type=jetpack-testimonial': __( 'new testimonial' ),
		'/wp-admin/site-editor.php?p=%2Fpattern': __( 'patterns' ),
	};

	// Find exact URL matches
	const exactMatch = urlMapping[ currentRoute as keyof typeof urlMapping ];
	if ( exactMatch ) {
		return exactMatch;
	}

	// Fuzzier matches
	const urlMatchKey = Object.keys( urlMapping ).find( ( key ) => currentRoute?.startsWith( key ) );
	return urlMatchKey ? urlMapping[ urlMatchKey as keyof typeof urlMapping ] : '';
};