Demonstration for how AffiliateWP registers a table to be compatible with the core metadata API.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Core class used to implement affiliate meta. | |
* | |
* @since 1.6 | |
* | |
* @see Affiliate_WP_DB | |
*/ | |
class Affiliate_WP_Affiliate_Meta_DB extends Affiliate_WP_DB { | |
/** | |
* Sets up the Affiliate Meta DB class. | |
* | |
* @access public | |
* @since 1.6 | |
*/ | |
public function __construct() { | |
global $wpdb; | |
$this->table_name = $wpdb->prefix . 'affiliate_wp_affiliatemeta'; | |
add_action( 'plugins_loaded', array( $this, 'register_table' ), 11 ); | |
} | |
// other code | |
/** | |
* Registers the table with $wpdb so the metadata api can find it. | |
* | |
* @access public | |
* @since 1.6 | |
* | |
* @global wpdb $wpdb WordPress database abstraction object. | |
*/ | |
public function register_table() { | |
global $wpdb; | |
$wpdb->affiliatemeta = $this->table_name; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment