function ellak_social_links() { ?> <div class="header-login"> <?php if (is_user_logged_in()) { ?> <a href="<?php echo esc_url(get_edit_user_link()); ?> "><?php _e('Ο λογαριασμός μου', 'gpchild-ellak'); ?> </a> <a href="<?php echo esc_url(wp_logout_url(get_permalink())); ?> "><?php _e('Αποσύνδεση', 'gpchild-ellak'); ?> </a> <?php } else { if (get_option('users_can_register')) { ?> <a href="<?php echo esc_url(wp_registration_url()); ?> "><?php _e('Εγγραφή', 'gpchild-ellak'); ?> </a> <?php } // get_option ?> <a href="<?php echo esc_url(wp_login_url()); ?> "><?php _e('Συνδεση', 'gpchild-ellak'); ?> </a> <?php } // is_user_logged_in ?> </div> <div class="header-social-links"> <ul class="social-links"> <li class="social-link-facebook"><a href="https://www.facebook.com/CreativeCommonsGreece" target="_blank"><span>Facebook</span></a></li> <li class="social-link-twitter"><a href="https://www.twitter.com/cc_greece" target="_blank"><span>Twitter</span></a></li> <li class="social-link-rss"><a href="https://ellak.gr/rss-feeds/" target="_blank"><span>RSS</span></a></li> </ul> </div><!-- .header-social-links --> <?php }
function regclass_process_form() { // error_log("+++++++++++++++++++++++++++++++++++++++++"); // error_log(print_r($_POST, true)); if (!empty($_POST['nonce_regclass_form'])) { if (!wp_verify_nonce($_POST['nonce_regclass_form'], 'handle_regclass_form')) { die('You are not authorized to perform this action.'); } else { //die('Its safe to do further processing on submitted data.'); $error = null; if (isset($_POST['signup'])) { wp_redirect(wp_registration_url(add_query_arg('id', $_GET['id'], get_permalink()))); exit; } else { if (isset($_POST['signin'])) { wp_redirect(wp_login_url(add_query_arg('id', $_GET['id'], get_permalink()))); exit; } else { //if( isset($_POST['register'])) { //die('Its safe to register.'); //echo "hello"; //error_log("register"); wp_redirect(the_permalink()); } } } } // process input show errors or success message return "Process Data"; }
/** * Add front-end notices. */ public function ticket_form_message() { /** @var $camptix CampTix_Plugin */ global $camptix; // Warn users that they will need to login to purchase a ticket if (!is_user_logged_in()) { $camptix->notice(apply_filters('camptix_require_login_please_login_message', sprintf(__('Please <a href="%s">log in</a> or <a href="%s">create an account</a> to purchase your tickets.', 'camptix'), wp_login_url(add_query_arg($_REQUEST, $this->get_redirect_return_url())), wp_registration_url()))); } // Inform a user registering multiple attendees that other attendees will enter their own info if (isset($_REQUEST['tix_action']) && 'attendee_info' == $_REQUEST['tix_action'] && $this->registering_multiple_attendees($_REQUEST['tix_tickets_selected'])) { $notice = __('<p>Please enter your own information for the first ticket, and then enter the names and e-mail addresses of other attendees in the subsequent ticket fields.</p>', 'camptix'); if ($this->tickets_have_questions($_REQUEST['tix_tickets_selected'])) { $notice .= __('<p>The other attendees will receive an e-mail asking them to confirm their registration and enter their additional information.</p>', 'camptix'); } $camptix->notice($notice); } // Ask the attendee to confirm their registration if (isset($_REQUEST['tix_action']) && 'edit_attendee' == $_REQUEST['tix_action'] && self::UNCONFIRMED_USERNAME == get_post_meta($_REQUEST['tix_attendee_id'], 'tix_username', true)) { $tickets_selected = array(get_post_meta($_REQUEST['tix_attendee_id'], 'tix_ticket_id', true) => 1); // mimic $_REQUEST['tix_tickets_selected'] if ($this->tickets_have_questions($tickets_selected)) { $notice = __('To complete your registration, please fill out the fields below, and then click on the Confirm Registration button.', 'camptix'); } else { $notice = __('To complete your registration, please verify that all of the information below is correct, and then click on the Confirm Registration button.', 'camptix'); } $camptix->notice($notice); } }
function wp_login_form($args = array()) { $defaults = array('redirect' => (is_ssl() ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'], 'form_id' => uniqid('loginform_'), 'label_username' => __('Username', 'dfd'), 'placeholder_username' => __('Enter your login', 'dfd'), 'label_password' => __('Password', 'dfd'), 'placeholder_password' => __('Enter your password', 'dfd'), 'label_lost_password' => __('Lost password', 'dfd'), 'label_log_in' => __('Log In', 'dfd'), 'id_username' => uniqid('user_login_'), 'id_password' => uniqid('user_pass_'), 'id_submit' => uniqid('wp-submit_'), 'lost_password' => true, 'value_username' => ''); $args = wp_parse_args($args, apply_filters('login_form_defaults', $defaults)); $registration_link = ''; if (get_option('users_can_register')) { $registration_link = ' <a href="' . wp_registration_url() . '"><i class="ios7icon-lock"></i>' . __('Registration', 'dfd') . '</a> '; } $form = ' <form name="' . $args['form_id'] . '" id="' . $args['form_id'] . '" action="' . esc_url(site_url('wp-login.php', 'login_post')) . '" method="post"> ' . apply_filters('login_form_top', '', $args) . ' <p class="login-username"> <label for="' . esc_attr($args['id_username']) . '">' . esc_html($args['label_username']) . '</label> <input type="text" name="log" id="' . esc_attr($args['id_username']) . '" class="input" value="' . esc_attr($args['value_username']) . '" size="20" placeholder="' . esc_html($args['placeholder_username']) . '" /> </p> <p class="login-password"> <label for="' . esc_attr($args['id_password']) . '">' . esc_html($args['label_password']) . '</label> <input type="password" name="pwd" id="' . esc_attr($args['id_password']) . '" class="input" value="" size="20" placeholder="' . esc_html($args['placeholder_password']) . '" /> </p> <p class="login-submit"> <button type="submit" name="wp-submit" id="' . esc_attr($args['id_submit']) . '" class="button"><i class="icon-arrow-left-1"></i>' . esc_attr($args['label_log_in']) . '</button> <input type="hidden" name="redirect_to" value="' . esc_url($args['redirect']) . '" /> </p> ' . ($args['lost_password'] ? '<p class="login-lost-password"><label>' . '<a href="' . wp_lostpassword_url() . '">' . esc_attr($args['label_lost_password']) . '</a></label></p>' : '') . '<p class="login-registration"> ' . $registration_link . ' </p>' . apply_filters('login_form_bottom', '', $args) . ' </form>'; echo $form; }
/** * 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; }
function v_forcelogin() { if (!is_user_logged_in() && (v_getUrl() != wp_login_url() && v_getUrl() != wp_registration_url() && v_getUrl() != wp_lostpassword_url())) { wp_redirect(wp_login_url(), 302); exit; } }
function widget($args, $instance) { global $user_login; if (!isset($args['widget_id'])) { $args['widget_id'] = null; } extract($args, EXTR_SKIP); extract($instance); echo $before_widget; $title = apply_filters('widget_title', $title, $instance, $this->id_base); if (is_user_logged_in()) { $user = get_user_by('login', $user_login); $title = __('Welcome', 'mfn-opts') . ' ' . $user->data->display_name; } echo '<div class="mfn-login">'; if ($title) { echo $before_title . $title . $after_title; } // validation if (isset($_GET['login']) && $_GET['login'] == 'failed') { $errcode = $_GET['errcode']; if ($errcode == "empty_username" || $errcode == "empty_password") { $error = __('Please enter Username and Password', 'mfn-opts'); } elseif ($errcode == 'invalid_username') { $error = __('Invalid Username', 'mfn-opts'); } elseif ($errcode == 'incorrect_password') { $error = __('Incorrect Password', 'mfn-opts'); } echo '<div class="alert alert_error">' . $error . '</div>'; } if (is_user_logged_in()) { echo '<div class="avatar-wrapper">' . get_avatar($user->ID, 64) . '</div>'; echo '<div class="author">'; _e('Logged in as ', 'mfn-opts'); echo '<strong>' . ucfirst(implode(', ', $user->roles)) . '</strong><br />'; echo '<a href="' . admin_url() . '">' . __('Dashboard', 'mfn-opts') . '</a>'; echo '<span class="sep">|</span>'; echo '<a href="' . admin_url() . 'profile.php">' . __('Profile', 'mfn-opts') . '</a>'; echo '<span class="sep">|</span>'; echo '<a href="' . wp_logout_url(site_url()) . '">' . __('Logout', 'mfn-opts') . '</a>'; echo '</div>'; } else { wp_login_form(array('value_remember' => 0, 'redirect' => site_url(), 'remember' => false)); echo '<div class="links">'; if ($show_register) { echo '<a href="' . wp_registration_url() . '">' . __('Register', 'mfn-opts') . '</a>'; } if ($show_register && $show_forgotten_password) { echo '<span class="sep">|</span>'; } if ($show_forgotten_password) { echo '<a href="' . wp_registration_url() . '">' . __('Lost your password?', 'mfn-opts') . '</a>'; } echo '</div>'; } echo '</div>' . "\n"; echo $after_widget; }
function dadospessoais_scripts() { wp_enqueue_script('dadospessoais', get_stylesheet_directory_uri() . '/js/dadospessoais.js', array('jquery')); $var_plataforma = array(); $var_plataforma['signup_url'] = wp_registration_url(); $var_plataforma['login_url'] = wp_login_url(); $var_plataforma['configs'] = array('ajaxurl' => admin_url('admin-ajax.php'), 'ajaxgif' => get_template_directory_uri() . '/images/ajax-loader.gif'); wp_localize_script('dadospessoais', 'dadosPessoais', $var_plataforma); }
/** Get ProfilePress login page URL or WP default login url if it isn't set. */ function pp_registration_url() { $data = pp_db_data(); if (!empty($data['set_registration_url'])) { $reg_url = get_permalink($data['set_registration_url']); } else { $reg_url = wp_registration_url(); } return $reg_url; }
/** * Creates the Nav Menu Markup class * @param My_Plugin_Settings_Public $settings */ function __construct(My_Plugin_Settings_Public $settings) { $this->settings = $settings; $this->site_title = get_bloginfo('name'); $this->home_url = esc_url(home_url('/')); $this->current_url = esc_url(get_permalink()); $this->login_url = wp_login_url($this->current_url); $this->logout_url = wp_logout_url($this->current_url); $this->register_url = wp_registration_url(); $this->unique_menu_id = 'menu_' . $settings->get_option_settings_db_name(); }
function login_form_register() { global $videotube; $loginpage = isset($videotube['loginpage']) ? $videotube['loginpage'] : null; if ($loginpage) { $permalink_structure = get_option('permalink_structure') ? '?' : '&'; $redirect_to = $_REQUEST['redirect_to'] ? $permalink_structure . 'redirect_to=' . $_REQUEST['redirect_to'] : null; wp_redirect(get_permalink($loginpage) . $redirect_to); } else { wp_redirect(wp_registration_url()); } }
function aione_register_link_shortcode($atts) { // Attributes extract(shortcode_atts(array('class' => '', 'text' => 'Sign up'), $atts)); $output = ""; if (!is_user_logged_in()) { $output .= '<div id="login_link" class="user-links login-link ' . $class . '">'; $output .= '<a href="' . wp_registration_url() . '" title="' . $text . '">' . $text . '</a>'; $output .= '</div>'; } return $output; }
function wdm_auction_dashboard_login($ext_html) { $login_screen = ''; $db_url = get_option('wdm_dashboard_page_url'); //get custom login and registration url if set $wdm_login_url = get_option('wdm_login_page_url'); $wdm_registration_url = get_option('wdm_register_page_url'); if (empty($wdm_login_url)) { if ($ext_html === 'bid') { $wdm_login_url = wp_login_url($_SERVER['REQUEST_URI']); } elseif ($ext_html === 'watchlist') { $wdm_login_url = wp_login_url($_SERVER['REQUEST_URI'] . "&add_to_watch=y"); } elseif ($ext_html === 'review') { $wdm_login_url = wp_login_url($_SERVER['REQUEST_URI'] . "&rnr=shw"); } else { $wdm_login_url = wp_login_url($db_url); } } if (empty($wdm_registration_url)) { $wdm_registration_url = wp_registration_url(); } //if($ext_html === 'watchlist'){ // $wdm_login_url = wp_login_url( $_SERVER['REQUEST_URI']."&add_to_watch=y"); //} //elseif($ext_html === 'review'){ // $wdm_login_url = wp_login_url( $_SERVER['REQUEST_URI']."&rnr=shw"); //} //if($ext_html === 'bid'){ if ($ext_html === 'bid') { $login_screen .= '<div class="wdm_ua_pop_up_cmn"><center><div class="ua_login_popup_text">'; $login_screen .= __("Please sign in to place your bid or buy the product.", "wdm-ultimate-auction"); $login_screen .= '</div>'; $login_screen .= '<a class="wdm-login-ua-db wdm_ua_login_db" href="' . $wdm_login_url . '" title="' . __('Login', 'wdm-ultimate-auction') . '">' . __("Login", "wdm-ultimate-auction") . '</a></center></div>'; // } //else{ // $login_screen .= '<div class="wdm_ua_pop_up_cmn"><center><div class="ua_login_popup_text">'; // $login_screen .= __("Please sign in to view your dashboard.", "wdm-ultimate-auction"); // $login_screen .= '</div>'; // $login_screen .= '<a class="wdm-login-ua-db wdm_ua_login_db" href="'.wp_login_url($db_url).'" title="Login">'.__("Login", "wdm-ultimate-auction").'</a></center></div>'; //} } else { $login_screen .= '<div class="wdm_ua_pop_up_cmn"><center><div class="ua_login_popup_text">'; $login_screen .= __("Please sign in to view your dashboard.", "wdm-ultimate-auction"); $login_screen .= '</div>'; $login_screen .= '<a class="wdm-login-ua-db wdm_ua_login_db" href="' . wp_login_url($db_url) . '" title="Login">' . __("Login", "wdm-ultimate-auction") . '</a></center></div>'; } $login_screen .= '<div class="wdm_ua_pop_up_cmn" style="margin-top:40px;"><center><div class="ua_login_popup_text">'; $login_screen .= __("Don't have an account?", "wdm-ultimate-auction"); $login_screen .= '</div>'; $login_screen .= '<a class="wdm-login-ua-db wdm_ua_reg_db" href="' . $wdm_registration_url . '" title="' . __('Register', 'wdm-ultimate-auction') . '">' . __("Register now", "wdm-ultimate-auction") . '</a></center></div>'; return $login_screen; }
/** * Scripts and styles */ function theme_enqueue_styles() { // styles wp_enqueue_style('parent-style', PARENT_URI . '/style.css'); wp_enqueue_style('child-style', CHILD_URI . '/css/style.css'); //scripts wp_enqueue_script('jquery'); wp_enqueue_script('flexslider', CHILD_URI . '/js/flexslider-min.js', 'jquery', 2.1); wp_enqueue_script('scripts', CHILD_URI . '/js/script.js', '', ''); $var_pna = array(); $var_pna['signup_url'] = wp_registration_url(); $var_pna['login_url'] = wp_login_url(get_permalink()); wp_localize_script('scripts', 'pna', $var_pna); }
public static function ensure_user_accepted_terms() { if (isset($_COOKIE['user-accepted-terms'])) { return; } elseif (isset($_POST) && isset($_POST['terms-acceptance'])) { setcookie('user-accepted-terms', 'yes', time() + 3600 * 24 * 10, COOKIEPATH, COOKIE_DOMAIN, false); wp_redirect(wp_registration_url()); exit; } else { KeyshotShopifyMultipassLoginPage::load_login_head(); KeyshotShopifyMultipass::view('terms', array()); exit; } }
/** * (non-PHPdoc) * * @see \Widgets\WidgetBase::widget() */ public function widget($args, $instance) { /* * Put all special URLs */ $instance['logoutUrl'] = wp_logout_url(home_url()); $instance['loginUrl'] = wp_login_url(home_url()); $instance['registrationUrl'] = wp_registration_url(); $instance['lostPasswordUrl'] = wp_lostpassword_url(); $instance['postsUrl'] = '/wp-admin/edit.php'; /* * And call the widget func from the parent class WidgetBase. */ parent::widget($args, $instance); }
function klarna_checkout_page($atts) { $atts = shortcode_atts(array('col' => ''), $atts); $widget_class = ''; if ('left' == $atts['col']) { $widget_class .= ' kco-left-col'; } elseif ('right' == $atts['col']) { $widget_class .= ' kco-right-col'; } $checkout = WC()->checkout(); if (!$checkout->enable_guest_checkout && !is_user_logged_in()) { echo apply_filters('klarna_checkout_must_be_logged_in_message', sprintf(__('You must be logged in to checkout. %s or %s.', 'woocommerce'), '<a href="' . wp_login_url() . '" title="Login">Login</a>', '<a href="' . wp_registration_url() . '" title="Create an account">create an account</a>')); } else { $data = new WC_Gateway_Klarna_Checkout(); return '<div class="klarna_checkout ' . $widget_class . '">' . $data->get_klarna_checkout_page() . '</div>'; } }
/** * Login form shortcode * @param array $atts [description] * @param string $content [description] * @return string [description] */ function gears_login($atts, $content) { $args = array('echo' => false); ob_start(); ?> <?php if (!is_user_logged_in()) { ?> <div class="gears-login-wrap"> <div class="gears-login-links"> <ul> <li class="current"> <?php _e('Sign in', 'gears'); ?> </li> <li> <a href="<?php echo wp_registration_url(); ?> " title="<?php _e('Create New Account', 'gears'); ?> "> <?php _e('Create New Account', 'gears'); ?> </a> </li> </ul> </div> <div class="gears-login well"> <?php echo wp_login_form($args); ?> </div> </div> <?php } ?> <?php $output = ob_get_clean(); return $output; }
static function check_access($exam, $post) { WatuPRO::$output_sent = false; // change this var from class method to avoid outputting the generic message if (!WatuPRO::can_access($exam)) { // not logged in error if (!is_user_logged_in()) { echo "<p><b>" . sprintf(__('You need to be registered and logged in to take this %s.', 'watupro'), __('quiz', 'watupro')) . " <a href='" . wp_login_url(get_permalink($post->ID)) . "'>" . __('Log in', 'watupro') . "</a>"; if (get_option("users_can_register")) { echo " " . __('or', 'watupro') . " <a href='" . wp_registration_url() . "'>" . __('Register', 'watupro') . "</a></b>"; } echo "</p>"; } else { // logged in but no rights to access if (!WatuPRO::$output_sent) { echo "<p>" . __('You are not allowed to access this exam at the moment.', 'watupro') . "</p><!-- logged in but no rights to access-->"; } } return false; // can_access returned false } return true; }
<input type="hidden" name="customize-login" value="1" /> <?php } ?> <input type="hidden" name="testcookie" value="1" /> </p> </form> <?php if (!$interim_login) { ?> <p id="nav"> <?php if (!isset($_GET['checkemail']) || !in_array($_GET['checkemail'], array('confirm', 'newpass'))) { if (get_option('users_can_register')) { $registration_url = sprintf('<a href="%s">%s</a>', esc_url(wp_registration_url()), __('Register')); /** This filter is documented in wp-includes/general-template.php */ echo apply_filters('register', $registration_url) . ' | '; } ?> <a href="<?php echo esc_url(wp_lostpassword_url()); ?> "><?php _e('Lost your password?'); ?> </a> <?php } ?> </p>
</h1> <div class="text-center yellow-color box" style="font-size: 4em; font-weight: 300; line-height: 1em;"><?php echo empty($trav_options['welcome_txt']) ? __('Welcome to Travelo!', 'trav') : __($trav_options['welcome_txt'], 'trav'); ?> </div> <p class="light-blue-color block" style="font-size: 1.3333em;"> <?php _e('Register For This Site as a Business Owner', 'trav'); ?> </p> <?php the_content(); ?> <div class="col-sm-8 col-md-6 col-lg-5 no-float no-padding center-block"> <form name="registerform" class="login-form" action="<?php echo esc_url(wp_registration_url()); ?> " method="post"> <p id="reg_passmail"><?php _e('A password will be e-mailed to you.', 'trav'); ?> </p> <div class="form-group"> <input type="text" name="user_login" class="input-text input-large full-width" placeholder="<?php _e('User Name', 'trav'); ?> " value="" size="20"></label> </div> <div class="form-group"> <input type="text" name="user_email" class="input-text input-large full-width" placeholder="<?php _e('Email', 'trav');
/** * Display the Registration or Admin link. * * Display a link which allows the user to navigate to the registration page if * not logged in and registration is enabled or to the dashboard if logged in. * * @since 1.5.0 * * @param string $before Text to output before the link. Default `<li>`. * @param string $after Text to output after the link. Default `</li>`. * @param bool $echo Default to echo and not return the link. * @return string|void String when retrieving. */ function wp_register($before = '<li>', $after = '</li>', $echo = true) { if (!is_user_logged_in()) { if (get_option('users_can_register')) { $link = $before . '<a href="' . esc_url(wp_registration_url()) . '">' . __('Register') . '</a>' . $after; } else { $link = ''; } } else { $link = $before . '<a href="' . admin_url() . '">' . __('Site Admin') . '</a>' . $after; } /** * Filter the HTML link to the Registration or Admin page. * * Users are sent to the admin page if logged-in, or the registration page * if enabled and logged-out. * * @since 1.5.0 * * @param string $link The HTML code for the link to the Registration or Admin page. */ $link = apply_filters('register', $link); if ($echo) { echo $link; } else { return $link; } }
/** * 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; }
if (!defined('ABSPATH')) { exit; // Exit if accessed directly } wc_print_notices(); do_action('woocommerce_before_cart'); ?> <div class="cart-login-or-register row"> <div class="login 2u"><a href="<?php echo wp_login_url(get_permalink()); ?> " title="Login">Log in</a></div> <div class="register 2u"> <a href="<?php echo wp_registration_url(); ?> ">Register</a> </div> <div class="8u"><p>Please register your royalty card to correct royalty points.</p></div> </div> <form action="<?php echo esc_url(WC()->cart->get_cart_url()); ?> " method="post"> <?php do_action('woocommerce_before_cart_table'); ?>
function sunshine_add_to_cart_form() { global $post, $sunshine; do_action('sunshine_before_add_to_cart_form'); $disable_products = get_post_meta(SunshineFrontend::$current_gallery->ID, 'sunshine_gallery_disable_products', true); $disable_products = get_post_meta(SunshineFrontend::$current_gallery->ID, 'sunshine_gallery_disable_products', true); $hide_add_to_cart = false; if ($sunshine->options['add_to_cart_require_account'] && !is_user_logged_in()) { echo '<p>' . sprintf(__('You must first <a href="%s">login</a> or <a href="%s">register</a> before you can add pictures to your cart. This allows us to track your favorites and items in your cart when you return.', 'sunshine'), wp_login_url(sunshine_current_url(false)), wp_registration_url() . '&redirect_to=' . sunshine_current_url(false)) . '</p>'; return; } elseif (sunshine_is_gallery_expired()) { echo '<p>' . __('This gallery this image belongs to has expired.', 'sunshine') . '</p>'; return; } if (!$disable_products && !$hide_add_to_cart && !$sunshine->options['proofing']) { ?> <form method="post" action=""> <ul id="sunshine-add-to-cart"> <?php $price_level = get_post_meta(SunshineFrontend::$current_gallery->ID, 'sunshine_gallery_price_level', true); $product_categories = get_terms('sunshine-product-category', 'orderby=slug&order=ASC'); foreach ($product_categories as $product_category) { $args = array('post_type' => 'sunshine-product', 'orderby' => 'menu_order', 'order' => 'ASC', 'nopaging' => true, 'tax_query' => array(array('taxonomy' => 'sunshine-product-category', 'field' => 'id', 'terms' => array($product_category->term_id))), 'meta_query' => array(array('key' => 'sunshine_product_price_' . $price_level, 'value' => '', 'compare' => '!='))); $args = apply_filters('sunshine_add_product_query_args', $args); $category_products = new WP_Query($args); if ($category_products->post_count > 0) { $available_products[$product_category->term_id] = $category_products; $available_categories[] = $product_category; } } if (count($available_categories) > 1) { ?> <li id="sunshine-product-category-select"> <h2><?php _e('Select Product Type', 'sunshine'); ?> </h2> <?php do_action('sunshine_before_product_category_select'); ?> <ul> <?php foreach ($available_categories as $product_category) { do_action('sunshine_before_product_category', $product_category); ?> <li><label><input type="radio" name="sunshine_product_category" value="<?php echo $product_category->term_id; ?> " /> <?php echo $product_category->name; ?> </label> <?php if ($product_category->description) { ?> <div class="sunshine-product-category-select-desc"><?php echo $product_category->description; ?> </div><?php } ?> </li> <?php do_action('sunshine_after_product_category', $product_category, $price_level); } ?> </ul> <?php do_action('sunshine_after_product_category_select', $price_level); ?> </li> <?php } ?> <?php if (!empty($available_products)) { ?> <li id="sunshine-product-select" style="display: <?php echo count($available_products) > 1 ? 'none' : 'block'; ?> "> <h2><?php _e('Select Product', 'sunshine'); ?> </h2> <?php foreach ($available_products as $category_id => $products) { ?> <div id="sunshine-product-category-<?php echo $category_id; ?> " class="sunshine-product-select" style="display: <?php echo count($available_products) > 1 ? 'none' : 'block'; ?> ;"> <?php if ($products->have_posts()) { ?> <ul> <?php while ($products->have_posts()) { $products->the_post(); ?> <li class="<?php sunshine_product_class(); ?> "> <?php do_action('sunshine_before_product', $post); ?> <label id="sunshine-product-<?php the_ID(); ?> "> <input type="radio" name="sunshine_product" value="<?php the_ID(); ?> "> <span class="sunshine-product-name"><?php the_title(); ?> </span> <span class="sunshine-product-divider">-</span> <span class="sunshine-product-price"><?php echo $sunshine->cart->get_product_price(get_the_ID(), $price_level); ?> </span> <?php if ($product_image_id = get_post_thumbnail_id()) { ?> <span class="sunshine-product-image-link"><a href="<?php echo wp_get_attachment_url($product_image_id); ?> " target="_blank"><?php _e('See Product', 'sunshine'); ?> </a></span> <?php } ?> </label> <?php if ($post->post_content) { ?> <span class="sunshine-product-desc-link"><a href="#sunshine-product-<?php the_ID(); ?> -desc" onclick="jQuery('#sunshine-product-<?php the_ID(); ?> -desc').toggle(); return false;"><?php _e('Details', 'sunshine'); ?> </a></span> <div class="sunshine-product-desc" id="sunshine-product-<?php the_ID(); ?> -desc"> <?php echo $post->post_content; ?> </div> <?php } ?> <?php do_action('sunshine_after_product', $post, $price_level); ?> </li> <?php } wp_reset_postdata(); ?> </ul> <?php } else { echo '<p>' . __('No products for this category', 'sunshine') . '</p>'; } ?> </div> <?php } // End foreach do_action('sunshine_after_product_select', $price_level); ?> </li> <?php } ?> <li id="sunshine-add-qty" style="display: none;"> <h2><?php _e('Quantity', 'sunshine'); ?> </h2> <input type="number" name="sunshine_qty" class="sunshine-qty" value="1" size="4" /> </li> <li id="sunshine-add-comments" style="display: none;"> <script> function limitText(limitField, limitCount, limitNum) { if (limitField.value.length > limitNum) { limitField.value = limitField.value.substring(0, limitNum); } else { limitCount.value = limitNum - limitField.value.length; } } </script> <h2><?php _e('Comments', 'sunshine'); ?> </h2> <textarea name="sunshine_comments" rows="5" cols="20" onKeyDown="limitText(this.form.sunshine_comments,this.form.countdown,200);" onKeyUp="limitText(this.form.sunshine_comments,this.form.countdown,200);"></textarea> <br /><?php echo sprintf(__('You have %s characters left', 'sunshine'), '<input readonly type="text" class="sunshine-countdown" name="countdown" size="3" value="200" />'); ?> </li> <li id="sunshine-add-button" style="display: none;"> <input type="submit" value="<?php _e('Add to Cart', 'sunshine'); ?> " class="sunshine-button" /> <input type="hidden" name="sunshine_add_to_cart" value="1" /> <input type="hidden" name="sunshine_image" value="<?php echo SunshineFrontend::$current_image->ID; ?> " /> </li> </ul> </form> <script type="text/javascript"> jQuery(document).ready(function() { jQuery('input[name="sunshine_product_category"]').change(function() { var product_category = jQuery(this).val(); jQuery('.sunshine-product-select').hide(); jQuery('#sunshine-product-select, #sunshine-product-category-'+product_category).show(); jQuery('#sunshine-add-qty, #sunshine-add-comments, #sunshine-add-button').hide(); }); jQuery('input[name="sunshine_product"]').change(function() { var product_id = jQuery(this).val(); jQuery('#sunshine-product-variations-'+product_id).toggle(); jQuery('#sunshine-add-qty, #sunshine-add-comments, #sunshine-add-button').show(); }); }); </script> <?php } do_action('sunshine_after_add_to_cart_form'); }
function rcl_get_register_user($errors) { global $wpdb, $rcl_options, $wp_errors; $wp_errors = new WP_Error(); if (count($errors->errors)) { $wp_errors = $errors; return $wp_errors; } $pass = sanitize_text_field($_POST['user_pass']); $email = $_POST['user_email']; $login = sanitize_user($_POST['user_login']); //print_r($_POST);exit; $ref = $_POST['redirect_to'] ? apply_filters('url_after_register_rcl', esc_url($_POST['redirect_to'])) : wp_registration_url(); $get_fields = get_option('custom_profile_field'); $requared = true; if ($get_fields) { foreach ((array) $get_fields as $custom_field) { $custom_field = apply_filters('chek_custom_field_regform', $custom_field); if (!$custom_field) { continue; } $slug = $custom_field['slug']; if ($custom_field['requared'] == 1 && $custom_field['register'] == 1) { if ($custom_field['type'] == 'checkbox') { $chek = explode('#', $custom_field['field_select']); $count_field = count($chek); for ($a = 0; $a < $count_field; $a++) { if (!isset($_POST[$slug][$a])) { $requared = false; } else { $requared = true; break; } } } else { if ($custom_field['type'] == 'file') { if (!isset($_FILES[$slug])) { $requared = false; } } else { if (!$_POST[$slug]) { $requared = false; } } } } } } if (!$pass || !$email || !$login || !$requared) { $wp_errors->add('rcl_register_empty', __('Fill in the required fields!', 'wp-recall')); return $wp_errors; } $wp_errors = apply_filters('rcl_registration_errors', $wp_errors, $login, $email); if ($wp_errors->errors) { return $wp_errors; } do_action('pre_register_user_rcl', $ref); //регистрируем юзера с указанными данными $userdata = array('user_pass' => $pass, 'user_login' => $login, 'user_email' => $email, 'display_name' => $fio); $user_id = rcl_insert_user($userdata); if ($user_id) { if ($rcl_options['login_form_recall'] == 2 || false !== strpos($ref, 'wp-login.php')) { //если форма ВП, то возвращаем на login с нужными GET-параметрами if ($rcl_options['confirm_register_recall'] == 1) { wp_safe_redirect('wp-login.php?checkemail=confirm'); } else { wp_safe_redirect('wp-login.php?checkemail=registered'); } } else { //иначе возвращаем на ту же страницу if ($rcl_options['confirm_register_recall'] == 1) { wp_redirect(rcl_format_url($ref) . 'action-rcl=register&success=confirm-email'); } else { wp_redirect(rcl_format_url($ref) . 'action-rcl=register&success=true'); } } exit; } }
<?php /** * Confirms that the activation key that is sent in an email after a user signs * up for a new blog matches the key for that user and then displays confirmation. * * @package WordPress */ define('WP_INSTALLING', true); /** Sets up the WordPress Environment. */ require dirname(__FILE__) . '/wp-load.php'; require dirname(__FILE__) . '/wp-blog-header.php'; if (!is_multisite()) { wp_redirect(wp_registration_url()); die; } if (is_object($wp_object_cache)) { $wp_object_cache->cache_enabled = false; } // Fix for page title $wp_query->is_404 = false; /** * Fires before the Site Activation page is loaded. * * @since 3.0.0 */ do_action('activate_header'); /** * Adds an action hook specific to this page that fires on wp_head * * @since MU
function pie_registration_url($url = false) { $this->pr_get_WP_Rewrite(); //$options = get_option("pie_register_2"); global $piereg_global_options; $options = $piereg_global_options; $pie_registration_url = get_permalink($options['alternate_register']); return $pie_registration_url ? $pie_registration_url : wp_registration_url(); }
echo '<li><a href="/"><i class="fa fa-home"></i><span>' . __('Home') . '</span></a></li>' . '<li><a href="' . $rcl_user_URL . '"><i class="fa fa-user"></i><span>' . __('Personal cabinet', 'wp-recall') . '</span></a></li>' . '<li><a href="' . esc_url(wp_logout_url('/')) . '"><i class="fa fa-sign-out"></i><span>' . __('Log Out') . '</span></a></li>'; } else { // если гость // и в настройках выбрано: if ($rcl_options['login_form_recall'] == 1) { // Каждая загружается отдельно $page_in_out = rcl_format_url(get_permalink($rcl_options['page_login_form_recall'])); // страница с формой входа-регистрации echo '<li><a href="/"><i class="fa fa-home"></i><span>' . __('Home') . '</span></a></li>' . '<li><a href="' . $page_in_out . 'action-rcl=register"><i class="fa fa-book"></i><span>' . __('Register') . '</span></a></li>' . '<li><a href="' . $page_in_out . 'action-rcl=login"><i class="fa fa-sign-in"></i><span>' . __('Entry', 'wp-recall') . '</span></a></li>'; } else { if ($rcl_options['login_form_recall'] == 2) { // Формы Wordpress echo '<li><a href="/"><i class="fa fa-home"></i><span>' . __('Home') . '</span></a></li>'; if (get_option('users_can_register')) { // если в настройках вордпресса разрешена регистрация - выводим echo '<li><a href="' . esc_url(wp_registration_url()) . '"><i class="fa fa-book"></i><span>' . __('Register') . '</span></a></li>'; } echo '<li><a href="' . esc_url(wp_login_url('/')) . '"><i class="fa fa-sign-in"></i><span>' . __('Entry', 'wp-recall') . '</span></a></li>'; } else { if ($rcl_options['login_form_recall'] == 3) { // Форма в виджете echo '<li><a href="/"><i class="fa fa-home"></i><span>' . __('Home') . '</span></a></li>'; } else { if (!$rcl_options['login_form_recall']) { // Всплывающая форма echo '<li><a href="/"><i class="fa fa-home"></i><span>' . __('Home') . '</span></a></li>' . '<li><a href="#" class="rcl-register"><i class="fa fa-book"></i><span>' . __('Register') . '</span></a></li>' . '<li><a href="#" class="rcl-login"><i class="fa fa-sign-in"></i><span>' . __('Entry', 'wp-recall') . '</span></a></li>'; } } } } }
/** * Redirects incoming links to the proper URL based on the site url. * * Search engines consider www.somedomain.com and somedomain.com to be two * different URLs when they both go to the same location. This SEO enhancement * prevents penalty for duplicate content by redirecting all incoming links to * one or the other. * * Prevents redirection for feeds, trackbacks, searches, comment popup, and * admin URLs. Does not redirect on non-pretty-permalink-supporting IIS 7+, * page/post previews, WP admin, Trackbacks, robots.txt, searches, or on POST * requests. * * Will also attempt to find the correct link when a user enters a URL that does * not exist based on exact WordPress query. Will instead try to parse the URL * or query in an attempt to figure the correct page to go to. * * @since 2.3.0 * * @global WP_Rewrite $wp_rewrite * @global bool $is_IIS * @global WP_Query $wp_query * @global wpdb $wpdb WordPress database abstraction object. * * @param string $requested_url Optional. The URL that was requested, used to * figure if redirect is needed. * @param bool $do_redirect Optional. Redirect to the new URL. * @return string|void The string of the URL, if redirect needed. */ function redirect_canonical($requested_url = null, $do_redirect = true) { global $wp_rewrite, $is_IIS, $wp_query, $wpdb, $wp; if (isset($_SERVER['REQUEST_METHOD']) && !in_array(strtoupper($_SERVER['REQUEST_METHOD']), array('GET', 'HEAD'))) { return; } // If we're not in wp-admin and the post has been published and preview nonce // is non-existent or invalid then no need for preview in query if (is_preview() && get_query_var('p') && 'publish' == get_post_status(get_query_var('p'))) { if (!isset($_GET['preview_id']) || !isset($_GET['preview_nonce']) || !wp_verify_nonce($_GET['preview_nonce'], 'post_preview_' . (int) $_GET['preview_id'])) { $wp_query->is_preview = false; } } if (is_trackback() || is_search() || is_comments_popup() || is_admin() || is_preview() || is_robots() || $is_IIS && !iis7_supports_permalinks()) { return; } if (!$requested_url && isset($_SERVER['HTTP_HOST'])) { // build the URL in the address bar $requested_url = is_ssl() ? 'https://' : 'http://'; $requested_url .= $_SERVER['HTTP_HOST']; $requested_url .= $_SERVER['REQUEST_URI']; } $original = @parse_url($requested_url); if (false === $original) { return; } $redirect = $original; $redirect_url = false; // Notice fixing if (!isset($redirect['path'])) { $redirect['path'] = ''; } if (!isset($redirect['query'])) { $redirect['query'] = ''; } // If the original URL ended with non-breaking spaces, they were almost // certainly inserted by accident. Let's remove them, so the reader doesn't // see a 404 error with no obvious cause. $redirect['path'] = preg_replace('|(%C2%A0)+$|i', '', $redirect['path']); // It's not a preview, so remove it from URL if (get_query_var('preview')) { $redirect['query'] = remove_query_arg('preview', $redirect['query']); } if (is_feed() && ($id = get_query_var('p'))) { if ($redirect_url = get_post_comments_feed_link($id, get_query_var('feed'))) { $redirect['query'] = _remove_qs_args_if_not_in_url($redirect['query'], array('p', 'page_id', 'attachment_id', 'pagename', 'name', 'post_type', 'feed'), $redirect_url); $redirect['path'] = parse_url($redirect_url, PHP_URL_PATH); } } if (is_singular() && 1 > $wp_query->post_count && ($id = get_query_var('p'))) { $vars = $wpdb->get_results($wpdb->prepare("SELECT post_type, post_parent FROM {$wpdb->posts} WHERE ID = %d", $id)); if (isset($vars[0]) && ($vars = $vars[0])) { if ('revision' == $vars->post_type && $vars->post_parent > 0) { $id = $vars->post_parent; } if ($redirect_url = get_permalink($id)) { $redirect['query'] = _remove_qs_args_if_not_in_url($redirect['query'], array('p', 'page_id', 'attachment_id', 'pagename', 'name', 'post_type'), $redirect_url); } } } // These tests give us a WP-generated permalink if (is_404()) { // Redirect ?page_id, ?p=, ?attachment_id= to their respective url's $id = max(get_query_var('p'), get_query_var('page_id'), get_query_var('attachment_id')); if ($id && ($redirect_post = get_post($id))) { $post_type_obj = get_post_type_object($redirect_post->post_type); if ($post_type_obj->public) { $redirect_url = get_permalink($redirect_post); $redirect['query'] = _remove_qs_args_if_not_in_url($redirect['query'], array('p', 'page_id', 'attachment_id', 'pagename', 'name', 'post_type'), $redirect_url); } } if (get_query_var('day') && get_query_var('monthnum') && get_query_var('year')) { $year = get_query_var('year'); $month = get_query_var('monthnum'); $day = get_query_var('day'); $date = sprintf('%04d-%02d-%02d', $year, $month, $day); if (!wp_checkdate($month, $day, $year, $date)) { $redirect_url = get_month_link($year, $month); $redirect['query'] = _remove_qs_args_if_not_in_url($redirect['query'], array('year', 'monthnum', 'day'), $redirect_url); } } elseif (get_query_var('monthnum') && get_query_var('year') && 12 < get_query_var('monthnum')) { $redirect_url = get_year_link(get_query_var('year')); $redirect['query'] = _remove_qs_args_if_not_in_url($redirect['query'], array('year', 'monthnum'), $redirect_url); } if (!$redirect_url) { if ($redirect_url = redirect_guess_404_permalink()) { $redirect['query'] = _remove_qs_args_if_not_in_url($redirect['query'], array('page', 'feed', 'p', 'page_id', 'attachment_id', 'pagename', 'name', 'post_type'), $redirect_url); } } if (get_query_var('page') && $wp_query->post && false !== strpos($wp_query->post->post_content, '<!--nextpage-->')) { $redirect['path'] = rtrim($redirect['path'], (int) get_query_var('page') . '/'); $redirect['query'] = remove_query_arg('page', $redirect['query']); $redirect_url = get_permalink($wp_query->post->ID); } } elseif (is_object($wp_rewrite) && $wp_rewrite->using_permalinks()) { // rewriting of old ?p=X, ?m=2004, ?m=200401, ?m=20040101 if (is_attachment() && !array_diff(array_keys($wp->query_vars), array('attachment', 'attachment_id')) && !$redirect_url) { if (!empty($_GET['attachment_id'])) { $redirect_url = get_attachment_link(get_query_var('attachment_id')); if ($redirect_url) { $redirect['query'] = remove_query_arg('attachment_id', $redirect['query']); } } else { $redirect_url = get_attachment_link(); } } elseif (is_single() && !empty($_GET['p']) && !$redirect_url) { if ($redirect_url = get_permalink(get_query_var('p'))) { $redirect['query'] = remove_query_arg(array('p', 'post_type'), $redirect['query']); } } elseif (is_single() && !empty($_GET['name']) && !$redirect_url) { if ($redirect_url = get_permalink($wp_query->get_queried_object_id())) { $redirect['query'] = remove_query_arg('name', $redirect['query']); } } elseif (is_page() && !empty($_GET['page_id']) && !$redirect_url) { if ($redirect_url = get_permalink(get_query_var('page_id'))) { $redirect['query'] = remove_query_arg('page_id', $redirect['query']); } } elseif (is_page() && !is_feed() && isset($wp_query->queried_object) && 'page' == get_option('show_on_front') && $wp_query->queried_object->ID == get_option('page_on_front') && !$redirect_url) { $redirect_url = home_url('/'); } elseif (is_home() && !empty($_GET['page_id']) && 'page' == get_option('show_on_front') && get_query_var('page_id') == get_option('page_for_posts') && !$redirect_url) { if ($redirect_url = get_permalink(get_option('page_for_posts'))) { $redirect['query'] = remove_query_arg('page_id', $redirect['query']); } } elseif (!empty($_GET['m']) && (is_year() || is_month() || is_day())) { $m = get_query_var('m'); switch (strlen($m)) { case 4: // Yearly $redirect_url = get_year_link($m); break; case 6: // Monthly $redirect_url = get_month_link(substr($m, 0, 4), substr($m, 4, 2)); break; case 8: // Daily $redirect_url = get_day_link(substr($m, 0, 4), substr($m, 4, 2), substr($m, 6, 2)); break; } if ($redirect_url) { $redirect['query'] = remove_query_arg('m', $redirect['query']); } // now moving on to non ?m=X year/month/day links } elseif (is_day() && get_query_var('year') && get_query_var('monthnum') && !empty($_GET['day'])) { if ($redirect_url = get_day_link(get_query_var('year'), get_query_var('monthnum'), get_query_var('day'))) { $redirect['query'] = remove_query_arg(array('year', 'monthnum', 'day'), $redirect['query']); } } elseif (is_month() && get_query_var('year') && !empty($_GET['monthnum'])) { if ($redirect_url = get_month_link(get_query_var('year'), get_query_var('monthnum'))) { $redirect['query'] = remove_query_arg(array('year', 'monthnum'), $redirect['query']); } } elseif (is_year() && !empty($_GET['year'])) { if ($redirect_url = get_year_link(get_query_var('year'))) { $redirect['query'] = remove_query_arg('year', $redirect['query']); } } elseif (is_author() && !empty($_GET['author']) && preg_match('|^[0-9]+$|', $_GET['author'])) { $author = get_userdata(get_query_var('author')); if (false !== $author && $wpdb->get_var($wpdb->prepare("SELECT ID FROM {$wpdb->posts} WHERE {$wpdb->posts}.post_author = %d AND {$wpdb->posts}.post_status = 'publish' LIMIT 1", $author->ID))) { if ($redirect_url = get_author_posts_url($author->ID, $author->user_nicename)) { $redirect['query'] = remove_query_arg('author', $redirect['query']); } } } elseif (is_category() || is_tag() || is_tax()) { // Terms (Tags/categories) $term_count = 0; foreach ($wp_query->tax_query->queried_terms as $tax_query) { $term_count += count($tax_query['terms']); } $obj = $wp_query->get_queried_object(); if ($term_count <= 1 && !empty($obj->term_id) && ($tax_url = get_term_link((int) $obj->term_id, $obj->taxonomy)) && !is_wp_error($tax_url)) { if (!empty($redirect['query'])) { // Strip taxonomy query vars off the url. $qv_remove = array('term', 'taxonomy'); if (is_category()) { $qv_remove[] = 'category_name'; $qv_remove[] = 'cat'; } elseif (is_tag()) { $qv_remove[] = 'tag'; $qv_remove[] = 'tag_id'; } else { // Custom taxonomies will have a custom query var, remove those too: $tax_obj = get_taxonomy($obj->taxonomy); if (false !== $tax_obj->query_var) { $qv_remove[] = $tax_obj->query_var; } } $rewrite_vars = array_diff(array_keys($wp_query->query), array_keys($_GET)); if (!array_diff($rewrite_vars, array_keys($_GET))) { // Check to see if all the Query vars are coming from the rewrite, none are set via $_GET $redirect['query'] = remove_query_arg($qv_remove, $redirect['query']); //Remove all of the per-tax qv's // Create the destination url for this taxonomy $tax_url = parse_url($tax_url); if (!empty($tax_url['query'])) { // Taxonomy accessible via ?taxonomy=..&term=.. or any custom qv.. parse_str($tax_url['query'], $query_vars); $redirect['query'] = add_query_arg($query_vars, $redirect['query']); } else { // Taxonomy is accessible via a "pretty-URL" $redirect['path'] = $tax_url['path']; } } else { // Some query vars are set via $_GET. Unset those from $_GET that exist via the rewrite foreach ($qv_remove as $_qv) { if (isset($rewrite_vars[$_qv])) { $redirect['query'] = remove_query_arg($_qv, $redirect['query']); } } } } } } elseif (is_single() && strpos($wp_rewrite->permalink_structure, '%category%') !== false && ($cat = get_query_var('category_name'))) { $category = get_category_by_path($cat); $post_terms = wp_get_object_terms($wp_query->get_queried_object_id(), 'category', array('fields' => 'tt_ids')); if (!$category || is_wp_error($category) || !is_wp_error($post_terms) && !empty($post_terms) && !in_array($category->term_taxonomy_id, $post_terms)) { $redirect_url = get_permalink($wp_query->get_queried_object_id()); } } // Post Paging if (is_singular() && !is_front_page() && get_query_var('page')) { if (!$redirect_url) { $redirect_url = get_permalink(get_queried_object_id()); } $redirect_url = trailingslashit($redirect_url) . user_trailingslashit(get_query_var('page'), 'single_paged'); $redirect['query'] = remove_query_arg('page', $redirect['query']); } // paging and feeds if (get_query_var('paged') || is_feed() || get_query_var('cpage')) { while (preg_match("#/{$wp_rewrite->pagination_base}/?[0-9]+?(/+)?\$#", $redirect['path']) || preg_match('#/(comments/?)?(feed|rss|rdf|atom|rss2)(/+)?$#', $redirect['path']) || preg_match("#/{$wp_rewrite->comments_pagination_base}-[0-9]+(/+)?\$#", $redirect['path'])) { // Strip off paging and feed $redirect['path'] = preg_replace("#/{$wp_rewrite->pagination_base}/?[0-9]+?(/+)?\$#", '/', $redirect['path']); // strip off any existing paging $redirect['path'] = preg_replace('#/(comments/?)?(feed|rss2?|rdf|atom)(/+|$)#', '/', $redirect['path']); // strip off feed endings $redirect['path'] = preg_replace("#/{$wp_rewrite->comments_pagination_base}-[0-9]+?(/+)?\$#", '/', $redirect['path']); // strip off any existing comment paging } $addl_path = ''; if (is_feed() && in_array(get_query_var('feed'), $wp_rewrite->feeds)) { $addl_path = !empty($addl_path) ? trailingslashit($addl_path) : ''; if (!is_singular() && get_query_var('withcomments')) { $addl_path .= 'comments/'; } if ('rss' == get_default_feed() && 'feed' == get_query_var('feed') || 'rss' == get_query_var('feed')) { $addl_path .= user_trailingslashit('feed/' . (get_default_feed() == 'rss2' ? '' : 'rss2'), 'feed'); } else { $addl_path .= user_trailingslashit('feed/' . (get_default_feed() == get_query_var('feed') || 'feed' == get_query_var('feed') ? '' : get_query_var('feed')), 'feed'); } $redirect['query'] = remove_query_arg('feed', $redirect['query']); } elseif (is_feed() && 'old' == get_query_var('feed')) { $old_feed_files = array('wp-atom.php' => 'atom', 'wp-commentsrss2.php' => 'comments_rss2', 'wp-feed.php' => get_default_feed(), 'wp-rdf.php' => 'rdf', 'wp-rss.php' => 'rss2', 'wp-rss2.php' => 'rss2'); if (isset($old_feed_files[basename($redirect['path'])])) { $redirect_url = get_feed_link($old_feed_files[basename($redirect['path'])]); wp_redirect($redirect_url, 301); die; } } if (get_query_var('paged') > 0) { $paged = get_query_var('paged'); $redirect['query'] = remove_query_arg('paged', $redirect['query']); if (!is_feed()) { if ($paged > 1 && !is_single()) { $addl_path = (!empty($addl_path) ? trailingslashit($addl_path) : '') . user_trailingslashit("{$wp_rewrite->pagination_base}/{$paged}", 'paged'); } elseif (!is_single()) { $addl_path = !empty($addl_path) ? trailingslashit($addl_path) : ''; } } elseif ($paged > 1) { $redirect['query'] = add_query_arg('paged', $paged, $redirect['query']); } } if (get_option('page_comments') && ('newest' == get_option('default_comments_page') && get_query_var('cpage') > 0 || 'newest' != get_option('default_comments_page') && get_query_var('cpage') > 1)) { $addl_path = (!empty($addl_path) ? trailingslashit($addl_path) : '') . user_trailingslashit($wp_rewrite->comments_pagination_base . '-' . get_query_var('cpage'), 'commentpaged'); $redirect['query'] = remove_query_arg('cpage', $redirect['query']); } $redirect['path'] = user_trailingslashit(preg_replace('|/' . preg_quote($wp_rewrite->index, '|') . '/?$|', '/', $redirect['path'])); // strip off trailing /index.php/ if (!empty($addl_path) && $wp_rewrite->using_index_permalinks() && strpos($redirect['path'], '/' . $wp_rewrite->index . '/') === false) { $redirect['path'] = trailingslashit($redirect['path']) . $wp_rewrite->index . '/'; } if (!empty($addl_path)) { $redirect['path'] = trailingslashit($redirect['path']) . $addl_path; } $redirect_url = $redirect['scheme'] . '://' . $redirect['host'] . $redirect['path']; } if ('wp-register.php' == basename($redirect['path'])) { if (is_multisite()) { /** This filter is documented in wp-login.php */ $redirect_url = apply_filters('wp_signup_location', network_site_url('wp-signup.php')); } else { $redirect_url = wp_registration_url(); } wp_redirect($redirect_url, 301); die; } } // tack on any additional query vars $redirect['query'] = preg_replace('#^\\??&*?#', '', $redirect['query']); if ($redirect_url && !empty($redirect['query'])) { parse_str($redirect['query'], $_parsed_query); $redirect = @parse_url($redirect_url); if (!empty($_parsed_query['name']) && !empty($redirect['query'])) { parse_str($redirect['query'], $_parsed_redirect_query); if (empty($_parsed_redirect_query['name'])) { unset($_parsed_query['name']); } } $_parsed_query = rawurlencode_deep($_parsed_query); $redirect_url = add_query_arg($_parsed_query, $redirect_url); } if ($redirect_url) { $redirect = @parse_url($redirect_url); } // www.example.com vs example.com $user_home = @parse_url(home_url()); if (!empty($user_home['host'])) { $redirect['host'] = $user_home['host']; } if (empty($user_home['path'])) { $user_home['path'] = '/'; } // Handle ports if (!empty($user_home['port'])) { $redirect['port'] = $user_home['port']; } else { unset($redirect['port']); } // trailing /index.php $redirect['path'] = preg_replace('|/' . preg_quote($wp_rewrite->index, '|') . '/*?$|', '/', $redirect['path']); // Remove trailing spaces from the path $redirect['path'] = preg_replace('#(%20| )+$#', '', $redirect['path']); if (!empty($redirect['query'])) { // Remove trailing spaces from certain terminating query string args $redirect['query'] = preg_replace('#((p|page_id|cat|tag)=[^&]*?)(%20| )+$#', '$1', $redirect['query']); // Clean up empty query strings $redirect['query'] = trim(preg_replace('#(^|&)(p|page_id|cat|tag)=?(&|$)#', '&', $redirect['query']), '&'); // Redirect obsolete feeds $redirect['query'] = preg_replace('#(^|&)feed=rss(&|$)#', '$1feed=rss2$2', $redirect['query']); // Remove redundant leading ampersands $redirect['query'] = preg_replace('#^\\??&*?#', '', $redirect['query']); } // strip /index.php/ when we're not using PATHINFO permalinks if (!$wp_rewrite->using_index_permalinks()) { $redirect['path'] = str_replace('/' . $wp_rewrite->index . '/', '/', $redirect['path']); } // trailing slashes if (is_object($wp_rewrite) && $wp_rewrite->using_permalinks() && !is_404() && (!is_front_page() || is_front_page() && get_query_var('paged') > 1)) { $user_ts_type = ''; if (get_query_var('paged') > 0) { $user_ts_type = 'paged'; } else { foreach (array('single', 'category', 'page', 'day', 'month', 'year', 'home') as $type) { $func = 'is_' . $type; if (call_user_func($func)) { $user_ts_type = $type; break; } } } $redirect['path'] = user_trailingslashit($redirect['path'], $user_ts_type); } elseif (is_front_page()) { $redirect['path'] = trailingslashit($redirect['path']); } // Strip multiple slashes out of the URL if (strpos($redirect['path'], '//') > -1) { $redirect['path'] = preg_replace('|/+|', '/', $redirect['path']); } // Always trailing slash the Front Page URL if (trailingslashit($redirect['path']) == trailingslashit($user_home['path'])) { $redirect['path'] = trailingslashit($redirect['path']); } // Ignore differences in host capitalization, as this can lead to infinite redirects // Only redirect no-www <=> yes-www if (strtolower($original['host']) == strtolower($redirect['host']) || strtolower($original['host']) != 'www.' . strtolower($redirect['host']) && 'www.' . strtolower($original['host']) != strtolower($redirect['host'])) { $redirect['host'] = $original['host']; } $compare_original = array($original['host'], $original['path']); if (!empty($original['port'])) { $compare_original[] = $original['port']; } if (!empty($original['query'])) { $compare_original[] = $original['query']; } $compare_redirect = array($redirect['host'], $redirect['path']); if (!empty($redirect['port'])) { $compare_redirect[] = $redirect['port']; } if (!empty($redirect['query'])) { $compare_redirect[] = $redirect['query']; } if ($compare_original !== $compare_redirect) { $redirect_url = $redirect['scheme'] . '://' . $redirect['host']; if (!empty($redirect['port'])) { $redirect_url .= ':' . $redirect['port']; } $redirect_url .= $redirect['path']; if (!empty($redirect['query'])) { $redirect_url .= '?' . $redirect['query']; } } if (!$redirect_url || $redirect_url == $requested_url) { return; } // Hex encoded octets are case-insensitive. if (false !== strpos($requested_url, '%')) { if (!function_exists('lowercase_octets')) { function lowercase_octets($matches) { return strtolower($matches[0]); } } $requested_url = preg_replace_callback('|%[a-fA-F0-9][a-fA-F0-9]|', 'lowercase_octets', $requested_url); } /** * Filter the canonical redirect URL. * * Returning false to this filter will cancel the redirect. * * @since 2.3.0 * * @param string $redirect_url The redirect URL. * @param string $requested_url The requested URL. */ $redirect_url = apply_filters('redirect_canonical', $redirect_url, $requested_url); // yes, again -- in case the filter aborted the request if (!$redirect_url || $redirect_url == $requested_url) { return; } if ($do_redirect) { // protect against chained redirects if (!redirect_canonical($redirect_url, false)) { wp_redirect($redirect_url, 301); exit; } else { // Debug // die("1: $redirect_url<br />2: " . redirect_canonical( $redirect_url, false ) ); return; } } else { return $redirect_url; } }