Advertisement
Guest User

Untitled

a guest
Oct 19th, 2016
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 17.63 KB | None | 0 0
  1. <?php
  2. /**
  3. * Template Name: Login
  4. */
  5. ?>
  6. <?php
  7. // IF USER IS ALREADY LOGGED -> REDIRECT HIM TO HOME PAGE
  8. if (is_user_logged_in()) :
  9. wp_redirect( home_url() );
  10. exit;
  11. else :
  12. // We get the logo image
  13. $login_logo_image = woffice_get_settings_option('login_logo_image');
  14. // Second landing :
  15. $login_layout = woffice_get_settings_option('login_layout');
  16.  
  17. ?>
  18. <html <?php language_attributes(); ?> style="margin-top: 0 !important;">
  19. <head>
  20. <meta charset="<?php bloginfo( 'charset' ); ?>">
  21. <!-- MAKE IT RESPONSIVE -->
  22. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  23. <meta name="mobile-web-app-capable" content="yes">
  24. <meta name="apple-mobile-web-app-capable" content="yes">
  25. <link rel="profile" href="http://gmpg.org/xfn/11">
  26. <link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>">
  27. <?php // GET FAVICONS
  28. woffice_favicons();
  29. ?>
  30. <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
  31. <!--[if lt IE 9]>
  32. <script src="<?php echo get_template_directory_uri(); ?>/js/html5shiv.js"></script>
  33. <script src="<?php echo get_template_directory_uri(); ?>/js/respond.min.js"></script>
  34. <script src="<?php echo get_template_directory_uri(); ?>/js/flexie.min.js"></script>
  35. <![endif]-->
  36. <?php wp_head(); ?>
  37. </head>
  38.  
  39. <body <?php body_class($login_layout); ?>>
  40.  
  41. <div id="page-wrapper">
  42. <div id="content-container">
  43. <?php // Check for Revolution Slider :
  44. $login_revslider = woffice_get_settings_option('login_revslider');
  45. ?>
  46. <!-- START CONTENT -->
  47. <section id="woffice-login" class="<?php echo (!empty($login_revslider) ? 'revslider-enabled' : 'revslider-disabled') ?>">
  48.  
  49. <div id="woffice-login-left">
  50. <?php
  51. // Revslider :
  52. if (!empty($login_revslider) && shortcode_exists('rev_slider')) :
  53. putRevSlider($login_revslider);
  54. endif;
  55. ?>
  56. </div>
  57.  
  58. <div id="woffice-login-right">
  59. <!-- LOGO & DESCRIPTION -->
  60. <header>
  61. <?php if (!empty($login_logo_image)) { ?>
  62. <a href="<?php echo home_url(); ?>" id="login-logo"><img src='<?php echo $login_logo_image["url"]; ?>'/></a>
  63. <?php } ?>
  64.  
  65. <?php // THE ERRORS
  66. $login = (isset($_GET['login']) ) ? $_GET['login'] : 0;
  67. $color_notifications = woffice_get_settings_option('color_notifications');
  68.  
  69. //Display default message for plugin New User Approve
  70. if(class_exists('pw_new_user_approve')) {
  71. if((is_string($login) && $login == 'pending_approval')) {
  72. echo'<div class="infobox fa-meh-o" style="background-color: '.$color_notifications.';">';
  73. echo'<span class="infobox-head"><i class="fa fa-exclamation-triangle"></i> '. __('ERROR:','woffice').'</span>';
  74. echo'<p>'. __('Your account is still pending approval.','woffice') .'</p>';
  75. echo'</div>';
  76. } else {
  77. echo'<div class="infobox" style="background-color: '.$color_notifications.';">';
  78. echo'<p>'. __('This site is accessible to approved users only. To be approved, you must first register.','woffice') .'</p>';
  79. echo'</div>';
  80. }
  81. }
  82.  
  83. if ( $login === "failed" ) {
  84. echo'<div class="infobox fa-meh-o" style="background-color: '.$color_notifications.';">';
  85. echo'<span class="infobox-head"><i class="fa fa-exclamation-triangle"></i> '. __('ERROR:','woffice').'</span>';
  86. echo'<p>'. __('Invalid username and/or password.','woffice') .'</p>';
  87. echo'</div>';
  88. } elseif ( $login === "empty" ) {
  89. echo'<div class="infobox fa-meh-o" style="background-color: '.$color_notifications.';">';
  90. echo'<p>'. __('Username and/or Password is empty.','woffice') .'</p>';
  91. echo'</div>';
  92. } elseif ( $login === "false" ) {
  93. $color_notifications_green = woffice_get_settings_option('color_notifications_green');
  94. echo'<div class="infobox fa-check-circle-o" style="background-color: '.$color_notifications_green.';">';
  95. echo'<span class="infobox-head"><i class="fa fa-check-circle-o"></i> '. __('Success:','woffice').'</span>';
  96. echo'<p>'. __('You are logged out.','woffice') .'</p>';
  97. echo'</div>';
  98. }
  99. ?>
  100.  
  101. <?php // GET & DISPLAY LOGIN TEXT
  102. $login_text = woffice_get_settings_option('login_text');
  103. if (!empty($login_text)):
  104. echo"<p>".$login_text."</p>";
  105. endif; ?>
  106.  
  107. <?php /* GOOGLE LOGIN */
  108. if (function_exists('woffice_glogin_frontend')){
  109. woffice_glogin_frontend();
  110. } ?>
  111.  
  112. </header>
  113.  
  114. <!-- FORM -->
  115. <?php
  116. // CHECKING FOR OTHER FORMS FIRST
  117. $type = (isset($_GET['type'])) ? $_GET['type'] : "";
  118. if ($type == "lost-password") {
  119. //
  120. // THE RESET PASSWORD FORM
  121. //
  122. // https://code.tutsplus.com/tutorials/build-a-custom-wordpress-user-flow-part-3-password-reset--cms-23811
  123.  
  124. $color_notifications = woffice_get_settings_option('color_notifications');
  125. echo'<div class="infobox fa-meh-o" style="background-color: '.$color_notifications.';">';
  126.  
  127. if ( isset( $_REQUEST['errors'] ) ) {
  128. $error_codes = explode( ',', $_REQUEST['errors'] );
  129.  
  130. foreach ( $error_codes as $error_code ) {
  131. switch ( $error_code ) {
  132. // Lost password
  133. case 'empty_username':
  134. $message_error = __( 'You need to enter your email address to continue.', 'woffice' );
  135. case 'invalid_email':
  136. case 'invalidcombo':
  137. $message_error = __( 'There are no users registered with this email address.', 'woffice' );
  138. // Reset password
  139. /*case 'expiredkey':
  140. case 'invalidkey':
  141. $message_error = __( 'The password reset link you used is not valid anymore.', 'personalize-login' );
  142. case 'password_reset_mismatch':
  143. $message_error = __( "The two passwords you entered don't match.", 'personalize-login' );
  144. case 'password_reset_empty':
  145. $message_error = __( "Sorry, we don't accept empty passwords.", 'personalize-login' );
  146. default:
  147. break;*/
  148. }
  149. echo'<p>'.$message_error.'</p>';
  150. }
  151. } else {
  152. echo'<span class="infobox-head">'. __('Forgot Your Password ? ','woffice').'</span>';
  153. echo'<p>'. __('Enter your email address and we'll send you a link you can use to pick a new password.','woffice') .'</p>';
  154. }
  155.  
  156. echo'</div>';
  157.  
  158. ?>
  159.  
  160. <form id="lostpasswordform" action="<?php echo wp_lostpassword_url(); ?>" class="clearfix" method="post">
  161. <p class="form-row">
  162. <label for="user_login"><?php _e( 'Email', 'woffice' ); ?>
  163. <input type="text" name="user_login" id="user_login">
  164. </p>
  165.  
  166. <p class="lostpassword-submit">
  167. <input type="submit" name="submit" class="lostpassword-button"
  168. value="<?php _e( 'Reset Password', 'woffice' ); ?>"/>
  169. </p>
  170. </form>
  171.  
  172. <?php
  173.  
  174. } else {
  175. //
  176. // THE LOGIN FORM
  177. //
  178. if ( isset( $_REQUEST['checkemail'] ) && $_REQUEST['checkemail'] == 'confirm' ) : ?>
  179. <p class="login-info">
  180. <?php _e( 'Check your email for a link to reset your password.', 'woffice' ); ?>
  181. </p>
  182. <?php endif;
  183.  
  184. $aft_login = woffice_get_settings_option('aft_login');
  185. $custom_redirect_url = woffice_get_settings_option('custom_redirect_url');
  186. if($aft_login == "custom") {
  187. $redirect_url = $custom_redirect_url;
  188. } elseif ($aft_login == "previous") {
  189. //Get the redirect url where redirect to
  190. $previous_url = (isset($_GET['redirect_to']) && !empty($_GET['redirect_to'])) ? urldecode($_GET['redirect_to']) : null;
  191.  
  192. if(!is_null($previous_url)) {
  193. //Get the current url
  194. $http = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443) ? "https://" : "http://";
  195. $current_url = $http . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
  196.  
  197. $current_url_noparam = explode("?", $current_url);
  198. $previous_url_noparam = explode("?", $previous_url);
  199.  
  200. //Check if the previous url is the same of current one or if it hosted on another address
  201. if ($current_url_noparam[0] == $previous_url_noparam[0] || strpos($previous_url, $_SERVER['HTTP_HOST']) === false){
  202. $redirect_url = home_url();
  203. } else {
  204. $redirect_url = $previous_url;
  205. }
  206. //$redirect_url = site_url($_SERVER['REQUEST_URI']);
  207. } else {
  208. $redirect_url = home_url();
  209. }
  210. } else {
  211. $redirect_url = home_url();
  212. }
  213.  
  214. $login_args = array(
  215. 'redirect' => $redirect_url,
  216. 'id_username' => 'user',
  217. 'id_password' => 'pass',
  218. );
  219. wp_login_form( $login_args );
  220. // LOST PASSWORD LINK
  221. $login_rest_password = woffice_get_settings_option('login_rest_password');
  222. if ($login_rest_password == "yep"){
  223. echo '<a href="'. wp_lostpassword_url() .'" class="password-lost">'. __('Lost Password','woffice') .'</a>';
  224. }
  225.  
  226. }
  227. ?>
  228.  
  229. <?php
  230. /* REGISTER FORM */
  231. $user_can_register = apply_filters('woffice_users_can_register', get_option('users_can_register'));
  232. if ($user_can_register == '1'){
  233. $register_message = woffice_get_settings_option('register_message');
  234. echo '<div id="register-wrapper">';
  235. echo '<p>'.$register_message.'</p>';
  236.  
  237. // Check for paid membership pro
  238. $register_pmp = woffice_get_settings_option('register_pmp');
  239. if ( $register_pmp == "yep" && function_exists("pmpro_getOption") ){
  240. $register_page = get_permalink(pmpro_getOption("levels_page_id"));
  241. echo '<a href="'.$register_page.'" class="btn btn-default bp-ajaxr" id="register-trigger"><i class="fa fa-sign-in bp-ajaxr"></i> '. __('Sign Up','woffice') .'</a>';
  242. } else {
  243. echo '<a href="#register-form" class="btn btn-default bp-ajaxr" id="register-trigger"><i class="fa fa-sign-in bp-ajaxr"></i> '. __('Sign Up','woffice') .'</a>';
  244. }
  245.  
  246. echo '</div>';
  247. echo '<div id="register-loader" class="intern-padding woffice-loader"><i class="fa fa-spinner"></i></div>';
  248.  
  249. echo '<div id="goback-trigger"><a href="#loginform" class="btn btn-default"><i class="fa fa-arrow-left"></i> '. __('Go back','woffice') .'</a></div>';
  250. }
  251. ?>
  252.  
  253.  
  254. <?php // DISPLAY WORDPRESS LINK ?
  255. $login_wordpress = woffice_get_settings_option('login_wordpress');
  256. if ($login_wordpress == "yep"):
  257. ?>
  258. <footer>
  259. <p>
  260. <?php _e("Proudly powered by","woffice"); ?>
  261. <a href="https://wordpress.org/" target="_blank">
  262. <img src="<?php echo home_url(); ?>/wp-admin/images/wordpress-logo.svg" alt="wordpress logo">
  263. </a>
  264. </p>
  265. </footer>
  266. <?php endif; ?>
  267. </div>
  268.  
  269. </section>
  270. <!-- END CONTENT -->
  271.  
  272. </div>
  273. </div>
  274.  
  275. <!-- JAVSCRIPTS BELOW AND FILES LOADED BY WORDPRESS -->
  276.  
  277. <script type="text/javascript">
  278. if (jQuery('#success-register').length > 0) {
  279. jQuery('#register-loader').slideDown();
  280. jQuery("#register-form, #goback-trigger").hide();
  281. jQuery("#loginform, #register-wrapper,a.password-lost").hide();
  282. function show_login() {
  283. jQuery("#loginform, #register-wrapper,a.password-lost").show();
  284. jQuery('#register-loader').slideUp();
  285. }
  286. setTimeout(show_login, 2000);
  287. <?php $register_autoredirect = woffice_get_settings_option('register_autoredirect');
  288. if($register_autoredirect == "yep") : ?>
  289. var NewUser = jQuery('#success-register').data('user');
  290. if (NewUser) {
  291. jQuery.ajax({
  292. type:"POST",
  293. url: "<?php echo get_site_url() ?>/wp-admin/admin-ajax.php",
  294. data: {"action" : "WofficeRegisterRedirect", "user_id" : NewUser, "security" : "<?php echo wp_create_nonce( "WofficeRegisterRedirectNonce" ); ?>"},
  295. success:function(returnval){
  296. jQuery(returnval).appendTo("body");
  297. jQuery(".woffice-ajax-main").show();
  298. function RedirectAfterLogin() {
  299. window.location.replace("<?php echo get_site_url() ?>");
  300. }
  301. setTimeout(RedirectAfterLogin, 2000);
  302. },
  303. });
  304. }
  305. <?php endif; ?>
  306. }
  307. jQuery("#register-loader, #register-form, #goback-trigger").hide();
  308. jQuery("#register-trigger").on('click', function(){
  309. jQuery('#register-loader').slideDown();
  310. jQuery("#loginform, #register-wrapper,a.password-lost").hide();
  311. function show_register() {
  312. jQuery("#register-form, #goback-trigger").show();
  313. jQuery('#register-loader').slideUp();
  314. }
  315. setTimeout(show_register, 1000);
  316. });
  317. jQuery("#goback-trigger a").on('click', function(){
  318. jQuery('#register-loader').slideDown();
  319. jQuery("#register-form, #goback-trigger").hide();
  320. function show_login() {
  321. jQuery("#loginform, #register-wrapper,a.password-lost").show();
  322. jQuery('#register-loader').slideUp();
  323. }
  324. setTimeout(show_login, 1000);
  325. });
  326. var hash = location.hash.replace('#', '');
  327. if (hash == 'register-form') {
  328. if (jQuery('#success-register').length == 0) {
  329. jQuery('#register-loader').slideDown();
  330. jQuery("#loginform, #register-wrapper,a.password-lost").hide();
  331. function show_register() {
  332. jQuery("#register-form").show();
  333. jQuery('#register-loader').slideUp();
  334. }
  335. setTimeout(show_register, 1000);
  336. }
  337. }
  338. </script>
  339.  
  340. <?php wp_footer(); ?>
  341. </body>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement