ddwpinfo_plugin_install_link

Helper function for creating easy & simple admin plugin install links.

Description

(string) ddwpinfo_plugin_install_link( (string) $plugin_slug = '', (string) $text = '' ); 

Returns (string)

String of WordPress.org plugin install link within admin.

Parameters (2)

0. $plugin_slug — Optional. (string) => ''
String of WordPress.org plugin slug.
1. $text — Optional. (string) => ''
String of plugin label text.

Usage

  1. if ( !function_exists( 'ddwpinfo_plugin_install_link' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'woocommerce-german-de_de/includes/ddwpinfo/ddwpinfo-functions.php'; 
  3.  
  4. // String of WordPress.org plugin slug. 
  5. $plugin_slug = ''; 
  6.  
  7. // String of plugin label text. 
  8. $text = ''; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = ddwpinfo_plugin_install_link($plugin_slug, $text); 
  12.  

Defined (1)

The function is defined in the following location(s).

/includes/ddwpinfo/ddwpinfo-functions.php  
  1. function ddwpinfo_plugin_install_link( $plugin_slug = '', $text = '' ) { 
  2.  
  3. /** Bail early if not enough capabilities */ 
  4. if ( ! current_user_can( 'install_plugins' ) ) { 
  5.  
  6. return; 
  7.  
  8. } // end if 
  9.  
  10. if ( is_main_site() ) { 
  11.  
  12. $url = network_admin_url( 'plugin-install.php?tab=plugin-information&plugin=' . $plugin_slug . '&TB_iframe=true&width=600&height=550' ); 
  13.  
  14. } else { 
  15.  
  16. $url = admin_url( 'plugin-install.php?tab=plugin-information&plugin=' . $plugin_slug . '&TB_iframe=true&width=600&height=550' ); 
  17.  
  18. } // end if 
  19.  
  20. /** Actual link title */ 
  21. $title_text = sprintf( '%s jetzt installieren', $text ); 
  22.  
  23. /** Create output string */ 
  24. $output = sprintf( 
  25. '<a class="add-new-h2 thickbox" href="%s" title="%s"><small>installieren</small></a>',  
  26. esc_url( $url ),  
  27. esc_attr( $title_text ) 
  28. ); 
  29.  
  30. /** Return output for display */ 
  31. return $output; 
  32.  
  33. } // end of function ddwpinfo_detect_plugin_install