Skip to content

Instantly share code, notes, and snippets.

@KaineLabs
Last active July 14, 2021 14:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KaineLabs/bc0beea560d1b6a4ecf38deb38213579 to your computer and use it in GitHub Desktop.
Save KaineLabs/bc0beea560d1b6a4ecf38deb38213579 to your computer and use it in GitHub Desktop.
Install Reviews Table
<?php
/**
* Install Reviews Table
* Ps: Once the reviews table added just remove this snippet.
*/
function yzc_install_reviews_table() {
global $wpdb;
// Set Variables
$sql = array();
$reviews_table = $wpdb->prefix . 'youzify_reviews';
$charset_collate = $wpdb->get_charset_collate();
$sql[] = "CREATE TABLE $reviews_table (
id BIGINT(20) NOT NULL AUTO_INCREMENT,
reviewer int(11) NOT NULL,
reviewed int(11) NOT NULL,
rating DECIMAL(2,1) NOT NULL,
review LONGTEXT NOT NULL,
options LONGTEXT NOT NULL,
time datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,
PRIMARY KEY (id)
) $charset_collate;";
// Include Files.
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
// Build Tables.
dbDelta( $sql );
}
add_action( 'init', 'yzc_install_reviews_table' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment