wsoe_admin_notices

The WooCommerce Simply Order Export wsoe admin notices class.

Defined (1)

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

/classes/class-wsoe-admin-notices.php  
  1. class wsoe_admin_notices { 
  2.  
  3. function __construct() { 
  4.  
  5. add_action( 'admin_print_styles', array( $this, 'check_wsoe_messages' ) ); 
  6. add_action( 'wp_loaded', array( $this, 'wsoe_hide_notices' ) ); 
  7.  
  8. static function update_notices() { 
  9.  
  10. if( !wsoe_is_shop_manager() ) { 
  11. return; 
  12.  
  13. $wsoe_messages = array(); 
  14. if( !in_array( 'woocommerce-simply-order-export-add-on/main.php', apply_filters( 'active_plugins', get_option( 'active_plugins' )) ) ) { 
  15. $wsoe_messages['wsoe_addon_installed'] = false; 
  16. $wsoe_messages['wsoe_addon_notice_display'] = true; 
  17. }else { 
  18. $wsoe_messages['wsoe_addon_installed'] = true; 
  19. $wsoe_messages['wsoe_addon_notice_display'] = false; 
  20.  
  21. if( !in_array( 'wsoe-scheduler-logger/wsoe-schedular.php', apply_filters( 'active_plugins', get_option( 'active_plugins' )) ) ) { 
  22. $wsoe_messages['wsoe_scheduler_installed'] = false; 
  23. $wsoe_messages['wsoe_scheduler_notice_display'] = true; 
  24. }else { 
  25. $wsoe_messages['wsoe_scheduler_installed'] = true; 
  26. $wsoe_messages['wsoe_scheduler_notice_display'] = false; 
  27.  
  28. /** 
  29. * This option will be utilized in admin_notices 
  30. */ 
  31. update_user_meta( get_current_user_id(), 'wsoe_messages', $wsoe_messages ); 
  32.  
  33. do_action('wsoe_update_notices'); 
  34.  
  35. function check_wsoe_messages() { 
  36.  
  37. /** 
  38. * Do not display notice if current user is not shop manager. 
  39. */ 
  40. if( !wsoe_is_shop_manager() ) { 
  41. return; 
  42.  
  43. /** 
  44. * For add-on notice 
  45. */ 
  46. $wsoe_messages = get_user_meta( get_current_user_id(), 'wsoe_messages', true ); 
  47. $wsoe_messages = wp_parse_args( $wsoe_messages, array('wsoe_addon_installed'=>false, 'wsoe_addon_notice_display'=>true ) ); 
  48.  
  49. if ( (empty($wsoe_messages['wsoe_addon_installed']) && !empty($wsoe_messages['wsoe_addon_notice_display'])) && !get_user_meta( get_current_user_id(), 'wsoe_addon_notice_dismissed', true ) ) { 
  50. add_action( 'admin_notices', array( $this, 'install_addon' ) ); 
  51.  
  52. if ( (empty($wsoe_messages['wsoe_scheduler_installed']) && !empty($wsoe_messages['wsoe_scheduler_notice_display'])) && !get_user_meta( get_current_user_id(), 'wsoe_scheduler_notice_dismissed', true ) ) { 
  53. add_action( 'admin_notices', array( $this, 'install_scheduler_logger' ) ); 
  54.  
  55. /** 
  56. * For file protection 
  57. */ 
  58. if( !get_user_meta( get_current_user_id(), 'wsoe_htaccess_dismissed', true ) ) { 
  59. add_action( 'admin_notices', array( $this, 'htaccess_missing' ) ); 
  60.  
  61. do_action('wsoe_check_wsoe_messages'); 
  62.  
  63.  
  64. /** 
  65. * Display notice if add-on is not installed. 
  66. */ 
  67. function install_addon() { 
  68.  
  69. include WSOE_BASE. 'views/html-notice-addon-support.php'; 
  70.  
  71. /** 
  72. * Display notice if Scheduler plugin is not installed 
  73. */ 
  74. function install_scheduler_logger() { 
  75.  
  76. include WSOE_BASE. 'views/html-notice-scheduler.php'; 
  77.  
  78. /** 
  79. * Show notice if htacess is missing. 
  80. */ 
  81. function htaccess_missing() { 
  82.  
  83. include WSOE_BASE. 'views/html-notice-htaccess-missing.php'; 
  84.  
  85. function wsoe_hide_notices() { 
  86. if ( isset( $_GET['wsoe-hide-notice'] ) ) { 
  87. $hide_notice = sanitize_text_field( $_GET['wsoe-hide-notice'] ); 
  88. self::remove_notice( $hide_notice ); 
  89. do_action( 'wsoe_hide_' . $hide_notice . '_notice' ); 
  90.  
  91. static function remove_notice($notice) { 
  92.  
  93. switch($notice) { 
  94.  
  95. case 'wsoe_addon_notice': 
  96. self::hide_wsoe_addon_notice(); 
  97. break; 
  98.  
  99. case 'wsoe_scheduler_notice': 
  100. self::hide_wsoe_scheduler_notice(); 
  101. break; 
  102.  
  103. case 'wsoe_htaccess_missing': 
  104. update_user_meta( get_current_user_id(), 'wsoe_htaccess_dismissed', true ); 
  105. break; 
  106.  
  107. default : 
  108. do_action('wsoe_hide_notice_'.$notice); 
  109. break; 
  110.  
  111. static function hide_wsoe_addon_notice() { 
  112.  
  113. $wsoe_messages = get_user_meta( get_current_user_id(), 'wsoe_messages', true ); 
  114. $wsoe_messages['wsoe_addon_notice_display'] = false; 
  115. update_user_meta( get_current_user_id(), 'wsoe_messages', $wsoe_messages ); 
  116. update_user_meta( get_current_user_id(), 'wsoe_addon_notice_dismissed', 1 ); 
  117.  
  118. static function hide_wsoe_scheduler_notice() { 
  119. $wsoe_messages = get_user_meta( get_current_user_id(), 'wsoe_messages', true ); 
  120. $wsoe_messages['wsoe_scheduler_notice_display'] = false; 
  121. update_user_meta( get_current_user_id(), 'wsoe_messages', $wsoe_messages ); 
  122. update_user_meta( get_current_user_id(), 'wsoe_scheduler_notice_dismissed', 1 ); 
  123.