$query ) { add_rewrite_rule( $regex, $query, 'top' ); } /* * Check to see if the rewrite rule has changed, if so, update the option * and flush the rewrite rules. * Save the rewrite rule to an option so we have something to compare against later. * We don't need to worry about the root rewrite rule above as it is always the same. */ if ( get_option( 'gp_rewrite_rule' ) != $rewrite_rules ) { update_option( 'gp_rewrite_rule', $rewrite_rules ); flush_rewrite_rules( false ); } } /** * Query vars for GP rewrite rules * * @since 1.0.0 */ function gp_query_vars( $query_vars ) { $query_vars[] = 'gp_route'; return $query_vars; } /** * GP run route * * @since 1.0.0 */ function gp_run_route() { gp_populate_notices(); if ( is_glotpress() ) { GP::$router->route(); } } /** * Determine if the page requested is handled by GlotPress. * * @since 1.0.0 * * @return bool Whether the request is handled by GlotPress. */ function is_glotpress() { global $wp; if ( ! is_admin() && GP_ROUTING && $wp instanceof WP && null !== $wp->query_vars && array_key_exists( 'gp_route', $wp->query_vars ) ) { return true; } return false; } /** * Sets `WP_Query->is_home` to false during GlotPress requests. * * @since 1.0.0 * * @param WP_Query $query The WP_Query instance. */ function gp_set_is_home_false( $query ) { if ( is_glotpress() && $query->is_home() && $query->is_main_query() ) { $query->is_home = false; } }