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