Forum Replies Created

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter rachelbronstein

    (@rachelbronstein)

    Following up here: there were a lot of other PHP errors in this plugin, especially after upgrading to PHP 7.2, so we have chosen a different provider.

    I’ve run into this same annoyance as well and after too many times clicking a link and ending up in the wrong environment, I wrote a filter to replace the stored link with the current home_url() + the desired path. I use the WP_HOME and WP_SITEURL constants in wp-config.php (which is gitignored) so home_url() is always pointing to the right place.

    
    add_filter('wp_nav_menu_objects', function ($menu_items) {
        foreach ($menu_items as $i => $menu_item) {
            $item_path = parse_url($menu_item->url, PHP_URL_PATH);
            $menu_item->url = home_url() . $item_path;
            $menu_items[$i] = $menu_item;
        }
        return $menu_items;
    });
    
Viewing 2 replies - 1 through 2 (of 2 total)