Make WordPress Core


Ignore:
Timestamp:
06/19/2016 12:01:11 PM (8 years ago)
Author:
swissspidy
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/formatting.php

    r37698 r37747  
    42054205                $value = str_replace( 'http://', '', $value );
    42064206            }
     4207
     4208            if ( 'permalink_structure' === $option && '' !== $value && ! preg_match( '/%[^\/%]+%/', $value ) ) {
     4209                $error = sprintf(
     4210                    /* translators: %s: Codex URL */
     4211                    __( 'A structure tag is required when using custom permalinks. <a href="%s">Learn more</a>' ),
     4212                    __( 'https://codex.wordpress.org/Using_Permalinks#Choosing_your_permalink_structure' )
     4213                );
     4214            }
    42074215            break;
    42084216
Note: See TracChangeset for help on using the changeset viewer.