UM_Admin_Notices

The Ultimate Member UM Admin Notices class.

Defined (1)

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

/admin/core/um-admin-notices.php  
  1. class UM_Admin_Notices { 
  2.  
  3. function __construct() { 
  4.  
  5. add_action('admin_init', array(&$this, 'create_languages_folder') ); 
  6.  
  7. add_action('admin_notices', array(&$this, 'main_notices'), 1); 
  8.  
  9. add_action('admin_notices', array(&$this, 'localize_note'), 2); 
  10.  
  11. add_action('admin_notices', array(&$this, 'show_update_messages'), 10); 
  12.  
  13.  
  14. /*** 
  15. *** @to store plugin languages 
  16. ***/ 
  17. function create_languages_folder() { 
  18.  
  19. global $ultimatemember; 
  20.  
  21. $path = $ultimatemember->files->upload_basedir; 
  22. $path = str_replace('/uploads/ultimatemember', '', $path); 
  23. $path = $path . '/languages/plugins/'; 
  24. $path = str_replace('//', '/', $path); 
  25.  
  26. if ( !file_exists( $path ) ) { 
  27. $old = umask(0); 
  28. @mkdir( $path, 0777, true); 
  29. umask($old); 
  30.  
  31.  
  32. /*** 
  33. *** @show main notices 
  34. ***/ 
  35. function main_notices() { 
  36. global $ultimatemember; 
  37. $hide_register_notice = get_option('um_can_register_notice'); 
  38.  
  39. if ( ! defined('DOING_AJAX') ) { 
  40.  
  41. if ( !get_option('users_can_register') && !$hide_register_notice ) { 
  42.  
  43. echo '<div class="updated" style="border-color: #3ba1da;"><p>'; 
  44.  
  45. echo sprintf(__( 'Registration is disabled. Please go to the <a href="%s">general settings</a> page in the WordPress admin and select anyone can register. <a href="%s">Hide this notice</a>', 'ultimatemember' ), admin_url('options-general.php'), add_query_arg('um_adm_action', 'um_can_register_notice') ); 
  46.  
  47. echo '</p></div>'; 
  48.  
  49.  
  50. $hide_exif_notice = get_option('um_hide_exif_notice'); 
  51.  
  52. if ( !extension_loaded('exif') && !$hide_exif_notice ) { 
  53.  
  54. echo '<div class="updated" style="border-color: #3ba1da;"><p>'; 
  55.  
  56. echo sprintf(__( 'Exif is not enabled on your server. Mobile photo uploads will not be rotated correctly until you enable the exif extension. <a href="%s">Hide this notice</a>', 'ultimatemember' ), add_query_arg('um_adm_action', 'um_hide_exif_notice') ); 
  57.  
  58. echo '</p></div>'; 
  59.  
  60.  
  61. // Regarding page setup 
  62. $pages = $ultimatemember->permalinks->core; 
  63. if ( $pages && is_array( $pages ) ) { 
  64.  
  65. $err = false; 
  66.  
  67. foreach( $pages as $slug => $page_id ) { 
  68.  
  69. $page = get_post( $page_id ); 
  70. if ( !isset( $page->ID ) && in_array( $slug, array( 'user', 'account', 'members', 'register', 'login', 'logout', 'password-reset' ) ) ) { 
  71. $err = true; 
  72.  
  73.  
  74. if ( $err ) { 
  75. echo '<div class="updated" style="border-color: #3ba1da;"><p>' . __('One or more of your Ultimate Member pages are not correctly setup. Please visit <strong>Ultimate Member > Settings</strong> to re-assign your missing pages.', 'ultimatemember') . '</p></div>'; 
  76.  
  77. if ( isset( $pages['user'] ) ) { 
  78. $test = get_post( $pages['user'] ); 
  79. if ( isset( $test->post_parent ) && $test->post_parent > 0 ) { 
  80. echo '<div class="updated" style="border-color: #3ba1da;"><p>' . __('Ultimate Member Setup Error: User page can not be a child page.', 'ultimatemember') . '</p></div>'; 
  81.  
  82. if ( isset( $pages['account'] ) ) { 
  83. $test = get_post( $pages['account'] ); 
  84. if ( isset( $test->post_parent ) && $test->post_parent > 0 ) { 
  85. echo '<div class="updated" style="border-color: #3ba1da;"><p>' . __('Ultimate Member Setup Error: Account page can not be a child page.', 'ultimatemember') . '</p></div>'; 
  86.  
  87.  
  88. do_action('um_admin_after_main_notices'); 
  89.  
  90.  
  91.  
  92. /*** 
  93. *** @localization notice 
  94. ***/ 
  95. function localize_note() { 
  96. global $ultimatemember; 
  97.  
  98. $locale = get_option('WPLANG'); 
  99. if ( !$locale ) return; 
  100. if ( strstr( $locale, 'en_' ) ) return; // really, english! 
  101. if ( file_exists( WP_LANG_DIR . '/plugins/ultimatemember-' . $locale . '.mo' ) ) return; 
  102.  
  103. if ( isset( $ultimatemember->available_languages[$locale] ) ) { 
  104.  
  105. $download_uri = add_query_arg('um_adm_action', 'um_language_downloader'); 
  106.  
  107. echo '<div class="updated" style="border-color: #3ba1da;"><p>'; 
  108.  
  109. echo sprintf(__('Your site language is <strong>%1$s</strong>. Good news! Ultimate Member is already available in <strong>%2$s language</strong>. <a href="%3$s">Download the translation</a> files and start using the plugin in your language now.', 'ultimatemember'), $locale, $ultimatemember->available_languages[$locale], $download_uri ); 
  110.  
  111. echo '</p></div>'; 
  112.  
  113. } else { 
  114.  
  115. $hide_locale_notice = get_option('um_hide_locale_notice'); 
  116. if ( !$hide_locale_notice ) { 
  117.  
  118. echo '<div class="updated" style="border-color: #3ba1da;"><p>'; 
  119.  
  120. echo sprintf(__('Ultimate Member has not yet been translated to your langeuage: <strong>%1$s</strong>. If you have translated the plugin you need put these files <code>ultimatemember-%1$s.po and ultimatemember-%1$s.mo</code> in <strong>/wp-content/languages/plugins/</strong> for the plugin to be translated in your language. <a href="%2$s">Hide this notice</a>', 'ultimatemember'), $locale, add_query_arg('um_adm_action', 'um_hide_locale_notice') ); 
  121.  
  122. echo '</p></div>'; 
  123.  
  124.  
  125.  
  126.  
  127. /*** 
  128. *** @updating users 
  129. ***/ 
  130. function show_update_messages() { 
  131.  
  132. if ( !isset($_REQUEST['update']) ) return; 
  133.  
  134. $update = $_REQUEST['update']; 
  135. switch($update) { 
  136.  
  137. case 'confirm_delete': 
  138. $confirm_uri = admin_url('users.php?' . http_build_query(array( 
  139. 'um_adm_action' => 'delete_users',  
  140. 'user' => array_map('intval', (array) $_REQUEST['user']),  
  141. 'confirm' => 1 
  142. ))); 
  143. $users = ''; 
  144.  
  145. if( isset( $_REQUEST['user'] ) ) { 
  146. foreach( $_REQUEST['user'] as $user_id ) { 
  147. $user = get_userdata( $user_id ); 
  148. $users .= '#' . $user_id . ': ' . $user->user_login . '<br />'; 
  149.  
  150. $ignore = admin_url('users.php'); 
  151.  
  152. $messages[0]['err_content'] = sprintf(__('Are you sure you want to delete the selected user(s)? The following users will be deleted: <p>%s</p> <strong>This cannot be undone!</strong>', 'ultimatemember'), $users); 
  153. $messages[0]['err_content'] .= '<p><a href="'. esc_html( $confirm_uri ) .'" class="button-primary">' . __('Remove', 'ultimatemember') . '</a>  <a href="'.$ignore.'" class="button">' . __('Undo', 'ultimatemember') . '</a></p>'; 
  154.  
  155. break; 
  156.  
  157. case 'language_updated': 
  158. $messages[0]['content'] = __('Your translation files have been updated successfully.', 'ultimatemember'); 
  159. break; 
  160.  
  161. case 'purged_temp': 
  162. $messages[0]['content'] = __('Your temp uploads directory is now clean.', 'ultimatemember'); 
  163. break; 
  164.  
  165. case 'cleared_cache': 
  166. $messages[0]['content'] = __('Your user cache is now removed.', 'ultimatemember'); 
  167. break; 
  168.  
  169. case 'form_duplicated': 
  170. $messages[0]['content'] = __('The form has been duplicated successfully.', 'ultimatemember'); 
  171. break; 
  172.  
  173. case 'user_updated': 
  174. $messages[0]['content'] = __('User has been updated.', 'ultimatemember'); 
  175. break; 
  176.  
  177. case 'users_updated': 
  178. $messages[0]['content'] = __('Users have been updated.', 'ultimatemember'); 
  179. break; 
  180.  
  181. case 'users_role_updated': 
  182. $messages[0]['content'] = __('Changed roles.', 'ultimatemember'); 
  183. break; 
  184.  
  185. case 'err_users_updated': 
  186. $messages[0]['err_content'] = __('Super administrators cannot be modified.', 'ultimatemember'); 
  187. $messages[1]['content'] = __('Other users have been updated.', 'ultimatemember'); 
  188.  
  189.  
  190. if ( !empty( $messages ) ) { 
  191. foreach( $messages as $message ) { 
  192. if ( isset($message['err_content'])) { 
  193. echo '<div class="error"><p>' . $message['err_content'] . '</p></div>'; 
  194. } else { 
  195. echo '<div class="updated" style="border-color: #3ba1da;"><p>' . $message['content'] . '</p></div>'; 
  196.  
  197.