/** * Handles overload methods (and dynamic class instances). * * @param string $method Name of a valid overload method to call upon. * Or a dynamic class to return an instance of, using the special class `©` prefix. * Or a dynamic singleton class method to call upon; also using the `©` prefix, along with a `.method_name` suffix. * * @param array $args An array of arguments to the overload method, or dynamic class object constructor. * In the case of dynamic objects, it's fine to exclude the first argument, which is handled automatically by this routine. * That is, the first argument to any extender is always the parent instance (i.e. `$this`). * * @return mixed Dynamic return values, or a dynamic object instance; else an exception is thrown. * * @throws exception If `$method` CANNOT be defined in any way. */ public function __call($method, $args) { $method = (string) $method; // Typecasting this to a string value. $args = (array) $args; // Typecast these arguments to an array value. if (method_exists($this->wpdb, $method)) { if (!empty($args[0]) && is_string($args[0]) && !in_array($method, array('escape', '_real_escape'), TRUE) && !$this->©plugin->is_active_at_current_version() && !$this->is_modifying_plugin_tables()) { $lc_method = strtolower($method); $plugin_tables_imploded_for_regex = $this->©db_tables->imploded_for_regex(); if (in_array($lc_method, array('query', 'get_var', 'get_row', 'get_col', 'get_results'), TRUE) && preg_match('/`(?:' . $plugin_tables_imploded_for_regex . ')`/', $args[0]) || in_array($lc_method, array('insert', 'replace', '_insert_replace_helper', 'update', 'delete'), TRUE) && preg_match('/^(?:' . $plugin_tables_imploded_for_regex . ')$/', $args[0])) { return NULL; } // Stop plugin queries. } // Else call upon the WordPress® DB class. return call_user_func_array(array($this->wpdb, $method), $args); } return parent::__call($method, $args); // Default return value. }