/** * custom log in functionality, from custom log in page */ static function login() { if (!isset($_POST[Kanban_Utils::get_nonce()]) || !wp_verify_nonce($_POST[Kanban_Utils::get_nonce()], 'login')) { return; } if (is_email($_POST['email'])) { $user = get_user_by('email', $_POST['email']); if (empty($user)) { Kanban_Flash::flash(__('Whoops! We can\'t find an account for that email address.', 'kanban'), 'danger'); wp_redirect($_POST['_wp_http_referer']); exit; } } else { $user = get_user_by('login', $_POST['email']); if (empty($user)) { Kanban_Flash::flash(__('Whoops! We can\'t find an account for that username.', 'kanban'), 'danger'); wp_redirect($_POST['_wp_http_referer']); exit; } } $creds = array(); $creds['user_login'] = $user->user_login; $creds['user_password'] = $_POST['password']; $creds['remember'] = true; $user = wp_signon($creds, false); if (is_wp_error($user)) { Kanban_Flash::flash(__('Whoops! That password is incorrect for this email address.', 'kanban'), 'danger'); wp_redirect($_POST['_wp_http_referer']); exit; } wp_set_current_user($user->ID); wp_set_auth_cookie($user->ID); wp_redirect(sprintf('%s/%s/board', site_url(), Kanban::$slug)); exit; }
static function init() { if (!function_exists('session_start')) { return; } self::$is_session_available = TRUE; // @link http://stackoverflow.com/a/28377350/38241 if (version_compare(phpversion(), "5.4.0") != -1) { if (session_status() == PHP_SESSION_NONE) { session_start(); } } else { if (session_id() == '') { session_start(); } } }
<?php // Exit if accessed directly if (!defined('ABSPATH')) { exit; } Kanban_Flash::init(); class Kanban_Flash { static function init() { add_action('init', array(__CLASS__, 'setup_flash_messages')); } static function setup_flash_messages() { if (version_compare(phpversion(), '5.4.0', '>=')) { if (session_status() == PHP_SESSION_NONE) { session_start(); } } else { if (session_id() == '') { session_start(); } } Kanban::$instance->flash = new Kanban\Messages(); Kanban::$instance->flash->msgTypes = array('default', 'info', 'warning', 'success', 'danger'); Kanban::$instance->flash->msgClass = 'alert alert-'; Kanban::$instance->flash->msgWrapper = '<div class="%s%s alert-dismissible"> <button type="button" class="close" data-dismiss="alert" aria-label="Close"> <span aria-hidden="true">×</span> </button>
<div class="row" style="margin-top: 60px;"> <form action="" method="post" class="col-sm-4 col-sm-offset-4"> <img src="<?php echo Kanban::get_instance()->settings->uri; ?> /img/kanbanwp-logo.png" class="img-responsive" style="margin: 0 auto 30px;"> <?php Kanban_Flash::flash(); ?> <div class="panel panel-default"> <div class="panel-heading"> <?php if (!is_user_logged_in()) { ?> <h2><?php echo __('Please Login', Kanban::$instance->settings->file); ?> </h2> <div class="form-group"> <label for="email" class="sr-only">