/** * Checks if we're on a EE-CPT archive-or-single page, and if we've never set the EE request var. * If so, sets the 'ee' request variable * so other parts of EE can know what CPT is getting queried. * To Mike's knowledge, this must be called from during or after the pre_get_posts hook * in order for is_archive() and is_single() methods to work properly. * @return void */ public function _possibly_set_ee_request_var() { // check if ee action var has been set if (!EE_Registry::instance()->REQ->is_set('ee')) { // check that route exists for CPT archive slug if (is_archive() && EE_Config::get_route($this->CPT['plural_slug'])) { // ie: set "ee" to "events" EE_Registry::instance()->REQ->set('ee', $this->CPT['plural_slug']); // or does it match a single page CPT like /event/ } else { if (is_single() && EE_Config::get_route($this->CPT['singular_slug'])) { // ie: set "ee" to "event" EE_Registry::instance()->REQ->set('ee', $this->CPT['singular_slug']); } } } }
/** * resolve_route * * this method simply takes a valid route, and resolves what module class method the route points to * * @access public * @param string $current_route * @return mixed EED_Module | boolean */ public function resolve_route($current_route) { // get module method that route has been mapped to $module_method = EE_Config::get_route($current_route); // printr( $module_method, '$module_method <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); // verify result was returned if (empty($module_method)) { $msg = sprintf(__('The requested route %s could not be mapped to any registered modules.', 'event_espresso'), $current_route); EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); return FALSE; } // verify that result is an array if (!is_array($module_method)) { $msg = sprintf(__('The %s route has not been properly registered.', 'event_espresso'), $current_route); EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); return FALSE; } // grab module name $module_name = $module_method[0]; // verify that a class method was registered properly if (!isset($module_method[1])) { $msg = sprintf(__('A class method for the %s route has not been properly registered.', 'event_espresso'), $current_route); EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); return FALSE; } // grab method $method = $module_method[1]; // verify that class exists if (!class_exists($module_name)) { $msg = sprintf(__('The requested %s class could not be found.', 'event_espresso'), $module_name); EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); return FALSE; } // verify that method exists if (!method_exists($module_name, $method)) { $msg = sprintf(__('The class method %s for the %s route is in invalid.', 'event_espresso'), $method, $current_route); EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); return FALSE; } // instantiate module and call route method return $this->_module_router($module_name, $method); }