PluginProbe
WP Coder – Insert & Manage Code Snippets / 3.0
WP Coder – Insert & Manage Code Snippets v3.0
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
← All changes | classes/Dashboard/DBManager.php +17 -22 3.13.0 View file →
@@ -3,9 +3,9 @@
3 3 namespace WPCoder\Dashboard;
4 4
5 5 defined( 'ABSPATH' ) || exit;
6 6
7 -use WPCoder\WPCoder;
7 +use WPCoder\WOW_Plugin;
8 8
9 9 class DBManager {
10 10
11 11 public static function remove_item() {
@@ -12,14 +12,14 @@
12 12 $page = isset( $_GET['page'] ) ? sanitize_text_field( $_GET['page'] ) : '';
13 13 $action = isset( $_GET['action'] ) ? sanitize_text_field( $_GET['action'] ) : '';
14 14 $id = isset( $_GET['id'] ) ? absint( $_GET['id'] ) : '';
15 15
16 - if ( ( $page !== WPCoder::SLUG ) || ( $action !== 'delete' ) || empty( $id ) ) {
16 + if ( ( $page !== WOW_Plugin::SLUG ) || ( $action !== 'delete' ) || empty( $id ) ) {
17 17 return false;
18 18 }
19 19
20 20 global $wpdb;
21 - $table = $wpdb->prefix . WPCoder::PREFIX;
21 + $table = $wpdb->prefix . WOW_Plugin::PREFIX;
22 22
23 23 $result = $wpdb->delete( $table, [ 'id' => $id ], [ '%d' ] );
24 24
25 25 if ( $result ) {
@@ -36,16 +36,18 @@
36 36 return false;
37 37 }
38 38
39 39 global $wpdb;
40 - $table = $wpdb->prefix . WPCoder::PREFIX;
40 + $table = $wpdb->prefix . WOW_Plugin::PREFIX;
41 41
42 42 return $wpdb->delete( $table, [ 'id' => $id ], [ '%d' ] );
43 +
43 44 }
44 45
45 46 public static function create( $columns ): void {
47 +
46 48 global $wpdb;
47 - $table = $wpdb->prefix . WPCoder::PREFIX;
49 + $table = $wpdb->prefix . WOW_Plugin::PREFIX;
48 50
49 51 $sql = "CREATE TABLE IF NOT EXISTS $table ($columns) DEFAULT CHARACTER SET {$wpdb->charset} COLLATE {$wpdb->collate};";
50 52
51 53 require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
@@ -53,9 +55,9 @@
53 55 }
54 56
55 57 public static function get_all_data() {
56 58 global $wpdb;
57 - $table = $wpdb->prefix . WPCoder::PREFIX;
59 + $table = $wpdb->prefix . WOW_Plugin::PREFIX;
58 60 $result = $wpdb->get_results( "SELECT * FROM $table ORDER BY id ASC" );
59 61
60 62 return ! empty( $result ) ? $result : false;
61 63 }
@@ -64,9 +66,9 @@
64 66 if ( empty( $id ) ) {
65 67 return false;
66 68 }
67 69 global $wpdb;
68 - $table = $wpdb->prefix . WPCoder::PREFIX;
70 + $table = $wpdb->prefix . WOW_Plugin::PREFIX;
69 71 $query = $wpdb->prepare( "SELECT * FROM $table WHERE id=%d", absint( $id ) );
70 72
71 73 return $wpdb->get_row( $query );
72 74 }
@@ -76,9 +78,9 @@
76 78 return false;
77 79 }
78 80
79 81 global $wpdb;
80 - $table = $wpdb->prefix . WPCoder::PREFIX;
82 + $table = $wpdb->prefix . WOW_Plugin::PREFIX;
81 83 $query = $wpdb->prepare( "SELECT * FROM $table WHERE title=%s", sanitize_text_field( $title ) );
82 84
83 85 return $wpdb->get_row( $query );
84 86 }
@@ -83,29 +85,22 @@
83 85 return $wpdb->get_row( $query );
84 86 }
85 87
86 88 public static function update( $data, $where, $data_formats ): void {
87 - if ( ! current_user_can( 'unfiltered_html' ) ) {
88 - return;
89 - }
90 -
91 89 global $wpdb;
92 - $table = $wpdb->prefix . WPCoder::PREFIX;
90 + $table = $wpdb->prefix . WOW_Plugin::PREFIX;
93 91 $result = $wpdb->update( $table, $data, $where, $data_formats );
94 92 }
95 93
96 94 public static function insert( $data, $data_formats ) {
97 - if ( ! current_user_can( 'unfiltered_html' ) ) {
98 - return false;
99 - }
100 -
101 95 global $wpdb;
102 - $table = $wpdb->prefix . WPCoder::PREFIX;
96 + $table = $wpdb->prefix . WOW_Plugin::PREFIX;
103 97
104 98 $result = $wpdb->insert( $table, $data, $data_formats );
105 99
106 100 if ( $result ) {
107 101 return $wpdb->insert_id;
102 +
108 103 }
109 104
110 105 return false;
111 106 }
@@ -111,9 +106,9 @@
111 106 }
112 107
113 108 public static function check_row( $id = '' ): bool {
114 109 global $wpdb;
115 - $table = $wpdb->prefix . WPCoder::PREFIX;
110 + $table = $wpdb->prefix . WOW_Plugin::PREFIX;
116 111 if ( empty( $id ) ) {
117 112 return false;
118 113 }
119 114
@@ -126,9 +121,9 @@
126 121 }
127 122
128 123 public static function get_columns() {
129 124 global $wpdb;
130 - $table_name = $wpdb->prefix . WPCoder::PREFIX;
125 + $table_name = $wpdb->prefix . WOW_Plugin::PREFIX;
131 126
132 127 return $wpdb->get_results( "DESCRIBE $table_name" );
133 128 }
134 129
@@ -133,9 +128,9 @@
133 128 }
134 129
135 130 public static function display_tags(): void {
136 131 global $wpdb;
137 - $table = $wpdb->prefix . WPCoder::PREFIX;
132 + $table = $wpdb->prefix . WOW_Plugin::PREFIX;
138 133 $result = $wpdb->get_results( "SELECT * FROM $table order by tag desc", ARRAY_A );
139 134 $tags = [];
140 135 if ( ! empty( $result ) ) {
141 136 foreach ( $result as $column ) {
@@ -152,9 +147,9 @@
152 147 }
153 148
154 149 public static function get_tags_from_table() {
155 150 global $wpdb;
156 - $table = $wpdb->prefix . WPCoder::PREFIX;
151 + $table = $wpdb->prefix . WOW_Plugin::PREFIX;
157 152 $all_tags = $wpdb->get_results( "SELECT DISTINCT tag FROM $table ORDER BY tag ASC", ARRAY_A );
158 153
159 154 return ! empty( $all_tags ) ? $all_tags : false;
160 155 }