| @@ -41,14 +41,26 @@ | ||
| 41 | 41 | |
| 42 | 42 | return $wpdb->delete( $table, [ 'id' => $id ], [ '%d' ] ); |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | - public static function create( $columns ): void { | |
| 45 | + public static function create(): void { | |
| 46 | 46 | global $wpdb; |
| 47 | - $table = $wpdb->prefix . WPCoder::PREFIX; | |
| 47 | + $table_name = $wpdb->prefix . WPCoder::PREFIX; | |
| 48 | + $charset_collate = $wpdb->get_charset_collate(); | |
| 48 | 49 | |
| 49 | - $sql = "CREATE TABLE IF NOT EXISTS $table ($columns) DEFAULT CHARACTER SET {$wpdb->charset} COLLATE {$wpdb->collate};"; | |
| 50 | - | |
| 50 | + $sql = "CREATE TABLE $table_name ( | |
| 51 | + id mediumint(9) NOT NULL AUTO_INCREMENT, | |
| 52 | + title VARCHAR(200) NOT NULL, | |
| 53 | + html_code LONGTEXT, | |
| 54 | + css_code LONGTEXT, | |
| 55 | + js_code LONGTEXT, | |
| 56 | + php_code LONGTEXT, | |
| 57 | + param LONGTEXT, | |
| 58 | + status BOOLEAN, | |
| 59 | + mode BOOLEAN, | |
| 60 | + tag TEXT, | |
| 61 | + PRIMARY KEY (id) | |
| 62 | + ) $charset_collate;"; | |
| 51 | 63 | require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); |
| 52 | 64 | dbDelta( $sql ); |
| 53 | 65 | } |
| 54 | 66 | |
| @@ -83,9 +95,9 @@ | ||
| 83 | 95 | return $wpdb->get_row( $query ); |
| 84 | 96 | } |
| 85 | 97 | |
| 86 | 98 | public static function update( $data, $where, $data_formats ): void { |
| 87 | - if ( ! current_user_can( 'unfiltered_html' ) ) { | |
| 99 | + if ( ! current_user_can( 'manage_options' ) ) { | |
| 88 | 100 | return; |
| 89 | 101 | } |
| 90 | 102 | |
| 91 | 103 | global $wpdb; |
| @@ -93,9 +105,9 @@ | ||
| 93 | 105 | $result = $wpdb->update( $table, $data, $where, $data_formats ); |
| 94 | 106 | } |
| 95 | 107 | |
| 96 | 108 | public static function insert( $data, $data_formats ) { |
| 97 | - if ( ! current_user_can( 'unfiltered_html' ) ) { | |
| 109 | + if ( ! current_user_can( 'manage_options' ) ) { | |
| 98 | 110 | return false; |
| 99 | 111 | } |
| 100 | 112 | |
| 101 | 113 | global $wpdb; |