WordPress.org

Make WordPress Core

Ticket #7856: akismet_sample_patch.diff

File akismet_sample_patch.diff, 1012 bytes (added by strider72, 6 years ago)

As a demonstration, this patch modifies Akismet to use this new filter. Now has "Settings" link in plugin admin row.

  • akismet.php

     
    3737} 
    3838 
    3939function akismet_config_page() { 
    40         if ( function_exists('add_submenu_page') ) 
    41                 add_submenu_page('plugins.php', __('Akismet Configuration'), __('Akismet Configuration'), 'manage_options', 'akismet-key-config', 'akismet_conf'); 
     40        if ( current_user_can('manage_options') && function_exists('add_submenu_page') ) { 
     41                        add_submenu_page('plugins.php', __('Akismet Configuration'), __('Akismet Configuration'), 'manage_options', 'akismet-key-config', 'akismet_conf'); 
     42                        $plugin = plugin_basename(__FILE__); 
     43                        add_filter("plugin_action_links_$plugin", 'akismet_filter_plugin_actions' ); 
     44        } 
     45} 
    4246 
     47function akismet_filter_plugin_actions( $links ) { 
     48        $settings_link = '<a href="plugins.php?page=akismet-key-config">' . __( 'Settings' ) . '</a>'; 
     49        array_unshift( $links, $settings_link ); 
     50        return $links; 
    4351} 
    4452 
    4553function akismet_conf() {