WordPress supports URL rewriting through the Rewrite API. It relies on underlying HTTP server mechanisms to get the job done.
It is not always possible for WordPress to enforce the Rewrite rules. For example, with Apache, when WordPress isn't allowed to create the .htaccess file.
The plugin I'm writing should take advantage of the Rewrite API, when it is available. Basically:
if (is_url_rewriting_available( ) ) {
Plan A
} else {
Plan B
}
But I can't find such function.
What I investigated so far:
- Nothing in the doc, in particular in https://codex.wordpress.org/Class_Reference/WP_Rewrite
- "Write" functions, such as
flush_rewrite_rules
, return nothing. So it can't be used to check the availability (eg.if (false == flush_rewrite_rules () )
). - In
wp-admin/options-permalink.php
, around line 130, the code checks URL rewriting requirements. However, this code doesn't seem to be reusable. Sure, I can copy/paste this code but...