$format = null ) { return $this->_insert_replace_helper( $table, $data, $format, 'REPLACE' ); } /** * Helper function for insert and replace. * * Runs an insert or replace query based on $type argument. * * @access private * @since 3.0.0 * @see wpdb::prepare() * @see wpdb::$field_types * @see wp_set_wpdb_vars() * * @param string $table table name * @param array $data Data to insert (in column => value pairs). Both $data columns and $data values should be "raw" (neither should be SQL escaped). * @param array|string $format Optional. An array of formats to be mapped to each of the value in $data. If string, that format will be used for all of the values in $data. * A format is one of '%d', '%s' (decimal number, string). If omitted, all values in $data will be treated as strings unless otherwise specified in wpdb::$field_types. * @return int|false The number of rows affected, or false on error. */ function _insert_replace_helper( $table, $data, $format = null, $type = 'INSERT' ) { if ( ! in_array( strtoupper( $type ), array( 'REPLACE', 'INSERT' ) ) ) return false; $formats = $format = (array) $format; $fields = array_keys( $data ); $formatted_fields = array(); foreach ( $fields as $field ) { if ( !empty( $format ) ) $form = ( $form = array_shift( $formats ) ) ? $form : $format[0]; elseif ( isset( $this->field_types[$field] ) ) $form = $this->field_types[$field]; else $form = '%s'; $formatted_fields[] = $form; } $sql = "{$type} INTO `$table` (`" . implode( '`,`', $fields ) . "`) VALUES ('" . implode( "','", $formatted_fields ) . "')"; return $this->query( $this->prepare( $sql, $data ) ); } /** * Update a row in the table * * * wpdb::update( 'table', array( 'column' => 'foo', 'field' => 'bar' ), array( 'ID' => 1 ) ) * wpdb::update( 'table', array( 'column' => 'foo', 'field' => 1337 ), array( 'ID' => 1 ), array( '%s', '%d' ), array( '%d' ) ) * * * @since 2.5.0 * @see wpdb::prepare() * @see wpdb::$field_types * @see wp_set_wpdb_vars() * * @param string $table table name * @param array $data Data to update (in column => value pairs). Both $data columns and $data values should be "raw" (neither should be SQL escaped). * @param array $where A named array of WHERE clauses (in column => value pairs). Multiple clauses will be joined with ANDs. Both $where columns and $where values should be "raw". * @param array|string $format Optional. An array of formats to be mapped to each of the values in $data. If string, that format will be used for all of the values in $data. * A format is one of '%d', '%s' (decimal number, string). If omitted, all values in $data will be treated as strings unless otherwise specified in wpdb::$field_types. * @param array|string $format_where Optional. An array of formats to be mapped to each of the values in $where. If string, that format will be used for all of the items in $where. A format is one of '%d', '%s' (decimal number, string). If omitted, all values in $where will be treated as strings. * @return int|false The number of rows updated, or false on error. */ function update( $table, $data, $where, $format = null, $where_format = null ) { if ( ! is_array( $data ) || ! is_array( $where ) ) return false; $formats = $format = (array) $format; $bits = $wheres = array(); foreach ( (array) array_keys( $data ) as $field ) { if ( !empty( $format ) ) $form = ( $form = array_shift( $formats ) ) ? $form : $format[0]; elseif ( isset($this->field_types[$field]) ) $form = $this->field_types[$field]; else $form = '%s'; $bits[] = "`$field` = {$form}"; } $where_formats = $where_format = (array) $where_format; foreach ( (array) array_keys( $where ) as $field ) { if ( !empty( $where_format ) ) $form = ( $form = array_shift( $where_formats ) ) ? $form : $where_format[0]; elseif ( isset( $this->field_types[$field] ) ) $form = $this->field_types[$field]; else $form = '%s'; $wheres[] = "`$field` = {$form}"; } $sql = "UPDATE `$table` SET " . implode( ', ', $bits ) . ' WHERE ' . implode( ' AND ', $wheres ); return $this->query( $this->prepare( $sql, array_merge( array_values( $data ), array_values( $where ) ) ) ); } /** * Retrieve one variable from the database. * * Executes a SQL query and returns the value from the SQL result. * If the SQL result contains more than one column and/or more than one row, this function returns the value in the column and row specified. * If $query is null, this function returns the value in the specified column and row from the previous SQL result. * * @since 0.71 * * @param string|null $query Optional. SQL query. Defaults to null, use the result from the previous query. * @param int $x Optional. Column of value to return. Indexed from 0. * @param int $y Optional. Row of value to return. Indexed from 0. * @return string|null Database query result (as string), or null on failure */ function get_var( $query = null, $x = 0, $y = 0 ) { $this->func_call = "\$db->get_var(\"$query\", $x, $y)"; if ( $query ) $this->query( $query ); // Extract var out of cached results based x,y vals if ( !empty( $this->last_result[$y] ) ) { $values = array_values( get_object_vars( $this->last_result[$y] ) ); } // If there is a value return it else return null return ( isset( $values[$x] ) && $values[$x] !== '' ) ? $values[$x] : null; } /** * Retrieve one row from the database. * * Executes a SQL query and returns the row from the SQL result. * * @since 0.71 * * @param string|null $query SQL query. * @param string $output Optional. one of ARRAY_A | ARRAY_N | OBJECT constants. Return an associative array (column => value, ...), * a numerically indexed array (0 => value, ...) or an object ( ->column = value ), respectively. * @param int $y Optional. Row to return. Indexed from 0. * @return mixed Database query result in format specifed by $output or null on failure */ function get_row( $query = null, $output = OBJECT, $y = 0 ) { $this->func_call = "\$db->get_row(\"$query\",$output,$y)"; if ( $query ) $this->query( $query ); else return null; if ( !isset( $this->last_result[$y] ) ) return null; if ( $output == OBJECT ) { return $this->last_result[$y] ? $this->last_result[$y] : null; } elseif ( $output == ARRAY_A ) { return $this->last_result[$y] ? get_object_vars( $this->last_result[$y] ) : null; } elseif ( $output == ARRAY_N ) { return $this->last_result[$y] ? array_values( get_object_vars( $this->last_result[$y] ) ) : null; } else { $this->print_error(/*WP_I18N_DB_GETROW_ERROR*/" \$db->get_row(string query, output type, int offset) -- Output type must be one of: OBJECT, ARRAY_A, ARRAY_N"/*/WP_I18N_DB_GETROW_ERROR*/); } } /** * Retrieve one column from the database. * * Executes a SQL query and returns the column from the SQL result. * If the SQL result contains more than one column, this function returns the column specified. * If $query is null, this function returns the specified column from the previous SQL result. * * @since 0.71 * * @param string|null $query Optional. SQL query. Defaults to previous query. * @param int $x Optional. Column to return. Indexed from 0. * @return array Database query result. Array indexed from 0 by SQL result row number. */ function get_col( $query = null , $x = 0 ) { if ( $query ) $this->query( $query ); $new_array = array(); // Extract the column values for ( $i = 0, $j = count( $this->last_result ); $i < $j; $i++ ) { $new_array[$i] = $this->get_var( null, $x, $i ); } return $new_array; } /** * Retrieve an entire SQL result set from the database (i.e., many rows) * * Executes a SQL query and returns the entire SQL result. * * @since 0.71 * * @param string $query SQL query. * @param string $output Optional. Any of ARRAY_A | ARRAY_N | OBJECT | OBJECT_K constants. With one of the first three, return an array of rows indexed from 0 by SQL result row number. * Each row is an associative array (column => value, ...), a numerically indexed array (0 => value, ...), or an object. ( ->column = value ), respectively. * With OBJECT_K, return an associative array of row objects keyed by the value of each row's first column's value. Duplicate keys are discarded. * @return mixed Database query results */ function get_results( $query = null, $output = OBJECT ) { $this->func_call = "\$db->get_results(\"$query\", $output)"; if ( $query ) $this->query( $query ); else return null; $new_array = array(); if ( $output == OBJECT ) { // Return an integer-keyed array of row objects return $this->last_result; } elseif ( $output == OBJECT_K ) { // Return an array of row objects with keys from column 1 // (Duplicates are discarded) foreach ( $this->last_result as $row ) { $key = array_shift( $var_by_ref = get_object_vars( $row ) ); if ( ! isset( $new_array[ $key ] ) ) $new_array[ $key ] = $row; } return $new_array; } elseif ( $output == ARRAY_A || $output == ARRAY_N ) { // Return an integer-keyed array of... if ( $this->last_result ) { foreach( (array) $this->last_result as $row ) { if ( $output == ARRAY_N ) { // ...integer-keyed row arrays $new_array[] = array_values( get_object_vars( $row ) ); } else { // ...column name-keyed row arrays $new_array[] = get_object_vars( $row ); } } } return $new_array; } return null; } /** * Retrieve column metadata from the last query. * * @since 0.71 * * @param string $info_type Optional. Type one of name, table, def, max_length, not_null, primary_key, multiple_key, unique_key, numeric, blob, type, unsigned, zerofill * @param int $col_offset Optional. 0: col name. 1: which table the col's in. 2: col's max length. 3: if the col is numeric. 4: col's type * @return mixed Column Results */ function get_col_info( $info_type = 'name', $col_offset = -1 ) { if ( $this->col_info ) { if ( $col_offset == -1 ) { $i = 0; $new_array = array(); foreach( (array) $this->col_info as $col ) { $new_array[$i] = $col->{$info_type}; $i++; } return $new_array; } else { return $this->col_info[$col_offset]->{$info_type}; } } } /** * Starts the timer, for debugging purposes. * * @since 1.5.0 * * @return true */ function timer_start() { $mtime = explode( ' ', microtime() ); $this->time_start = $mtime[1] + $mtime[0]; return true; } /** * Stops the debugging timer. * * @since 1.5.0 * * @return int Total time spent on the query, in milliseconds */ function timer_stop() { $mtime = explode( ' ', microtime() ); $time_end = $mtime[1] + $mtime[0]; $time_total = $time_end - $this->time_start; return $time_total; } /** * Wraps errors in a nice header and footer and dies. * * Will not die if wpdb::$show_errors is true * * @since 1.5.0 * * @param string $message The Error message * @param string $error_code Optional. A Computer readable string to identify the error. * @return false|void */ function bail( $message, $error_code = '500' ) { if ( !$this->show_errors ) { if ( class_exists( 'WP_Error' ) ) $this->error = new WP_Error($error_code, $message); else $this->error = $message; return false; } wp_die($message); } /** * Whether MySQL database is at least the required minimum version. * * @since 2.5.0 * @uses $wp_version * @uses $required_mysql_version * * @return WP_Error */ function check_database_version() { global $wp_version, $required_mysql_version; // Make sure the server has the required MySQL version if ( version_compare($this->db_version(), $required_mysql_version, '<') ) return new WP_Error('database_version', sprintf( __( 'ERROR: WordPress %1$s requires MySQL %2$s or higher' ), $wp_version, $required_mysql_version )); } /** * Whether the database supports collation. * * Called when WordPress is generating the table scheme. * * @since 2.5.0 * * @return bool True if collation is supported, false if version does not */ function supports_collation() { return $this->has_cap( 'collation' ); } /** * Determine if a database supports a particular feature * * @since 2.7 * @see wpdb::db_version() * * @param string $db_cap the feature * @return bool */ function has_cap( $db_cap ) { $version = $this->db_version(); switch ( strtolower( $db_cap ) ) { case 'collation' : // @since 2.5.0 case 'group_concat' : // @since 2.7 case 'subqueries' : // @since 2.7 return version_compare( $version, '4.1', '>=' ); }; return false; } /** * Retrieve the name of the function that called wpdb. * * Searches up the list of functions until it reaches * the one that would most logically had called this method. * * @since 2.5.0 * * @return string The name of the calling function */ function get_caller() { $trace = array_reverse( debug_backtrace() ); $caller = array(); foreach ( $trace as $call ) { if ( isset( $call['class'] ) && __CLASS__ == $call['class'] ) continue; // Filter out wpdb calls. $caller[] = isset( $call['class'] ) ? "{$call['class']}->{$call['function']}" : $call['function']; } return join( ', ', $caller ); } /** * The database version number. * * @return false|string false on failure, version number on success */ function db_version() { return preg_replace( '/[^0-9.].*/', '', mysql_get_server_info( $this->dbh ) ); } } if ( ! isset( $wpdb ) ) { /** * WordPress Database Object, if it isn't set already in wp-content/db.php * @global object $wpdb Creates a new wpdb object based on wp-config.php Constants for the database * @since 0.71 */ $wpdb = new wpdb( DB_USER, DB_PASSWORD, DB_NAME, DB_HOST ); } ?> '] = is_author() ? get_query_var( 'author' ) : 0; $r = wp_parse_args( $args, $defaults ); extract( $r, EXTR_SKIP ); $blog_prefix = $wpdb->get_blog_prefix( $blog_id ); $query = "SELECT {$wpdb->users}.* FROM $wpdb->users, $wpdb->usermeta WHERE {$wpdb->users}.ID = {$wpdb->usermeta}.user_id AND meta_key = '{$blog_prefix}capabilities'"; $query_where = array(); if ( is_array($include) ) $include = join(',', $include); $include = preg_replace('/[^0-9,]/', '', $include); // (int) if ( $include ) $query_where[] = "ID IN ($include)"; if ( is_array($exclude) ) $exclude = join(',', $exclude); $exclude = preg_replace('/[^0-9,]/', '', $exclude); // (int) if ( $exclude ) $query_where[] = "ID NOT IN ($exclude)"; if ( $query_where ) $query .= " AND " . join(' AND', $query_where); $query .= " ORDER BY $orderby $order"; $users = $wpdb->get_results( $query ); $output = ''; if ( !empty($users) ) { $name = esc_attr( $name ); if ( $multi && ! $id ) $id = ''; else $id = $id ? " id='" . esc_attr( $id ) . "'" : " id='$name'"; $output = ""; } $output = apply_filters('wp_dropdown_users', $output); if ( $echo ) echo $output; return $output; } /** * Add user meta data as properties to given user object. * * The finished user data is cached, but the cache is not used to fill in the * user data for the given object. Once the function has been used, the cache * should be used to retrieve user data. The intention is if the current data * had been cached already, there would be no need to call this function. * * @access private * @since 2.5.0 * @uses $wpdb WordPress database object for queries * * @param object $user The user data object. */ function _fill_user( &$user ) { $metavalues = get_user_metavalues(array($user->ID)); _fill_single_user($user, $metavalues[$user->ID]); } /** * Perform the query to get the $metavalues array(s) needed by _fill_user and _fill_many_users * * @since 3.0.0 * @param array $ids User ID numbers list. * @return array of arrays. The array is indexed by user_id, containing $metavalues object arrays. */ function get_user_metavalues($ids) { global $wpdb; $clean = array_map('intval', $ids); if ( 0 == count($clean) ) return $objects; $list = implode(',', $clean); $show = $wpdb->hide_errors(); $metavalues = $wpdb->get_results("SELECT user_id, meta_key, meta_value FROM $wpdb->usermeta WHERE user_id IN ($list)"); $wpdb->show_errors($show); $objects = array(); foreach($clean as $id) { $objects[$id] = array(); } foreach($metavalues as $meta_object) { $objects[$meta_object->user_id][] = $meta_object; } return $objects; } /** * Unserialize user metadata, fill $user object, then cache everything. * * @since 3.0.0 * @param object $user The User object. * @param array $metavalues An array of objects provided by get_user_metavalues() */ function _fill_single_user( &$user, &$metavalues ) { global $wpdb; foreach ( $metavalues as $meta ) { $value = maybe_unserialize($meta->meta_value); // Keys used as object vars cannot have dashes. $key = str_replace('-', '', $meta->meta_key); $user->{$key} = $value; } $level = $wpdb->prefix . 'user_level'; if ( isset( $user->{$level} ) ) $user->user_level = $user->{$level}; // For backwards compat. if ( isset($user->first_name) ) $user->user_firstname = $user->first_name; if ( isset($user->last_name) ) $user->user_lastname = $user->last_name; if ( isset($user->description) ) $user->user_description = $user->description; update_user_caches($user); } /** * Take an array of user objects, fill them with metas, and cache them. * * @since 3.0.0 * @param array $users User objects */ function _fill_many_users( &$users ) { $ids = array(); foreach($users as $user_object) { $ids[] = $user_object->ID; } $metas = get_user_metavalues($ids); foreach($users as $user_object) { if (isset($metas[$user_object->ID])) { _fill_single_user($user_object, $metas[$user_object->ID]); } } } /** * Sanitize every user field. * * If the context is 'raw', then the user object or array will get minimal santization of the int fields. * * @since 2.3.0 * @uses sanitize_user_field() Used to sanitize the fields. * * @param object|array $user The User Object or Array * @param string $context Optional, default is 'display'. How to sanitize user fields. * @return object|array The now sanitized User Object or Array (will be the same type as $user) */ function sanitize_user_object($user, $context = 'display') { if ( is_object($user) ) { if ( !isset($user->ID) ) $user->ID = 0; if ( isset($user->data) ) $vars = get_object_vars( $user->data ); else $vars = get_object_vars($user); foreach ( array_keys($vars) as $field ) { if ( is_string($user->$field) || is_numeric($user->$field) ) $user->$field = sanitize_user_field($field, $user->$field, $user->ID, $context); } $user->filter = $context; } else { if ( !isset($user['ID']) ) $user['ID'] = 0; foreach ( array_keys($user) as $field ) $user[$field] = sanitize_user_field($field, $user[$field], $user['ID'], $context); $user['filter'] = $context; } return $user; } /** * Sanitize user field based on context. * * Possible context values are: 'raw', 'edit', 'db', 'display', 'attribute' and 'js'. The * 'display' context is used by default. 'attribute' and 'js' contexts are treated like 'display' * when calling filters. * * @since 2.3.0 * @uses apply_filters() Calls 'edit_$field' and '${field_no_prefix}_edit_pre' passing $value and * $user_id if $context == 'edit' and field name prefix == 'user_'. * * @uses apply_filters() Calls 'edit_user_$field' passing $value and $user_id if $context == 'db'. * @uses apply_filters() Calls 'pre_$field' passing $value if $context == 'db' and field name prefix == 'user_'. * @uses apply_filters() Calls '${field}_pre' passing $value if $context == 'db' and field name prefix != 'user_'. * * @uses apply_filters() Calls '$field' passing $value, $user_id and $context if $context == anything * other than 'raw', 'edit' and 'db' and field name prefix == 'user_'. * @uses apply_filters() Calls 'user_$field' passing $value if $context == anything other than 'raw', * 'edit' and 'db' and field name prefix != 'user_'. * * @param string $field The user Object field name. * @param mixed $value The user Object value. * @param int $user_id user ID. * @param string $context How to sanitize user fields. Looks for 'raw', 'edit', 'db', 'display', * 'attribute' and 'js'. * @return mixed Sanitized value. */ function sanitize_user_field($field, $value, $user_id, $context) { $int_fields = array('ID'); if ( in_array($field, $int_fields) ) $value = (int) $value; if ( 'raw' == $context ) return $value; if ( !is_string($value) && !is_numeric($value) ) return $value; $prefixed = false; if ( false !== strpos($field, 'user_') ) { $prefixed = true; $field_no_prefix = str_replace('user_', '', $field); } if ( 'edit' == $context ) { if ( $prefixed ) { $value = apply_filters("edit_$field", $value, $user_id); } else { $value = apply_filters("edit_user_$field", $value, $user_id); } if ( 'description' == $field ) $value = esc_html($value); else $value = esc_attr($value); } else if ( 'db' == $context ) { if ( $prefixed ) { $value = apply_filters("pre_$field", $value); } else { $value = apply_filters("pre_user_$field", $value); } } else { // Use display filters by default. if ( $prefixed ) $value = apply_filters($field, $value, $user_id, $context); else $value = apply_filters("user_$field", $value, $user_id, $context); } if ( 'user_url' == $field ) $value = esc_url($value); if ( 'attribute' == $context ) $value = esc_attr($value); else if ( 'js' == $context ) $value = esc_js($value); return $value; } /** * Update all user caches * * @since 3.0.0 * * @param object $user User object to be cached */ function update_user_caches(&$user) { wp_cache_add($user->ID, $user, 'users'); wp_cache_add($user->user_login, $user->ID, 'userlogins'); wp_cache_add($user->user_email, $user->ID, 'useremail'); wp_cache_add($user->user_nicename, $user->ID, 'userslugs'); } /** * Clean all user caches * * @since 3.0.0 * * @param int $id User ID */ function clean_user_cache($id) { $user = new WP_User($id); wp_cache_delete($id, 'users'); wp_cache_delete($user->user_login, 'userlogins'); wp_cache_delete($user->user_email, 'useremail'); wp_cache_delete($user->user_nicename, 'userslugs'); } ?>
Fatal error: Cannot redeclare delete_usermeta() in /home/herveyw/public_html/wp-includes/deprecated.php on line 2278