Created
May 29, 2018 05:04
-
-
Save AlbertoMontalesi/d8f1f5f4b311285e379efd497bb6d123 to your computer and use it in GitHub Desktop.
wordpress files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* thim functions and definitions | |
* | |
* @package thim | |
*/ | |
define( 'THIM_DIR', trailingslashit( get_template_directory() ) ); | |
define( 'THIM_URI', trailingslashit( get_template_directory_uri() ) ); | |
define( 'THIM_THEME_VERSION', '3.4.3' ); | |
/** | |
* Set the content width based on the theme's design and stylesheet. | |
*/ | |
if ( ! isset( $content_width ) ) { | |
$content_width = 640; /* pixels */ | |
} | |
/** | |
* Translation ready | |
*/ | |
load_theme_textdomain( 'eduma', get_template_directory() . '/languages' ); | |
if ( ! function_exists( 'thim_setup' ) ) : | |
/** | |
* Sets up theme defaults and registers support for various WordPress features. | |
* | |
* Note that this function is hooked into the after_setup_theme hook, which | |
* runs before the init hook. The init hook is too late for some features, such | |
* as indicating support for post thumbnails. | |
*/ | |
function thim_setup() { | |
/* | |
* Make theme available for translation. | |
* Translations can be filed in the /languages/ directory. | |
* If you're building a theme based on thim, use a find and replace | |
* to change 'eduma' to the name of your theme in all the template files | |
*/ | |
load_theme_textdomain( 'eduma', get_template_directory() . '/languages' ); | |
add_theme_support( 'title-tag' ); | |
// Add default posts and comments RSS feed links to head. | |
add_theme_support( 'automatic-feed-links' ); | |
/* | |
* Enable support for Post Thumbnails on posts and pages. | |
* | |
* @link http://codex.wordpress.org/Function_Reference/add_theme_support#Post_Thumbnails | |
*/ | |
add_theme_support( 'post-thumbnails' ); | |
// This theme uses wp_nav_menu() in one location. | |
register_nav_menus( array( | |
'primary' => esc_html__( 'Primary Menu', 'eduma' ), | |
) ); | |
/* | |
* Switch default core markup for search form, comment form, and comments | |
* to output valid HTML5. | |
*/ | |
add_theme_support( 'html5', array( | |
'search-form', | |
'comment-form', | |
'comment-list', | |
'gallery', | |
'caption', | |
) ); | |
/* Add WooCommerce support */ | |
add_theme_support( 'woocommerce' ); | |
add_theme_support( 'thim-core' ); | |
add_theme_support( 'eduma-demo-data' ); | |
/* | |
* Enable support for Post Formats. | |
* See http://codex.wordpress.org/Post_Formats | |
*/ | |
add_theme_support( 'post-formats', array( | |
'aside', | |
'image', | |
'video', | |
'quote', | |
'link', | |
'gallery', | |
'audio' | |
) ); | |
} | |
endif; // thim_setup | |
add_action( 'after_setup_theme', 'thim_setup' ); | |
/** | |
* Register widget area. | |
* | |
* @link http://codex.wordpress.org/Function_Reference/register_sidebar | |
*/ | |
if ( ! function_exists( 'thim_widgets_inits' ) ) { | |
function thim_widgets_inits() { | |
register_sidebar( array( | |
'name' => esc_html__( 'Sidebar', 'eduma' ), | |
'id' => 'sidebar', | |
'description' => esc_html__( 'Right Sidebar', 'eduma' ), | |
'before_widget' => '<aside id="%1$s" class="widget %2$s">', | |
'after_widget' => '</aside>', | |
'before_title' => '<h4 class="widget-title">', | |
'after_title' => '</h4>', | |
) ); | |
register_sidebar( array( | |
'name' => esc_html__( 'Toolbar', 'eduma' ), | |
'id' => 'toolbar', | |
'description' => esc_html__( 'Toolbar Header', 'eduma' ), | |
'before_widget' => '<aside id="%1$s" class="widget %2$s">', | |
'after_widget' => '</aside>', | |
'before_title' => '<h4 class="widget-title">', | |
'after_title' => '</h4>', | |
) ); | |
register_sidebar( array( | |
'name' => esc_html__( 'Menu Right', 'eduma' ), | |
'id' => 'menu_right', | |
'description' => esc_html__( 'Menu Right', 'eduma' ), | |
'before_widget' => '<li id="%1$s" class="widget %2$s">', | |
'after_widget' => '</li>', | |
'before_title' => '<h4>', | |
'after_title' => '</h4>', | |
) ); | |
register_sidebar( array( | |
'name' => esc_html__( 'Menu Top', 'eduma' ), | |
'id' => 'menu_top', | |
'description' => esc_html__( 'Menu top only display with header version 2', 'eduma' ), | |
'before_widget' => '<li id="%1$s" class="widget %2$s">', | |
'after_widget' => '</li>', | |
'before_title' => '<h4>', | |
'after_title' => '</h4>', | |
) ); | |
register_sidebar( array( | |
'name' => esc_html__( 'Footer Top', 'eduma' ), | |
'id' => 'footer_top', | |
'description' => esc_html__( 'Footer Top Sidebar', 'eduma' ), | |
'before_widget' => '<aside id="%1$s" class="widget %2$s footer_bottom_widget">', | |
'after_widget' => '</aside>', | |
'before_title' => '<h4 class="widget-title">', | |
'after_title' => '</h4>', | |
) ); | |
register_sidebar( array( | |
'name' => esc_html__( 'Footer', 'eduma' ), | |
'id' => 'footer', | |
'description' => esc_html__( 'Footer Sidebar', 'eduma' ), | |
'before_widget' => '<aside id="%1$s" class="widget %2$s footer_widget">', | |
'after_widget' => '</aside>', | |
'before_title' => '<h4 class="widget-title">', | |
'after_title' => '</h4>', | |
) ); | |
register_sidebar( array( | |
'name' => esc_html__( 'Footer Bottom', 'eduma' ), | |
'id' => 'footer_bottom', | |
'description' => esc_html__( 'Footer Bottom Sidebar', 'eduma' ), | |
'before_widget' => '<aside id="%1$s" class="widget %2$s footer_bottom_widget">', | |
'after_widget' => '</aside>', | |
'before_title' => '<h4 class="widget-title">', | |
'after_title' => '</h4>', | |
) ); | |
register_sidebar( array( | |
'name' => esc_html__( 'Copyright', 'eduma' ), | |
'id' => 'copyright', | |
'description' => esc_html__( 'Copyright', 'eduma' ), | |
'before_widget' => '<aside id="%1$s" class="widget %2$s">', | |
'after_widget' => '</aside>', | |
'before_title' => '<h4 class="widget-title">', | |
'after_title' => '</h4>', | |
) ); | |
if ( class_exists( 'WooCommerce' ) ) { | |
register_sidebar( array( | |
'name' => esc_html__( 'Sidebar Shop', 'eduma' ), | |
'id' => 'sidebar_shop', | |
'description' => esc_html__( 'Sidebar Shop', 'eduma' ), | |
'before_widget' => '<aside id="%1$s" class="widget %2$s">', | |
'after_widget' => '</aside>', | |
'before_title' => '<h4 class="widget-title">', | |
'after_title' => '</h4>', | |
) ); | |
} | |
if ( class_exists( 'LearnPress' ) ) { | |
register_sidebar( array( | |
'name' => esc_html__( 'Sidebar Courses', 'eduma' ), | |
'id' => 'sidebar_courses', | |
'description' => esc_html__( 'Sidebar Courses', 'eduma' ), | |
'before_widget' => '<aside id="%1$s" class="widget %2$s">', | |
'after_widget' => '</aside>', | |
'before_title' => '<h4 class="widget-title">', | |
'after_title' => '</h4>', | |
) ); | |
} | |
if ( class_exists( 'TP_Event' ) || class_exists( 'WPEMS' ) ) { | |
register_sidebar( array( | |
'name' => esc_html__( 'Sidebar Events', 'eduma' ), | |
'id' => 'sidebar_events', | |
'description' => esc_html__( 'Sidebar Events', 'eduma' ), | |
'before_widget' => '<aside id="%1$s" class="widget %2$s">', | |
'after_widget' => '</aside>', | |
'before_title' => '<h4 class="widget-title">', | |
'after_title' => '</h4>', | |
) ); | |
} | |
register_sidebar( array( | |
'name' => esc_html__( 'Header', 'eduma' ), | |
'id' => 'header', | |
'description' => esc_html__( 'Sidebar display on header version 3', 'eduma' ), | |
'before_widget' => '<aside id="%1$s" class="widget %2$s footer_bottom_widget">', | |
'after_widget' => '</aside>', | |
'before_title' => '<h4 class="widget-title">', | |
'after_title' => '</h4>', | |
) ); | |
/** | |
* Feature create sidebar in wp-admin. | |
* Do not remove this. | |
*/ | |
$sidebars = apply_filters( 'thim_core_list_sidebar', array() ); | |
if ( count( $sidebars ) > 0 ) { | |
foreach ( $sidebars as $sidebar ) { | |
$new_sidebar = array( | |
'name' => $sidebar['name'], | |
'id' => $sidebar['id'], | |
'description' => esc_html__( 'Custom widgets area.', 'eduma' ), | |
'before_widget' => '<aside id="%1$s" class="widget %2$s footer_bottom_widget">', | |
'after_widget' => '</aside>', | |
'before_title' => '<h4 class="widget-title">', | |
'after_title' => '</h4>', | |
); | |
register_sidebar( $new_sidebar ); | |
} | |
} | |
} | |
} | |
add_action( 'widgets_init', 'thim_widgets_inits' ); | |
/** | |
* Enqueue styles. | |
*/ | |
if ( ! function_exists( 'thim_styles' ) ) { | |
function thim_styles() { | |
if ( is_multisite() ) { | |
wp_enqueue_style( 'thim-style', THIM_URI . 'style.css', array(), THIM_THEME_VERSION ); | |
} else { | |
wp_enqueue_style( 'thim-style', get_stylesheet_uri(), array(), THIM_THEME_VERSION ); | |
} | |
if( get_theme_mod( 'thim_layout_content_page', 'normal' ) == 'new-1' ) { | |
wp_enqueue_style( 'thim-linearicons-font', THIM_URI . 'assets/css/linearicons.css', array(), THIM_THEME_VERSION ); | |
} | |
//Load style for page builder Visual Composer | |
$page_builder = get_theme_mod( 'thim_page_builder_chosen', '' ); | |
if ( $page_builder === 'visual_composer' ) { | |
wp_enqueue_style( 'thim-custom-vc', THIM_URI . 'assets/css/custom-vc.css', array(), THIM_THEME_VERSION ); | |
} | |
if ( get_theme_mod( 'thim_rtl_support', false ) ) { | |
wp_enqueue_style( 'thim-rtl', THIM_URI . 'rtl.css', array(), THIM_THEME_VERSION ); | |
} | |
wp_enqueue_style( 'thim-font-flaticon', THIM_URI . 'assets/css/flaticon.css', array(), THIM_THEME_VERSION ); | |
} | |
} | |
add_action( 'wp_enqueue_scripts', 'thim_styles', 1001 ); | |
/** | |
* Enqueue scripts. | |
*/ | |
if ( ! function_exists( 'thim_scripts' ) ) { | |
function thim_scripts() { | |
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) { | |
wp_enqueue_script( 'comment-reply' ); | |
} | |
// New script update from resca,sailing | |
wp_enqueue_script( 'thim-main', THIM_URI . 'assets/js/main.min.js', array( 'jquery' ), THIM_THEME_VERSION, true ); | |
if ( get_theme_mod( 'thim_smooth_scroll', true ) ) { | |
wp_enqueue_script( 'thim-smooth-scroll', THIM_URI . 'assets/js/smooth_scroll.min.js', array( 'jquery' ), THIM_THEME_VERSION, true ); | |
} | |
if ( thim_is_new_learnpress( '2.0' ) ) { | |
wp_enqueue_script( 'thim-custom-script', THIM_URI . 'assets/js/custom-script-v2.js', array( 'jquery' ), THIM_THEME_VERSION, true ); | |
} else if ( thim_is_new_learnpress( '1.0' ) ) { | |
wp_enqueue_script( 'thim-custom-script', THIM_URI . 'assets/js/custom-script-v1.js', array( 'jquery' ), THIM_THEME_VERSION, true ); | |
} else { | |
wp_enqueue_script( 'thim-custom-script', THIM_URI . 'assets/js/custom-script.js', array( 'jquery' ), THIM_THEME_VERSION, true ); | |
} | |
// Localize the script with new data | |
wp_localize_script( 'thim-custom-script', 'thim_js_translate', array( | |
'login' => esc_attr__( 'Username', 'eduma' ), | |
'password' => esc_attr__( 'Password', 'eduma' ), | |
'close' => esc_html__( 'Close', 'eduma' ), | |
) ); | |
if ( get_post_type() == 'portfolio' && ( is_category() || is_archive() || is_singular( 'portfolio' ) ) ) { | |
wp_enqueue_script( 'thim-portfolio-appear', THIM_URI . 'assets/js/jquery.appear.js', array( 'jquery' ), THIM_THEME_VERSION, true ); | |
wp_enqueue_script( 'thim-portfolio-widget', THIM_URI . 'assets/js/portfolio.js', array( | |
'jquery', | |
'thim-main' | |
), THIM_THEME_VERSION, true ); | |
} | |
wp_dequeue_script( 'framework-bootstrap' ); | |
wp_dequeue_script( 'thim-flexslider' ); | |
// Remove some scripts LearnPress | |
wp_dequeue_style( 'lpr-print-rate-css' ); | |
wp_dequeue_style( 'tipsy' ); | |
wp_dequeue_style( 'certificate' ); | |
wp_dequeue_style( 'fib' ); | |
wp_dequeue_style( 'sorting-choice' ); | |
wp_dequeue_style( 'course-wishlist-style' ); | |
wp_dequeue_script( 'tipsy' ); | |
wp_dequeue_script( 'lpr-print-rate-js' ); | |
wp_dequeue_script( 'course-wishlist-script' ); | |
wp_dequeue_script( 'course-review' ); | |
wp_dequeue_style( 'course-review' ); | |
wp_dequeue_style( 'learn-press-pmpro-style' ); | |
wp_dequeue_style( 'learn-press-jalerts' ); | |
if ( ! is_single( 'lpr_course' ) && ! is_single( 'lpr_quiz' ) ) { | |
wp_dequeue_script( 'sorting-choice' ); | |
wp_deregister_script( 'block-ui' ); | |
} | |
if ( is_front_page() ) { | |
wp_dequeue_script( 'webfont' ); | |
wp_dequeue_script( 'fabric-js' ); | |
wp_dequeue_script( 'certificate' ); | |
wp_dequeue_script( 'thim-event-countdown-plugin-js' ); | |
wp_dequeue_script( 'thim-event-countdown-js' ); | |
wp_dequeue_script( 'tp-event-auth' ); | |
if ( ! is_user_logged_in() ) { | |
wp_dequeue_style( 'dashicons' ); | |
} | |
} | |
//Plugin tp-event | |
wp_dequeue_style( 'thim-event' ); | |
wp_dequeue_style( 'tp-event-auth' ); | |
wp_dequeue_script( 'thim-event-owl-carousel-js' ); | |
wp_dequeue_script( 'tp-event-site-js-events.js' ); | |
wp_dequeue_style( 'thim-event-countdown-css' ); | |
wp_dequeue_style( 'thim-event-owl-carousel-css' ); | |
wp_dequeue_style( 'tp-event-fronted-css' ); | |
wp_dequeue_style( 'tp-event-owl-carousel-css' ); | |
wp_dequeue_style( 'tp-event-magnific-popup-css' ); | |
wp_dequeue_style( 'mo_openid_admin_settings_style' ); | |
wp_dequeue_style( 'mo_openid_admin_settings_phone_style' ); | |
//wp_dequeue_style( 'mo-wp-bootstrap-social' ); | |
wp_dequeue_style( 'mo-wp-bootstrap-main' ); | |
wp_dequeue_style( 'mo-wp-font-awesome' ); | |
//Woocommerce | |
wp_dequeue_script( 'jquery-cookie' ); | |
//Miniorange-login | |
wp_dequeue_script( 'js-cookie-script' ); | |
wp_dequeue_script( 'mo-social-login-script' ); | |
if ( ! thim_use_bbpress() ) { | |
wp_dequeue_style( 'bbp-default' ); | |
wp_dequeue_script( 'bbpress-editor' ); | |
} | |
//LearnPress 2.0 | |
wp_dequeue_style( 'owl_carousel_css' ); | |
wp_dequeue_style( 'learn-press-coming-soon-course' ); | |
wp_dequeue_script( 'learn-press-jquery-mb-coming-soon' ); | |
} | |
} | |
add_action( 'wp_enqueue_scripts', 'thim_scripts', 1000 ); | |
if ( class_exists( 'WooCommerce' ) ) { | |
add_action( 'wp_enqueue_scripts', 'thim_manage_woocommerce_styles', 9999 ); | |
} | |
if ( ! function_exists( 'thim_manage_woocommerce_styles' ) ) { | |
function thim_manage_woocommerce_styles() { | |
//remove generator meta tag | |
remove_action( 'wp_head', array( $GLOBALS['woocommerce'], 'generator' ) ); | |
if ( is_post_type_archive( 'product' ) ) { | |
wp_enqueue_script( 'wc-add-to-cart-variation' ); | |
} | |
} | |
} | |
function thim_custom_admin_scripts() { | |
wp_enqueue_script( 'thim-admin-custom-script', THIM_URI . 'assets/js/admin-custom-script.js', array( 'jquery' ), THIM_THEME_VERSION, true ); | |
wp_enqueue_style( 'thim-admin-theme-style', THIM_URI . 'assets/css/thim-admin.css', array(), THIM_THEME_VERSION ); | |
wp_enqueue_style( 'thim-admin-font-icon7', THIM_URI . 'assets/css/font-pe-icon-7.css', array(), THIM_THEME_VERSION ); | |
wp_enqueue_style( 'thim-admin-font-flaticon', THIM_URI . 'assets/css/flaticon.css', array(), THIM_THEME_VERSION ); | |
$thim_mod = get_theme_mods(); | |
$thim_page_builder_chosen = ! empty( $thim_mod['thim_page_builder_chosen'] ) ? $thim_mod['thim_page_builder_chosen'] : ''; | |
wp_localize_script( 'thim-admin-custom-script', 'thim_theme_mods', array( | |
'thim_page_builder_chosen' => $thim_page_builder_chosen, | |
) ); | |
} | |
add_action( 'admin_enqueue_scripts', 'thim_custom_admin_scripts' ); | |
// Require library | |
require THIM_DIR . 'inc/libs/theme-wrapper.php'; | |
require THIM_DIR . 'inc/libs/aq_resizer.php'; | |
// Custom functions. | |
require get_template_directory() . '/inc/custom-functions.php'; | |
/** | |
* Custom template tags for this theme. | |
*/ | |
require THIM_DIR . 'inc/template-tags.php'; | |
if ( class_exists( 'WooCommerce' ) ) { | |
require THIM_DIR . 'woocommerce/woocommerce.php'; | |
} | |
if ( class_exists( 'BuddyPress' ) ) { | |
require THIM_DIR . 'buddypress/bp-custom.php'; | |
} | |
//logo | |
require_once THIM_DIR . 'inc/header/logo.php'; | |
//custom logo mobile | |
require_once THIM_DIR . 'inc/header/logo-mobile.php'; | |
//Visual composer shortcodes | |
if ( class_exists( 'Vc_Manager' ) && thim_plugin_active( 'js_composer/js_composer.php' ) ) { | |
require THIM_DIR . 'vc-shortcodes/vc-shortcodes.php'; | |
} | |
// Remove references to SiteOrigin Premium | |
add_filter( 'siteorigin_premium_upgrade_teaser', '__return_false' ); | |
//For use thim-core | |
require_once THIM_DIR . 'inc/thim-core-function.php'; | |
require_once THIM_DIR . 'inc/upgrade.php'; | |
/** | |
* Testing | |
*/ | |
function xxx( $x ) { | |
echo '<pre>'; | |
if ( is_array( $x ) || is_object( $x ) ) { | |
print_r( $x ); | |
} else { | |
echo $x; | |
} | |
echo '</pre>'; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* The Header for our theme. | |
* | |
* Displays all of the <head> section and everything up till <div id="content"> | |
* | |
* @package thim | |
*/ | |
?><!DOCTYPE html> | |
<html itemscope itemtype="http://schema.org/WebPage" <?php language_attributes(); ?>> | |
<head> | |
<meta charset="<?php bloginfo( 'charset' ); ?>"> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
<link rel="profile" href="http://gmpg.org/xfn/11"> | |
<link rel="pingback" href="<?php esc_url( bloginfo( 'pingback_url' ) ); ?>"> | |
<?php wp_head(); ?> | |
</head> | |
<body <?php body_class(); ?> id="thim-body"> | |
<?php | |
$attributes = array(); | |
$doctype = 'html'; | |
if ( function_exists( 'is_rtl' ) && is_rtl() ) | |
$attributes[] = 'dir="rtl"'; | |
if ( $lang = get_bloginfo('language') ) { | |
if ( get_option('html_type') == 'text/html' || $doctype == 'html' ) | |
$attributes[] = "lang=\"$lang\""; | |
if ( get_option('html_type') != 'text/html' || $doctype == 'xhtml' ) | |
$attributes[] = "xml:lang=\"$lang\""; | |
} | |
?> | |
<?php do_action( 'thim_before_body' ); ?> | |
<div id="wrapper-container" class="wrapper-container"> | |
<div class="content-pusher"> | |
<header id="masthead" class="site-header affix-top<?php thim_header_class(); ?>"> | |
<?php | |
//Toolbar | |
if ( get_theme_mod( 'thim_toolbar_show', true ) ) { | |
get_template_part( 'inc/header/toolbar' ); | |
} | |
//Header style | |
if ( get_theme_mod( 'thim_header_style', 'header_v1' ) ) { | |
get_template_part( 'inc/header/' . get_theme_mod( 'thim_header_style', 'header_v1' ) ); | |
} | |
?> | |
</header> | |
<!-- Mobile Menu--> | |
<nav class="mobile-menu-container mobile-effect"> | |
<?php get_template_part( 'inc/header/menu-mobile' ); ?> | |
</nav> | |
<div id="main-content"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$class_archive = ''; | |
$archive_layout = get_theme_mod( 'thim_front_page_cate_display_layout' ); | |
$layout_type = !empty( $archive_layout ) ? 'grid' : ''; | |
if ( $layout_type == 'grid' ) { | |
$class_archive = ' blog-switch-layout blog-list'; | |
global $post, $wp_query; | |
if ( is_category() ) { | |
$total = get_queried_object(); | |
$total = $total->count; | |
} elseif ( !empty( $_REQUEST['s'] ) ) { | |
$total = $wp_query->found_posts; | |
} else { | |
$total = wp_count_posts( 'post' ); | |
$total = $total->publish; | |
} | |
if ( $total == 0 ) { | |
echo '<p class="message message-error">' . esc_html__( 'There are no available posts!', 'eduma' ) . '</p>'; | |
return; | |
} elseif ( $total == 1 ) { | |
$index = esc_html__( 'Showing only one result', 'eduma' ); | |
} else { | |
$courses_per_page = absint( get_option( 'posts_per_page' ) ); | |
$paged = get_query_var( 'paged' ) ? intval( get_query_var( 'paged' ) ) : 1; | |
$from = 1 + ( $paged - 1 ) * $courses_per_page; | |
$to = ( $paged * $courses_per_page > $total ) ? $total : $paged * $courses_per_page; | |
if ( $from == $to ) { | |
$index = sprintf( | |
esc_html__( 'Showing last post of %s results', 'eduma' ), | |
$total | |
); | |
} else { | |
$index = sprintf( | |
esc_html__( 'Showing %s-%s of %s results', 'eduma' ), | |
$from, | |
$to, | |
$total | |
); | |
} | |
} | |
} | |
if ( have_posts() ) :?> | |
<div id="blog-archive" class="blog-content<?php echo esc_attr( $class_archive ); ?>"> | |
<?php if ( $layout_type == 'grid' ): ?> | |
<div class="thim-blog-top switch-layout-container"> | |
<div class="switch-layout"> | |
<a href="#" class="list switchToGrid switch-active"><i class="fa fa-th-large"></i></a> | |
<a href="#" class="grid switchToList"><i class="fa fa-list-ul"></i></a> | |
</div> | |
<div class="post-index"><?php echo esc_html( $index ); ?></div> | |
</div> | |
<div class="row"> | |
<?php | |
/* Start the Loop */ | |
while ( have_posts() ) : the_post(); | |
get_template_part( 'content-grid' ); | |
endwhile; | |
?> | |
</div> | |
<?php else: ?> | |
<div class="row"> | |
<?php | |
/* Start the Loop */ | |
while ( have_posts() ) : the_post(); | |
get_template_part( 'content' ); | |
endwhile; | |
?> | |
</div> | |
<?php endif; ?> | |
</div> | |
<?php | |
thim_paging_nav(); | |
else : | |
get_template_part( 'content', 'none' ); | |
endif; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* WordPress User Page | |
* | |
* Handles authentication, registering, resetting passwords, forgot password, | |
* and other user handling. | |
* | |
* @package WordPress | |
*/ | |
/** Make sure that the WordPress bootstrap has run before continuing. */ | |
require( dirname(__FILE__) . '/wp-load.php' ); | |
// Redirect to https login if forced to use SSL | |
if ( force_ssl_admin() && ! is_ssl() ) { | |
if ( 0 === strpos($_SERVER['REQUEST_URI'], 'http') ) { | |
wp_safe_redirect( set_url_scheme( $_SERVER['REQUEST_URI'], 'https' ) ); | |
exit(); | |
} else { | |
wp_safe_redirect( 'https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] ); | |
exit(); | |
} | |
} | |
/** | |
* Output the login page header. | |
* | |
* @param string $title Optional. WordPress login Page title to display in the `<title>` element. | |
* Default 'Log In'. | |
* @param string $message Optional. Message to display in header. Default empty. | |
* @param WP_Error $wp_error Optional. The error to pass. Default empty. | |
*/ | |
function login_header( $title = 'Log In', $message = '', $wp_error = '' ) { | |
global $error, $interim_login, $action; | |
// Don't index any of these forms | |
add_action( 'login_head', 'wp_no_robots' ); | |
add_action( 'login_head', 'wp_login_viewport_meta' ); | |
if ( empty($wp_error) ) | |
$wp_error = new WP_Error(); | |
// Shake it! | |
$shake_error_codes = array( 'empty_password', 'empty_email', 'invalid_email', 'invalidcombo', 'empty_username', 'invalid_username', 'incorrect_password' ); | |
/** | |
* Filters the error codes array for shaking the login form. | |
* | |
* @since 3.0.0 | |
* | |
* @param array $shake_error_codes Error codes that shake the login form. | |
*/ | |
$shake_error_codes = apply_filters( 'shake_error_codes', $shake_error_codes ); | |
if ( $shake_error_codes && $wp_error->get_error_code() && in_array( $wp_error->get_error_code(), $shake_error_codes ) ) | |
add_action( 'login_head', 'wp_shake_js', 12 ); | |
$login_title = get_bloginfo( 'name', 'display' ); | |
/* translators: Login screen title. 1: Login screen name, 2: Network or site name */ | |
$login_title = sprintf( __( '%1$s ‹ %2$s — WordPress' ), $title, $login_title ); | |
/** | |
* Filters the title tag content for login page. | |
* | |
* @since 4.9.0 | |
* | |
* @param string $login_title The page title, with extra context added. | |
* @param string $title The original page title. | |
*/ | |
$login_title = apply_filters( 'login_title', $login_title, $title ); | |
?><!DOCTYPE html> | |
<!--[if IE 8]> | |
<html xmlns="http://www.w3.org/1999/xhtml" class="ie8" <?php language_attributes(); ?>> | |
<![endif]--> | |
<!--[if !(IE 8) ]><!--> | |
<html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes(); ?>> | |
<!--<![endif]--> | |
<head> | |
<meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php bloginfo('charset'); ?>" /> | |
<title><?php echo $login_title; ?></title> | |
<?php | |
wp_enqueue_style( 'login' ); | |
/* | |
* Remove all stored post data on logging out. | |
* This could be added by add_action('login_head'...) like wp_shake_js(), | |
* but maybe better if it's not removable by plugins | |
*/ | |
if ( 'loggedout' == $wp_error->get_error_code() ) { | |
?> | |
<script>if("sessionStorage" in window){try{for(var key in sessionStorage){if(key.indexOf("wp-autosave-")!=-1){sessionStorage.removeItem(key)}}}catch(e){}};</script> | |
<?php | |
} | |
/** | |
* Enqueue scripts and styles for the login page. | |
* | |
* @since 3.1.0 | |
*/ | |
do_action( 'login_enqueue_scripts' ); | |
/** | |
* Fires in the login page header after scripts are enqueued. | |
* | |
* @since 2.1.0 | |
*/ | |
do_action( 'login_head' ); | |
if ( is_multisite() ) { | |
$login_header_url = network_home_url(); | |
$login_header_title = get_network()->site_name; | |
} else { | |
$login_header_url = __( 'https://wordpress.org/' ); | |
$login_header_title = __( 'Powered by WordPress' ); | |
} | |
/** | |
* Filters link URL of the header logo above login form. | |
* | |
* @since 2.1.0 | |
* | |
* @param string $login_header_url Login header logo URL. | |
*/ | |
$login_header_url = apply_filters( 'login_headerurl', $login_header_url ); | |
/** | |
* Filters the title attribute of the header logo above login form. | |
* | |
* @since 2.1.0 | |
* | |
* @param string $login_header_title Login header logo title attribute. | |
*/ | |
$login_header_title = apply_filters( 'login_headertitle', $login_header_title ); | |
/* | |
* To match the URL/title set above, Multisite sites have the blog name, | |
* while single sites get the header title. | |
*/ | |
if ( is_multisite() ) { | |
$login_header_text = get_bloginfo( 'name', 'display' ); | |
} else { | |
$login_header_text = $login_header_title; | |
} | |
$classes = array( 'login-action-' . $action, 'wp-core-ui' ); | |
if ( is_rtl() ) | |
$classes[] = 'rtl'; | |
if ( $interim_login ) { | |
$classes[] = 'interim-login'; | |
?> | |
<style type="text/css">html{background-color: transparent;}</style> | |
<?php | |
if ( 'success' === $interim_login ) | |
$classes[] = 'interim-login-success'; | |
} | |
$classes[] =' locale-' . sanitize_html_class( strtolower( str_replace( '_', '-', get_locale() ) ) ); | |
/** | |
* Filters the login page body classes. | |
* | |
* @since 3.5.0 | |
* | |
* @param array $classes An array of body classes. | |
* @param string $action The action that brought the visitor to the login page. | |
*/ | |
$classes = apply_filters( 'login_body_class', $classes, $action ); | |
?> | |
</head> | |
<body class="login <?php echo esc_attr( implode( ' ', $classes ) ); ?>"> | |
<?php | |
/** | |
* Fires in the login page header after the body tag is opened. | |
* | |
* @since 4.6.0 | |
*/ | |
do_action( 'login_header' ); | |
?> | |
<div id="login"> | |
<h1><a href="<?php echo esc_url( $login_header_url ); ?>" title="<?php echo esc_attr( $login_header_title ); ?>" tabindex="-1"><?php echo $login_header_text; ?></a></h1> | |
<?php | |
unset( $login_header_url, $login_header_title ); | |
/** | |
* Filters the message to display above the login form. | |
* | |
* @since 2.1.0 | |
* | |
* @param string $message Login message text. | |
*/ | |
$message = apply_filters( 'login_message', $message ); | |
if ( !empty( $message ) ) | |
echo $message . "\n"; | |
// In case a plugin uses $error rather than the $wp_errors object | |
if ( !empty( $error ) ) { | |
$wp_error->add('error', $error); | |
unset($error); | |
} | |
if ( $wp_error->get_error_code() ) { | |
$errors = ''; | |
$messages = ''; | |
foreach ( $wp_error->get_error_codes() as $code ) { | |
$severity = $wp_error->get_error_data( $code ); | |
foreach ( $wp_error->get_error_messages( $code ) as $error_message ) { | |
if ( 'message' == $severity ) | |
$messages .= ' ' . $error_message . "<br />\n"; | |
else | |
$errors .= ' ' . $error_message . "<br />\n"; | |
} | |
} | |
if ( ! empty( $errors ) ) { | |
/** | |
* Filters the error messages displayed above the login form. | |
* | |
* @since 2.1.0 | |
* | |
* @param string $errors Login error message. | |
*/ | |
echo '<div id="login_error">' . apply_filters( 'login_errors', $errors ) . "</div>\n"; | |
} | |
if ( ! empty( $messages ) ) { | |
/** | |
* Filters instructional messages displayed above the login form. | |
* | |
* @since 2.5.0 | |
* | |
* @param string $messages Login messages. | |
*/ | |
echo '<p class="message">' . apply_filters( 'login_messages', $messages ) . "</p>\n"; | |
} | |
} | |
} // End of login_header() | |
/** | |
* Outputs the footer for the login page. | |
* | |
* @param string $input_id Which input to auto-focus | |
*/ | |
function login_footer($input_id = '') { | |
global $interim_login; | |
// Don't allow interim logins to navigate away from the page. | |
if ( ! $interim_login ): ?> | |
<p id="backtoblog"><a href="<?php echo esc_url( home_url( '/' ) ); ?>"><?php | |
/* translators: %s: site title */ | |
printf( _x( '← Back to %s', 'site' ), get_bloginfo( 'title', 'display' ) ); | |
?></a></p> | |
<?php the_privacy_policy_link( '<div class="privacy-policy-page-link">', '</div>' ); ?> | |
<?php endif; ?> | |
</div> | |
<?php if ( !empty($input_id) ) : ?> | |
<script type="text/javascript"> | |
try{document.getElementById('<?php echo $input_id; ?>').focus();}catch(e){} | |
if(typeof wpOnload=='function')wpOnload(); | |
</script> | |
<?php endif; ?> | |
<?php | |
/** | |
* Fires in the login page footer. | |
* | |
* @since 3.1.0 | |
*/ | |
do_action( 'login_footer' ); ?> | |
<div class="clear"></div> | |
</body> | |
</html> | |
<?php | |
} | |
/** | |
* @since 3.0.0 | |
*/ | |
function wp_shake_js() { | |
?> | |
<script type="text/javascript"> | |
addLoadEvent = function(func){if(typeof jQuery!="undefined")jQuery(document).ready(func);else if(typeof wpOnload!='function'){wpOnload=func;}else{var oldonload=wpOnload;wpOnload=function(){oldonload();func();}}}; | |
function s(id,pos){g(id).left=pos+'px';} | |
function g(id){return document.getElementById(id).style;} | |
function shake(id,a,d){c=a.shift();s(id,c);if(a.length>0){setTimeout(function(){shake(id,a,d);},d);}else{try{g(id).position='static';wp_attempt_focus();}catch(e){}}} | |
addLoadEvent(function(){ var p=new Array(15,30,15,0,-15,-30,-15,0);p=p.concat(p.concat(p));var i=document.forms[0].id;g(i).position='relative';shake(i,p,20);}); | |
</script> | |
<?php | |
} | |
/** | |
* @since 3.7.0 | |
*/ | |
function wp_login_viewport_meta() { | |
?> | |
<meta name="viewport" content="width=device-width" /> | |
<?php | |
} | |
/** | |
* Handles sending password retrieval email to user. | |
* | |
* @return bool|WP_Error True: when finish. WP_Error on error | |
*/ | |
function retrieve_password() { | |
$errors = new WP_Error(); | |
if ( empty( $_POST['user_login'] ) || ! is_string( $_POST['user_login'] ) ) { | |
$errors->add('empty_username', __('<strong>ERROR</strong>: Enter a username or email address.')); | |
} elseif ( strpos( $_POST['user_login'], '@' ) ) { | |
$user_data = get_user_by( 'email', trim( wp_unslash( $_POST['user_login'] ) ) ); | |
if ( empty( $user_data ) ) | |
$errors->add('invalid_email', __('<strong>ERROR</strong>: There is no user registered with that email address.')); | |
} else { | |
$login = trim($_POST['user_login']); | |
$user_data = get_user_by('login', $login); | |
} | |
/** | |
* Fires before errors are returned from a password reset request. | |
* | |
* @since 2.1.0 | |
* @since 4.4.0 Added the `$errors` parameter. | |
* | |
* @param WP_Error $errors A WP_Error object containing any errors generated | |
* by using invalid credentials. | |
*/ | |
do_action( 'lostpassword_post', $errors ); | |
if ( $errors->get_error_code() ) | |
return $errors; | |
if ( !$user_data ) { | |
$errors->add('invalidcombo', __('<strong>ERROR</strong>: Invalid username or email.')); | |
return $errors; | |
} | |
// Redefining user_login ensures we return the right case in the email. | |
$user_login = $user_data->user_login; | |
$user_email = $user_data->user_email; | |
$key = get_password_reset_key( $user_data ); | |
if ( is_wp_error( $key ) ) { | |
return $key; | |
} | |
if ( is_multisite() ) { | |
$site_name = get_network()->site_name; | |
} else { | |
/* | |
* The blogname option is escaped with esc_html on the way into the database | |
* in sanitize_option we want to reverse this for the plain text arena of emails. | |
*/ | |
$site_name = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ); | |
} | |
$message = __( 'Someone has requested a password reset for the following account:' ) . "\r\n\r\n"; | |
/* translators: %s: site name */ | |
$message .= sprintf( __( 'Site Name: %s'), $site_name ) . "\r\n\r\n"; | |
/* translators: %s: user login */ | |
$message .= sprintf( __( 'Username: %s'), $user_login ) . "\r\n\r\n"; | |
$message .= __( 'If this was a mistake, just ignore this email and nothing will happen.' ) . "\r\n\r\n"; | |
$message .= __( 'To reset your password, visit the following address:' ) . "\r\n\r\n"; | |
$message .= '<' . network_site_url( "wp-login.php?action=rp&key=$key&login=" . rawurlencode( $user_login ), 'login' ) . ">\r\n"; | |
/* translators: Password reset email subject. %s: Site name */ | |
$title = sprintf( __( '[%s] Password Reset' ), $site_name ); | |
/** | |
* Filters the subject of the password reset email. | |
* | |
* @since 2.8.0 | |
* @since 4.4.0 Added the `$user_login` and `$user_data` parameters. | |
* | |
* @param string $title Default email title. | |
* @param string $user_login The username for the user. | |
* @param WP_User $user_data WP_User object. | |
*/ | |
$title = apply_filters( 'retrieve_password_title', $title, $user_login, $user_data ); | |
/** | |
* Filters the message body of the password reset mail. | |
* | |
* If the filtered message is empty, the password reset email will not be sent. | |
* | |
* @since 2.8.0 | |
* @since 4.1.0 Added `$user_login` and `$user_data` parameters. | |
* | |
* @param string $message Default mail message. | |
* @param string $key The activation key. | |
* @param string $user_login The username for the user. | |
* @param WP_User $user_data WP_User object. | |
*/ | |
$message = apply_filters( 'retrieve_password_message', $message, $key, $user_login, $user_data ); | |
if ( $message && !wp_mail( $user_email, wp_specialchars_decode( $title ), $message ) ) | |
wp_die( __('The email could not be sent.') . "<br />\n" . __('Possible reason: your host may have disabled the mail() function.') ); | |
return true; | |
} | |
// | |
// Main | |
// | |
$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : 'login'; | |
$errors = new WP_Error(); | |
if ( isset($_GET['key']) ) | |
$action = 'resetpass'; | |
// validate action so as to default to the login screen | |
if ( !in_array( $action, array( 'postpass', 'logout', 'lostpassword', 'retrievepassword', 'resetpass', 'rp', 'register', 'login', 'confirmaction' ), true ) && false === has_filter( 'login_form_' . $action ) ) | |
$action = 'login'; | |
nocache_headers(); | |
header('Content-Type: '.get_bloginfo('html_type').'; charset='.get_bloginfo('charset')); | |
if ( defined( 'RELOCATE' ) && RELOCATE ) { // Move flag is set | |
if ( isset( $_SERVER['PATH_INFO'] ) && ($_SERVER['PATH_INFO'] != $_SERVER['PHP_SELF']) ) | |
$_SERVER['PHP_SELF'] = str_replace( $_SERVER['PATH_INFO'], '', $_SERVER['PHP_SELF'] ); | |
$url = dirname( set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'] ) ); | |
if ( $url != get_option( 'siteurl' ) ) | |
update_option( 'siteurl', $url ); | |
} | |
//Set a cookie now to see if they are supported by the browser. | |
$secure = ( 'https' === parse_url( wp_login_url(), PHP_URL_SCHEME ) ); | |
setcookie( TEST_COOKIE, 'WP Cookie check', 0, COOKIEPATH, COOKIE_DOMAIN, $secure ); | |
if ( SITECOOKIEPATH != COOKIEPATH ) | |
setcookie( TEST_COOKIE, 'WP Cookie check', 0, SITECOOKIEPATH, COOKIE_DOMAIN, $secure ); | |
$lang = ! empty( $_GET['wp_lang'] ) ? sanitize_text_field( $_GET['wp_lang'] ) : ''; | |
$switched_locale = switch_to_locale( $lang ); | |
/** | |
* Fires when the login form is initialized. | |
* | |
* @since 3.2.0 | |
*/ | |
do_action( 'login_init' ); | |
/** | |
* Fires before a specified login form action. | |
* | |
* The dynamic portion of the hook name, `$action`, refers to the action | |
* that brought the visitor to the login form. Actions include 'postpass', | |
* 'logout', 'lostpassword', etc. | |
* | |
* @since 2.8.0 | |
*/ | |
do_action( "login_form_{$action}" ); | |
$http_post = ('POST' == $_SERVER['REQUEST_METHOD']); | |
$interim_login = isset($_REQUEST['interim-login']); | |
/** | |
* Filters the separator used between login form navigation links. | |
* | |
* @since 4.9.0 | |
* | |
* @param string $login_link_separator The separator used between login form navigation links. | |
*/ | |
$login_link_separator = apply_filters( 'login_link_separator', ' | ' ); | |
switch ($action) { | |
case 'postpass' : | |
if ( ! array_key_exists( 'post_password', $_POST ) ) { | |
wp_safe_redirect( wp_get_referer() ); | |
exit(); | |
} | |
require_once ABSPATH . WPINC . '/class-phpass.php'; | |
$hasher = new PasswordHash( 8, true ); | |
/** | |
* Filters the life span of the post password cookie. | |
* | |
* By default, the cookie expires 10 days from creation. To turn this | |
* into a session cookie, return 0. | |
* | |
* @since 3.7.0 | |
* | |
* @param int $expires The expiry time, as passed to setcookie(). | |
*/ | |
$expire = apply_filters( 'post_password_expires', time() + 10 * DAY_IN_SECONDS ); | |
$referer = wp_get_referer(); | |
if ( $referer ) { | |
$secure = ( 'https' === parse_url( $referer, PHP_URL_SCHEME ) ); | |
} else { | |
$secure = false; | |
} | |
setcookie( 'wp-postpass_' . COOKIEHASH, $hasher->HashPassword( wp_unslash( $_POST['post_password'] ) ), $expire, COOKIEPATH, COOKIE_DOMAIN, $secure ); | |
if ( $switched_locale ) { | |
restore_previous_locale(); | |
} | |
wp_safe_redirect( wp_get_referer() ); | |
exit(); | |
case 'logout' : | |
check_admin_referer('log-out'); | |
$user = wp_get_current_user(); | |
wp_logout(); | |
if ( ! empty( $_REQUEST['redirect_to'] ) ) { | |
$redirect_to = $requested_redirect_to = $_REQUEST['redirect_to']; | |
} else { | |
$redirect_to = 'wp-login.php?loggedout=true'; | |
$requested_redirect_to = ''; | |
} | |
if ( $switched_locale ) { | |
restore_previous_locale(); | |
} | |
/** | |
* Filters the log out redirect URL. | |
* | |
* @since 4.2.0 | |
* | |
* @param string $redirect_to The redirect destination URL. | |
* @param string $requested_redirect_to The requested redirect destination URL passed as a parameter. | |
* @param WP_User $user The WP_User object for the user that's logging out. | |
*/ | |
$redirect_to = apply_filters( 'logout_redirect', $redirect_to, $requested_redirect_to, $user ); | |
wp_safe_redirect( $redirect_to ); | |
exit(); | |
case 'lostpassword' : | |
case 'retrievepassword' : | |
if ( $http_post ) { | |
$errors = retrieve_password(); | |
if ( !is_wp_error($errors) ) { | |
$redirect_to = !empty( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : 'wp-login.php?checkemail=confirm'; | |
wp_safe_redirect( $redirect_to ); | |
exit(); | |
} | |
} | |
if ( isset( $_GET['error'] ) ) { | |
if ( 'invalidkey' == $_GET['error'] ) { | |
$errors->add( 'invalidkey', __( 'Your password reset link appears to be invalid. Please request a new link below.' ) ); | |
} elseif ( 'expiredkey' == $_GET['error'] ) { | |
$errors->add( 'expiredkey', __( 'Your password reset link has expired. Please request a new link below.' ) ); | |
} | |
} | |
$lostpassword_redirect = ! empty( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : ''; | |
/** | |
* Filters the URL redirected to after submitting the lostpassword/retrievepassword form. | |
* | |
* @since 3.0.0 | |
* | |
* @param string $lostpassword_redirect The redirect destination URL. | |
*/ | |
$redirect_to = apply_filters( 'lostpassword_redirect', $lostpassword_redirect ); | |
/** | |
* Fires before the lost password form. | |
* | |
* @since 1.5.1 | |
*/ | |
do_action( 'lost_password' ); | |
login_header(__('Lost Password'), '<p class="message">' . __('Please enter your username or email address. You will receive a link to create a new password via email.') . '</p>', $errors); | |
$user_login = ''; | |
if ( isset( $_POST['user_login'] ) && is_string( $_POST['user_login'] ) ) { | |
$user_login = wp_unslash( $_POST['user_login'] ); | |
} | |
?> | |
<form name="lostpasswordform" id="lostpasswordform" action="<?php echo esc_url( network_site_url( 'wp-login.php?action=lostpassword', 'login_post' ) ); ?>" method="post"> | |
<p> | |
<label for="user_login" ><?php _e( 'Username or Email Address' ); ?><br /> | |
<input type="text" name="user_login" id="user_login" class="input" value="<?php echo esc_attr($user_login); ?>" size="20" /></label> | |
</p> | |
<?php | |
/** | |
* Fires inside the lostpassword form tags, before the hidden fields. | |
* | |
* @since 2.1.0 | |
*/ | |
do_action( 'lostpassword_form' ); ?> | |
<input type="hidden" name="redirect_to" value="<?php echo esc_attr( $redirect_to ); ?>" /> | |
<p class="submit"><input type="submit" name="wp-submit" id="wp-submit" class="button button-primary button-large" value="<?php esc_attr_e('Get New Password'); ?>" /></p> | |
</form> | |
<p id="nav"> | |
<a href="<?php echo esc_url( wp_login_url() ); ?>"><?php _e('Log in') ?></a> | |
<?php | |
if ( get_option( 'users_can_register' ) ) : | |
$registration_url = sprintf( '<a href="%s">%s</a>', esc_url( wp_registration_url() ), __( 'Register' ) ); | |
echo esc_html( $login_link_separator ); | |
/** This filter is documented in wp-includes/general-template.php */ | |
echo apply_filters( 'register', $registration_url ); | |
endif; | |
?> | |
</p> | |
<?php | |
login_footer('user_login'); | |
if ( $switched_locale ) { | |
restore_previous_locale(); | |
} | |
break; | |
case 'resetpass' : | |
case 'rp' : | |
list( $rp_path ) = explode( '?', wp_unslash( $_SERVER['REQUEST_URI'] ) ); | |
$rp_cookie = 'wp-resetpass-' . COOKIEHASH; | |
if ( isset( $_GET['key'] ) ) { | |
$value = sprintf( '%s:%s', wp_unslash( $_GET['login'] ), wp_unslash( $_GET['key'] ) ); | |
setcookie( $rp_cookie, $value, 0, $rp_path, COOKIE_DOMAIN, is_ssl(), true ); | |
wp_safe_redirect( remove_query_arg( array( 'key', 'login' ) ) ); | |
exit; | |
} | |
if ( isset( $_COOKIE[ $rp_cookie ] ) && 0 < strpos( $_COOKIE[ $rp_cookie ], ':' ) ) { | |
list( $rp_login, $rp_key ) = explode( ':', wp_unslash( $_COOKIE[ $rp_cookie ] ), 2 ); | |
$user = check_password_reset_key( $rp_key, $rp_login ); | |
if ( isset( $_POST['pass1'] ) && ! hash_equals( $rp_key, $_POST['rp_key'] ) ) { | |
$user = false; | |
} | |
} else { | |
$user = false; | |
} | |
if ( ! $user || is_wp_error( $user ) ) { | |
setcookie( $rp_cookie, ' ', time() - YEAR_IN_SECONDS, $rp_path, COOKIE_DOMAIN, is_ssl(), true ); | |
if ( $user && $user->get_error_code() === 'expired_key' ) | |
wp_redirect( site_url( 'wp-login.php?action=lostpassword&error=expiredkey' ) ); | |
else | |
wp_redirect( site_url( 'wp-login.php?action=lostpassword&error=invalidkey' ) ); | |
exit; | |
} | |
$errors = new WP_Error(); | |
if ( isset($_POST['pass1']) && $_POST['pass1'] != $_POST['pass2'] ) | |
$errors->add( 'password_reset_mismatch', __( 'The passwords do not match.' ) ); | |
/** | |
* Fires before the password reset procedure is validated. | |
* | |
* @since 3.5.0 | |
* | |
* @param object $errors WP Error object. | |
* @param WP_User|WP_Error $user WP_User object if the login and reset key match. WP_Error object otherwise. | |
*/ | |
do_action( 'validate_password_reset', $errors, $user ); | |
if ( ( ! $errors->get_error_code() ) && isset( $_POST['pass1'] ) && !empty( $_POST['pass1'] ) ) { | |
reset_password($user, $_POST['pass1']); | |
setcookie( $rp_cookie, ' ', time() - YEAR_IN_SECONDS, $rp_path, COOKIE_DOMAIN, is_ssl(), true ); | |
login_header( __( 'Password Reset' ), '<p class="message reset-pass">' . __( 'Your password has been reset.' ) . ' <a href="' . esc_url( wp_login_url() ) . '">' . __( 'Log in' ) . '</a></p>' ); | |
login_footer(); | |
exit; | |
} | |
wp_enqueue_script('utils'); | |
wp_enqueue_script('user-profile'); | |
login_header(__('Reset Password'), '<p class="message reset-pass">' . __('Enter your new password below.') . '</p>', $errors ); | |
?> | |
<form name="resetpassform" id="resetpassform" action="<?php echo esc_url( network_site_url( 'wp-login.php?action=resetpass', 'login_post' ) ); ?>" method="post" autocomplete="off"> | |
<input type="hidden" id="user_login" value="<?php echo esc_attr( $rp_login ); ?>" autocomplete="off" /> | |
<div class="user-pass1-wrap"> | |
<p> | |
<label for="pass1"><?php _e( 'New password' ) ?></label> | |
</p> | |
<div class="wp-pwd"> | |
<div class="password-input-wrapper"> | |
<input type="password" data-reveal="1" data-pw="<?php echo esc_attr( wp_generate_password( 16 ) ); ?>" name="pass1" id="pass1" class="input password-input" size="24" value="" autocomplete="off" aria-describedby="pass-strength-result" /> | |
<span class="button button-secondary wp-hide-pw hide-if-no-js"> | |
<span class="dashicons dashicons-hidden"></span> | |
</span> | |
</div> | |
<div id="pass-strength-result" class="hide-if-no-js" aria-live="polite"><?php _e( 'Strength indicator' ); ?></div> | |
</div> | |
<div class="pw-weak"> | |
<label> | |
<input type="checkbox" name="pw_weak" class="pw-checkbox" /> | |
<?php _e( 'Confirm use of weak password' ); ?> | |
</label> | |
</div> | |
</div> | |
<p class="user-pass2-wrap"> | |
<label for="pass2"><?php _e( 'Confirm new password' ) ?></label><br /> | |
<input type="password" name="pass2" id="pass2" class="input" size="20" value="" autocomplete="off" /> | |
</p> | |
<p class="description indicator-hint"><?php echo wp_get_password_hint(); ?></p> | |
<br class="clear" /> | |
<?php | |
/** | |
* Fires following the 'Strength indicator' meter in the user password reset form. | |
* | |
* @since 3.9.0 | |
* | |
* @param WP_User $user User object of the user whose password is being reset. | |
*/ | |
do_action( 'resetpass_form', $user ); | |
?> | |
<input type="hidden" name="rp_key" value="<?php echo esc_attr( $rp_key ); ?>" /> | |
<p class="submit"><input type="submit" name="wp-submit" id="wp-submit" class="button button-primary button-large" value="<?php esc_attr_e('Reset Password'); ?>" /></p> | |
</form> | |
<p id="nav"> | |
<a href="<?php echo esc_url( wp_login_url() ); ?>"><?php _e( 'Log in' ); ?></a> | |
<?php | |
if ( get_option( 'users_can_register' ) ) : | |
$registration_url = sprintf( '<a href="%s">%s</a>', esc_url( wp_registration_url() ), __( 'Register' ) ); | |
echo esc_html( $login_link_separator ); | |
/** This filter is documented in wp-includes/general-template.php */ | |
echo apply_filters( 'register', $registration_url ); | |
endif; | |
?> | |
</p> | |
<?php | |
login_footer('user_pass'); | |
if ( $switched_locale ) { | |
restore_previous_locale(); | |
} | |
break; | |
case 'register' : | |
if ( is_multisite() ) { | |
/** | |
* Filters the Multisite sign up URL. | |
* | |
* @since 3.0.0 | |
* | |
* @param string $sign_up_url The sign up URL. | |
*/ | |
wp_redirect( apply_filters( 'wp_signup_location', network_site_url( 'wp-signup.php' ) ) ); | |
exit; | |
} | |
if ( !get_option('users_can_register') ) { | |
wp_redirect( site_url('wp-login.php?registration=disabled') ); | |
exit(); | |
} | |
$user_login = ''; | |
$user_email = ''; | |
if ( $http_post ) { | |
if ( isset( $_POST['user_login'] ) && is_string( $_POST['user_login'] ) ) { | |
$user_login = $_POST['user_login']; | |
} | |
if ( isset( $_POST['user_email'] ) && is_string( $_POST['user_email'] ) ) { | |
$user_email = wp_unslash( $_POST['user_email'] ); | |
} | |
$errors = register_new_user($user_login, $user_email); | |
if ( !is_wp_error($errors) ) { | |
$redirect_to = !empty( $_POST['redirect_to'] ) ? $_POST['redirect_to'] : 'wp-login.php?checkemail=registered'; | |
wp_safe_redirect( $redirect_to ); | |
exit(); | |
} | |
} | |
$registration_redirect = ! empty( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : ''; | |
/** | |
* Filters the registration redirect URL. | |
* | |
* @since 3.0.0 | |
* | |
* @param string $registration_redirect The redirect destination URL. | |
*/ | |
$redirect_to = apply_filters( 'registration_redirect', $registration_redirect ); | |
login_header(__('Registration Form'), '<p class="message register">' . __('Register For This Site') . '</p>', $errors); | |
?> | |
<form name="registerform" id="registerform" action="<?php echo esc_url( site_url( 'wp-login.php?action=register', 'login_post' ) ); ?>" method="post" novalidate="novalidate"> | |
<p> | |
<label for="user_login"><?php _e('Username') ?><br /> | |
<input type="text" name="user_login" id="user_login" class="input" value="<?php echo esc_attr(wp_unslash($user_login)); ?>" size="20" /></label> | |
</p> | |
<p> | |
<label for="user_email"><?php _e('Email') ?><br /> | |
<input type="email" name="user_email" id="user_email" class="input" value="<?php echo esc_attr( wp_unslash( $user_email ) ); ?>" size="25" /></label> | |
</p> | |
<?php | |
/** | |
* Fires following the 'Email' field in the user registration form. | |
* | |
* @since 2.1.0 | |
*/ | |
do_action( 'register_form' ); | |
?> | |
<p id="reg_passmail"><?php _e( 'Registration confirmation will be emailed to you.' ); ?></p> | |
<br class="clear" /> | |
<input type="hidden" name="redirect_to" value="<?php echo esc_attr( $redirect_to ); ?>" /> | |
<p class="submit"><input type="submit" name="wp-submit" id="wp-submit" class="button button-primary button-large" value="<?php esc_attr_e('Register'); ?>" /></p> | |
</form> | |
<p id="nav"> | |
<a href="<?php echo esc_url( wp_login_url() ); ?>"><?php _e( 'Log in' ); ?></a> | |
<?php echo esc_html( $login_link_separator ); ?> | |
<a href="<?php echo esc_url( wp_lostpassword_url() ); ?>"><?php _e( 'Lost your password?' ); ?></a> | |
</p> | |
<?php | |
login_footer('user_login'); | |
if ( $switched_locale ) { | |
restore_previous_locale(); | |
} | |
break; | |
case 'confirmaction' : | |
if ( ! isset( $_GET['request_id'] ) ) { | |
wp_die( __( 'Invalid request.' ) ); | |
} | |
$request_id = (int) $_GET['request_id']; | |
if ( isset( $_GET['confirm_key'] ) ) { | |
$key = sanitize_text_field( wp_unslash( $_GET['confirm_key'] ) ); | |
$result = wp_validate_user_request_key( $request_id, $key ); | |
} else { | |
$result = new WP_Error( 'invalid_key', __( 'Invalid key' ) ); | |
} | |
if ( is_wp_error( $result ) ) { | |
wp_die( $result ); | |
} | |
/** | |
* Fires an action hook when the account action has been confirmed by the user. | |
* | |
* Using this you can assume the user has agreed to perform the action by | |
* clicking on the link in the confirmation email. | |
* | |
* After firing this action hook the page will redirect to wp-login a callback | |
* redirects or exits first. | |
* | |
* @param int $request_id Request ID. | |
*/ | |
do_action( 'user_request_action_confirmed', $request_id ); | |
$message = _wp_privacy_account_request_confirmed_message( $request_id ); | |
login_header( __( 'User action confirmed.' ), $message ); | |
login_footer(); | |
exit; | |
case 'login' : | |
default: | |
$secure_cookie = ''; | |
$customize_login = isset( $_REQUEST['customize-login'] ); | |
if ( $customize_login ) | |
wp_enqueue_script( 'customize-base' ); | |
// If the user wants ssl but the session is not ssl, force a secure cookie. | |
if ( !empty($_POST['log']) && !force_ssl_admin() ) { | |
$user_name = sanitize_user($_POST['log']); | |
$user = get_user_by( 'login', $user_name ); | |
if ( ! $user && strpos( $user_name, '@' ) ) { | |
$user = get_user_by( 'email', $user_name ); | |
} | |
if ( $user ) { | |
if ( get_user_option('use_ssl', $user->ID) ) { | |
$secure_cookie = true; | |
force_ssl_admin(true); | |
} | |
} | |
} | |
if ( isset( $_REQUEST['redirect_to'] ) ) { | |
$redirect_to = $_REQUEST['redirect_to']; | |
// Redirect to https if user wants ssl | |
if ( $secure_cookie && false !== strpos($redirect_to, 'wp-admin') ) | |
$redirect_to = preg_replace('|^http://|', 'https://', $redirect_to); | |
} else { | |
$redirect_to = admin_url(); | |
} | |
$reauth = empty($_REQUEST['reauth']) ? false : true; | |
$user = wp_signon( array(), $secure_cookie ); | |
if ( empty( $_COOKIE[ LOGGED_IN_COOKIE ] ) ) { | |
if ( headers_sent() ) { | |
/* translators: 1: Browser cookie documentation URL, 2: Support forums URL */ | |
$user = new WP_Error( 'test_cookie', sprintf( __( '<strong>ERROR</strong>: Cookies are blocked due to unexpected output. For help, please see <a href="%1$s">this documentation</a> or try the <a href="%2$s">support forums</a>.' ), | |
__( 'https://codex.wordpress.org/Cookies' ), __( 'https://wordpress.org/support/' ) ) ); | |
} elseif ( isset( $_POST['testcookie'] ) && empty( $_COOKIE[ TEST_COOKIE ] ) ) { | |
// If cookies are disabled we can't log in even with a valid user+pass | |
/* translators: 1: Browser cookie documentation URL */ | |
$user = new WP_Error( 'test_cookie', sprintf( __( '<strong>ERROR</strong>: Cookies are blocked or not supported by your browser. You must <a href="%s">enable cookies</a> to use WordPress.' ), | |
__( 'https://codex.wordpress.org/Cookies' ) ) ); | |
} | |
} | |
$requested_redirect_to = isset( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : ''; | |
/** | |
* Filters the login redirect URL. | |
* | |
* @since 3.0.0 | |
* | |
* @param string $redirect_to The redirect destination URL. | |
* @param string $requested_redirect_to The requested redirect destination URL passed as a parameter. | |
* @param WP_User|WP_Error $user WP_User object if login was successful, WP_Error object otherwise. | |
*/ | |
$redirect_to = apply_filters( 'login_redirect', $redirect_to, $requested_redirect_to, $user ); | |
if ( !is_wp_error($user) && !$reauth ) { | |
if ( $interim_login ) { | |
$message = '<p class="message">' . __('You have logged in successfully.') . '</p>'; | |
$interim_login = 'success'; | |
login_header( '', $message ); ?> | |
</div> | |
<?php | |
/** This action is documented in wp-login.php */ | |
do_action( 'login_footer' ); ?> | |
<?php if ( $customize_login ) : ?> | |
<script type="text/javascript">setTimeout( function(){ new wp.customize.Messenger({ url: '<?php echo wp_customize_url(); ?>', channel: 'login' }).send('login') }, 1000 );</script> | |
<?php endif; ?> | |
</body></html> | |
<?php exit; | |
} | |
if ( ( empty( $redirect_to ) || $redirect_to == 'wp-admin/' || $redirect_to == admin_url() ) ) { | |
// If the user doesn't belong to a blog, send them to user admin. If the user can't edit posts, send them to their profile. | |
if ( is_multisite() && !get_active_blog_for_user($user->ID) && !is_super_admin( $user->ID ) ) | |
$redirect_to = user_admin_url(); | |
elseif ( is_multisite() && !$user->has_cap('read') ) | |
$redirect_to = get_dashboard_url( $user->ID ); | |
elseif ( !$user->has_cap('edit_posts') ) | |
$redirect_to = $user->has_cap( 'read' ) ? admin_url( 'profile.php' ) : home_url(); | |
wp_redirect( $redirect_to ); | |
exit(); | |
} | |
wp_safe_redirect($redirect_to); | |
exit(); | |
} | |
$errors = $user; | |
// Clear errors if loggedout is set. | |
if ( !empty($_GET['loggedout']) || $reauth ) | |
$errors = new WP_Error(); | |
if ( $interim_login ) { | |
if ( ! $errors->get_error_code() ) | |
$errors->add( 'expired', __( 'Your session has expired. Please log in to continue where you left off.' ), 'message' ); | |
} else { | |
// Some parts of this script use the main login form to display a message | |
if ( isset($_GET['loggedout']) && true == $_GET['loggedout'] ) | |
$errors->add('loggedout', __('You are now logged out.'), 'message'); | |
elseif ( isset($_GET['registration']) && 'disabled' == $_GET['registration'] ) | |
$errors->add('registerdisabled', __('User registration is currently not allowed.')); | |
elseif ( isset($_GET['checkemail']) && 'confirm' == $_GET['checkemail'] ) | |
$errors->add('confirm', __('Check your email for the confirmation link.'), 'message'); | |
elseif ( isset($_GET['checkemail']) && 'newpass' == $_GET['checkemail'] ) | |
$errors->add('newpass', __('Check your email for your new password.'), 'message'); | |
elseif ( isset($_GET['checkemail']) && 'registered' == $_GET['checkemail'] ) | |
$errors->add('registered', __('Registration complete. Please check your email.'), 'message'); | |
elseif ( strpos( $redirect_to, 'about.php?updated' ) ) | |
$errors->add('updated', __( '<strong>You have successfully updated WordPress!</strong> Please log back in to see what’s new.' ), 'message' ); | |
} | |
/** | |
* Filters the login page errors. | |
* | |
* @since 3.6.0 | |
* | |
* @param object $errors WP Error object. | |
* @param string $redirect_to Redirect destination URL. | |
*/ | |
$errors = apply_filters( 'wp_login_errors', $errors, $redirect_to ); | |
// Clear any stale cookies. | |
if ( $reauth ) | |
wp_clear_auth_cookie(); | |
login_header(__('Log In'), '', $errors); | |
if ( isset($_POST['log']) ) | |
$user_login = ( 'incorrect_password' == $errors->get_error_code() || 'empty_password' == $errors->get_error_code() ) ? esc_attr(wp_unslash($_POST['log'])) : ''; | |
$rememberme = ! empty( $_POST['rememberme'] ); | |
if ( ! empty( $errors->errors ) ) { | |
$aria_describedby_error = ' aria-describedby="login_error"'; | |
} else { | |
$aria_describedby_error = ''; | |
} | |
?> | |
<form name="loginform" id="loginform" action="<?php echo esc_url( site_url( 'wp-login.php', 'login_post' ) ); ?>" method="post"> | |
<p> | |
<label for="user_login"><?php _e( 'Username or Email Address' ); ?><br /> | |
<input type="text" name="log" id="user_login"<?php echo $aria_describedby_error; ?> class="input" value="<?php echo esc_attr( $user_login ); ?>" size="20" /></label> | |
</p> | |
<p> | |
<label for="user_pass"><?php _e( 'Password' ); ?><br /> | |
<input type="password" name="pwd" id="user_pass"<?php echo $aria_describedby_error; ?> class="input" value="" size="20" /></label> | |
</p> | |
<?php | |
/** | |
* Fires following the 'Password' field in the login form. | |
* | |
* @since 2.1.0 | |
*/ | |
do_action( 'login_form' ); | |
?> | |
<p class="forgetmenot"><label for="rememberme"><input name="rememberme" type="checkbox" id="rememberme" value="forever" <?php checked( $rememberme ); ?> /> <?php esc_html_e( 'Remember Me' ); ?></label></p> | |
<p class="submit"> | |
<input type="submit" name="wp-submit" id="wp-submit" class="button button-primary button-large" value="<?php esc_attr_e('Log In'); ?>" /> | |
<?php if ( $interim_login ) { ?> | |
<input type="hidden" name="interim-login" value="1" /> | |
<?php } else { ?> | |
<input type="hidden" name="redirect_to" value="<?php echo esc_attr($redirect_to); ?>" /> | |
<?php } ?> | |
<?php if ( $customize_login ) : ?> | |
<input type="hidden" name="customize-login" value="1" /> | |
<?php endif; ?> | |
<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 ); | |
echo esc_html( $login_link_separator ); | |
endif; | |
?> | |
<a href="<?php echo esc_url( wp_lostpassword_url() ); ?>"><?php _e( 'Lost your password?' ); ?></a> | |
<?php endif; ?> | |
</p> | |
<?php } ?> | |
<script type="text/javascript"> | |
function wp_attempt_focus(){ | |
setTimeout( function(){ try{ | |
<?php if ( $user_login ) { ?> | |
d = document.getElementById('user_pass'); | |
d.value = ''; | |
<?php } else { ?> | |
d = document.getElementById('user_login'); | |
<?php if ( 'invalid_username' == $errors->get_error_code() ) { ?> | |
if( d.value != '' ) | |
d.value = ''; | |
<?php | |
} | |
}?> | |
d.focus(); | |
d.select(); | |
} catch(e){} | |
}, 200); | |
} | |
<?php | |
/** | |
* Filters whether to print the call to `wp_attempt_focus()` on the login screen. | |
* | |
* @since 4.8.0 | |
* | |
* @param bool $print Whether to print the function call. Default true. | |
*/ | |
if ( apply_filters( 'enable_login_autofocus', true ) && ! $error ) { ?> | |
wp_attempt_focus(); | |
<?php } ?> | |
if(typeof wpOnload=='function')wpOnload(); | |
<?php if ( $interim_login ) { ?> | |
(function(){ | |
try { | |
var i, links = document.getElementsByTagName('a'); | |
for ( i in links ) { | |
if ( links[i].href ) | |
links[i].target = '_blank'; | |
} | |
} catch(e){} | |
}()); | |
<?php } ?> | |
</script> | |
<?php | |
login_footer(); | |
if ( $switched_locale ) { | |
restore_previous_locale(); | |
} | |
break; | |
} // end action switch |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** Sets up the WordPress Environment. */ | |
require( dirname(__FILE__) . '/wp-load.php' ); | |
add_action( 'wp_head', 'wp_no_robots' ); | |
require( dirname( __FILE__ ) . '/wp-blog-header.php' ); | |
nocache_headers(); | |
if ( is_array( get_site_option( 'illegal_names' )) && isset( $_GET[ 'new' ] ) && in_array( $_GET[ 'new' ], get_site_option( 'illegal_names' ) ) ) { | |
wp_redirect( network_home_url() ); | |
die(); | |
} | |
/** | |
* Prints signup_header via wp_head | |
* | |
* @since MU (3.0.0) | |
*/ | |
function do_signup_header() { | |
/** | |
* Fires within the head section of the site sign-up screen. | |
* | |
* @since 3.0.0 | |
*/ | |
do_action( 'signup_header' ); | |
} | |
add_action( 'wp_head', 'do_signup_header' ); | |
if ( !is_multisite() ) { | |
wp_redirect( wp_registration_url() ); | |
die(); | |
} | |
if ( !is_main_site() ) { | |
wp_redirect( network_site_url( 'wp-signup.php' ) ); | |
die(); | |
} | |
// Fix for page title | |
$wp_query->is_404 = false; | |
/** | |
* Fires before the Site Signup page is loaded. | |
* | |
* @since 4.4.0 | |
*/ | |
do_action( 'before_signup_header' ); | |
/** | |
* Prints styles for front-end Multisite signup pages | |
* | |
* @since MU (3.0.0) | |
*/ | |
function wpmu_signup_stylesheet() { | |
?> | |
<style type="text/css"> | |
.mu_register { width: 90%; margin:0 auto; } | |
.mu_register form { margin-top: 2em; } | |
.mu_register .error { font-weight:700; padding:10px; color:#333333; background:#FFEBE8; border:1px solid #CC0000; } | |
.mu_register input[type="submit"], | |
.mu_register #blog_title, | |
.mu_register #user_email, | |
.mu_register #blogname, | |
.mu_register #user_name { width:100%; font-size: 24px; margin:5px 0; } | |
.mu_register #site-language { display: block; } | |
.mu_register .prefix_address, | |
.mu_register .suffix_address {font-size: 18px;display:inline; } | |
.mu_register label { font-weight:700; font-size:15px; display:block; margin:10px 0; } | |
.mu_register label.checkbox { display:inline; } | |
.mu_register .mu_alert { font-weight:700; padding:10px; color:#333333; background:#ffffe0; border:1px solid #e6db55; } | |
</style> | |
<?php | |
} | |
add_action( 'wp_head', 'wpmu_signup_stylesheet' ); | |
get_header( 'wp-signup' ); | |
/** | |
* Fires before the site sign-up form. | |
* | |
* @since 3.0.0 | |
*/ | |
do_action( 'before_signup_form' ); | |
?> | |
<div id="signup-content" class="widecolumn"> | |
<div class="mu_register wp-signup-container"> | |
<?php | |
/** | |
* Generates and displays the Signup and Create Site forms | |
* | |
* @since MU (3.0.0) | |
* | |
* @param string $blogname The new site name. | |
* @param string $blog_title The new site title. | |
* @param WP_Error|string $errors A WP_Error object containing existing errors. Defaults to empty string. | |
*/ | |
function show_blog_form( $blogname = '', $blog_title = '', $errors = '' ) { | |
if ( ! is_wp_error( $errors ) ) { | |
$errors = new WP_Error(); | |
} | |
$current_network = get_network(); | |
// Blog name | |
if ( !is_subdomain_install() ) | |
echo '<label for="blogname">' . __('Site Name:') . '</label>'; | |
else | |
echo '<label for="blogname">' . __('Site Domain:') . '</label>'; | |
if ( $errmsg = $errors->get_error_message('blogname') ) { ?> | |
<p class="error"><?php echo $errmsg ?></p> | |
<?php } | |
if ( !is_subdomain_install() ) | |
echo '<span class="prefix_address">' . $current_network->domain . $current_network->path . '</span><input name="blogname" type="text" id="blogname" value="'. esc_attr($blogname) .'" maxlength="60" /><br />'; | |
else | |
echo '<input name="blogname" type="text" id="blogname" value="'.esc_attr($blogname).'" maxlength="60" /><span class="suffix_address">.' . ( $site_domain = preg_replace( '|^www\.|', '', $current_network->domain ) ) . '</span><br />'; | |
if ( ! is_user_logged_in() ) { | |
if ( ! is_subdomain_install() ) { | |
$site = $current_network->domain . $current_network->path . __( 'sitename' ); | |
} else { | |
$site = __( 'domain' ) . '.' . $site_domain . $current_network->path; | |
} | |
/* translators: %s: site address */ | |
echo '<p>(<strong>' . sprintf( __( 'Your address will be %s.' ), $site ) . '</strong>) ' . __( 'Must be at least 4 characters, letters and numbers only. It cannot be changed, so choose carefully!' ) . '</p>'; | |
} | |
// Blog Title | |
?> | |
<label for="blog_title"><?php _e('Site Title:') ?></label> | |
<?php if ( $errmsg = $errors->get_error_message('blog_title') ) { ?> | |
<p class="error"><?php echo $errmsg ?></p> | |
<?php } | |
echo '<input name="blog_title" type="text" id="blog_title" value="'.esc_attr($blog_title).'" />'; | |
?> | |
<?php | |
// Site Language. | |
$languages = signup_get_available_languages(); | |
if ( ! empty( $languages ) ) : | |
?> | |
<p> | |
<label for="site-language"><?php _e( 'Site Language:' ); ?></label> | |
<?php | |
// Network default. | |
$lang = get_site_option( 'WPLANG' ); | |
if ( isset( $_POST['WPLANG'] ) ) { | |
$lang = $_POST['WPLANG']; | |
} | |
// Use US English if the default isn't available. | |
if ( ! in_array( $lang, $languages ) ) { | |
$lang = ''; | |
} | |
wp_dropdown_languages( array( | |
'name' => 'WPLANG', | |
'id' => 'site-language', | |
'selected' => $lang, | |
'languages' => $languages, | |
'show_available_translations' => false, | |
) ); | |
?> | |
</p> | |
<?php endif; // Languages. ?> | |
<div id="privacy"> | |
<p class="privacy-intro"> | |
<label for="blog_public_on"><?php _e('Privacy:') ?></label> | |
<?php _e( 'Allow search engines to index this site.' ); ?> | |
<br style="clear:both" /> | |
<label class="checkbox" for="blog_public_on"> | |
<input type="radio" id="blog_public_on" name="blog_public" value="1" <?php if ( !isset( $_POST['blog_public'] ) || $_POST['blog_public'] == '1' ) { ?>checked="checked"<?php } ?> /> | |
<strong><?php _e( 'Yes' ); ?></strong> | |
</label> | |
<label class="checkbox" for="blog_public_off"> | |
<input type="radio" id="blog_public_off" name="blog_public" value="0" <?php if ( isset( $_POST['blog_public'] ) && $_POST['blog_public'] == '0' ) { ?>checked="checked"<?php } ?> /> | |
<strong><?php _e( 'No' ); ?></strong> | |
</label> | |
</p> | |
</div> | |
<?php | |
/** | |
* Fires after the site sign-up form. | |
* | |
* @since 3.0.0 | |
* | |
* @param WP_Error $errors A WP_Error object possibly containing 'blogname' or 'blog_title' errors. | |
*/ | |
do_action( 'signup_blogform', $errors ); | |
} | |
/** | |
* Validate the new site signup | |
* | |
* @since MU (3.0.0) | |
* | |
* @return array Contains the new site data and error messages. | |
*/ | |
function validate_blog_form() { | |
$user = ''; | |
if ( is_user_logged_in() ) | |
$user = wp_get_current_user(); | |
return wpmu_validate_blog_signup($_POST['blogname'], $_POST['blog_title'], $user); | |
} | |
/** | |
* Display user registration form | |
* | |
* @since MU (3.0.0) | |
* | |
* @param string $user_name The entered username. | |
* @param string $user_email The entered email address. | |
* @param WP_Error|string $errors A WP_Error object containing existing errors. Defaults to empty string. | |
*/ | |
function show_user_form($user_name = '', $user_email = '', $errors = '') { | |
if ( ! is_wp_error( $errors ) ) { | |
$errors = new WP_Error(); | |
} | |
// User name | |
echo '<label for="user_name">' . __('Username:') . '</label>'; | |
if ( $errmsg = $errors->get_error_message('user_name') ) { | |
echo '<p class="error">'.$errmsg.'</p>'; | |
} | |
echo '<input name="user_name" type="text" id="user_name" value="'. esc_attr( $user_name ) .'" autocapitalize="none" autocorrect="off" maxlength="60" /><br />'; | |
_e( '(Must be at least 4 characters, letters and numbers only.)' ); | |
?> | |
<label for="user_email"><?php _e( 'Email Address:' ) ?></label> | |
<?php if ( $errmsg = $errors->get_error_message('user_email') ) { ?> | |
<p class="error"><?php echo $errmsg ?></p> | |
<?php } ?> | |
<input name="user_email" type="email" id="user_email" value="<?php echo esc_attr($user_email) ?>" maxlength="200" /><br /><?php _e('We send your registration email to this address. (Double-check your email address before continuing.)') ?> | |
<?php | |
if ( $errmsg = $errors->get_error_message('generic') ) { | |
echo '<p class="error">' . $errmsg . '</p>'; | |
} | |
/** | |
* Fires at the end of the user registration form on the site sign-up form. | |
* | |
* @since 3.0.0 | |
* | |
* @param WP_Error $errors A WP_Error object containing 'user_name' or 'user_email' errors. | |
*/ | |
do_action( 'signup_extra_fields', $errors ); | |
} | |
/** | |
* Validate user signup name and email | |
* | |
* @since MU (3.0.0) | |
* | |
* @return array Contains username, email, and error messages. | |
*/ | |
function validate_user_form() { | |
return wpmu_validate_user_signup($_POST['user_name'], $_POST['user_email']); | |
} | |
/** | |
* Allow returning users to sign up for another site | |
* | |
* @since MU (3.0.0) | |
* | |
* @param string $blogname The new site name | |
* @param string $blog_title The new site title. | |
* @param WP_Error|string $errors A WP_Error object containing existing errors. Defaults to empty string. | |
*/ | |
function signup_another_blog( $blogname = '', $blog_title = '', $errors = '' ) { | |
$current_user = wp_get_current_user(); | |
if ( ! is_wp_error($errors) ) { | |
$errors = new WP_Error(); | |
} | |
$signup_defaults = array( | |
'blogname' => $blogname, | |
'blog_title' => $blog_title, | |
'errors' => $errors | |
); | |
/** | |
* Filters the default site sign-up variables. | |
* | |
* @since 3.0.0 | |
* | |
* @param array $signup_defaults { | |
* An array of default site sign-up variables. | |
* | |
* @type string $blogname The site blogname. | |
* @type string $blog_title The site title. | |
* @type WP_Error $errors A WP_Error object possibly containing 'blogname' or 'blog_title' errors. | |
* } | |
*/ | |
$filtered_results = apply_filters( 'signup_another_blog_init', $signup_defaults ); | |
$blogname = $filtered_results['blogname']; | |
$blog_title = $filtered_results['blog_title']; | |
$errors = $filtered_results['errors']; | |
echo '<h2>' . sprintf( __( 'Get <em>another</em> %s site in seconds' ), get_network()->site_name ) . '</h2>'; | |
if ( $errors->get_error_code() ) { | |
echo '<p>' . __( 'There was a problem, please correct the form below and try again.' ) . '</p>'; | |
} | |
?> | |
<p><?php printf( __( 'Welcome back, %s. By filling out the form below, you can <strong>add another site to your account</strong>. There is no limit to the number of sites you can have, so create to your heart’s content, but write responsibly!' ), $current_user->display_name ) ?></p> | |
<?php | |
$blogs = get_blogs_of_user($current_user->ID); | |
if ( !empty($blogs) ) { ?> | |
<p><?php _e( 'Sites you are already a member of:' ) ?></p> | |
<ul> | |
<?php foreach ( $blogs as $blog ) { | |
$home_url = get_home_url( $blog->userblog_id ); | |
echo '<li><a href="' . esc_url( $home_url ) . '">' . $home_url . '</a></li>'; | |
} ?> | |
</ul> | |
<?php } ?> | |
<p><?php _e( 'If you’re not going to use a great site domain, leave it for a new user. Now have at it!' ) ?></p> | |
<form id="setupform" method="post" action="wp-signup.php"> | |
<input type="hidden" name="stage" value="gimmeanotherblog" /> | |
<?php | |
/** | |
* Hidden sign-up form fields output when creating another site or user. | |
* | |
* @since MU (3.0.0) | |
* | |
* @param string $context A string describing the steps of the sign-up process. The value can be | |
* 'create-another-site', 'validate-user', or 'validate-site'. | |
*/ | |
do_action( 'signup_hidden_fields', 'create-another-site' ); | |
?> | |
<?php show_blog_form($blogname, $blog_title, $errors); ?> | |
<p class="submit"><input type="submit" name="submit" class="submit" value="<?php esc_attr_e( 'Create Site' ) ?>" /></p> | |
</form> | |
<?php | |
} | |
/** | |
* Validate a new site signup. | |
* | |
* @since MU (3.0.0) | |
* | |
* @return null|bool True if site signup was validated, false if error. | |
* The function halts all execution if the user is not logged in. | |
*/ | |
function validate_another_blog_signup() { | |
global $blogname, $blog_title, $errors, $domain, $path; | |
$current_user = wp_get_current_user(); | |
if ( ! is_user_logged_in() ) { | |
die(); | |
} | |
$result = validate_blog_form(); | |
// Extracted values set/overwrite globals. | |
$domain = $result['domain']; | |
$path = $result['path']; | |
$blogname = $result['blogname']; | |
$blog_title = $result['blog_title']; | |
$errors = $result['errors']; | |
if ( $errors->get_error_code() ) { | |
signup_another_blog($blogname, $blog_title, $errors); | |
return false; | |
} | |
$public = (int) $_POST['blog_public']; | |
$blog_meta_defaults = array( | |
'lang_id' => 1, | |
'public' => $public | |
); | |
// Handle the language setting for the new site. | |
if ( ! empty( $_POST['WPLANG'] ) ) { | |
$languages = signup_get_available_languages(); | |
if ( in_array( $_POST['WPLANG'], $languages ) ) { | |
$language = wp_unslash( sanitize_text_field( $_POST['WPLANG'] ) ); | |
if ( $language ) { | |
$blog_meta_defaults['WPLANG'] = $language; | |
} | |
} | |
} | |
/** | |
* Filters the new site meta variables. | |
* | |
* Use the {@see 'add_signup_meta'} filter instead. | |
* | |
* @since MU (3.0.0) | |
* @deprecated 3.0.0 Use the {@see 'add_signup_meta'} filter instead. | |
* | |
* @param array $blog_meta_defaults An array of default blog meta variables. | |
*/ | |
$meta_defaults = apply_filters( 'signup_create_blog_meta', $blog_meta_defaults ); | |
/** | |
* Filters the new default site meta variables. | |
* | |
* @since 3.0.0 | |
* | |
* @param array $meta { | |
* An array of default site meta variables. | |
* | |
* @type int $lang_id The language ID. | |
* @type int $blog_public Whether search engines should be discouraged from indexing the site. 1 for true, 0 for false. | |
* } | |
*/ | |
$meta = apply_filters( 'add_signup_meta', $meta_defaults ); | |
$blog_id = wpmu_create_blog( $domain, $path, $blog_title, $current_user->ID, $meta, get_current_network_id() ); | |
if ( is_wp_error( $blog_id ) ) { | |
return false; | |
} | |
confirm_another_blog_signup( $domain, $path, $blog_title, $current_user->user_login, $current_user->user_email, $meta, $blog_id ); | |
return true; | |
} | |
/** | |
* Confirm a new site signup. | |
* | |
* @since MU (3.0.0) | |
* @since 4.4.0 Added the `$blog_id` parameter. | |
* | |
* @param string $domain The domain URL. | |
* @param string $path The site root path. | |
* @param string $blog_title The site title. | |
* @param string $user_name The username. | |
* @param string $user_email The user's email address. | |
* @param array $meta Any additional meta from the {@see 'add_signup_meta'} filter in validate_blog_signup(). | |
* @param int $blog_id The site ID. | |
*/ | |
function confirm_another_blog_signup( $domain, $path, $blog_title, $user_name, $user_email = '', $meta = array(), $blog_id = 0 ) { | |
if ( $blog_id ) { | |
switch_to_blog( $blog_id ); | |
$home_url = home_url( '/' ); | |
$login_url = wp_login_url(); | |
restore_current_blog(); | |
} else { | |
$home_url = 'http://' . $domain . $path; | |
$login_url = 'http://' . $domain . $path . 'wp-login.php'; | |
} | |
$site = sprintf( '<a href="%1$s">%2$s</a>', | |
esc_url( $home_url ), | |
$blog_title | |
); | |
?> | |
<h2><?php | |
/* translators: %s: site name */ | |
printf( __( 'The site %s is yours.' ), $site ); | |
?></h2> | |
<p> | |
<?php printf( | |
/* translators: 1: link to new site, 2: login URL, 3: username */ | |
__( '%1$s is your new site. <a href="%2$s">Log in</a> as “%3$s” using your existing password.' ), | |
sprintf( | |
'<a href="%s">%s</a>', | |
esc_url( $home_url ), | |
untrailingslashit( $domain . $path ) | |
), | |
esc_url( $login_url ), | |
$user_name | |
); ?> | |
</p> | |
<?php | |
/** | |
* Fires when the site or user sign-up process is complete. | |
* | |
* @since 3.0.0 | |
*/ | |
do_action( 'signup_finished' ); | |
} | |
/** | |
* Setup the new user signup process | |
* | |
* @since MU (3.0.0) | |
* | |
* @param string $user_name The username. | |
* @param string $user_email The user's email. | |
* @param WP_Error|string $errors A WP_Error object containing existing errors. Defaults to empty string. | |
*/ | |
function signup_user( $user_name = '', $user_email = '', $errors = '' ) { | |
global $active_signup; | |
if ( !is_wp_error($errors) ) | |
$errors = new WP_Error(); | |
$signup_for = isset( $_POST[ 'signup_for' ] ) ? esc_html( $_POST[ 'signup_for' ] ) : 'blog'; | |
$signup_user_defaults = array( | |
'user_name' => $user_name, | |
'user_email' => $user_email, | |
'errors' => $errors, | |
); | |
/** | |
* Filters the default user variables used on the user sign-up form. | |
* | |
* @since 3.0.0 | |
* | |
* @param array $signup_user_defaults { | |
* An array of default user variables. | |
* | |
* @type string $user_name The user username. | |
* @type string $user_email The user email address. | |
* @type WP_Error $errors A WP_Error object with possible errors relevant to the sign-up user. | |
* } | |
*/ | |
$filtered_results = apply_filters( 'signup_user_init', $signup_user_defaults ); | |
$user_name = $filtered_results['user_name']; | |
$user_email = $filtered_results['user_email']; | |
$errors = $filtered_results['errors']; | |
?> | |
<h2><?php | |
/* translators: %s: name of the network */ | |
printf( __( 'Get your own %s account in seconds' ), get_network()->site_name ); | |
?></h2> | |
<form id="setupform" method="post" action="wp-signup.php" novalidate="novalidate"> | |
<input type="hidden" name="stage" value="validate-user-signup" /> | |
<?php | |
/** This action is documented in wp-signup.php */ | |
do_action( 'signup_hidden_fields', 'validate-user' ); | |
?> | |
<?php show_user_form($user_name, $user_email, $errors); ?> | |
<p> | |
<?php if ( $active_signup == 'blog' ) { ?> | |
<input id="signupblog" type="hidden" name="signup_for" value="blog" /> | |
<?php } elseif ( $active_signup == 'user' ) { ?> | |
<input id="signupblog" type="hidden" name="signup_for" value="user" /> | |
<?php } else { ?> | |
<input id="signupblog" type="radio" name="signup_for" value="blog" <?php checked( $signup_for, 'blog' ); ?> /> | |
<label class="checkbox" for="signupblog"><?php _e('Gimme a site!') ?></label> | |
<br /> | |
<input id="signupuser" type="radio" name="signup_for" value="user" <?php checked( $signup_for, 'user' ); ?> /> | |
<label class="checkbox" for="signupuser"><?php _e('Just a username, please.') ?></label> | |
<?php } ?> | |
</p> | |
<p class="submit"><input type="submit" name="submit" class="submit" value="<?php esc_attr_e('Next') ?>" /></p> | |
</form> | |
<?php | |
} | |
/** | |
* Validate the new user signup | |
* | |
* @since MU (3.0.0) | |
* | |
* @return bool True if new user signup was validated, false if error | |
*/ | |
function validate_user_signup() { | |
$result = validate_user_form(); | |
$user_name = $result['user_name']; | |
$user_email = $result['user_email']; | |
$errors = $result['errors']; | |
if ( $errors->get_error_code() ) { | |
signup_user($user_name, $user_email, $errors); | |
return false; | |
} | |
if ( 'blog' == $_POST['signup_for'] ) { | |
signup_blog($user_name, $user_email); | |
return false; | |
} | |
/** This filter is documented in wp-signup.php */ | |
wpmu_signup_user( $user_name, $user_email, apply_filters( 'add_signup_meta', array() ) ); | |
confirm_user_signup($user_name, $user_email); | |
return true; | |
} | |
/** | |
* New user signup confirmation | |
* | |
* @since MU (3.0.0) | |
* | |
* @param string $user_name The username | |
* @param string $user_email The user's email address | |
*/ | |
function confirm_user_signup($user_name, $user_email) { | |
?> | |
<h2><?php /* translators: %s: username */ | |
printf( __( '%s is your new username' ), $user_name) ?></h2> | |
<p><?php _e( 'But, before you can start using your new username, <strong>you must activate it</strong>.' ) ?></p> | |
<p><?php /* translators: %s: email address */ | |
printf( __( 'Check your inbox at %s and click the link given.' ), '<strong>' . $user_email . '</strong>' ); ?></p> | |
<p><?php _e( 'If you do not activate your username within two days, you will have to sign up again.' ); ?></p> | |
<?php | |
/** This action is documented in wp-signup.php */ | |
do_action( 'signup_finished' ); | |
} | |
/** | |
* Setup the new site signup | |
* | |
* @since MU (3.0.0) | |
* | |
* @param string $user_name The username. | |
* @param string $user_email The user's email address. | |
* @param string $blogname The site name. | |
* @param string $blog_title The site title. | |
* @param WP_Error|string $errors A WP_Error object containing existing errors. Defaults to empty string. | |
*/ | |
function signup_blog($user_name = '', $user_email = '', $blogname = '', $blog_title = '', $errors = '') { | |
if ( !is_wp_error($errors) ) | |
$errors = new WP_Error(); | |
$signup_blog_defaults = array( | |
'user_name' => $user_name, | |
'user_email' => $user_email, | |
'blogname' => $blogname, | |
'blog_title' => $blog_title, | |
'errors' => $errors | |
); | |
/** | |
* Filters the default site creation variables for the site sign-up form. | |
* | |
* @since 3.0.0 | |
* | |
* @param array $signup_blog_defaults { | |
* An array of default site creation variables. | |
* | |
* @type string $user_name The user username. | |
* @type string $user_email The user email address. | |
* @type string $blogname The blogname. | |
* @type string $blog_title The title of the site. | |
* @type WP_Error $errors A WP_Error object with possible errors relevant to new site creation variables. | |
* } | |
*/ | |
$filtered_results = apply_filters( 'signup_blog_init', $signup_blog_defaults ); | |
$user_name = $filtered_results['user_name']; | |
$user_email = $filtered_results['user_email']; | |
$blogname = $filtered_results['blogname']; | |
$blog_title = $filtered_results['blog_title']; | |
$errors = $filtered_results['errors']; | |
if ( empty($blogname) ) | |
$blogname = $user_name; | |
?> | |
<form id="setupform" method="post" action="wp-signup.php"> | |
<input type="hidden" name="stage" value="validate-blog-signup" /> | |
<input type="hidden" name="user_name" value="<?php echo esc_attr($user_name) ?>" /> | |
<input type="hidden" name="user_email" value="<?php echo esc_attr($user_email) ?>" /> | |
<?php | |
/** This action is documented in wp-signup.php */ | |
do_action( 'signup_hidden_fields', 'validate-site' ); | |
?> | |
<?php show_blog_form($blogname, $blog_title, $errors); ?> | |
<p class="submit"><input type="submit" name="submit" class="submit" value="<?php esc_attr_e('Signup') ?>" /></p> | |
</form> | |
<?php | |
} | |
/** | |
* Validate new site signup | |
* | |
* @since MU (3.0.0) | |
* | |
* @return bool True if the site signup was validated, false if error | |
*/ | |
function validate_blog_signup() { | |
// Re-validate user info. | |
$user_result = wpmu_validate_user_signup( $_POST['user_name'], $_POST['user_email'] ); | |
$user_name = $user_result['user_name']; | |
$user_email = $user_result['user_email']; | |
$user_errors = $user_result['errors']; | |
if ( $user_errors->get_error_code() ) { | |
signup_user( $user_name, $user_email, $user_errors ); | |
return false; | |
} | |
$result = wpmu_validate_blog_signup( $_POST['blogname'], $_POST['blog_title'] ); | |
$domain = $result['domain']; | |
$path = $result['path']; | |
$blogname = $result['blogname']; | |
$blog_title = $result['blog_title']; | |
$errors = $result['errors']; | |
if ( $errors->get_error_code() ) { | |
signup_blog($user_name, $user_email, $blogname, $blog_title, $errors); | |
return false; | |
} | |
$public = (int) $_POST['blog_public']; | |
$signup_meta = array ('lang_id' => 1, 'public' => $public); | |
// Handle the language setting for the new site. | |
if ( ! empty( $_POST['WPLANG'] ) ) { | |
$languages = signup_get_available_languages(); | |
if ( in_array( $_POST['WPLANG'], $languages ) ) { | |
$language = wp_unslash( sanitize_text_field( $_POST['WPLANG'] ) ); | |
if ( $language ) { | |
$signup_meta['WPLANG'] = $language; | |
} | |
} | |
} | |
/** This filter is documented in wp-signup.php */ | |
$meta = apply_filters( 'add_signup_meta', $signup_meta ); | |
wpmu_signup_blog($domain, $path, $blog_title, $user_name, $user_email, $meta); | |
confirm_blog_signup($domain, $path, $blog_title, $user_name, $user_email, $meta); | |
return true; | |
} | |
/** | |
* New site signup confirmation | |
* | |
* @since MU (3.0.0) | |
* | |
* @param string $domain The domain URL | |
* @param string $path The site root path | |
* @param string $blog_title The new site title | |
* @param string $user_name The user's username | |
* @param string $user_email The user's email address | |
* @param array $meta Any additional meta from the {@see 'add_signup_meta'} filter in validate_blog_signup() | |
*/ | |
function confirm_blog_signup( $domain, $path, $blog_title, $user_name = '', $user_email = '', $meta = array() ) { | |
?> | |
<h2><?php /* translators: %s: site address */ | |
printf( __( 'Congratulations! Your new site, %s, is almost ready.' ), "<a href='http://{$domain}{$path}'>{$blog_title}</a>" ) ?></h2> | |
<p><?php _e( 'But, before you can start using your site, <strong>you must activate it</strong>.' ) ?></p> | |
<p><?php /* translators: %s: email address */ | |
printf( __( 'Check your inbox at %s and click the link given.' ), '<strong>' . $user_email . '</strong>' ); ?></p> | |
<p><?php _e( 'If you do not activate your site within two days, you will have to sign up again.' ); ?></p> | |
<h2><?php _e( 'Still waiting for your email?' ); ?></h2> | |
<p> | |
<?php _e( 'If you haven’t received your email yet, there are a number of things you can do:' ) ?> | |
<ul id="noemail-tips"> | |
<li><p><strong><?php _e( 'Wait a little longer. Sometimes delivery of email can be delayed by processes outside of our control.' ) ?></strong></p></li> | |
<li><p><?php _e( 'Check the junk or spam folder of your email client. Sometime emails wind up there by mistake.' ) ?></p></li> | |
<li><?php | |
/* translators: %s: email address */ | |
printf( __( 'Have you entered your email correctly? You have entered %s, if it’s incorrect, you will not receive your email.' ), $user_email ); | |
?></li> | |
</ul> | |
</p> | |
<?php | |
/** This action is documented in wp-signup.php */ | |
do_action( 'signup_finished' ); | |
} | |
/** | |
* Retrieves languages available during the site/user signup process. | |
* | |
* @since 4.4.0 | |
* | |
* @see get_available_languages() | |
* | |
* @return array List of available languages. | |
*/ | |
function signup_get_available_languages() { | |
/** | |
* Filters the list of available languages for front-end site signups. | |
* | |
* Passing an empty array to this hook will disable output of the setting on the | |
* signup form, and the default language will be used when creating the site. | |
* | |
* Languages not already installed will be stripped. | |
* | |
* @since 4.4.0 | |
* | |
* @param array $available_languages Available languages. | |
*/ | |
$languages = (array) apply_filters( 'signup_get_available_languages', get_available_languages() ); | |
/* | |
* Strip any non-installed languages and return. | |
* | |
* Re-call get_available_languages() here in case a language pack was installed | |
* in a callback hooked to the 'signup_get_available_languages' filter before this point. | |
*/ | |
return array_intersect_assoc( $languages, get_available_languages() ); | |
} | |
// Main | |
$active_signup = get_site_option( 'registration', 'none' ); | |
/** | |
* Filters the type of site sign-up. | |
* | |
* @since 3.0.0 | |
* | |
* @param string $active_signup String that returns registration type. The value can be | |
* 'all', 'none', 'blog', or 'user'. | |
*/ | |
$active_signup = apply_filters( 'wpmu_active_signup', $active_signup ); | |
if ( current_user_can( 'manage_network' ) ) { | |
echo '<div class="mu_alert">'; | |
_e( 'Greetings Network Administrator!' ); | |
echo ' '; | |
switch ( $active_signup ) { | |
case 'none': | |
_e( 'The network currently disallows registrations.' ); | |
break; | |
case 'blog': | |
_e( 'The network currently allows site registrations.' ); | |
break; | |
case 'user': | |
_e( 'The network currently allows user registrations.' ); | |
break; | |
default: | |
_e( 'The network currently allows both site and user registrations.' ); | |
break; | |
} | |
echo ' '; | |
/* translators: %s: network settings URL */ | |
printf( __( 'To change or disable registration go to your <a href="%s">Options page</a>.' ), esc_url( network_admin_url( 'settings.php' ) ) ); | |
echo '</div>'; | |
} | |
$newblogname = isset($_GET['new']) ? strtolower(preg_replace('/^-|-$|[^-a-zA-Z0-9]/', '', $_GET['new'])) : null; | |
$current_user = wp_get_current_user(); | |
if ( $active_signup == 'none' ) { | |
_e( 'Registration has been disabled.' ); | |
} elseif ( $active_signup == 'blog' && !is_user_logged_in() ) { | |
$login_url = wp_login_url( network_site_url( 'wp-signup.php' ) ); | |
/* translators: %s: login URL */ | |
printf( __( 'You must first <a href="%s">log in</a>, and then you can create a new site.' ), $login_url ); | |
} else { | |
$stage = isset( $_POST['stage'] ) ? $_POST['stage'] : 'default'; | |
switch ( $stage ) { | |
case 'validate-user-signup' : | |
if ( $active_signup == 'all' || $_POST[ 'signup_for' ] == 'blog' && $active_signup == 'blog' || $_POST[ 'signup_for' ] == 'user' && $active_signup == 'user' ) | |
validate_user_signup(); | |
else | |
_e( 'User registration has been disabled.' ); | |
break; | |
case 'validate-blog-signup': | |
if ( $active_signup == 'all' || $active_signup == 'blog' ) | |
validate_blog_signup(); | |
else | |
_e( 'Site registration has been disabled.' ); | |
break; | |
case 'gimmeanotherblog': | |
validate_another_blog_signup(); | |
break; | |
case 'default': | |
default : | |
$user_email = isset( $_POST[ 'user_email' ] ) ? $_POST[ 'user_email' ] : ''; | |
/** | |
* Fires when the site sign-up form is sent. | |
* | |
* @since 3.0.0 | |
*/ | |
do_action( 'preprocess_signup_form' ); | |
if ( is_user_logged_in() && ( $active_signup == 'all' || $active_signup == 'blog' ) ) | |
signup_another_blog($newblogname); | |
elseif ( ! is_user_logged_in() && ( $active_signup == 'all' || $active_signup == 'user' ) ) | |
signup_user( $newblogname, $user_email ); | |
elseif ( ! is_user_logged_in() && ( $active_signup == 'blog' ) ) | |
_e( 'Sorry, new registrations are not allowed at this time.' ); | |
else | |
_e( 'You are logged in already. No need to register again!' ); | |
if ( $newblogname ) { | |
$newblog = get_blogaddress_by_name( $newblogname ); | |
if ( $active_signup == 'blog' || $active_signup == 'all' ) | |
/* translators: %s: site address */ | |
printf( '<p><em>' . __( 'The site you were looking for, %s, does not exist, but you can create it now!' ) . '</em></p>', | |
'<strong>' . $newblog . '</strong>' | |
); | |
else | |
/* translators: %s: site address */ | |
printf( '<p><em>' . __( 'The site you were looking for, %s, does not exist.' ) . '</em></p>', | |
'<strong>' . $newblog . '</strong>' | |
); | |
} | |
break; | |
} | |
} | |
?> | |
</div> | |
</div> | |
<?php | |
/** | |
* Fires after the sign-up forms, before wp_footer. | |
* | |
* @since 3.0.0 | |
*/ | |
do_action( 'after_signup_form' ); ?> | |
<?php get_footer( 'wp-signup' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
what is it for