Forum Replies Created

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

    (@mbis)

    If the code still does not work, there are two possibilities – the code is inactive, or you removed the first exclamation mark instead of the last one. There were two exclamation marks in the second line – the first one should stay intact.

    If this does not help, please send me the screenshot with the fragment where the full snippet’s code was pasted.

    Plugin Author Maciej Bis

    (@mbis)

    Just in case, the only difference is in the end of second line – the exclamation mark needs to be removed:

    Before:
    ! empty( $uri_parts['endpoint_value'] )

    After:
    empty( $uri_parts['endpoint_value'] )
    Plugin Author Maciej Bis

    (@mbis)

    Hi @ericafontimedia,

    I think I made a small type in the code, could you try to use this version instead?

    function pm_force_404_filter_endpoint( $element_id, $uri_parts ) {
    if ( ! empty( $uri_parts['endpoint'] ) && $uri_parts['endpoint'] == 'filter' && empty( $uri_parts['endpoint_value'] ) ) {
    $element_id = '';
    }

    return $element_id;
    }
    add_filter( 'permalink_manager_detected_element_id', 'pm_force_404_filter_endpoint', 100, 2 );
    Plugin Author Maciej Bis

    (@mbis)

    Hi @ericafontimedia,

    The problem is caused by one of the Permalink Manager’s functions that parses the endpoints from the requested URL. Could you try to fix this issue by using the below code snippet?

    function pm_force_404_filter_endpoint( $element_id, $uri_parts ) {
    if ( ! empty( $uri_parts['endpoint'] ) && $uri_parts['endpoint'] == 'filter' && ! empty( $uri_parts['endpoint_value'] ) ) {
    $element_id = '';
    }

    return $element_id;
    }
    add_filter( 'permalink_manager_detected_element_id', 'pm_force_404_filter_endpoint', 100, 2 );

    Best regards,
    Maciej

    Plugin Author Maciej Bis

    (@mbis)

    Hi @thevisitorcounterplugin,

    I apologize for the inconvenience and thank you for reporting this. To fix this bug (and remove the empty entries from custom permalinks array), the returned array in get_all_uris() should be wrapped with array_filter() function:

    I will patch this in the next release, could you try to manually overwrite line #210

    return $permalink_manager_uris;

    in below file:
    https://plugins.trac.www.ads-software.com/browser/permalink-manager/trunk/includes/core/permalink-manager-uri-functions.php#L210

    with:

    return array_filter( $permalink_manager_uris );

    Best regards,
    Maciej

    Plugin Author Maciej Bis

    (@mbis)

    Hi @lykkemedia,

    I am afraid that this might be impossible, as the custom permalinks generated by Permalink Manager can only be detected if the plugin is active.

    In other words, Permalink Manager not only generate and save the custom permalinks but also includes a function that allows WordPress to recognize them. WordPress builtin permalink functions support only basic URL formats, so without the plugin activated, your custom permalinks would stop working.

    The only function that remains in effect after the plugin is deactivate is the “Regenerate/reset” tool if “Regenerate native slugs” mode is used. This is because it affects the original slugs used for native permalinks, rather than custom permalinks.

    Best regards,
    Maciej Bis

    Plugin Author Maciej Bis

    (@mbis)

    Hi @floadrmd,

    Please accept my apology for late response and inconvenience. According to the debug data, it seems like the language code is not properly parsed from the request URL. As of now, Permalink Manager is compatible only with WPML & Polylang plugins and no other language plugin is officially supported.

    Could you try to manually overwrite the extracted URI parts using below code snippet?

    function pm_remove_language_code( $uri_pats ) {
    // Check if 'en-us' exists in the URI
    if ( strpos( $uri_pats['uri'], 'en-us' ) !== false ) {
    // Replace 'en-us' with an empty string
    $uri_pats['uri'] = str_replace( 'en-us/', '', $uri_pats['uri'] );
    }

    return $uri_pats;
    }
    add_filter('permalink_manager_detect_uri', 'pm_remove_language_code');

    Best regards,
    Maciej

    Plugin Author Maciej Bis

    (@mbis)

    Hi Akhilesh,

    I do not think that RankMath could interfere with the trailing slashes settings.

    I have not checked the codebase of WP Rocket plugin recently, so there is a chance the addressed the issue with dynamic trailing slash redirect and PHP/script caching. If so, enabling “Add Trailing Slashes” and “Trailing Slash Redirect” in Permalink Manager settings should solve the problem.

    If not, you will need to use .htaccess redirect rule. If you do not have access to .htaccess file via FTP, you can use the .htaccess editor included with Rank Math to force the trailing slash redirect with redirect rule.

    Best regards,
    Maciej

    Plugin Author Maciej Bis

    (@mbis)

    Hi Akhilesh,

    In the default state, the plugin uses the built-in settings for the trailing slashes. Enabling “Add Trailing Slashes” should also activate the trailing slash redirect (if it is enabled in “Redirect settings” of my plugin), but it will work only if WP Rocket does not use the same cache container for both URL variants (with and without slash).

    Best regards,
    Maciej

    Plugin Author Maciej Bis

    (@mbis)

    Hi @abhagwani,

    Could you check if the issue persists when Permalink Manager is deactivated? The HTML output of your website indicates that WP Rocket plugin is enabled.

    The problem you are experiencing is pretty common for some cache plugins. Please check out the below article for more details:
    https://permalinkmanager.pro/docs/plugin-settings/how-to-add-remove-trailing-slashes/#7-trailing-slashes-and-cache-plugins

    To address this issue you will need to use a patch provided by WP Rocket:
    https://docs.wp-rocket.me/article/131-redirection-to-enforce-trailing-slash-on-urls

    Best regards,
    Maciej

    Plugin Author Maciej Bis

    (@mbis)

    Hi Mikko,

    To address this issue and prevent the fatal error with older versions of TSF, in the next version of plugin I will add more strict check in includes\core\permalink-manager-helper-functions.php file:

    // B. The SEO Framework
    else if ( function_exists( 'the_seo_framework' ) || function_exists( 'tsf' ) ) {
    if ( class_exists( 'The_SEO_Framework\Data\Plugin\Post' ) ) {
    $primary_term = The_SEO_Framework\Data\Plugin\Post::get_primary_term( $post_id, $taxonomy );
    } elseif ( function_exists( 'the_seo_framework' ) && method_exists( the_seo_framework(), 'get_primary_term' ) ) {
    $primary_term = the_seo_framework()->get_primary_term( $post_id, $taxonomy );
    }
    }
    • This reply was modified 1 month, 1 week ago by Maciej Bis. Reason: Tab indent fix
    • This reply was modified 1 month, 1 week ago by Maciej Bis. Reason: Better solution
    Plugin Author Maciej Bis

    (@mbis)

    If the problem occurs only in the admin dashboard, it might be caused by the fact that all Permalink Manager code (including functions responsible for URLs saving) is automatically disabled in order to prevent compatibility issues with Elementor editor. Unfortunately, there is no way to get around it or make it work without breaking the integration with third-party plugins ??

    Therefore, if a post is created directly from Elementor interface, its custom permalink will not be generated and it will still use the default URL.

    If you mean the front-end form where visitors can submit some content, you can theoretically us PHP snippet to force the custom permalink to be generated when some specific action hook is called:

    https://permalinkmanager.pro/docs/filters-hooks/custom-permalink-functions/#2-how-to-save-the-custom-permalink

    // A1. Get the default URI
    $new_uri = Permalink_Manager_URI_Functions_Post::get_default_post_uri( $post );

    // A2. Save the URI in DB
    Permalink_Manager_URI_Functions::save_single_uri( $post->ID, $new_uri, false, true );

    Plugin Author Maciej Bis

    (@mbis)

    Since I have not heard from you, I assume that you have figured out how to solve this problem. If not, please feel free to reopen this topic and provide further information.

    Plugin Author Maciej Bis

    (@mbis)

    Following up on my previous message. As I have not heard back from you, I am closing this thread. Feel free to reopen if you have further information.

    Plugin Author Maciej Bis

    (@mbis)

    Hi @thebigbanik,

    I apologize for the inconvenience. To be honest, I have never tested the plugin in such scenario, but I guess that the problem here is that all the custom permalinks are stored serialized in $permalink_manager_uris global. I am not exactly certain how exactly you add the new posts, but apparently the update_option() function that saves custom permalink behaves like it is called asynchronously.

    Theoretically, if you create a first post, Permalink Manager will append the new permalink to the end of custom permalinks array inside the global variable and finally save the whole $permalink_manager_uris in the database. The problem may appear, if you publish another post before the $permalink_manager_uris global with the custom permalink for first post is saved to the database. Then, the array with custom permalink for earlier post can be overwritten with the array including the newer post’s but without the custom permalink for earlier post.

    • This reply was modified 2 months ago by Maciej Bis.
Viewing 15 replies - 16 through 30 (of 1,418 total)