| 1 | <?php
|
|---|
| 2 |
|
|---|
| 3 | class WPDB_Injector {
|
|---|
| 4 | private $wpdb;
|
|---|
| 5 | static function init() {
|
|---|
| 6 | global $wpdb;
|
|---|
| 7 | if ( ! $wpdb instanceof WPDB_Injector ) {
|
|---|
| 8 | $wpdb = new WPDB_Injector( $wpdb );
|
|---|
| 9 | }
|
|---|
| 10 | }
|
|---|
| 11 | private function __construct( $wpdb ) { $this->wpdb = $wpdb; }
|
|---|
| 12 |
|
|---|
| 13 | public function __call( $method, $args ) { return call_user_func_array( array( $this->wpdb, $method ), $args ); }
|
|---|
| 14 | public function __get( $var ) { return $this->wpdb->$var; }
|
|---|
| 15 | public function __set( $var, $val ) { return $this->wpdb->$var = $val; }
|
|---|
| 16 | public function __isset( $var ) { return isset( $this->wpdb->$var ); }
|
|---|
| 17 | public function __unset( $var ) { unset( $this->wpdb->$var ); }
|
|---|
| 18 |
|
|---|
| 19 | public function update() {
|
|---|
| 20 | $args = func_get_args();
|
|---|
| 21 |
|
|---|
| 22 | do_action( 'WPDB_Injector_update', $args );
|
|---|
| 23 |
|
|---|
| 24 | return $this->__call( 'update', $args );
|
|---|
| 25 | }
|
|---|
| 26 |
|
|---|
| 27 | }
|
|---|
| 28 | WPDB_Injector::init();
|
|---|