lts; } /** * A custom table stores locations */ public function create_table() { global $wpdb; $feed_locator_table_name = $wpdb->prefix . $this->table; if ($wpdb->get_var("show tables like '{$feed_locator_table_name}'") != $feed_locator_table_name) { $sql = "CREATE TABLE " . $feed_locator_table_name . " (\n\t\t\t\tid BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,\n feed_id VARCHAR(50) DEFAULT '' NOT NULL,\n post_id BIGINT(20) UNSIGNED NOT NULL,\n html_location VARCHAR(50) DEFAULT 'unknown' NOT NULL,\n shortcode_atts LONGTEXT NOT NULL,\n last_update DATETIME\n );"; $wpdb->query($sql); } $error = $wpdb->last_error; $query = $wpdb->last_query; $had_error = \false; if ($wpdb->get_var("show tables like '{$feed_locator_table_name}'") != $feed_locator_table_name) { $had_error = \true; } if (!$had_error) { $wpdb->query("ALTER TABLE {$feed_locator_table_name} ADD INDEX feed_id (feed_id)"); $wpdb->query("ALTER TABLE {$feed_locator_table_name} ADD INDEX post_id (post_id)"); } } public function update_legacy_to_builder($args) { global $wpdb; $data = array('feed_id' => '*' . $args['new_feed_id'], 'shortcode_atts' => '{"feed":"' . $args['new_feed_id'] . '"}'); $affected = $wpdb->query($wpdb->prepare("UPDATE {$this->table}\n \t\t\t\tSET feed_id = %s, shortcode_atts = %s", $data['feed_id'], $data['shortcode_atts'])); return $affected; } }