本文整理汇总了PHP中Theme_My_Login类的典型用法代码示例。如果您正苦于以下问题:PHP Theme_My_Login类的具体用法?PHP Theme_My_Login怎么用?PHP Theme_My_Login使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Theme_My_Login类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: activate
/**
* Activates the module
*
* Callback for "tml_activate_themed-profiles/themed-profiles.php" hook in method Theme_My_Login_Modules_Admin::activate_module()
*
* @see Theme_My_Login_Modules_Admin::activate_module()
* @since 6.0
* @access public
*/
public function activate()
{
if (!($page_id = Theme_My_Login::get_page_id('profile'))) {
$page_id = wp_insert_post(array('post_title' => __('Your Profile'), 'post_status' => 'publish', 'post_type' => 'page', 'post_content' => '[theme-my-login]', 'comment_status' => 'closed', 'ping_status' => 'closed'));
update_post_meta($page_id, '_tml_action', 'profile');
}
}
示例2: widget
/**
* 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);
}
示例3: login_form
/**
* 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()
{
if (!empty($_REQUEST['redirect_to'])) {
$referer = wp_unslash($_REQUEST['redirect_to']);
} elseif (wp_get_original_referer()) {
$referer = wp_get_original_referer();
} else {
$referer = Theme_My_Login::is_tml_page() ? wp_get_referer() : wp_unslash($_SERVER['REQUEST_URI']);
}
echo '<input type="hidden" name="_wp_original_http_referer" value="' . esc_attr($referer) . '" />';
}
示例4: wp_setup_nav_menu_item
/**
* Hide Profile link if user is not logged in
*
* Callback for "wp_setup_nav_menu_item" hook in wp_setup_nav_menu_item()
*
* @see wp_setup_nav_menu_item()
* @since 6.4
* @access public
*
* @param object $menu_item The menu item
* @return object The (possibly) modified menu item
*/
public function wp_setup_nav_menu_item($menu_item)
{
if (is_admin()) {
return $menu_item;
}
if ('page' != $menu_item->object) {
return $menu_item;
}
// User is not logged in
if (!is_user_logged_in()) {
// Hide Profile
if (Theme_My_Login::is_tml_page('profile', $menu_item->object_id)) {
$menu_item->_invalid = true;
}
}
return $menu_item;
}
示例5: get_redirect_url
/**
* Returns the proper redirect URL according to action
*
* @since 6.0
* @access public
*
* @param string $action The action
* @return string The redirect URL
*/
function get_redirect_url($action = '')
{
if (empty($action)) {
$action = $this->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_current_url('checkemail=confirm'));
break;
case 'register':
$url = apply_filters('registration_redirect', !empty($redirect_to) ? $redirect_to : Theme_My_Login::get_current_url('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);
}
示例6: site_url
/**
* Changes links from "profile.php" to themed profile page
*
* Callback for "site_url" hook
*
* @see site_url()
* @since 6.0
* @access public
*
* @param string $url The generated link
* @param string $path The specified path
* @param string $orig_scheme The original connection scheme
* @return string The filtered link
*/
public function site_url($url, $path, $orig_scheme = '')
{
global $current_user, $pagenow;
if ('profile.php' != $pagenow && strpos($url, 'profile.php') !== false) {
$user_role = reset($current_user->roles);
if (is_multisite() && empty($user_role)) {
$user_role = 'subscriber';
}
if ($user_role && !$this->get_option(array($user_role, 'theme_profile'))) {
return $url;
}
$parsed_url = parse_url($url);
$url = Theme_My_Login::get_page_link('profile');
if (isset($parsed_url['query'])) {
$url = add_query_arg(array_map('rawurlencode', wp_parse_args($parsed_url['query'])), $url);
}
}
return $url;
}
示例7: wp_setup_nav_menu_item
/**
* Adds CSS class to TML pages
*
* @since 6.3
* @access public
*
* @param object $menu_item Nav menu item
* @return object Nav menu item
*/
public function wp_setup_nav_menu_item($menu_item)
{
if ('tml_page' == $menu_item->object && Theme_My_Login::is_tml_page('', $menu_item->object_id)) {
if (!is_user_logged_in()) {
$menu_item->classes[] = 'tml_ajax_link';
}
}
return $menu_item;
}
示例8: install
/**
* Installs TML
*
* @since 6.0
* @access public
*/
public function install()
{
global $wpdb;
// Current version
$version = $this->get_option('version', Theme_My_Login::version);
// Check if legacy page exists
if ($page_id = $this->get_option('page_id')) {
$page = get_post($page_id);
} else {
$page = get_page_by_title('Login');
}
// 4.4 upgrade
if (version_compare($version, '4.4', '<')) {
remove_role('denied');
}
// 6.0 upgrade
if (version_compare($version, '6.0', '<')) {
// Replace shortcode
if ($page) {
$page->post_content = str_replace('[theme-my-login-page]', '[theme-my-login]', $page->post_content);
wp_update_post($page);
}
}
// 6.3 upgrade
if (version_compare($version, '6.3.3', '<')) {
// Delete obsolete options
$this->delete_option('page_id');
$this->delete_option('show_page');
$this->delete_option('initial_nag');
$this->delete_option('permalinks');
$this->delete_option('flush_rules');
// Move options to their own rows
foreach ($this->get_options() as $key => $value) {
if (in_array($key, array('active_modules'))) {
continue;
}
if (!is_array($value)) {
continue;
}
update_option("theme_my_login_{$key}", $value);
$this->delete_option($key);
}
// Maybe create login page?
if ($page) {
// Make sure the page is not in the trash
if ('trash' == $page->post_status) {
wp_untrash_post($page->ID);
}
update_post_meta($page->ID, '_tml_action', 'login');
}
}
// 6.3.7 upgrade
if (version_compare($version, '6.3.7', '<')) {
// Convert TML pages to regular pages
$wpdb->update($wpdb->posts, array('post_type' => 'page'), array('post_type' => 'tml_page'));
// Get rid of stale rewrite rules
flush_rewrite_rules(false);
}
// 6.4 upgrade
if (version_compare($version, '6.4', '<')) {
// Convert e-mail login option
if ($this->get_option('email_login')) {
$this->set_option('login_type', 'both');
}
$this->delete_option('email_login');
}
// Setup default pages
foreach (Theme_My_Login::default_pages() as $action => $title) {
if (!($page_id = Theme_My_Login::get_page_id($action))) {
$page_id = wp_insert_post(array('post_title' => $title, 'post_name' => $action, 'post_status' => 'publish', 'post_type' => 'page', 'post_content' => '[theme-my-login]', 'comment_status' => 'closed', 'ping_status' => 'closed'));
update_post_meta($page_id, '_tml_action', $action);
}
}
// Activate modules
foreach ($this->get_option('active_modules', array()) as $module) {
if (file_exists(WP_PLUGIN_DIR . '/theme-my-login/modules/' . $module)) {
include_once WP_PLUGIN_DIR . '/theme-my-login/modules/' . $module;
}
do_action('tml_activate_' . $module);
}
$this->set_option('version', Theme_My_Login::version);
$this->save_options();
}
示例9: network_site_url
/**
* 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;
}
示例10: user_approval_notification_message_filter
/**
* 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;
}
示例11: array_merge_recursive
/**
* Merges arrays recursively, replacing duplicate string keys
*
* @since 6.0
* @access public
*/
function array_merge_recursive()
{
$args = func_get_args();
$result = array_shift($args);
foreach ($args as $arg) {
foreach ($arg as $key => $value) {
// Renumber numeric keys as array_merge() does.
if (is_numeric($key)) {
if (!in_array($value, $result)) {
$result[] = $value;
}
} elseif (array_key_exists($key, $result) && is_array($result[$key]) && is_array($value)) {
$result[$key] = Theme_My_Login::array_merge_recursive($result[$key], $value);
} else {
$result[$key] = $value;
}
}
}
return $result;
}
示例12: send_activation
/**
* Handles "send_activation" action for login page
*
* Callback for "tml_request_send_activation" hook in method Theme_My_Login::the_request();
*
* @see Theme_My_Login::the_request();
* @since 6.0
* @access public
*/
function send_activation()
{
global $theme_my_login, $wpdb;
$login = isset($_GET['login']) ? trim($_GET['login']) : '';
if (!($user_id = $wpdb->get_var($wpdb->prepare("SELECT ID FROM {$wpdb->users} WHERE user_login = %s", $login)))) {
$redirect_to = Theme_My_Login::get_current_url('sendactivation=failed');
if (!empty($theme_my_login->request_instance)) {
$redirect_to = add_query_arg('instance', $theme_my_login->request_instance, $redirect_to);
}
wp_redirect($redirect_to);
exit;
}
$user = new WP_User($user_id);
if (in_array('pending', (array) $user->roles)) {
// Send activation e-mail
$this->new_user_activation_notification($user->ID);
// Now redirect them
$redirect_to = Theme_My_Login::get_current_url('sendactivation=sent');
wp_redirect($redirect_to);
exit;
}
}
示例13: cimy_uef_is_theme_my_login_register_page
/**
* @since 2.5.2
* @return true on Themed My Login - Themed Registration page
*/
function cimy_uef_is_theme_my_login_register_page()
{
// Theme My Login <= v6.2.x
if (!empty($GLOBALS['theme_my_login']) && $GLOBALS['theme_my_login']->is_login_page()) {
return true;
}
// Theme My Login >= v6.3.0
if (function_exists('Theme_My_Login') && Theme_My_Login::is_tml_page('register')) {
return true;
}
return false;
}
示例14: login_form
/**
* 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()
{
echo wp_original_referer_field(false, Theme_My_Login::is_tml_page() ? 'previous' : 'current') . "\n";
}
示例15: login_form
/**
* 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";
}