/** * Generate the WP rewrite rules. * * @since 1.0.0 * * @param string|bool $gp_base Optional. The base of all GlotPress URLs. * Defaults to the `GP_URL_BASE` constant. * @return array Rewrite rules that transform the URL structure * to a set of query vars */ function gp_generate_rewrite_rules($gp_base = false) { if (false === $gp_base) { $gp_base = trim(gp_url_base_path(), '/'); } $rules = array(); if (!$gp_base) { $rules['$'] = 'index.php?gp_route'; $rules['^(.*)$'] = 'index.php?gp_route=$matches[1]'; } else { $rules['^' . $gp_base . '$'] = 'index.php?gp_route'; $rules['^' . $gp_base . '\\/+(.*)$'] = 'index.php?gp_route=$matches[1]'; } return $rules; }
function gp_url_public_root() { return home_url(gp_url_base_path()); }
/** * @ticket gh-203 */ function test_gp_url_base_path_filter() { add_filter('gp_url_base_path', array($this, '_gp_url_base_path_filter_single_slash')); $this->assertSame($this->base_path_single_slash, gp_url_base_path()); $this->assertSame('http://example.org' . $this->base_path_single_slash, gp_url_public_root()); remove_filter('gp_url_base_path', array($this, '_gp_url_base_path_filter_single_slash')); }