Wrong WPML cornerstone/edit links

I’m having an issue on my site where the multilingual /cornerstone/edit/[id] links are not working, these links can be found at the Backend -> Pages -> Edit with Cornerstone and at the Frontend -> Admin bar -> Cornerstone -> Edit page. They redirect to /cornerstone/ where I can see a list of pages to the left. If I click one of those I noticed that the format is [locale]/cornerstone/edit/[id], these links do work. Also the big blue button on the page edit screen under the Cornerstone tab redirects to the wrong url. It seems like Cornerstone is ignoring the locale prefix.

It’s setup to be at the root of the Site home actually. There’s a fix coming out next week around sites that use a directory for their default language with WPML. Your fix fixes this issue if your Cornerstone pages load at all so that’s pretty great actually, but currently you’ll need to have the default language not be on it’s own directory till the fix. Let me know if this helps and have a great day.

Hi Charlie,

Thanks for the quick reply. Good to know where the bug is coming from. For now my quick fix is enough to let the client work with the site. I’ll await your update.

In case anyone else is having this issue, copy / paste the following code in you themes functions.php as a quick fix.

 /**
 * Fix wrong edit links
 */
function fix_wpml_cornerstone_edit_links()
{
  if ( is_user_logged_in() )
  {
    $locale = apply_filters( 'wpml_current_language', null );

    ?>
    <script>
      (function($)
      {
        var locale = '<?php echo $locale; ?>';

        $(function()
        {
          $( 'a[href*="/cornerstone/edit/"' ).each( function()
          {
            var $this = $( this ),
                href = $this.attr( 'href' );
            if ( href.indexOf( '/' + locale + '/' ) < 0 )
            {
              $this.attr( 'href', href.replace( '/cornerstone/edit/', '/' + locale + '/cornerstone/edit/' ) );
            }
          } );
        });
      })(jQuery);
    </script>
    <?php
  }
}

add_action( 'wp_head', 'fix_wpml_cornerstone_edit_links' );
add_action( 'admin_head', 'fix_wpml_cornerstone_edit_links' );

Hi Falise,

Glad that you shared the quick fix with others.

Thanks

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.