Making a note of something I noticed in the documentation.
The example for the blueprint step writeFile shows how to create a mu-plugin that enables pretty permalinks.
{
"step": "writeFile",
"path": "/wordpress/wp-content/mu-plugins/rewrite.php",
"data": "<?php /* Use pretty permalinks */ add_action( 'after_setup_theme', function() { global $wp_rewrite; $wp_rewrite->set_permalink_structure('/%postname%/'); $wp_rewrite->flush_rules(); } );"
}
Expanding the code:
<?php
/* Use pretty permalinks */
add_action( 'after_setup_theme', function() {
global $wp_rewrite;
$wp_rewrite->set_permalink_structure('/%postname%/');
$wp_rewrite->flush_rules();
} );
The after_setup_theme action is called on every page load, so it's not the best way to enable pretty permalinks and flush rewrite rules (which is considered an "expensive" operation).
A better way is to do it once using the runPHP step.
{
"step": "runPHP",
"code": "<?php include '/var/www/html/wp-load.php'; global $wp_rewrite; $wp_rewrite->set_permalink_structure('/%postname%/'); $wp_rewrite->flush_rules();"
},
There might be a simpler way to achieve it. This PR seems to have made pretty permalinks the default.
update_option('permalink_structure', '/%year%/%monthnum%/%day%/%postname%/');
This method does not flush rewrite rules. Maybe it's not needed because it's always run on a freshly created site.
Anyway, if the default is to use pretty permalinks, then the above mentioned example in the docs is unnecessary and could be removed altogether.
Making a note of something I noticed in the documentation.
The example for the blueprint step
writeFileshows how to create amu-pluginthat enables pretty permalinks.{ "step": "writeFile", "path": "/wordpress/wp-content/mu-plugins/rewrite.php", "data": "<?php /* Use pretty permalinks */ add_action( 'after_setup_theme', function() { global $wp_rewrite; $wp_rewrite->set_permalink_structure('/%postname%/'); $wp_rewrite->flush_rules(); } );" }Expanding the code:
The
after_setup_themeaction is called on every page load, so it's not the best way to enable pretty permalinks and flush rewrite rules (which is considered an "expensive" operation).A better way is to do it once using the
runPHPstep.{ "step": "runPHP", "code": "<?php include '/var/www/html/wp-load.php'; global $wp_rewrite; $wp_rewrite->set_permalink_structure('/%postname%/'); $wp_rewrite->flush_rules();" },There might be a simpler way to achieve it. This PR seems to have made pretty permalinks the default.
This method does not flush rewrite rules. Maybe it's not needed because it's always run on a freshly created site.
Anyway, if the default is to use pretty permalinks, then the above mentioned example in the docs is unnecessary and could be removed altogether.