| 1 |
<?php |
| 2 |
/** |
| 3 |
* UsersWP Notice display functions. |
| 4 |
* |
| 5 |
* All UsersWP notice display related functions can be found here. |
| 6 |
* |
| 7 |
* @since 1.0.0 |
| 8 |
* @author GeoDirectory Team <info@wpgeodirectory.com> |
| 9 |
*/ |
| 10 |
class UsersWP_Notices { |
| 11 |
|
| 12 |
/** |
| 13 |
* Wrap notice with a div. |
| 14 |
* |
| 15 |
* @since 1.0.0 |
| 16 |
* @package userswp |
| 17 |
* @return string Html string. |
| 18 |
*/ |
| 19 |
function wrap_notice($message, $type) { |
| 20 |
$output = '<div class="uwp-alert-'.$type.' text-center">'; |
| 21 |
$output .= $message; |
| 22 |
$output .= '</div>'; |
| 23 |
return $output; |
| 24 |
|
| 25 |
} |
| 26 |
|
| 27 |
/** |
| 28 |
* Displays notices when registration disabled. |
| 29 |
* |
| 30 |
* @since 1.0.0 |
| 31 |
* @package userswp |
| 32 |
* @return void |
| 33 |
*/ |
| 34 |
function display_registration_disabled_notice($type) { |
| 35 |
if ($type == 'register') { |
| 36 |
if (!get_option('users_can_register')) { |
| 37 |
$message = __('<strong>Heads Up!</strong><br/> User registration is currently not allowed.', 'userswp'); |
| 38 |
echo '<div class="uwp-alert-error text-center">'; |
| 39 |
echo $message; |
| 40 |
echo '</div>'; |
| 41 |
} |
| 42 |
} |
| 43 |
} |
| 44 |
|
| 45 |
/** |
| 46 |
* Displays noticed based on notice key. |
| 47 |
* |
| 48 |
* @since 1.0.0 |
| 49 |
* @package userswp |
| 50 |
* @return void |
| 51 |
*/ |
| 52 |
public function form_notice_by_key() { |
| 53 |
$messages = array(); |
| 54 |
$messages['act_success'] = array( |
| 55 |
'message' => __('Account activated successfully. Please login to continue.', 'userswp'), |
| 56 |
'type' => 'uwp-alert-success', |
| 57 |
); |
| 58 |
$messages['act_pending'] = array( |
| 59 |
'message' => __('Your account is not activated yet. Please check your email for activation email.', 'userswp'), |
| 60 |
'type' => 'uwp-alert-error', |
| 61 |
); |
| 62 |
$messages['act_error'] = array( |
| 63 |
'message' => __('Invalid activation key or account.', 'userswp'), |
| 64 |
'type' => 'uwp-alert-error', |
| 65 |
); |
| 66 |
$messages['act_wrong'] = array( |
| 67 |
'message' => __('Something went wrong.', 'userswp'), |
| 68 |
'type' => 'uwp-alert-error', |
| 69 |
); |
| 70 |
$messages = apply_filters('uwp_form_error_messages', $messages); |
| 71 |
if (isset($_GET['uwp_err'])) { |
| 72 |
$key = strip_tags(esc_sql($_GET['uwp_err'])); |
| 73 |
if (isset($messages[$key])) { |
| 74 |
$value = $messages[$key]; |
| 75 |
$message = $value['message']; |
| 76 |
$type = $value['type']; |
| 77 |
echo '<div class="'.$type.' text-center">'; |
| 78 |
echo $message; |
| 79 |
echo '</div>'; |
| 80 |
} |
| 81 |
} |
| 82 |
} |
| 83 |
|
| 84 |
public function show_admin_notices() { |
| 85 |
settings_errors( 'uwp-notices' ); |
| 86 |
|
| 87 |
include_once dirname( __FILE__ ) . '/class-uwp-background-updater.php'; |
| 88 |
$updater = new UsersWP_Background_Updater(); |
| 89 |
if ( $updater->is_updating() || ! empty( $_GET['force_sync_data'] ) ) { |
| 90 |
?> |
| 91 |
<div id="message" class="updated notice notice-alt uwp-message"> |
| 92 |
<p><strong><?php _e( 'UsersWP data sync', 'userswp' ); ?></strong> – <?php _e( 'Users data sync is running in the background.', 'userswp' ); ?> <a href="<?php echo esc_url( add_query_arg( 'force_sync_data', 'true', admin_url( 'admin.php?page=userswp' ) ) ); ?>"><?php _e( 'Taking a while? Click here to run it now.', 'userswp' ); ?></a></p> |
| 93 |
</div> |
| 94 |
<?php |
| 95 |
} |
| 96 |
} |
| 97 |
|
| 98 |
/** |
| 99 |
* Displays UsersWP admin notices |
| 100 |
* |
| 101 |
* @since 1.0.0 |
| 102 |
* @package userswp |
| 103 |
* |
| 104 |
* @return void |
| 105 |
*/ |
| 106 |
function uwp_admin_notices() { |
| 107 |
$errors = get_option( 'uwp_admin_notices' ); |
| 108 |
|
| 109 |
if ( ! empty( $errors ) ) { |
| 110 |
|
| 111 |
echo '<div id="uwp_admin_errors" class="notice-error notice is-dismissible">'; |
| 112 |
|
| 113 |
echo '<p>' . $errors . '</p>'; |
| 114 |
|
| 115 |
echo '</div>'; |
| 116 |
|
| 117 |
// Clear |
| 118 |
delete_option( 'uwp_admin_notices' ); |
| 119 |
} |
| 120 |
} |
| 121 |
|
| 122 |
} |