• Resolved Rasso Hilber

    (@nonverbla)


    Hi there – thank you for this amazing plugin!

    I just noticed that some of my posts were missing from the static export. Turns out it was posts that had url-encoded values as their post_name, for example this: “bedo%cc%88” (wich is, after urldecode, equivalent to “bedö”. Something in simply static is preventing these posts from being exportet.

    As a hotfix, I’ve created this little WP-CLI script that “prepares” all my post_name values – but of course, these will lead to 404s (I’m archiving a site that was existing in it’s dynamic form for a long time). Not ideal but oh well. Here’s the script:

    /**
    * Sanitize permalinks so that simply-static doesn't miss them in it's exports
    * Usage: wp sanitize-permalinks
    */
    if (defined('WP_CLI') && WP_CLI) {
    WP_CLI::add_command('sanitize-permalinks', function() {
    $post_types = array_values([
    'page',
    ...get_post_types(['public' => true, '_builtin' => false])
    ]);
    $posts = get_posts([
    'post_type' => $post_types,
    'post_status' => 'any',
    'posts_per_page' => -1,
    ]);

    foreach ($posts as $post) {
    $original = $post->post_name;
    $sanitized = sanitize_title(urldecode($original));
    if ($original === $sanitized) continue;

    wp_update_post([
    'ID' => $post->ID,
    'post_name' => $sanitized
    ]);

    WP_CLI::success("Sanitized post_name for '$post->post_title'. Before: $original, After: $sanitized");
    }
    });
    }
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author patrickposner

    (@patrickposner)

    @nonverbla thanks for the report!

    I worked on a patch for this now and it will be included in the next update! 🙂

    Thread Starter Rasso Hilber

    (@nonverbla)

    Thank you @patrickposner , looking forward to the next release then 🙂

    EDIT: Ah, just saw that a fix for this is included in 3.5.5 – Will try that out, thank you!!

    Thread Starter Rasso Hilber

    (@nonverbla)

    Hmm – just tested this: It doesn’t seem to be fixed. How you can test this:

    • Update one of your posts: wp post update 210 --post_name=bedo%cc%88
    • Run the simply static export
    • Observe that the post is not in the exported list of posts

    If you point me to the general area in the code where you implemented your fix, I could take a look 🙂

Viewing 3 replies - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.