Ich versuche, einem WordPress-Plugin einige Aktionslinks hinzuzufügen. Ich habe mit folgendem angefangen.
class Angelleye_PayPal_WooCommerce
{
public function __construct()
{
add_filter('plugin_action_links', array($this,'plugin_action_links'));
}
public function plugin_action_links($actions)
{
$custom_actions = array(
'configure' => sprintf( '<a href="https://stackoverflow.com/questions/22577727/%s">%s</a>', admin_url( 'admin.php?page=wc-settings&tab=checkout' ), __( 'Configure', 'paypal-for-woocommerce' ) ),
'docs' => sprintf( '<a href="https://stackoverflow.com/questions/22577727/%s" target="_blank">%s</a>', 'http://docs.angelleye.com/paypal-for-woocommerce/', __( 'Docs', 'paypal-for-woocommerce' ) ),
'support' => sprintf( '<a href="https://stackoverflow.com/questions/22577727/%s" target="_blank">%s</a>', 'http://www.angelleye.com/contact-us/', __( 'Support', 'paypal-for-woocommerce' ) ),
'review' => sprintf( '<a href="https://stackoverflow.com/questions/22577727/%s" target="_blank">%s</a>', 'http://wordpress.org/support/view/plugin-reviews/paypal-for-woocommerce', __( 'Write a Review', 'paypal-for-woocommerce' ) ),
);
// add the links to the front of the actions list
return array_merge( $custom_actions, $actions );
}
}
Dies funktioniert, außer dass es die Links auf jedes einzelne Plugin setzt, das derzeit aktiviert ist, anstatt nur auf mein eigenes. Ich schaue mir die an WordPress-Codex-Infos dazu, und es wird angezeigt, dass der an den Filternamen angehängte Dateiname verwendet wird. Also habe ich die Anpassung wie folgt vorgenommen:
add_filter('plugin_action_links_'.__FILE__, array($this,'plugin_action_links'));
Wenn ich das tue, verschwinden jedoch alle Links vollständig und sie werden nirgendwo angezeigt, nicht einmal bei meinen eigenen. Was mache ich hier falsch?