| 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 |
* Displays notices when registration disabled. |
| 14 |
* |
| 15 |
* @since 1.0.0 |
| 16 |
* @package userswp |
| 17 |
* @return void |
| 18 |
*/ |
| 19 |
function display_registration_disabled_notice($type) { |
| 20 |
if ($type == 'register') { |
| 21 |
if (!get_option('users_can_register')) { |
| 22 |
echo aui()->alert(array( |
| 23 |
'class' => 'text-center', |
| 24 |
'type'=>'danger', |
| 25 |
'heading' => __( 'Heads Up!', 'userswp' ), |
| 26 |
'content'=> __( 'User registration is currently not allowed.', 'userswp' ) |
| 27 |
) |
| 28 |
); |
| 29 |
} |
| 30 |
} |
| 31 |
} |
| 32 |
|
| 33 |
/** |
| 34 |
* Displays noticed based on notice key. |
| 35 |
* |
| 36 |
* @param string $type |
| 37 |
* @param bool $echo |
| 38 |
* |
| 39 |
* @return string |
| 40 |
*/ |
| 41 |
public function form_notice_by_key($type = '', $echo = true, $user_id = 0) { |
| 42 |
$key = isset($_REQUEST['uwp_err']) ? sanitize_html_class($_GET['uwp_err']) : $type; |
| 43 |
$user_id = isset($_REQUEST['user_id']) ? absint($_REQUEST['user_id']) : $user_id; |
| 44 |
$messages = array(); |
| 45 |
$notice = $link = ''; |
| 46 |
|
| 47 |
$messages['act_success'] = array( |
| 48 |
'message' => __('Account activated successfully. Please login to continue.', 'userswp'), |
| 49 |
'type' => 'success', |
| 50 |
); |
| 51 |
|
| 52 |
if(isset($user_id) && !empty($user_id)){ |
| 53 |
$resend_link = uwp_get_login_page_url(); |
| 54 |
$resend_link = add_query_arg( |
| 55 |
array( |
| 56 |
'user_id' => $user_id, |
| 57 |
'action' => 'uwp_resend', |
| 58 |
'_nonce' => wp_create_nonce('uwp_resend'), |
| 59 |
), |
| 60 |
$resend_link |
| 61 |
); |
| 62 |
|
| 63 |
$link = "<a href='".esc_url_raw($resend_link)."' >".__('Resend', 'userswp')."</a>"; |
| 64 |
} |
| 65 |
|
| 66 |
$messages['act_email_success'] = array( |
| 67 |
'message' => __('Email updated successfully.', 'userswp'), |
| 68 |
'type' => 'success', |
| 69 |
); |
| 70 |
|
| 71 |
$messages['act_pending'] = array( |
| 72 |
'message' => __('Your account is not activated yet. Please check your email for activation email.', 'userswp').$link, |
| 73 |
'type' => 'error', |
| 74 |
); |
| 75 |
$messages['act_error'] = array( |
| 76 |
'message' => __('Invalid activation key or account.', 'userswp'), |
| 77 |
'type' => 'error', |
| 78 |
); |
| 79 |
$messages['act_wrong'] = array( |
| 80 |
'message' => __('Invalid activation key or account.', 'userswp'), |
| 81 |
'type' => 'error', |
| 82 |
); |
| 83 |
|
| 84 |
$messages = apply_filters('uwp_form_error_messages', $messages); |
| 85 |
|
| 86 |
if (!empty($key) && isset($messages[$key])) { |
| 87 |
$value = $messages[$key]; |
| 88 |
$message = $value['message']; |
| 89 |
$type = $value['type']; |
| 90 |
$notice = aui()->alert(array( |
| 91 |
'type'=> $type, |
| 92 |
'content'=> $message |
| 93 |
) |
| 94 |
); |
| 95 |
|
| 96 |
} |
| 97 |
|
| 98 |
if($notice && $echo){ |
| 99 |
echo $notice; |
| 100 |
}else{ |
| 101 |
return $notice; |
| 102 |
} |
| 103 |
|
| 104 |
} |
| 105 |
|
| 106 |
public function show_admin_notices() { |
| 107 |
settings_errors( 'uwp-notices' ); |
| 108 |
|
| 109 |
include_once dirname( __FILE__ ) . '/class-uwp-background-updater.php'; |
| 110 |
$updater = new UsersWP_Background_Updater(); |
| 111 |
if ( $updater->is_updating() || ! empty( $_GET['force_sync_data'] ) ) { |
| 112 |
?> |
| 113 |
<div id="message" class="updated notice notice-alt uwp-message"> |
| 114 |
<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> |
| 115 |
</div> |
| 116 |
<?php |
| 117 |
} |
| 118 |
} |
| 119 |
|
| 120 |
/** |
| 121 |
* Displays admin side notice to try Bootstrap layout |
| 122 |
* |
| 123 |
* @since 2.0.0 |
| 124 |
* @package userswp |
| 125 |
* |
| 126 |
* @return void |
| 127 |
*/ |
| 128 |
public static function try_bootstrap(){ |
| 129 |
$show = get_option("uwp_notice_try_bootstrap"); |
| 130 |
if( $show && uwp_get_option('design_style','bootstrap') != 'bootstrap'){ |
| 131 |
$settings_link = admin_url("admin.php?page=userswp&tab=general§ion=developer&try-bootstrap=true"); |
| 132 |
// set the setting on the fly if set to do so |
| 133 |
if(is_admin() && current_user_can( 'manage_options' ) && isset($_REQUEST['page']) && $_REQUEST['page']=='userswp' && !empty($_REQUEST['try-bootstrap']) ){ |
| 134 |
uwp_update_option('design_style','bootstrap'); |
| 135 |
?> |
| 136 |
<div class="notice notice-success"> |
| 137 |
<p><strong>UsersWP - </strong><?php _e( 'Congratulations your site is now set to use the new Bootstrap styles!', 'userswp' ); ?></p> |
| 138 |
</div> |
| 139 |
<?php |
| 140 |
}else{ |
| 141 |
?> |
| 142 |
<div class="notice notice-info is-dismissible uwp-notice-try-bootstrap"> |
| 143 |
<p><strong>UsersWP - </strong><?php _e( 'Try our exciting new bootstrap styling for a more modern and clean look (switch back at any time).', 'userswp' ); ?> |
| 144 |
<a href="<?php echo esc_url_raw( $settings_link );?>" class="button button-primary"><?php _e( 'Try Now', 'userswp' ); ?></a> |
| 145 |
</p> |
| 146 |
</div> |
| 147 |
<script> |
| 148 |
jQuery(function() { |
| 149 |
setTimeout(function(){ |
| 150 |
jQuery('.uwp-notice-try-bootstrap .notice-dismiss').click(function(){ |
| 151 |
jQuery.post("<?php echo admin_url("admin-ajax.php?action=uwp_notice_clear_try_bootstrap"); ?>", function(data, status){ |
| 152 |
}); |
| 153 |
}); |
| 154 |
}, 300); |
| 155 |
}); |
| 156 |
</script> |
| 157 |
<?php |
| 158 |
} |
| 159 |
|
| 160 |
} |
| 161 |
|
| 162 |
} |
| 163 |
|
| 164 |
public static function yoast_user_archives_disabled(){ |
| 165 |
if( !current_user_can( 'manage_options' ) ) { |
| 166 |
return; |
| 167 |
} |
| 168 |
|
| 169 |
if( defined( 'WPSEO_VERSION' ) && version_compare( WPSEO_VERSION, '7.0', '>=' ) && class_exists('WPSEO_Options') && WPSEO_Options::get( 'disable-author', false ) ){ |
| 170 |
$settings_link = admin_url("admin.php?page=wpseo_titles#top#archives"); |
| 171 |
|
| 172 |
$profile_page_id = uwp_get_page_id( 'profile_page' ); |
| 173 |
if ($profile_page_id > 0 && ( $page_object = get_post( $profile_page_id ) )) { |
| 174 |
if ('page' === $page_object->post_type && in_array($page_object->post_status, array('publish'))) { |
| 175 |
?> |
| 176 |
<div class="notice notice-error"> |
| 177 |
<p><strong>UsersWP - </strong><?php _e( 'Yoast SEO has disabled user profiles, please enable them.', 'userswp' ); ?> |
| 178 |
<a href="<?php echo esc_url_raw( $settings_link );?>" class="button button-primary"><?php _e( 'View Settings', 'userswp' ); ?></a> |
| 179 |
</p> |
| 180 |
</div> |
| 181 |
<?php |
| 182 |
} |
| 183 |
} |
| 184 |
} |
| 185 |
|
| 186 |
} |
| 187 |
|
| 188 |
} |