This commit is contained in:
rodolfomartinez 2026-02-02 00:13:36 -05:00
parent 572552ff13
commit 847ed92c23
10 changed files with 1232 additions and 591 deletions

View file

@ -122,6 +122,7 @@ function mlf_init() {
if (is_admin()) {
new MLF_Admin_Page();
new MLF_Ajax_Handler();
new MLF_Font_Search();
}
}
add_action('plugins_loaded', 'mlf_init', 20);
@ -155,9 +156,9 @@ function mlf_get_capability() {
*/
function mlf_register_menu() {
add_submenu_page(
'themes.php',
__('Maple Local Fonts', 'maple-local-fonts'),
__('Local Fonts', 'maple-local-fonts'),
'options-general.php',
__('Maple Fonts', 'maple-local-fonts'),
__('Maple Fonts', 'maple-local-fonts'),
mlf_get_capability(),
'maple-local-fonts',
'mlf_render_admin_page'
@ -165,6 +166,23 @@ function mlf_register_menu() {
}
add_action('admin_menu', 'mlf_register_menu');
/**
* Add settings link to plugin action links.
*
* @param array $links Existing plugin action links.
* @return array Modified plugin action links.
*/
function mlf_plugin_action_links($links) {
$settings_link = sprintf(
'<a href="%s">%s</a>',
esc_url(admin_url('options-general.php?page=maple-local-fonts')),
esc_html__('Settings', 'maple-local-fonts')
);
array_unshift($links, $settings_link);
return $links;
}
add_filter('plugin_action_links_' . MLF_PLUGIN_BASENAME, 'mlf_plugin_action_links');
/**
* Render admin page (delegates to MLF_Admin_Page).
*/
@ -179,7 +197,7 @@ function mlf_render_admin_page() {
* @param string $hook The current admin page hook.
*/
function mlf_enqueue_admin_assets($hook) {
if ($hook !== 'appearance_page_maple-local-fonts') {
if ($hook !== 'settings_page_maple-local-fonts') {
return;
}
@ -202,14 +220,17 @@ function mlf_enqueue_admin_assets($hook) {
'ajaxUrl' => admin_url('admin-ajax.php'),
'downloadNonce' => wp_create_nonce('mlf_download_font'),
'deleteNonce' => wp_create_nonce('mlf_delete_font'),
'searchNonce' => wp_create_nonce('mlf_search_fonts'),
'strings' => [
'downloading' => __('Downloading...', 'maple-local-fonts'),
'deleting' => __('Deleting...', 'maple-local-fonts'),
'confirmDelete' => __('Are you sure you want to delete this font?', 'maple-local-fonts'),
'error' => __('An error occurred. Please try again.', 'maple-local-fonts'),
'selectWeight' => __('Please select at least one weight.', 'maple-local-fonts'),
'selectStyle' => __('Please select at least one style.', 'maple-local-fonts'),
'enterFontName' => __('Please enter a font name.', 'maple-local-fonts'),
'downloading' => __('Downloading...', 'maple-local-fonts'),
'deleting' => __('Deleting...', 'maple-local-fonts'),
'confirmDelete' => __('Are you sure you want to delete this font?', 'maple-local-fonts'),
'error' => __('An error occurred. Please try again.', 'maple-local-fonts'),
'searchPlaceholder' => __('Search Google Fonts...', 'maple-local-fonts'),
'searching' => __('Searching...', 'maple-local-fonts'),
'noResults' => __('No fonts found. Try a different search term.', 'maple-local-fonts'),
'selectFont' => __('Select a font from the search results above.', 'maple-local-fonts'),
'previewText' => __('Maple Fonts Preview', 'maple-local-fonts'),
],
]);
}