|
69 | 69 | get_current_screen()->set_help_sidebar( $help_sidebar_content ); |
70 | 70 | unset( $help_sidebar_content ); |
71 | 71 |
|
| 72 | +/** @global WP_Rewrite $wp_rewrite WordPress rewrite component. */ |
| 73 | +global $wp_rewrite; |
| 74 | + |
72 | 75 | $home_path = get_home_path(); |
73 | 76 | $iis7_permalinks = iis7_supports_permalinks(); |
74 | 77 | $permalink_structure = get_option( 'permalink_structure' ); |
|
94 | 97 |
|
95 | 98 | $category_base = get_option( 'category_base' ); |
96 | 99 | $tag_base = get_option( 'tag_base' ); |
| 100 | +$random_base = get_option( 'wp_random_base' ); |
| 101 | +$random_base = is_string( $random_base ) ? $random_base : ''; |
97 | 102 |
|
98 | 103 | $structure_updated = false; |
99 | 104 | $htaccess_update_required = false; |
|
144 | 149 |
|
145 | 150 | $wp_rewrite->set_tag_base( $tag_base ); |
146 | 151 | } |
| 152 | + |
| 153 | + if ( wp_is_random_content_redirect_enabled() && isset( $_POST['wp_random_base'] ) && is_string( $_POST['wp_random_base'] ) ) { |
| 154 | + $random_base = $_POST['wp_random_base']; |
| 155 | + |
| 156 | + if ( ! empty( $random_base ) ) { |
| 157 | + $random_base = $blog_prefix . preg_replace( '#/+#', '/', '/' . str_replace( '#', '', $random_base ) ); |
| 158 | + } |
| 159 | + |
| 160 | + $wp_rewrite->set_random_base( $random_base ); |
| 161 | + } |
147 | 162 | } |
148 | 163 |
|
149 | 164 | if ( $iis7_permalinks ) { |
|
236 | 251 | $permalink_structure = preg_replace( '|^/?blog|', '', $permalink_structure ); |
237 | 252 | $category_base = preg_replace( '|^/?blog|', '', $category_base ); |
238 | 253 | $tag_base = preg_replace( '|^/?blog|', '', $tag_base ); |
| 254 | + $random_base = preg_replace( '|^/?blog|', '', $random_base ) ?? ''; |
239 | 255 | } |
240 | 256 |
|
241 | 257 | $url_base = home_url( $blog_prefix . $index_php_prefix ); |
@@ -457,6 +473,29 @@ class="button button-secondary" |
457 | 473 | <?php endif; ?> |
458 | 474 | </td> |
459 | 475 | </tr> |
| 476 | + <?php if ( wp_is_random_content_redirect_enabled() ) : ?> |
| 477 | + <tr> |
| 478 | + <th> |
| 479 | + <label for="wp_random_base"> |
| 480 | + <?php _e( 'Random base' ); ?> |
| 481 | + </label> |
| 482 | + </th> |
| 483 | + <td> |
| 484 | + <?php if ( '' === $blog_prefix ) : ?> |
| 485 | + <input name="wp_random_base" id="wp_random_base" type="text" |
| 486 | + value="<?php echo esc_attr( $random_base ); ?>" class="regular-text code" |
| 487 | + /> |
| 488 | + <?php else : ?> |
| 489 | + <span class="code permalink-structure-has-blog-prefix"> |
| 490 | + <code class="no-break"><?php echo $blog_prefix; ?></code> |
| 491 | + <input name="wp_random_base" id="wp_random_base" type="text" |
| 492 | + value="<?php echo esc_attr( $random_base ); ?>" class="regular-text code" |
| 493 | + /> |
| 494 | + </span> |
| 495 | + <?php endif; ?> |
| 496 | + </td> |
| 497 | + </tr> |
| 498 | + <?php endif; ?> |
460 | 499 | <?php do_settings_fields( 'permalink', 'optional' ); ?> |
461 | 500 | </table> |
462 | 501 |
|
|
0 commit comments