PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 2.3.2
GiveWP – Donation Plugin and Fundraising Platform v2.3.2
4.17.0 4.16.9 4.16.8.1 4.16.8 4.16.7.2 4.16.7.1 4.16.7 4.16.6.1 4.16.6 4.16.5.1 4.16.5 4.16.4 4.16.3 4.16.2 4.16.1 4.16.0 4.15.5 4.15.4 4.15.3 4.15.2 4.15.1 4.15.0 2.3.0 2.3.1 2.3.2 All 256 releases
give / includes / class-give-db-donor-meta.php

class-give-db-donor-meta.php in GiveWP – Donation Plugin and Fundraising Platform 2.3.2, at includes/class-give-db-donor-meta.php

119 lines 2.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Donor Meta DB class
4 *
5 * @package Give
6 * @subpackage Classes/DB Donor Meta
7 * @copyright Copyright (c) 2016, GiveWP
8 * @license https://opensource.org/licenses/gpl-license GNU Public License
9 * @since 1.6
10 */
11
12 // Exit if accessed directly.
13 if ( ! defined( 'ABSPATH' ) ) {
14 exit;
15 }
16
17 /**
18 * Class Give_DB_Donor_Meta
19 *
20 * This class is for interacting with the donor meta database table.
21 *
22 * @since 1.6
23 */
24 class Give_DB_Donor_Meta extends Give_DB_Meta {
25
26 /**
27 * Meta supports.
28 *
29 * @since 2.0
30 * @access protected
31 * @var array
32 */
33 protected $supports = array();
34
35 /**
36 * Meta type
37 *
38 * @since 2.0
39 * @access public
40 *
41 * @var string
42 */
43 public $meta_type = 'donor';
44
45
46 /**
47 * Give_DB_Donor_Meta constructor.
48 *
49 * @access public
50 * @since 1.6
51 */
52 public function __construct() {
53 /* @var WPDB $wpdb */
54 global $wpdb;
55
56 $wpdb->donormeta = $this->table_name = $wpdb->prefix . 'give_donormeta';
57 $this->primary_key = 'meta_id';
58 $this->version = '1.0';
59
60 parent::__construct();
61
62 $this->bc_200_params();
63 }
64
65 /**
66 * Get table columns and data types.
67 *
68 * @access public
69 * @since 1.6
70 *
71 * @return array Columns and formats.
72 */
73 public function get_columns() {
74 return array(
75 'meta_id' => '%d',
76 'donor_id' => '%d',
77 'meta_key' => '%s',
78 'meta_value' => '%s',
79 );
80 }
81
82 /**
83 * Add backward compatibility for old table name
84 *
85 * @since 2.0
86 * @access private
87 * @global wpdb $wpdb
88 */
89 private function bc_200_params() {
90 /* @var wpdb $wpdb */
91 global $wpdb;
92
93 if (
94 ! give_has_upgrade_completed( 'v20_rename_donor_tables' ) &&
95 $wpdb->query( $wpdb->prepare( "SHOW TABLES LIKE %s","{$wpdb->prefix}give_customermeta" ) )
96 ) {
97 $wpdb->donormeta = $this->table_name = "{$wpdb->prefix}give_customermeta";
98 $this->meta_type = 'customer';
99 }
100
101 $wpdb->customermeta = $wpdb->donormeta;
102 }
103
104 /**
105 * Check if current id is valid
106 *
107 * @since 2.0
108 * @access protected
109 *
110 * @param $ID
111 *
112 * @return bool
113 */
114 protected function is_valid_post_type( $ID ) {
115 return $ID && true;
116 }
117
118 }
119