Skip to content

wp-now: Support pretty permalinks without index.php#164

Merged
adamziel merged 1 commit intoWordPress:trunkfrom
eliot-akira:wp-now-support-pretty-permalinks
Mar 4, 2024
Merged

wp-now: Support pretty permalinks without index.php#164
adamziel merged 1 commit intoWordPress:trunkfrom
eliot-akira:wp-now-support-pretty-permalinks

Conversation

@eliot-akira
Copy link
Copy Markdown
Contributor

What?

Before

wp-now-support-pretty-permalinks--before

After

wp-now-support-pretty-permalinks--after

Why?

The admin screen at Settings -> Permalinks prepends index.php to all pretty permalinks if the function got_url_rewrite() returns false. (wp-admin/options-permalink.php)

There's a filter got_url_rewrite to override this behavior. (wp-admin/misc.php)

How?

Adds a one-line mu-plugin to set the filter to return true. This is done in downloadMuPlugins(), which is called during startWPNow().

Testing Instructions

  1. Check out the branch.
  2. Run npx nx preview wp-now start
  3. Visit http://localhost:8881/wp-admin/options-permalink.php
  4. Confirm that pretty permalinks do not have URL base index.php

@eliot-akira eliot-akira changed the title Support pretty permalinks without index.php wp-now: Support pretty permalinks without index.php Feb 25, 2024
Copy link
Copy Markdown
Collaborator

@adamziel adamziel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks lovely! CC @sejas

@eliot-akira
Copy link
Copy Markdown
Contributor Author

eliot-akira commented Feb 29, 2024

I noticed the package @wp-playground/remote creates a mu-plugin that adds the same filter got_url_rewrite.

/**
 * Supports URL rewriting to remove `index.php` from permalinks.
 */
add_filter('got_url_rewrite', '__return_true');

From: packages/playground/remote/src/lib/playground-mu-plugin/0-playground.php

Some (but not all?) of the other customizations in that mu-plugin seem possibly useful for wp-now. Maybe they can be copied over, or consolidated in the future as a shared/common mu-plugin for both environments (wp-now and in browser).

@adamziel adamziel added Enhancement New feature or request wp-now labels Mar 4, 2024
@adamziel
Copy link
Copy Markdown
Collaborator

adamziel commented Mar 4, 2024

cc @bgrgicak, this is relevant to the discussion in WordPress/wordpress-playground#1054

Some (but not all?) of the other customizations in that mu-plugin seem possibly useful for wp-now.

The following ones should be also useful in every Playground-based app:

  • Silence 32-bit integer warnings
  • The got_url_rewrite filter
  • Creating the fonts directory if missing
  • Configuring error logging
  • (potentially) display admin username/password

Making that mu-plugin modular and exporting it from the Playground repo in some form would be really useful.

@adamziel
Copy link
Copy Markdown
Collaborator

adamziel commented Mar 4, 2024

In the meantime, let me merge this PR. Good work @eliot-akira! 🎉

@adamziel
Copy link
Copy Markdown
Collaborator

adamziel commented Mar 4, 2024

@sejas would you be up for releasing a new version?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Enhancement New feature or request wp-now

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support pretty permalinks

2 participants