fs_ui_get_action_button

The NextGEN Gallery fs ui get action button function.

Description

(string) fs_ui_get_action_button( (string) $slug, (string) $page, (string) $action, (string) $title, (array) $params = array(), (constant) $is_primary = true, (constant) $icon_class = false, (constant) $confirmation = false, (string) $method = 'GET' ); 

Returns (string)

Parameters (9)

0. $slug (string)
The slug.
1. $page (string)
The page.
2. $action (string)
The action.
3. $title (string)
The title.
4. $params — Optional. (array) => array()
The params.
5. $is_primary — Optional. (constant) => true
The is primary.
6. $icon_class — Optional. (constant) => false
Class for an icon.
7. $confirmation — Optional. (constant) => false
Confirmation message before submit.
8. $method — Optional. (string) => 'GET'
The method.

Usage

  1. if ( !function_exists( 'fs_ui_get_action_button' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'nextgen-gallery/freemius/includes/fs-core-functions.php'; 
  3.  
  4. // The slug. 
  5. $slug = ''; 
  6.  
  7. // The page. 
  8. $page = ''; 
  9.  
  10. // The action. 
  11. $action = ''; 
  12.  
  13. // The title. 
  14. $title = ''; 
  15.  
  16. // The params. 
  17. $params = array(); 
  18.  
  19. // The is primary. 
  20. $is_primary = true; 
  21.  
  22. // Optional class for an icon. 
  23. $icon_class = false; 
  24.  
  25. // Optional confirmation message before submit. 
  26. $confirmation = false; 
  27.  
  28. // The method. 
  29. $method = 'GET'; 
  30.  
  31. // NOTICE! Understand what this does before running. 
  32. $result = fs_ui_get_action_button($slug, $page, $action, $title, $params, $is_primary, $icon_class, $confirmation, $method); 
  33.  

Defined (1)

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

/freemius/includes/fs-core-functions.php  
  1. function fs_ui_get_action_button( 
  2. $slug,  
  3. $page,  
  4. $action,  
  5. $title,  
  6. $params = array(),  
  7. $is_primary = true,  
  8. $icon_class = false,  
  9. $confirmation = false,  
  10. $method = 'GET' 
  11. ) { 
  12. // Prepend icon (if set). 
  13. $title = ( is_string( $icon_class ) ? '<i class="' . $icon_class . '"></i> ' : '' ) . $title; 
  14.  
  15. if ( is_string( $confirmation ) ) { 
  16. return sprintf( '<form action="%s" method="%s"><input type="hidden" name="fs_action" value="%s">%s<a href="#" class="%s" onclick="if (confirm(\'%s\')) this.parentNode.submit(); return false;">%s</a></form>',  
  17. freemius $slug )->_get_admin_page_url( $page, $params ),  
  18. $method,  
  19. $action,  
  20. wp_nonce_field( $action, '_wpnonce', true, false ),  
  21. 'button' . ( $is_primary ? ' button-primary' : '' ),  
  22. $confirmation,  
  23. $title 
  24. ); 
  25. } else if ( 'GET' !== strtoupper( $method ) ) { 
  26. return sprintf( '<form action="%s" method="%s"><input type="hidden" name="fs_action" value="%s">%s<a href="#" class="%s" onclick="this.parentNode.submit(); return false;">%s</a></form>',  
  27. freemius $slug )->_get_admin_page_url( $page, $params ),  
  28. $method,  
  29. $action,  
  30. wp_nonce_field( $action, '_wpnonce', true, false ),  
  31. 'button' . ( $is_primary ? ' button-primary' : '' ),  
  32. $title 
  33. ); 
  34. } else { 
  35. return sprintf( '<a href="%s" class="%s">%s</a></form>',  
  36. wp_nonce_url(freemius $slug )->_get_admin_page_url( $page, array_merge( $params, array( 'fs_action' => $action ) ) ), $action ),  
  37. 'button' . ( $is_primary ? ' button-primary' : '' ),  
  38. $title 
  39. );