PHP 8.1.33
Preview: install-helper.php Size: 5.89 KB
/home/jambtst2015/public_html/wp-admin/install-helper.php

<?php
/**
 * Plugins may load this file to gain access to special helper functions for
 * plugin installation. This file is not included by WordPress and it is
 * recommended, to prevent fatal errors, that this file is included using
 * require_once.
 *
 * These functions are not optimized for speed, but they should only be used
 * once in a while, so speed shouldn't be a concern. If it is and you are
 * needing to use these functions a lot, you might experience time outs. If you
 * do, then it is advised to just write the SQL code yourself.
 *
 *     check_column( 'wp_links', 'link_description', 'mediumtext' );
 *     if ( check_column( $wpdb->comments, 'comment_author', 'tinytext' ) ) {
 *         echo "ok\n";
 *     }
 *
 *     $error_count = 0;
 *     $tablename = $wpdb->links;
 *     // Check the column.
 *     if ( ! check_column( $wpdb->links, 'link_description', 'varchar( 255 )' ) ) {
 *         $ddl = "ALTER TABLE $wpdb->links MODIFY COLUMN link_description varchar(255) NOT NULL DEFAULT '' ";
 *         $q = $wpdb->query( $ddl );
 *     }
 *
 *     if ( check_column( $wpdb->links, 'link_description', 'varchar( 255 )' ) ) {
 *         $res .= $tablename . ' - ok <br />';
 *     } else {
 *         $res .= 'There was a problem with ' . $tablename . '<br />';
 *         ++$error_count;
 *     }
 *
 * @package WordPress
 * @subpackage Plugin
 */

/** Load WordPress Bootstrap */
require_once dirname( __DIR__ ) . '/wp-load.php';

if ( ! function_exists( 'maybe_create_table' ) ) :
	/**
	 * Creates a table in the database if it doesn't already exist.
	 *
	 * @since 1.0.0
	 *
	 * @global wpdb $wpdb WordPress database abstraction object.
	 *
	 * @param string $table_name Database table name.
	 * @param string $create_ddl SQL statement to create table.
	 * @return bool True on success or if the table already exists. False on failure.
	 */
	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, so 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;
	}
endif;

if ( ! function_exists( 'maybe_add_column' ) ) :
	/**
	 * Adds column to database table, if it doesn't already exist.
	 *
	 * @since 1.0.0
	 *
	 * @global wpdb $wpdb WordPress database abstraction object.
	 *
	 * @param string $table_name  Database table name.
	 * @param string $column_name Table column name.
	 * @param string $create_ddl  SQL statement to add column.
	 * @return bool True on success or if the column already exists. False on failure.
	 */
	function maybe_add_column( $table_name, $column_name, $create_ddl ) {
		global $wpdb;

		foreach ( $wpdb->get_col( "DESC $table_name", 0 ) as $column ) {
			if ( $column === $column_name ) {
				return true;
			}
		}

		// Didn't find it, so 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;
	}
endif;

/**
 * Drops column from database table, if it exists.
 *
 * @since 1.0.0
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param string $table_name  Database table name.
 * @param string $column_name Table column name.
 * @param string $drop_ddl    SQL statement to drop column.
 * @return bool True on success or if the column doesn't exist. False on failure.
 */
function maybe_drop_column( $table_name, $column_name, $drop_ddl ) {
	global $wpdb;

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

			// Found it, so try to drop it.
			$wpdb->query( $drop_ddl );

			// We cannot directly tell that whether this succeeded!
			foreach ( $wpdb->get_col( "DESC $table_name", 0 ) as $column ) {
				if ( $column === $column_name ) {
					return false;
				}
			}
		}
	}

	// Else didn't find it.
	return true;
}

/**
 * Checks that database table column matches the criteria.
 *
 * Uses the SQL DESC for retrieving the table info for the column. It will help
 * understand the parameters, if you do more research on what column information
 * is returned by the SQL statement. Pass in null to skip checking that
 * criteria.
 *
 * Column names returned from DESC table are case sensitive and are listed:
 *      Field
 *      Type
 *      Null
 *      Key
 *      Default
 *      Extra
 *
 * @since 1.0.0
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param string $table_name Database table name.
 * @param string $col_name   Table column name.
 * @param string $col_type   Table column type.
 * @param bool   $is_null    Optional. Check is null.
 * @param mixed  $key        Optional. Key info.
 * @param mixed  $default    Optional. Default value.
 * @param mixed  $extra      Optional. Extra value.
 * @return bool True, if matches. False, if not matching.
 */
function check_column( $table_name, $col_name, $col_type, $is_null = null, $key = null, $default = null, $extra = null ) {
	global $wpdb;

	$diffs   = 0;
	$results = $wpdb->get_results( "DESC $table_name" );

	foreach ( $results as $row ) {

		if ( $row->Field === $col_name ) {

			// Got our column, check the params.
			if ( ( null !== $col_type ) && ( $row->Type !== $col_type ) ) {
				++$diffs;
			}
			if ( ( null !== $is_null ) && ( $row->Null !== $is_null ) ) {
				++$diffs;
			}
			if ( ( null !== $key ) && ( $row->Key !== $key ) ) {
				++$diffs;
			}
			if ( ( null !== $default ) && ( $row->Default !== $default ) ) {
				++$diffs;
			}
			if ( ( null !== $extra ) && ( $row->Extra !== $extra ) ) {
				++$diffs;
			}

			if ( $diffs > 0 ) {
				return false;
			}

			return true;
		} // End if found our column.
	}

	return false;
}

Directory Contents

Dirs: 7 × Files: 91

Name Size Perms Modified Actions
css DIR
- drwxr-xr-x 2024-11-22 17:53:11
Edit Download
images DIR
- drwxr-xr-x 2024-11-22 17:53:11
Edit Download
includes DIR
- drwxr-xr-x 2024-12-08 14:52:17
Edit Download
js DIR
- drwxr-xr-x 2024-11-22 17:53:11
Edit Download
maint DIR
- drwxr-xr-x 2024-11-22 17:53:11
Edit Download
network DIR
- drwxr-xr-x 2025-10-19 00:06:17
Edit Download
user DIR
- drwxr-xr-x 2025-10-19 00:06:17
Edit Download
81 B lr--r--r-- 2024-12-09 06:09:12
Edit Download
25.13 KB lrw-r--r-- 2025-10-08 16:39:40
Edit Download
4.58 KB lrw-r--r-- 2024-11-22 17:53:11
Edit Download
2.77 KB lrw-r--r-- 2024-11-22 17:53:11
Edit Download
406 B lrw-r--r-- 2024-11-22 17:53:11
Edit Download
8.42 KB lrw-r--r-- 2024-11-22 17:53:11
Edit Download
1.63 KB lrw-r--r-- 2024-11-22 17:53:11
Edit Download
11.85 KB lrw-r--r-- 2024-11-22 17:53:11
Edit Download
3.74 KB lrw-r--r-- 2024-11-22 17:53:11
Edit Download
65.71 KB lr--r--r-- 2023-10-23 06:09:12
Edit Download
11.11 KB lrw-r--r-- 2024-11-22 17:53:11
Edit Download
3.77 KB lrw-r--r-- 2024-11-22 17:53:11
Edit Download
416 B lrw-r--r-- 2024-11-22 17:53:11
Edit Download
426 B lrw-r--r-- 2024-11-22 17:53:11
Edit Download
10.07 KB lrw-r--r-- 2024-11-22 17:53:11
Edit Download
13.42 KB lrw-r--r-- 2024-11-22 17:53:11
Edit Download
28.22 KB lrw-r--r-- 2024-11-22 17:53:11
Edit Download
14.48 KB lrw-r--r-- 2024-11-22 17:53:11
Edit Download
7.91 KB lrw-r--r-- 2024-11-22 17:53:11
Edit Download
6.09 KB lrw-r--r-- 2024-11-22 17:53:11
Edit Download
9.87 KB lrw-r--r-- 2024-11-22 17:53:11
Edit Download
21.40 KB lrw-r--r-- 2024-11-22 17:53:11
Edit Download
18.07 KB lrw-r--r-- 2024-11-22 17:53:11
Edit Download
3.16 KB lrw-r--r-- 2024-11-22 17:53:11
Edit Download
140.80 KB lrw-r--r-- 2025-11-04 02:36:00
Edit Download
3.13 KB lrw-r--r-- 2024-11-22 17:53:11
Edit Download
10.71 KB lrw-r--r-- 2024-11-22 17:53:11
Edit Download
4.46 KB lrw-r--r-- 2024-11-22 17:53:11
Edit Download
7.35 KB lrw-r--r-- 2024-11-22 17:53:11
Edit Download
6.75 KB lrw-r--r-- 2024-11-22 17:53:11
Edit Download
5.89 KB lrw-r--r-- 2024-11-22 17:53:11
Edit Download
16.51 KB lrw-r--r-- 2024-11-22 17:53:11
Edit Download
711 B lrw-r--r-- 2024-11-22 17:53:11
Edit Download
4.09 KB lrw-r--r-- 2024-11-22 17:53:11
Edit Download
2.59 KB lrw-r--r-- 2024-11-22 17:53:11
Edit Download
2.67 KB lrw-r--r-- 2024-11-22 17:53:11
Edit Download
1.65 KB lrw-r--r-- 2024-11-22 17:53:11
Edit Download
2.25 KB lrw-r--r-- 2024-11-22 17:53:11
Edit Download
3.12 KB lrw-r--r-- 2024-11-22 17:53:11
Edit Download
3.41 KB lrw-r--r-- 2024-11-22 17:53:11
Edit Download
5.47 KB lrw-r--r-- 2024-11-22 17:53:11
Edit Download
9.60 KB lrw-r--r-- 2024-11-22 17:53:11
Edit Download
14.19 KB lrw-r--r-- 2024-11-22 17:53:11
Edit Download
307 B lrw-r--r-- 2024-11-22 17:53:11
Edit Download
196 B lrw-r--r-- 2024-11-22 17:53:11
Edit Download
4.18 KB lrw-r--r-- 2024-11-22 17:53:11
Edit Download
216 B lrw-r--r-- 2024-11-22 17:53:11
Edit Download
223 B lrw-r--r-- 2024-11-22 17:53:11
Edit Download
215 B lrw-r--r-- 2024-11-22 17:53:11
Edit Download
217 B lrw-r--r-- 2024-11-22 17:53:11
Edit Download
219 B lrw-r--r-- 2024-11-22 17:53:11
Edit Download
215 B lrw-r--r-- 2024-11-22 17:53:11
Edit Download
4.54 KB lrw-r--r-- 2024-11-22 17:53:11
Edit Download
43.72 KB lrw-r--r-- 2024-11-22 17:53:11
Edit Download
5.25 KB lrw-r--r-- 2024-11-22 17:53:11
Edit Download
15.08 KB lrw-r--r-- 2024-11-22 17:53:11
Edit Download
14.61 KB lrw-r--r-- 2024-11-22 17:53:11
Edit Download
492 B lrw-r--r-- 2024-11-22 17:53:11
Edit Download
6.15 KB lrw-r--r-- 2024-11-22 17:53:11
Edit Download
18.76 KB lrw-r--r-- 2024-11-22 17:53:11
Edit Download
7.88 KB lrw-r--r-- 2024-11-22 17:53:11
Edit Download
9.48 KB lrw-r--r-- 2024-11-22 17:53:11
Edit Download
8.42 KB lrw-r--r-- 2024-11-22 17:53:11
Edit Download
12.48 KB lrw-r--r-- 2024-11-22 17:53:11
Edit Download
13.01 KB lrw-r--r-- 2024-11-22 17:53:11
Edit Download
6.21 KB lrw-r--r-- 2024-11-22 17:53:11
Edit Download
28.45 KB lrw-r--r-- 2024-11-22 17:53:11
Edit Download
2.64 KB lrw-r--r-- 2024-11-22 17:53:11
Edit Download
9.76 KB lrw-r--r-- 2024-11-22 17:53:11
Edit Download
2.33 KB lrw-r--r-- 2024-11-22 17:53:11
Edit Download
833 B lrw-r--r-- 2024-11-22 17:53:11
Edit Download
2.25 KB lrw-r--r-- 2024-11-22 17:53:11
Edit Download
283 B lrw-r--r-- 2024-11-22 17:53:11
Edit Download
5.41 KB lrw-r--r-- 2024-11-22 17:53:11
Edit Download
15.44 KB lrw-r--r-- 2024-11-22 17:53:11
Edit Download
5.65 KB lrw-r--r-- 2024-11-22 17:53:11
Edit Download
5.21 KB lrw-r--r-- 2024-11-22 17:53:11
Edit Download
2.20 KB lrw-r--r-- 2024-11-22 17:53:11
Edit Download
14.68 KB lrw-r--r-- 2024-11-22 17:53:11
Edit Download
21.48 KB lrw-r--r-- 2024-11-22 17:53:11
Edit Download
43.78 KB lrw-r--r-- 2024-11-22 17:53:11
Edit Download
3.37 KB lrw-r--r-- 2024-11-22 17:53:11
Edit Download
37.39 KB lrw-r--r-- 2024-11-22 17:53:11
Edit Download
12.59 KB lrw-r--r-- 2024-11-22 17:53:11
Edit Download
341 B lrw-r--r-- 2024-11-22 17:53:11
Edit Download
5.47 KB lrw-r--r-- 2024-11-22 17:53:11
Edit Download
13.64 KB lrw-r--r-- 2024-11-22 17:53:11
Edit Download
28.52 KB lrw-r--r-- 2024-11-22 17:53:11
Edit Download
22.64 KB lrw-r--r-- 2024-11-22 17:53:11
Edit Download
19.43 KB lrw-r--r-- 2024-11-22 17:53:11
Edit Download
19.28 KB lrw-r--r-- 2024-11-22 17:53:11
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).