/** * Sets the right href and class attributes for the modal link in menus */ function palo_filter_frontend_modal_link_atts($atts, $item, $args) { /** * Ony apply to modal login or register */ if (in_array($atts['href'], array('#pa_modal_login', '#pa_modal_register'))) { /** * Add trigger if not logged in */ if (!is_user_logged_in()) { $atts['class'] = assign_if_exists('class', $atts) . ' palo-modal-login-trigger'; } /** * Modify links */ if ('#pa_modal_login' == $atts['href']) { if (is_user_logged_in()) { $atts['href'] = wp_logout_url(); } else { $atts['href'] = wp_login_url(); $atts['data-palo-modal'] = palo_append_qs(wp_login_url(), 'palo-login=1'); } } else { if ('#pa_modal_register' == $atts['href']) { $atts['href'] = wp_registration_url(); $atts['data-palo-modal'] = palo_append_qs(wp_registration_url(), 'palo-login=1'); } } } return $atts; }
/** * Generates a wp_die screen with the url for wp-login.php:lostpassword. * * The url has the tracker palo-login if applicable */ function palo_action_captcha_reset_die() { global $palo_options, $palo_textdomain; if (!palo_captcha_test()) { $url = palo_append_qs(wp_login_url(), 'action=lostpassword'); wp_die(__($palo_options['palo_captcha_error_msg'], $palo_textdomain) . '</p><p><strong><a class="button button-large" href="' . $url . '">' . __('Try again', $palo_textdomain) . '</a></strong>'); } }
/** * Keep track of (palo-login=1) and (interim-login=1) */ function palo_filter_login_tracker($url) { if (!empty($_REQUEST['interim-login'])) { $url = palo_append_qs($url, 'interim-login=1'); } if (!empty($_REQUEST['palo-login'])) { $url = palo_append_qs($url, 'palo-login=1'); } return $url; }
/** * Creates the output for [pa_modal_register] * * @return string the shortcode generated HTML code */ function palo_shortcode_frontend_modal_register($atts = array()) { global $palo_textdomain; $atts = shortcode_atts(array('register_text' => __('Register', $palo_textdomain), 'registered_text' => __('You are already registered', $palo_textdomain)), $atts); /** * Logged in user will see a normal link and not logged in * users will see a normal login that has additional Javascript * functions attached to it */ if (is_user_logged_in()) { $link = $atts['registered_text']; } else { $link = sprintf('<a href="%s" data-palo-modal="%s" class="palo-modal-login-trigger">%s</a>', wp_registration_url(), palo_append_qs(wp_registration_url(), 'palo-login=1'), $atts['register_text']); } return $link; }
/** * Registers the frontend stylesheet and script files */ function palo_action_frontend_scripts() { global $palo_scripts_dir, $palo_styles_dir, $palo_helper, $palo_options; wp_register_style('palo-front', $palo_styles_dir . 'front.css'); wp_register_script('palo-front', $palo_scripts_dir . 'frontend.js', array('jquery'), false, true); wp_enqueue_style('palo-front'); wp_enqueue_script('palo-front'); /** * Add the modal window HTML/CSS if not already done */ if (!is_user_logged_in()) { // wp_auth_check_html() with <p> tags removed and correct URL ob_start(); wp_auth_check_html(); $wp_auth_check_html = ob_get_clean(); $wp_auth_check_html = preg_replace('/<p>.*<\\/p>/s', '', $wp_auth_check_html); $wp_auth_check_html = str_replace('interim-login=1', 'palo-login=1', $wp_auth_check_html); echo $wp_auth_check_html; wp_enqueue_style('wp-auth-check'); $text_color = assign_if_exists('palo_setting_modal_text_color', $palo_options); ?> <style> #wp-auth-check-wrap #wp-auth-check { padding-top: 0 !important } #wp-auth-check-wrap .wp-auth-check-close:before { color: <?php echo $text_color; ?> !important; } </style> <script type="text/javascript"> jQuery( document ).ready( function($) { $( 'a[href="#pa_modal_login"]' ) .attr( 'href', '<?php echo wp_login_url(); ?> ' ) .attr( 'data-palo-modal', '<?php echo palo_append_qs(wp_login_url(), "palo-login=1"); ?> '.replace( '&', '&' ) ) .addClass( 'palo-modal-login-trigger' ) ; $( 'a[href="#pa_modal_register"]' ) .attr( 'href', '<?php echo wp_registration_url(); ?> ' ) .attr( 'data-palo-modal', '<?php echo palo_append_qs(wp_registration_url(), "palo-login=1"); ?> '.replace( '&', '&' ) ) .addClass( 'palo-modal-login-trigger' ) ; } ); </script> <?php } else { ?> <script type="text/javascript"> jQuery( document ).ready( function($) { $( 'a[href="#pa_modal_login"]' ).attr( 'href', '<?php echo wp_logout_url(); ?> '.replace( '&', '&' ) ); } ); </script> <?php } }