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