maybe_add_column

Definition:
function maybe_add_column($table_name, $column_name, $create_ddl) {}

* maybe_add_column() * Add column to db table if it doesn’t exist.
* Returns: true if already exists or on successful completion * false on error

Parameters

  • $table_name
  • $column_name
  • $create_ddl

Source code

function maybe_add_column($table_name, $column_name, $create_ddl) {

	global $wpdb, $debug;

	foreach ($wpdb->get_col("DESC $table_name", 0) as $column ) {

		if ($debug) echo("checking $column == $column_name<br />");

		if ($column == $column_name) {

			return true;

		}

	}

	//didn't find it try to create it.

	$q = $wpdb->query($create_ddl);

	// we cannot directly tell that whether this succeeded!

	foreach ($wpdb->get_col("DESC $table_name", 0) as $column ) {

		if ($column == $column_name) {

			return true;

		}

	}

	return false;

}

9993

is_wp_error

Definition:
function is_wp_error($thing) {}

Check whether variable is a WordPress Error.
Looks at the object and if a WP_Error class. Does not check to see if the parent is also WP_Error, so can’t inherit WP_Error and still use this function.

Parameters

  • mixed $thing: Check if unknown variable is WordPress Error object.

Return values

returns:True, if WP_Error. False, if not WP_Error.

Source code

function is_wp_error($thing) {

	if ( is_object($thing) && is_a($thing, 'WP_Error') )

		return true;

	return false;

}

9944

is_user_admin

Definition:
function is_user_admin() {}

Whether the current request is for a user admin screen /wp-admin/user/
Does not inform on whether the user is an admin! Use capability checks to tell if the user should be accessing a section or not.

Return values

returns:True if inside WordPress user administration pages.

Source code

function is_user_admin() {

	if ( defined( 'WP_USER_ADMIN' ) )

		return WP_USER_ADMIN;

	return false;

}

9937

is_post_type_archive

Definition:
function is_post_type_archive( $post_types = '' ) {}

Is the query for a post type archive page?

Parameters

  • mixed $post_types: Optional. Post type or array of posts types to check against.

Source code

	function is_post_type_archive( $post_types = '' ) {

		if ( empty( $post_types ) || !$this->is_post_type_archive )

			return (bool) $this->is_post_type_archive;



		$post_type_object = $this->get_queried_object();



		return in_array( $post_type_object->name, (array) $post_types );

	}

9908