* @since 3.1.0
*
* @return bool
*/
function is_date() {
return (bool) $this->is_date;
}
/**
* Is the query for a day archive?
*
* @since 3.1.0
*
* @return bool
*/
function is_day() {
return (bool) $this->is_day;
}
/**
* Is the query for a feed?
*
* @since 3.1.0
*
* @param string|array $feeds Optional feed types to check.
* @return bool
*/
function is_feed( $feeds = '' ) {
if ( empty( $feeds ) || ! $this->is_feed )
return (bool) $this->is_feed;
$qv = $this->get( 'feed' );
if ( 'feed' == $qv )
$qv = get_default_feed();
return in_array( $qv, (array) $feeds );
}
/**
* Is the query for a comments feed?
*
* @since 3.1.0
*
* @return bool
*/
function is_comment_feed() {
return (bool) $this->is_comment_feed;
}
/**
* Is the query for the front page of the site?
*
* This is for what is displayed at your site's main URL.
*
* Depends on the site's "Front page displays" Reading Settings 'show_on_front' and 'page_on_front'.
*
* If you set a static page for the front page of your site, this function will return
* true when viewing that page.
*
* Otherwise the same as @see WP_Query::is_home()
*
* @since 3.1.0
* @uses is_home()
* @uses get_option()
*
* @return bool True, if front of site.
*/
function is_front_page() {
// most likely case
if ( 'posts' == get_option( 'show_on_front') && $this->is_home() )
return true;
elseif ( 'page' == get_option( 'show_on_front') && get_option( 'page_on_front' ) && $this->is_page( get_option( 'page_on_front' ) ) )
return true;
else
return false;
}
/**
* Is the query for the blog homepage?
*
* This is the page which shows the time based blog content of your site.
*
* Depends on the site's "Front page displays" Reading Settings 'show_on_front' and 'page_for_posts'.
*
* If you set a static page for the front page of your site, this function will return
* true only on the page you set as the "Posts page".
*
* @see WP_Query::is_front_page()
*
* @since 3.1.0
*
* @return bool True if blog view homepage.
*/
function is_home() {
return (bool) $this->is_home;
}
/**
* Is the query for a month archive?
*
* @since 3.1.0
*
* @return bool
*/
function is_month() {
return (bool) $this->is_month;
}
/**
* Is the query for a single page?
*
* If the $page parameter is specified, this function will additionally
* check if the query is for one of the pages specified.
*
* @see WP_Query::is_single()
* @see WP_Query::is_singular()
*
* @since 3.1.0
*
* @param mixed $page Page ID, title, slug, or array of such.
* @return bool
*/
function is_page( $page = '' ) {
if ( !$this->is_page )
return false;
if ( empty( $page ) )
return true;
$page_obj = $this->get_queried_object();
$page = (array) $page;
if ( in_array( $page_obj->ID, $page ) )
return true;
elseif ( in_array( $page_obj->post_title, $page ) )
return true;
else if ( in_array( $page_obj->post_name, $page ) )
return true;
return false;
}
/**
* Is the query for paged result and not for the first page?
*
* @since 3.1.0
*
* @return bool
*/
function is_paged() {
return (bool) $this->is_paged;
}
/**
* Is the query for a post or page preview?
*
* @since 3.1.0
*
* @return bool
*/
function is_preview() {
return (bool) $this->is_preview;
}
/**
* Is the query for the robots file?
*
* @since 3.1.0
*
* @return bool
*/
function is_robots() {
return (bool) $this->is_robots;
}
/**
* Is the query for a search?
*
* @since 3.1.0
*
* @return bool
*/
function is_search() {
return (bool) $this->is_search;
}
/**
* Is the query for a single post?
*
* Works for any post type, except attachments and pages
*
* If the $post parameter is specified, this function will additionally
* check if the query is for one of the Posts specified.
*
* @see WP_Query::is_page()
* @see WP_Query::is_singular()
*
* @since 3.1.0
*
* @param mixed $post Post ID, title, slug, or array of such.
* @return bool
*/
function is_single( $post = '' ) {
if ( !$this->is_single )
return false;
if ( empty($post) )
return true;
$post_obj = $this->get_queried_object();
$post = (array) $post;
if ( in_array( $post_obj->ID, $post ) )
return true;
elseif ( in_array( $post_obj->post_title, $post ) )
return true;
elseif ( in_array( $post_obj->post_name, $post ) )
return true;
return false;
}
/**
* Is the query for a single post of any post type (post, attachment, page, ... )?
*
* If the $post_types parameter is specified, this function will additionally
* check if the query is for one of the Posts Types specified.
*
* @see WP_Query::is_page()
* @see WP_Query::is_single()
*
* @since 3.1.0
*
* @param mixed $post_types Optional. Post Type or array of Post Types
* @return bool
*/
function is_singular( $post_types = '' ) {
if ( empty( $post_types ) || !$this->is_singular )
return (bool) $this->is_singular;
$post_obj = $this->get_queried_object();
return in_array( $post_obj->post_type, (array) $post_types );
}
/**
* Is the query for a specific time?
*
* @since 3.1.0
*
* @return bool
*/
function is_time() {
return (bool) $this->is_time;
}
/**
* Is the query for a trackback endpoint call?
*
* @since 3.1.0
*
* @return bool
*/
function is_trackback() {
return (bool) $this->is_trackback;
}
/**
* Is the query for a specific year?
*
* @since 3.1.0
*
* @return bool
*/
function is_year() {
return (bool) $this->is_year;
}
/**
* Is the query a 404 (returns no results)?
*
* @since 3.1.0
*
* @return bool
*/
function is_404() {
return (bool) $this->is_404;
}
/**
* Is the query the main query?
*
* @since 3.3.0
*
* @return bool
*/
function is_main_query() {
global $wp_the_query;
return $wp_the_query === $this;
}
}
/**
* Redirect old slugs to the correct permalink.
*
* Attempts to find the current slug from the past slugs.
*
* @since 2.1.0
* @uses $wp_query
* @uses $wpdb
*
* @return null If no link is found, null is returned.
*/
function wp_old_slug_redirect() {
global $wp_query;
if ( is_404() && '' != $wp_query->query_vars['name'] ) :
global $wpdb;
// Guess the current post_type based on the query vars.
if ( get_query_var('post_type') )
$post_type = get_query_var('post_type');
elseif ( !empty($wp_query->query_vars['pagename']) )
$post_type = 'page';
else
$post_type = 'post';
if ( is_array( $post_type ) ) {
if ( count( $post_type ) > 1 )
return;
$post_type = array_shift( $post_type );
}
// Do not attempt redirect for hierarchical post types
if ( is_post_type_hierarchical( $post_type ) )
return;
$query = $wpdb->prepare("SELECT post_id FROM $wpdb->postmeta, $wpdb->posts WHERE ID = post_id AND post_type = %s AND meta_key = '_wp_old_slug' AND meta_value = %s", $post_type, $wp_query->query_vars['name']);
// if year, monthnum, or day have been specified, make our query more precise
// just in case there are multiple identical _wp_old_slug values
if ( '' != $wp_query->query_vars['year'] )
$query .= $wpdb->prepare(" AND YEAR(post_date) = %d", $wp_query->query_vars['year']);
if ( '' != $wp_query->query_vars['monthnum'] )
$query .= $wpdb->prepare(" AND MONTH(post_date) = %d", $wp_query->query_vars['monthnum']);
if ( '' != $wp_query->query_vars['day'] )
$query .= $wpdb->prepare(" AND DAYOFMONTH(post_date) = %d", $wp_query->query_vars['day']);
$id = (int) $wpdb->get_var($query);
if ( ! $id )
return;
$link = get_permalink($id);
if ( !$link )
return;
wp_redirect( $link, 301 ); // Permanent redirect
exit;
endif;
}
/**
* Set up global post data.
*
* @since 1.5.0
*
* @param object $post Post data.
* @uses do_action_ref_array() Calls 'the_post'
* @return bool True when finished.
*/
function setup_postdata($post) {
global $id, $authordata, $currentday, $currentmonth, $page, $pages, $multipage, $more, $numpages;
$id = (int) $post->ID;
$authordata = get_userdata($post->post_author);
$currentday = mysql2date('d.m.y', $post->post_date, false);
$currentmonth = mysql2date('m', $post->post_date, false);
$numpages = 1;
$page = get_query_var('page');
if ( !$page )
$page = 1;
if ( is_single() || is_page() || is_feed() )
$more = 1;
$content = $post->post_content;
if ( strpos( $content, '' ) ) {
if ( $page > 1 )
$more = 1;
$multipage = 1;
$content = str_replace("\n\n", '', $content);
$content = str_replace("\n", '', $content);
$content = str_replace("\n", '', $content);
$pages = explode('', $content);
$numpages = count($pages);
} else {
$pages = array( $post->post_content );
$multipage = 0;
}
do_action_ref_array('the_post', array(&$post));
return true;
}
?>
'pre_user_description' that can be hooked into.
*
* The $userdata array can contain the following fields:
* 'ID' - An integer that will be used for updating an existing user.
* 'user_pass' - A string that contains the plain text password for the user.
* 'user_login' - A string that contains the user's username for logging in.
* 'user_nicename' - A string that contains a nicer looking name for the user.
* The default is the user's username.
* 'user_url' - A string containing the user's URL for the user's web site.
* 'user_email' - A string containing the user's email address.
* 'display_name' - A string that will be shown on the site. Defaults to user's
* username. It is likely that you will want to change this, for appearance.
* 'nickname' - The user's nickname, defaults to the user's username.
* 'first_name' - The user's first name.
* 'last_name' - The user's last name.
* 'description' - A string containing content about the user.
* 'rich_editing' - A string for whether to enable the rich editor. False
* if not empty.
* 'user_registered' - The date the user registered. Format is 'Y-m-d H:i:s'.
* 'role' - A string used to set the user's role.
* 'jabber' - User's Jabber account.
* 'aim' - User's AOL IM account.
* 'yim' - User's Yahoo IM account.
*
* @since 2.0.0
* @uses $wpdb WordPress database layer.
* @uses apply_filters() Calls filters for most of the $userdata fields with the prefix 'pre_user'. See note above.
* @uses do_action() Calls 'profile_update' hook when updating giving the user's ID
* @uses do_action() Calls 'user_register' hook when creating a new user giving the user's ID
*
* @param array $userdata An array of user data.
* @return int|WP_Error The newly created user's ID or a WP_Error object if the user could not be created.
*/
function wp_insert_user($userdata) {
global $wpdb;
extract($userdata, EXTR_SKIP);
// Are we updating or creating?
if ( !empty($ID) ) {
$ID = (int) $ID;
$update = true;
$old_user_data = WP_User::get_data_by( 'id', $ID );
} else {
$update = false;
// Hash the password
$user_pass = wp_hash_password($user_pass);
}
$user_login = sanitize_user($user_login, true);
$user_login = apply_filters('pre_user_login', $user_login);
//Remove any non-printable chars from the login string to see if we have ended up with an empty username
$user_login = trim($user_login);
if ( empty($user_login) )
return new WP_Error('empty_user_login', __('Cannot create a user with an empty login name.') );
if ( !$update && username_exists( $user_login ) )
return new WP_Error('existing_user_login', __('This username is already registered.') );
if ( empty($user_nicename) )
$user_nicename = sanitize_title( $user_login );
$user_nicename = apply_filters('pre_user_nicename', $user_nicename);
if ( empty($user_url) )
$user_url = '';
$user_url = apply_filters('pre_user_url', $user_url);
if ( empty($user_email) )
$user_email = '';
$user_email = apply_filters('pre_user_email', $user_email);
if ( !$update && ! defined( 'WP_IMPORTING' ) && email_exists($user_email) )
return new WP_Error('existing_user_email', __('This email address is already registered.') );
if ( empty($display_name) )
$display_name = $user_login;
$display_name = apply_filters('pre_user_display_name', $display_name);
if ( empty($nickname) )
$nickname = $user_login;
$nickname = apply_filters('pre_user_nickname', $nickname);
if ( empty($first_name) )
$first_name = '';
$first_name = apply_filters('pre_user_first_name', $first_name);
if ( empty($last_name) )
$last_name = '';
$last_name = apply_filters('pre_user_last_name', $last_name);
if ( empty($description) )
$description = '';
$description = apply_filters('pre_user_description', $description);
if ( empty($rich_editing) )
$rich_editing = 'true';
if ( empty($comment_shortcuts) )
$comment_shortcuts = 'false';
if ( empty($admin_color) )
$admin_color = 'fresh';
$admin_color = preg_replace('|[^a-z0-9 _.\-@]|i', '', $admin_color);
if ( empty($use_ssl) )
$use_ssl = 0;
if ( empty($user_registered) )
$user_registered = gmdate('Y-m-d H:i:s');
if ( empty($show_admin_bar_front) )
$show_admin_bar_front = 'true';
$user_nicename_check = $wpdb->get_var( $wpdb->prepare("SELECT ID FROM $wpdb->users WHERE user_nicename = %s AND user_login != %s LIMIT 1" , $user_nicename, $user_login));
if ( $user_nicename_check ) {
$suffix = 2;
while ($user_nicename_check) {
$alt_user_nicename = $user_nicename . "-$suffix";
$user_nicename_check = $wpdb->get_var( $wpdb->prepare("SELECT ID FROM $wpdb->users WHERE user_nicename = %s AND user_login != %s LIMIT 1" , $alt_user_nicename, $user_login));
$suffix++;
}
$user_nicename = $alt_user_nicename;
}
$data = compact( 'user_pass', 'user_email', 'user_url', 'user_nicename', 'display_name', 'user_registered' );
$data = stripslashes_deep( $data );
if ( $update ) {
$wpdb->update( $wpdb->users, $data, compact( 'ID' ) );
$user_id = (int) $ID;
} else {
$wpdb->insert( $wpdb->users, $data + compact( 'user_login' ) );
$user_id = (int) $wpdb->insert_id;
}
$user = new WP_User( $user_id );
foreach ( _get_additional_user_keys( $user ) as $key ) {
if ( isset( $$key ) )
update_user_meta( $user_id, $key, $$key );
}
if ( isset($role) )
$user->set_role($role);
elseif ( !$update )
$user->set_role(get_option('default_role'));
wp_cache_delete($user_id, 'users');
wp_cache_delete($user_login, 'userlogins');
if ( $update )
do_action('profile_update', $user_id, $old_user_data);
else
do_action('user_register', $user_id);
return $user_id;
}
/**
* Update an user in the database.
*
* It is possible to update a user's password by specifying the 'user_pass'
* value in the $userdata parameter array.
*
* If $userdata does not contain an 'ID' key, then a new user will be created
* and the new user's ID will be returned.
*
* If current user's password is being updated, then the cookies will be
* cleared.
*
* @since 2.0.0
* @see wp_insert_user() For what fields can be set in $userdata
* @uses wp_insert_user() Used to update existing user or add new one if user doesn't exist already
*
* @param array $userdata An array of user data.
* @return int The updated user's ID.
*/
function wp_update_user($userdata) {
$ID = (int) $userdata['ID'];
// First, get all of the original fields
$user_obj = get_userdata( $ID );
$user = get_object_vars( $user_obj->data );
// Add additional custom fields
foreach ( _get_additional_user_keys( $user_obj ) as $key ) {
$user[ $key ] = get_user_meta( $ID, $key, true );
}
// Escape data pulled from DB.
$user = add_magic_quotes( $user );
// If password is changing, hash it now.
if ( ! empty($userdata['user_pass']) ) {
$plaintext_pass = $userdata['user_pass'];
$userdata['user_pass'] = wp_hash_password($userdata['user_pass']);
}
wp_cache_delete($user[ 'user_email' ], 'useremail');
// Merge old and new fields with new fields overwriting old ones.
$userdata = array_merge($user, $userdata);
$user_id = wp_insert_user($userdata);
// Update the cookies if the password changed.
$current_user = wp_get_current_user();
if ( $current_user->ID == $ID ) {
if ( isset($plaintext_pass) ) {
wp_clear_auth_cookie();
wp_set_auth_cookie($ID);
}
}
return $user_id;
}
/**
* A simpler way of inserting an user into the database.
*
* Creates a new user with just the username, password, and email. For more
* complex user creation use wp_insert_user() to specify more information.
*
* @since 2.0.0
* @see wp_insert_user() More complete way to create a new user
*
* @param string $username The user's username.
* @param string $password The user's password.
* @param string $email The user's email (optional).
* @return int The new user's ID.
*/
function wp_create_user($username, $password, $email = '') {
$user_login = esc_sql( $username );
$user_email = esc_sql( $email );
$user_pass = $password;
$userdata = compact('user_login', 'user_email', 'user_pass');
return wp_insert_user($userdata);
}
/**
* Return a list of meta keys that wp_insert_user() is supposed to set.
*
* @access private
* @since 3.3.0
*
* @param object $user WP_User instance
* @return array
*/
function _get_additional_user_keys( $user ) {
$keys = array( 'first_name', 'last_name', 'nickname', 'description', 'rich_editing', 'comment_shortcuts', 'admin_color', 'use_ssl', 'show_admin_bar_front' );
return array_merge( $keys, array_keys( _wp_get_user_contactmethods( $user ) ) );
}
/**
* Set up the default contact methods
*
* @access private
* @since
*
* @param object $user User data object (optional)
* @return array $user_contactmethods Array of contact methods and their labels.
*/
function _wp_get_user_contactmethods( $user = null ) {
$user_contactmethods = array(
'aim' => __('AIM'),
'yim' => __('Yahoo IM'),
'jabber' => __('Jabber / Google Talk')
);
return apply_filters( 'user_contactmethods', $user_contactmethods, $user );
}
?>
Parse error: syntax error, unexpected $end in /home/commerci/public_html/wp-includes/script-loader.php on line 1