Last active
October 2, 2022 23:46
-
-
Save newfiesoft/de7bc52bb85bead7fba1d31359a3159e to your computer and use it in GitHub Desktop.
How to add WordPress plugin custom link in admin page
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// This help to create additional button after Plugin it is activated Installed Plugins list | |
add_filter('plugin_action_links_' . plugin_basename(__FILE__), 'mysat_custom_link_options_plugin', 10, 2); | |
function mysat_custom_link_options_plugin($actions): array | |
{ | |
// Build URL Links | |
$support_url = esc_url(add_query_arg('page', 'my-style-anytime', get_admin_url() . 'admin.php')); | |
$getpro_url = esc_url(add_query_arg('', '', 'https://newfiesoft.com/wp-plugins/my-style-anytime/')); | |
// Links name | |
$support_name ='Settings'; | |
$getpro_name ='Get Premium'; | |
// Create buttons | |
$settings_url = '<a href="' . $support_url . '">' . $support_name . '</a>'; | |
$site_link_premium = '<a href="' . $getpro_url . '" class="premium" target="_blank">' . $getpro_name . '</a>'; | |
// Organize buttons | |
return array_merge( | |
(array)$settings_url, | |
(array)$site_link_premium, | |
// (array)$help_link, | |
$actions, | |
); | |
} | |
// This help to create additional custom meta links in the sequel after Version By .... Installed Plugins list | |
add_filter('plugin_row_meta', 'mysat_custom_link_action_plugin', 10, 4); | |
function mysat_custom_link_action_plugin($links_array, $mysat_plugin_name) | |
{ | |
$plugindir = plugin_basename(__FILE__); | |
if ($mysat_plugin_name === $plugindir) { | |
// Build URL Links | |
$support_url = 'https://wordpress.org/support/plugin/my-style-anytime/'; | |
$faq_url = 'https://wordpress.org/plugins/my-style-anytime/#faq'; | |
$rating_url = 'https://wordpress.org/support/plugin/my-style-anytime/reviews/#new-post'; | |
// Links name | |
$support_name ='Community Support'; | |
$faq_name ='FAQ'; | |
$rating_name ='Ratings'; | |
// Create buttons | |
$links_array[] = '<a href="' . $support_url . '" class="help-style" target="_blank">' . $support_name . '</a>'; | |
$links_array[] = '<a href="' . $faq_url . '" class="help-style" target="_blank">' . $faq_name . '</a>'; | |
$links_array[] = '<a href="' . $rating_url . '" class="help-style" target="_blank">' . $rating_name . '</a>'; | |
} | |
return $links_array; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment