2014-12-15 22:38:07 +02:00
< ? php
class UM_Admin_Notices {
function __construct () {
2015-02-04 20:31:39 +02:00
add_action ( 'admin_init' , array ( & $this , 'create_languages_folder' ) );
2014-12-15 22:38:07 +02:00
2015-01-06 00:38:33 +02:00
add_action ( 'admin_notices' , array ( & $this , 'main_notices' ), 1 );
2015-02-04 20:31:39 +02:00
add_action ( 'admin_notices' , array ( & $this , 'localize_note' ), 2 );
2015-01-06 00:38:33 +02:00
add_action ( 'admin_notices' , array ( & $this , 'show_update_messages' ), 10 );
2015-01-04 03:10:49 +02:00
2014-12-15 22:38:07 +02:00
}
2015-02-04 20:31:39 +02:00
/***
*** @to store plugin languages
***/
function create_languages_folder () {
global $ultimatemember ;
$path = $ultimatemember -> files -> upload_basedir ;
$path = str_replace ( '/uploads/ultimatemember' , '' , $path );
$path = $path . '/languages/plugins/' ;
$path = str_replace ( '//' , '/' , $path );
if ( ! file_exists ( $path ) ) {
2015-02-10 02:05:27 +02:00
$old = umask ( 0 );
2015-02-04 20:31:39 +02:00
@ mkdir ( $path , 0777 , true );
2015-02-10 02:05:27 +02:00
umask ( $old );
2015-02-04 20:31:39 +02:00
}
}
2014-12-15 22:38:07 +02:00
/***
2015-01-06 00:38:33 +02:00
*** @show main notices
2014-12-15 22:38:07 +02:00
***/
2015-01-06 00:38:33 +02:00
function main_notices (){
2014-12-15 22:38:07 +02:00
2015-02-01 01:30:04 +02:00
$hide_register_notice = get_option ( 'um_can_register_notice' );
2014-12-15 22:38:07 +02:00
2015-02-01 01:30:04 +02:00
if ( ! get_option ( 'users_can_register' ) && ! $hide_register_notice ) {
2015-01-06 00:38:33 +02:00
echo '<div class="updated" style="border-color: #3ba1da;"><p>' ;
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' ) );
2014-12-15 22:38:07 +02:00
2015-01-06 00:38:33 +02:00
echo '</p></div>' ;
}
2015-02-01 01:30:04 +02:00
2015-02-04 20:31:39 +02:00
$hide_exif_notice = get_option ( 'um_hide_exif_notice' );
2015-02-01 01:30:04 +02:00
if ( ! extension_loaded ( 'exif' ) && ! $hide_exif_notice ) {
echo '<div class="updated" style="border-color: #3ba1da;"><p>' ;
2015-02-04 20:31:39 +02:00
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' ) );
2015-02-01 01:30:04 +02:00
echo '</p></div>' ;
}
2015-01-06 00:38:33 +02:00
}
2015-02-04 20:31:39 +02:00
/***
*** @localization notice
***/
function localize_note () {
global $ultimatemember ;
$locale = get_option ( 'WPLANG' );
if ( ! $locale ) return ;
2015-02-23 01:43:11 +02:00
if ( strstr ( $locale , 'en_' ) ) return ; // really, english!
2015-02-04 20:31:39 +02:00
if ( file_exists ( WP_LANG_DIR . '/plugins/ultimatemember-' . $locale . '.mo' ) ) return ;
if ( isset ( $ultimatemember -> available_languages [ $locale ] ) ) {
$download_uri = add_query_arg ( 'um_adm_action' , 'um_language_downloader' );
echo '<div class="updated" style="border-color: #3ba1da;"><p>' ;
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 );
echo '</p></div>' ;
} else {
$hide_locale_notice = get_option ( 'um_hide_locale_notice' );
if ( ! $hide_locale_notice ) {
echo '<div class="updated" style="border-color: #3ba1da;"><p>' ;
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' ) );
echo '</p></div>' ;
}
}
}
2015-01-06 00:38:33 +02:00
/***
*** @updating users
***/
function show_update_messages (){
if ( ! isset ( $_REQUEST [ 'update' ]) ) return ;
$update = $_REQUEST [ 'update' ];
2014-12-15 22:38:07 +02:00
switch ( $update ) {
2015-02-06 02:38:41 +02:00
2015-02-14 02:06:43 +02:00
case 'confirm_delete' :
$confirm_uri = urldecode ( $_REQUEST [ '_refer' ]);
$users = implode ( ', ' , $_REQUEST [ 'user' ]);
$ignore = admin_url ( 'users.php' );
$messages [ 0 ][ 'err_content' ] = sprintf ( __ ( 'Are you sure you want to delete the selected user(s)? The following users will be deleted: (%s) <strong>This cannot be undone!</strong>' , 'ultimatemember' ), $users );
$messages [ 0 ][ 'err_content' ] .= ' <a href="' . $confirm_uri . '" class="button-primary">' . __ ( 'Yes! Delete' , 'ultimatemember' ) . '</a> <a href="' . $ignore . '" class="button">' . __ ( 'Cancel' , 'ultimatemember' ) . '</a>' ;
break ;
2015-02-10 02:05:27 +02:00
case 'language_updated' :
$messages [ 0 ][ 'content' ] = __ ( 'Your translation files have been updated successfully.' , 'ultimatemember' );
break ;
2015-02-09 00:29:16 +02:00
case 'purged_temp' :
$messages [ 0 ][ 'content' ] = __ ( 'Your temp uploads directory is now clean.' , 'ultimatemember' );
break ;
2015-02-06 02:38:41 +02:00
case 'form_duplicated' :
$messages [ 0 ][ 'content' ] = __ ( 'The form has been duplicated successfully.' , 'ultimatemember' );
break ;
2014-12-15 22:38:07 +02:00
case 'user_updated' :
$messages [ 0 ][ 'content' ] = __ ( 'User has been updated.' , 'ultimatemember' );
break ;
case 'users_updated' :
$messages [ 0 ][ 'content' ] = __ ( 'Users have been updated.' , 'ultimatemember' );
break ;
case 'err_users_updated' :
$messages [ 0 ][ 'err_content' ] = __ ( 'Super administrators cannot be modified.' , 'ultimatemember' );
$messages [ 1 ][ 'content' ] = __ ( 'Other users have been updated.' , 'ultimatemember' );
}
if ( ! empty ( $messages ) ) {
foreach ( $messages as $message ) {
if ( isset ( $message [ 'err_content' ])) {
2015-01-06 00:38:33 +02:00
echo '<div class="error"><p>' . $message [ 'err_content' ] . '</p></div>' ;
2014-12-15 22:38:07 +02:00
} else {
2015-01-06 00:38:33 +02:00
echo '<div class="updated" style="border-color: #3ba1da;"><p>' . $message [ 'content' ] . '</p></div>' ;
2014-12-15 22:38:07 +02:00
}
}
}
}
}