create table likes and com

task_4097
GP_DV 3 months ago
parent 6e7ed0ee35
commit 38bec6349a
  1. 22
      wp-content/themes/cosmopet/functions.php

@ -760,3 +760,25 @@ return $result > 0;
add_filter('comment_form_logged_in', '__return_empty_string');
// Создание таблицы
function create_likes_table() {
global $wpdb;
$table_name = $wpdb->prefix . 'cosmopet_likes';
$charset_collate = $wpdb->get_charset_collate();
$sql = "CREATE TABLE IF NOT EXISTS $table_name (
id bigint(20) NOT NULL AUTO_INCREMENT,
user_id bigint(20) NOT NULL,
post_id bigint(20) DEFAULT '0',
comment_id bigint(20) DEFAULT '0',
date_added datetime DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (id),
KEY post_id (post_id),
KEY comment_id (comment_id),
KEY user_id (user_id),
UNIQUE KEY user_post (user_id, post_id, comment_id)
) $charset_collate;";
require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
dbDelta($sql);
}
add_action('after_switch_theme', 'create_likes_table');

Loading…
Cancel
Save