-
Notifications
You must be signed in to change notification settings - Fork 205
Expand file tree
/
Copy pathclass-give-db-comments-meta.php
More file actions
118 lines (105 loc) · 2.09 KB
/
Copy pathclass-give-db-comments-meta.php
File metadata and controls
118 lines (105 loc) · 2.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
<?php
/**
* Comments Meta DB class
*
* @package Give
* @subpackage Classes/Give_DB_Comment_Meta
* @copyright Copyright (c) 2018, GiveWP
* @license https://opensource.org/licenses/gpl-license GNU Public License
* @since 2.3.0
*/
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Class Give_DB_Comment_Meta
*
* This class is for interacting with the comment meta database table.
*
* @since 2.3.0
*/
class Give_DB_Comment_Meta extends Give_DB_Meta {
/**
* Meta supports.
*
* @since 2.3.0
* @access protected
* @var array
*/
protected $supports = array();
/**
* Meta type
*
* @since 2.3.0
* @access protected
* @var bool
*/
protected $meta_type = 'give_comment';
/**
* Give_DB_Comment_Meta constructor.
*
* @access public
* @since 2.3.0
*/
public function __construct() {
/* @var WPDB $wpdb */
global $wpdb;
$wpdb->give_commentmeta = $this->table_name = $wpdb->prefix . 'give_commentmeta';
$this->primary_key = 'meta_id';
$this->version = '1.0';
parent::__construct();
}
/**
* Get table columns and data types.
*
* @access public
* @since 2.3.0
*
* @return array Columns and formats.
*/
public function get_columns() {
return array(
'meta_id' => '%d',
'give_comment_id' => '%d',
'meta_key' => '%s',
'meta_value' => '%s',
);
}
/**
* Delete all comment meta
*
* @since 2.3.0
* @access public
*
* @param int $comment_id
*
* @return bool
*/
public function delete_row( $comment_id = 0 ) {
/* @var WPDB $wpdb */
global $wpdb;
// Row ID must be positive integer
$comment_id = absint( $comment_id );
if ( empty( $comment_id ) ) {
return false;
}
if ( false === $wpdb->query( $wpdb->prepare( "DELETE FROM {$this->table_name} WHERE give_comment_id = %d", $comment_id ) ) ) {
return false;
}
return true;
}
/**
* Check if current id is valid
*
* @since 2.3.0
* @access protected
*
* @param $ID
*
* @return bool
*/
protected function is_valid_post_type( $ID ) {
return $ID && true;
}
}