NF_Notices_SP

NF_Notices_SP Class.

Defined (1)

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

/deprecated/classes/notices-save-progress.php  
  1. class NF_Notices_SP extends NF_Notices 
  2. // Basic actions to run 
  3. public function __construct() { 
  4.  
  5. // Runs the admin notice ignore function incase a dismiss button has been clicked 
  6. add_action( 'admin_init', array( $this, 'admin_notice_ignore' ) ); 
  7.  
  8. // Runs the visibility checks for admin notices after all needed core files are loaded 
  9. add_filter( 'nf_admin_notices', array( $this, 'special_parameters' ) ); 
  10.  
  11.  
  12. // Function to do all the special checks before running the notice 
  13. public function special_parameters( $admin_notices ) { 
  14.  
  15. // Check if on builder 
  16. if ( ! $this->admin_notice_pages( array( array( 'ninja-forms', 'builder' ) ) ) ) { 
  17. return $admin_notices; 
  18.  
  19. // Check for 20 fields in one form 
  20. $field_check = 0; 
  21. $all_fields = ninja_forms_get_all_fields(); 
  22.  
  23. if ( is_array( $all_fields ) ) { 
  24. $count = array(); 
  25.  
  26. foreach ( $all_fields as $key => $val ) { 
  27. $form_id = $all_fields[ $key ][ 'form_id' ]; 
  28. if ( ! isset( $count[ $form_id ] ) ) { 
  29. $count[ $form_id ] = 1; 
  30. } else { 
  31. $count[ $form_id ]++; 
  32.  
  33. foreach ( $count as $form_id => $field_count ) { 
  34. if ( $field_count >=40 ) { 
  35. $field_check = 1; 
  36.  
  37. // Check for multi-part forms installed and if the above passes 
  38. if ( ! is_plugin_active( 'ninja-forms-save-progress/save-progress.php' ) && $field_check == 1 ) { 
  39. // Add notice 
  40. $tags = '?utm_medium=plugin&utm_source=admin-notice&utm_campaign=Ninja+Forms+Upsell&utm_content=Save+Progress'; 
  41. $save_progress_ignore = add_query_arg( array( 'nf_admin_notice_ignore' => 'save_progress' ) ); 
  42. $save_progress_temp = add_query_arg( array( 'nf_admin_notice_temp_ignore' => 'save_progress', 'int' => 14) ); 
  43. $admin_notices['save_progress'] = array( 
  44. 'title' => __( 'Increase Conversions', 'ninja-forms' ),  
  45. 'msg' => __( 'Users are more likely to complete long forms when they can save and return to complete their submission later.<p>The Save Progress extension for Ninja Forms makes this quick and easy.</p>', 'ninja-forms' ),  
  46. 'link' => '<li> <span class="dashicons dashicons-external"></span><a target="_blank" href="https://ninjaforms.com/extensions/save-user-progress/' . $tags . '"> ' . __( 'Learn More About Save Progress', 'ninja-forms' ) . '</a></li> 
  47. <li><span class="dashicons dashicons-calendar-alt"></span><a href="' . $save_progress_temp . '">' . __( 'Maybe Later' , 'ninja-forms' ) . '</a></li> 
  48. <li><span class="dashicons dashicons-dismiss"></span><a href="' . $save_progress_ignore . '">' . __( 'Dismiss', 'ninja-forms' ) . '</a></li>',  
  49. 'int' => 0 
  50. ); 
  51.  
  52.  
  53. return $admin_notices; 
  54.  
  55. // Ignore function that gets ran at admin init to ensure any messages that were dismissed get marked 
  56. public function admin_notice_ignore() { 
  57.  
  58. $slug = ( isset( $_GET[ 'nf_admin_notice_ignore' ] ) ) ? $_GET[ 'nf_admin_notice_ignore' ] : ''; 
  59. // If user clicks to ignore the notice, run this action 
  60. if ( $slug == 'multi-part19' && current_user_can( apply_filters( 'ninja_forms_admin_parent_menu_capabilities', 'manage_options' ) ) ) { 
  61.  
  62. $admin_notices_extra_option = get_option( 'nf_admin_notice_extra', array() ); 
  63. $admin_notices_extra_option[ $_GET[ 'nf_admin_notice_ignore' ] ][ 'test19' ] = 1; 
  64. update_option( 'nf_admin_notice_extra', $admin_notices_extra_option ); 
  65.  
  66.