NF_AddonChecker

The Ninja Forms NF AddonChecker class.

Defined (1)

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

/lib/NF_AddonChecker.php  
  1. final class NF_AddonChecker 
  2. public function __construct() 
  3. add_action( 'plugins_loaded', array( $this, 'check_plugins' ) ); 
  4. add_action( 'admin_notices', array( $this, 'deactivation_notice' ) ); 
  5.  
  6. public function check_plugins() 
  7. if ( ! function_exists( 'get_plugins' ) ) { 
  8.  
  9. require_once ABSPATH . 'wp-admin/includes/plugin.php'; 
  10.  
  11.  
  12. $plugins = get_plugins(); 
  13.  
  14. foreach( $plugins as $plugin => $data ) { 
  15.  
  16. if( 'ninja-forms/ninja-forms.php' != $plugin && 0 === strncmp( $plugin, 'ninja-forms-', 12 ) && version_compare( $data[ 'Version' ], '3', '<' ) ) { 
  17.  
  18. if( ! is_plugin_active( $plugin ) ) continue; 
  19.  
  20. deactivate_plugins($plugin); 
  21.  
  22. wp_redirect( admin_url( 'plugins.php?nf-deactivated=' . $plugin ) ); exit; 
  23.  
  24. public function deactivation_notice() 
  25. if( ! isset( $_GET[ 'nf-deactivated' ] ) ) return; 
  26.  
  27. $plugin = sanitize_text_field( $_GET[ 'nf-deactivated' ] ); 
  28.  
  29. ?> 
  30. <div class="notice notice-error is-dismissible"> 
  31. <p><?php echo sprintf( __( 'Oops! That addon is not yet compatible with Ninja Forms THREE. %sLearn More%s.', 'ninja-forms' ), '<a target="_blank" href="https://ninjaforms.com/ninja-forms-three-extension-development-master-list/">', '</a>' ); ?></p> 
  32. <p><?php echo sprintf( __( '%s was deactivated.', 'ninja-forms' ), '<code>' . $plugin . '</code>'); ?></p> 
  33. </div> 
  34. <?php