예제 #1
0
파일: rewrite.php 프로젝트: akirk/GlotPress
/**
 * 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;
}
예제 #2
0
function gp_url_public_root()
{
    return home_url(gp_url_base_path());
}
예제 #3
0
 /**
  * @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'));
 }