Create a PHP and JavaScript snippet to build a ‘Dynamic Admin Favorites’ system. It should function as follows:
The Menu: Add a top-level WP Admin menu item labeled ‘Favorites’.
The ‘Add’ Button: Use the admin_enqueue_scripts hook to inject a small ‘Add to Favorites’ button (using a star dashicon) next to the page title (the .wp-heading-inline or h1) on every admin page.
The Logic: When the star is clicked, use AJAX to save the current page’s URL and Title to the current user’s ‘user_meta’.
The Display: The ‘Favorites’ menu should dynamically list all saved pages as sub-menu items.
Management: Include a simple ‘Clear Favorites’ option at the bottom of the list.
Please ensure the code includes the necessary wp_ajax actions and uses get_user_meta to keep the favorites unique to each logged-in user.