PluginProbe
WP Coder – Insert & Manage Code Snippets / 4.3
WP Coder – Insert & Manage Code Snippets v4.3
4.5.1 1.1 2.3.1 2.3.2 2.4.1 2.5.1 2.5.2 2.5.3 2.5.4 2.5.5 2.5.6 3.0 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.1 3.1.1 3.2 3.2.1 3.3 3.4 3.5 3.5.1 All 39 releases
wp-coder / classes / Update / UpdateDB.php

UpdateDB.php in WP Coder – Insert & Manage Code Snippets 4.3, at classes/Update/UpdateDB.php

54 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace WPCoder\Update;
4
5 use WPCoder\WPCoder;
6
7 class UpdateDB {
8
9 const NEW_DB_VERSION = '3.6';
10
11 const TABLE_COLUMNS = "
12 id mediumint(9) NOT NULL AUTO_INCREMENT,
13 title VARCHAR(200) NOT NULL,
14 html_code LONGTEXT,
15 css_code LONGTEXT,
16 js_code LONGTEXT,
17 php_code LONGTEXT,
18 param LONGTEXT,
19 status BOOLEAN,
20 mode BOOLEAN,
21 tag TEXT,
22 php_include int(11) NOT NULL DEFAULT '0',
23 UNIQUE KEY id (id),
24 INDEX id_index (id)
25 ";
26
27 public static function init(): void {
28 $current_db_version = get_option( WPCoder::PREFIX . '_db_version' );
29
30 if ( $current_db_version && version_compare( $current_db_version, self::NEW_DB_VERSION, '>=' ) ) {
31 return;
32 }
33
34 self::start_update();
35 update_option( WPCoder::PREFIX . '_db_version', self::NEW_DB_VERSION );
36 }
37
38 private static function start_update(): void {
39 self::update_database();
40 }
41
42 private static function update_database(): void {
43 global $wpdb;
44
45 $table = $wpdb->prefix . WPCoder::PREFIX;
46 $charset_collate = $wpdb->get_charset_collate();
47
48 require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
49
50 $sql = "CREATE TABLE $table (" . self::TABLE_COLUMNS . ") $charset_collate;";
51 dbDelta( $sql );
52 }
53
54 }