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-payment-meta.php
94 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Payment Meta DB class |
| 4 | * |
| 5 | * @package Give |
| 6 | * @subpackage Classes/DB Payment Meta |
| 7 | * @copyright Copyright (c) 2016, GiveWP |
| 8 | * @license https://opensource.org/licenses/gpl-license GNU Public License |
| 9 | * @since 2.0 |
| 10 | */ |
| 11 | |
| 12 | // Exit if accessed directly. |
| 13 | if ( ! defined( 'ABSPATH' ) ) { |
| 14 | exit; |
| 15 | } |
| 16 | |
| 17 | /** |
| 18 | * Class Give_DB_Payment_Meta |
| 19 | * |
| 20 | * This class is for interacting with the payment meta database table. |
| 21 | * |
| 22 | * @since 2.0 |
| 23 | */ |
| 24 | class Give_DB_Payment_Meta extends Give_DB_Meta { |
| 25 | /** |
| 26 | * Post type |
| 27 | * |
| 28 | * @since 2.0 |
| 29 | * @access protected |
| 30 | * @var bool |
| 31 | */ |
| 32 | protected $post_type = 'give_payment'; |
| 33 | |
| 34 | /** |
| 35 | * Meta type |
| 36 | * |
| 37 | * @since 2.0 |
| 38 | * @access protected |
| 39 | * @var bool |
| 40 | */ |
| 41 | protected $meta_type = 'donation'; |
| 42 | |
| 43 | /** |
| 44 | * Give_DB_Payment_Meta constructor. |
| 45 | * |
| 46 | * @access public |
| 47 | * @since 2.0 |
| 48 | */ |
| 49 | public function __construct() { |
| 50 | /* @var WPDB $wpdb */ |
| 51 | global $wpdb; |
| 52 | |
| 53 | // @todo: We leave $wpdb->paymentmeta for backward compatibility, use $wpdb->donationmeta instead. We can remove it after 2.1.3. |
| 54 | $wpdb->paymentmeta = $wpdb->donationmeta = $this->table_name = $wpdb->prefix . 'give_donationmeta'; |
| 55 | $this->version = '1.0'; |
| 56 | |
| 57 | // Backward compatibility. |
| 58 | if ( ! give_has_upgrade_completed( 'v220_rename_donation_meta_type' ) ) { |
| 59 | $this->meta_type = 'payment'; |
| 60 | $wpdb->paymentmeta = $wpdb->donationmeta = $this->table_name = $wpdb->prefix . 'give_paymentmeta'; |
| 61 | } |
| 62 | |
| 63 | parent::__construct(); |
| 64 | } |
| 65 | |
| 66 | /** |
| 67 | * Get table columns and data types. |
| 68 | * |
| 69 | * @access public |
| 70 | * @since 2.0 |
| 71 | * |
| 72 | * @return array Columns and formats. |
| 73 | */ |
| 74 | public function get_columns() { |
| 75 | return array( |
| 76 | 'meta_id' => '%d', |
| 77 | "{$this->meta_type}_id" => '%d', |
| 78 | 'meta_key' => '%s', |
| 79 | 'meta_value' => '%s', |
| 80 | ); |
| 81 | } |
| 82 | |
| 83 | /** |
| 84 | * check if custom meta table enabled or not. |
| 85 | * |
| 86 | * @since 2.0 |
| 87 | * @access protected |
| 88 | * @return bool |
| 89 | */ |
| 90 | protected function is_custom_meta_table_active() { |
| 91 | return give_has_upgrade_completed( 'v20_move_metadata_into_new_table' ); |
| 92 | } |
| 93 | } |
| 94 |