• Resolved noamkr

    (@noamkr)


    1. Our site is in English (main language) and Hebrew. English pages,posts and other custom post types on our website, are translated to Hebrew using the WPML Translation Editor. However, we get ugly permalinks for these translated pages, posts etc.

    2. We use the Permalink Manager plugin + WPML plugin.

    3. On the page or post itself (in front end), the displayed permalink is nice, but in Edit mode, the permalink you see is ugly. Also, when you share the page or post using an email share button, it pasts the ugly permalink to the email.

    For example:

    The nice permalink in front end for a Hebrew page: krollconsultants.com/he/????????/??????-????/

    The ugly permalink for the same Hebrew page: https://krollconsultants.com/he/%D7%90%D7%95%D7%93%D7%95%D7%AA%D7%99%D7%A0%D7%95/%D7%94%D7%94%D7%A0%D7%94%D7%92%D7%94-%D7%A9%D7%9C%D7%A0%D7%95/

    5. Our .htaccess file contains the rule: RewriteRule . /index.php [L]

    2. Our database is UTF-8 encoded.

    How do we solve this issue?

Viewing 15 replies - 1 through 15 (of 16 total)
  • Plugin Author Maciej Bis

    (@mbis)

    Hi,

    this issue is not caused by my plugin, the permalinks are encoded natively by WordPress to make sure that they can be read by older browser versions, see this short article:
    https://xahlee.info/js/url_encoding_unicode.html

    I guess that your browser automatically detects the encoded URIs (krollconsultants.com/he/%D7%90%D7%95%D7%93%D7%95%D7%AA%D7%99%D7%A0%D7%95/%D7%94%D7%94%D7%A0%D7%94%D7%92%D7%94-%D7%A9%D7%9C%D7%A0%D7%95/) and displays them as (krollconsultants.com/he/????????/??????-????/) when it comes to the regular links. Unfortunately this does not apply to the permalinks parsed by “Email share button” and displayed inside the email text.

    There are two fix possibilities:

    • you can directly filter the permalink used by the “email share button” plugin (most recommended)
    • you can filter all the permalinks and force them to be always decoded (not recommended due to old browsers compatibility)

    To decode all the peramlinks, you will need to to paste this snippet into your theme’s functions.php file:

    function decode_permalinks($link) {
    	return urldecode($link);
    }
    add_filter( '_get_page_link', 'decode_permalinks', 999);
    add_filter( 'page_link', 'decode_permalinks', 999);
    add_filter( 'post_link', 'decode_permalinks', 999);
    add_filter( 'post_type_link', 'decode_permalinks', 999);
    
    function decode_uris_array($uris) {
    	if(!is_admin()) {
    		foreach ($uris as $key => $value) {
    			if(preg_match('/[^\x20-\x7f]/', $value)) {
    				$uris[$key] = implode('/', array_map('rawurlencode', explode('/', $value)));
    			}
    		}
    	}
    	return $uris;
    }
    add_filter('permalink-manager-uris', 'decode_uris_array', 999);

    Best Regards,
    Maciej

    • This reply was modified 7 years, 8 months ago by Maciej Bis.
    • This reply was modified 7 years, 8 months ago by Maciej Bis.
    Thread Starter noamkr

    (@noamkr)

    Dear Maciej,

    Thank you so much for your reply.

    1. We raised this issue with WPML and this is what their support wrote us:

    Thanks for sending credentials. I made a copy of your site using the Duplicator plugin so that I could further troubleshoot. When I deactivate the Permalink Manager plugin, the URL shows correctly on the page editor. It looks like it is most likely a compatibility issue, as I don’t see Permalinks Manager on our list of compatible plugins: https://wpml.org/documentation/plugins-compatibility/

    2. I must say this is true. Before our developers decided to add your plugin, the permalinks in HE displayed perfectly. Only after activating your plugin, Hebrew permalinks are skewed.

    3. When I asked our developers, who are struggling with the “ugly” Hebrew permalinks, if we really need your plugin, considering the fact that is skewed our Hebrew permalinks, they said:
    “Due to the complex nature of the permalinks, if you want to retain the custom category pages in the Insights section, then we unfortunately need the Permalink Manager plugin, although it is not WPML compatible”.

    What do you suggest?

    Thanks,

    Noam

    Plugin Author Maciej Bis

    (@mbis)

    Hi Noam,

    actually, you are facing two problems:

    1. When you disable my plugin, the ugly permalinks are not fixed in front-end (I mean the “share” links).

    It is only your browser that decodes the ugly permalink to pretty permalink ONLY in your browser’s URL bar, everywhere else the permalinks are still ugly (you can check it in your HTML output code, in eg. internal links, meta tags, etc.). That is why the page’s links are “ugly” when you share it and this issue is not caused by my plugin.

    To prove it, just disable my plugin and check how the permalink looks like when “share” function is used. As I mentioned in my previous reply, the URIs are encoded to provide support for older-browsers: https://xahlee.info/js/url_encoding_unicode.html The only problem here is that the “share” links are not decoded.

    2. The second problem (ugly permalinks in “Edit” area) is not caused by WPML incompability – my plugin is compatible and tested with WPML, but I just did not apply for their “compability plugin program” yet. The issue you encounter occurs due to the fact that my plugin did not decode URIs before in get_sample_permalink_html(), just like it is done in native WordPress core functions.

    I have just fixed this bug (point 2.) and all you need to do is to remove old instance of my plugin & reinstall a fresh copy.

    Best Regards,
    Maciej

    • This reply was modified 7 years, 7 months ago by Maciej Bis.
    • This reply was modified 7 years, 7 months ago by Maciej Bis.
    Thread Starter noamkr

    (@noamkr)

    Hello Maciej,

    Thank you so much for your reply.

    Should we deactivate and remove your plugin and then upload from Dashboard>>Plugins>> Add new?

    And another thing: How do we keep the current settings? Is it possible?

    Thanks again for all your help!

    Noam

    Plugin Author Maciej Bis

    (@mbis)

    Hi again Noam,

    yes, exactly. The saved settings will not be affected, no database-data-related action is triggered during plugin deactivation and activation.

    I added a new functionality (this should help the first issue), now you can force decoded URIs in the plugin’s settings (it is not recommended due to old-browsers compatibility):

    Best Regards,
    Maciej

    Thread Starter noamkr

    (@noamkr)

    Dear Maciej,

    Thank you so much for all your help and the excellent and outstanding support.

    It is greatly appreciated!

    Best Regards,

    Noam

    Plugin Author Maciej Bis

    (@mbis)

    Hi Noam,

    you are welcome ??

    if you have any time available, I would be grateful, if you could review my plugin here: https://www.ads-software.com/support/plugin/permalink-manager/reviews/#new-post

    Best Regards,
    Maciej

    Thread Starter noamkr

    (@noamkr)

    Just added my review with great pleasure!

    Thread Starter noamkr

    (@noamkr)

    Dear Maciej,

    One more issue if I may:

    The only thing that is still skewed with the Hebrew permalinks is: When you copy a permalink from the address bar of a Hebrew webpage and paste it to an email or a word document, it displays the “ugly permalink”.

    Why is that? What can be done?

    Thanks,

    Noam

    • This reply was modified 7 years, 7 months ago by noamkr.
    Plugin Author Maciej Bis

    (@mbis)

    Hi Noam,

    I am afraid that nothing can be done, when you click on or paste into address bar the permalink with non-ASCII characters, the browser encodes it, but displays it correctly (in decoded format).

    I do not think that it is possible to change the browser behavior, all non-ASCII characters in URLs are URI-encoded by browser for security reasons (eg. to avoid SQL injection).

    More info:
    https://stackoverflow.com/a/30012739
    https://www.raymond.cc/blog/decoding-percent-with-numbers-encoding-in-urls/

    Best Regards,
    Maciej

    Thread Starter noamkr

    (@noamkr)

    Dear Maciej,

    Thank you so much for your answer.

    Just to make sure I understand: It does NOT happen with English pages on our website, where the entire permalink is in English.

    It happens only is Hebrew pages, where part of the permalink contains Hebrew wording.

    So it seems that it is all about Hebrew characters used in the permalink.

    Why is that? Can it be solved?

    Thanks,

    Noam

    Plugin Author Maciej Bis

    (@mbis)

    Hi Noam,

    it does not happen with English pages, because all latin characters are ASCII-valid, that is why they are not encoded by browsers. Hebrew letters are not ASCII-valid and that is why they are encoded.

    Here is the full list of ASCII letters:
    https://www.kerryr.net/pioneers/ascii2.htm

    Rest of them (including Hebrew letters, excluding special characters: “:”, “/”, “\” and “?”) will be encoded by browser in address bar and there is nothing that can be done about it. I already explained it, all non-standard letters are encoded in address bar due to security reasons.

    Maybe this topic will help you, but for sure this is not related to my plugin:
    https://stackoverflow.com/questions/18176661/copying-a-utf-8-url-from-browsers-address-bar-gives-only-the-ugly-encoded-one

    Best Regards,
    Maciej

    Thread Starter noamkr

    (@noamkr)

    Hi Maciej,

    Thanks again for all your help!! Much appreciated.

    I’ll have a word with WPML support, to see if they have some built in solution for non-ASCII characters such as Hebrew.

    Noam

    Thread Starter noamkr

    (@noamkr)

    Dea Maciej,

    Noam here again. Hope you are well.

    Question please:

    We are still having issues with our Hebrew permalinks. Currently, all Hebrew permalinks relating to Visual Composer items display a 404 page.

    WPML and our developers are trying to figure out why.

    Can you help?

    Thanks,

    Noam

    Plugin Author Maciej Bis

    (@mbis)

    Hi Noam,

    yes, but I need access to your WordPress Admin panel. If it is possible please send me the credentials to contact /at/ maciejbis.net, if not please send me detailed problem explanation with screenshots.

    Regards,
    Maciej

Viewing 15 replies - 1 through 15 (of 16 total)
  • The topic ‘Our site is in English (main language) and Hebrew. Hebrew permalinks are “ugly”’ is closed to new replies.