ngg_fs

Create a helper function for easy SDK access.

Description

ngg_fs( (bool) $activate_for_all = false ); 

Parameters (1)

0. $activate_for_all — Optional. (bool) => false
If true, activate Freemius for all users. Was added for testing.

Usage

  1. if ( !function_exists( 'ngg_fs' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'nextgen-gallery/nggallery.php'; 
  3.  
  4. // If true, activate Freemius for all users. Was added for testing. 
  5. $activate_for_all = false; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = ngg_fs($activate_for_all); 
  9.  

Defined (1)

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

/nggallery.php  
  1. function ngg_fs( $activate_for_all = false ) { 
  2. global $ngg_fs; 
  3.  
  4. if ( ! $activate_for_all ) { 
  5. $ngg_options = get_option( 'ngg_options' ); 
  6. $ngg_run_freemius = get_option( 'ngg_run_freemius', null ); 
  7.  
  8. if ( false === $ngg_options ) { 
  9. // New plugin installation. 
  10.  
  11. if ( defined( 'WP_FS__DEV_MODE' ) && WP_FS__DEV_MODE ) { 
  12. // Always run Freemius in development mode for new plugin installs. 
  13. $run_freemius = true; 
  14. } else { 
  15. // Run Freemius code on 20% of the new installations. 
  16. // $random = rand( 1, 10 ); 
  17. // $run_freemius = ( 1 <= $random && $random <= 2 ); 
  18. // Update 2016-08: run on all new instances 
  19. $run_freemius = TRUE; 
  20.  
  21. update_option( 'ngg_run_freemius', $run_freemius ); 
  22.  
  23. // Compare both bool or string 0/1 because get_option() may give us either 
  24. } else if ( ( is_bool( $ngg_run_freemius ) && $ngg_run_freemius ) || '1' === $ngg_run_freemius ) { 
  25. // If runFreemius was set, use the value. 
  26. $run_freemius = $ngg_run_freemius; 
  27. } else { 
  28. // Don't run Freemius for plugin updates. 
  29. $run_freemius = false; 
  30. if (is_null($ngg_run_freemius)) 
  31. update_option('ngg_run_freemius', FALSE); 
  32.  
  33. if ( ! $run_freemius ) { 
  34. return false; 
  35.  
  36. if ( ! isset( $ngg_fs ) ) { 
  37. // Include Freemius SDK. 
  38. require_once dirname( __FILE__ ) . '/freemius/start.php'; 
  39.  
  40. $ngg_fs = fs_dynamic_init( array( 
  41. 'id' => '266',  
  42. 'slug' => 'nextgen-gallery',  
  43. 'public_key' => 'pk_009356711cd548837f074e1ef60a4',  
  44. 'is_premium' => false,  
  45. 'has_addons' => false,  
  46. 'has_paid_plans' => false,  
  47. 'menu' => array( 
  48. 'slug' => 'nextgen-gallery',  
  49. 'account' => false,  
  50. 'contact' => false,  
  51. 'support' => false,  
  52. ),  
  53. 'permissions' => array( 
  54. 'newsletter' => true,  
  55. ),  
  56. ) ); 
  57.  
  58. /** 
  59. // Optional button override. 
  60. if ( function_exists( 'fs_override_i18n' ) ) { 
  61. fs_override_i18n( array( 
  62. 'opt-in-connect' => __('OK - I\'m in!', 'nggallery'),  
  63. ), 'nextgen-gallery' ); 
  64. */ 
  65.  
  66. // Hook to the custom message filter. 
  67. $ngg_fs->add_filter( 'connect_message', 'ngg_fs_custom_connect_message', 10, 6 ); 
  68. $ngg_fs->add_action( 'after_uninstall', 'ngg_fs_uninstall' ); 
  69.  
  70. // Hook to new gallery creation event. 
  71.  
  72. return $ngg_fs;