mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-28 22:30:04 +00:00
Permalinks: Validate custom permalink structures.
Custom permalink structures require at least one valid structure tag, e.g. `%postname%`. If none is included, it would leave users with broken permalinks. Let's make sure this won't happen by validating the permalink structure. Adds unit tests. Props rockwell15 for initial patch. Fixes #35936. git-svn-id: https://develop.svn.wordpress.org/trunk@37747 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -4204,6 +4204,14 @@ function sanitize_option( $option, $value ) {
|
||||
$value = esc_url_raw( $value );
|
||||
$value = str_replace( 'http://', '', $value );
|
||||
}
|
||||
|
||||
if ( 'permalink_structure' === $option && '' !== $value && ! preg_match( '/%[^\/%]+%/', $value ) ) {
|
||||
$error = sprintf(
|
||||
/* translators: %s: Codex URL */
|
||||
__( 'A structure tag is required when using custom permalinks. <a href="%s">Learn more</a>' ),
|
||||
__( 'https://codex.wordpress.org/Using_Permalinks#Choosing_your_permalink_structure' )
|
||||
);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'default_role' :
|
||||
|
||||
Reference in New Issue
Block a user