| @@ -7,24 +7,9 @@ | ||
| 7 | 7 | * @since 1.0.0 |
| 8 | 8 | * @author GeoDirectory Team <info@wpgeodirectory.com> |
| 9 | 9 | */ |
| 10 | 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 | 11 | |
| 25 | - } | |
| 26 | - | |
| 27 | 12 | /** |
| 28 | 13 | * Displays notices when registration disabled. |
| 29 | 14 | * |
| 30 | 15 | * @since 1.0.0 |
| @@ -33,80 +18,184 @@ | ||
| 33 | 18 | */ |
| 34 | 19 | function display_registration_disabled_notice($type) { |
| 35 | 20 | if ($type == 'register') { |
| 36 | 21 | 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>'; | |
| 22 | + echo aui()->alert(array( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | |
| 23 | + 'class' => 'text-center', | |
| 24 | + 'type'=>'danger', | |
| 25 | + 'heading' => esc_attr__( 'Heads Up!', 'userswp' ), | |
| 26 | + 'content'=> esc_attr__( 'User registration is currently not allowed.', 'userswp' ) | |
| 27 | + ) | |
| 28 | + ); | |
| 41 | 29 | } |
| 42 | 30 | } |
| 43 | 31 | } |
| 44 | - | |
| 32 | + | |
| 45 | 33 | /** |
| 46 | - * Displays noticed based on notice key. | |
| 34 | + * Displays noticed based on notice key. | |
| 35 | + * | |
| 36 | + * @param string $type | |
| 37 | + * @param bool $echo | |
| 47 | 38 | * |
| 48 | - * @since 1.0.0 | |
| 49 | - * @package userswp | |
| 50 | - * @return void | |
| 39 | + * @return string | |
| 51 | 40 | */ |
| 52 | - public function form_notice_by_key() { | |
| 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; | |
| 53 | 44 | $messages = array(); |
| 45 | + $notice = $link = ''; | |
| 46 | + | |
| 54 | 47 | $messages['act_success'] = array( |
| 55 | 48 | 'message' => __('Account activated successfully. Please login to continue.', 'userswp'), |
| 56 | - 'type' => 'uwp-alert-success', | |
| 49 | + 'type' => 'success', | |
| 57 | 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 | + | |
| 58 | 71 | $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', | |
| 72 | + 'message' => __('Your account is not activated yet. Please check your email for activation email.', 'userswp').$link, | |
| 73 | + 'type' => 'error', | |
| 61 | 74 | ); |
| 62 | 75 | $messages['act_error'] = array( |
| 63 | 76 | 'message' => __('Invalid activation key or account.', 'userswp'), |
| 64 | - 'type' => 'uwp-alert-error', | |
| 77 | + 'type' => 'error', | |
| 65 | 78 | ); |
| 66 | 79 | $messages['act_wrong'] = array( |
| 67 | - 'message' => __('Something went wrong.', 'userswp'), | |
| 68 | - 'type' => 'uwp-alert-error', | |
| 80 | + 'message' => __('Invalid activation key or account.', 'userswp'), | |
| 81 | + 'type' => 'error', | |
| 69 | 82 | ); |
| 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 | - } | |
| 83 | + | |
| 84 | + $messages = apply_filters('uwp_form_error_messages', $messages, $echo, $user_id ); | |
| 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 | + | |
| 81 | 96 | } |
| 97 | + | |
| 98 | + if($notice && $echo){ | |
| 99 | + echo $notice; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | |
| 100 | + }else{ | |
| 101 | + return $notice; | |
| 102 | + } | |
| 103 | + | |
| 82 | 104 | } |
| 83 | 105 | |
| 84 | 106 | public function show_admin_notices() { |
| 85 | 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 esc_attr_e( 'UsersWP data sync', 'userswp' ); ?></strong> – <?php esc_attr_e( 'Users data sync is running in the background.', 'userswp' ); ?> <a href="<?php echo esc_url( add_query_arg( array( 'force_sync_data' => 'true', '_nonce' => wp_create_nonce( 'force_sync_data' ) ), admin_url( 'admin.php?page=userswp' ) ) ); ?>"><?php esc_attr_e( 'Taking a while? Click here to run it now.', 'userswp' ); ?></a></p> | |
| 115 | + </div> | |
| 116 | + <?php | |
| 117 | + } | |
| 86 | 118 | } |
| 87 | 119 | |
| 88 | - /** | |
| 89 | - * Displays UsersWP admin notices | |
| 90 | - * | |
| 91 | - * @since 1.0.0 | |
| 92 | - * @package userswp | |
| 93 | - * | |
| 94 | - * @return void | |
| 95 | - */ | |
| 96 | - function uwp_admin_notices() { | |
| 97 | - $errors = get_option( 'uwp_admin_notices' ); | |
| 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 esc_attr_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 esc_attr_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 esc_attr_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 esc_url( admin_url("admin-ajax.php?action=uwp_notice_clear_try_bootstrap")); ?>", function(data, status){ | |
| 152 | + }); | |
| 153 | + }); | |
| 154 | + }, 300); | |
| 155 | + }); | |
| 156 | + </script> | |
| 157 | + <?php | |
| 158 | + } | |
| 98 | 159 | |
| 99 | - if ( ! empty( $errors ) ) { | |
| 160 | + } | |
| 100 | 161 | |
| 101 | - echo '<div id="uwp_admin_errors" class="notice-error notice is-dismissible">'; | |
| 162 | + } | |
| 102 | 163 | |
| 103 | - echo '<p>' . $errors . '</p>'; | |
| 164 | + public static function yoast_user_archives_disabled(){ | |
| 165 | + if( !current_user_can( 'manage_options' ) ) { | |
| 166 | + return; | |
| 167 | + } | |
| 104 | 168 | |
| 105 | - echo '</div>'; | |
| 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_page_settings#/author-archives"); | |
| 106 | 171 | |
| 107 | - // Clear | |
| 108 | - delete_option( 'uwp_admin_notices' ); | |
| 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 | + if ( !get_user_meta( get_current_user_id(), 'uwp_seo_author_disabled_notice_dismissed' ) ) { | |
| 176 | + ?> | |
| 177 | + <div class="notice notice-error"> | |
| 178 | + <p><strong>UsersWP | |
| 179 | + - </strong><?php esc_attr_e( 'Yoast SEO has disabled user profiles, please enable them.', 'userswp' ); ?> | |
| 180 | + <a href="<?php echo esc_url_raw( $settings_link ); ?>" | |
| 181 | + class="button button-primary"><?php esc_attr_e( 'View Settings', 'userswp' ); ?></a> | |
| 182 | + <a href="<?php echo esc_url( add_query_arg('uwp-seo-notice-dismissed', 1, uwp_current_page_url()) ); ?>" | |
| 183 | + class="button button-primary"><?php esc_attr_e( 'Dismiss', 'userswp' ); ?></a> | |
| 184 | + </p> | |
| 185 | + </div> | |
| 186 | + <?php | |
| 187 | + } | |
| 188 | + } | |
| 189 | + } | |
| 109 | 190 | } |
| 191 | + | |
| 192 | + } | |
| 193 | + | |
| 194 | + public function admin_init_handler(){ | |
| 195 | + $user_id = get_current_user_id(); | |
| 196 | + if ( isset( $_GET['uwp-seo-notice-dismissed'] ) ) { | |
| 197 | + add_user_meta( $user_id, 'uwp_seo_author_disabled_notice_dismissed', 'true', true ); | |
| 198 | + } | |
| 110 | 199 | } |
| 111 | 200 | |
| 112 | 201 | } |