maybe_create_table

Definition:
function maybe_create_table($table_name, $create_ddl) {}

Create database table, if it doesn’t already exist.

Parameters

  • string $table_name: Database table name.
  • string $create_ddl: Create database table SQL.

Return values

returns:False on error, true if already exists or success.

Source code

function maybe_create_table($table_name, $create_ddl) {

	global $wpdb;

	foreach ($wpdb->get_col("SHOW TABLES",0) as $table ) {

		if ($table == $table_name) {

			return true;

		}

	}

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

	$wpdb->query($create_ddl);

	// we cannot directly tell that whether this succeeded!

	foreach ($wpdb->get_col("SHOW TABLES",0) as $table ) {

		if ($table == $table_name) {

			return true;

		}

	}

	return false;

}

2329

maybe_add_existing_user_to_blog

Definition:
function maybe_add_existing_user_to_blog() {}

Add a new user to a blog by visiting /newbloguser/username/.
This will only work when the user’s details are saved as an option keyed as ‘new_user_x’, where ‘x’ is the username of the user to be added, as when a user is invited through the regular WP Add User interface.

Source code

function maybe_add_existing_user_to_blog() {

	if ( false === strpos( $_SERVER[ 'REQUEST_URI' ], '/newbloguser/' ) )

		return false;



	$parts = explode( '/', $_SERVER[ 'REQUEST_URI' ] );

	$key = array_pop( $parts );



	if ( $key == '' )

		$key = array_pop( $parts );



	$details = get_option( 'new_user_' . $key );

	if ( !empty( $details ) )

		delete_option( 'new_user_' . $key );



	if ( empty( $details ) || is_wp_error( add_existing_user_to_blog( $details ) ) )

		wp_die( sprintf(__('An error occurred adding you to this site. Back to the <a href="%s">homepage</a>.'), site_url() ) );



	wp_die( sprintf(__('You have been added to this site. Please visit the <a href="%s">homepage</a> or <a href="%s">log in</a> using your username and password.'), site_url(), admin_url() ), __('Success') );

}

2327

maybe_add_column

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

Add column to database table, if column doesn’t already exist in table.

Parameters

  • string $table_name: Database table name
  • string $column_name: Table column name
  • string $create_ddl: SQL to add column to table.

Return values

returns:False on failure. True, if already exists or was successful.

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.

	$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;

}

2325

manage_columns_prefs

Definition:
function manage_columns_prefs( $page ) {}

Parameters

  • unknown_type $page

Source code

function manage_columns_prefs( $page ) {

	$columns = get_column_headers( $page );

	$hidden  = get_hidden_columns( $page );

	$special = array('_title', 'cb', 'comment', 'media', 'name', 'title', 'username');



	foreach ( $columns as $column => $title ) {

		// Can't hide these or they are special

		if ( in_array( $column, $special ) )

			continue;

		if ( empty( $title ) )

			continue;



		if ( 'comments' == $column )

			$title = __( 'Comments' );

		$id = "$column-hide";

		echo '<label for="' . $id . '">';

		echo '<input class="hide-column-tog" name="' . $id . '" type="checkbox" id="' . $id . '" value="' . $column . '"' . (! in_array($column, $hidden) ? ' checked="checked"' : '') . ' />';

		echo "$title</label>\n";

	}

}

2321