/** * Displays the widget * * @since 6.0 * @access public * * @param array $args Display arguments including before_title, after_title, before_widget, and after_widget. * @param array $instance The settings for the particular instance of the widget */ public function widget($args, $instance) { $theme_my_login = Theme_My_Login::get_object(); $instance = wp_parse_args($instance, array('default_action' => 'login', 'logged_in_widget' => true, 'logged_out_widget' => true, 'show_title' => true, 'show_log_link' => true, 'show_reg_link' => true, 'show_pass_link' => true, 'show_gravatar' => true, 'gravatar_size' => 50)); // Show if logged in? if (is_user_logged_in() && !$instance['logged_in_widget']) { return; } // Show if logged out? if (!is_user_logged_in() && !$instance['logged_out_widget']) { return; } $args = array_merge($args, $instance); echo $theme_my_login->shortcode($args); }
/** * Handles AJAX response * * @since 6.3 * @access public */ public function template_redirect() { $theme_my_login = Theme_My_Login::get_object(); if (Theme_My_Login::is_tml_page() && isset($_GET['ajax'])) { define('DOING_AJAX', true); $instance =& $theme_my_login->get_instance(); $instance->set_option('default_action', !empty($theme_my_login->request_action) ? $theme_my_login->request_action : 'login'); $instance->set_option('gravatar_size', 75); $instance->set_option('before_title', '<h2>'); $instance->set_option('after_title', '</h2>'); $data = $instance->display(); send_origin_headers(); @header('Content-Type: text/html; charset=' . get_option('blog_charset')); @header('X-Robots-Tag: noindex'); send_nosniff_header(); nocache_headers(); $x = new WP_Ajax_Response(array('what' => 'login', 'action' => $theme_my_login->request_action, 'data' => $theme_my_login->errors->get_error_code() ? $theme_my_login->errors : $data, 'supplemental' => array('html' => $data, 'success' => is_user_logged_in()))); $x->send(); exit; } }
/** * Outputs password fields to multisite signup user form * * Callback for "signup_extra_fields" hook in file "ms-signup-user-form.php", included by Theme_My_Login_Template::display() * * @see Theme_My_Login::display() * @since 6.1 * @access public */ public function ms_password_fields() { $theme_my_login = Theme_My_Login::get_object(); $template = $theme_my_login->get_active_instance(); $errors = array(); foreach ($theme_my_login->errors->get_error_codes() as $code) { if (in_array($code, array('empty_password', 'password_mismatch', 'password_length'))) { $errors[] = $theme_my_login->errors->get_error_message($code); } } ?> <label for="pass1<?php $template->the_instance(); ?> "><?php _e('Password:'******'theme-my-login'); ?> </label> <?php if (!empty($errors)) { ?> <p class="error"><?php echo implode('<br />', $errors); ?> </p> <?php } ?> <input autocomplete="off" name="pass1" id="pass1<?php $template->the_instance(); ?> " class="input" size="20" value="" type="password" /><br /> <span class="hint"><?php echo apply_filters('tml_password_hint', __('(Must be at least 6 characters.)', 'theme-my-login')); ?> </span> <label for="pass2<?php $template->the_instance(); ?> "><?php _e('Confirm Password:'******'theme-my-login'); ?> </label> <input autocomplete="off" name="pass2" id="pass2<?php $template->the_instance(); ?> " class="input" size="20" value="" type="password" /><br /> <span class="hint"><?php echo apply_filters('tml_password_confirm_hint', __('Confirm that you\'ve typed your password correctly.', 'theme-my-login')); ?> </span> <?php }
/** * Outputs profile form HTML * * Callback for "tml_display_profile" hook in method Theme_My_login_Template::display() * * @see Theme_My_Login_Template::display() * @since 6.0 * @access public * * @param object $template Reference to $theme_my_login_template object */ public function tml_display_profile(&$template) { global $current_user, $profileuser, $_wp_admin_css_colors, $wp_version; require_once ABSPATH . 'wp-admin/includes/user.php'; require_once ABSPATH . 'wp-admin/includes/misc.php'; if (isset($_GET['updated']) && 'true' == $_GET['updated']) { Theme_My_Login::get_object()->errors->add('profile_updated', __('Profile updated.'), 'message'); } $current_user = wp_get_current_user(); $profileuser = get_user_to_edit($current_user->ID); $user_role = reset($profileuser->roles); if (is_multisite() && empty($user_role)) { $user_role = 'subscriber'; } $_template = array(); // Allow template override via shortcode or template tag args if (!empty($template->options['profile_template'])) { $_template[] = $template->options['profile_template']; } // Allow role template overrid via shortcode or template tag args if (!empty($template->options["profile_template_{$user_role}"])) { $_template[] = $template->options["profile_template_{$user_role}"]; } // Role template $_template[] = "profile-form-{$user_role}.php"; // Default template $_template[] = 'profile-form.php'; // Load template $template->get_template($_template, true, compact('current_user', 'profileuser', 'user_role', '_wp_admin_css_colors', 'wp_version')); }
/** * Returns the proper redirect URL according to action * * @since 6.0 * @access public * * @param string $action The action * @return string The redirect URL */ public function get_redirect_url($action = '') { $theme_my_login = Theme_My_Login::get_object(); if (empty($action)) { $action = $this->get_option('default_action'); } $redirect_to = isset($_REQUEST['redirect_to']) ? $_REQUEST['redirect_to'] : ''; switch ($action) { case 'lostpassword': case 'retrievepassword': $url = apply_filters('lostpassword_redirect', !empty($redirect_to) ? $redirect_to : Theme_My_Login::get_page_link('login', 'checkemail=confirm')); break; case 'register': $url = apply_filters('registration_redirect', !empty($redirect_to) ? $redirect_to : Theme_My_Login::get_page_link('login', 'checkemail=registered')); break; case 'login': default: $url = apply_filters('login_redirect', !empty($redirect_to) ? $redirect_to : admin_url(), $redirect_to, null); } return apply_filters('tml_redirect_url', $url, $action); }
/** * Adds "_wp_original_referer" field to login form * * Callback for "login_form" hook in file "login-form.php", included by method Theme_My_Login_Template::display() * * @see Theme_My_Login_Template::display() * @since 6.0 * @access public */ public function login_form() { $template = Theme_My_Login::get_object()->get_active_instance(); echo wp_original_referer_field(false, $template->get_option('instance') ? 'current' : 'previous') . "\n"; }
/** * Changes the user approval e-mail message * * Callback for "user_approval_notification_message" hook in Theme_My_Login_User_Moderation_Admin::approve_user() * * @see Theme_My_Login_User_Moderation_Admin::approve_user() * @since 6.1 * @access public * * @param string $title The default message * @param string $new_pass The user's new password * @param int $user_id The user's ID * @return string The filtered message */ public function user_approval_notification_message_filter($message, $new_pass, $user_id) { $_message = $this->get_option(array('user_approval', 'message')); if (!empty($_message)) { $message = Theme_My_Login_Common::replace_vars($_message, $user_id, array('%loginurl%' => Theme_My_Login::get_object()->get_page_link('login'), '%user_pass%' => $new_pass)); } return $message; }
/** * Displays a TML instance * * @see Theme_My_Login::shortcode() for $args parameters * @since 6.0 * * @param string|array $args Template tag arguments */ function theme_my_login($args = '') { echo Theme_My_Login::get_object()->shortcode(wp_parse_args($args)); }
/** * Rewrites URL's created by network_site_url * * @since 6.3 * @access public * * @param string $url The URL * @param string $path The path specified * @param string $orig_scheme The current connection scheme (HTTP/HTTPS) * @return string The modified URL */ public function network_site_url($url, $path, $orig_scheme) { global $current_site; $url = $this->site_url($url, $path, $orig_scheme); switch_to_blog(1); $url = Theme_My_Login::get_object()->site_url($url, $path, $orig_scheme, $current_site->blog_id); restore_current_blog(); return $url; }
/** * Changes the user approval e-mail message * * Callback for "user_approval_notification_message" hook in Theme_My_Login_User_Moderation_Admin::approve_user() * * @see Theme_My_Login_User_Moderation_Admin::approve_user() * @since 6.1 * @access public * * @param string $title The default message * @param string $key The user's reset key * @param int $user_id The user's ID * @return string The filtered message */ public function user_approval_notification_message_filter($message, $key, $user_id) { $_message = $this->get_option(array('user_approval', 'message')); if (!empty($_message)) { $user = get_user_by('id', $user_id); $message = Theme_My_Login_Common::replace_vars($_message, $user_id, array('%loginurl%' => Theme_My_Login::get_object()->get_page_link('login'), '%reseturl%' => site_url("wp-login.php?action=rp&key={$key}&login=" . rawurlencode($user->user_login), 'login'))); } return $message; }