public function add_rewrite_rules($rules) { global $wp_rewrite; $new_rules = array(); $routes = MvcRouter::get_public_routes(); // Use default routes if none have been defined if (empty($routes)) { MvcRouter::public_connect('{:controller}', array('action' => 'index')); MvcRouter::public_connect('{:controller}/{:id:[\\d]+}', array('action' => 'show')); MvcRouter::public_connect('{:controller}/{:action}/{:id:[\\d]+}'); $routes = MvcRouter::get_public_routes(); } foreach ($routes as $route) { $route_path = $route[0]; $route_defaults = $route[1]; if (strpos($route_path, '{:controller}') !== false) { foreach ($this->public_controller_names as $controller) { $route_rules = $this->get_rewrite_rules($route_path, $route_defaults, $controller); $new_rules = array_merge($route_rules, $new_rules); } } else { if (!empty($route_defaults['controller'])) { $route_rules = $this->get_rewrite_rules($route_path, $route_defaults, $route_defaults['controller'], 1); $new_rules = array_merge($route_rules, $new_rules); } } } $rules = array_merge($new_rules, $rules); $rules = apply_filters('mvc_public_rewrite_rules', $rules); return $rules; }
<?php MvcRouter::public_connect('{:controller}', array('action' => 'index')); MvcRouter::public_connect('{:controller}/{:id:[\d]+}', array('action' => 'show')); MvcRouter::public_connect('{:controller}/{:action}/{:id:[\d]+}'); MvcRouter::public_connect('{:controller}/{:action}'); MvcRouter::public_connect('enroll', array('controller' => 'enrollments', 'action' => 'enroll')); MvcRouter::public_connect('apply/{:hash}', array('controller' => 'enrollments', 'action' => 'payment')); MvcRouter::public_connect('renew', array('controller' => 'enrollments', 'action' => 'payment')); MvcRouter::public_connect('upgrade', array('controller' => 'enrollments', 'action' => 'payment')); MvcRouter::admin_ajax_connect(array('controller' => 'members', 'action' => 'update_details')); MvcRouter::admin_ajax_connect(array('controller' => 'members', 'action' => 'update_pwd')); MvcRouter::admin_ajax_connect(array('controller' => 'members', 'action' => 'update_settings')); MvcRouter::admin_ajax_connect(array('controller' => 'members', 'action' => 'update_cc')); MvcRouter::admin_ajax_connect(array('controller' => 'members', 'action' => 'update_auto_renew'));
<?php MvcRouter::public_connect('', array('controller' => 'documentation_nodes', 'action' => 'show', 'local_id' => 1)); MvcRouter::public_connect('documentation/{:documentation_version_name:[\\d.]+}', array('controller' => 'documentation_nodes', 'action' => 'show', 'local_id' => 1)); MvcRouter::public_connect('documentation/{:documentation_version_name:[\\d.]+}/{:local_id:[\\d]+}/.*', array('controller' => 'documentation_nodes', 'action' => 'show')); MvcRouter::public_connect('documentation/{:local_id:[\\d]+}/.*', array('controller' => 'documentation_nodes', 'action' => 'show')); MvcRouter::public_connect('search', array('controller' => 'documentation_nodes', 'action' => 'search')); MvcRouter::public_connect('{:controller}', array('action' => 'index')); MvcRouter::public_connect('{:controller}/{:id:[\\d]+}', array('action' => 'show')); MvcRouter::public_connect('{:controller}/{:action}/{:id:[\\d]+}'); MvcRouter::admin_ajax_connect(array('controller' => 'admin_documentation_nodes', 'action' => 'update_tree')); MvcRouter::admin_ajax_connect(array('controller' => 'admin_documentation_nodes', 'action' => 'preview_content'));