diff  includes/schema.php includes/schema.php
1,962c1,963
< <?php
< /**
<  * WordPress Administration Scheme API
<  *
<  * Here we keep the DB structure and option values.
<  *
<  * @package WordPress
<  * @subpackage Administration
<  */
< 
< // Declare these as global in case schema.php is included from a function.
< global $wpdb, $wp_queries, $charset_collate;
< 
< /**
<  * The database character collate.
<  * @var string
<  * @global string
<  * @name $charset_collate
<  */
< $charset_collate = '';
< 
< if ( ! empty( $wpdb->charset ) )
< 	$charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
< if ( ! empty( $wpdb->collate ) )
< 	$charset_collate .= " COLLATE $wpdb->collate";
< 
< /**
<  * Retrieve the SQL for creating database tables.
<  *
<  * @since 3.3.0
<  *
<  * @param string $scope Optional. The tables for which to retrieve SQL. Can be all, global, ms_global, or blog tables. Defaults to all.
<  * @param int $blog_id Optional. The blog ID for which to retrieve SQL.  Default is the current blog ID.
<  * @return string The SQL needed to create the requested tables.
<  */
< function wp_get_db_schema( $scope = 'all', $blog_id = null ) {
< 	global $wpdb;
< 
< 	$charset_collate = '';
< 
< 	if ( ! empty($wpdb->charset) )
< 		$charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
< 	if ( ! empty($wpdb->collate) )
< 		$charset_collate .= " COLLATE $wpdb->collate";
< 
< 	if ( $blog_id && $blog_id != $wpdb->blogid )
< 		$old_blog_id = $wpdb->set_blog_id( $blog_id );
< 
< 	// Engage multisite if in the middle of turning it on from network.php.
< 	$is_multisite = is_multisite() || ( defined( 'WP_INSTALLING_NETWORK' ) && WP_INSTALLING_NETWORK );
< 
< 	// Blog specific tables.
< 	$blog_tables = "CREATE TABLE $wpdb->terms (
<  term_id bigint(20) unsigned NOT NULL auto_increment,
<  name varchar(200) NOT NULL default '',
<  slug varchar(200) NOT NULL default '',
<  term_group bigint(10) NOT NULL default 0,
<  PRIMARY KEY  (term_id),
<  UNIQUE KEY slug (slug),
<  KEY name (name)
< ) $charset_collate;
< CREATE TABLE $wpdb->term_taxonomy (
<  term_taxonomy_id bigint(20) unsigned NOT NULL auto_increment,
<  term_id bigint(20) unsigned NOT NULL default 0,
<  taxonomy varchar(32) NOT NULL default '',
<  description longtext NOT NULL,
<  parent bigint(20) unsigned NOT NULL default 0,
<  count bigint(20) NOT NULL default 0,
<  PRIMARY KEY  (term_taxonomy_id),
<  UNIQUE KEY term_id_taxonomy (term_id,taxonomy),
<  KEY taxonomy (taxonomy)
< ) $charset_collate;
< CREATE TABLE $wpdb->term_relationships (
<  object_id bigint(20) unsigned NOT NULL default 0,
<  term_taxonomy_id bigint(20) unsigned NOT NULL default 0,
<  term_order int(11) NOT NULL default 0,
<  PRIMARY KEY  (object_id,term_taxonomy_id),
<  KEY term_taxonomy_id (term_taxonomy_id)
< ) $charset_collate;
< CREATE TABLE $wpdb->commentmeta (
<   meta_id bigint(20) unsigned NOT NULL auto_increment,
<   comment_id bigint(20) unsigned NOT NULL default '0',
<   meta_key varchar(255) default NULL,
<   meta_value longtext,
<   PRIMARY KEY  (meta_id),
<   KEY comment_id (comment_id),
<   KEY meta_key (meta_key)
< ) $charset_collate;
< CREATE TABLE $wpdb->comments (
<   comment_ID bigint(20) unsigned NOT NULL auto_increment,
<   comment_post_ID bigint(20) unsigned NOT NULL default '0',
<   comment_author tinytext NOT NULL,
<   comment_author_email varchar(100) NOT NULL default '',
<   comment_author_url varchar(200) NOT NULL default '',
<   comment_author_IP varchar(100) NOT NULL default '',
<   comment_date datetime NOT NULL default '0000-00-00 00:00:00',
<   comment_date_gmt datetime NOT NULL default '0000-00-00 00:00:00',
<   comment_content text NOT NULL,
<   comment_karma int(11) NOT NULL default '0',
<   comment_approved varchar(20) NOT NULL default '1',
<   comment_agent varchar(255) NOT NULL default '',
<   comment_type varchar(20) NOT NULL default '',
<   comment_parent bigint(20) unsigned NOT NULL default '0',
<   user_id bigint(20) unsigned NOT NULL default '0',
<   PRIMARY KEY  (comment_ID),
<   KEY comment_approved (comment_approved),
<   KEY comment_post_ID (comment_post_ID),
<   KEY comment_approved_date_gmt (comment_approved,comment_date_gmt),
<   KEY comment_date_gmt (comment_date_gmt),
<   KEY comment_parent (comment_parent)
< ) $charset_collate;
< CREATE TABLE $wpdb->links (
<   link_id bigint(20) unsigned NOT NULL auto_increment,
<   link_url varchar(255) NOT NULL default '',
<   link_name varchar(255) NOT NULL default '',
<   link_image varchar(255) NOT NULL default '',
<   link_target varchar(25) NOT NULL default '',
<   link_description varchar(255) NOT NULL default '',
<   link_visible varchar(20) NOT NULL default 'Y',
<   link_owner bigint(20) unsigned NOT NULL default '1',
<   link_rating int(11) NOT NULL default '0',
<   link_updated datetime NOT NULL default '0000-00-00 00:00:00',
<   link_rel varchar(255) NOT NULL default '',
<   link_notes mediumtext NOT NULL,
<   link_rss varchar(255) NOT NULL default '',
<   PRIMARY KEY  (link_id),
<   KEY link_visible (link_visible)
< ) $charset_collate;
< CREATE TABLE $wpdb->options (
<   option_id bigint(20) unsigned NOT NULL auto_increment,
<   blog_id int(11) NOT NULL default '0',
<   option_name varchar(64) NOT NULL default '',
<   option_value longtext NOT NULL,
<   autoload varchar(20) NOT NULL default 'yes',
<   PRIMARY KEY  (option_id),
<   UNIQUE KEY option_name (option_name)
< ) $charset_collate;
< CREATE TABLE $wpdb->postmeta (
<   meta_id bigint(20) unsigned NOT NULL auto_increment,
<   post_id bigint(20) unsigned NOT NULL default '0',
<   meta_key varchar(255) default NULL,
<   meta_value longtext,
<   PRIMARY KEY  (meta_id),
<   KEY post_id (post_id),
<   KEY meta_key (meta_key)
< ) $charset_collate;
< CREATE TABLE $wpdb->posts (
<   ID bigint(20) unsigned NOT NULL auto_increment,
<   post_author bigint(20) unsigned NOT NULL default '0',
<   post_date datetime NOT NULL default '0000-00-00 00:00:00',
<   post_date_gmt datetime NOT NULL default '0000-00-00 00:00:00',
<   post_content longtext NOT NULL,
<   post_title text NOT NULL,
<   post_excerpt text NOT NULL,
<   post_status varchar(20) NOT NULL default 'publish',
<   comment_status varchar(20) NOT NULL default 'open',
<   ping_status varchar(20) NOT NULL default 'open',
<   post_password varchar(20) NOT NULL default '',
<   post_name varchar(200) NOT NULL default '',
<   to_ping text NOT NULL,
<   pinged text NOT NULL,
<   post_modified datetime NOT NULL default '0000-00-00 00:00:00',
<   post_modified_gmt datetime NOT NULL default '0000-00-00 00:00:00',
<   post_content_filtered text NOT NULL,
<   post_parent bigint(20) unsigned NOT NULL default '0',
<   guid varchar(255) NOT NULL default '',
<   menu_order int(11) NOT NULL default '0',
<   post_type varchar(20) NOT NULL default 'post',
<   post_mime_type varchar(100) NOT NULL default '',
<   comment_count bigint(20) NOT NULL default '0',
<   PRIMARY KEY  (ID),
<   KEY post_name (post_name),
<   KEY type_status_date (post_type,post_status,post_date,ID),
<   KEY post_parent (post_parent),
<   KEY post_author (post_author)
< ) $charset_collate;\n";
< 
< 	// Single site users table. The multisite flavor of the users table is handled below.
< 	$users_single_table = "CREATE TABLE $wpdb->users (
<   ID bigint(20) unsigned NOT NULL auto_increment,
<   user_login varchar(60) NOT NULL default '',
<   user_pass varchar(64) NOT NULL default '',
<   user_nicename varchar(50) NOT NULL default '',
<   user_email varchar(100) NOT NULL default '',
<   user_url varchar(100) NOT NULL default '',
<   user_registered datetime NOT NULL default '0000-00-00 00:00:00',
<   user_activation_key varchar(60) NOT NULL default '',
<   user_status int(11) NOT NULL default '0',
<   display_name varchar(250) NOT NULL default '',
<   PRIMARY KEY  (ID),
<   KEY user_login_key (user_login),
<   KEY user_nicename (user_nicename)
< ) $charset_collate;\n";
< 
< 	// Multisite users table
< 	$users_multi_table = "CREATE TABLE $wpdb->users (
<   ID bigint(20) unsigned NOT NULL auto_increment,
<   user_login varchar(60) NOT NULL default '',
<   user_pass varchar(64) NOT NULL default '',
<   user_nicename varchar(50) NOT NULL default '',
<   user_email varchar(100) NOT NULL default '',
<   user_url varchar(100) NOT NULL default '',
<   user_registered datetime NOT NULL default '0000-00-00 00:00:00',
<   user_activation_key varchar(60) NOT NULL default '',
<   user_status int(11) NOT NULL default '0',
<   display_name varchar(250) NOT NULL default '',
<   spam tinyint(2) NOT NULL default '0',
<   deleted tinyint(2) NOT NULL default '0',
<   PRIMARY KEY  (ID),
<   KEY user_login_key (user_login),
<   KEY user_nicename (user_nicename)
< ) $charset_collate;\n";
< 
< 	// usermeta
< 	$usermeta_table = "CREATE TABLE $wpdb->usermeta (
<   umeta_id bigint(20) unsigned NOT NULL auto_increment,
<   user_id bigint(20) unsigned NOT NULL default '0',
<   meta_key varchar(255) default NULL,
<   meta_value longtext,
<   PRIMARY KEY  (umeta_id),
<   KEY user_id (user_id),
<   KEY meta_key (meta_key)
< ) $charset_collate;\n";
< 
< 	// Global tables
< 	if ( $is_multisite )
< 		$global_tables = $users_multi_table . $usermeta_table;
< 	else
< 		$global_tables = $users_single_table . $usermeta_table;
< 
< 	// Multisite global tables.
< 	$ms_global_tables = "CREATE TABLE $wpdb->blogs (
<   blog_id bigint(20) NOT NULL auto_increment,
<   site_id bigint(20) NOT NULL default '0',
<   domain varchar(200) NOT NULL default '',
<   path varchar(100) NOT NULL default '',
<   registered datetime NOT NULL default '0000-00-00 00:00:00',
<   last_updated datetime NOT NULL default '0000-00-00 00:00:00',
<   public tinyint(2) NOT NULL default '1',
<   archived enum('0','1') NOT NULL default '0',
<   mature tinyint(2) NOT NULL default '0',
<   spam tinyint(2) NOT NULL default '0',
<   deleted tinyint(2) NOT NULL default '0',
<   lang_id int(11) NOT NULL default '0',
<   PRIMARY KEY  (blog_id),
<   KEY domain (domain(50),path(5)),
<   KEY lang_id (lang_id)
< ) $charset_collate;
< CREATE TABLE $wpdb->blog_versions (
<   blog_id bigint(20) NOT NULL default '0',
<   db_version varchar(20) NOT NULL default '',
<   last_updated datetime NOT NULL default '0000-00-00 00:00:00',
<   PRIMARY KEY  (blog_id),
<   KEY db_version (db_version)
< ) $charset_collate;
< CREATE TABLE $wpdb->registration_log (
<   ID bigint(20) NOT NULL auto_increment,
<   email varchar(255) NOT NULL default '',
<   IP varchar(30) NOT NULL default '',
<   blog_id bigint(20) NOT NULL default '0',
<   date_registered datetime NOT NULL default '0000-00-00 00:00:00',
<   PRIMARY KEY  (ID),
<   KEY IP (IP)
< ) $charset_collate;
< CREATE TABLE $wpdb->site (
<   id bigint(20) NOT NULL auto_increment,
<   domain varchar(200) NOT NULL default '',
<   path varchar(100) NOT NULL default '',
<   PRIMARY KEY  (id),
<   KEY domain (domain,path)
< ) $charset_collate;
< CREATE TABLE $wpdb->sitemeta (
<   meta_id bigint(20) NOT NULL auto_increment,
<   site_id bigint(20) NOT NULL default '0',
<   meta_key varchar(255) default NULL,
<   meta_value longtext,
<   PRIMARY KEY  (meta_id),
<   KEY meta_key (meta_key),
<   KEY site_id (site_id)
< ) $charset_collate;
< CREATE TABLE $wpdb->signups (
<   domain varchar(200) NOT NULL default '',
<   path varchar(100) NOT NULL default '',
<   title longtext NOT NULL,
<   user_login varchar(60) NOT NULL default '',
<   user_email varchar(100) NOT NULL default '',
<   registered datetime NOT NULL default '0000-00-00 00:00:00',
<   activated datetime NOT NULL default '0000-00-00 00:00:00',
<   active tinyint(1) NOT NULL default '0',
<   activation_key varchar(50) NOT NULL default '',
<   meta longtext,
<   KEY activation_key (activation_key),
<   KEY domain (domain)
< ) $charset_collate;";
< 
< 	switch ( $scope ) {
< 		case 'blog' :
< 			$queries = $blog_tables;
< 			break;
< 		case 'global' :
< 			$queries = $global_tables;
< 			if ( $is_multisite )
< 				$queries .= $ms_global_tables;
< 			break;
< 		case 'ms_global' :
< 			$queries = $ms_global_tables;
< 			break;
< 		default:
< 		case 'all' :
< 			$queries = $global_tables . $blog_tables;
< 			if ( $is_multisite )
< 				$queries .= $ms_global_tables;
< 			break;
< 	}
< 
< 	if ( isset( $old_blog_id ) )
< 		$wpdb->set_blog_id( $old_blog_id );
< 
< 	return $queries;
< }
< 
< // Populate for back compat.
< $wp_queries = wp_get_db_schema( 'all' );
< 
< /**
<  * Create WordPress options and set the default values.
<  *
<  * @since 1.5.0
<  * @uses $wpdb
<  * @uses $wp_db_version
<  */
< function populate_options() {
< 	global $wpdb, $wp_db_version, $current_site, $wp_current_db_version;
< 
< 	$guessurl = wp_guess_url();
< 
< 	do_action('populate_options');
< 
< 	if ( ini_get('safe_mode') ) {
< 		// Safe mode can break mkdir() so use a flat structure by default.
< 		$uploads_use_yearmonth_folders = 0;
< 	} else {
< 		$uploads_use_yearmonth_folders = 1;
< 	}
< 
< 	$template = WP_DEFAULT_THEME;
< 	// If default theme is a child theme, we need to get its template
< 	foreach ( (array) get_themes() as $theme ) {
< 		if ( WP_DEFAULT_THEME == $theme['Stylesheet'] ) {
< 			$template = $theme['Template'];
< 			break;
< 		}
< 	}
< 
< 	$options = array(
< 	'siteurl' => $guessurl,
< 	'blogname' => __('My Site'),
< 	/* translators: blog tagline */
< 	'blogdescription' => __('Just another WordPress site'),
< 	'users_can_register' => 0,
< 	'admin_email' => 'you@example.com',
< 	'start_of_week' => 1,
< 	'use_balanceTags' => 0,
< 	'use_smilies' => 1,
< 	'require_name_email' => 1,
< 	'comments_notify' => 1,
< 	'posts_per_rss' => 10,
< 	'rss_use_excerpt' => 0,
< 	'mailserver_url' => 'mail.example.com',
< 	'mailserver_login' => 'login@example.com',
< 	'mailserver_pass' => 'password',
< 	'mailserver_port' => 110,
< 	'default_category' => 1,
< 	'default_comment_status' => 'open',
< 	'default_ping_status' => 'open',
< 	'default_pingback_flag' => 1,
< 	'default_post_edit_rows' => 20,
< 	'posts_per_page' => 10,
< 	/* translators: default date format, see http://php.net/date */
< 	'date_format' => __('F j, Y'),
< 	/* translators: default time format, see http://php.net/date */
< 	'time_format' => __('g:i a'),
< 	/* translators: links last updated date format, see http://php.net/date */
< 	'links_updated_date_format' => __('F j, Y g:i a'),
< 	'links_recently_updated_prepend' => '<em>',
< 	'links_recently_updated_append' => '</em>',
< 	'links_recently_updated_time' => 120,
< 	'comment_moderation' => 0,
< 	'moderation_notify' => 1,
< 	'permalink_structure' => '',
< 	'gzipcompression' => 0,
< 	'hack_file' => 0,
< 	'blog_charset' => 'UTF-8',
< 	'moderation_keys' => '',
< 	'active_plugins' => array(),
< 	'home' => $guessurl,
< 	'category_base' => '',
< 	'ping_sites' => 'http://rpc.pingomatic.com/',
< 	'advanced_edit' => 0,
< 	'comment_max_links' => 2,
< 	'gmt_offset' => date('Z') / 3600,
< 
< 	// 1.5
< 	'default_email_category' => 1,
< 	'recently_edited' => '',
< 	'template' => $template,
< 	'stylesheet' => WP_DEFAULT_THEME,
< 	'comment_whitelist' => 1,
< 	'blacklist_keys' => '',
< 	'comment_registration' => 0,
< 	'rss_language' => 'en',
< 	'html_type' => 'text/html',
< 
< 	// 1.5.1
< 	'use_trackback' => 0,
< 
< 	// 2.0
< 	'default_role' => 'subscriber',
< 	'db_version' => $wp_db_version,
< 
< 	// 2.0.1
< 	'uploads_use_yearmonth_folders' => $uploads_use_yearmonth_folders,
< 	'upload_path' => '',
< 
< 	// 2.1
< 	'blog_public' => '1',
< 	'default_link_category' => 2,
< 	'show_on_front' => 'posts',
< 
< 	// 2.2
< 	'tag_base' => '',
< 
< 	// 2.5
< 	'show_avatars' => '1',
< 	'avatar_rating' => 'G',
< 	'upload_url_path' => '',
< 	'thumbnail_size_w' => 150,
< 	'thumbnail_size_h' => 150,
< 	'thumbnail_crop' => 1,
< 	'medium_size_w' => 300,
< 	'medium_size_h' => 300,
< 
< 	// 2.6
< 	'avatar_default' => 'mystery',
< 	'enable_app' => 0,
< 	'enable_xmlrpc' => 0,
< 
< 	// 2.7
< 	'large_size_w' => 1024,
< 	'large_size_h' => 1024,
< 	'image_default_link_type' => 'file',
< 	'image_default_size' => '',
< 	'image_default_align' => '',
< 	'close_comments_for_old_posts' => 0,
< 	'close_comments_days_old' => 14,
< 	'thread_comments' => 1,
< 	'thread_comments_depth' => 5,
< 	'page_comments' => 0,
< 	'comments_per_page' => 50,
< 	'default_comments_page' => 'newest',
< 	'comment_order' => 'asc',
< 	'sticky_posts' => array(),
< 	'widget_categories' => array(),
< 	'widget_text' => array(),
< 	'widget_rss' => array(),
< 
< 	// 2.8
< 	'timezone_string' => '',
< 
< 	// 2.9
< 	'embed_autourls' => 1,
< 	'embed_size_w' => '',
< 	'embed_size_h' => 600,
< 
< 	// 3.0
< 	'page_for_posts' => 0,
< 	'page_on_front' => 0,
< 
< 	// 3.1
< 	'default_post_format' => 0,
< 	);
< 
< 	// 3.3
< 	if ( ! is_multisite() ) {
< 		$options['initial_db_version'] = ! empty( $wp_current_db_version ) && $wp_current_db_version < $wp_db_version
< 			? $wp_current_db_version : $wp_db_version;
< 	}
< 
< 	// 3.0 multisite
< 	if ( is_multisite() ) {
< 		/* translators: blog tagline */
< 		$options[ 'blogdescription' ] = sprintf(__('Just another %s site'), $current_site->site_name );
< 		$options[ 'permalink_structure' ] = '/%year%/%monthnum%/%day%/%postname%/';
< 	}
< 
< 	// Set autoload to no for these options
< 	$fat_options = array( 'moderation_keys', 'recently_edited', 'blacklist_keys' );
< 
< 	$existing_options = $wpdb->get_col("SELECT option_name FROM $wpdb->options");
< 
< 	$insert = '';
< 	foreach ( $options as $option => $value ) {
< 		if ( in_array($option, $existing_options) )
< 			continue;
< 		if ( in_array($option, $fat_options) )
< 			$autoload = 'no';
< 		else
< 			$autoload = 'yes';
< 
< 		$option = $wpdb->escape($option);
< 		if ( is_array($value) )
< 			$value = serialize($value);
< 		$value = $wpdb->escape($value);
< 		if ( !empty($insert) )
< 			$insert .= ', ';
< 		$insert .= "('$option', '$value', '$autoload')";
< 	}
< 
< 	if ( !empty($insert) )
< 		$wpdb->query("INSERT INTO $wpdb->options (option_name, option_value, autoload) VALUES " . $insert);
< 
< 	// in case it is set, but blank, update "home"
< 	if ( !__get_option('home') ) update_option('home', $guessurl);
< 
< 	// Delete unused options
< 	$unusedoptions = array ('blodotgsping_url', 'bodyterminator', 'emailtestonly', 'phoneemail_separator', 'smilies_directory', 'subjectprefix', 'use_bbcode', 'use_blodotgsping', 'use_phoneemail', 'use_quicktags', 'use_weblogsping', 'weblogs_cache_file', 'use_preview', 'use_htmltrans', 'smilies_directory', 'fileupload_allowedusers', 'use_phoneemail', 'default_post_status', 'default_post_category', 'archive_mode', 'time_difference', 'links_minadminlevel', 'links_use_adminlevels', 'links_rating_type', 'links_rating_char', 'links_rating_ignore_zero', 'links_rating_single_image', 'links_rating_image0', 'links_rating_image1', 'links_rating_image2', 'links_rating_image3', 'links_rating_image4', 'links_rating_image5', 'links_rating_image6', 'links_rating_image7', 'links_rating_image8', 'links_rating_image9', 'weblogs_cacheminutes', 'comment_allowed_tags', 'search_engine_friendly_urls', 'default_geourl_lat', 'default_geourl_lon', 'use_default_geourl', 'weblogs_xml_url', 'new_users_can_blog', '_wpnonce', '_wp_http_referer', 'Update', 'action', 'rich_editing', 'autosave_interval', 'deactivated_plugins', 'can_compress_scripts', 'page_uris', 'update_core', 'update_plugins', 'update_themes', 'doing_cron', 'random_seed', 'rss_excerpt_length', 'secret', 'use_linksupdate', 'default_comment_status_page', 'wporg_popular_tags', 'what_to_show');
< 	foreach ( $unusedoptions as $option )
< 		delete_option($option);
< 
< 	// delete obsolete magpie stuff
< 	$wpdb->query("DELETE FROM $wpdb->options WHERE option_name REGEXP '^rss_[0-9a-f]{32}(_ts)?$'");
< }
< 
< /**
<  * Execute WordPress role creation for the various WordPress versions.
<  *
<  * @since 2.0.0
<  */
< function populate_roles() {
< 	populate_roles_160();
< 	populate_roles_210();
< 	populate_roles_230();
< 	populate_roles_250();
< 	populate_roles_260();
< 	populate_roles_270();
< 	populate_roles_280();
< 	populate_roles_300();
< }
< 
< /**
<  * Create the roles for WordPress 2.0
<  *
<  * @since 2.0.0
<  */
< function populate_roles_160() {
< 	// Add roles
< 
< 	// Dummy gettext calls to get strings in the catalog.
< 	/* translators: user role */
< 	_x('Administrator', 'User role');
< 	/* translators: user role */
< 	_x('Editor', 'User role');
< 	/* translators: user role */
< 	_x('Author', 'User role');
< 	/* translators: user role */
< 	_x('Contributor', 'User role');
< 	/* translators: user role */
< 	_x('Subscriber', 'User role');
< 
< 	add_role('administrator', 'Administrator');
< 	add_role('editor', 'Editor');
< 	add_role('author', 'Author');
< 	add_role('contributor', 'Contributor');
< 	add_role('subscriber', 'Subscriber');
< 
< 	// Add caps for Administrator role
< 	$role =& get_role('administrator');
< 	$role->add_cap('switch_themes');
< 	$role->add_cap('edit_themes');
< 	$role->add_cap('activate_plugins');
< 	$role->add_cap('edit_plugins');
< 	$role->add_cap('edit_users');
< 	$role->add_cap('edit_files');
< 	$role->add_cap('manage_options');
< 	$role->add_cap('moderate_comments');
< 	$role->add_cap('manage_categories');
< 	$role->add_cap('manage_links');
< 	$role->add_cap('upload_files');
< 	$role->add_cap('import');
< 	$role->add_cap('unfiltered_html');
< 	$role->add_cap('edit_posts');
< 	$role->add_cap('edit_others_posts');
< 	$role->add_cap('edit_published_posts');
< 	$role->add_cap('publish_posts');
< 	$role->add_cap('edit_pages');
< 	$role->add_cap('read');
< 	$role->add_cap('level_10');
< 	$role->add_cap('level_9');
< 	$role->add_cap('level_8');
< 	$role->add_cap('level_7');
< 	$role->add_cap('level_6');
< 	$role->add_cap('level_5');
< 	$role->add_cap('level_4');
< 	$role->add_cap('level_3');
< 	$role->add_cap('level_2');
< 	$role->add_cap('level_1');
< 	$role->add_cap('level_0');
< 
< 	// Add caps for Editor role
< 	$role =& get_role('editor');
< 	$role->add_cap('moderate_comments');
< 	$role->add_cap('manage_categories');
< 	$role->add_cap('manage_links');
< 	$role->add_cap('upload_files');
< 	$role->add_cap('unfiltered_html');
< 	$role->add_cap('edit_posts');
< 	$role->add_cap('edit_others_posts');
< 	$role->add_cap('edit_published_posts');
< 	$role->add_cap('publish_posts');
< 	$role->add_cap('edit_pages');
< 	$role->add_cap('read');
< 	$role->add_cap('level_7');
< 	$role->add_cap('level_6');
< 	$role->add_cap('level_5');
< 	$role->add_cap('level_4');
< 	$role->add_cap('level_3');
< 	$role->add_cap('level_2');
< 	$role->add_cap('level_1');
< 	$role->add_cap('level_0');
< 
< 	// Add caps for Author role
< 	$role =& get_role('author');
< 	$role->add_cap('upload_files');
< 	$role->add_cap('edit_posts');
< 	$role->add_cap('edit_published_posts');
< 	$role->add_cap('publish_posts');
< 	$role->add_cap('read');
< 	$role->add_cap('level_2');
< 	$role->add_cap('level_1');
< 	$role->add_cap('level_0');
< 
< 	// Add caps for Contributor role
< 	$role =& get_role('contributor');
< 	$role->add_cap('edit_posts');
< 	$role->add_cap('read');
< 	$role->add_cap('level_1');
< 	$role->add_cap('level_0');
< 
< 	// Add caps for Subscriber role
< 	$role =& get_role('subscriber');
< 	$role->add_cap('read');
< 	$role->add_cap('level_0');
< }
< 
< /**
<  * Create and modify WordPress roles for WordPress 2.1.
<  *
<  * @since 2.1.0
<  */
< function populate_roles_210() {
< 	$roles = array('administrator', 'editor');
< 	foreach ($roles as $role) {
< 		$role =& get_role($role);
< 		if ( empty($role) )
< 			continue;
< 
< 		$role->add_cap('edit_others_pages');
< 		$role->add_cap('edit_published_pages');
< 		$role->add_cap('publish_pages');
< 		$role->add_cap('delete_pages');
< 		$role->add_cap('delete_others_pages');
< 		$role->add_cap('delete_published_pages');
< 		$role->add_cap('delete_posts');
< 		$role->add_cap('delete_others_posts');
< 		$role->add_cap('delete_published_posts');
< 		$role->add_cap('delete_private_posts');
< 		$role->add_cap('edit_private_posts');
< 		$role->add_cap('read_private_posts');
< 		$role->add_cap('delete_private_pages');
< 		$role->add_cap('edit_private_pages');
< 		$role->add_cap('read_private_pages');
< 	}
< 
< 	$role =& get_role('administrator');
< 	if ( ! empty($role) ) {
< 		$role->add_cap('delete_users');
< 		$role->add_cap('create_users');
< 	}
< 
< 	$role =& get_role('author');
< 	if ( ! empty($role) ) {
< 		$role->add_cap('delete_posts');
< 		$role->add_cap('delete_published_posts');
< 	}
< 
< 	$role =& get_role('contributor');
< 	if ( ! empty($role) ) {
< 		$role->add_cap('delete_posts');
< 	}
< }
< 
< /**
<  * Create and modify WordPress roles for WordPress 2.3.
<  *
<  * @since 2.3.0
<  */
< function populate_roles_230() {
< 	$role =& get_role( 'administrator' );
< 
< 	if ( !empty( $role ) ) {
< 		$role->add_cap( 'unfiltered_upload' );
< 	}
< }
< 
< /**
<  * Create and modify WordPress roles for WordPress 2.5.
<  *
<  * @since 2.5.0
<  */
< function populate_roles_250() {
< 	$role =& get_role( 'administrator' );
< 
< 	if ( !empty( $role ) ) {
< 		$role->add_cap( 'edit_dashboard' );
< 	}
< }
< 
< /**
<  * Create and modify WordPress roles for WordPress 2.6.
<  *
<  * @since 2.6.0
<  */
< function populate_roles_260() {
< 	$role =& get_role( 'administrator' );
< 
< 	if ( !empty( $role ) ) {
< 		$role->add_cap( 'update_plugins' );
< 		$role->add_cap( 'delete_plugins' );
< 	}
< }
< 
< /**
<  * Create and modify WordPress roles for WordPress 2.7.
<  *
<  * @since 2.7.0
<  */
< function populate_roles_270() {
< 	$role =& get_role( 'administrator' );
< 
< 	if ( !empty( $role ) ) {
< 		$role->add_cap( 'install_plugins' );
< 		$role->add_cap( 'update_themes' );
< 	}
< }
< 
< /**
<  * Create and modify WordPress roles for WordPress 2.8.
<  *
<  * @since 2.8.0
<  */
< function populate_roles_280() {
< 	$role =& get_role( 'administrator' );
< 
< 	if ( !empty( $role ) ) {
< 		$role->add_cap( 'install_themes' );
< 	}
< }
< 
< /**
<  * Create and modify WordPress roles for WordPress 3.0.
<  *
<  * @since 3.0.0
<  */
< function populate_roles_300() {
< 	$role =& get_role( 'administrator' );
< 
< 	if ( !empty( $role ) ) {
< 		$role->add_cap( 'update_core' );
< 		$role->add_cap( 'list_users' );
< 		$role->add_cap( 'remove_users' );
< 		$role->add_cap( 'add_users' );
< 		$role->add_cap( 'promote_users' );
< 		$role->add_cap( 'edit_theme_options' );
< 		$role->add_cap( 'delete_themes' );
< 		$role->add_cap( 'export' );
< 	}
< }
< 
< /**
<  * Install Network.
<  *
<  * @since 3.0.0
<  *
<  */
< if ( !function_exists( 'install_network' ) ) :
< function install_network() {
< 	if ( ! defined( 'WP_INSTALLING_NETWORK' ) )
< 		define( 'WP_INSTALLING_NETWORK', true );
< 
< 	dbDelta( wp_get_db_schema( 'global' ) );
< }
< endif;
< 
< /**
<  * populate network settings
<  *
<  * @since 3.0.0
<  *
<  * @param int $network_id id of network to populate
<  * @return bool|WP_Error True on success, or WP_Error on warning (with the install otherwise successful,
<  * 	so the error code must be checked) or failure.
<  */
< function populate_network( $network_id = 1, $domain = '', $email = '', $site_name = '', $path = '/', $subdomain_install = false ) {
< 	global $wpdb, $current_site, $wp_db_version, $wp_rewrite;
< 
< 	$errors = new WP_Error();
< 	if ( '' == $domain )
< 		$errors->add( 'empty_domain', __( 'You must provide a domain name.' ) );
< 	if ( '' == $site_name )
< 		$errors->add( 'empty_sitename', __( 'You must provide a name for your network of sites.' ) );
< 
< 	// check for network collision
< 	if ( $network_id == $wpdb->get_var( $wpdb->prepare( "SELECT id FROM $wpdb->site WHERE id = %d", $network_id ) ) )
< 		$errors->add( 'siteid_exists', __( 'The network already exists.' ) );
< 
< 	$site_user = get_user_by( 'email', $email );
< 	if ( ! is_email( $email ) )
< 		$errors->add( 'invalid_email', __( 'You must provide a valid e-mail address.' ) );
< 
< 	if ( $errors->get_error_code() )
< 		return $errors;
< 
< 	// set up site tables
< 	$template = get_option( 'template' );
< 	$stylesheet = get_option( 'stylesheet' );
< 	$allowed_themes = array( $stylesheet => true );
< 	if ( $template != $stylesheet )
< 		$allowed_themes[ $template ] = true;
< 	if ( WP_DEFAULT_THEME != $stylesheet && WP_DEFAULT_THEME != $template )
< 		$allowed_themes[ WP_DEFAULT_THEME ] = true;
< 
< 	if ( 1 == $network_id ) {
< 		$wpdb->insert( $wpdb->site, array( 'domain' => $domain, 'path' => $path ) );
< 		$network_id = $wpdb->insert_id;
< 	} else {
< 		$wpdb->insert( $wpdb->site, array( 'domain' => $domain, 'path' => $path, 'id' => $network_id ) );
< 	}
< 
< 	if ( !is_multisite() ) {
< 		$site_admins = array( $site_user->user_login );
< 		$users = get_users( array( 'fields' => array( 'ID', 'user_login' ) ) );
< 		if ( $users ) {
< 			foreach ( $users as $user ) {
< 				if ( is_super_admin( $user->ID ) && !in_array( $user->user_login, $site_admins ) )
< 					$site_admins[] = $user->user_login;
< 			}
< 		}
< 	} else {
< 		$site_admins = get_site_option( 'site_admins' );
< 	}
< 
< 	$welcome_email = __( 'Dear User,
< 
< Your new SITE_NAME site has been successfully set up at:
< BLOG_URL
< 
< You can log in to the administrator account with the following information:
< Username: USERNAME
< Password: PASSWORD
< Log in here: BLOG_URLwp-login.php
< 
< We hope you enjoy your new site. Thanks!
< 
< --The Team @ SITE_NAME' );
< 
< 	$sitemeta = array(
< 		'site_name' => $site_name,
< 		'admin_email' => $site_user->user_email,
< 		'admin_user_id' => $site_user->ID,
< 		'registration' => 'none',
< 		'upload_filetypes' => 'jpg jpeg png gif mp3 mov avi wmv midi mid pdf',
< 		'blog_upload_space' => 10,
< 		'fileupload_maxk' => 1500,
< 		'site_admins' => $site_admins,
< 		'allowedthemes' => $allowed_themes,
< 		'illegal_names' => array( 'www', 'web', 'root', 'admin', 'main', 'invite', 'administrator', 'files' ),
< 		'wpmu_upgrade_site' => $wp_db_version,
< 		'welcome_email' => $welcome_email,
< 		'first_post' => __( 'Welcome to <a href="SITE_URL">SITE_NAME</a>. This is your first post. Edit or delete it, then start blogging!' ),
< 		// @todo - network admins should have a method of editing the network siteurl (used for cookie hash)
< 		'siteurl' => get_option( 'siteurl' ) . '/',
< 		'add_new_users' => '0',
< 		'upload_space_check_disabled' => '0',
< 		'subdomain_install' => intval( $subdomain_install ),
< 		'global_terms_enabled' => global_terms_enabled() ? '1' : '0',
< 		'initial_db_version' => get_option( 'initial_db_version' ),
< 		'active_sitewide_plugins' => array(),
< 	);
< 	if ( ! $subdomain_install )
< 		$sitemeta['illegal_names'][] = 'blog';
< 
< 	$insert = '';
< 	foreach ( $sitemeta as $meta_key => $meta_value ) {
< 		$meta_key = $wpdb->escape( $meta_key );
< 		if ( is_array( $meta_value ) )
< 			$meta_value = serialize( $meta_value );
< 		$meta_value = $wpdb->escape( $meta_value );
< 		if ( !empty( $insert ) )
< 			$insert .= ', ';
< 		$insert .= "( $network_id, '$meta_key', '$meta_value')";
< 	}
< 	$wpdb->query( "INSERT INTO $wpdb->sitemeta ( site_id, meta_key, meta_value ) VALUES " . $insert );
< 
< 	$current_site->domain = $domain;
< 	$current_site->path = $path;
< 	$current_site->site_name = ucfirst( $domain );
< 
< 	if ( !is_multisite() ) {
< 		$wpdb->insert( $wpdb->blogs, array( 'site_id' => $network_id, 'domain' => $domain, 'path' => $path, 'registered' => current_time( 'mysql' ) ) );
< 		$blog_id = $wpdb->insert_id;
< 		update_user_meta( $site_user->ID, 'source_domain', $domain );
< 		update_user_meta( $site_user->ID, 'primary_blog', $blog_id );
< 		if ( !$upload_path = get_option( 'upload_path' ) ) {
< 			$upload_path = substr( WP_CONTENT_DIR, strlen( ABSPATH ) ) . '/uploads';
< 			update_option( 'upload_path', $upload_path );
< 		}
< 		update_option( 'fileupload_url', get_option( 'siteurl' ) . '/' . $upload_path );
< 	}
< 
< 	if ( $subdomain_install )
< 		update_option( 'permalink_structure', '/%year%/%monthnum%/%day%/%postname%/');
< 	else
< 		update_option( 'permalink_structure', '/blog/%year%/%monthnum%/%day%/%postname%/');
< 
< 	$wp_rewrite->flush_rules();
< 
< 	if ( $subdomain_install ) {
< 		$vhost_ok = false;
< 		$errstr = '';
< 		$hostname = substr( md5( time() ), 0, 6 ) . '.' . $domain; // Very random hostname!
< 		$page = wp_remote_get( 'http://' . $hostname, array( 'timeout' => 5, 'httpversion' => '1.1' ) );
< 		if ( is_wp_error( $page ) )
< 			$errstr = $page->get_error_message();
< 		elseif ( 200 == wp_remote_retrieve_response_code( $page ) )
< 				$vhost_ok = true;
< 
< 		if ( ! $vhost_ok ) {
< 			$msg = '<p><strong>' . __( 'Warning! Wildcard DNS may not be configured correctly!' ) . '</strong></p>';
< 			$msg .= '<p>' . sprintf( __( 'The installer attempted to contact a random hostname (<code>%1$s</code>) on your domain.' ), $hostname );
< 			if ( ! empty ( $errstr ) )
< 				$msg .= ' ' . sprintf( __( 'This resulted in an error message: %s' ), '<code>' . $errstr . '</code>' );
< 			$msg .= '</p>';
< 			$msg .= '<p>' . __( 'To use a subdomain configuration, you must have a wildcard entry in your DNS. This usually means adding a <code>*</code> hostname record pointing at your web server in your DNS configuration tool.' ) . '</p>';
< 			$msg .= '<p>' . __( 'You can still use your site but any subdomain you create may not be accessible. If you know your DNS is correct, ignore this message.' ) . '</p>';
< 			return new WP_Error( 'no_wildcard_dns', $msg );
< 		}
< 	}
< 
< 	return true;
< }
< 
< ?>
---
> <?php
> /**
>  * WordPress Administration Scheme API
>  *
>  * Here we keep the DB structure and option values.
>  *
>  * @package WordPress
>  * @subpackage Administration
>  */
> 
> // Declare these as global in case schema.php is included from a function.
> global $wpdb, $wp_queries, $charset_collate;
> 
> /**
>  * The database character collate.
>  * @var string
>  * @global string
>  * @name $charset_collate
>  */
> $charset_collate = '';
> 
> if ( ! empty( $wpdb->charset ) )
> 	$charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
> if ( ! empty( $wpdb->collate ) )
> 	$charset_collate .= " COLLATE $wpdb->collate";
> 
> /**
>  * Retrieve the SQL for creating database tables.
>  *
>  * @since 3.3.0
>  *
>  * @param string $scope Optional. The tables for which to retrieve SQL. Can be all, global, ms_global, or blog tables. Defaults to all.
>  * @param int $blog_id Optional. The blog ID for which to retrieve SQL.  Default is the current blog ID.
>  * @return string The SQL needed to create the requested tables.
>  */
> function wp_get_db_schema( $scope = 'all', $blog_id = null ) {
> 	global $wpdb;
> 
> 	$charset_collate = '';
> 
> 	if ( ! empty($wpdb->charset) )
> 		$charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
> 	if ( ! empty($wpdb->collate) )
> 		$charset_collate .= " COLLATE $wpdb->collate";
> 
> 	if ( $blog_id && $blog_id != $wpdb->blogid )
> 		$old_blog_id = $wpdb->set_blog_id( $blog_id );
> 
> 	// Engage multisite if in the middle of turning it on from network.php.
> 	$is_multisite = is_multisite() || ( defined( 'WP_INSTALLING_NETWORK' ) && WP_INSTALLING_NETWORK );
> 
> 	// Blog specific tables.
> 	$blog_tables = "CREATE TABLE $wpdb->terms (
>  term_id bigint(20) unsigned NOT NULL auto_increment,
>  name varchar(200) NOT NULL default '',
>  slug varchar(200) NOT NULL default '',
>  term_group bigint(10) NOT NULL default 0,
>  PRIMARY KEY  (term_id),
>  UNIQUE KEY slug (slug),
>  KEY name (name)
> ) $charset_collate;
> CREATE TABLE $wpdb->term_taxonomy (
>  term_taxonomy_id bigint(20) unsigned NOT NULL auto_increment,
>  term_id bigint(20) unsigned NOT NULL default 0,
>  taxonomy varchar(32) NOT NULL default '',
>  description longtext NOT NULL,
>  parent bigint(20) unsigned NOT NULL default 0,
>  count bigint(20) NOT NULL default 0,
>  PRIMARY KEY  (term_taxonomy_id),
>  UNIQUE KEY term_id_taxonomy (term_id,taxonomy),
>  KEY taxonomy (taxonomy)
> ) $charset_collate;
> CREATE TABLE $wpdb->term_relationships (
>  object_id bigint(20) unsigned NOT NULL default 0,
>  term_taxonomy_id bigint(20) unsigned NOT NULL default 0,
>  term_order int(11) NOT NULL default 0,
>  PRIMARY KEY  (object_id,term_taxonomy_id),
>  KEY term_taxonomy_id (term_taxonomy_id)
> ) $charset_collate;
> CREATE TABLE $wpdb->commentmeta (
>   meta_id bigint(20) unsigned NOT NULL auto_increment,
>   comment_id bigint(20) unsigned NOT NULL default '0',
>   meta_key varchar(255) default NULL,
>   meta_value longtext,
>   PRIMARY KEY  (meta_id),
>   KEY comment_id (comment_id),
>   KEY meta_key (meta_key)
> ) $charset_collate;
> CREATE TABLE $wpdb->comments (
>   comment_ID bigint(20) unsigned NOT NULL auto_increment,
>   comment_post_ID bigint(20) unsigned NOT NULL default '0',
>   comment_author tinytext NOT NULL,
>   comment_author_email varchar(100) NOT NULL default '',
>   comment_author_url varchar(200) NOT NULL default '',
>   comment_author_IP varchar(100) NOT NULL default '',
>   comment_date datetime NOT NULL default '0000-00-00 00:00:00',
>   comment_date_gmt datetime NOT NULL default '0000-00-00 00:00:00',
>   comment_content text NOT NULL,
>   comment_karma int(11) NOT NULL default '0',
>   comment_approved varchar(20) NOT NULL default '1',
>   comment_agent varchar(255) NOT NULL default '',
>   comment_type varchar(20) NOT NULL default '',
>   comment_parent bigint(20) unsigned NOT NULL default '0',
>   user_id bigint(20) unsigned NOT NULL default '0',
>   PRIMARY KEY  (comment_ID),
>   KEY comment_approved (comment_approved),
>   KEY comment_post_ID (comment_post_ID),
>   KEY comment_approved_date_gmt (comment_approved,comment_date_gmt),
>   KEY comment_date_gmt (comment_date_gmt),
>   KEY comment_parent (comment_parent)
> ) $charset_collate;
> CREATE TABLE $wpdb->links (
>   link_id bigint(20) unsigned NOT NULL auto_increment,
>   link_url varchar(255) NOT NULL default '',
>   link_name varchar(255) NOT NULL default '',
>   link_image varchar(255) NOT NULL default '',
>   link_target varchar(25) NOT NULL default '',
>   link_description varchar(255) NOT NULL default '',
>   link_visible varchar(20) NOT NULL default 'Y',
>   link_owner bigint(20) unsigned NOT NULL default '1',
>   link_rating int(11) NOT NULL default '0',
>   link_updated datetime NOT NULL default '0000-00-00 00:00:00',
>   link_rel varchar(255) NOT NULL default '',
>   link_notes mediumtext NOT NULL,
>   link_rss varchar(255) NOT NULL default '',
>   PRIMARY KEY  (link_id),
>   KEY link_visible (link_visible)
> ) $charset_collate;
> CREATE TABLE $wpdb->options (
>   option_id bigint(20) unsigned NOT NULL auto_increment,
>   blog_id int(11) NOT NULL default '0',
>   option_name varchar(64) NOT NULL default '',
>   option_value longtext NOT NULL,
>   autoload varchar(20) NOT NULL default 'yes',
>   PRIMARY KEY  (option_id),
>   UNIQUE KEY option_name (option_name)
> ) $charset_collate;
> CREATE TABLE $wpdb->postmeta (
>   meta_id bigint(20) unsigned NOT NULL auto_increment,
>   post_id bigint(20) unsigned NOT NULL default '0',
>   meta_key varchar(255) default NULL,
>   meta_value longtext,
>   PRIMARY KEY  (meta_id),
>   KEY post_id (post_id),
>   KEY meta_key (meta_key)
> ) $charset_collate;
> CREATE TABLE $wpdb->posts (
>   ID bigint(20) unsigned NOT NULL auto_increment,
>   post_author bigint(20) unsigned NOT NULL default '0',
>   post_date datetime NOT NULL default '0000-00-00 00:00:00',
>   post_date_gmt datetime NOT NULL default '0000-00-00 00:00:00',
>   post_content longtext NOT NULL,
>   post_title text NOT NULL,
>   post_excerpt text NOT NULL,
>   post_status varchar(20) NOT NULL default 'publish',
>   comment_status varchar(20) NOT NULL default 'open',
>   ping_status varchar(20) NOT NULL default 'open',
>   post_password varchar(20) NOT NULL default '',
>   post_name varchar(200) NOT NULL default '',
>   to_ping text NOT NULL,
>   pinged text NOT NULL,
>   post_modified datetime NOT NULL default '0000-00-00 00:00:00',
>   post_modified_gmt datetime NOT NULL default '0000-00-00 00:00:00',
>   post_content_filtered text NOT NULL,
>   post_parent bigint(20) unsigned NOT NULL default '0',
>   guid varchar(255) NOT NULL default '',
>   menu_order int(11) NOT NULL default '0',
>   post_type varchar(20) NOT NULL default 'post',
>   post_mime_type varchar(100) NOT NULL default '',
>   comment_count bigint(20) NOT NULL default '0',
>   PRIMARY KEY  (ID),
>   KEY post_name (post_name),
>   KEY type_status_date (post_type,post_status,post_date,ID),
>   KEY post_parent (post_parent),
>   KEY post_author (post_author)
> ) $charset_collate;\n";
> 
> 	// Single site users table. The multisite flavor of the users table is handled below.
> 	$users_single_table = "CREATE TABLE $wpdb->users (
>   ID bigint(20) unsigned NOT NULL auto_increment,
>   user_login varchar(60) NOT NULL default '',
>   user_pass varchar(64) NOT NULL default '',
>   user_nicename varchar(50) NOT NULL default '',
>   user_email varchar(100) NOT NULL default '',
>   user_url varchar(100) NOT NULL default '',
>   user_registered datetime NOT NULL default '0000-00-00 00:00:00',
>   user_activation_key varchar(60) NOT NULL default '',
>   user_status int(11) NOT NULL default '0',
>   display_name varchar(250) NOT NULL default '',
>   PRIMARY KEY  (ID),
>   KEY user_login_key (user_login),
>   KEY user_nicename (user_nicename)
> ) $charset_collate;\n";
> 
> 	// Multisite users table
> 	$users_multi_table = "CREATE TABLE $wpdb->users (
>   ID bigint(20) unsigned NOT NULL auto_increment,
>   user_login varchar(60) NOT NULL default '',
>   user_pass varchar(64) NOT NULL default '',
>   user_nicename varchar(50) NOT NULL default '',
>   user_email varchar(100) NOT NULL default '',
>   user_url varchar(100) NOT NULL default '',
>   user_registered datetime NOT NULL default '0000-00-00 00:00:00',
>   user_activation_key varchar(60) NOT NULL default '',
>   user_status int(11) NOT NULL default '0',
>   display_name varchar(250) NOT NULL default '',
>   spam tinyint(2) NOT NULL default '0',
>   deleted tinyint(2) NOT NULL default '0',
>   PRIMARY KEY  (ID),
>   KEY user_login_key (user_login),
>   KEY user_nicename (user_nicename)
> ) $charset_collate;\n";
> 
> 	// usermeta
> 	$usermeta_table = "CREATE TABLE $wpdb->usermeta (
>   umeta_id bigint(20) unsigned NOT NULL auto_increment,
>   user_id bigint(20) unsigned NOT NULL default '0',
>   meta_key varchar(255) default NULL,
>   meta_value longtext,
>   PRIMARY KEY  (umeta_id),
>   KEY user_id (user_id),
>   KEY meta_key (meta_key)
> ) $charset_collate;\n";
> 
> 	// Global tables
> 	if ( $is_multisite )
> 		$global_tables = $users_multi_table . $usermeta_table;
> 	else
> 		$global_tables = $users_single_table . $usermeta_table;
> 
> 	// Multisite global tables.
> 	$ms_global_tables = "CREATE TABLE $wpdb->blogs (
>   blog_id bigint(20) NOT NULL auto_increment,
>   site_id bigint(20) NOT NULL default '0',
>   domain varchar(200) NOT NULL default '',
>   path varchar(100) NOT NULL default '',
>   registered datetime NOT NULL default '0000-00-00 00:00:00',
>   last_updated datetime NOT NULL default '0000-00-00 00:00:00',
>   public tinyint(2) NOT NULL default '1',
>   archived enum('0','1') NOT NULL default '0',
>   mature tinyint(2) NOT NULL default '0',
>   spam tinyint(2) NOT NULL default '0',
>   deleted tinyint(2) NOT NULL default '0',
>   lang_id int(11) NOT NULL default '0',
>   PRIMARY KEY  (blog_id),
>   KEY domain (domain(50),path(5)),
>   KEY lang_id (lang_id)
> ) $charset_collate;
> CREATE TABLE $wpdb->blog_versions (
>   blog_id bigint(20) NOT NULL default '0',
>   db_version varchar(20) NOT NULL default '',
>   last_updated datetime NOT NULL default '0000-00-00 00:00:00',
>   PRIMARY KEY  (blog_id),
>   KEY db_version (db_version)
> ) $charset_collate;
> CREATE TABLE $wpdb->registration_log (
>   ID bigint(20) NOT NULL auto_increment,
>   email varchar(255) NOT NULL default '',
>   IP varchar(30) NOT NULL default '',
>   blog_id bigint(20) NOT NULL default '0',
>   date_registered datetime NOT NULL default '0000-00-00 00:00:00',
>   PRIMARY KEY  (ID),
>   KEY IP (IP)
> ) $charset_collate;
> CREATE TABLE $wpdb->site (
>   id bigint(20) NOT NULL auto_increment,
>   domain varchar(200) NOT NULL default '',
>   path varchar(100) NOT NULL default '',
>   PRIMARY KEY  (id),
>   KEY domain (domain,path)
> ) $charset_collate;
> CREATE TABLE $wpdb->sitemeta (
>   meta_id bigint(20) NOT NULL auto_increment,
>   site_id bigint(20) NOT NULL default '0',
>   meta_key varchar(255) default NULL,
>   meta_value longtext,
>   PRIMARY KEY  (meta_id),
>   KEY meta_key (meta_key),
>   KEY site_id (site_id)
> ) $charset_collate;
> CREATE TABLE $wpdb->signups (
>   domain varchar(200) NOT NULL default '',
>   path varchar(100) NOT NULL default '',
>   title longtext NOT NULL,
>   user_login varchar(60) NOT NULL default '',
>   user_email varchar(100) NOT NULL default '',
>   registered datetime NOT NULL default '0000-00-00 00:00:00',
>   activated datetime NOT NULL default '0000-00-00 00:00:00',
>   active tinyint(1) NOT NULL default '0',
>   activation_key varchar(50) NOT NULL default '',
>   meta longtext,
>   KEY activation_key (activation_key),
>   KEY domain (domain)
> ) $charset_collate;";
> 
> 	switch ( $scope ) {
> 		case 'blog' :
> 			$queries = $blog_tables;
> 			break;
> 		case 'global' :
> 			$queries = $global_tables;
> 			if ( $is_multisite )
> 				$queries .= $ms_global_tables;
> 			break;
> 		case 'ms_global' :
> 			$queries = $ms_global_tables;
> 			break;
> 		default:
> 		case 'all' :
> 			$queries = $global_tables . $blog_tables;
> 			if ( $is_multisite )
> 				$queries .= $ms_global_tables;
> 			break;
> 	}
> 
> 	if ( isset( $old_blog_id ) )
> 		$wpdb->set_blog_id( $old_blog_id );
> 
> 	return $queries;
> }
> 
> // Populate for back compat.
> $wp_queries = wp_get_db_schema( 'all' );
> 
> /**
>  * Create WordPress options and set the default values.
>  *
>  * @since 1.5.0
>  * @uses $wpdb
>  * @uses $wp_db_version
>  */
> function populate_options() {
> 	global $wpdb, $wp_db_version, $current_site, $wp_current_db_version;
> 
> 	$guessurl = wp_guess_url();
> 
> 	do_action('populate_options');
> 
> 	if ( ini_get('safe_mode') ) {
> 		// Safe mode can break mkdir() so use a flat structure by default.
> 		$uploads_use_yearmonth_folders = 0;
> 	} else {
> 		$uploads_use_yearmonth_folders = 1;
> 	}
> 
> 	$template = WP_DEFAULT_THEME;
> 	// If default theme is a child theme, we need to get its template
> 	foreach ( (array) get_themes() as $theme ) {
> 		if ( WP_DEFAULT_THEME == $theme['Stylesheet'] ) {
> 			$template = $theme['Template'];
> 			break;
> 		}
> 	}
> 
> 	$options = array(
> 	'siteurl' => $guessurl,
> 	'blogname' => __('My Site'),
> 	/* translators: blog tagline */
> 	'blogdescription' => __('Just another WordPress site'),
> 	'users_can_register' => 0,
> 	'admin_email' => 'you@example.com',
> 	'start_of_week' => 1,
> 	'use_balanceTags' => 0,
> 	'use_smilies' => 1,
> 	'require_name_email' => 1,
> 	'comments_notify' => 1,
> 	'posts_per_rss' => 10,
> 	'rss_use_excerpt' => 0,
> 	'mailserver_url' => 'mail.example.com',
> 	'mailserver_login' => 'login@example.com',
> 	'mailserver_pass' => 'password',
> 	'mailserver_port' => 110,
> 	'default_category' => 1,
> 	'default_comment_status' => 'open',
> 	'default_ping_status' => 'open',
> 	'default_pingback_flag' => 1,
> 	'default_post_edit_rows' => 20,
> 	'posts_per_page' => 10,
> 	/* translators: default date format, see http://php.net/date */
> 	'date_format' => __('F j, Y'),
> 	/* translators: default time format, see http://php.net/date */
> 	'time_format' => __('g:i a'),
> 	/* translators: links last updated date format, see http://php.net/date */
> 	'links_updated_date_format' => __('F j, Y g:i a'),
> 	'links_recently_updated_prepend' => '<em>',
> 	'links_recently_updated_append' => '</em>',
> 	'links_recently_updated_time' => 120,
> 	'comment_moderation' => 0,
>         'registration_notify' => 1,
> 	'moderation_notify' => 1,
> 	'permalink_structure' => '',
> 	'gzipcompression' => 0,
> 	'hack_file' => 0,
> 	'blog_charset' => 'UTF-8',
> 	'moderation_keys' => '',
> 	'active_plugins' => array(),
> 	'home' => $guessurl,
> 	'category_base' => '',
> 	'ping_sites' => 'http://rpc.pingomatic.com/',
> 	'advanced_edit' => 0,
> 	'comment_max_links' => 2,
> 	'gmt_offset' => date('Z') / 3600,
> 
> 	// 1.5
> 	'default_email_category' => 1,
> 	'recently_edited' => '',
> 	'template' => $template,
> 	'stylesheet' => WP_DEFAULT_THEME,
> 	'comment_whitelist' => 1,
> 	'blacklist_keys' => '',
> 	'comment_registration' => 0,
> 	'rss_language' => 'en',
> 	'html_type' => 'text/html',
> 
> 	// 1.5.1
> 	'use_trackback' => 0,
> 
> 	// 2.0
> 	'default_role' => 'subscriber',
> 	'db_version' => $wp_db_version,
> 
> 	// 2.0.1
> 	'uploads_use_yearmonth_folders' => $uploads_use_yearmonth_folders,
> 	'upload_path' => '',
> 
> 	// 2.1
> 	'blog_public' => '1',
> 	'default_link_category' => 2,
> 	'show_on_front' => 'posts',
> 
> 	// 2.2
> 	'tag_base' => '',
> 
> 	// 2.5
> 	'show_avatars' => '1',
> 	'avatar_rating' => 'G',
> 	'upload_url_path' => '',
> 	'thumbnail_size_w' => 150,
> 	'thumbnail_size_h' => 150,
> 	'thumbnail_crop' => 1,
> 	'medium_size_w' => 300,
> 	'medium_size_h' => 300,
> 
> 	// 2.6
> 	'avatar_default' => 'mystery',
> 	'enable_app' => 0,
> 	'enable_xmlrpc' => 0,
> 
> 	// 2.7
> 	'large_size_w' => 1024,
> 	'large_size_h' => 1024,
> 	'image_default_link_type' => 'file',
> 	'image_default_size' => '',
> 	'image_default_align' => '',
> 	'close_comments_for_old_posts' => 0,
> 	'close_comments_days_old' => 14,
> 	'thread_comments' => 1,
> 	'thread_comments_depth' => 5,
> 	'page_comments' => 0,
> 	'comments_per_page' => 50,
> 	'default_comments_page' => 'newest',
> 	'comment_order' => 'asc',
> 	'sticky_posts' => array(),
> 	'widget_categories' => array(),
> 	'widget_text' => array(),
> 	'widget_rss' => array(),
> 
> 	// 2.8
> 	'timezone_string' => '',
> 
> 	// 2.9
> 	'embed_autourls' => 1,
> 	'embed_size_w' => '',
> 	'embed_size_h' => 600,
> 
> 	// 3.0
> 	'page_for_posts' => 0,
> 	'page_on_front' => 0,
> 
> 	// 3.1
> 	'default_post_format' => 0,
> 	);
> 
> 	// 3.3
> 	if ( ! is_multisite() ) {
> 		$options['initial_db_version'] = ! empty( $wp_current_db_version ) && $wp_current_db_version < $wp_db_version
> 			? $wp_current_db_version : $wp_db_version;
> 	}
> 
> 	// 3.0 multisite
> 	if ( is_multisite() ) {
> 		/* translators: blog tagline */
> 		$options[ 'blogdescription' ] = sprintf(__('Just another %s site'), $current_site->site_name );
> 		$options[ 'permalink_structure' ] = '/%year%/%monthnum%/%day%/%postname%/';
> 	}
> 
> 	// Set autoload to no for these options
> 	$fat_options = array( 'moderation_keys', 'recently_edited', 'blacklist_keys' );
> 
> 	$existing_options = $wpdb->get_col("SELECT option_name FROM $wpdb->options");
> 
> 	$insert = '';
> 	foreach ( $options as $option => $value ) {
> 		if ( in_array($option, $existing_options) )
> 			continue;
> 		if ( in_array($option, $fat_options) )
> 			$autoload = 'no';
> 		else
> 			$autoload = 'yes';
> 
> 		$option = $wpdb->escape($option);
> 		if ( is_array($value) )
> 			$value = serialize($value);
> 		$value = $wpdb->escape($value);
> 		if ( !empty($insert) )
> 			$insert .= ', ';
> 		$insert .= "('$option', '$value', '$autoload')";
> 	}
> 
> 	if ( !empty($insert) )
> 		$wpdb->query("INSERT INTO $wpdb->options (option_name, option_value, autoload) VALUES " . $insert);
> 
> 	// in case it is set, but blank, update "home"
> 	if ( !__get_option('home') ) update_option('home', $guessurl);
> 
> 	// Delete unused options
> 	$unusedoptions = array ('blodotgsping_url', 'bodyterminator', 'emailtestonly', 'phoneemail_separator', 'smilies_directory', 'subjectprefix', 'use_bbcode', 'use_blodotgsping', 'use_phoneemail', 'use_quicktags', 'use_weblogsping', 'weblogs_cache_file', 'use_preview', 'use_htmltrans', 'smilies_directory', 'fileupload_allowedusers', 'use_phoneemail', 'default_post_status', 'default_post_category', 'archive_mode', 'time_difference', 'links_minadminlevel', 'links_use_adminlevels', 'links_rating_type', 'links_rating_char', 'links_rating_ignore_zero', 'links_rating_single_image', 'links_rating_image0', 'links_rating_image1', 'links_rating_image2', 'links_rating_image3', 'links_rating_image4', 'links_rating_image5', 'links_rating_image6', 'links_rating_image7', 'links_rating_image8', 'links_rating_image9', 'weblogs_cacheminutes', 'comment_allowed_tags', 'search_engine_friendly_urls', 'default_geourl_lat', 'default_geourl_lon', 'use_default_geourl', 'weblogs_xml_url', 'new_users_can_blog', '_wpnonce', '_wp_http_referer', 'Update', 'action', 'rich_editing', 'autosave_interval', 'deactivated_plugins', 'can_compress_scripts', 'page_uris', 'update_core', 'update_plugins', 'update_themes', 'doing_cron', 'random_seed', 'rss_excerpt_length', 'secret', 'use_linksupdate', 'default_comment_status_page', 'wporg_popular_tags', 'what_to_show');
> 	foreach ( $unusedoptions as $option )
> 		delete_option($option);
> 
> 	// delete obsolete magpie stuff
> 	$wpdb->query("DELETE FROM $wpdb->options WHERE option_name REGEXP '^rss_[0-9a-f]{32}(_ts)?$'");
> }
> 
> /**
>  * Execute WordPress role creation for the various WordPress versions.
>  *
>  * @since 2.0.0
>  */
> function populate_roles() {
> 	populate_roles_160();
> 	populate_roles_210();
> 	populate_roles_230();
> 	populate_roles_250();
> 	populate_roles_260();
> 	populate_roles_270();
> 	populate_roles_280();
> 	populate_roles_300();
> }
> 
> /**
>  * Create the roles for WordPress 2.0
>  *
>  * @since 2.0.0
>  */
> function populate_roles_160() {
> 	// Add roles
> 
> 	// Dummy gettext calls to get strings in the catalog.
> 	/* translators: user role */
> 	_x('Administrator', 'User role');
> 	/* translators: user role */
> 	_x('Editor', 'User role');
> 	/* translators: user role */
> 	_x('Author', 'User role');
> 	/* translators: user role */
> 	_x('Contributor', 'User role');
> 	/* translators: user role */
> 	_x('Subscriber', 'User role');
> 
> 	add_role('administrator', 'Administrator');
> 	add_role('editor', 'Editor');
> 	add_role('author', 'Author');
> 	add_role('contributor', 'Contributor');
> 	add_role('subscriber', 'Subscriber');
> 
> 	// Add caps for Administrator role
> 	$role =& get_role('administrator');
> 	$role->add_cap('switch_themes');
> 	$role->add_cap('edit_themes');
> 	$role->add_cap('activate_plugins');
> 	$role->add_cap('edit_plugins');
> 	$role->add_cap('edit_users');
> 	$role->add_cap('edit_files');
> 	$role->add_cap('manage_options');
> 	$role->add_cap('moderate_comments');
> 	$role->add_cap('manage_categories');
> 	$role->add_cap('manage_links');
> 	$role->add_cap('upload_files');
> 	$role->add_cap('import');
> 	$role->add_cap('unfiltered_html');
> 	$role->add_cap('edit_posts');
> 	$role->add_cap('edit_others_posts');
> 	$role->add_cap('edit_published_posts');
> 	$role->add_cap('publish_posts');
> 	$role->add_cap('edit_pages');
> 	$role->add_cap('read');
> 	$role->add_cap('level_10');
> 	$role->add_cap('level_9');
> 	$role->add_cap('level_8');
> 	$role->add_cap('level_7');
> 	$role->add_cap('level_6');
> 	$role->add_cap('level_5');
> 	$role->add_cap('level_4');
> 	$role->add_cap('level_3');
> 	$role->add_cap('level_2');
> 	$role->add_cap('level_1');
> 	$role->add_cap('level_0');
> 
> 	// Add caps for Editor role
> 	$role =& get_role('editor');
> 	$role->add_cap('moderate_comments');
> 	$role->add_cap('manage_categories');
> 	$role->add_cap('manage_links');
> 	$role->add_cap('upload_files');
> 	$role->add_cap('unfiltered_html');
> 	$role->add_cap('edit_posts');
> 	$role->add_cap('edit_others_posts');
> 	$role->add_cap('edit_published_posts');
> 	$role->add_cap('publish_posts');
> 	$role->add_cap('edit_pages');
> 	$role->add_cap('read');
> 	$role->add_cap('level_7');
> 	$role->add_cap('level_6');
> 	$role->add_cap('level_5');
> 	$role->add_cap('level_4');
> 	$role->add_cap('level_3');
> 	$role->add_cap('level_2');
> 	$role->add_cap('level_1');
> 	$role->add_cap('level_0');
> 
> 	// Add caps for Author role
> 	$role =& get_role('author');
> 	$role->add_cap('upload_files');
> 	$role->add_cap('edit_posts');
> 	$role->add_cap('edit_published_posts');
> 	$role->add_cap('publish_posts');
> 	$role->add_cap('read');
> 	$role->add_cap('level_2');
> 	$role->add_cap('level_1');
> 	$role->add_cap('level_0');
> 
> 	// Add caps for Contributor role
> 	$role =& get_role('contributor');
> 	$role->add_cap('edit_posts');
> 	$role->add_cap('read');
> 	$role->add_cap('level_1');
> 	$role->add_cap('level_0');
> 
> 	// Add caps for Subscriber role
> 	$role =& get_role('subscriber');
> 	$role->add_cap('read');
> 	$role->add_cap('level_0');
> }
> 
> /**
>  * Create and modify WordPress roles for WordPress 2.1.
>  *
>  * @since 2.1.0
>  */
> function populate_roles_210() {
> 	$roles = array('administrator', 'editor');
> 	foreach ($roles as $role) {
> 		$role =& get_role($role);
> 		if ( empty($role) )
> 			continue;
> 
> 		$role->add_cap('edit_others_pages');
> 		$role->add_cap('edit_published_pages');
> 		$role->add_cap('publish_pages');
> 		$role->add_cap('delete_pages');
> 		$role->add_cap('delete_others_pages');
> 		$role->add_cap('delete_published_pages');
> 		$role->add_cap('delete_posts');
> 		$role->add_cap('delete_others_posts');
> 		$role->add_cap('delete_published_posts');
> 		$role->add_cap('delete_private_posts');
> 		$role->add_cap('edit_private_posts');
> 		$role->add_cap('read_private_posts');
> 		$role->add_cap('delete_private_pages');
> 		$role->add_cap('edit_private_pages');
> 		$role->add_cap('read_private_pages');
> 	}
> 
> 	$role =& get_role('administrator');
> 	if ( ! empty($role) ) {
> 		$role->add_cap('delete_users');
> 		$role->add_cap('create_users');
> 	}
> 
> 	$role =& get_role('author');
> 	if ( ! empty($role) ) {
> 		$role->add_cap('delete_posts');
> 		$role->add_cap('delete_published_posts');
> 	}
> 
> 	$role =& get_role('contributor');
> 	if ( ! empty($role) ) {
> 		$role->add_cap('delete_posts');
> 	}
> }
> 
> /**
>  * Create and modify WordPress roles for WordPress 2.3.
>  *
>  * @since 2.3.0
>  */
> function populate_roles_230() {
> 	$role =& get_role( 'administrator' );
> 
> 	if ( !empty( $role ) ) {
> 		$role->add_cap( 'unfiltered_upload' );
> 	}
> }
> 
> /**
>  * Create and modify WordPress roles for WordPress 2.5.
>  *
>  * @since 2.5.0
>  */
> function populate_roles_250() {
> 	$role =& get_role( 'administrator' );
> 
> 	if ( !empty( $role ) ) {
> 		$role->add_cap( 'edit_dashboard' );
> 	}
> }
> 
> /**
>  * Create and modify WordPress roles for WordPress 2.6.
>  *
>  * @since 2.6.0
>  */
> function populate_roles_260() {
> 	$role =& get_role( 'administrator' );
> 
> 	if ( !empty( $role ) ) {
> 		$role->add_cap( 'update_plugins' );
> 		$role->add_cap( 'delete_plugins' );
> 	}
> }
> 
> /**
>  * Create and modify WordPress roles for WordPress 2.7.
>  *
>  * @since 2.7.0
>  */
> function populate_roles_270() {
> 	$role =& get_role( 'administrator' );
> 
> 	if ( !empty( $role ) ) {
> 		$role->add_cap( 'install_plugins' );
> 		$role->add_cap( 'update_themes' );
> 	}
> }
> 
> /**
>  * Create and modify WordPress roles for WordPress 2.8.
>  *
>  * @since 2.8.0
>  */
> function populate_roles_280() {
> 	$role =& get_role( 'administrator' );
> 
> 	if ( !empty( $role ) ) {
> 		$role->add_cap( 'install_themes' );
> 	}
> }
> 
> /**
>  * Create and modify WordPress roles for WordPress 3.0.
>  *
>  * @since 3.0.0
>  */
> function populate_roles_300() {
> 	$role =& get_role( 'administrator' );
> 
> 	if ( !empty( $role ) ) {
> 		$role->add_cap( 'update_core' );
> 		$role->add_cap( 'list_users' );
> 		$role->add_cap( 'remove_users' );
> 		$role->add_cap( 'add_users' );
> 		$role->add_cap( 'promote_users' );
> 		$role->add_cap( 'edit_theme_options' );
> 		$role->add_cap( 'delete_themes' );
> 		$role->add_cap( 'export' );
> 	}
> }
> 
> /**
>  * Install Network.
>  *
>  * @since 3.0.0
>  *
>  */
> if ( !function_exists( 'install_network' ) ) :
> function install_network() {
> 	if ( ! defined( 'WP_INSTALLING_NETWORK' ) )
> 		define( 'WP_INSTALLING_NETWORK', true );
> 
> 	dbDelta( wp_get_db_schema( 'global' ) );
> }
> endif;
> 
> /**
>  * populate network settings
>  *
>  * @since 3.0.0
>  *
>  * @param int $network_id id of network to populate
>  * @return bool|WP_Error True on success, or WP_Error on warning (with the install otherwise successful,
>  * 	so the error code must be checked) or failure.
>  */
> function populate_network( $network_id = 1, $domain = '', $email = '', $site_name = '', $path = '/', $subdomain_install = false ) {
> 	global $wpdb, $current_site, $wp_db_version, $wp_rewrite;
> 
> 	$errors = new WP_Error();
> 	if ( '' == $domain )
> 		$errors->add( 'empty_domain', __( 'You must provide a domain name.' ) );
> 	if ( '' == $site_name )
> 		$errors->add( 'empty_sitename', __( 'You must provide a name for your network of sites.' ) );
> 
> 	// check for network collision
> 	if ( $network_id == $wpdb->get_var( $wpdb->prepare( "SELECT id FROM $wpdb->site WHERE id = %d", $network_id ) ) )
> 		$errors->add( 'siteid_exists', __( 'The network already exists.' ) );
> 
> 	$site_user = get_user_by( 'email', $email );
> 	if ( ! is_email( $email ) )
> 		$errors->add( 'invalid_email', __( 'You must provide a valid e-mail address.' ) );
> 
> 	if ( $errors->get_error_code() )
> 		return $errors;
> 
> 	// set up site tables
> 	$template = get_option( 'template' );
> 	$stylesheet = get_option( 'stylesheet' );
> 	$allowed_themes = array( $stylesheet => true );
> 	if ( $template != $stylesheet )
> 		$allowed_themes[ $template ] = true;
> 	if ( WP_DEFAULT_THEME != $stylesheet && WP_DEFAULT_THEME != $template )
> 		$allowed_themes[ WP_DEFAULT_THEME ] = true;
> 
> 	if ( 1 == $network_id ) {
> 		$wpdb->insert( $wpdb->site, array( 'domain' => $domain, 'path' => $path ) );
> 		$network_id = $wpdb->insert_id;
> 	} else {
> 		$wpdb->insert( $wpdb->site, array( 'domain' => $domain, 'path' => $path, 'id' => $network_id ) );
> 	}
> 
> 	if ( !is_multisite() ) {
> 		$site_admins = array( $site_user->user_login );
> 		$users = get_users( array( 'fields' => array( 'ID', 'user_login' ) ) );
> 		if ( $users ) {
> 			foreach ( $users as $user ) {
> 				if ( is_super_admin( $user->ID ) && !in_array( $user->user_login, $site_admins ) )
> 					$site_admins[] = $user->user_login;
> 			}
> 		}
> 	} else {
> 		$site_admins = get_site_option( 'site_admins' );
> 	}
> 
> 	$welcome_email = __( 'Dear User,
> 
> Your new SITE_NAME site has been successfully set up at:
> BLOG_URL
> 
> You can log in to the administrator account with the following information:
> Username: USERNAME
> Password: PASSWORD
> Log in here: BLOG_URLwp-login.php
> 
> We hope you enjoy your new site. Thanks!
> 
> --The Team @ SITE_NAME' );
> 
> 	$sitemeta = array(
> 		'site_name' => $site_name,
> 		'admin_email' => $site_user->user_email,
> 		'admin_user_id' => $site_user->ID,
> 		'registration' => 'none',
> 		'upload_filetypes' => 'jpg jpeg png gif mp3 mov avi wmv midi mid pdf',
> 		'blog_upload_space' => 10,
> 		'fileupload_maxk' => 1500,
> 		'site_admins' => $site_admins,
> 		'allowedthemes' => $allowed_themes,
> 		'illegal_names' => array( 'www', 'web', 'root', 'admin', 'main', 'invite', 'administrator', 'files' ),
> 		'wpmu_upgrade_site' => $wp_db_version,
> 		'welcome_email' => $welcome_email,
> 		'first_post' => __( 'Welcome to <a href="SITE_URL">SITE_NAME</a>. This is your first post. Edit or delete it, then start blogging!' ),
> 		// @todo - network admins should have a method of editing the network siteurl (used for cookie hash)
> 		'siteurl' => get_option( 'siteurl' ) . '/',
> 		'add_new_users' => '0',
> 		'upload_space_check_disabled' => '0',
> 		'subdomain_install' => intval( $subdomain_install ),
> 		'global_terms_enabled' => global_terms_enabled() ? '1' : '0',
> 		'initial_db_version' => get_option( 'initial_db_version' ),
> 		'active_sitewide_plugins' => array(),
> 	);
> 	if ( ! $subdomain_install )
> 		$sitemeta['illegal_names'][] = 'blog';
> 
> 	$insert = '';
> 	foreach ( $sitemeta as $meta_key => $meta_value ) {
> 		$meta_key = $wpdb->escape( $meta_key );
> 		if ( is_array( $meta_value ) )
> 			$meta_value = serialize( $meta_value );
> 		$meta_value = $wpdb->escape( $meta_value );
> 		if ( !empty( $insert ) )
> 			$insert .= ', ';
> 		$insert .= "( $network_id, '$meta_key', '$meta_value')";
> 	}
> 	$wpdb->query( "INSERT INTO $wpdb->sitemeta ( site_id, meta_key, meta_value ) VALUES " . $insert );
> 
> 	$current_site->domain = $domain;
> 	$current_site->path = $path;
> 	$current_site->site_name = ucfirst( $domain );
> 
> 	if ( !is_multisite() ) {
> 		$wpdb->insert( $wpdb->blogs, array( 'site_id' => $network_id, 'domain' => $domain, 'path' => $path, 'registered' => current_time( 'mysql' ) ) );
> 		$blog_id = $wpdb->insert_id;
> 		update_user_meta( $site_user->ID, 'source_domain', $domain );
> 		update_user_meta( $site_user->ID, 'primary_blog', $blog_id );
> 		if ( !$upload_path = get_option( 'upload_path' ) ) {
> 			$upload_path = substr( WP_CONTENT_DIR, strlen( ABSPATH ) ) . '/uploads';
> 			update_option( 'upload_path', $upload_path );
> 		}
> 		update_option( 'fileupload_url', get_option( 'siteurl' ) . '/' . $upload_path );
> 	}
> 
> 	if ( $subdomain_install )
> 		update_option( 'permalink_structure', '/%year%/%monthnum%/%day%/%postname%/');
> 	else
> 		update_option( 'permalink_structure', '/blog/%year%/%monthnum%/%day%/%postname%/');
> 
> 	$wp_rewrite->flush_rules();
> 
> 	if ( $subdomain_install ) {
> 		$vhost_ok = false;
> 		$errstr = '';
> 		$hostname = substr( md5( time() ), 0, 6 ) . '.' . $domain; // Very random hostname!
> 		$page = wp_remote_get( 'http://' . $hostname, array( 'timeout' => 5, 'httpversion' => '1.1' ) );
> 		if ( is_wp_error( $page ) )
> 			$errstr = $page->get_error_message();
> 		elseif ( 200 == wp_remote_retrieve_response_code( $page ) )
> 				$vhost_ok = true;
> 
> 		if ( ! $vhost_ok ) {
> 			$msg = '<p><strong>' . __( 'Warning! Wildcard DNS may not be configured correctly!' ) . '</strong></p>';
> 			$msg .= '<p>' . sprintf( __( 'The installer attempted to contact a random hostname (<code>%1$s</code>) on your domain.' ), $hostname );
> 			if ( ! empty ( $errstr ) )
> 				$msg .= ' ' . sprintf( __( 'This resulted in an error message: %s' ), '<code>' . $errstr . '</code>' );
> 			$msg .= '</p>';
> 			$msg .= '<p>' . __( 'To use a subdomain configuration, you must have a wildcard entry in your DNS. This usually means adding a <code>*</code> hostname record pointing at your web server in your DNS configuration tool.' ) . '</p>';
> 			$msg .= '<p>' . __( 'You can still use your site but any subdomain you create may not be accessible. If you know your DNS is correct, ignore this message.' ) . '</p>';
> 			return new WP_Error( 'no_wildcard_dns', $msg );
> 		}
> 	}
> 
> 	return true;
> }
> 
> ?>
diff  options-discussion.php options-discussion.php
1,253c1,257
< <?php
< /**
<  * Discussion settings administration panel.
<  *
<  * @package WordPress
<  * @subpackage Administration
<  */
< 
< /** WordPress Administration Bootstrap */
< require_once('./admin.php');
< 
< if ( ! current_user_can( 'manage_options' ) )
< 	wp_die( __( 'You do not have sufficient permissions to manage options for this site.' ) );
< 
< $title = __('Discussion Settings');
< $parent_file = 'options-general.php';
< 
< get_current_screen()->add_help_tab( array(
< 	'id'      => 'overview',
< 	'title'   => __('Overview'),
< 	'content' => '<p>' . __('This screen provides many options for controlling the management and display of comments and links to your posts/pages. So many, in fact, they won&#8217;t all fit here! :) Use the documentation links to get information on what each discussion setting does.') . '</p>' .
< 		'<p>' . __('You must click the Save Changes button at the bottom of the screen for new settings to take effect.') . '</p>',
< ) );
< 
< get_current_screen()->set_help_sidebar(
< 	'<p><strong>' . __('For more information:') . '</strong></p>' .
< 	'<p>' . __('<a href="http://codex.wordpress.org/Settings_Discussion_Screen" target="_blank">Documentation on Discussion Settings</a>') . '</p>' .
< 	'<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>'
< );
< 
< include('./admin-header.php');
< ?>
< 
< <div class="wrap">
< <?php screen_icon(); ?>
< <h2><?php echo esc_html( $title ); ?></h2>
< 
< <form method="post" action="options.php">
< <?php settings_fields('discussion'); ?>
< 
< <table class="form-table">
< <tr valign="top">
< <th scope="row"><?php _e('Default article settings'); ?></th>
< <td><fieldset><legend class="screen-reader-text"><span><?php _e('Default article settings'); ?></span></legend>
< <label for="default_pingback_flag">
< <input name="default_pingback_flag" type="checkbox" id="default_pingback_flag" value="1" <?php checked('1', get_option('default_pingback_flag')); ?> />
< <?php _e('Attempt to notify any blogs linked to from the article'); ?></label>
< <br />
< <label for="default_ping_status">
< <input name="default_ping_status" type="checkbox" id="default_ping_status" value="open" <?php checked('open', get_option('default_ping_status')); ?> />
< <?php _e('Allow link notifications from other blogs (pingbacks and trackbacks)'); ?></label>
< <br />
< <label for="default_comment_status">
< <input name="default_comment_status" type="checkbox" id="default_comment_status" value="open" <?php checked('open', get_option('default_comment_status')); ?> />
< <?php _e('Allow people to post comments on new articles'); ?></label>
< <br />
< <small><em><?php echo '(' . __('These settings may be overridden for individual articles.') . ')'; ?></em></small>
< </fieldset></td>
< </tr>
< <tr valign="top">
< <th scope="row"><?php _e('Other comment settings'); ?></th>
< <td><fieldset><legend class="screen-reader-text"><span><?php _e('Other comment settings'); ?></span></legend>
< <label for="require_name_email"><input type="checkbox" name="require_name_email" id="require_name_email" value="1" <?php checked('1', get_option('require_name_email')); ?> /> <?php _e('Comment author must fill out name and e-mail'); ?></label>
< <br />
< <label for="comment_registration">
< <input name="comment_registration" type="checkbox" id="comment_registration" value="1" <?php checked('1', get_option('comment_registration')); ?> />
< <?php _e('Users must be registered and logged in to comment'); ?>
< <?php if ( !get_option( 'users_can_register' ) && is_multisite() ) echo ' ' . __( '(Signup has been disabled. Only members of this site can comment.)' ); ?>
< </label>
< <br />
< 
< <label for="close_comments_for_old_posts">
< <input name="close_comments_for_old_posts" type="checkbox" id="close_comments_for_old_posts" value="1" <?php checked('1', get_option('close_comments_for_old_posts')); ?> />
< <?php printf( __('Automatically close comments on articles older than %s days'), '</label><input name="close_comments_days_old" type="text" id="close_comments_days_old" value="' . esc_attr(get_option('close_comments_days_old')) . '" class="small-text" />'); ?>
< <br />
< <label for="thread_comments">
< <input name="thread_comments" type="checkbox" id="thread_comments" value="1" <?php checked('1', get_option('thread_comments')); ?> />
< <?php
< 
< $maxdeep = (int) apply_filters( 'thread_comments_depth_max', 10 );
< 
< $thread_comments_depth = '</label><select name="thread_comments_depth" id="thread_comments_depth">';
< for ( $i = 2; $i <= $maxdeep; $i++ ) {
< 	$thread_comments_depth .= "<option value='" . esc_attr($i) . "'";
< 	if ( get_option('thread_comments_depth') == $i ) $thread_comments_depth .= " selected='selected'";
< 	$thread_comments_depth .= ">$i</option>";
< }
< $thread_comments_depth .= '</select>';
< 
< printf( __('Enable threaded (nested) comments %s levels deep'), $thread_comments_depth );
< 
< ?><br />
< <label for="page_comments">
< <input name="page_comments" type="checkbox" id="page_comments" value="1" <?php checked('1', get_option('page_comments')); ?> />
< <?php
< 
< $default_comments_page = '</label><label for="default_comments_page"><select name="default_comments_page" id="default_comments_page"><option value="newest"';
< if ( 'newest' == get_option('default_comments_page') ) $default_comments_page .= ' selected="selected"';
< $default_comments_page .= '>' . __('last') . '</option><option value="oldest"';
< if ( 'oldest' == get_option('default_comments_page') ) $default_comments_page .= ' selected="selected"';
< $default_comments_page .= '>' . __('first') . '</option></select>';
< 
< printf( __('Break comments into pages with %1$s top level comments per page and the %2$s page displayed by default'), '</label><label for="comments_per_page"><input name="comments_per_page" type="text" id="comments_per_page" value="' . esc_attr(get_option('comments_per_page')) . '" class="small-text" />', $default_comments_page );
< 
< ?></label>
< <br />
< <label for="comment_order"><?php
< 
< $comment_order = '<select name="comment_order" id="comment_order"><option value="asc"';
< if ( 'asc' == get_option('comment_order') ) $comment_order .= ' selected="selected"';
< $comment_order .= '>' . __('older') . '</option><option value="desc"';
< if ( 'desc' == get_option('comment_order') ) $comment_order .= ' selected="selected"';
< $comment_order .= '>' . __('newer') . '</option></select>';
< 
< printf( __('Comments should be displayed with the %s comments at the top of each page'), $comment_order );
< 
< ?></label>
< </fieldset></td>
< </tr>
< <tr valign="top">
< <th scope="row"><?php _e('E-mail me whenever'); ?></th>
< <td><fieldset><legend class="screen-reader-text"><span><?php _e('E-mail me whenever'); ?></span></legend>
< <label for="comments_notify">
< <input name="comments_notify" type="checkbox" id="comments_notify" value="1" <?php checked('1', get_option('comments_notify')); ?> />
< <?php _e('Anyone posts a comment'); ?> </label>
< <br />
< <label for="moderation_notify">
< <input name="moderation_notify" type="checkbox" id="moderation_notify" value="1" <?php checked('1', get_option('moderation_notify')); ?> />
< <?php _e('A comment is held for moderation'); ?> </label>
< </fieldset></td>
< </tr>
< <tr valign="top">
< <th scope="row"><?php _e('Before a comment appears'); ?></th>
< <td><fieldset><legend class="screen-reader-text"><span><?php _e('Before a comment appears'); ?></span></legend>
< <label for="comment_moderation">
< <input name="comment_moderation" type="checkbox" id="comment_moderation" value="1" <?php checked('1', get_option('comment_moderation')); ?> />
< <?php _e('An administrator must always approve the comment'); ?> </label>
< <br />
< <label for="comment_whitelist"><input type="checkbox" name="comment_whitelist" id="comment_whitelist" value="1" <?php checked('1', get_option('comment_whitelist')); ?> /> <?php _e('Comment author must have a previously approved comment'); ?></label>
< </fieldset></td>
< </tr>
< <tr valign="top">
< <th scope="row"><?php _e('Comment Moderation'); ?></th>
< <td><fieldset><legend class="screen-reader-text"><span><?php _e('Comment Moderation'); ?></span></legend>
< <p><label for="comment_max_links"><?php printf(__('Hold a comment in the queue if it contains %s or more links. (A common characteristic of comment spam is a large number of hyperlinks.)'), '<input name="comment_max_links" type="text" id="comment_max_links" value="' . esc_attr(get_option('comment_max_links')) . '" class="small-text" />' ); ?></label></p>
< 
< <p><label for="moderation_keys"><?php _e('When a comment contains any of these words in its content, name, URL, e-mail, or IP, it will be held in the <a href="edit-comments.php?comment_status=moderated">moderation queue</a>. One word or IP per line. It will match inside words, so &#8220;press&#8221; will match &#8220;WordPress&#8221;.'); ?></label></p>
< <p>
< <textarea name="moderation_keys" rows="10" cols="50" id="moderation_keys" class="large-text code"><?php echo esc_textarea( get_option( 'moderation_keys' ) ); ?></textarea>
< </p>
< </fieldset></td>
< </tr>
< <tr valign="top">
< <th scope="row"><?php _e('Comment Blacklist'); ?></th>
< <td><fieldset><legend class="screen-reader-text"><span><?php _e('Comment Blacklist'); ?></span></legend>
< <p><label for="blacklist_keys"><?php _e('When a comment contains any of these words in its content, name, URL, e-mail, or IP, it will be marked as spam. One word or IP per line. It will match inside words, so &#8220;press&#8221; will match &#8220;WordPress&#8221;.'); ?></label></p>
< <p>
< <textarea name="blacklist_keys" rows="10" cols="50" id="blacklist_keys" class="large-text code"><?php echo esc_textarea( get_option( 'blacklist_keys' ) ); ?></textarea>
< </p>
< </fieldset></td>
< </tr>
< <?php do_settings_fields('discussion', 'default'); ?>
< </table>
< 
< <h3><?php _e('Avatars'); ?></h3>
< 
< <p><?php _e('An avatar is an image that follows you from weblog to weblog appearing beside your name when you comment on avatar enabled sites.  Here you can enable the display of avatars for people who comment on your site.'); ?></p>
< 
< <?php // the above would be a good place to link to codex documentation on the gravatar functions, for putting it in themes. anything like that? ?>
< 
< <table class="form-table">
< <tr valign="top">
< <th scope="row"><?php _e('Avatar Display'); ?></th>
< <td><fieldset><legend class="screen-reader-text"><span><?php _e('Avatar Display'); ?></span></legend>
< <?php
< 	$yesorno = array( 0 => __( 'Don&#8217;t show Avatars' ), 1 => __( 'Show Avatars' ) );
< 	foreach ( $yesorno as $key => $value) {
< 		$selected = (get_option('show_avatars') == $key) ? 'checked="checked"' : '';
< 		echo "\n\t<label><input type='radio' name='show_avatars' value='" . esc_attr($key) . "' $selected/> $value</label><br />";
< 	}
< ?>
< </fieldset></td>
< </tr>
< <tr valign="top">
< <th scope="row"><?php _e('Maximum Rating'); ?></th>
< <td><fieldset><legend class="screen-reader-text"><span><?php _e('Maximum Rating'); ?></span></legend>
< 
< <?php
< $ratings = array(
< 	/* translators: Content suitability rating: http://bit.ly/89QxZA */
< 	'G' => __('G &#8212; Suitable for all audiences'),
< 	/* translators: Content suitability rating: http://bit.ly/89QxZA */
< 	'PG' => __('PG &#8212; Possibly offensive, usually for audiences 13 and above'),
< 	/* translators: Content suitability rating: http://bit.ly/89QxZA */
< 	'R' => __('R &#8212; Intended for adult audiences above 17'),
< 	/* translators: Content suitability rating: http://bit.ly/89QxZA */
< 	'X' => __('X &#8212; Even more mature than above')
< );
< foreach ($ratings as $key => $rating) :
< 	$selected = (get_option('avatar_rating') == $key) ? 'checked="checked"' : '';
< 	echo "\n\t<label><input type='radio' name='avatar_rating' value='" . esc_attr($key) . "' $selected/> $rating</label><br />";
< endforeach;
< ?>
< 
< </fieldset></td>
< </tr>
< <tr valign="top">
< <th scope="row"><?php _e('Default Avatar'); ?></th>
< <td class="defaultavatarpicker"><fieldset><legend class="screen-reader-text"><span><?php _e('Default Avatar'); ?></span></legend>
< 
< <?php _e('For users without a custom avatar of their own, you can either display a generic logo or a generated one based on their e-mail address.'); ?><br />
< 
< <?php
< $avatar_defaults = array(
< 	'mystery' => __('Mystery Man'),
< 	'blank' => __('Blank'),
< 	'gravatar_default' => __('Gravatar Logo'),
< 	'identicon' => __('Identicon (Generated)'),
< 	'wavatar' => __('Wavatar (Generated)'),
< 	'monsterid' => __('MonsterID (Generated)'),
< 	'retro' => __('Retro (Generated)')
< );
< $avatar_defaults = apply_filters('avatar_defaults', $avatar_defaults);
< $default = get_option('avatar_default');
< if ( empty($default) )
< 	$default = 'mystery';
< $size = 32;
< $avatar_list = '';
< foreach ( $avatar_defaults as $default_key => $default_name ) {
< 	$selected = ($default == $default_key) ? 'checked="checked" ' : '';
< 	$avatar_list .= "\n\t<label><input type='radio' name='avatar_default' id='avatar_{$default_key}' value='" . esc_attr($default_key)  . "' {$selected}/> ";
< 
< 	$avatar = get_avatar( $user_email, $size, $default_key );
< 	$avatar_list .= preg_replace("/src='(.+?)'/", "src='\$1&amp;forcedefault=1'", $avatar);
< 
< 	$avatar_list .= ' ' . $default_name . '</label>';
< 	$avatar_list .= '<br />';
< }
< echo apply_filters('default_avatar_select', $avatar_list);
< ?>
< 
< </fieldset></td>
< </tr>
< <?php do_settings_fields('discussion', 'avatars'); ?>
< </table>
< 
< <?php do_settings_sections('discussion'); ?>
< 
< <?php submit_button(); ?>
< </form>
< </div>
< 
< <?php include('./admin-footer.php'); ?>
---
> <?php
> /**
>  * Discussion settings administration panel.
>  *
>  * @package WordPress
>  * @subpackage Administration
>  */
> 
> /** WordPress Administration Bootstrap */
> require_once('./admin.php');
> 
> if ( ! current_user_can( 'manage_options' ) )
> 	wp_die( __( 'You do not have sufficient permissions to manage options for this site.' ) );
> 
> $title = __('Discussion Settings');
> $parent_file = 'options-general.php';
> 
> get_current_screen()->add_help_tab( array(
> 	'id'      => 'overview',
> 	'title'   => __('Overview'),
> 	'content' => '<p>' . __('This screen provides many options for controlling the management and display of comments and links to your posts/pages. So many, in fact, they won&#8217;t all fit here! :) Use the documentation links to get information on what each discussion setting does.') . '</p>' .
> 		'<p>' . __('You must click the Save Changes button at the bottom of the screen for new settings to take effect.') . '</p>',
> ) );
> 
> get_current_screen()->set_help_sidebar(
> 	'<p><strong>' . __('For more information:') . '</strong></p>' .
> 	'<p>' . __('<a href="http://codex.wordpress.org/Settings_Discussion_Screen" target="_blank">Documentation on Discussion Settings</a>') . '</p>' .
> 	'<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>'
> );
> 
> include('./admin-header.php');
> ?>
> 
> <div class="wrap">
> <?php screen_icon(); ?>
> <h2><?php echo esc_html( $title ); ?></h2>
> 
> <form method="post" action="options.php">
> <?php settings_fields('discussion'); ?>
> 
> <table class="form-table">
> <tr valign="top">
> <th scope="row"><?php _e('Default article settings'); ?></th>
> <td><fieldset><legend class="screen-reader-text"><span><?php _e('Default article settings'); ?></span></legend>
> <label for="default_pingback_flag">
> <input name="default_pingback_flag" type="checkbox" id="default_pingback_flag" value="1" <?php checked('1', get_option('default_pingback_flag')); ?> />
> <?php _e('Attempt to notify any blogs linked to from the article'); ?></label>
> <br />
> <label for="default_ping_status">
> <input name="default_ping_status" type="checkbox" id="default_ping_status" value="open" <?php checked('open', get_option('default_ping_status')); ?> />
> <?php _e('Allow link notifications from other blogs (pingbacks and trackbacks)'); ?></label>
> <br />
> <label for="default_comment_status">
> <input name="default_comment_status" type="checkbox" id="default_comment_status" value="open" <?php checked('open', get_option('default_comment_status')); ?> />
> <?php _e('Allow people to post comments on new articles'); ?></label>
> <br />
> <small><em><?php echo '(' . __('These settings may be overridden for individual articles.') . ')'; ?></em></small>
> </fieldset></td>
> </tr>
> <tr valign="top">
> <th scope="row"><?php _e('Other comment settings'); ?></th>
> <td><fieldset><legend class="screen-reader-text"><span><?php _e('Other comment settings'); ?></span></legend>
> <label for="require_name_email"><input type="checkbox" name="require_name_email" id="require_name_email" value="1" <?php checked('1', get_option('require_name_email')); ?> /> <?php _e('Comment author must fill out name and e-mail'); ?></label>
> <br />
> <label for="comment_registration">
> <input name="comment_registration" type="checkbox" id="comment_registration" value="1" <?php checked('1', get_option('comment_registration')); ?> />
> <?php _e('Users must be registered and logged in to comment'); ?>
> <?php if ( !get_option( 'users_can_register' ) && is_multisite() ) echo ' ' . __( '(Signup has been disabled. Only members of this site can comment.)' ); ?>
> </label>
> <br />
> 
> <label for="close_comments_for_old_posts">
> <input name="close_comments_for_old_posts" type="checkbox" id="close_comments_for_old_posts" value="1" <?php checked('1', get_option('close_comments_for_old_posts')); ?> />
> <?php printf( __('Automatically close comments on articles older than %s days'), '</label><input name="close_comments_days_old" type="text" id="close_comments_days_old" value="' . esc_attr(get_option('close_comments_days_old')) . '" class="small-text" />'); ?>
> <br />
> <label for="thread_comments">
> <input name="thread_comments" type="checkbox" id="thread_comments" value="1" <?php checked('1', get_option('thread_comments')); ?> />
> <?php
> 
> $maxdeep = (int) apply_filters( 'thread_comments_depth_max', 10 );
> 
> $thread_comments_depth = '</label><select name="thread_comments_depth" id="thread_comments_depth">';
> for ( $i = 2; $i <= $maxdeep; $i++ ) {
> 	$thread_comments_depth .= "<option value='" . esc_attr($i) . "'";
> 	if ( get_option('thread_comments_depth') == $i ) $thread_comments_depth .= " selected='selected'";
> 	$thread_comments_depth .= ">$i</option>";
> }
> $thread_comments_depth .= '</select>';
> 
> printf( __('Enable threaded (nested) comments %s levels deep'), $thread_comments_depth );
> 
> ?><br />
> <label for="page_comments">
> <input name="page_comments" type="checkbox" id="page_comments" value="1" <?php checked('1', get_option('page_comments')); ?> />
> <?php
> 
> $default_comments_page = '</label><label for="default_comments_page"><select name="default_comments_page" id="default_comments_page"><option value="newest"';
> if ( 'newest' == get_option('default_comments_page') ) $default_comments_page .= ' selected="selected"';
> $default_comments_page .= '>' . __('last') . '</option><option value="oldest"';
> if ( 'oldest' == get_option('default_comments_page') ) $default_comments_page .= ' selected="selected"';
> $default_comments_page .= '>' . __('first') . '</option></select>';
> 
> printf( __('Break comments into pages with %1$s top level comments per page and the %2$s page displayed by default'), '</label><label for="comments_per_page"><input name="comments_per_page" type="text" id="comments_per_page" value="' . esc_attr(get_option('comments_per_page')) . '" class="small-text" />', $default_comments_page );
> 
> ?></label>
> <br />
> <label for="comment_order"><?php
> 
> $comment_order = '<select name="comment_order" id="comment_order"><option value="asc"';
> if ( 'asc' == get_option('comment_order') ) $comment_order .= ' selected="selected"';
> $comment_order .= '>' . __('older') . '</option><option value="desc"';
> if ( 'desc' == get_option('comment_order') ) $comment_order .= ' selected="selected"';
> $comment_order .= '>' . __('newer') . '</option></select>';
> 
> printf( __('Comments should be displayed with the %s comments at the top of each page'), $comment_order );
> 
> ?></label>
> </fieldset></td>
> </tr>
> <tr valign="top">
> <th scope="row"><?php _e('E-mail me whenever'); ?></th>
> <td><fieldset><legend class="screen-reader-text"><span><?php _e('E-mail me whenever'); ?></span></legend>
> <label for="registration_notify">
> <input name="registration_notify" type="checkbox" id="registration_notify" value="1" <?php checked('1', get_option('registration_notify')); ?> />
> <?php _e('Someone registers'); ?> </label>
> <br />
> <label for="comments_notify">
> <input name="comments_notify" type="checkbox" id="comments_notify" value="1" <?php checked('1', get_option('comments_notify')); ?> />
> <?php _e('Anyone posts a comment'); ?> </label>
> <br />
> <label for="moderation_notify">
> <input name="moderation_notify" type="checkbox" id="moderation_notify" value="1" <?php checked('1', get_option('moderation_notify')); ?> />
> <?php _e('A comment is held for moderation'); ?> </label>
> </fieldset></td>
> </tr>
> <tr valign="top">
> <th scope="row"><?php _e('Before a comment appears'); ?></th>
> <td><fieldset><legend class="screen-reader-text"><span><?php _e('Before a comment appears'); ?></span></legend>
> <label for="comment_moderation">
> <input name="comment_moderation" type="checkbox" id="comment_moderation" value="1" <?php checked('1', get_option('comment_moderation')); ?> />
> <?php _e('An administrator must always approve the comment'); ?> </label>
> <br />
> <label for="comment_whitelist"><input type="checkbox" name="comment_whitelist" id="comment_whitelist" value="1" <?php checked('1', get_option('comment_whitelist')); ?> /> <?php _e('Comment author must have a previously approved comment'); ?></label>
> </fieldset></td>
> </tr>
> <tr valign="top">
> <th scope="row"><?php _e('Comment Moderation'); ?></th>
> <td><fieldset><legend class="screen-reader-text"><span><?php _e('Comment Moderation'); ?></span></legend>
> <p><label for="comment_max_links"><?php printf(__('Hold a comment in the queue if it contains %s or more links. (A common characteristic of comment spam is a large number of hyperlinks.)'), '<input name="comment_max_links" type="text" id="comment_max_links" value="' . esc_attr(get_option('comment_max_links')) . '" class="small-text" />' ); ?></label></p>
> 
> <p><label for="moderation_keys"><?php _e('When a comment contains any of these words in its content, name, URL, e-mail, or IP, it will be held in the <a href="edit-comments.php?comment_status=moderated">moderation queue</a>. One word or IP per line. It will match inside words, so &#8220;press&#8221; will match &#8220;WordPress&#8221;.'); ?></label></p>
> <p>
> <textarea name="moderation_keys" rows="10" cols="50" id="moderation_keys" class="large-text code"><?php echo esc_textarea( get_option( 'moderation_keys' ) ); ?></textarea>
> </p>
> </fieldset></td>
> </tr>
> <tr valign="top">
> <th scope="row"><?php _e('Comment Blacklist'); ?></th>
> <td><fieldset><legend class="screen-reader-text"><span><?php _e('Comment Blacklist'); ?></span></legend>
> <p><label for="blacklist_keys"><?php _e('When a comment contains any of these words in its content, name, URL, e-mail, or IP, it will be marked as spam. One word or IP per line. It will match inside words, so &#8220;press&#8221; will match &#8220;WordPress&#8221;.'); ?></label></p>
> <p>
> <textarea name="blacklist_keys" rows="10" cols="50" id="blacklist_keys" class="large-text code"><?php echo esc_textarea( get_option( 'blacklist_keys' ) ); ?></textarea>
> </p>
> </fieldset></td>
> </tr>
> <?php do_settings_fields('discussion', 'default'); ?>
> </table>
> 
> <h3><?php _e('Avatars'); ?></h3>
> 
> <p><?php _e('An avatar is an image that follows you from weblog to weblog appearing beside your name when you comment on avatar enabled sites.  Here you can enable the display of avatars for people who comment on your site.'); ?></p>
> 
> <?php // the above would be a good place to link to codex documentation on the gravatar functions, for putting it in themes. anything like that? ?>
> 
> <table class="form-table">
> <tr valign="top">
> <th scope="row"><?php _e('Avatar Display'); ?></th>
> <td><fieldset><legend class="screen-reader-text"><span><?php _e('Avatar Display'); ?></span></legend>
> <?php
> 	$yesorno = array( 0 => __( 'Don&#8217;t show Avatars' ), 1 => __( 'Show Avatars' ) );
> 	foreach ( $yesorno as $key => $value) {
> 		$selected = (get_option('show_avatars') == $key) ? 'checked="checked"' : '';
> 		echo "\n\t<label><input type='radio' name='show_avatars' value='" . esc_attr($key) . "' $selected/> $value</label><br />";
> 	}
> ?>
> </fieldset></td>
> </tr>
> <tr valign="top">
> <th scope="row"><?php _e('Maximum Rating'); ?></th>
> <td><fieldset><legend class="screen-reader-text"><span><?php _e('Maximum Rating'); ?></span></legend>
> 
> <?php
> $ratings = array(
> 	/* translators: Content suitability rating: http://bit.ly/89QxZA */
> 	'G' => __('G &#8212; Suitable for all audiences'),
> 	/* translators: Content suitability rating: http://bit.ly/89QxZA */
> 	'PG' => __('PG &#8212; Possibly offensive, usually for audiences 13 and above'),
> 	/* translators: Content suitability rating: http://bit.ly/89QxZA */
> 	'R' => __('R &#8212; Intended for adult audiences above 17'),
> 	/* translators: Content suitability rating: http://bit.ly/89QxZA */
> 	'X' => __('X &#8212; Even more mature than above')
> );
> foreach ($ratings as $key => $rating) :
> 	$selected = (get_option('avatar_rating') == $key) ? 'checked="checked"' : '';
> 	echo "\n\t<label><input type='radio' name='avatar_rating' value='" . esc_attr($key) . "' $selected/> $rating</label><br />";
> endforeach;
> ?>
> 
> </fieldset></td>
> </tr>
> <tr valign="top">
> <th scope="row"><?php _e('Default Avatar'); ?></th>
> <td class="defaultavatarpicker"><fieldset><legend class="screen-reader-text"><span><?php _e('Default Avatar'); ?></span></legend>
> 
> <?php _e('For users without a custom avatar of their own, you can either display a generic logo or a generated one based on their e-mail address.'); ?><br />
> 
> <?php
> $avatar_defaults = array(
> 	'mystery' => __('Mystery Man'),
> 	'blank' => __('Blank'),
> 	'gravatar_default' => __('Gravatar Logo'),
> 	'identicon' => __('Identicon (Generated)'),
> 	'wavatar' => __('Wavatar (Generated)'),
> 	'monsterid' => __('MonsterID (Generated)'),
> 	'retro' => __('Retro (Generated)')
> );
> $avatar_defaults = apply_filters('avatar_defaults', $avatar_defaults);
> $default = get_option('avatar_default');
> if ( empty($default) )
> 	$default = 'mystery';
> $size = 32;
> $avatar_list = '';
> foreach ( $avatar_defaults as $default_key => $default_name ) {
> 	$selected = ($default == $default_key) ? 'checked="checked" ' : '';
> 	$avatar_list .= "\n\t<label><input type='radio' name='avatar_default' id='avatar_{$default_key}' value='" . esc_attr($default_key)  . "' {$selected}/> ";
> 
> 	$avatar = get_avatar( $user_email, $size, $default_key );
> 	$avatar_list .= preg_replace("/src='(.+?)'/", "src='\$1&amp;forcedefault=1'", $avatar);
> 
> 	$avatar_list .= ' ' . $default_name . '</label>';
> 	$avatar_list .= '<br />';
> }
> echo apply_filters('default_avatar_select', $avatar_list);
> ?>
> 
> </fieldset></td>
> </tr>
> <?php do_settings_fields('discussion', 'avatars'); ?>
> </table>
> 
> <?php do_settings_sections('discussion'); ?>
> 
> <?php submit_button(); ?>
> </form>
> </div>
> 
> <?php include('./admin-footer.php'); ?>
diff  options.php options.php
1,227c1,227
< <?php
< /**
<  * Options Management Administration Screen.
<  *
<  * If accessed directly in a browser this page shows a list of all saved options
<  * along with editable fields for their values. Serialized data is not supported
<  * and there is no way to remove options via this page. It is not linked to from
<  * anywhere else in the admin.
<  *
<  * This file is also the target of the forms in core and custom options pages
<  * that use the Settings API. In this case it saves the new option values
<  * and returns the user to their page of origin.
<  *
<  * @package WordPress
<  * @subpackage Administration
<  */
< 
< /** WordPress Administration Bootstrap */
< require_once('./admin.php');
< 
< $title = __('Settings');
< $this_file = 'options.php';
< $parent_file = 'options-general.php';
< 
< wp_reset_vars(array('action', 'option_page'));
< 
< $capability = 'manage_options';
< 
< if ( empty($option_page) ) // This is for back compat and will eventually be removed.
< 	$option_page = 'options';
< else
< 	$capability = apply_filters( "option_page_capability_{$option_page}", $capability );
< 
< if ( !current_user_can( $capability ) )
< 	wp_die(__('Cheatin&#8217; uh?'));
< 
< // Handle admin email change requests
< if ( is_multisite() ) {
< 	if ( ! empty($_GET[ 'adminhash' ] ) ) {
< 		$new_admin_details = get_option( 'adminhash' );
< 		$redirect = 'options-general.php?updated=false';
< 		if ( is_array( $new_admin_details ) && $new_admin_details[ 'hash' ] == $_GET[ 'adminhash' ] && !empty($new_admin_details[ 'newemail' ]) ) {
< 			update_option( 'admin_email', $new_admin_details[ 'newemail' ] );
< 			delete_option( 'adminhash' );
< 			delete_option( 'new_admin_email' );
< 			$redirect = 'options-general.php?updated=true';
< 		}
< 		wp_redirect( admin_url( $redirect ) );
< 		exit;
< 	} elseif ( ! empty( $_GET['dismiss'] ) && 'new_admin_email' == $_GET['dismiss'] ) {
< 		delete_option( 'adminhash' );
< 		delete_option( 'new_admin_email' );
< 		wp_redirect( admin_url( 'options-general.php?updated=true' ) );
< 		exit;
< 	}
< }
< 
< if ( is_multisite() && !is_super_admin() && 'update' != $action )
< 	wp_die(__('Cheatin&#8217; uh?'));
< 
< $whitelist_options = array(
< 	'general' => array( 'blogname', 'blogdescription', 'gmt_offset', 'date_format', 'time_format', 'start_of_week', 'timezone_string' ),
< 	'discussion' => array( 'default_pingback_flag', 'default_ping_status', 'default_comment_status', 'comments_notify', 'moderation_notify', 'comment_moderation', 'require_name_email', 'comment_whitelist', 'comment_max_links', 'moderation_keys', 'blacklist_keys', 'show_avatars', 'avatar_rating', 'avatar_default', 'close_comments_for_old_posts', 'close_comments_days_old', 'thread_comments', 'thread_comments_depth', 'page_comments', 'comments_per_page', 'default_comments_page', 'comment_order', 'comment_registration' ),
< 	'media' => array( 'thumbnail_size_w', 'thumbnail_size_h', 'thumbnail_crop', 'medium_size_w', 'medium_size_h', 'large_size_w', 'large_size_h', 'image_default_size', 'image_default_align', 'image_default_link_type', 'embed_autourls', 'embed_size_w', 'embed_size_h' ),
< 	'privacy' => array( 'blog_public' ),
< 	'reading' => array( 'posts_per_page', 'posts_per_rss', 'rss_use_excerpt', 'blog_charset', 'show_on_front', 'page_on_front', 'page_for_posts' ),
< 	'writing' => array( 'default_post_edit_rows', 'use_smilies', 'default_category', 'default_email_category', 'use_balanceTags', 'default_link_category', 'default_post_format', 'enable_app', 'enable_xmlrpc' ),
< 	'options' => array( '' ) );
< 
< $mail_options = array('mailserver_url', 'mailserver_port', 'mailserver_login', 'mailserver_pass');
< $uploads_options = array('uploads_use_yearmonth_folders', 'upload_path', 'upload_url_path');
< 
< if ( !is_multisite() ) {
< 	if ( !defined( 'WP_SITEURL' ) )
< 		$whitelist_options['general'][] = 'siteurl';
< 	if ( !defined( 'WP_HOME' ) )
< 		$whitelist_options['general'][] = 'home';
< 
< 	$whitelist_options['general'][] = 'admin_email';
< 	$whitelist_options['general'][] = 'users_can_register';
< 	$whitelist_options['general'][] = 'default_role';
< 
< 	$whitelist_options['writing'] = array_merge($whitelist_options['writing'], $mail_options);
< 	$whitelist_options['writing'][] = 'ping_sites';
< 
< 	$whitelist_options['media'] = array_merge($whitelist_options['media'], $uploads_options);
< } else {
< 	$whitelist_options['general'][] = 'new_admin_email';
< 	$whitelist_options['general'][] = 'WPLANG';
< 	$whitelist_options['general'][] = 'language';
< 
< 	if ( apply_filters( 'enable_post_by_email_configuration', true ) )
< 		$whitelist_options['writing'] = array_merge($whitelist_options['writing'], $mail_options);
< 
< 	$whitelist_options[ 'misc' ] = array();
< }
< 
< $whitelist_options = apply_filters( 'whitelist_options', $whitelist_options );
< 
< /*
<  * If $_GET['action'] == 'update' we are saving settings sent from a settings page
<  */
< if ( 'update' == $action ) {
< 	if ( 'options' == $option_page && !isset( $_POST['option_page'] ) ) { // This is for back compat and will eventually be removed.
< 		$unregistered = true;
< 		check_admin_referer( 'update-options' );
< 	} else {
< 		$unregistered = false;
< 		check_admin_referer( $option_page . '-options' );
< 	}
< 
< 	if ( !isset( $whitelist_options[ $option_page ] ) )
< 		wp_die( __( '<strong>ERROR</strong>: options page not found.' ) );
< 
< 	if ( 'options' == $option_page ) {
< 		if ( is_multisite() && ! is_super_admin() )
< 			wp_die( __( 'You do not have sufficient permissions to modify unregistered settings for this site.' ) );
< 		$options = explode( ',', stripslashes( $_POST[ 'page_options' ] ) );
< 	} else {
< 		$options = $whitelist_options[ $option_page ];
< 	}
< 
< 	// Handle custom date/time formats
< 	if ( 'general' == $option_page ) {
< 		if ( !empty($_POST['date_format']) && isset($_POST['date_format_custom']) && '\c\u\s\t\o\m' == stripslashes( $_POST['date_format'] ) )
< 			$_POST['date_format'] = $_POST['date_format_custom'];
< 		if ( !empty($_POST['time_format']) && isset($_POST['time_format_custom']) && '\c\u\s\t\o\m' == stripslashes( $_POST['time_format'] ) )
< 			$_POST['time_format'] = $_POST['time_format_custom'];
< 		// Map UTC+- timezones to gmt_offsets and set timezone_string to empty.
< 		if ( !empty($_POST['timezone_string']) && preg_match('/^UTC[+-]/', $_POST['timezone_string']) ) {
< 			$_POST['gmt_offset'] = $_POST['timezone_string'];
< 			$_POST['gmt_offset'] = preg_replace('/UTC\+?/', '', $_POST['gmt_offset']);
< 			$_POST['timezone_string'] = '';
< 		}
< 	}
< 
< 	if ( $options ) {
< 		foreach ( $options as $option ) {
< 			if ( $unregistered )
< 				_deprecated_argument( 'options.php', '2.7', sprintf( __( 'The <code>%1$s</code> setting is unregistered. Unregistered settings are deprecated. See http://codex.wordpress.org/Settings_API' ), $option, $option_page ) );
< 
< 			$option = trim($option);
< 			$value = null;
< 			if ( isset($_POST[$option]) )
< 				$value = $_POST[$option];
< 			if ( !is_array($value) )
< 				$value = trim($value);
< 			$value = stripslashes_deep($value);
< 			update_option($option, $value);
< 		}
< 	}
< 
< 	/**
< 	 *  Handle settings errors and return to options page
< 	 */
< 	// If no settings errors were registered add a general 'updated' message.
< 	if ( !count( get_settings_errors() ) )
< 		add_settings_error('general', 'settings_updated', __('Settings saved.'), 'updated');
< 	set_transient('settings_errors', get_settings_errors(), 30);
< 
< 	/**
< 	 * Redirect back to the settings page that was submitted
< 	 */
< 	$goback = add_query_arg( 'settings-updated', 'true',  wp_get_referer() );
< 	wp_redirect( $goback );
< 	exit;
< }
< 
< include('./admin-header.php'); ?>
< 
< <div class="wrap">
< <?php screen_icon(); ?>
<   <h2><?php esc_html_e('All Settings'); ?></h2>
<   <form name="form" action="options.php" method="post" id="all-options">
<   <?php wp_nonce_field('options-options') ?>
<   <input type="hidden" name="action" value="update" />
<   <input type='hidden' name='option_page' value='options' />
<   <table class="form-table">
< <?php
< $options = $wpdb->get_results( "SELECT * FROM $wpdb->options ORDER BY option_name" );
< 
< foreach ( (array) $options as $option ) :
< 	$disabled = false;
< 	if ( $option->option_name == '' )
< 		continue;
< 	if ( is_serialized( $option->option_value ) ) {
< 		if ( is_serialized_string( $option->option_value ) ) {
< 			// this is a serialized string, so we should display it
< 			$value = maybe_unserialize( $option->option_value );
< 			$options_to_update[] = $option->option_name;
< 			$class = 'all-options';
< 		} else {
< 			$value = 'SERIALIZED DATA';
< 			$disabled = true;
< 			$class = 'all-options disabled';
< 		}
< 	} else {
< 		$value = $option->option_value;
< 		$options_to_update[] = $option->option_name;
< 		$class = 'all-options';
< 	}
< 	$name = esc_attr( $option->option_name );
< 	echo "
< <tr>
< 	<th scope='row'><label for='$name'>" . esc_html( $option->option_name ) . "</label></th>
< <td>";
< 	if ( strpos( $value, "\n" ) !== false )
< 		echo "<textarea class='$class' name='$name' id='$name' cols='30' rows='5'>" . esc_textarea( $value ) . "</textarea>";
< 	else
< 		echo "<input class='regular-text $class' type='text' name='$name' id='$name' value='" . esc_attr( $value ) . "'" . disabled( $disabled, true, false ) . " />";
< 	echo "</td>
< </tr>";
< endforeach;
< ?>
<   </table>
< 
< <input type="hidden" name="page_options" value="<?php echo esc_attr( implode( ',', $options_to_update ) ); ?>" />
< 
< <?php submit_button( __( 'Save Changes' ), 'primary', 'Update' ); ?>
< 
<   </form>
< </div>
< 
< 
< <?php
< include('./admin-footer.php');
< ?>
---
> <?php
> /**
>  * Options Management Administration Screen.
>  *
>  * If accessed directly in a browser this page shows a list of all saved options
>  * along with editable fields for their values. Serialized data is not supported
>  * and there is no way to remove options via this page. It is not linked to from
>  * anywhere else in the admin.
>  *
>  * This file is also the target of the forms in core and custom options pages
>  * that use the Settings API. In this case it saves the new option values
>  * and returns the user to their page of origin.
>  *
>  * @package WordPress
>  * @subpackage Administration
>  */
> 
> /** WordPress Administration Bootstrap */
> require_once('./admin.php');
> 
> $title = __('Settings');
> $this_file = 'options.php';
> $parent_file = 'options-general.php';
> 
> wp_reset_vars(array('action', 'option_page'));
> 
> $capability = 'manage_options';
> 
> if ( empty($option_page) ) // This is for back compat and will eventually be removed.
> 	$option_page = 'options';
> else
> 	$capability = apply_filters( "option_page_capability_{$option_page}", $capability );
> 
> if ( !current_user_can( $capability ) )
> 	wp_die(__('Cheatin&#8217; uh?'));
> 
> // Handle admin email change requests
> if ( is_multisite() ) {
> 	if ( ! empty($_GET[ 'adminhash' ] ) ) {
> 		$new_admin_details = get_option( 'adminhash' );
> 		$redirect = 'options-general.php?updated=false';
> 		if ( is_array( $new_admin_details ) && $new_admin_details[ 'hash' ] == $_GET[ 'adminhash' ] && !empty($new_admin_details[ 'newemail' ]) ) {
> 			update_option( 'admin_email', $new_admin_details[ 'newemail' ] );
> 			delete_option( 'adminhash' );
> 			delete_option( 'new_admin_email' );
> 			$redirect = 'options-general.php?updated=true';
> 		}
> 		wp_redirect( admin_url( $redirect ) );
> 		exit;
> 	} elseif ( ! empty( $_GET['dismiss'] ) && 'new_admin_email' == $_GET['dismiss'] ) {
> 		delete_option( 'adminhash' );
> 		delete_option( 'new_admin_email' );
> 		wp_redirect( admin_url( 'options-general.php?updated=true' ) );
> 		exit;
> 	}
> }
> 
> if ( is_multisite() && !is_super_admin() && 'update' != $action )
> 	wp_die(__('Cheatin&#8217; uh?'));
> 
> $whitelist_options = array(
> 	'general' => array( 'blogname', 'blogdescription', 'gmt_offset', 'date_format', 'time_format', 'start_of_week', 'timezone_string' ),
> 	'discussion' => array( 'default_pingback_flag', 'default_ping_status', 'default_comment_status', 'registration_notify','comments_notify', 'moderation_notify', 'comment_moderation', 'require_name_email', 'comment_whitelist', 'comment_max_links', 'moderation_keys', 'blacklist_keys', 'show_avatars', 'avatar_rating', 'avatar_default', 'close_comments_for_old_posts', 'close_comments_days_old', 'thread_comments', 'thread_comments_depth', 'page_comments', 'comments_per_page', 'default_comments_page', 'comment_order', 'comment_registration' ),
> 	'media' => array( 'thumbnail_size_w', 'thumbnail_size_h', 'thumbnail_crop', 'medium_size_w', 'medium_size_h', 'large_size_w', 'large_size_h', 'image_default_size', 'image_default_align', 'image_default_link_type', 'embed_autourls', 'embed_size_w', 'embed_size_h' ),
> 	'privacy' => array( 'blog_public' ),
> 	'reading' => array( 'posts_per_page', 'posts_per_rss', 'rss_use_excerpt', 'blog_charset', 'show_on_front', 'page_on_front', 'page_for_posts' ),
> 	'writing' => array( 'default_post_edit_rows', 'use_smilies', 'default_category', 'default_email_category', 'use_balanceTags', 'default_link_category', 'default_post_format', 'enable_app', 'enable_xmlrpc' ),
> 	'options' => array( '' ) );
> 
> $mail_options = array('mailserver_url', 'mailserver_port', 'mailserver_login', 'mailserver_pass');
> $uploads_options = array('uploads_use_yearmonth_folders', 'upload_path', 'upload_url_path');
> 
> if ( !is_multisite() ) {
> 	if ( !defined( 'WP_SITEURL' ) )
> 		$whitelist_options['general'][] = 'siteurl';
> 	if ( !defined( 'WP_HOME' ) )
> 		$whitelist_options['general'][] = 'home';
> 
> 	$whitelist_options['general'][] = 'admin_email';
> 	$whitelist_options['general'][] = 'users_can_register';
> 	$whitelist_options['general'][] = 'default_role';
> 
> 	$whitelist_options['writing'] = array_merge($whitelist_options['writing'], $mail_options);
> 	$whitelist_options['writing'][] = 'ping_sites';
> 
> 	$whitelist_options['media'] = array_merge($whitelist_options['media'], $uploads_options);
> } else {
> 	$whitelist_options['general'][] = 'new_admin_email';
> 	$whitelist_options['general'][] = 'WPLANG';
> 	$whitelist_options['general'][] = 'language';
> 
> 	if ( apply_filters( 'enable_post_by_email_configuration', true ) )
> 		$whitelist_options['writing'] = array_merge($whitelist_options['writing'], $mail_options);
> 
> 	$whitelist_options[ 'misc' ] = array();
> }
> 
> $whitelist_options = apply_filters( 'whitelist_options', $whitelist_options );
> 
> /*
>  * If $_GET['action'] == 'update' we are saving settings sent from a settings page
>  */
> if ( 'update' == $action ) {
> 	if ( 'options' == $option_page && !isset( $_POST['option_page'] ) ) { // This is for back compat and will eventually be removed.
> 		$unregistered = true;
> 		check_admin_referer( 'update-options' );
> 	} else {
> 		$unregistered = false;
> 		check_admin_referer( $option_page . '-options' );
> 	}
> 
> 	if ( !isset( $whitelist_options[ $option_page ] ) )
> 		wp_die( __( '<strong>ERROR</strong>: options page not found.' ) );
> 
> 	if ( 'options' == $option_page ) {
> 		if ( is_multisite() && ! is_super_admin() )
> 			wp_die( __( 'You do not have sufficient permissions to modify unregistered settings for this site.' ) );
> 		$options = explode( ',', stripslashes( $_POST[ 'page_options' ] ) );
> 	} else {
> 		$options = $whitelist_options[ $option_page ];
> 	}
> 
> 	// Handle custom date/time formats
> 	if ( 'general' == $option_page ) {
> 		if ( !empty($_POST['date_format']) && isset($_POST['date_format_custom']) && '\c\u\s\t\o\m' == stripslashes( $_POST['date_format'] ) )
> 			$_POST['date_format'] = $_POST['date_format_custom'];
> 		if ( !empty($_POST['time_format']) && isset($_POST['time_format_custom']) && '\c\u\s\t\o\m' == stripslashes( $_POST['time_format'] ) )
> 			$_POST['time_format'] = $_POST['time_format_custom'];
> 		// Map UTC+- timezones to gmt_offsets and set timezone_string to empty.
> 		if ( !empty($_POST['timezone_string']) && preg_match('/^UTC[+-]/', $_POST['timezone_string']) ) {
> 			$_POST['gmt_offset'] = $_POST['timezone_string'];
> 			$_POST['gmt_offset'] = preg_replace('/UTC\+?/', '', $_POST['gmt_offset']);
> 			$_POST['timezone_string'] = '';
> 		}
> 	}
> 
> 	if ( $options ) {
> 		foreach ( $options as $option ) {
> 			if ( $unregistered )
> 				_deprecated_argument( 'options.php', '2.7', sprintf( __( 'The <code>%1$s</code> setting is unregistered. Unregistered settings are deprecated. See http://codex.wordpress.org/Settings_API' ), $option, $option_page ) );
> 
> 			$option = trim($option);
> 			$value = null;
> 			if ( isset($_POST[$option]) )
> 				$value = $_POST[$option];
> 			if ( !is_array($value) )
> 				$value = trim($value);
> 			$value = stripslashes_deep($value);
> 			update_option($option, $value);
> 		}
> 	}
> 
> 	/**
> 	 *  Handle settings errors and return to options page
> 	 */
> 	// If no settings errors were registered add a general 'updated' message.
> 	if ( !count( get_settings_errors() ) )
> 		add_settings_error('general', 'settings_updated', __('Settings saved.'), 'updated');
> 	set_transient('settings_errors', get_settings_errors(), 30);
> 
> 	/**
> 	 * Redirect back to the settings page that was submitted
> 	 */
> 	$goback = add_query_arg( 'settings-updated', 'true',  wp_get_referer() );
> 	wp_redirect( $goback );
> 	exit;
> }
> 
> include('./admin-header.php'); ?>
> 
> <div class="wrap">
> <?php screen_icon(); ?>
>   <h2><?php esc_html_e('All Settings'); ?></h2>
>   <form name="form" action="options.php" method="post" id="all-options">
>   <?php wp_nonce_field('options-options') ?>
>   <input type="hidden" name="action" value="update" />
>   <input type='hidden' name='option_page' value='options' />
>   <table class="form-table">
> <?php
> $options = $wpdb->get_results( "SELECT * FROM $wpdb->options ORDER BY option_name" );
> 
> foreach ( (array) $options as $option ) :
> 	$disabled = false;
> 	if ( $option->option_name == '' )
> 		continue;
> 	if ( is_serialized( $option->option_value ) ) {
> 		if ( is_serialized_string( $option->option_value ) ) {
> 			// this is a serialized string, so we should display it
> 			$value = maybe_unserialize( $option->option_value );
> 			$options_to_update[] = $option->option_name;
> 			$class = 'all-options';
> 		} else {
> 			$value = 'SERIALIZED DATA';
> 			$disabled = true;
> 			$class = 'all-options disabled';
> 		}
> 	} else {
> 		$value = $option->option_value;
> 		$options_to_update[] = $option->option_name;
> 		$class = 'all-options';
> 	}
> 	$name = esc_attr( $option->option_name );
> 	echo "
> <tr>
> 	<th scope='row'><label for='$name'>" . esc_html( $option->option_name ) . "</label></th>
> <td>";
> 	if ( strpos( $value, "\n" ) !== false )
> 		echo "<textarea class='$class' name='$name' id='$name' cols='30' rows='5'>" . esc_textarea( $value ) . "</textarea>";
> 	else
> 		echo "<input class='regular-text $class' type='text' name='$name' id='$name' value='" . esc_attr( $value ) . "'" . disabled( $disabled, true, false ) . " />";
> 	echo "</td>
> </tr>";
> endforeach;
> ?>
>   </table>
> 
> <input type="hidden" name="page_options" value="<?php echo esc_attr( implode( ',', $options_to_update ) ); ?>" />
> 
> <?php submit_button( __( 'Save Changes' ), 'primary', 'Update' ); ?>
> 
>   </form>
> </div>
> 
> 
> <?php
> include('./admin-footer.php');
> ?>
diff  pluggable.php pluggable.php
1,1743c1,1745
< <?php
< /**
<  * These functions can be replaced via plugins. If plugins do not redefine these
<  * functions, then these will be used instead.
<  *
<  * @package WordPress
<  */
< 
< if ( !function_exists('wp_set_current_user') ) :
< /**
<  * Changes the current user by ID or name.
<  *
<  * Set $id to null and specify a name if you do not know a user's ID.
<  *
<  * Some WordPress functionality is based on the current user and not based on
<  * the signed in user. Therefore, it opens the ability to edit and perform
<  * actions on users who aren't signed in.
<  *
<  * @since 2.0.3
<  * @global object $current_user The current user object which holds the user data.
<  * @uses do_action() Calls 'set_current_user' hook after setting the current user.
<  *
<  * @param int $id User ID
<  * @param string $name User's username
<  * @return WP_User Current user User object
<  */
< function wp_set_current_user($id, $name = '') {
< 	global $current_user;
< 
< 	if ( isset($current_user) && ($id == $current_user->ID) )
< 		return $current_user;
< 
< 	$current_user = new WP_User($id, $name);
< 
< 	setup_userdata($current_user->ID);
< 
< 	do_action('set_current_user');
< 
< 	return $current_user;
< }
< endif;
< 
< if ( !function_exists('wp_get_current_user') ) :
< /**
<  * Retrieve the current user object.
<  *
<  * @since 2.0.3
<  *
<  * @return WP_User Current user WP_User object
<  */
< function wp_get_current_user() {
< 	global $current_user;
< 
< 	get_currentuserinfo();
< 
< 	return $current_user;
< }
< endif;
< 
< if ( !function_exists('get_currentuserinfo') ) :
< /**
<  * Populate global variables with information about the currently logged in user.
<  *
<  * Will set the current user, if the current user is not set. The current user
<  * will be set to the logged in person. If no user is logged in, then it will
<  * set the current user to 0, which is invalid and won't have any permissions.
<  *
<  * @since 0.71
<  * @uses $current_user Checks if the current user is set
<  * @uses wp_validate_auth_cookie() Retrieves current logged in user.
<  *
<  * @return bool|null False on XMLRPC Request and invalid auth cookie. Null when current user set
<  */
< function get_currentuserinfo() {
< 	global $current_user;
< 
< 	if ( defined('XMLRPC_REQUEST') && XMLRPC_REQUEST )
< 		return false;
< 
< 	if ( ! empty($current_user) )
< 		return;
< 
< 	if ( ! $user = wp_validate_auth_cookie() ) {
< 		 if ( is_blog_admin() || is_network_admin() || empty($_COOKIE[LOGGED_IN_COOKIE]) || !$user = wp_validate_auth_cookie($_COOKIE[LOGGED_IN_COOKIE], 'logged_in') ) {
< 		 	wp_set_current_user(0);
< 		 	return false;
< 		 }
< 	}
< 
< 	wp_set_current_user($user);
< }
< endif;
< 
< if ( !function_exists('get_userdata') ) :
< /**
<  * Retrieve user info by user ID.
<  *
<  * @since 0.71
<  *
<  * @param int $user_id User ID
<  * @return bool|object False on failure, WP_User object on success
<  */
< function get_userdata( $user_id ) {
< 	return get_user_by( 'id', $user_id );
< }
< endif;
< 
< if ( !function_exists('get_user_by') ) :
< /**
<  * Retrieve user info by a given field
<  *
<  * @since 2.8.0
<  *
<  * @param string $field The field to retrieve the user with.  id | slug | email | login
<  * @param int|string $value A value for $field.  A user ID, slug, email address, or login name.
<  * @return bool|object False on failure, WP_User object on success
<  */
< function get_user_by( $field, $value ) {
< 	$userdata = WP_User::get_data_by( $field, $value );
< 
< 	if ( !$userdata )
< 		return false;
< 
< 	$user = new WP_User;
< 	$user->init( $userdata );
< 
< 	return $user;
< }
< endif;
< 
< if ( !function_exists('cache_users') ) :
< /**
<  * Retrieve info for user lists to prevent multiple queries by get_userdata()
<  *
<  * @since 3.0.0
<  *
<  * @param array $user_ids User ID numbers list
<  */
< function cache_users( $user_ids ) {
< 	global $wpdb;
< 
< 	$clean = array();
< 	foreach ( $user_ids as $id ) {
< 		$id = (int) $id;
< 		if ( !wp_cache_get( $id, 'users' ) ) {
< 			$clean[] = $id;
< 		}
< 	}
< 
< 	if ( empty( $clean ) )
< 		return;
< 
< 	$list = implode( ',', $clean );
< 
< 	$users = $wpdb->get_results( "SELECT * FROM $wpdb->users WHERE ID IN ($list)" );
< 
< 	$ids = array();
< 	foreach ( $users as $user ) {
< 		update_user_caches( $user );
< 		$ids[] = $user->ID;
< 	}
< 	update_meta_cache( 'user', $ids );
< }
< endif;
< 
< if ( !function_exists( 'wp_mail' ) ) :
< /**
<  * Send mail, similar to PHP's mail
<  *
<  * A true return value does not automatically mean that the user received the
<  * email successfully. It just only means that the method used was able to
<  * process the request without any errors.
<  *
<  * Using the two 'wp_mail_from' and 'wp_mail_from_name' hooks allow from
<  * creating a from address like 'Name <email@address.com>' when both are set. If
<  * just 'wp_mail_from' is set, then just the email address will be used with no
<  * name.
<  *
<  * The default content type is 'text/plain' which does not allow using HTML.
<  * However, you can set the content type of the email by using the
<  * 'wp_mail_content_type' filter.
<  *
<  * The default charset is based on the charset used on the blog. The charset can
<  * be set using the 'wp_mail_charset' filter.
<  *
<  * @since 1.2.1
<  * @uses apply_filters() Calls 'wp_mail' hook on an array of all of the parameters.
<  * @uses apply_filters() Calls 'wp_mail_from' hook to get the from email address.
<  * @uses apply_filters() Calls 'wp_mail_from_name' hook to get the from address name.
<  * @uses apply_filters() Calls 'wp_mail_content_type' hook to get the email content type.
<  * @uses apply_filters() Calls 'wp_mail_charset' hook to get the email charset
<  * @uses do_action_ref_array() Calls 'phpmailer_init' hook on the reference to
<  *		phpmailer object.
<  * @uses PHPMailer
<  *
<  * @param string|array $to Array or comma-separated list of email addresses to send message.
<  * @param string $subject Email subject
<  * @param string $message Message contents
<  * @param string|array $headers Optional. Additional headers.
<  * @param string|array $attachments Optional. Files to attach.
<  * @return bool Whether the email contents were sent successfully.
<  */
< function wp_mail( $to, $subject, $message, $headers = '', $attachments = array() ) {
< 	// Compact the input, apply the filters, and extract them back out
< 	extract( apply_filters( 'wp_mail', compact( 'to', 'subject', 'message', 'headers', 'attachments' ) ) );
< 
< 	if ( !is_array($attachments) )
< 		$attachments = explode( "\n", str_replace( "\r\n", "\n", $attachments ) );
< 
< 	global $phpmailer;
< 
< 	// (Re)create it, if it's gone missing
< 	if ( !is_object( $phpmailer ) || !is_a( $phpmailer, 'PHPMailer' ) ) {
< 		require_once ABSPATH . WPINC . '/class-phpmailer.php';
< 		require_once ABSPATH . WPINC . '/class-smtp.php';
< 		$phpmailer = new PHPMailer( true );
< 	}
< 
< 	// Headers
< 	if ( empty( $headers ) ) {
< 		$headers = array();
< 	} else {
< 		if ( !is_array( $headers ) ) {
< 			// Explode the headers out, so this function can take both
< 			// string headers and an array of headers.
< 			$tempheaders = explode( "\n", str_replace( "\r\n", "\n", $headers ) );
< 		} else {
< 			$tempheaders = $headers;
< 		}
< 		$headers = array();
< 		$cc = array();
< 		$bcc = array();
< 
< 		// If it's actually got contents
< 		if ( !empty( $tempheaders ) ) {
< 			// Iterate through the raw headers
< 			foreach ( (array) $tempheaders as $header ) {
< 				if ( strpos($header, ':') === false ) {
< 					if ( false !== stripos( $header, 'boundary=' ) ) {
< 						$parts = preg_split('/boundary=/i', trim( $header ) );
< 						$boundary = trim( str_replace( array( "'", '"' ), '', $parts[1] ) );
< 					}
< 					continue;
< 				}
< 				// Explode them out
< 				list( $name, $content ) = explode( ':', trim( $header ), 2 );
< 
< 				// Cleanup crew
< 				$name    = trim( $name    );
< 				$content = trim( $content );
< 
< 				switch ( strtolower( $name ) ) {
< 					// Mainly for legacy -- process a From: header if it's there
< 					case 'from':
< 						if ( strpos($content, '<' ) !== false ) {
< 							// So... making my life hard again?
< 							$from_name = substr( $content, 0, strpos( $content, '<' ) - 1 );
< 							$from_name = str_replace( '"', '', $from_name );
< 							$from_name = trim( $from_name );
< 
< 							$from_email = substr( $content, strpos( $content, '<' ) + 1 );
< 							$from_email = str_replace( '>', '', $from_email );
< 							$from_email = trim( $from_email );
< 						} else {
< 							$from_email = trim( $content );
< 						}
< 						break;
< 					case 'content-type':
< 						if ( strpos( $content, ';' ) !== false ) {
< 							list( $type, $charset ) = explode( ';', $content );
< 							$content_type = trim( $type );
< 							if ( false !== stripos( $charset, 'charset=' ) ) {
< 								$charset = trim( str_replace( array( 'charset=', '"' ), '', $charset ) );
< 							} elseif ( false !== stripos( $charset, 'boundary=' ) ) {
< 								$boundary = trim( str_replace( array( 'BOUNDARY=', 'boundary=', '"' ), '', $charset ) );
< 								$charset = '';
< 							}
< 						} else {
< 							$content_type = trim( $content );
< 						}
< 						break;
< 					case 'cc':
< 						$cc = array_merge( (array) $cc, explode( ',', $content ) );
< 						break;
< 					case 'bcc':
< 						$bcc = array_merge( (array) $bcc, explode( ',', $content ) );
< 						break;
< 					default:
< 						// Add it to our grand headers array
< 						$headers[trim( $name )] = trim( $content );
< 						break;
< 				}
< 			}
< 		}
< 	}
< 
< 	// Empty out the values that may be set
< 	$phpmailer->ClearAddresses();
< 	$phpmailer->ClearAllRecipients();
< 	$phpmailer->ClearAttachments();
< 	$phpmailer->ClearBCCs();
< 	$phpmailer->ClearCCs();
< 	$phpmailer->ClearCustomHeaders();
< 	$phpmailer->ClearReplyTos();
< 
< 	// From email and name
< 	// If we don't have a name from the input headers
< 	if ( !isset( $from_name ) )
< 		$from_name = 'WordPress';
< 
< 	/* If we don't have an email from the input headers default to wordpress@$sitename
< 	 * Some hosts will block outgoing mail from this address if it doesn't exist but
< 	 * there's no easy alternative. Defaulting to admin_email might appear to be another
< 	 * option but some hosts may refuse to relay mail from an unknown domain. See
< 	 * http://trac.wordpress.org/ticket/5007.
< 	 */
< 
< 	if ( !isset( $from_email ) ) {
< 		// Get the site domain and get rid of www.
< 		$sitename = strtolower( $_SERVER['SERVER_NAME'] );
< 		if ( substr( $sitename, 0, 4 ) == 'www.' ) {
< 			$sitename = substr( $sitename, 4 );
< 		}
< 
< 		$from_email = 'wordpress@' . $sitename;
< 	}
< 
< 	// Plugin authors can override the potentially troublesome default
< 	$phpmailer->From     = apply_filters( 'wp_mail_from'     , $from_email );
< 	$phpmailer->FromName = apply_filters( 'wp_mail_from_name', $from_name  );
< 
< 	// Set destination addresses
< 	if ( !is_array( $to ) )
< 		$to = explode( ',', $to );
< 
< 	foreach ( (array) $to as $recipient ) {
< 		try {
< 			// Break $recipient into name and address parts if in the format "Foo <bar@baz.com>"
< 			$recipient_name = '';
< 			if( preg_match( '/(.*)<(.+)>/', $recipient, $matches ) ) {
< 				if ( count( $matches ) == 3 ) {
< 					$recipient_name = $matches[1];
< 					$recipient = $matches[2];
< 				}
< 			}
< 			$phpmailer->AddAddress( $recipient, $recipient_name);
< 		} catch ( phpmailerException $e ) {
< 			continue;
< 		}
< 	}
< 
< 	// Set mail's subject and body
< 	$phpmailer->Subject = $subject;
< 	$phpmailer->Body    = $message;
< 
< 	// Add any CC and BCC recipients
< 	if ( !empty( $cc ) ) {
< 		foreach ( (array) $cc as $recipient ) {
< 			try {
< 				// Break $recipient into name and address parts if in the format "Foo <bar@baz.com>"
< 				$recipient_name = '';
< 				if( preg_match( '/(.*)<(.+)>/', $recipient, $matches ) ) {
< 					if ( count( $matches ) == 3 ) {
< 						$recipient_name = $matches[1];
< 						$recipient = $matches[2];
< 					}
< 				}
< 				$phpmailer->AddCc( $recipient, $recipient_name );
< 			} catch ( phpmailerException $e ) {
< 				continue;
< 			}
< 		}
< 	}
< 
< 	if ( !empty( $bcc ) ) {
< 		foreach ( (array) $bcc as $recipient) {
< 			try {
< 				// Break $recipient into name and address parts if in the format "Foo <bar@baz.com>"
< 				$recipient_name = '';
< 				if( preg_match( '/(.*)<(.+)>/', $recipient, $matches ) ) {
< 					if ( count( $matches ) == 3 ) {
< 						$recipient_name = $matches[1];
< 						$recipient = $matches[2];
< 					}
< 				}
< 				$phpmailer->AddBcc( $recipient, $recipient_name );
< 			} catch ( phpmailerException $e ) {
< 				continue;
< 			}
< 		}
< 	}
< 
< 	// Set to use PHP's mail()
< 	$phpmailer->IsMail();
< 
< 	// Set Content-Type and charset
< 	// If we don't have a content-type from the input headers
< 	if ( !isset( $content_type ) )
< 		$content_type = 'text/plain';
< 
< 	$content_type = apply_filters( 'wp_mail_content_type', $content_type );
< 
< 	$phpmailer->ContentType = $content_type;
< 
< 	// Set whether it's plaintext, depending on $content_type
< 	if ( 'text/html' == $content_type )
< 		$phpmailer->IsHTML( true );
< 
< 	// If we don't have a charset from the input headers
< 	if ( !isset( $charset ) )
< 		$charset = get_bloginfo( 'charset' );
< 
< 	// Set the content-type and charset
< 	$phpmailer->CharSet = apply_filters( 'wp_mail_charset', $charset );
< 
< 	// Set custom headers
< 	if ( !empty( $headers ) ) {
< 		foreach( (array) $headers as $name => $content ) {
< 			$phpmailer->AddCustomHeader( sprintf( '%1$s: %2$s', $name, $content ) );
< 		}
< 
< 		if ( false !== stripos( $content_type, 'multipart' ) && ! empty($boundary) )
< 			$phpmailer->AddCustomHeader( sprintf( "Content-Type: %s;\n\t boundary=\"%s\"", $content_type, $boundary ) );
< 	}
< 
< 	if ( !empty( $attachments ) ) {
< 		foreach ( $attachments as $attachment ) {
< 			try {
< 				$phpmailer->AddAttachment($attachment);
< 			} catch ( phpmailerException $e ) {
< 				continue;
< 			}
< 		}
< 	}
< 
< 	do_action_ref_array( 'phpmailer_init', array( &$phpmailer ) );
< 
< 	// Send!
< 	try {
< 		$phpmailer->Send();
< 	} catch ( phpmailerException $e ) {
< 		return false;
< 	}
< 
< 	return true;
< }
< endif;
< 
< if ( !function_exists('wp_authenticate') ) :
< /**
<  * Checks a user's login information and logs them in if it checks out.
<  *
<  * @since 2.5.0
<  *
<  * @param string $username User's username
<  * @param string $password User's password
<  * @return WP_Error|WP_User WP_User object if login successful, otherwise WP_Error object.
<  */
< function wp_authenticate($username, $password) {
< 	$username = sanitize_user($username);
< 	$password = trim($password);
< 
< 	$user = apply_filters('authenticate', null, $username, $password);
< 
< 	if ( $user == null ) {
< 		// TODO what should the error message be? (Or would these even happen?)
< 		// Only needed if all authentication handlers fail to return anything.
< 		$user = new WP_Error('authentication_failed', __('<strong>ERROR</strong>: Invalid username or incorrect password.'));
< 	}
< 
< 	$ignore_codes = array('empty_username', 'empty_password');
< 
< 	if (is_wp_error($user) && !in_array($user->get_error_code(), $ignore_codes) ) {
< 		do_action('wp_login_failed', $username);
< 	}
< 
< 	return $user;
< }
< endif;
< 
< if ( !function_exists('wp_logout') ) :
< /**
<  * Log the current user out.
<  *
<  * @since 2.5.0
<  */
< function wp_logout() {
< 	wp_clear_auth_cookie();
< 	do_action('wp_logout');
< }
< endif;
< 
< if ( !function_exists('wp_validate_auth_cookie') ) :
< /**
<  * Validates authentication cookie.
<  *
<  * The checks include making sure that the authentication cookie is set and
<  * pulling in the contents (if $cookie is not used).
<  *
<  * Makes sure the cookie is not expired. Verifies the hash in cookie is what is
<  * should be and compares the two.
<  *
<  * @since 2.5
<  *
<  * @param string $cookie Optional. If used, will validate contents instead of cookie's
<  * @param string $scheme Optional. The cookie scheme to use: auth, secure_auth, or logged_in
<  * @return bool|int False if invalid cookie, User ID if valid.
<  */
< function wp_validate_auth_cookie($cookie = '', $scheme = '') {
< 	if ( ! $cookie_elements = wp_parse_auth_cookie($cookie, $scheme) ) {
< 		do_action('auth_cookie_malformed', $cookie, $scheme);
< 		return false;
< 	}
< 
< 	extract($cookie_elements, EXTR_OVERWRITE);
< 
< 	$expired = $expiration;
< 
< 	// Allow a grace period for POST and AJAX requests
< 	if ( defined('DOING_AJAX') || 'POST' == $_SERVER['REQUEST_METHOD'] )
< 		$expired += 3600;
< 
< 	// Quick check to see if an honest cookie has expired
< 	if ( $expired < time() ) {
< 		do_action('auth_cookie_expired', $cookie_elements);
< 		return false;
< 	}
< 
< 	$user = get_user_by('login', $username);
< 	if ( ! $user ) {
< 		do_action('auth_cookie_bad_username', $cookie_elements);
< 		return false;
< 	}
< 
< 	$pass_frag = substr($user->user_pass, 8, 4);
< 
< 	$key = wp_hash($username . $pass_frag . '|' . $expiration, $scheme);
< 	$hash = hash_hmac('md5', $username . '|' . $expiration, $key);
< 
< 	if ( $hmac != $hash ) {
< 		do_action('auth_cookie_bad_hash', $cookie_elements);
< 		return false;
< 	}
< 
< 	if ( $expiration < time() ) // AJAX/POST grace period set above
< 		$GLOBALS['login_grace_period'] = 1;
< 
< 	do_action('auth_cookie_valid', $cookie_elements, $user);
< 
< 	return $user->ID;
< }
< endif;
< 
< if ( !function_exists('wp_generate_auth_cookie') ) :
< /**
<  * Generate authentication cookie contents.
<  *
<  * @since 2.5
<  * @uses apply_filters() Calls 'auth_cookie' hook on $cookie contents, User ID
<  *		and expiration of cookie.
<  *
<  * @param int $user_id User ID
<  * @param int $expiration Cookie expiration in seconds
<  * @param string $scheme Optional. The cookie scheme to use: auth, secure_auth, or logged_in
<  * @return string Authentication cookie contents
<  */
< function wp_generate_auth_cookie($user_id, $expiration, $scheme = 'auth') {
< 	$user = get_userdata($user_id);
< 
< 	$pass_frag = substr($user->user_pass, 8, 4);
< 
< 	$key = wp_hash($user->user_login . $pass_frag . '|' . $expiration, $scheme);
< 	$hash = hash_hmac('md5', $user->user_login . '|' . $expiration, $key);
< 
< 	$cookie = $user->user_login . '|' . $expiration . '|' . $hash;
< 
< 	return apply_filters('auth_cookie', $cookie, $user_id, $expiration, $scheme);
< }
< endif;
< 
< if ( !function_exists('wp_parse_auth_cookie') ) :
< /**
<  * Parse a cookie into its components
<  *
<  * @since 2.7
<  *
<  * @param string $cookie
<  * @param string $scheme Optional. The cookie scheme to use: auth, secure_auth, or logged_in
<  * @return array Authentication cookie components
<  */
< function wp_parse_auth_cookie($cookie = '', $scheme = '') {
< 	if ( empty($cookie) ) {
< 		switch ($scheme){
< 			case 'auth':
< 				$cookie_name = AUTH_COOKIE;
< 				break;
< 			case 'secure_auth':
< 				$cookie_name = SECURE_AUTH_COOKIE;
< 				break;
< 			case "logged_in":
< 				$cookie_name = LOGGED_IN_COOKIE;
< 				break;
< 			default:
< 				if ( is_ssl() ) {
< 					$cookie_name = SECURE_AUTH_COOKIE;
< 					$scheme = 'secure_auth';
< 				} else {
< 					$cookie_name = AUTH_COOKIE;
< 					$scheme = 'auth';
< 				}
< 	    }
< 
< 		if ( empty($_COOKIE[$cookie_name]) )
< 			return false;
< 		$cookie = $_COOKIE[$cookie_name];
< 	}
< 
< 	$cookie_elements = explode('|', $cookie);
< 	if ( count($cookie_elements) != 3 )
< 		return false;
< 
< 	list($username, $expiration, $hmac) = $cookie_elements;
< 
< 	return compact('username', 'expiration', 'hmac', 'scheme');
< }
< endif;
< 
< if ( !function_exists('wp_set_auth_cookie') ) :
< /**
<  * Sets the authentication cookies based User ID.
<  *
<  * The $remember parameter increases the time that the cookie will be kept. The
<  * default the cookie is kept without remembering is two days. When $remember is
<  * set, the cookies will be kept for 14 days or two weeks.
<  *
<  * @since 2.5
<  *
<  * @param int $user_id User ID
<  * @param bool $remember Whether to remember the user
<  */
< function wp_set_auth_cookie($user_id, $remember = false, $secure = '') {
< 	if ( $remember ) {
< 		$expiration = $expire = time() + apply_filters('auth_cookie_expiration', 1209600, $user_id, $remember);
< 	} else {
< 		$expiration = time() + apply_filters('auth_cookie_expiration', 172800, $user_id, $remember);
< 		$expire = 0;
< 	}
< 
< 	if ( '' === $secure )
< 		$secure = is_ssl();
< 
< 	$secure = apply_filters('secure_auth_cookie', $secure, $user_id);
< 	$secure_logged_in_cookie = apply_filters('secure_logged_in_cookie', false, $user_id, $secure);
< 
< 	if ( $secure ) {
< 		$auth_cookie_name = SECURE_AUTH_COOKIE;
< 		$scheme = 'secure_auth';
< 	} else {
< 		$auth_cookie_name = AUTH_COOKIE;
< 		$scheme = 'auth';
< 	}
< 
< 	$auth_cookie = wp_generate_auth_cookie($user_id, $expiration, $scheme);
< 	$logged_in_cookie = wp_generate_auth_cookie($user_id, $expiration, 'logged_in');
< 
< 	do_action('set_auth_cookie', $auth_cookie, $expire, $expiration, $user_id, $scheme);
< 	do_action('set_logged_in_cookie', $logged_in_cookie, $expire, $expiration, $user_id, 'logged_in');
< 
< 	setcookie($auth_cookie_name, $auth_cookie, $expire, PLUGINS_COOKIE_PATH, COOKIE_DOMAIN, $secure, true);
< 	setcookie($auth_cookie_name, $auth_cookie, $expire, ADMIN_COOKIE_PATH, COOKIE_DOMAIN, $secure, true);
< 	setcookie(LOGGED_IN_COOKIE, $logged_in_cookie, $expire, COOKIEPATH, COOKIE_DOMAIN, $secure_logged_in_cookie, true);
< 	if ( COOKIEPATH != SITECOOKIEPATH )
< 		setcookie(LOGGED_IN_COOKIE, $logged_in_cookie, $expire, SITECOOKIEPATH, COOKIE_DOMAIN, $secure_logged_in_cookie, true);
< }
< endif;
< 
< if ( !function_exists('wp_clear_auth_cookie') ) :
< /**
<  * Removes all of the cookies associated with authentication.
<  *
<  * @since 2.5
<  */
< function wp_clear_auth_cookie() {
< 	do_action('clear_auth_cookie');
< 
< 	setcookie(AUTH_COOKIE, ' ', time() - 31536000, ADMIN_COOKIE_PATH, COOKIE_DOMAIN);
< 	setcookie(SECURE_AUTH_COOKIE, ' ', time() - 31536000, ADMIN_COOKIE_PATH, COOKIE_DOMAIN);
< 	setcookie(AUTH_COOKIE, ' ', time() - 31536000, PLUGINS_COOKIE_PATH, COOKIE_DOMAIN);
< 	setcookie(SECURE_AUTH_COOKIE, ' ', time() - 31536000, PLUGINS_COOKIE_PATH, COOKIE_DOMAIN);
< 	setcookie(LOGGED_IN_COOKIE, ' ', time() - 31536000, COOKIEPATH, COOKIE_DOMAIN);
< 	setcookie(LOGGED_IN_COOKIE, ' ', time() - 31536000, SITECOOKIEPATH, COOKIE_DOMAIN);
< 
< 	// Old cookies
< 	setcookie(AUTH_COOKIE, ' ', time() - 31536000, COOKIEPATH, COOKIE_DOMAIN);
< 	setcookie(AUTH_COOKIE, ' ', time() - 31536000, SITECOOKIEPATH, COOKIE_DOMAIN);
< 	setcookie(SECURE_AUTH_COOKIE, ' ', time() - 31536000, COOKIEPATH, COOKIE_DOMAIN);
< 	setcookie(SECURE_AUTH_COOKIE, ' ', time() - 31536000, SITECOOKIEPATH, COOKIE_DOMAIN);
< 
< 	// Even older cookies
< 	setcookie(USER_COOKIE, ' ', time() - 31536000, COOKIEPATH, COOKIE_DOMAIN);
< 	setcookie(PASS_COOKIE, ' ', time() - 31536000, COOKIEPATH, COOKIE_DOMAIN);
< 	setcookie(USER_COOKIE, ' ', time() - 31536000, SITECOOKIEPATH, COOKIE_DOMAIN);
< 	setcookie(PASS_COOKIE, ' ', time() - 31536000, SITECOOKIEPATH, COOKIE_DOMAIN);
< }
< endif;
< 
< if ( !function_exists('is_user_logged_in') ) :
< /**
<  * Checks if the current visitor is a logged in user.
<  *
<  * @since 2.0.0
<  *
<  * @return bool True if user is logged in, false if not logged in.
<  */
< function is_user_logged_in() {
< 	$user = wp_get_current_user();
< 
< 	if ( empty( $user->ID ) )
< 		return false;
< 
< 	return true;
< }
< endif;
< 
< if ( !function_exists('auth_redirect') ) :
< /**
<  * Checks if a user is logged in, if not it redirects them to the login page.
<  *
<  * @since 1.5
<  */
< function auth_redirect() {
< 	// Checks if a user is logged in, if not redirects them to the login page
< 
< 	$secure = ( is_ssl() || force_ssl_admin() );
< 
< 	$secure = apply_filters('secure_auth_redirect', $secure);
< 
< 	// If https is required and request is http, redirect
< 	if ( $secure && !is_ssl() && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin') ) {
< 		if ( 0 === strpos($_SERVER['REQUEST_URI'], 'http') ) {
< 			wp_redirect(preg_replace('|^http://|', 'https://', $_SERVER['REQUEST_URI']));
< 			exit();
< 		} else {
< 			wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
< 			exit();
< 		}
< 	}
< 
< 	if ( is_user_admin() )
< 		$scheme = 'logged_in';
< 	else
< 		$scheme = apply_filters( 'auth_redirect_scheme', '' );
< 
< 	if ( $user_id = wp_validate_auth_cookie( '',  $scheme) ) {
< 		do_action('auth_redirect', $user_id);
< 
< 		// If the user wants ssl but the session is not ssl, redirect.
< 		if ( !$secure && get_user_option('use_ssl', $user_id) && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin') ) {
< 			if ( 0 === strpos($_SERVER['REQUEST_URI'], 'http') ) {
< 				wp_redirect(preg_replace('|^http://|', 'https://', $_SERVER['REQUEST_URI']));
< 				exit();
< 			} else {
< 				wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
< 				exit();
< 			}
< 		}
< 
< 		return;  // The cookie is good so we're done
< 	}
< 
< 	// The cookie is no good so force login
< 	nocache_headers();
< 
< 	if ( is_ssl() )
< 		$proto = 'https://';
< 	else
< 		$proto = 'http://';
< 
< 	$redirect = ( strpos($_SERVER['REQUEST_URI'], '/options.php') && wp_get_referer() ) ? wp_get_referer() : $proto . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
< 
< 	$login_url = wp_login_url($redirect, true);
< 
< 	wp_redirect($login_url);
< 	exit();
< }
< endif;
< 
< if ( !function_exists('check_admin_referer') ) :
< /**
<  * Makes sure that a user was referred from another admin page.
<  *
<  * To avoid security exploits.
<  *
<  * @since 1.2.0
<  * @uses do_action() Calls 'check_admin_referer' on $action.
<  *
<  * @param string $action Action nonce
<  * @param string $query_arg where to look for nonce in $_REQUEST (since 2.5)
<  */
< function check_admin_referer($action = -1, $query_arg = '_wpnonce') {
< 	if ( -1 == $action )
< 		_doing_it_wrong( __FUNCTION__, __( 'You should specify a nonce action to be verified by using the first parameter.' ), '3.2' );
< 
< 	$adminurl = strtolower(admin_url());
< 	$referer = strtolower(wp_get_referer());
< 	$result = isset($_REQUEST[$query_arg]) ? wp_verify_nonce($_REQUEST[$query_arg], $action) : false;
< 	if ( !$result && !(-1 == $action && strpos($referer, $adminurl) === 0) ) {
< 		wp_nonce_ays($action);
< 		die();
< 	}
< 	do_action('check_admin_referer', $action, $result);
< 	return $result;
< }endif;
< 
< if ( !function_exists('check_ajax_referer') ) :
< /**
<  * Verifies the AJAX request to prevent processing requests external of the blog.
<  *
<  * @since 2.0.3
<  *
<  * @param string $action Action nonce
<  * @param string $query_arg where to look for nonce in $_REQUEST (since 2.5)
<  */
< function check_ajax_referer( $action = -1, $query_arg = false, $die = true ) {
< 	if ( $query_arg )
< 		$nonce = $_REQUEST[$query_arg];
< 	else
< 		$nonce = isset($_REQUEST['_ajax_nonce']) ? $_REQUEST['_ajax_nonce'] : $_REQUEST['_wpnonce'];
< 
< 	$result = wp_verify_nonce( $nonce, $action );
< 
< 	if ( $die && false == $result )
< 		die('-1');
< 
< 	do_action('check_ajax_referer', $action, $result);
< 
< 	return $result;
< }
< endif;
< 
< if ( !function_exists('wp_redirect') ) :
< /**
<  * Redirects to another page.
<  *
<  * @since 1.5.1
<  * @uses apply_filters() Calls 'wp_redirect' hook on $location and $status.
<  *
<  * @param string $location The path to redirect to
<  * @param int $status Status code to use
<  * @return bool False if $location is not set
<  */
< function wp_redirect($location, $status = 302) {
< 	global $is_IIS;
< 
< 	$location = apply_filters('wp_redirect', $location, $status);
< 	$status = apply_filters('wp_redirect_status', $status, $location);
< 
< 	if ( !$location ) // allows the wp_redirect filter to cancel a redirect
< 		return false;
< 
< 	$location = wp_sanitize_redirect($location);
< 
< 	if ( !$is_IIS && php_sapi_name() != 'cgi-fcgi' )
< 		status_header($status); // This causes problems on IIS and some FastCGI setups
< 
< 	header("Location: $location", true, $status);
< }
< endif;
< 
< if ( !function_exists('wp_sanitize_redirect') ) :
< /**
<  * Sanitizes a URL for use in a redirect.
<  *
<  * @since 2.3
<  *
<  * @return string redirect-sanitized URL
<  **/
< function wp_sanitize_redirect($location) {
< 	$location = preg_replace('|[^a-z0-9-~+_.?#=&;,/:%!]|i', '', $location);
< 	$location = wp_kses_no_null($location);
< 
< 	// remove %0d and %0a from location
< 	$strip = array('%0d', '%0a', '%0D', '%0A');
< 	$location = _deep_replace($strip, $location);
< 	return $location;
< }
< endif;
< 
< if ( !function_exists('wp_safe_redirect') ) :
< /**
<  * Performs a safe (local) redirect, using wp_redirect().
<  *
<  * Checks whether the $location is using an allowed host, if it has an absolute
<  * path. A plugin can therefore set or remove allowed host(s) to or from the
<  * list.
<  *
<  * If the host is not allowed, then the redirect is to wp-admin on the siteurl
<  * instead. This prevents malicious redirects which redirect to another host,
<  * but only used in a few places.
<  *
<  * @since 2.3
<  * @uses wp_validate_redirect() To validate the redirect is to an allowed host.
<  *
<  * @return void Does not return anything
<  **/
< function wp_safe_redirect($location, $status = 302) {
< 
< 	// Need to look at the URL the way it will end up in wp_redirect()
< 	$location = wp_sanitize_redirect($location);
< 
< 	$location = wp_validate_redirect($location, admin_url());
< 
< 	wp_redirect($location, $status);
< }
< endif;
< 
< if ( !function_exists('wp_validate_redirect') ) :
< /**
<  * Validates a URL for use in a redirect.
<  *
<  * Checks whether the $location is using an allowed host, if it has an absolute
<  * path. A plugin can therefore set or remove allowed host(s) to or from the
<  * list.
<  *
<  * If the host is not allowed, then the redirect is to $default supplied
<  *
<  * @since 2.8.1
<  * @uses apply_filters() Calls 'allowed_redirect_hosts' on an array containing
<  *		WordPress host string and $location host string.
<  *
<  * @param string $location The redirect to validate
<  * @param string $default The value to return is $location is not allowed
<  * @return string redirect-sanitized URL
<  **/
< function wp_validate_redirect($location, $default = '') {
< 	// browsers will assume 'http' is your protocol, and will obey a redirect to a URL starting with '//'
< 	if ( substr($location, 0, 2) == '//' )
< 		$location = 'http:' . $location;
< 
< 	// In php 5 parse_url may fail if the URL query part contains http://, bug #38143
< 	$test = ( $cut = strpos($location, '?') ) ? substr( $location, 0, $cut ) : $location;
< 
< 	$lp  = parse_url($test);
< 
< 	// Give up if malformed URL
< 	if ( false === $lp )
< 		return $default;
< 
< 	// Allow only http and https schemes. No data:, etc.
< 	if ( isset($lp['scheme']) && !('http' == $lp['scheme'] || 'https' == $lp['scheme']) )
< 		return $default;
< 
< 	// Reject if scheme is set but host is not. This catches urls like https:host.com for which parse_url does not set the host field.
< 	if ( isset($lp['scheme'])  && !isset($lp['host']) )
< 		return $default;
< 
< 	$wpp = parse_url(home_url());
< 
< 	$allowed_hosts = (array) apply_filters('allowed_redirect_hosts', array($wpp['host']), isset($lp['host']) ? $lp['host'] : '');
< 
< 	if ( isset($lp['host']) && ( !in_array($lp['host'], $allowed_hosts) && $lp['host'] != strtolower($wpp['host'])) )
< 		$location = $default;
< 
< 	return $location;
< }
< endif;
< 
< if ( ! function_exists('wp_notify_postauthor') ) :
< /**
<  * Notify an author of a comment/trackback/pingback to one of their posts.
<  *
<  * @since 1.0.0
<  *
<  * @param int $comment_id Comment ID
<  * @param string $comment_type Optional. The comment type either 'comment' (default), 'trackback', or 'pingback'
<  * @return bool False if user email does not exist. True on completion.
<  */
< function wp_notify_postauthor( $comment_id, $comment_type = '' ) {
< 	$comment = get_comment( $comment_id );
< 	$post    = get_post( $comment->comment_post_ID );
< 	$author  = get_userdata( $post->post_author );
< 
< 	// The comment was left by the author
< 	if ( $comment->user_id == $post->post_author )
< 		return false;
< 
< 	// The author moderated a comment on his own post
< 	if ( $post->post_author == get_current_user_id() )
< 		return false;
< 
< 	// If there's no email to send the comment to
< 	if ( '' == $author->user_email )
< 		return false;
< 
< 	$comment_author_domain = @gethostbyaddr($comment->comment_author_IP);
< 
< 	// 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.
< 	$blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
< 
< 	if ( empty( $comment_type ) ) $comment_type = 'comment';
< 
< 	if ('comment' == $comment_type) {
< 		$notify_message  = sprintf( __( 'New comment on your post "%s"' ), $post->post_title ) . "\r\n";
< 		/* translators: 1: comment author, 2: author IP, 3: author domain */
< 		$notify_message .= sprintf( __('Author : %1$s (IP: %2$s , %3$s)'), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n";
< 		$notify_message .= sprintf( __('E-mail : %s'), $comment->comment_author_email ) . "\r\n";
< 		$notify_message .= sprintf( __('URL    : %s'), $comment->comment_author_url ) . "\r\n";
< 		$notify_message .= sprintf( __('Whois  : http://whois.arin.net/rest/ip/%s'), $comment->comment_author_IP ) . "\r\n";
< 		$notify_message .= __('Comment: ') . "\r\n" . $comment->comment_content . "\r\n\r\n";
< 		$notify_message .= __('You can see all comments on this post here: ') . "\r\n";
< 		/* translators: 1: blog name, 2: post title */
< 		$subject = sprintf( __('[%1$s] Comment: "%2$s"'), $blogname, $post->post_title );
< 	} elseif ('trackback' == $comment_type) {
< 		$notify_message  = sprintf( __( 'New trackback on your post "%s"' ), $post->post_title ) . "\r\n";
< 		/* translators: 1: website name, 2: author IP, 3: author domain */
< 		$notify_message .= sprintf( __('Website: %1$s (IP: %2$s , %3$s)'), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n";
< 		$notify_message .= sprintf( __('URL    : %s'), $comment->comment_author_url ) . "\r\n";
< 		$notify_message .= __('Excerpt: ') . "\r\n" . $comment->comment_content . "\r\n\r\n";
< 		$notify_message .= __('You can see all trackbacks on this post here: ') . "\r\n";
< 		/* translators: 1: blog name, 2: post title */
< 		$subject = sprintf( __('[%1$s] Trackback: "%2$s"'), $blogname, $post->post_title );
< 	} elseif ('pingback' == $comment_type) {
< 		$notify_message  = sprintf( __( 'New pingback on your post "%s"' ), $post->post_title ) . "\r\n";
< 		/* translators: 1: comment author, 2: author IP, 3: author domain */
< 		$notify_message .= sprintf( __('Website: %1$s (IP: %2$s , %3$s)'), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n";
< 		$notify_message .= sprintf( __('URL    : %s'), $comment->comment_author_url ) . "\r\n";
< 		$notify_message .= __('Excerpt: ') . "\r\n" . sprintf('[...] %s [...]', $comment->comment_content ) . "\r\n\r\n";
< 		$notify_message .= __('You can see all pingbacks on this post here: ') . "\r\n";
< 		/* translators: 1: blog name, 2: post title */
< 		$subject = sprintf( __('[%1$s] Pingback: "%2$s"'), $blogname, $post->post_title );
< 	}
< 	$notify_message .= get_permalink($comment->comment_post_ID) . "#comments\r\n\r\n";
< 	$notify_message .= sprintf( __('Permalink: %s'), get_permalink( $comment->comment_post_ID ) . '#comment-' . $comment_id ) . "\r\n";
< 	if ( EMPTY_TRASH_DAYS )
< 		$notify_message .= sprintf( __('Trash it: %s'), admin_url("comment.php?action=trash&c=$comment_id") ) . "\r\n";
< 	else
< 		$notify_message .= sprintf( __('Delete it: %s'), admin_url("comment.php?action=delete&c=$comment_id") ) . "\r\n";
< 	$notify_message .= sprintf( __('Spam it: %s'), admin_url("comment.php?action=spam&c=$comment_id") ) . "\r\n";
< 
< 	$wp_email = 'wordpress@' . preg_replace('#^www\.#', '', strtolower($_SERVER['SERVER_NAME']));
< 
< 	if ( '' == $comment->comment_author ) {
< 		$from = "From: \"$blogname\" <$wp_email>";
< 		if ( '' != $comment->comment_author_email )
< 			$reply_to = "Reply-To: $comment->comment_author_email";
< 	} else {
< 		$from = "From: \"$comment->comment_author\" <$wp_email>";
< 		if ( '' != $comment->comment_author_email )
< 			$reply_to = "Reply-To: \"$comment->comment_author_email\" <$comment->comment_author_email>";
< 	}
< 
< 	$message_headers = "$from\n"
< 		. "Content-Type: text/plain; charset=\"" . get_option('blog_charset') . "\"\n";
< 
< 	if ( isset($reply_to) )
< 		$message_headers .= $reply_to . "\n";
< 
< 	$notify_message = apply_filters('comment_notification_text', $notify_message, $comment_id);
< 	$subject = apply_filters('comment_notification_subject', $subject, $comment_id);
< 	$message_headers = apply_filters('comment_notification_headers', $message_headers, $comment_id);
< 
< 	@wp_mail( $author->user_email, $subject, $notify_message, $message_headers );
< 
< 	return true;
< }
< endif;
< 
< if ( !function_exists('wp_notify_moderator') ) :
< /**
<  * Notifies the moderator of the blog about a new comment that is awaiting approval.
<  *
<  * @since 1.0
<  * @uses $wpdb
<  *
<  * @param int $comment_id Comment ID
<  * @return bool Always returns true
<  */
< function wp_notify_moderator($comment_id) {
< 	global $wpdb;
< 
< 	if ( 0 == get_option( 'moderation_notify' ) )
< 		return true;
< 
< 	$comment = get_comment($comment_id);
< 	$post = get_post($comment->comment_post_ID);
< 	$user = get_userdata( $post->post_author );
< 	// Send to the administration and to the post author if the author can modify the comment.
< 	$email_to = array( get_option('admin_email') );
< 	if ( user_can($user->ID, 'edit_comment', $comment_id) && !empty($user->user_email) && ( get_option('admin_email') != $user->user_email) )
< 		$email_to[] = $user->user_email;
< 
< 	$comment_author_domain = @gethostbyaddr($comment->comment_author_IP);
< 	$comments_waiting = $wpdb->get_var("SELECT count(comment_ID) FROM $wpdb->comments WHERE comment_approved = '0'");
< 
< 	// 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.
< 	$blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
< 
< 	switch ($comment->comment_type)
< 	{
< 		case 'trackback':
< 			$notify_message  = sprintf( __('A new trackback on the post "%s" is waiting for your approval'), $post->post_title ) . "\r\n";
< 			$notify_message .= get_permalink($comment->comment_post_ID) . "\r\n\r\n";
< 			$notify_message .= sprintf( __('Website : %1$s (IP: %2$s , %3$s)'), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n";
< 			$notify_message .= sprintf( __('URL    : %s'), $comment->comment_author_url ) . "\r\n";
< 			$notify_message .= __('Trackback excerpt: ') . "\r\n" . $comment->comment_content . "\r\n\r\n";
< 			break;
< 		case 'pingback':
< 			$notify_message  = sprintf( __('A new pingback on the post "%s" is waiting for your approval'), $post->post_title ) . "\r\n";
< 			$notify_message .= get_permalink($comment->comment_post_ID) . "\r\n\r\n";
< 			$notify_message .= sprintf( __('Website : %1$s (IP: %2$s , %3$s)'), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n";
< 			$notify_message .= sprintf( __('URL    : %s'), $comment->comment_author_url ) . "\r\n";
< 			$notify_message .= __('Pingback excerpt: ') . "\r\n" . $comment->comment_content . "\r\n\r\n";
< 			break;
< 		default: //Comments
< 			$notify_message  = sprintf( __('A new comment on the post "%s" is waiting for your approval'), $post->post_title ) . "\r\n";
< 			$notify_message .= get_permalink($comment->comment_post_ID) . "\r\n\r\n";
< 			$notify_message .= sprintf( __('Author : %1$s (IP: %2$s , %3$s)'), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n";
< 			$notify_message .= sprintf( __('E-mail : %s'), $comment->comment_author_email ) . "\r\n";
< 			$notify_message .= sprintf( __('URL    : %s'), $comment->comment_author_url ) . "\r\n";
< 			$notify_message .= sprintf( __('Whois  : http://whois.arin.net/rest/ip/%s'), $comment->comment_author_IP ) . "\r\n";
< 			$notify_message .= __('Comment: ') . "\r\n" . $comment->comment_content . "\r\n\r\n";
< 			break;
< 	}
< 
< 	$notify_message .= sprintf( __('Approve it: %s'),  admin_url("comment.php?action=approve&c=$comment_id") ) . "\r\n";
< 	if ( EMPTY_TRASH_DAYS )
< 		$notify_message .= sprintf( __('Trash it: %s'), admin_url("comment.php?action=trash&c=$comment_id") ) . "\r\n";
< 	else
< 		$notify_message .= sprintf( __('Delete it: %s'), admin_url("comment.php?action=delete&c=$comment_id") ) . "\r\n";
< 	$notify_message .= sprintf( __('Spam it: %s'), admin_url("comment.php?action=spam&c=$comment_id") ) . "\r\n";
< 
< 	$notify_message .= sprintf( _n('Currently %s comment is waiting for approval. Please visit the moderation panel:',
<  		'Currently %s comments are waiting for approval. Please visit the moderation panel:', $comments_waiting), number_format_i18n($comments_waiting) ) . "\r\n";
< 	$notify_message .= admin_url("edit-comments.php?comment_status=moderated") . "\r\n";
< 
< 	$subject = sprintf( __('[%1$s] Please moderate: "%2$s"'), $blogname, $post->post_title );
< 	$message_headers = '';
< 
< 	$notify_message = apply_filters('comment_moderation_text', $notify_message, $comment_id);
< 	$subject = apply_filters('comment_moderation_subject', $subject, $comment_id);
< 	$message_headers = apply_filters('comment_moderation_headers', $message_headers);
< 
< 	foreach ( $email_to as $email )
< 		@wp_mail($email, $subject, $notify_message, $message_headers);
< 
< 	return true;
< }
< endif;
< 
< if ( !function_exists('wp_password_change_notification') ) :
< /**
<  * Notify the blog admin of a user changing password, normally via email.
<  *
<  * @since 2.7
<  *
<  * @param object $user User Object
<  */
< function wp_password_change_notification(&$user) {
< 	// send a copy of password change notification to the admin
< 	// but check to see if it's the admin whose password we're changing, and skip this
< 	if ( $user->user_email != get_option('admin_email') ) {
< 		$message = sprintf(__('Password Lost and Changed for user: %s'), $user->user_login) . "\r\n";
< 		// 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.
< 		$blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
< 		wp_mail(get_option('admin_email'), sprintf(__('[%s] Password Lost/Changed'), $blogname), $message);
< 	}
< }
< endif;
< 
< if ( !function_exists('wp_new_user_notification') ) :
< /**
<  * Notify the blog admin of a new user, normally via email.
<  *
<  * @since 2.0
<  *
<  * @param int $user_id User ID
<  * @param string $plaintext_pass Optional. The user's plaintext password
<  */
< function wp_new_user_notification($user_id, $plaintext_pass = '') {
< 	$user = new WP_User($user_id);
< 
< 	$user_login = stripslashes($user->user_login);
< 	$user_email = stripslashes($user->user_email);
< 
< 	// 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.
< 	$blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
< 
< 	$message  = sprintf(__('New user registration on your site %s:'), $blogname) . "\r\n\r\n";
< 	$message .= sprintf(__('Username: %s'), $user_login) . "\r\n\r\n";
< 	$message .= sprintf(__('E-mail: %s'), $user_email) . "\r\n";
< 
< 	@wp_mail(get_option('admin_email'), sprintf(__('[%s] New User Registration'), $blogname), $message);
< 
< 	if ( empty($plaintext_pass) )
< 		return;
< 
< 	$message  = sprintf(__('Username: %s'), $user_login) . "\r\n";
< 	$message .= sprintf(__('Password: %s'), $plaintext_pass) . "\r\n";
< 	$message .= wp_login_url() . "\r\n";
< 
< 	wp_mail($user_email, sprintf(__('[%s] Your username and password'), $blogname), $message);
< 
< }
< endif;
< 
< if ( !function_exists('wp_nonce_tick') ) :
< /**
<  * Get the time-dependent variable for nonce creation.
<  *
<  * A nonce has a lifespan of two ticks. Nonces in their second tick may be
<  * updated, e.g. by autosave.
<  *
<  * @since 2.5
<  *
<  * @return int
<  */
< function wp_nonce_tick() {
< 	$nonce_life = apply_filters('nonce_life', 86400);
< 
< 	return ceil(time() / ( $nonce_life / 2 ));
< }
< endif;
< 
< if ( !function_exists('wp_verify_nonce') ) :
< /**
<  * Verify that correct nonce was used with time limit.
<  *
<  * The user is given an amount of time to use the token, so therefore, since the
<  * UID and $action remain the same, the independent variable is the time.
<  *
<  * @since 2.0.3
<  *
<  * @param string $nonce Nonce that was used in the form to verify
<  * @param string|int $action Should give context to what is taking place and be the same when nonce was created.
<  * @return bool Whether the nonce check passed or failed.
<  */
< function wp_verify_nonce($nonce, $action = -1) {
< 	$user = wp_get_current_user();
< 	$uid = (int) $user->ID;
< 
< 	$i = wp_nonce_tick();
< 
< 	// Nonce generated 0-12 hours ago
< 	if ( substr(wp_hash($i . $action . $uid, 'nonce'), -12, 10) == $nonce )
< 		return 1;
< 	// Nonce generated 12-24 hours ago
< 	if ( substr(wp_hash(($i - 1) . $action . $uid, 'nonce'), -12, 10) == $nonce )
< 		return 2;
< 	// Invalid nonce
< 	return false;
< }
< endif;
< 
< if ( !function_exists('wp_create_nonce') ) :
< /**
<  * Creates a random, one time use token.
<  *
<  * @since 2.0.3
<  *
<  * @param string|int $action Scalar value to add context to the nonce.
<  * @return string The one use form token
<  */
< function wp_create_nonce($action = -1) {
< 	$user = wp_get_current_user();
< 	$uid = (int) $user->ID;
< 
< 	$i = wp_nonce_tick();
< 
< 	return substr(wp_hash($i . $action . $uid, 'nonce'), -12, 10);
< }
< endif;
< 
< if ( !function_exists('wp_salt') ) :
< /**
<  * Get salt to add to hashes to help prevent attacks.
<  *
<  * The secret key is located in two places: the database in case the secret key
<  * isn't defined in the second place, which is in the wp-config.php file. If you
<  * are going to set the secret key, then you must do so in the wp-config.php
<  * file.
<  *
<  * The secret key in the database is randomly generated and will be appended to
<  * the secret key that is in wp-config.php file in some instances. It is
<  * important to have the secret key defined or changed in wp-config.php.
<  *
<  * If you have installed WordPress 2.5 or later, then you will have the
<  * SECRET_KEY defined in the wp-config.php already. You will want to change the
<  * value in it because hackers will know what it is. If you have upgraded to
<  * WordPress 2.5 or later version from a version before WordPress 2.5, then you
<  * should add the constant to your wp-config.php file.
<  *
<  * Below is an example of how the SECRET_KEY constant is defined with a value.
<  * You must not copy the below example and paste into your wp-config.php. If you
<  * need an example, then you can have a
<  * {@link https://api.wordpress.org/secret-key/1.1/ secret key created} for you.
<  *
<  * <code>
<  * define('SECRET_KEY', 'mAry1HadA15|\/|b17w55w1t3asSn09w');
<  * </code>
<  *
<  * Salting passwords helps against tools which has stored hashed values of
<  * common dictionary strings. The added values makes it harder to crack if given
<  * salt string is not weak.
<  *
<  * @since 2.5
<  * @link https://api.wordpress.org/secret-key/1.1/ Create a Secret Key for wp-config.php
<  *
<  * @param string $scheme Authentication scheme
<  * @return string Salt value
<  */
< function wp_salt($scheme = 'auth') {
< 	global $wp_default_secret_key;
< 	$secret_key = '';
< 	if ( defined('SECRET_KEY') && ('' != SECRET_KEY) && ( $wp_default_secret_key != SECRET_KEY) )
< 		$secret_key = SECRET_KEY;
< 
< 	if ( 'auth' == $scheme ) {
< 		if ( defined('AUTH_KEY') && ('' != AUTH_KEY) && ( $wp_default_secret_key != AUTH_KEY) )
< 			$secret_key = AUTH_KEY;
< 
< 		if ( defined('AUTH_SALT') && ('' != AUTH_SALT) && ( $wp_default_secret_key != AUTH_SALT) ) {
< 			$salt = AUTH_SALT;
< 		} elseif ( defined('SECRET_SALT') && ('' != SECRET_SALT) && ( $wp_default_secret_key != SECRET_SALT) ) {
< 			$salt = SECRET_SALT;
< 		} else {
< 			$salt = get_site_option('auth_salt');
< 			if ( empty($salt) ) {
< 				$salt = wp_generate_password( 64, true, true );
< 				update_site_option('auth_salt', $salt);
< 			}
< 		}
< 	} elseif ( 'secure_auth' == $scheme ) {
< 		if ( defined('SECURE_AUTH_KEY') && ('' != SECURE_AUTH_KEY) && ( $wp_default_secret_key != SECURE_AUTH_KEY) )
< 			$secret_key = SECURE_AUTH_KEY;
< 
< 		if ( defined('SECURE_AUTH_SALT') && ('' != SECURE_AUTH_SALT) && ( $wp_default_secret_key != SECURE_AUTH_SALT) ) {
< 			$salt = SECURE_AUTH_SALT;
< 		} else {
< 			$salt = get_site_option('secure_auth_salt');
< 			if ( empty($salt) ) {
< 				$salt = wp_generate_password( 64, true, true );
< 				update_site_option('secure_auth_salt', $salt);
< 			}
< 		}
< 	} elseif ( 'logged_in' == $scheme ) {
< 		if ( defined('LOGGED_IN_KEY') && ('' != LOGGED_IN_KEY) && ( $wp_default_secret_key != LOGGED_IN_KEY) )
< 			$secret_key = LOGGED_IN_KEY;
< 
< 		if ( defined('LOGGED_IN_SALT') && ('' != LOGGED_IN_SALT) && ( $wp_default_secret_key != LOGGED_IN_SALT) ) {
< 			$salt = LOGGED_IN_SALT;
< 		} else {
< 			$salt = get_site_option('logged_in_salt');
< 			if ( empty($salt) ) {
< 				$salt = wp_generate_password( 64, true, true );
< 				update_site_option('logged_in_salt', $salt);
< 			}
< 		}
< 	} elseif ( 'nonce' == $scheme ) {
< 		if ( defined('NONCE_KEY') && ('' != NONCE_KEY) && ( $wp_default_secret_key != NONCE_KEY) )
< 			$secret_key = NONCE_KEY;
< 
< 		if ( defined('NONCE_SALT') && ('' != NONCE_SALT) && ( $wp_default_secret_key != NONCE_SALT) ) {
< 			$salt = NONCE_SALT;
< 		} else {
< 			$salt = get_site_option('nonce_salt');
< 			if ( empty($salt) ) {
< 				$salt = wp_generate_password( 64, true, true );
< 				update_site_option('nonce_salt', $salt);
< 			}
< 		}
< 	} else {
< 		// ensure each auth scheme has its own unique salt
< 		$salt = hash_hmac('md5', $scheme, $secret_key);
< 	}
< 
< 	return apply_filters('salt', $secret_key . $salt, $scheme);
< }
< endif;
< 
< if ( !function_exists('wp_hash') ) :
< /**
<  * Get hash of given string.
<  *
<  * @since 2.0.3
<  * @uses wp_salt() Get WordPress salt
<  *
<  * @param string $data Plain text to hash
<  * @return string Hash of $data
<  */
< function wp_hash($data, $scheme = 'auth') {
< 	$salt = wp_salt($scheme);
< 
< 	return hash_hmac('md5', $data, $salt);
< }
< endif;
< 
< if ( !function_exists('wp_hash_password') ) :
< /**
<  * Create a hash (encrypt) of a plain text password.
<  *
<  * For integration with other applications, this function can be overwritten to
<  * instead use the other package password checking algorithm.
<  *
<  * @since 2.5
<  * @global object $wp_hasher PHPass object
<  * @uses PasswordHash::HashPassword
<  *
<  * @param string $password Plain text user password to hash
<  * @return string The hash string of the password
<  */
< function wp_hash_password($password) {
< 	global $wp_hasher;
< 
< 	if ( empty($wp_hasher) ) {
< 		require_once( ABSPATH . 'wp-includes/class-phpass.php');
< 		// By default, use the portable hash from phpass
< 		$wp_hasher = new PasswordHash(8, TRUE);
< 	}
< 
< 	return $wp_hasher->HashPassword($password);
< }
< endif;
< 
< if ( !function_exists('wp_check_password') ) :
< /**
<  * Checks the plaintext password against the encrypted Password.
<  *
<  * Maintains compatibility between old version and the new cookie authentication
<  * protocol using PHPass library. The $hash parameter is the encrypted password
<  * and the function compares the plain text password when encrypted similarly
<  * against the already encrypted password to see if they match.
<  *
<  * For integration with other applications, this function can be overwritten to
<  * instead use the other package password checking algorithm.
<  *
<  * @since 2.5
<  * @global object $wp_hasher PHPass object used for checking the password
<  *	against the $hash + $password
<  * @uses PasswordHash::CheckPassword
<  *
<  * @param string $password Plaintext user's password
<  * @param string $hash Hash of the user's password to check against.
<  * @return bool False, if the $password does not match the hashed password
<  */
< function wp_check_password($password, $hash, $user_id = '') {
< 	global $wp_hasher;
< 
< 	// If the hash is still md5...
< 	if ( strlen($hash) <= 32 ) {
< 		$check = ( $hash == md5($password) );
< 		if ( $check && $user_id ) {
< 			// Rehash using new hash.
< 			wp_set_password($password, $user_id);
< 			$hash = wp_hash_password($password);
< 		}
< 
< 		return apply_filters('check_password', $check, $password, $hash, $user_id);
< 	}
< 
< 	// If the stored hash is longer than an MD5, presume the
< 	// new style phpass portable hash.
< 	if ( empty($wp_hasher) ) {
< 		require_once( ABSPATH . 'wp-includes/class-phpass.php');
< 		// By default, use the portable hash from phpass
< 		$wp_hasher = new PasswordHash(8, TRUE);
< 	}
< 
< 	$check = $wp_hasher->CheckPassword($password, $hash);
< 
< 	return apply_filters('check_password', $check, $password, $hash, $user_id);
< }
< endif;
< 
< if ( !function_exists('wp_generate_password') ) :
< /**
<  * Generates a random password drawn from the defined set of characters.
<  *
<  * @since 2.5
<  *
<  * @param int $length The length of password to generate
<  * @param bool $special_chars Whether to include standard special characters. Default true.
<  * @param bool $extra_special_chars Whether to include other special characters. Used when
<  *   generating secret keys and salts. Default false.
<  * @return string The random password
<  **/
< function wp_generate_password( $length = 12, $special_chars = true, $extra_special_chars = false ) {
< 	$chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
< 	if ( $special_chars )
< 		$chars .= '!@#$%^&*()';
< 	if ( $extra_special_chars )
< 		$chars .= '-_ []{}<>~`+=,.;:/?|';
< 
< 	$password = '';
< 	for ( $i = 0; $i < $length; $i++ ) {
< 		$password .= substr($chars, wp_rand(0, strlen($chars) - 1), 1);
< 	}
< 
< 	// random_password filter was previously in random_password function which was deprecated
< 	return apply_filters('random_password', $password);
< }
< endif;
< 
< if ( !function_exists('wp_rand') ) :
<  /**
<  * Generates a random number
<  *
<  * @since 2.6.2
<  *
<  * @param int $min Lower limit for the generated number (optional, default is 0)
<  * @param int $max Upper limit for the generated number (optional, default is 4294967295)
<  * @return int A random number between min and max
<  */
< function wp_rand( $min = 0, $max = 0 ) {
< 	global $rnd_value;
< 
< 	// Reset $rnd_value after 14 uses
< 	// 32(md5) + 40(sha1) + 40(sha1) / 8 = 14 random numbers from $rnd_value
< 	if ( strlen($rnd_value) < 8 ) {
< 		if ( defined( 'WP_SETUP_CONFIG' ) )
< 			static $seed = '';
< 		else
< 			$seed = get_transient('random_seed');
< 		$rnd_value = md5( uniqid(microtime() . mt_rand(), true ) . $seed );
< 		$rnd_value .= sha1($rnd_value);
< 		$rnd_value .= sha1($rnd_value . $seed);
< 		$seed = md5($seed . $rnd_value);
< 		if ( ! defined( 'WP_SETUP_CONFIG' ) )
< 			set_transient('random_seed', $seed);
< 	}
< 
< 	// Take the first 8 digits for our value
< 	$value = substr($rnd_value, 0, 8);
< 
< 	// Strip the first eight, leaving the remainder for the next call to wp_rand().
< 	$rnd_value = substr($rnd_value, 8);
< 
< 	$value = abs(hexdec($value));
< 
< 	// Reduce the value to be within the min - max range
< 	// 4294967295 = 0xffffffff = max random number
< 	if ( $max != 0 )
< 		$value = $min + (($max - $min + 1) * ($value / (4294967295 + 1)));
< 
< 	return abs(intval($value));
< }
< endif;
< 
< if ( !function_exists('wp_set_password') ) :
< /**
<  * Updates the user's password with a new encrypted one.
<  *
<  * For integration with other applications, this function can be overwritten to
<  * instead use the other package password checking algorithm.
<  *
<  * @since 2.5
<  * @uses $wpdb WordPress database object for queries
<  * @uses wp_hash_password() Used to encrypt the user's password before passing to the database
<  *
<  * @param string $password The plaintext new user password
<  * @param int $user_id User ID
<  */
< function wp_set_password( $password, $user_id ) {
< 	global $wpdb;
< 
< 	$hash = wp_hash_password($password);
< 	$wpdb->update($wpdb->users, array('user_pass' => $hash, 'user_activation_key' => ''), array('ID' => $user_id) );
< 
< 	wp_cache_delete($user_id, 'users');
< }
< endif;
< 
< if ( !function_exists( 'get_avatar' ) ) :
< /**
<  * Retrieve the avatar for a user who provided a user ID or email address.
<  *
<  * @since 2.5
<  * @param int|string|object $id_or_email A user ID,  email address, or comment object
<  * @param int $size Size of the avatar image
<  * @param string $default URL to a default image to use if no avatar is available
<  * @param string $alt Alternate text to use in image tag. Defaults to blank
<  * @return string <img> tag for the user's avatar
< */
< function get_avatar( $id_or_email, $size = '96', $default = '', $alt = false ) {
< 	if ( ! get_option('show_avatars') )
< 		return false;
< 
< 	if ( false === $alt)
< 		$safe_alt = '';
< 	else
< 		$safe_alt = esc_attr( $alt );
< 
< 	if ( !is_numeric($size) )
< 		$size = '96';
< 
< 	$email = '';
< 	if ( is_numeric($id_or_email) ) {
< 		$id = (int) $id_or_email;
< 		$user = get_userdata($id);
< 		if ( $user )
< 			$email = $user->user_email;
< 	} elseif ( is_object($id_or_email) ) {
< 		// No avatar for pingbacks or trackbacks
< 		$allowed_comment_types = apply_filters( 'get_avatar_comment_types', array( 'comment' ) );
< 		if ( ! empty( $id_or_email->comment_type ) && ! in_array( $id_or_email->comment_type, (array) $allowed_comment_types ) )
< 			return false;
< 
< 		if ( !empty($id_or_email->user_id) ) {
< 			$id = (int) $id_or_email->user_id;
< 			$user = get_userdata($id);
< 			if ( $user)
< 				$email = $user->user_email;
< 		} elseif ( !empty($id_or_email->comment_author_email) ) {
< 			$email = $id_or_email->comment_author_email;
< 		}
< 	} else {
< 		$email = $id_or_email;
< 	}
< 
< 	if ( empty($default) ) {
< 		$avatar_default = get_option('avatar_default');
< 		if ( empty($avatar_default) )
< 			$default = 'mystery';
< 		else
< 			$default = $avatar_default;
< 	}
< 
< 	if ( !empty($email) )
< 		$email_hash = md5( strtolower( $email ) );
< 
< 	if ( is_ssl() ) {
< 		$host = 'https://secure.gravatar.com';
< 	} else {
< 		if ( !empty($email) )
< 			$host = sprintf( "http://%d.gravatar.com", ( hexdec( $email_hash[0] ) % 2 ) );
< 		else
< 			$host = 'http://0.gravatar.com';
< 	}
< 
< 	if ( 'mystery' == $default )
< 		$default = "$host/avatar/ad516503a11cd5ca435acc9bb6523536?s={$size}"; // ad516503a11cd5ca435acc9bb6523536 == md5('unknown@gravatar.com')
< 	elseif ( 'blank' == $default )
< 		$default = includes_url('images/blank.gif');
< 	elseif ( !empty($email) && 'gravatar_default' == $default )
< 		$default = '';
< 	elseif ( 'gravatar_default' == $default )
< 		$default = "$host/avatar/s={$size}";
< 	elseif ( empty($email) )
< 		$default = "$host/avatar/?d=$default&amp;s={$size}";
< 	elseif ( strpos($default, 'http://') === 0 )
< 		$default = add_query_arg( 's', $size, $default );
< 
< 	if ( !empty($email) ) {
< 		$out = "$host/avatar/";
< 		$out .= $email_hash;
< 		$out .= '?s='.$size;
< 		$out .= '&amp;d=' . urlencode( $default );
< 
< 		$rating = get_option('avatar_rating');
< 		if ( !empty( $rating ) )
< 			$out .= "&amp;r={$rating}";
< 
< 		$avatar = "<img alt='{$safe_alt}' src='{$out}' class='avatar avatar-{$size} photo' height='{$size}' width='{$size}' />";
< 	} else {
< 		$avatar = "<img alt='{$safe_alt}' src='{$default}' class='avatar avatar-{$size} photo avatar-default' height='{$size}' width='{$size}' />";
< 	}
< 
< 	return apply_filters('get_avatar', $avatar, $id_or_email, $size, $default, $alt);
< }
< endif;
< 
< if ( !function_exists( 'wp_text_diff' ) ) :
< /**
<  * Displays a human readable HTML representation of the difference between two strings.
<  *
<  * The Diff is available for getting the changes between versions. The output is
<  * HTML, so the primary use is for displaying the changes. If the two strings
<  * are equivalent, then an empty string will be returned.
<  *
<  * The arguments supported and can be changed are listed below.
<  *
<  * 'title' : Default is an empty string. Titles the diff in a manner compatible
<  *		with the output.
<  * 'title_left' : Default is an empty string. Change the HTML to the left of the
<  *		title.
<  * 'title_right' : Default is an empty string. Change the HTML to the right of
<  *		the title.
<  *
<  * @since 2.6
<  * @see wp_parse_args() Used to change defaults to user defined settings.
<  * @uses Text_Diff
<  * @uses WP_Text_Diff_Renderer_Table
<  *
<  * @param string $left_string "old" (left) version of string
<  * @param string $right_string "new" (right) version of string
<  * @param string|array $args Optional. Change 'title', 'title_left', and 'title_right' defaults.
<  * @return string Empty string if strings are equivalent or HTML with differences.
<  */
< function wp_text_diff( $left_string, $right_string, $args = null ) {
< 	$defaults = array( 'title' => '', 'title_left' => '', 'title_right' => '' );
< 	$args = wp_parse_args( $args, $defaults );
< 
< 	if ( !class_exists( 'WP_Text_Diff_Renderer_Table' ) )
< 		require( ABSPATH . WPINC . '/wp-diff.php' );
< 
< 	$left_string  = normalize_whitespace($left_string);
< 	$right_string = normalize_whitespace($right_string);
< 
< 	$left_lines  = split("\n", $left_string);
< 	$right_lines = split("\n", $right_string);
< 
< 	$text_diff = new Text_Diff($left_lines, $right_lines);
< 	$renderer  = new WP_Text_Diff_Renderer_Table();
< 	$diff = $renderer->render($text_diff);
< 
< 	if ( !$diff )
< 		return '';
< 
< 	$r  = "<table class='diff'>\n";
< 	$r .= "<col class='ltype' /><col class='content' /><col class='ltype' /><col class='content' />";
< 
< 	if ( $args['title'] || $args['title_left'] || $args['title_right'] )
< 		$r .= "<thead>";
< 	if ( $args['title'] )
< 		$r .= "<tr class='diff-title'><th colspan='4'>$args[title]</th></tr>\n";
< 	if ( $args['title_left'] || $args['title_right'] ) {
< 		$r .= "<tr class='diff-sub-title'>\n";
< 		$r .= "\t<td></td><th>$args[title_left]</th>\n";
< 		$r .= "\t<td></td><th>$args[title_right]</th>\n";
< 		$r .= "</tr>\n";
< 	}
< 	if ( $args['title'] || $args['title_left'] || $args['title_right'] )
< 		$r .= "</thead>\n";
< 
< 	$r .= "<tbody>\n$diff\n</tbody>\n";
< 	$r .= "</table>";
< 
< 	return $r;
< }
< endif;
---
> <?php
> /**
>  * These functions can be replaced via plugins. If plugins do not redefine these
>  * functions, then these will be used instead.
>  *
>  * @package WordPress
>  */
> 
> if ( !function_exists('wp_set_current_user') ) :
> /**
>  * Changes the current user by ID or name.
>  *
>  * Set $id to null and specify a name if you do not know a user's ID.
>  *
>  * Some WordPress functionality is based on the current user and not based on
>  * the signed in user. Therefore, it opens the ability to edit and perform
>  * actions on users who aren't signed in.
>  *
>  * @since 2.0.3
>  * @global object $current_user The current user object which holds the user data.
>  * @uses do_action() Calls 'set_current_user' hook after setting the current user.
>  *
>  * @param int $id User ID
>  * @param string $name User's username
>  * @return WP_User Current user User object
>  */
> function wp_set_current_user($id, $name = '') {
> 	global $current_user;
> 
> 	if ( isset($current_user) && ($id == $current_user->ID) )
> 		return $current_user;
> 
> 	$current_user = new WP_User($id, $name);
> 
> 	setup_userdata($current_user->ID);
> 
> 	do_action('set_current_user');
> 
> 	return $current_user;
> }
> endif;
> 
> if ( !function_exists('wp_get_current_user') ) :
> /**
>  * Retrieve the current user object.
>  *
>  * @since 2.0.3
>  *
>  * @return WP_User Current user WP_User object
>  */
> function wp_get_current_user() {
> 	global $current_user;
> 
> 	get_currentuserinfo();
> 
> 	return $current_user;
> }
> endif;
> 
> if ( !function_exists('get_currentuserinfo') ) :
> /**
>  * Populate global variables with information about the currently logged in user.
>  *
>  * Will set the current user, if the current user is not set. The current user
>  * will be set to the logged in person. If no user is logged in, then it will
>  * set the current user to 0, which is invalid and won't have any permissions.
>  *
>  * @since 0.71
>  * @uses $current_user Checks if the current user is set
>  * @uses wp_validate_auth_cookie() Retrieves current logged in user.
>  *
>  * @return bool|null False on XMLRPC Request and invalid auth cookie. Null when current user set
>  */
> function get_currentuserinfo() {
> 	global $current_user;
> 
> 	if ( defined('XMLRPC_REQUEST') && XMLRPC_REQUEST )
> 		return false;
> 
> 	if ( ! empty($current_user) )
> 		return;
> 
> 	if ( ! $user = wp_validate_auth_cookie() ) {
> 		 if ( is_blog_admin() || is_network_admin() || empty($_COOKIE[LOGGED_IN_COOKIE]) || !$user = wp_validate_auth_cookie($_COOKIE[LOGGED_IN_COOKIE], 'logged_in') ) {
> 		 	wp_set_current_user(0);
> 		 	return false;
> 		 }
> 	}
> 
> 	wp_set_current_user($user);
> }
> endif;
> 
> if ( !function_exists('get_userdata') ) :
> /**
>  * Retrieve user info by user ID.
>  *
>  * @since 0.71
>  *
>  * @param int $user_id User ID
>  * @return bool|object False on failure, WP_User object on success
>  */
> function get_userdata( $user_id ) {
> 	return get_user_by( 'id', $user_id );
> }
> endif;
> 
> if ( !function_exists('get_user_by') ) :
> /**
>  * Retrieve user info by a given field
>  *
>  * @since 2.8.0
>  *
>  * @param string $field The field to retrieve the user with.  id | slug | email | login
>  * @param int|string $value A value for $field.  A user ID, slug, email address, or login name.
>  * @return bool|object False on failure, WP_User object on success
>  */
> function get_user_by( $field, $value ) {
> 	$userdata = WP_User::get_data_by( $field, $value );
> 
> 	if ( !$userdata )
> 		return false;
> 
> 	$user = new WP_User;
> 	$user->init( $userdata );
> 
> 	return $user;
> }
> endif;
> 
> if ( !function_exists('cache_users') ) :
> /**
>  * Retrieve info for user lists to prevent multiple queries by get_userdata()
>  *
>  * @since 3.0.0
>  *
>  * @param array $user_ids User ID numbers list
>  */
> function cache_users( $user_ids ) {
> 	global $wpdb;
> 
> 	$clean = array();
> 	foreach ( $user_ids as $id ) {
> 		$id = (int) $id;
> 		if ( !wp_cache_get( $id, 'users' ) ) {
> 			$clean[] = $id;
> 		}
> 	}
> 
> 	if ( empty( $clean ) )
> 		return;
> 
> 	$list = implode( ',', $clean );
> 
> 	$users = $wpdb->get_results( "SELECT * FROM $wpdb->users WHERE ID IN ($list)" );
> 
> 	$ids = array();
> 	foreach ( $users as $user ) {
> 		update_user_caches( $user );
> 		$ids[] = $user->ID;
> 	}
> 	update_meta_cache( 'user', $ids );
> }
> endif;
> 
> if ( !function_exists( 'wp_mail' ) ) :
> /**
>  * Send mail, similar to PHP's mail
>  *
>  * A true return value does not automatically mean that the user received the
>  * email successfully. It just only means that the method used was able to
>  * process the request without any errors.
>  *
>  * Using the two 'wp_mail_from' and 'wp_mail_from_name' hooks allow from
>  * creating a from address like 'Name <email@address.com>' when both are set. If
>  * just 'wp_mail_from' is set, then just the email address will be used with no
>  * name.
>  *
>  * The default content type is 'text/plain' which does not allow using HTML.
>  * However, you can set the content type of the email by using the
>  * 'wp_mail_content_type' filter.
>  *
>  * The default charset is based on the charset used on the blog. The charset can
>  * be set using the 'wp_mail_charset' filter.
>  *
>  * @since 1.2.1
>  * @uses apply_filters() Calls 'wp_mail' hook on an array of all of the parameters.
>  * @uses apply_filters() Calls 'wp_mail_from' hook to get the from email address.
>  * @uses apply_filters() Calls 'wp_mail_from_name' hook to get the from address name.
>  * @uses apply_filters() Calls 'wp_mail_content_type' hook to get the email content type.
>  * @uses apply_filters() Calls 'wp_mail_charset' hook to get the email charset
>  * @uses do_action_ref_array() Calls 'phpmailer_init' hook on the reference to
>  *		phpmailer object.
>  * @uses PHPMailer
>  *
>  * @param string|array $to Array or comma-separated list of email addresses to send message.
>  * @param string $subject Email subject
>  * @param string $message Message contents
>  * @param string|array $headers Optional. Additional headers.
>  * @param string|array $attachments Optional. Files to attach.
>  * @return bool Whether the email contents were sent successfully.
>  */
> function wp_mail( $to, $subject, $message, $headers = '', $attachments = array() ) {
> 	// Compact the input, apply the filters, and extract them back out
> 	extract( apply_filters( 'wp_mail', compact( 'to', 'subject', 'message', 'headers', 'attachments' ) ) );
> 
> 	if ( !is_array($attachments) )
> 		$attachments = explode( "\n", str_replace( "\r\n", "\n", $attachments ) );
> 
> 	global $phpmailer;
> 
> 	// (Re)create it, if it's gone missing
> 	if ( !is_object( $phpmailer ) || !is_a( $phpmailer, 'PHPMailer' ) ) {
> 		require_once ABSPATH . WPINC . '/class-phpmailer.php';
> 		require_once ABSPATH . WPINC . '/class-smtp.php';
> 		$phpmailer = new PHPMailer( true );
> 	}
> 
> 	// Headers
> 	if ( empty( $headers ) ) {
> 		$headers = array();
> 	} else {
> 		if ( !is_array( $headers ) ) {
> 			// Explode the headers out, so this function can take both
> 			// string headers and an array of headers.
> 			$tempheaders = explode( "\n", str_replace( "\r\n", "\n", $headers ) );
> 		} else {
> 			$tempheaders = $headers;
> 		}
> 		$headers = array();
> 		$cc = array();
> 		$bcc = array();
> 
> 		// If it's actually got contents
> 		if ( !empty( $tempheaders ) ) {
> 			// Iterate through the raw headers
> 			foreach ( (array) $tempheaders as $header ) {
> 				if ( strpos($header, ':') === false ) {
> 					if ( false !== stripos( $header, 'boundary=' ) ) {
> 						$parts = preg_split('/boundary=/i', trim( $header ) );
> 						$boundary = trim( str_replace( array( "'", '"' ), '', $parts[1] ) );
> 					}
> 					continue;
> 				}
> 				// Explode them out
> 				list( $name, $content ) = explode( ':', trim( $header ), 2 );
> 
> 				// Cleanup crew
> 				$name    = trim( $name    );
> 				$content = trim( $content );
> 
> 				switch ( strtolower( $name ) ) {
> 					// Mainly for legacy -- process a From: header if it's there
> 					case 'from':
> 						if ( strpos($content, '<' ) !== false ) {
> 							// So... making my life hard again?
> 							$from_name = substr( $content, 0, strpos( $content, '<' ) - 1 );
> 							$from_name = str_replace( '"', '', $from_name );
> 							$from_name = trim( $from_name );
> 
> 							$from_email = substr( $content, strpos( $content, '<' ) + 1 );
> 							$from_email = str_replace( '>', '', $from_email );
> 							$from_email = trim( $from_email );
> 						} else {
> 							$from_email = trim( $content );
> 						}
> 						break;
> 					case 'content-type':
> 						if ( strpos( $content, ';' ) !== false ) {
> 							list( $type, $charset ) = explode( ';', $content );
> 							$content_type = trim( $type );
> 							if ( false !== stripos( $charset, 'charset=' ) ) {
> 								$charset = trim( str_replace( array( 'charset=', '"' ), '', $charset ) );
> 							} elseif ( false !== stripos( $charset, 'boundary=' ) ) {
> 								$boundary = trim( str_replace( array( 'BOUNDARY=', 'boundary=', '"' ), '', $charset ) );
> 								$charset = '';
> 							}
> 						} else {
> 							$content_type = trim( $content );
> 						}
> 						break;
> 					case 'cc':
> 						$cc = array_merge( (array) $cc, explode( ',', $content ) );
> 						break;
> 					case 'bcc':
> 						$bcc = array_merge( (array) $bcc, explode( ',', $content ) );
> 						break;
> 					default:
> 						// Add it to our grand headers array
> 						$headers[trim( $name )] = trim( $content );
> 						break;
> 				}
> 			}
> 		}
> 	}
> 
> 	// Empty out the values that may be set
> 	$phpmailer->ClearAddresses();
> 	$phpmailer->ClearAllRecipients();
> 	$phpmailer->ClearAttachments();
> 	$phpmailer->ClearBCCs();
> 	$phpmailer->ClearCCs();
> 	$phpmailer->ClearCustomHeaders();
> 	$phpmailer->ClearReplyTos();
> 
> 	// From email and name
> 	// If we don't have a name from the input headers
> 	if ( !isset( $from_name ) )
> 		$from_name = 'WordPress';
> 
> 	/* If we don't have an email from the input headers default to wordpress@$sitename
> 	 * Some hosts will block outgoing mail from this address if it doesn't exist but
> 	 * there's no easy alternative. Defaulting to admin_email might appear to be another
> 	 * option but some hosts may refuse to relay mail from an unknown domain. See
> 	 * http://trac.wordpress.org/ticket/5007.
> 	 */
> 
> 	if ( !isset( $from_email ) ) {
> 		// Get the site domain and get rid of www.
> 		$sitename = strtolower( $_SERVER['SERVER_NAME'] );
> 		if ( substr( $sitename, 0, 4 ) == 'www.' ) {
> 			$sitename = substr( $sitename, 4 );
> 		}
> 
> 		$from_email = 'wordpress@' . $sitename;
> 	}
> 
> 	// Plugin authors can override the potentially troublesome default
> 	$phpmailer->From     = apply_filters( 'wp_mail_from'     , $from_email );
> 	$phpmailer->FromName = apply_filters( 'wp_mail_from_name', $from_name  );
> 
> 	// Set destination addresses
> 	if ( !is_array( $to ) )
> 		$to = explode( ',', $to );
> 
> 	foreach ( (array) $to as $recipient ) {
> 		try {
> 			// Break $recipient into name and address parts if in the format "Foo <bar@baz.com>"
> 			$recipient_name = '';
> 			if( preg_match( '/(.*)<(.+)>/', $recipient, $matches ) ) {
> 				if ( count( $matches ) == 3 ) {
> 					$recipient_name = $matches[1];
> 					$recipient = $matches[2];
> 				}
> 			}
> 			$phpmailer->AddAddress( $recipient, $recipient_name);
> 		} catch ( phpmailerException $e ) {
> 			continue;
> 		}
> 	}
> 
> 	// Set mail's subject and body
> 	$phpmailer->Subject = $subject;
> 	$phpmailer->Body    = $message;
> 
> 	// Add any CC and BCC recipients
> 	if ( !empty( $cc ) ) {
> 		foreach ( (array) $cc as $recipient ) {
> 			try {
> 				// Break $recipient into name and address parts if in the format "Foo <bar@baz.com>"
> 				$recipient_name = '';
> 				if( preg_match( '/(.*)<(.+)>/', $recipient, $matches ) ) {
> 					if ( count( $matches ) == 3 ) {
> 						$recipient_name = $matches[1];
> 						$recipient = $matches[2];
> 					}
> 				}
> 				$phpmailer->AddCc( $recipient, $recipient_name );
> 			} catch ( phpmailerException $e ) {
> 				continue;
> 			}
> 		}
> 	}
> 
> 	if ( !empty( $bcc ) ) {
> 		foreach ( (array) $bcc as $recipient) {
> 			try {
> 				// Break $recipient into name and address parts if in the format "Foo <bar@baz.com>"
> 				$recipient_name = '';
> 				if( preg_match( '/(.*)<(.+)>/', $recipient, $matches ) ) {
> 					if ( count( $matches ) == 3 ) {
> 						$recipient_name = $matches[1];
> 						$recipient = $matches[2];
> 					}
> 				}
> 				$phpmailer->AddBcc( $recipient, $recipient_name );
> 			} catch ( phpmailerException $e ) {
> 				continue;
> 			}
> 		}
> 	}
> 
> 	// Set to use PHP's mail()
> 	$phpmailer->IsMail();
> 
> 	// Set Content-Type and charset
> 	// If we don't have a content-type from the input headers
> 	if ( !isset( $content_type ) )
> 		$content_type = 'text/plain';
> 
> 	$content_type = apply_filters( 'wp_mail_content_type', $content_type );
> 
> 	$phpmailer->ContentType = $content_type;
> 
> 	// Set whether it's plaintext, depending on $content_type
> 	if ( 'text/html' == $content_type )
> 		$phpmailer->IsHTML( true );
> 
> 	// If we don't have a charset from the input headers
> 	if ( !isset( $charset ) )
> 		$charset = get_bloginfo( 'charset' );
> 
> 	// Set the content-type and charset
> 	$phpmailer->CharSet = apply_filters( 'wp_mail_charset', $charset );
> 
> 	// Set custom headers
> 	if ( !empty( $headers ) ) {
> 		foreach( (array) $headers as $name => $content ) {
> 			$phpmailer->AddCustomHeader( sprintf( '%1$s: %2$s', $name, $content ) );
> 		}
> 
> 		if ( false !== stripos( $content_type, 'multipart' ) && ! empty($boundary) )
> 			$phpmailer->AddCustomHeader( sprintf( "Content-Type: %s;\n\t boundary=\"%s\"", $content_type, $boundary ) );
> 	}
> 
> 	if ( !empty( $attachments ) ) {
> 		foreach ( $attachments as $attachment ) {
> 			try {
> 				$phpmailer->AddAttachment($attachment);
> 			} catch ( phpmailerException $e ) {
> 				continue;
> 			}
> 		}
> 	}
> 
> 	do_action_ref_array( 'phpmailer_init', array( &$phpmailer ) );
> 
> 	// Send!
> 	try {
> 		$phpmailer->Send();
> 	} catch ( phpmailerException $e ) {
> 		return false;
> 	}
> 
> 	return true;
> }
> endif;
> 
> if ( !function_exists('wp_authenticate') ) :
> /**
>  * Checks a user's login information and logs them in if it checks out.
>  *
>  * @since 2.5.0
>  *
>  * @param string $username User's username
>  * @param string $password User's password
>  * @return WP_Error|WP_User WP_User object if login successful, otherwise WP_Error object.
>  */
> function wp_authenticate($username, $password) {
> 	$username = sanitize_user($username);
> 	$password = trim($password);
> 
> 	$user = apply_filters('authenticate', null, $username, $password);
> 
> 	if ( $user == null ) {
> 		// TODO what should the error message be? (Or would these even happen?)
> 		// Only needed if all authentication handlers fail to return anything.
> 		$user = new WP_Error('authentication_failed', __('<strong>ERROR</strong>: Invalid username or incorrect password.'));
> 	}
> 
> 	$ignore_codes = array('empty_username', 'empty_password');
> 
> 	if (is_wp_error($user) && !in_array($user->get_error_code(), $ignore_codes) ) {
> 		do_action('wp_login_failed', $username);
> 	}
> 
> 	return $user;
> }
> endif;
> 
> if ( !function_exists('wp_logout') ) :
> /**
>  * Log the current user out.
>  *
>  * @since 2.5.0
>  */
> function wp_logout() {
> 	wp_clear_auth_cookie();
> 	do_action('wp_logout');
> }
> endif;
> 
> if ( !function_exists('wp_validate_auth_cookie') ) :
> /**
>  * Validates authentication cookie.
>  *
>  * The checks include making sure that the authentication cookie is set and
>  * pulling in the contents (if $cookie is not used).
>  *
>  * Makes sure the cookie is not expired. Verifies the hash in cookie is what is
>  * should be and compares the two.
>  *
>  * @since 2.5
>  *
>  * @param string $cookie Optional. If used, will validate contents instead of cookie's
>  * @param string $scheme Optional. The cookie scheme to use: auth, secure_auth, or logged_in
>  * @return bool|int False if invalid cookie, User ID if valid.
>  */
> function wp_validate_auth_cookie($cookie = '', $scheme = '') {
> 	if ( ! $cookie_elements = wp_parse_auth_cookie($cookie, $scheme) ) {
> 		do_action('auth_cookie_malformed', $cookie, $scheme);
> 		return false;
> 	}
> 
> 	extract($cookie_elements, EXTR_OVERWRITE);
> 
> 	$expired = $expiration;
> 
> 	// Allow a grace period for POST and AJAX requests
> 	if ( defined('DOING_AJAX') || 'POST' == $_SERVER['REQUEST_METHOD'] )
> 		$expired += 3600;
> 
> 	// Quick check to see if an honest cookie has expired
> 	if ( $expired < time() ) {
> 		do_action('auth_cookie_expired', $cookie_elements);
> 		return false;
> 	}
> 
> 	$user = get_user_by('login', $username);
> 	if ( ! $user ) {
> 		do_action('auth_cookie_bad_username', $cookie_elements);
> 		return false;
> 	}
> 
> 	$pass_frag = substr($user->user_pass, 8, 4);
> 
> 	$key = wp_hash($username . $pass_frag . '|' . $expiration, $scheme);
> 	$hash = hash_hmac('md5', $username . '|' . $expiration, $key);
> 
> 	if ( $hmac != $hash ) {
> 		do_action('auth_cookie_bad_hash', $cookie_elements);
> 		return false;
> 	}
> 
> 	if ( $expiration < time() ) // AJAX/POST grace period set above
> 		$GLOBALS['login_grace_period'] = 1;
> 
> 	do_action('auth_cookie_valid', $cookie_elements, $user);
> 
> 	return $user->ID;
> }
> endif;
> 
> if ( !function_exists('wp_generate_auth_cookie') ) :
> /**
>  * Generate authentication cookie contents.
>  *
>  * @since 2.5
>  * @uses apply_filters() Calls 'auth_cookie' hook on $cookie contents, User ID
>  *		and expiration of cookie.
>  *
>  * @param int $user_id User ID
>  * @param int $expiration Cookie expiration in seconds
>  * @param string $scheme Optional. The cookie scheme to use: auth, secure_auth, or logged_in
>  * @return string Authentication cookie contents
>  */
> function wp_generate_auth_cookie($user_id, $expiration, $scheme = 'auth') {
> 	$user = get_userdata($user_id);
> 
> 	$pass_frag = substr($user->user_pass, 8, 4);
> 
> 	$key = wp_hash($user->user_login . $pass_frag . '|' . $expiration, $scheme);
> 	$hash = hash_hmac('md5', $user->user_login . '|' . $expiration, $key);
> 
> 	$cookie = $user->user_login . '|' . $expiration . '|' . $hash;
> 
> 	return apply_filters('auth_cookie', $cookie, $user_id, $expiration, $scheme);
> }
> endif;
> 
> if ( !function_exists('wp_parse_auth_cookie') ) :
> /**
>  * Parse a cookie into its components
>  *
>  * @since 2.7
>  *
>  * @param string $cookie
>  * @param string $scheme Optional. The cookie scheme to use: auth, secure_auth, or logged_in
>  * @return array Authentication cookie components
>  */
> function wp_parse_auth_cookie($cookie = '', $scheme = '') {
> 	if ( empty($cookie) ) {
> 		switch ($scheme){
> 			case 'auth':
> 				$cookie_name = AUTH_COOKIE;
> 				break;
> 			case 'secure_auth':
> 				$cookie_name = SECURE_AUTH_COOKIE;
> 				break;
> 			case "logged_in":
> 				$cookie_name = LOGGED_IN_COOKIE;
> 				break;
> 			default:
> 				if ( is_ssl() ) {
> 					$cookie_name = SECURE_AUTH_COOKIE;
> 					$scheme = 'secure_auth';
> 				} else {
> 					$cookie_name = AUTH_COOKIE;
> 					$scheme = 'auth';
> 				}
> 	    }
> 
> 		if ( empty($_COOKIE[$cookie_name]) )
> 			return false;
> 		$cookie = $_COOKIE[$cookie_name];
> 	}
> 
> 	$cookie_elements = explode('|', $cookie);
> 	if ( count($cookie_elements) != 3 )
> 		return false;
> 
> 	list($username, $expiration, $hmac) = $cookie_elements;
> 
> 	return compact('username', 'expiration', 'hmac', 'scheme');
> }
> endif;
> 
> if ( !function_exists('wp_set_auth_cookie') ) :
> /**
>  * Sets the authentication cookies based User ID.
>  *
>  * The $remember parameter increases the time that the cookie will be kept. The
>  * default the cookie is kept without remembering is two days. When $remember is
>  * set, the cookies will be kept for 14 days or two weeks.
>  *
>  * @since 2.5
>  *
>  * @param int $user_id User ID
>  * @param bool $remember Whether to remember the user
>  */
> function wp_set_auth_cookie($user_id, $remember = false, $secure = '') {
> 	if ( $remember ) {
> 		$expiration = $expire = time() + apply_filters('auth_cookie_expiration', 1209600, $user_id, $remember);
> 	} else {
> 		$expiration = time() + apply_filters('auth_cookie_expiration', 172800, $user_id, $remember);
> 		$expire = 0;
> 	}
> 
> 	if ( '' === $secure )
> 		$secure = is_ssl();
> 
> 	$secure = apply_filters('secure_auth_cookie', $secure, $user_id);
> 	$secure_logged_in_cookie = apply_filters('secure_logged_in_cookie', false, $user_id, $secure);
> 
> 	if ( $secure ) {
> 		$auth_cookie_name = SECURE_AUTH_COOKIE;
> 		$scheme = 'secure_auth';
> 	} else {
> 		$auth_cookie_name = AUTH_COOKIE;
> 		$scheme = 'auth';
> 	}
> 
> 	$auth_cookie = wp_generate_auth_cookie($user_id, $expiration, $scheme);
> 	$logged_in_cookie = wp_generate_auth_cookie($user_id, $expiration, 'logged_in');
> 
> 	do_action('set_auth_cookie', $auth_cookie, $expire, $expiration, $user_id, $scheme);
> 	do_action('set_logged_in_cookie', $logged_in_cookie, $expire, $expiration, $user_id, 'logged_in');
> 
> 	setcookie($auth_cookie_name, $auth_cookie, $expire, PLUGINS_COOKIE_PATH, COOKIE_DOMAIN, $secure, true);
> 	setcookie($auth_cookie_name, $auth_cookie, $expire, ADMIN_COOKIE_PATH, COOKIE_DOMAIN, $secure, true);
> 	setcookie(LOGGED_IN_COOKIE, $logged_in_cookie, $expire, COOKIEPATH, COOKIE_DOMAIN, $secure_logged_in_cookie, true);
> 	if ( COOKIEPATH != SITECOOKIEPATH )
> 		setcookie(LOGGED_IN_COOKIE, $logged_in_cookie, $expire, SITECOOKIEPATH, COOKIE_DOMAIN, $secure_logged_in_cookie, true);
> }
> endif;
> 
> if ( !function_exists('wp_clear_auth_cookie') ) :
> /**
>  * Removes all of the cookies associated with authentication.
>  *
>  * @since 2.5
>  */
> function wp_clear_auth_cookie() {
> 	do_action('clear_auth_cookie');
> 
> 	setcookie(AUTH_COOKIE, ' ', time() - 31536000, ADMIN_COOKIE_PATH, COOKIE_DOMAIN);
> 	setcookie(SECURE_AUTH_COOKIE, ' ', time() - 31536000, ADMIN_COOKIE_PATH, COOKIE_DOMAIN);
> 	setcookie(AUTH_COOKIE, ' ', time() - 31536000, PLUGINS_COOKIE_PATH, COOKIE_DOMAIN);
> 	setcookie(SECURE_AUTH_COOKIE, ' ', time() - 31536000, PLUGINS_COOKIE_PATH, COOKIE_DOMAIN);
> 	setcookie(LOGGED_IN_COOKIE, ' ', time() - 31536000, COOKIEPATH, COOKIE_DOMAIN);
> 	setcookie(LOGGED_IN_COOKIE, ' ', time() - 31536000, SITECOOKIEPATH, COOKIE_DOMAIN);
> 
> 	// Old cookies
> 	setcookie(AUTH_COOKIE, ' ', time() - 31536000, COOKIEPATH, COOKIE_DOMAIN);
> 	setcookie(AUTH_COOKIE, ' ', time() - 31536000, SITECOOKIEPATH, COOKIE_DOMAIN);
> 	setcookie(SECURE_AUTH_COOKIE, ' ', time() - 31536000, COOKIEPATH, COOKIE_DOMAIN);
> 	setcookie(SECURE_AUTH_COOKIE, ' ', time() - 31536000, SITECOOKIEPATH, COOKIE_DOMAIN);
> 
> 	// Even older cookies
> 	setcookie(USER_COOKIE, ' ', time() - 31536000, COOKIEPATH, COOKIE_DOMAIN);
> 	setcookie(PASS_COOKIE, ' ', time() - 31536000, COOKIEPATH, COOKIE_DOMAIN);
> 	setcookie(USER_COOKIE, ' ', time() - 31536000, SITECOOKIEPATH, COOKIE_DOMAIN);
> 	setcookie(PASS_COOKIE, ' ', time() - 31536000, SITECOOKIEPATH, COOKIE_DOMAIN);
> }
> endif;
> 
> if ( !function_exists('is_user_logged_in') ) :
> /**
>  * Checks if the current visitor is a logged in user.
>  *
>  * @since 2.0.0
>  *
>  * @return bool True if user is logged in, false if not logged in.
>  */
> function is_user_logged_in() {
> 	$user = wp_get_current_user();
> 
> 	if ( empty( $user->ID ) )
> 		return false;
> 
> 	return true;
> }
> endif;
> 
> if ( !function_exists('auth_redirect') ) :
> /**
>  * Checks if a user is logged in, if not it redirects them to the login page.
>  *
>  * @since 1.5
>  */
> function auth_redirect() {
> 	// Checks if a user is logged in, if not redirects them to the login page
> 
> 	$secure = ( is_ssl() || force_ssl_admin() );
> 
> 	$secure = apply_filters('secure_auth_redirect', $secure);
> 
> 	// If https is required and request is http, redirect
> 	if ( $secure && !is_ssl() && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin') ) {
> 		if ( 0 === strpos($_SERVER['REQUEST_URI'], 'http') ) {
> 			wp_redirect(preg_replace('|^http://|', 'https://', $_SERVER['REQUEST_URI']));
> 			exit();
> 		} else {
> 			wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
> 			exit();
> 		}
> 	}
> 
> 	if ( is_user_admin() )
> 		$scheme = 'logged_in';
> 	else
> 		$scheme = apply_filters( 'auth_redirect_scheme', '' );
> 
> 	if ( $user_id = wp_validate_auth_cookie( '',  $scheme) ) {
> 		do_action('auth_redirect', $user_id);
> 
> 		// If the user wants ssl but the session is not ssl, redirect.
> 		if ( !$secure && get_user_option('use_ssl', $user_id) && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin') ) {
> 			if ( 0 === strpos($_SERVER['REQUEST_URI'], 'http') ) {
> 				wp_redirect(preg_replace('|^http://|', 'https://', $_SERVER['REQUEST_URI']));
> 				exit();
> 			} else {
> 				wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
> 				exit();
> 			}
> 		}
> 
> 		return;  // The cookie is good so we're done
> 	}
> 
> 	// The cookie is no good so force login
> 	nocache_headers();
> 
> 	if ( is_ssl() )
> 		$proto = 'https://';
> 	else
> 		$proto = 'http://';
> 
> 	$redirect = ( strpos($_SERVER['REQUEST_URI'], '/options.php') && wp_get_referer() ) ? wp_get_referer() : $proto . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
> 
> 	$login_url = wp_login_url($redirect, true);
> 
> 	wp_redirect($login_url);
> 	exit();
> }
> endif;
> 
> if ( !function_exists('check_admin_referer') ) :
> /**
>  * Makes sure that a user was referred from another admin page.
>  *
>  * To avoid security exploits.
>  *
>  * @since 1.2.0
>  * @uses do_action() Calls 'check_admin_referer' on $action.
>  *
>  * @param string $action Action nonce
>  * @param string $query_arg where to look for nonce in $_REQUEST (since 2.5)
>  */
> function check_admin_referer($action = -1, $query_arg = '_wpnonce') {
> 	if ( -1 == $action )
> 		_doing_it_wrong( __FUNCTION__, __( 'You should specify a nonce action to be verified by using the first parameter.' ), '3.2' );
> 
> 	$adminurl = strtolower(admin_url());
> 	$referer = strtolower(wp_get_referer());
> 	$result = isset($_REQUEST[$query_arg]) ? wp_verify_nonce($_REQUEST[$query_arg], $action) : false;
> 	if ( !$result && !(-1 == $action && strpos($referer, $adminurl) === 0) ) {
> 		wp_nonce_ays($action);
> 		die();
> 	}
> 	do_action('check_admin_referer', $action, $result);
> 	return $result;
> }endif;
> 
> if ( !function_exists('check_ajax_referer') ) :
> /**
>  * Verifies the AJAX request to prevent processing requests external of the blog.
>  *
>  * @since 2.0.3
>  *
>  * @param string $action Action nonce
>  * @param string $query_arg where to look for nonce in $_REQUEST (since 2.5)
>  */
> function check_ajax_referer( $action = -1, $query_arg = false, $die = true ) {
> 	if ( $query_arg )
> 		$nonce = $_REQUEST[$query_arg];
> 	else
> 		$nonce = isset($_REQUEST['_ajax_nonce']) ? $_REQUEST['_ajax_nonce'] : $_REQUEST['_wpnonce'];
> 
> 	$result = wp_verify_nonce( $nonce, $action );
> 
> 	if ( $die && false == $result )
> 		die('-1');
> 
> 	do_action('check_ajax_referer', $action, $result);
> 
> 	return $result;
> }
> endif;
> 
> if ( !function_exists('wp_redirect') ) :
> /**
>  * Redirects to another page.
>  *
>  * @since 1.5.1
>  * @uses apply_filters() Calls 'wp_redirect' hook on $location and $status.
>  *
>  * @param string $location The path to redirect to
>  * @param int $status Status code to use
>  * @return bool False if $location is not set
>  */
> function wp_redirect($location, $status = 302) {
> 	global $is_IIS;
> 
> 	$location = apply_filters('wp_redirect', $location, $status);
> 	$status = apply_filters('wp_redirect_status', $status, $location);
> 
> 	if ( !$location ) // allows the wp_redirect filter to cancel a redirect
> 		return false;
> 
> 	$location = wp_sanitize_redirect($location);
> 
> 	if ( !$is_IIS && php_sapi_name() != 'cgi-fcgi' )
> 		status_header($status); // This causes problems on IIS and some FastCGI setups
> 
> 	header("Location: $location", true, $status);
> }
> endif;
> 
> if ( !function_exists('wp_sanitize_redirect') ) :
> /**
>  * Sanitizes a URL for use in a redirect.
>  *
>  * @since 2.3
>  *
>  * @return string redirect-sanitized URL
>  **/
> function wp_sanitize_redirect($location) {
> 	$location = preg_replace('|[^a-z0-9-~+_.?#=&;,/:%!]|i', '', $location);
> 	$location = wp_kses_no_null($location);
> 
> 	// remove %0d and %0a from location
> 	$strip = array('%0d', '%0a', '%0D', '%0A');
> 	$location = _deep_replace($strip, $location);
> 	return $location;
> }
> endif;
> 
> if ( !function_exists('wp_safe_redirect') ) :
> /**
>  * Performs a safe (local) redirect, using wp_redirect().
>  *
>  * Checks whether the $location is using an allowed host, if it has an absolute
>  * path. A plugin can therefore set or remove allowed host(s) to or from the
>  * list.
>  *
>  * If the host is not allowed, then the redirect is to wp-admin on the siteurl
>  * instead. This prevents malicious redirects which redirect to another host,
>  * but only used in a few places.
>  *
>  * @since 2.3
>  * @uses wp_validate_redirect() To validate the redirect is to an allowed host.
>  *
>  * @return void Does not return anything
>  **/
> function wp_safe_redirect($location, $status = 302) {
> 
> 	// Need to look at the URL the way it will end up in wp_redirect()
> 	$location = wp_sanitize_redirect($location);
> 
> 	$location = wp_validate_redirect($location, admin_url());
> 
> 	wp_redirect($location, $status);
> }
> endif;
> 
> if ( !function_exists('wp_validate_redirect') ) :
> /**
>  * Validates a URL for use in a redirect.
>  *
>  * Checks whether the $location is using an allowed host, if it has an absolute
>  * path. A plugin can therefore set or remove allowed host(s) to or from the
>  * list.
>  *
>  * If the host is not allowed, then the redirect is to $default supplied
>  *
>  * @since 2.8.1
>  * @uses apply_filters() Calls 'allowed_redirect_hosts' on an array containing
>  *		WordPress host string and $location host string.
>  *
>  * @param string $location The redirect to validate
>  * @param string $default The value to return is $location is not allowed
>  * @return string redirect-sanitized URL
>  **/
> function wp_validate_redirect($location, $default = '') {
> 	// browsers will assume 'http' is your protocol, and will obey a redirect to a URL starting with '//'
> 	if ( substr($location, 0, 2) == '//' )
> 		$location = 'http:' . $location;
> 
> 	// In php 5 parse_url may fail if the URL query part contains http://, bug #38143
> 	$test = ( $cut = strpos($location, '?') ) ? substr( $location, 0, $cut ) : $location;
> 
> 	$lp  = parse_url($test);
> 
> 	// Give up if malformed URL
> 	if ( false === $lp )
> 		return $default;
> 
> 	// Allow only http and https schemes. No data:, etc.
> 	if ( isset($lp['scheme']) && !('http' == $lp['scheme'] || 'https' == $lp['scheme']) )
> 		return $default;
> 
> 	// Reject if scheme is set but host is not. This catches urls like https:host.com for which parse_url does not set the host field.
> 	if ( isset($lp['scheme'])  && !isset($lp['host']) )
> 		return $default;
> 
> 	$wpp = parse_url(home_url());
> 
> 	$allowed_hosts = (array) apply_filters('allowed_redirect_hosts', array($wpp['host']), isset($lp['host']) ? $lp['host'] : '');
> 
> 	if ( isset($lp['host']) && ( !in_array($lp['host'], $allowed_hosts) && $lp['host'] != strtolower($wpp['host'])) )
> 		$location = $default;
> 
> 	return $location;
> }
> endif;
> 
> if ( ! function_exists('wp_notify_postauthor') ) :
> /**
>  * Notify an author of a comment/trackback/pingback to one of their posts.
>  *
>  * @since 1.0.0
>  *
>  * @param int $comment_id Comment ID
>  * @param string $comment_type Optional. The comment type either 'comment' (default), 'trackback', or 'pingback'
>  * @return bool False if user email does not exist. True on completion.
>  */
> function wp_notify_postauthor( $comment_id, $comment_type = '' ) {
> 	$comment = get_comment( $comment_id );
> 	$post    = get_post( $comment->comment_post_ID );
> 	$author  = get_userdata( $post->post_author );
> 
> 	// The comment was left by the author
> 	if ( $comment->user_id == $post->post_author )
> 		return false;
> 
> 	// The author moderated a comment on his own post
> 	if ( $post->post_author == get_current_user_id() )
> 		return false;
> 
> 	// If there's no email to send the comment to
> 	if ( '' == $author->user_email )
> 		return false;
> 
> 	$comment_author_domain = @gethostbyaddr($comment->comment_author_IP);
> 
> 	// 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.
> 	$blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
> 
> 	if ( empty( $comment_type ) ) $comment_type = 'comment';
> 
> 	if ('comment' == $comment_type) {
> 		$notify_message  = sprintf( __( 'New comment on your post "%s"' ), $post->post_title ) . "\r\n";
> 		/* translators: 1: comment author, 2: author IP, 3: author domain */
> 		$notify_message .= sprintf( __('Author : %1$s (IP: %2$s , %3$s)'), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n";
> 		$notify_message .= sprintf( __('E-mail : %s'), $comment->comment_author_email ) . "\r\n";
> 		$notify_message .= sprintf( __('URL    : %s'), $comment->comment_author_url ) . "\r\n";
> 		$notify_message .= sprintf( __('Whois  : http://whois.arin.net/rest/ip/%s'), $comment->comment_author_IP ) . "\r\n";
> 		$notify_message .= __('Comment: ') . "\r\n" . $comment->comment_content . "\r\n\r\n";
> 		$notify_message .= __('You can see all comments on this post here: ') . "\r\n";
> 		/* translators: 1: blog name, 2: post title */
> 		$subject = sprintf( __('[%1$s] Comment: "%2$s"'), $blogname, $post->post_title );
> 	} elseif ('trackback' == $comment_type) {
> 		$notify_message  = sprintf( __( 'New trackback on your post "%s"' ), $post->post_title ) . "\r\n";
> 		/* translators: 1: website name, 2: author IP, 3: author domain */
> 		$notify_message .= sprintf( __('Website: %1$s (IP: %2$s , %3$s)'), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n";
> 		$notify_message .= sprintf( __('URL    : %s'), $comment->comment_author_url ) . "\r\n";
> 		$notify_message .= __('Excerpt: ') . "\r\n" . $comment->comment_content . "\r\n\r\n";
> 		$notify_message .= __('You can see all trackbacks on this post here: ') . "\r\n";
> 		/* translators: 1: blog name, 2: post title */
> 		$subject = sprintf( __('[%1$s] Trackback: "%2$s"'), $blogname, $post->post_title );
> 	} elseif ('pingback' == $comment_type) {
> 		$notify_message  = sprintf( __( 'New pingback on your post "%s"' ), $post->post_title ) . "\r\n";
> 		/* translators: 1: comment author, 2: author IP, 3: author domain */
> 		$notify_message .= sprintf( __('Website: %1$s (IP: %2$s , %3$s)'), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n";
> 		$notify_message .= sprintf( __('URL    : %s'), $comment->comment_author_url ) . "\r\n";
> 		$notify_message .= __('Excerpt: ') . "\r\n" . sprintf('[...] %s [...]', $comment->comment_content ) . "\r\n\r\n";
> 		$notify_message .= __('You can see all pingbacks on this post here: ') . "\r\n";
> 		/* translators: 1: blog name, 2: post title */
> 		$subject = sprintf( __('[%1$s] Pingback: "%2$s"'), $blogname, $post->post_title );
> 	}
> 	$notify_message .= get_permalink($comment->comment_post_ID) . "#comments\r\n\r\n";
> 	$notify_message .= sprintf( __('Permalink: %s'), get_permalink( $comment->comment_post_ID ) . '#comment-' . $comment_id ) . "\r\n";
> 	if ( EMPTY_TRASH_DAYS )
> 		$notify_message .= sprintf( __('Trash it: %s'), admin_url("comment.php?action=trash&c=$comment_id") ) . "\r\n";
> 	else
> 		$notify_message .= sprintf( __('Delete it: %s'), admin_url("comment.php?action=delete&c=$comment_id") ) . "\r\n";
> 	$notify_message .= sprintf( __('Spam it: %s'), admin_url("comment.php?action=spam&c=$comment_id") ) . "\r\n";
> 
> 	$wp_email = 'wordpress@' . preg_replace('#^www\.#', '', strtolower($_SERVER['SERVER_NAME']));
> 
> 	if ( '' == $comment->comment_author ) {
> 		$from = "From: \"$blogname\" <$wp_email>";
> 		if ( '' != $comment->comment_author_email )
> 			$reply_to = "Reply-To: $comment->comment_author_email";
> 	} else {
> 		$from = "From: \"$comment->comment_author\" <$wp_email>";
> 		if ( '' != $comment->comment_author_email )
> 			$reply_to = "Reply-To: \"$comment->comment_author_email\" <$comment->comment_author_email>";
> 	}
> 
> 	$message_headers = "$from\n"
> 		. "Content-Type: text/plain; charset=\"" . get_option('blog_charset') . "\"\n";
> 
> 	if ( isset($reply_to) )
> 		$message_headers .= $reply_to . "\n";
> 
> 	$notify_message = apply_filters('comment_notification_text', $notify_message, $comment_id);
> 	$subject = apply_filters('comment_notification_subject', $subject, $comment_id);
> 	$message_headers = apply_filters('comment_notification_headers', $message_headers, $comment_id);
> 
> 	@wp_mail( $author->user_email, $subject, $notify_message, $message_headers );
> 
> 	return true;
> }
> endif;
> 
> if ( !function_exists('wp_notify_moderator') ) :
> /**
>  * Notifies the moderator of the blog about a new comment that is awaiting approval.
>  *
>  * @since 1.0
>  * @uses $wpdb
>  *
>  * @param int $comment_id Comment ID
>  * @return bool Always returns true
>  */
> function wp_notify_moderator($comment_id) {
> 	global $wpdb;
> 
> 	if ( 0 == get_option( 'moderation_notify' ) )
> 		return true;
> 
> 	$comment = get_comment($comment_id);
> 	$post = get_post($comment->comment_post_ID);
> 	$user = get_userdata( $post->post_author );
> 	// Send to the administration and to the post author if the author can modify the comment.
> 	$email_to = array( get_option('admin_email') );
> 	if ( user_can($user->ID, 'edit_comment', $comment_id) && !empty($user->user_email) && ( get_option('admin_email') != $user->user_email) )
> 		$email_to[] = $user->user_email;
> 
> 	$comment_author_domain = @gethostbyaddr($comment->comment_author_IP);
> 	$comments_waiting = $wpdb->get_var("SELECT count(comment_ID) FROM $wpdb->comments WHERE comment_approved = '0'");
> 
> 	// 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.
> 	$blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
> 
> 	switch ($comment->comment_type)
> 	{
> 		case 'trackback':
> 			$notify_message  = sprintf( __('A new trackback on the post "%s" is waiting for your approval'), $post->post_title ) . "\r\n";
> 			$notify_message .= get_permalink($comment->comment_post_ID) . "\r\n\r\n";
> 			$notify_message .= sprintf( __('Website : %1$s (IP: %2$s , %3$s)'), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n";
> 			$notify_message .= sprintf( __('URL    : %s'), $comment->comment_author_url ) . "\r\n";
> 			$notify_message .= __('Trackback excerpt: ') . "\r\n" . $comment->comment_content . "\r\n\r\n";
> 			break;
> 		case 'pingback':
> 			$notify_message  = sprintf( __('A new pingback on the post "%s" is waiting for your approval'), $post->post_title ) . "\r\n";
> 			$notify_message .= get_permalink($comment->comment_post_ID) . "\r\n\r\n";
> 			$notify_message .= sprintf( __('Website : %1$s (IP: %2$s , %3$s)'), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n";
> 			$notify_message .= sprintf( __('URL    : %s'), $comment->comment_author_url ) . "\r\n";
> 			$notify_message .= __('Pingback excerpt: ') . "\r\n" . $comment->comment_content . "\r\n\r\n";
> 			break;
> 		default: //Comments
> 			$notify_message  = sprintf( __('A new comment on the post "%s" is waiting for your approval'), $post->post_title ) . "\r\n";
> 			$notify_message .= get_permalink($comment->comment_post_ID) . "\r\n\r\n";
> 			$notify_message .= sprintf( __('Author : %1$s (IP: %2$s , %3$s)'), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n";
> 			$notify_message .= sprintf( __('E-mail : %s'), $comment->comment_author_email ) . "\r\n";
> 			$notify_message .= sprintf( __('URL    : %s'), $comment->comment_author_url ) . "\r\n";
> 			$notify_message .= sprintf( __('Whois  : http://whois.arin.net/rest/ip/%s'), $comment->comment_author_IP ) . "\r\n";
> 			$notify_message .= __('Comment: ') . "\r\n" . $comment->comment_content . "\r\n\r\n";
> 			break;
> 	}
> 
> 	$notify_message .= sprintf( __('Approve it: %s'),  admin_url("comment.php?action=approve&c=$comment_id") ) . "\r\n";
> 	if ( EMPTY_TRASH_DAYS )
> 		$notify_message .= sprintf( __('Trash it: %s'), admin_url("comment.php?action=trash&c=$comment_id") ) . "\r\n";
> 	else
> 		$notify_message .= sprintf( __('Delete it: %s'), admin_url("comment.php?action=delete&c=$comment_id") ) . "\r\n";
> 	$notify_message .= sprintf( __('Spam it: %s'), admin_url("comment.php?action=spam&c=$comment_id") ) . "\r\n";
> 
> 	$notify_message .= sprintf( _n('Currently %s comment is waiting for approval. Please visit the moderation panel:',
>  		'Currently %s comments are waiting for approval. Please visit the moderation panel:', $comments_waiting), number_format_i18n($comments_waiting) ) . "\r\n";
> 	$notify_message .= admin_url("edit-comments.php?comment_status=moderated") . "\r\n";
> 
> 	$subject = sprintf( __('[%1$s] Please moderate: "%2$s"'), $blogname, $post->post_title );
> 	$message_headers = '';
> 
> 	$notify_message = apply_filters('comment_moderation_text', $notify_message, $comment_id);
> 	$subject = apply_filters('comment_moderation_subject', $subject, $comment_id);
> 	$message_headers = apply_filters('comment_moderation_headers', $message_headers);
> 
> 	foreach ( $email_to as $email )
> 		@wp_mail($email, $subject, $notify_message, $message_headers);
> 
> 	return true;
> }
> endif;
> 
> if ( !function_exists('wp_password_change_notification') ) :
> /**
>  * Notify the blog admin of a user changing password, normally via email.
>  *
>  * @since 2.7
>  *
>  * @param object $user User Object
>  */
> function wp_password_change_notification(&$user) {
> 	// send a copy of password change notification to the admin
> 	// but check to see if it's the admin whose password we're changing, and skip this
> 	if ( $user->user_email != get_option('admin_email') ) {
> 		$message = sprintf(__('Password Lost and Changed for user: %s'), $user->user_login) . "\r\n";
> 		// 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.
> 		$blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
> 		wp_mail(get_option('admin_email'), sprintf(__('[%s] Password Lost/Changed'), $blogname), $message);
> 	}
> }
> endif;
> 
> if ( !function_exists('wp_new_user_notification') ) :
> /**
>  * Notify the blog admin of a new user, normally via email.
>  *
>  * @since 2.0
>  *
>  * @param int $user_id User ID
>  * @param string $plaintext_pass Optional. The user's plaintext password
>  */
> function wp_new_user_notification($user_id, $plaintext_pass = '') {
> 	$user = new WP_User($user_id);
> 
> 	$user_login = stripslashes($user->user_login);
> 	$user_email = stripslashes($user->user_email);
> 
> 	// 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.
> 	$blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
> 
> 	$message  = sprintf(__('New user registration on your site %s:'), $blogname) . "\r\n\r\n";
> 	$message .= sprintf(__('Username: %s'), $user_login) . "\r\n\r\n";
> 	$message .= sprintf(__('E-mail: %s'), $user_email) . "\r\n";
> 
> 	if ( 1 == get_option( 'registration_notify' ) ) {
>             @wp_mail(get_option('admin_email'), sprintf(__('[%s] New User Registration'), $blogname), $message);
>         }
> 
> 	if ( empty($plaintext_pass) )
> 		return;
> 
> 	$message  = sprintf(__('Username: %s'), $user_login) . "\r\n";
> 	$message .= sprintf(__('Password: %s'), $plaintext_pass) . "\r\n";
> 	$message .= wp_login_url() . "\r\n";
> 
> 	wp_mail($user_email, sprintf(__('[%s] Your username and password'), $blogname), $message);
> 
> }
> endif;
> 
> if ( !function_exists('wp_nonce_tick') ) :
> /**
>  * Get the time-dependent variable for nonce creation.
>  *
>  * A nonce has a lifespan of two ticks. Nonces in their second tick may be
>  * updated, e.g. by autosave.
>  *
>  * @since 2.5
>  *
>  * @return int
>  */
> function wp_nonce_tick() {
> 	$nonce_life = apply_filters('nonce_life', 86400);
> 
> 	return ceil(time() / ( $nonce_life / 2 ));
> }
> endif;
> 
> if ( !function_exists('wp_verify_nonce') ) :
> /**
>  * Verify that correct nonce was used with time limit.
>  *
>  * The user is given an amount of time to use the token, so therefore, since the
>  * UID and $action remain the same, the independent variable is the time.
>  *
>  * @since 2.0.3
>  *
>  * @param string $nonce Nonce that was used in the form to verify
>  * @param string|int $action Should give context to what is taking place and be the same when nonce was created.
>  * @return bool Whether the nonce check passed or failed.
>  */
> function wp_verify_nonce($nonce, $action = -1) {
> 	$user = wp_get_current_user();
> 	$uid = (int) $user->ID;
> 
> 	$i = wp_nonce_tick();
> 
> 	// Nonce generated 0-12 hours ago
> 	if ( substr(wp_hash($i . $action . $uid, 'nonce'), -12, 10) == $nonce )
> 		return 1;
> 	// Nonce generated 12-24 hours ago
> 	if ( substr(wp_hash(($i - 1) . $action . $uid, 'nonce'), -12, 10) == $nonce )
> 		return 2;
> 	// Invalid nonce
> 	return false;
> }
> endif;
> 
> if ( !function_exists('wp_create_nonce') ) :
> /**
>  * Creates a random, one time use token.
>  *
>  * @since 2.0.3
>  *
>  * @param string|int $action Scalar value to add context to the nonce.
>  * @return string The one use form token
>  */
> function wp_create_nonce($action = -1) {
> 	$user = wp_get_current_user();
> 	$uid = (int) $user->ID;
> 
> 	$i = wp_nonce_tick();
> 
> 	return substr(wp_hash($i . $action . $uid, 'nonce'), -12, 10);
> }
> endif;
> 
> if ( !function_exists('wp_salt') ) :
> /**
>  * Get salt to add to hashes to help prevent attacks.
>  *
>  * The secret key is located in two places: the database in case the secret key
>  * isn't defined in the second place, which is in the wp-config.php file. If you
>  * are going to set the secret key, then you must do so in the wp-config.php
>  * file.
>  *
>  * The secret key in the database is randomly generated and will be appended to
>  * the secret key that is in wp-config.php file in some instances. It is
>  * important to have the secret key defined or changed in wp-config.php.
>  *
>  * If you have installed WordPress 2.5 or later, then you will have the
>  * SECRET_KEY defined in the wp-config.php already. You will want to change the
>  * value in it because hackers will know what it is. If you have upgraded to
>  * WordPress 2.5 or later version from a version before WordPress 2.5, then you
>  * should add the constant to your wp-config.php file.
>  *
>  * Below is an example of how the SECRET_KEY constant is defined with a value.
>  * You must not copy the below example and paste into your wp-config.php. If you
>  * need an example, then you can have a
>  * {@link https://api.wordpress.org/secret-key/1.1/ secret key created} for you.
>  *
>  * <code>
>  * define('SECRET_KEY', 'mAry1HadA15|\/|b17w55w1t3asSn09w');
>  * </code>
>  *
>  * Salting passwords helps against tools which has stored hashed values of
>  * common dictionary strings. The added values makes it harder to crack if given
>  * salt string is not weak.
>  *
>  * @since 2.5
>  * @link https://api.wordpress.org/secret-key/1.1/ Create a Secret Key for wp-config.php
>  *
>  * @param string $scheme Authentication scheme
>  * @return string Salt value
>  */
> function wp_salt($scheme = 'auth') {
> 	global $wp_default_secret_key;
> 	$secret_key = '';
> 	if ( defined('SECRET_KEY') && ('' != SECRET_KEY) && ( $wp_default_secret_key != SECRET_KEY) )
> 		$secret_key = SECRET_KEY;
> 
> 	if ( 'auth' == $scheme ) {
> 		if ( defined('AUTH_KEY') && ('' != AUTH_KEY) && ( $wp_default_secret_key != AUTH_KEY) )
> 			$secret_key = AUTH_KEY;
> 
> 		if ( defined('AUTH_SALT') && ('' != AUTH_SALT) && ( $wp_default_secret_key != AUTH_SALT) ) {
> 			$salt = AUTH_SALT;
> 		} elseif ( defined('SECRET_SALT') && ('' != SECRET_SALT) && ( $wp_default_secret_key != SECRET_SALT) ) {
> 			$salt = SECRET_SALT;
> 		} else {
> 			$salt = get_site_option('auth_salt');
> 			if ( empty($salt) ) {
> 				$salt = wp_generate_password( 64, true, true );
> 				update_site_option('auth_salt', $salt);
> 			}
> 		}
> 	} elseif ( 'secure_auth' == $scheme ) {
> 		if ( defined('SECURE_AUTH_KEY') && ('' != SECURE_AUTH_KEY) && ( $wp_default_secret_key != SECURE_AUTH_KEY) )
> 			$secret_key = SECURE_AUTH_KEY;
> 
> 		if ( defined('SECURE_AUTH_SALT') && ('' != SECURE_AUTH_SALT) && ( $wp_default_secret_key != SECURE_AUTH_SALT) ) {
> 			$salt = SECURE_AUTH_SALT;
> 		} else {
> 			$salt = get_site_option('secure_auth_salt');
> 			if ( empty($salt) ) {
> 				$salt = wp_generate_password( 64, true, true );
> 				update_site_option('secure_auth_salt', $salt);
> 			}
> 		}
> 	} elseif ( 'logged_in' == $scheme ) {
> 		if ( defined('LOGGED_IN_KEY') && ('' != LOGGED_IN_KEY) && ( $wp_default_secret_key != LOGGED_IN_KEY) )
> 			$secret_key = LOGGED_IN_KEY;
> 
> 		if ( defined('LOGGED_IN_SALT') && ('' != LOGGED_IN_SALT) && ( $wp_default_secret_key != LOGGED_IN_SALT) ) {
> 			$salt = LOGGED_IN_SALT;
> 		} else {
> 			$salt = get_site_option('logged_in_salt');
> 			if ( empty($salt) ) {
> 				$salt = wp_generate_password( 64, true, true );
> 				update_site_option('logged_in_salt', $salt);
> 			}
> 		}
> 	} elseif ( 'nonce' == $scheme ) {
> 		if ( defined('NONCE_KEY') && ('' != NONCE_KEY) && ( $wp_default_secret_key != NONCE_KEY) )
> 			$secret_key = NONCE_KEY;
> 
> 		if ( defined('NONCE_SALT') && ('' != NONCE_SALT) && ( $wp_default_secret_key != NONCE_SALT) ) {
> 			$salt = NONCE_SALT;
> 		} else {
> 			$salt = get_site_option('nonce_salt');
> 			if ( empty($salt) ) {
> 				$salt = wp_generate_password( 64, true, true );
> 				update_site_option('nonce_salt', $salt);
> 			}
> 		}
> 	} else {
> 		// ensure each auth scheme has its own unique salt
> 		$salt = hash_hmac('md5', $scheme, $secret_key);
> 	}
> 
> 	return apply_filters('salt', $secret_key . $salt, $scheme);
> }
> endif;
> 
> if ( !function_exists('wp_hash') ) :
> /**
>  * Get hash of given string.
>  *
>  * @since 2.0.3
>  * @uses wp_salt() Get WordPress salt
>  *
>  * @param string $data Plain text to hash
>  * @return string Hash of $data
>  */
> function wp_hash($data, $scheme = 'auth') {
> 	$salt = wp_salt($scheme);
> 
> 	return hash_hmac('md5', $data, $salt);
> }
> endif;
> 
> if ( !function_exists('wp_hash_password') ) :
> /**
>  * Create a hash (encrypt) of a plain text password.
>  *
>  * For integration with other applications, this function can be overwritten to
>  * instead use the other package password checking algorithm.
>  *
>  * @since 2.5
>  * @global object $wp_hasher PHPass object
>  * @uses PasswordHash::HashPassword
>  *
>  * @param string $password Plain text user password to hash
>  * @return string The hash string of the password
>  */
> function wp_hash_password($password) {
> 	global $wp_hasher;
> 
> 	if ( empty($wp_hasher) ) {
> 		require_once( ABSPATH . 'wp-includes/class-phpass.php');
> 		// By default, use the portable hash from phpass
> 		$wp_hasher = new PasswordHash(8, TRUE);
> 	}
> 
> 	return $wp_hasher->HashPassword($password);
> }
> endif;
> 
> if ( !function_exists('wp_check_password') ) :
> /**
>  * Checks the plaintext password against the encrypted Password.
>  *
>  * Maintains compatibility between old version and the new cookie authentication
>  * protocol using PHPass library. The $hash parameter is the encrypted password
>  * and the function compares the plain text password when encrypted similarly
>  * against the already encrypted password to see if they match.
>  *
>  * For integration with other applications, this function can be overwritten to
>  * instead use the other package password checking algorithm.
>  *
>  * @since 2.5
>  * @global object $wp_hasher PHPass object used for checking the password
>  *	against the $hash + $password
>  * @uses PasswordHash::CheckPassword
>  *
>  * @param string $password Plaintext user's password
>  * @param string $hash Hash of the user's password to check against.
>  * @return bool False, if the $password does not match the hashed password
>  */
> function wp_check_password($password, $hash, $user_id = '') {
> 	global $wp_hasher;
> 
> 	// If the hash is still md5...
> 	if ( strlen($hash) <= 32 ) {
> 		$check = ( $hash == md5($password) );
> 		if ( $check && $user_id ) {
> 			// Rehash using new hash.
> 			wp_set_password($password, $user_id);
> 			$hash = wp_hash_password($password);
> 		}
> 
> 		return apply_filters('check_password', $check, $password, $hash, $user_id);
> 	}
> 
> 	// If the stored hash is longer than an MD5, presume the
> 	// new style phpass portable hash.
> 	if ( empty($wp_hasher) ) {
> 		require_once( ABSPATH . 'wp-includes/class-phpass.php');
> 		// By default, use the portable hash from phpass
> 		$wp_hasher = new PasswordHash(8, TRUE);
> 	}
> 
> 	$check = $wp_hasher->CheckPassword($password, $hash);
> 
> 	return apply_filters('check_password', $check, $password, $hash, $user_id);
> }
> endif;
> 
> if ( !function_exists('wp_generate_password') ) :
> /**
>  * Generates a random password drawn from the defined set of characters.
>  *
>  * @since 2.5
>  *
>  * @param int $length The length of password to generate
>  * @param bool $special_chars Whether to include standard special characters. Default true.
>  * @param bool $extra_special_chars Whether to include other special characters. Used when
>  *   generating secret keys and salts. Default false.
>  * @return string The random password
>  **/
> function wp_generate_password( $length = 12, $special_chars = true, $extra_special_chars = false ) {
> 	$chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
> 	if ( $special_chars )
> 		$chars .= '!@#$%^&*()';
> 	if ( $extra_special_chars )
> 		$chars .= '-_ []{}<>~`+=,.;:/?|';
> 
> 	$password = '';
> 	for ( $i = 0; $i < $length; $i++ ) {
> 		$password .= substr($chars, wp_rand(0, strlen($chars) - 1), 1);
> 	}
> 
> 	// random_password filter was previously in random_password function which was deprecated
> 	return apply_filters('random_password', $password);
> }
> endif;
> 
> if ( !function_exists('wp_rand') ) :
>  /**
>  * Generates a random number
>  *
>  * @since 2.6.2
>  *
>  * @param int $min Lower limit for the generated number (optional, default is 0)
>  * @param int $max Upper limit for the generated number (optional, default is 4294967295)
>  * @return int A random number between min and max
>  */
> function wp_rand( $min = 0, $max = 0 ) {
> 	global $rnd_value;
> 
> 	// Reset $rnd_value after 14 uses
> 	// 32(md5) + 40(sha1) + 40(sha1) / 8 = 14 random numbers from $rnd_value
> 	if ( strlen($rnd_value) < 8 ) {
> 		if ( defined( 'WP_SETUP_CONFIG' ) )
> 			static $seed = '';
> 		else
> 			$seed = get_transient('random_seed');
> 		$rnd_value = md5( uniqid(microtime() . mt_rand(), true ) . $seed );
> 		$rnd_value .= sha1($rnd_value);
> 		$rnd_value .= sha1($rnd_value . $seed);
> 		$seed = md5($seed . $rnd_value);
> 		if ( ! defined( 'WP_SETUP_CONFIG' ) )
> 			set_transient('random_seed', $seed);
> 	}
> 
> 	// Take the first 8 digits for our value
> 	$value = substr($rnd_value, 0, 8);
> 
> 	// Strip the first eight, leaving the remainder for the next call to wp_rand().
> 	$rnd_value = substr($rnd_value, 8);
> 
> 	$value = abs(hexdec($value));
> 
> 	// Reduce the value to be within the min - max range
> 	// 4294967295 = 0xffffffff = max random number
> 	if ( $max != 0 )
> 		$value = $min + (($max - $min + 1) * ($value / (4294967295 + 1)));
> 
> 	return abs(intval($value));
> }
> endif;
> 
> if ( !function_exists('wp_set_password') ) :
> /**
>  * Updates the user's password with a new encrypted one.
>  *
>  * For integration with other applications, this function can be overwritten to
>  * instead use the other package password checking algorithm.
>  *
>  * @since 2.5
>  * @uses $wpdb WordPress database object for queries
>  * @uses wp_hash_password() Used to encrypt the user's password before passing to the database
>  *
>  * @param string $password The plaintext new user password
>  * @param int $user_id User ID
>  */
> function wp_set_password( $password, $user_id ) {
> 	global $wpdb;
> 
> 	$hash = wp_hash_password($password);
> 	$wpdb->update($wpdb->users, array('user_pass' => $hash, 'user_activation_key' => ''), array('ID' => $user_id) );
> 
> 	wp_cache_delete($user_id, 'users');
> }
> endif;
> 
> if ( !function_exists( 'get_avatar' ) ) :
> /**
>  * Retrieve the avatar for a user who provided a user ID or email address.
>  *
>  * @since 2.5
>  * @param int|string|object $id_or_email A user ID,  email address, or comment object
>  * @param int $size Size of the avatar image
>  * @param string $default URL to a default image to use if no avatar is available
>  * @param string $alt Alternate text to use in image tag. Defaults to blank
>  * @return string <img> tag for the user's avatar
> */
> function get_avatar( $id_or_email, $size = '96', $default = '', $alt = false ) {
> 	if ( ! get_option('show_avatars') )
> 		return false;
> 
> 	if ( false === $alt)
> 		$safe_alt = '';
> 	else
> 		$safe_alt = esc_attr( $alt );
> 
> 	if ( !is_numeric($size) )
> 		$size = '96';
> 
> 	$email = '';
> 	if ( is_numeric($id_or_email) ) {
> 		$id = (int) $id_or_email;
> 		$user = get_userdata($id);
> 		if ( $user )
> 			$email = $user->user_email;
> 	} elseif ( is_object($id_or_email) ) {
> 		// No avatar for pingbacks or trackbacks
> 		$allowed_comment_types = apply_filters( 'get_avatar_comment_types', array( 'comment' ) );
> 		if ( ! empty( $id_or_email->comment_type ) && ! in_array( $id_or_email->comment_type, (array) $allowed_comment_types ) )
> 			return false;
> 
> 		if ( !empty($id_or_email->user_id) ) {
> 			$id = (int) $id_or_email->user_id;
> 			$user = get_userdata($id);
> 			if ( $user)
> 				$email = $user->user_email;
> 		} elseif ( !empty($id_or_email->comment_author_email) ) {
> 			$email = $id_or_email->comment_author_email;
> 		}
> 	} else {
> 		$email = $id_or_email;
> 	}
> 
> 	if ( empty($default) ) {
> 		$avatar_default = get_option('avatar_default');
> 		if ( empty($avatar_default) )
> 			$default = 'mystery';
> 		else
> 			$default = $avatar_default;
> 	}
> 
> 	if ( !empty($email) )
> 		$email_hash = md5( strtolower( $email ) );
> 
> 	if ( is_ssl() ) {
> 		$host = 'https://secure.gravatar.com';
> 	} else {
> 		if ( !empty($email) )
> 			$host = sprintf( "http://%d.gravatar.com", ( hexdec( $email_hash[0] ) % 2 ) );
> 		else
> 			$host = 'http://0.gravatar.com';
> 	}
> 
> 	if ( 'mystery' == $default )
> 		$default = "$host/avatar/ad516503a11cd5ca435acc9bb6523536?s={$size}"; // ad516503a11cd5ca435acc9bb6523536 == md5('unknown@gravatar.com')
> 	elseif ( 'blank' == $default )
> 		$default = includes_url('images/blank.gif');
> 	elseif ( !empty($email) && 'gravatar_default' == $default )
> 		$default = '';
> 	elseif ( 'gravatar_default' == $default )
> 		$default = "$host/avatar/s={$size}";
> 	elseif ( empty($email) )
> 		$default = "$host/avatar/?d=$default&amp;s={$size}";
> 	elseif ( strpos($default, 'http://') === 0 )
> 		$default = add_query_arg( 's', $size, $default );
> 
> 	if ( !empty($email) ) {
> 		$out = "$host/avatar/";
> 		$out .= $email_hash;
> 		$out .= '?s='.$size;
> 		$out .= '&amp;d=' . urlencode( $default );
> 
> 		$rating = get_option('avatar_rating');
> 		if ( !empty( $rating ) )
> 			$out .= "&amp;r={$rating}";
> 
> 		$avatar = "<img alt='{$safe_alt}' src='{$out}' class='avatar avatar-{$size} photo' height='{$size}' width='{$size}' />";
> 	} else {
> 		$avatar = "<img alt='{$safe_alt}' src='{$default}' class='avatar avatar-{$size} photo avatar-default' height='{$size}' width='{$size}' />";
> 	}
> 
> 	return apply_filters('get_avatar', $avatar, $id_or_email, $size, $default, $alt);
> }
> endif;
> 
> if ( !function_exists( 'wp_text_diff' ) ) :
> /**
>  * Displays a human readable HTML representation of the difference between two strings.
>  *
>  * The Diff is available for getting the changes between versions. The output is
>  * HTML, so the primary use is for displaying the changes. If the two strings
>  * are equivalent, then an empty string will be returned.
>  *
>  * The arguments supported and can be changed are listed below.
>  *
>  * 'title' : Default is an empty string. Titles the diff in a manner compatible
>  *		with the output.
>  * 'title_left' : Default is an empty string. Change the HTML to the left of the
>  *		title.
>  * 'title_right' : Default is an empty string. Change the HTML to the right of
>  *		the title.
>  *
>  * @since 2.6
>  * @see wp_parse_args() Used to change defaults to user defined settings.
>  * @uses Text_Diff
>  * @uses WP_Text_Diff_Renderer_Table
>  *
>  * @param string $left_string "old" (left) version of string
>  * @param string $right_string "new" (right) version of string
>  * @param string|array $args Optional. Change 'title', 'title_left', and 'title_right' defaults.
>  * @return string Empty string if strings are equivalent or HTML with differences.
>  */
> function wp_text_diff( $left_string, $right_string, $args = null ) {
> 	$defaults = array( 'title' => '', 'title_left' => '', 'title_right' => '' );
> 	$args = wp_parse_args( $args, $defaults );
> 
> 	if ( !class_exists( 'WP_Text_Diff_Renderer_Table' ) )
> 		require( ABSPATH . WPINC . '/wp-diff.php' );
> 
> 	$left_string  = normalize_whitespace($left_string);
> 	$right_string = normalize_whitespace($right_string);
> 
> 	$left_lines  = split("\n", $left_string);
> 	$right_lines = split("\n", $right_string);
> 
> 	$text_diff = new Text_Diff($left_lines, $right_lines);
> 	$renderer  = new WP_Text_Diff_Renderer_Table();
> 	$diff = $renderer->render($text_diff);
> 
> 	if ( !$diff )
> 		return '';
> 
> 	$r  = "<table class='diff'>\n";
> 	$r .= "<col class='ltype' /><col class='content' /><col class='ltype' /><col class='content' />";
> 
> 	if ( $args['title'] || $args['title_left'] || $args['title_right'] )
> 		$r .= "<thead>";
> 	if ( $args['title'] )
> 		$r .= "<tr class='diff-title'><th colspan='4'>$args[title]</th></tr>\n";
> 	if ( $args['title_left'] || $args['title_right'] ) {
> 		$r .= "<tr class='diff-sub-title'>\n";
> 		$r .= "\t<td></td><th>$args[title_left]</th>\n";
> 		$r .= "\t<td></td><th>$args[title_right]</th>\n";
> 		$r .= "</tr>\n";
> 	}
> 	if ( $args['title'] || $args['title_left'] || $args['title_right'] )
> 		$r .= "</thead>\n";
> 
> 	$r .= "<tbody>\n$diff\n</tbody>\n";
> 	$r .= "</table>";
> 
> 	return $r;
> }
> endif;
