/** * Instantiates the plugin and setup all modules. * * @since 4.0.0 * * @global wpdb $wpdb The instance of database connection. * @global domain_map $dm_map The instance of domain_map class. */ function domainmap_launch() { global $wpdb, $dm_map; // setup environment define('DOMAINMAP_BASEFILE', __FILE__); define('DOMAINMAP_ABSURL', plugins_url('/', __FILE__)); define('DOMAINMAP_ABSPATH', dirname(__FILE__)); if (!defined('DM_FORCE_PROTOCOL_ON_MAPPED_DOMAIN')) { define('DM_FORCE_PROTOCOL_ON_MAPPED_DOMAIN', false); } $prefix = isset($wpdb->base_prefix) ? $wpdb->base_prefix : $wpdb->prefix; define('DOMAINMAP_TABLE_MAP', "{$prefix}domain_mapping"); define('DOMAINMAP_TABLE_RESELLER_LOG', "{$prefix}domain_mapping_reseller_log"); // MultiDB compatibility, register global tables if (defined('MULTI_DB_VERSION') && function_exists('add_global_table')) { add_global_table('domain_mapping'); add_global_table('domain_mapping_reseller_log'); } // set up the plugin core class $dm_map = new domain_map(); // instantiate the plugin $plugin = Domainmap_Plugin::instance(); // set general modules $plugin->set_module(Domainmap_Module_System::NAME); $plugin->set_module(Domainmap_Module_Setup::NAME); $plugin->set_module(Domainmap_Module_Mapping::NAME); // CDSSO module $sunrise = defined('SUNRISE') && filter_var(SUNRISE, FILTER_VALIDATE_BOOLEAN); if ($sunrise && defined('DOMAINMAPPING_USE_CDSSO') && $plugin->get_option('map_crossautologin')) { $plugin->set_module(Domainmap_Module_Cdsso::NAME); } // conditional modules if (defined('DOING_AJAX') && DOING_AJAX) { // suppresses errors rendering to prevent unexpected issues set_error_handler('__return_true'); set_exception_handler('__return_true'); // set ajax modules $plugin->set_module(Domainmap_Module_Ajax_Map::NAME); $plugin->set_module(Domainmap_Module_Ajax_Purchase::NAME); $plugin->set_module(Domainmap_Module_Ajax_Register::NAME); } else { if (is_admin()) { // set admin modules $plugin->set_module(Domainmap_Module_Pages::NAME); $plugin->set_module(Domainmap_Module_Admin::NAME); } } }
/** * Logs request to reseller API. * * @since 4.0.0 * * @access protected * @global wpdb $wpdb The current database connection. * @param int $type The request type. * @param boolean $valid Determines whether the request has been successfull or not. * @param array|string $errors The error(s) received in the response. * @param mixed $response The response information, received on request. */ protected function _log_request($type, $valid, $errors, $response) { global $wpdb; // sets last errors if request failed if (!$valid) { $this->_last_errors = new WP_Error(); foreach ((array) $errors as $code => $message) { $this->_last_errors->add($code, $message); } } else { $this->_last_errors = null; } // get logging level option $options = Domainmap_Plugin::instance()->get_options(); $level = isset($options['map_reseller_log']) ? (int) $options['map_reseller_log'] : self::LOG_LEVEL_DISABLED; // don't log request if logging is disabled or request is valid, // but only errors should be logged if (!$type || !$level || $valid && $level == self::LOG_LEVEL_ERRORS) { return; } // save requests into the log $wpdb->insert(DOMAINMAP_TABLE_RESELLER_LOG, array('user_id' => get_current_user_id(), 'provider' => $this->get_reseller_id(), 'requested_at' => current_time('mysql'), 'type' => $type, 'valid' => $valid ? 1 : 0, 'errors' => is_array($errors) ? implode(PHP_EOL, $errors) : $errors, 'response' => json_encode($response)), array('%d', '%s', '%s', '%d', '%d', '%s', '%s')); }
/** * Renders registration form. * * @since 4.1.0 * * @access public * @global WP_User $current_user The current user object. */ public function render_registration_form() { global $current_user; get_currentuserinfo(); $cardholder = trim($current_user->user_firstname . ' ' . $current_user->user_lastname); if (empty($cardholder)) { $cardholder = __('Your name', 'domainmap'); } $template = new Domainmap_Render_Reseller_Enom_Register(); $template->errors = $this->get_last_errors(); $template->cardtypes = $this->get_card_types(); $template->cardholder = $cardholder; $template->countries = Domainmap_Plugin::instance()->get_countries(); $template->render(); }
function setup_plugin() { $this->options = Domainmap_Plugin::instance()->get_options(); $permitted = true; if (function_exists('is_pro_site') && !empty($this->options['map_supporteronly'])) { // We have a pro-site option set and the pro-site plugin exists $levels = (array) get_site_option('psts_levels'); if (!is_array($this->options['map_supporteronly']) && !empty($levels) && $this->options['map_supporteronly'] == '1') { $keys = array_keys($levels); $this->options['map_supporteronly'] = array($keys[0]); } $permitted = false; foreach ((array) $this->options['map_supporteronly'] as $level) { if (is_pro_site(false, $level)) { $permitted = true; } } } // Add the network admin settings if ($permitted) { add_action('wp_logout', array($this, 'wp_logout'), 10); add_action('admin_head', array($this, 'build_cookie')); } }