-
-
Save tommcfarlin/14b73af1670ed6500ab82c0fecb1a3a7 to your computer and use it in GitHub Desktop.
[WordPress] Adding Custom WordPress Plugin Links
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 | |
add_action('plugin_row_meta', __NAMESPACE__ . '\\addCustomPluginLinks'); | |
/** | |
* @param array $metaData the array of metadata that appears in the row of plugin information | |
* | |
* @return array $metaData the modified array that includes the custom anchor | |
*/ | |
function addCustomPluginLinks(array $metaData): array | |
{ | |
$metaData[] = '<a href="https://google.com">Example Link</a>'; | |
return $metaData; | |
} |
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 | |
add_action('plugin_row_meta', __NAMESPACE__ . '\\addCustomPluginLinks'); | |
/** | |
* @param array $metaData the array of metadata that appears in the row of plugin information | |
* | |
* @return array $metaData the modified array that includes the custom anchor | |
*/ | |
function addCustomPluginLinks(array $metaData): array | |
{ | |
// Safely build the markup for the new anchor. | |
$html = wp_kses( | |
'<a href="https://google.com" target="_blank" data-title="Example Link" aria-label="Example Link">Example Link</a>', | |
[ | |
'a' => [ | |
'href' => [], | |
'target' => [], | |
'aria-label' => [], | |
'data-title' => [], | |
], | |
] | |
); | |
// Insert the markup at the end of the array. | |
$metaData[] = $html; | |
return $metaData; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment