WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru
функция не описана

WPSEO_Rewrite::category_rewrite_rules() public Yoast 1.0

This function taken and only slightly adapted from WP No Category Base plugin by Saurabh Gupta.

Ищем WP-разработчика! Фулл-тайм, удаленка, хорошая зарплата, соц. пакет. Подробности.
Компания Boosta.

{} Это метод класса: WPSEO_Rewrite{}

Хуков нет.

Возвращает

Массив.

Использование

$WPSEO_Rewrite = new WPSEO_Rewrite();
$WPSEO_Rewrite->category_rewrite_rules();

Код WPSEO_Rewrite::category_rewrite_rules() Yoast 17.4

public function category_rewrite_rules() {
	global $wp_rewrite;

	$category_rewrite = [];

	$taxonomy            = get_taxonomy( 'category' );
	$permalink_structure = get_option( 'permalink_structure' );

	$blog_prefix = '';
	if ( is_multisite() && ! is_subdomain_install() && is_main_site() && strpos( $permalink_structure, '/blog/' ) === 0 ) {
		$blog_prefix = 'blog/';
	}

	$categories = get_categories( [ 'hide_empty' => false ] );
	if ( is_array( $categories ) && $categories !== [] ) {
		foreach ( $categories as $category ) {
			$category_nicename = $category->slug;
			if ( $category->parent === $category->cat_ID ) {
				// Recursive recursion.
				$category->parent = 0;
			}
			elseif ( $taxonomy->rewrite['hierarchical'] !== false && $category->parent !== 0 ) {
					$parents = get_category_parents( $category->parent, false, '/', true );
				if ( ! is_wp_error( $parents ) ) {
					$category_nicename = $parents . $category_nicename;
				}
				unset( $parents );
			}

			$category_rewrite = $this->add_category_rewrites( $category_rewrite, $category_nicename, $blog_prefix, $wp_rewrite->pagination_base );

			// Adds rules for the uppercase encoded URIs.
			$category_nicename_filtered = $this->convert_encoded_to_upper( $category_nicename );

			if ( $category_nicename_filtered !== $category_nicename ) {
				$category_rewrite = $this->add_category_rewrites( $category_rewrite, $category_nicename_filtered, $blog_prefix, $wp_rewrite->pagination_base );
			}
		}
		unset( $categories, $category, $category_nicename, $category_nicename_filtered );
	}

	// Redirect support from Old Category Base.
	$old_base                            = $wp_rewrite->get_category_permastruct();
	$old_base                            = str_replace( '%category%', '(.+)', $old_base );
	$old_base                            = trim( $old_base, '/' );
	$category_rewrite[ $old_base . '$' ] = 'index.php?wpseo_category_redirect=$matches[1]';

	return $category_rewrite;
}