'.login_button_text().' '; else: if (get_option( 'option_usermodal' ) != 1): return ' '; else: return ' '; endif; endif; } add_shortcode( 'Alimir_BootModal_Login', 'alimir_bootModal_login_shortcode' ); function login_button_text(){ if (!is_user_logged_in()): if (get_option('button_text') == null): return __('Login','alimir'); else: return get_option('button_text'); endif; else: if (get_option('button_text2') == null): return __('Profile','alimir'); else: return get_option('button_text2'); endif; endif; } function default_buttons(){ if (get_option( 'default_buttons' )==0) return 'btn-primary'; else if (get_option( 'default_buttons' )==1) return 'btn-info'; else if (get_option( 'default_buttons' )==2) return 'btn-success'; else if (get_option( 'default_buttons' )==3) return 'btn-warning'; else if (get_option( 'default_buttons' )==4) return 'btn-danger'; else if (get_option( 'default_buttons' )==5) return 'btn-inverse'; } function default_sizes(){ if (get_option( 'default_sizes' )==0) return 'btn-large'; else if (get_option( 'default_sizes' )==1) return 'btn-small'; else if (get_option( 'default_sizes' )==2) return 'btn-mini'; } function alimir_bootModal_ajax_login_init(){ if (!is_admin()) : wp_register_script( 'ajax-login-script', plugins_url( '/assets/js/scripts.js' , __FILE__ ), array( 'jquery' ) ); wp_enqueue_script( 'ajax-login-script' ); endif; wp_localize_script( 'ajax-login-script', 'ajax_login_object', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ), 'redirecturl' => admin_url(), 'loadingmessage' => __('

Sending user info, please wait...

','alimir'), 'registrationloadingmessage' => __( '

Processing Registration...

', 'alimir' ) )); add_action( 'wp_ajax_nopriv_ajaxregister', 'alimir_bootModal_ajax_registration' ); add_action( 'wp_ajax_nopriv_ajaxlogin', 'alimir_bootModal_ajax_login' ); } add_action('init', 'alimir_bootModal_ajax_login_init'); // Login Process function alimir_bootModal_ajax_login(){ check_ajax_referer( 'ajax-login-nonce', 'security' ); $credentials = array(); $credentials['user_login'] = $_POST['username']; $credentials['user_password'] = $_POST['password']; $credentials['remember'] = true; if ( $credentials['user_login'] == null || $credentials['user_password'] == null ){ echo json_encode(array('loggedin'=>false, 'message'=>__('

Please fill all the fields.

','alimir'))); } else{ if ($credentials['user_login'] != null && $credentials['user_password'] != null){ $errors = wp_signon( $credentials, false ); } if ( is_wp_error($errors) ){ $display_errors = __('

ERROR: Wrong username or password.

','alimir'); echo json_encode(array('loggedin'=>false, 'message'=>$display_errors)); } else{ echo json_encode(array('loggedin'=>true, 'message'=>__('

Login successful, redirecting...

','alimir'))); } } die(); } // Register Process function alimir_bootModal_ajax_registration() { check_ajax_referer( 'ajax-form-nonce', 'security2' ); $user_login = $_POST['user_login']; $user_email = $_POST['user_email']; if ( $user_login == null || $user_email == null ){ echo json_encode(array('registered'=>false, 'message'=>__('

Please fill all the fields.

','alimir'))); } else{ $errors = register_new_user($user_login, $user_email); if ( is_wp_error( $errors ) ) { $registration_error_messages = $errors->errors; $display_errors = '
'; foreach($registration_error_messages as $error){ $display_errors .= '
'.$error[0].'
'; } $display_errors .= '
'; echo json_encode( array( 'registered' => false, 'message' => $display_errors, ) ); } else { echo json_encode( array( 'registered' => true, 'message' => __( '

Registration complete. Please check your e-mail.

', 'alimir' ), ) ); } } die(); } // Main Forms function alimir_bootModal_form() { if (!is_user_logged_in()) : ?> 4) array_shift($posts); if (!in_array($post->ID, $posts)) $posts[] = $post->ID; update_user_meta( $user_id, 'alimir_viewed_posts', $posts ); endif; } add_action('wp_head', 'alimir_bootModal_update_user_view'); // Sidebar Widget wp_register_widget_control( 'alimir_bootModal_login', 'alimir_bootModal_login', 'alimir_bootModal_widget_control' ); wp_register_sidebar_widget( 'alimir_bootModal_login', 'Ajax BootModal Login', 'alimir_bootModal_widget', array( 'description' => 'wordpress modal login, poweres by bootstrap and ajax. you can use this plugin for better login and show user profile with new shape.' ) ); function alimir_bootModal_widget($args) { $widgettitle = get_option('about_us_widget_title'); extract($args); echo $before_widget; echo $before_title . $widgettitle . $after_title; echo $after_widget; echo do_shortcode('[Alimir_BootModal_Login]'); } function alimir_bootModal_widget_control($args=array()) { if (isset($_POST['submitted'])) { update_option('about_us_widget_title', $_POST['widgettitle']); } $widgettitle = get_option('about_us_widget_title'); ?>