コード例 #1
0
        # Add filter permalink structure for taxonomy archives
        foreach (Get_Taxonomies(Null, 'objects') as $taxonomy) {
            $taxonomy_slug = $taxonomy->rewrite['slug'];
            if (!In_Array(Post_Type::$post_type_name, $taxonomy->object_type)) {
                continue;
            }
            self::$rewrite_rules[LTrim(SPrintF('%s/([^/]+)/filter:([^/]+)/?$', $taxonomy_slug), '/')] = SPrintF('index.php?%s=$matches[1]&filter=$matches[2]', $taxonomy->name);
            self::$rewrite_rules[LTrim(SPrintF('%s/([^/]+)/filter:([^/]+)/page/([0-9]{1,})/?$', $taxonomy_slug), '/')] = SPrintF('index.php?%s=$matches[1]&filter=$matches[2]&paged=$matches[3]', $taxonomy->name);
        }
    }
    static function addRewriteRules($rules)
    {
        if (Is_Array(self::$rewrite_rules) && Is_Array($rules)) {
            return Array_Merge(self::$rewrite_rules, $rules);
        } else {
            return $rules;
        }
    }
    static function flushRewriteRules()
    {
        $rules = Get_Option('rewrite_rules');
        foreach (self::$rewrite_rules as $new_rule => $redirect) {
            if (!isset($rules[$new_rule])) {
                Flush_Rewrite_Rules();
                return;
            }
        }
    }
}
Permalinks::Init();
コード例 #2
0
ファイル: Router.php プロジェクト: knapnet/PHP-Fusion
 /**
  * Cleans the URL
  *
  * Thanks to "THE PERFECT PHP CLEAN URL GENERATOR"(http://cubiq.org/the-perfect-php-clean-url-generator)
  *
  * This function will clean the URL by removing any unwanted characters from it and
  * only allowing alphanumeric and - in the URL.
  * This function can be customized according to your needs.
  *
  * @param string $string The URL String
  * @access private
  */
 private function cleanURL($string, $delimiter = "-")
 {
     /** Alias of Static Function of PermalinksDisplay */
     $string = Permalinks::cleanURL($string, $delimiter);
     return $string;
 }
コード例 #3
0
ファイル: permalinks.php プロジェクト: AliBritt/pressgang
 * rewrite /wp-content/themes/theme-name/css/ to /css/
 * rewrite /wp-content/themes/theme-name/js/ to /js/
 * rewrite /wp-content/themes/theme-name/img/ to /img/
 * rewrite /wp-content/plugins/ to /plugins/
 *
 */
class Permalinks
{
    /**
     * init
     */
    public static function init()
    {
        add_action('generate_rewrite_rules', array('PressGang\\Permalinks', 'add_rewrites'));
    }
    /**
     * add_rewrites
     *
     * @param $content
     */
    public static function add_rewrites($content)
    {
        $var = explode('/themes/', get_stylesheet_directory());
        $theme_name = next($var);
        global $wp_rewrite;
        $new_non_wp_rules = array('style.css' => 'wp-content/themes/' . $theme_name . '/style.css', 'css/(.*)' => 'wp-content/themes/' . $theme_name . '/css/$1', 'js/(.*)' => 'wp-content/themes/' . $theme_name . '/js/$1', 'img/(.*)' => 'wp-content/themes/' . $theme_name . '/img/$1', 'fonts/(.*)' => 'wp-content/themes/' . $theme_name . '/fonts/$1', 'plugins/(.*)' => 'wp-content/plugins/$1');
        $wp_rewrite->non_wp_rules += $new_non_wp_rules;
    }
}
Permalinks::init();