d> 1 年之前 16793 058f31828c first commit 1 年之前 16795 058f31828c first commit 1 年之前 16797 058f31828c first commit 1 年之前 16800 058f31828c first commit 1 年之前 16802 058f31828c first commit 1 年之前 16803 058f31828c first commit 1 年之前 16805 058f31828c first commit 1 年之前 16807 058f31828c first commit 1 年之前 16810 058f31828c first commit 1 年之前 16812 058f31828c first commit 1 年之前 16814 058f31828c first commit 1 年之前 16817 058f31828c first commit 1 年之前 16819 058f31828c first commit 1 年之前 16821 058f31828c first commit 1 年之前 16824 058f31828c first commit 1 年之前 16831 058f31828c first commit 1 年之前 16832 058f31828c first commit 1 年之前 16843 058f31828c first commit 1 年之前 16844 058f31828c first commit 1 年之前 16850 058f31828c first commit 1 年之前 16856 058f31828c first commit 1 年之前 16862 058f31828c first commit 1 年之前 16868 058f31828c first commit 1 年之前 16869 058f31828c first commit 1 年之前 16871 058f31828c first commit 1 年之前 16874 058f31828c first commit 1 年之前 16876 058f31828c first commit 1 年之前 16877 058f31828c first commit 1 年之前 16879 058f31828c first commit 1 年之前 16887 058f31828c first commit 1 年之前 16889 058f31828c first commit 1 年之前 16892 058f31828c first commit 1 年之前 16896 058f31828c first commit 1 年之前 16898 058f31828c first commit 1 年之前 16901 058f31828c first commit 1 年之前 16903 058f31828c first commit 1 年之前 16911 058f31828c first commit 1 年之前 16917 058f31828c first commit 1 年之前 16918 058f31828c first commit 1 年之前 16922 058f31828c first commit 1 年之前 16924 058f31828c first commit 1 年之前 16926 058f31828c first commit 1 年之前 16927 058f31828c first commit 1 年之前 16928 058f31828c first commit 1 年之前 16929 058f31828c first commit 1 年之前 16932 058f31828c first commit 1 年之前 16934 058f31828c first commit 1 年之前 16941 058f31828c first commit 1 年之前 16942 058f31828c first commit 1 年之前 16944 058f31828c first commit 1 年之前 16947 058f31828c first commit 1 年之前 16949 058f31828c first commit 1 年之前 16951 058f31828c first commit 1 年之前 16952 058f31828c first commit 1 年之前 16962 058f31828c first commit 1 年之前 16964 058f31828c first commit 1 年之前 16967 058f31828c first commit 1 年之前 16969 058f31828c first commit 1 年之前 16971 058f31828c first commit 1 年之前 16974 058f31828c first commit 1 年之前 16976 058f31828c first commit 1 年之前 16978 058f31828c first commit 1 年之前 16981 058f31828c first commit 1 年之前 16983 058f31828c first commit 1 年之前 16984 058f31828c first commit 1 年之前 16986 058f31828c first commit 1 年之前 16996 058f31828c first commit 1 年之前 17008 058f31828c first commit 1 年之前 17009 058f31828c first commit 1 年之前 17020 058f31828c first commit 1 年之前 17021 058f31828c first commit 1 年之前 17022 058f31828c first commit 1 年之前 17024 058f31828c first commit 1 年之前 17034 058f31828c first commit 1 年之前 17037 058f31828c first commit 1 年之前 17039 058f31828c first commit 1 年之前 17040 058f31828c first commit 1 年之前 17041 058f31828c first commit 1 年之前 17042 058f31828c first commit 1 年之前 174 058f31828c first commit 1 年之前 175 058f31828c first commit 1 年之前 2187 058f31828c first commit 1 年之前 2224 058f31828c first commit 1 年之前 2328 058f31828c first commit 1 年之前 2336 058f31828c first commit 1 年之前 2337 058f31828c first commit 1 年之前 2579 058f31828c first commit 1 年之前 2600 058f31828c first commit 1 年之前 2600_fsm 058f31828c first commit 1 年之前 2600_vm 058f31828c first commit 1 年之前 2601 058f31828c first commit 1 年之前 2601_fsm 058f31828c first commit 1 年之前 2601_vm 058f31828c first commit 1 年之前 2602 058f31828c first commit 1 年之前 2602_fsm 058f31828c first commit 1 年之前 2602_vm 058f31828c first commit 1 年之前 2603 058f31828c first commit 1 年之前 2603_fsm 058f31828c first commit 1 年之前 2603_vm 058f31828c first commit 1 年之前 2604 058f31828c first commit 1 年之前 2605 058f31828c first commit 1 年之前 2605_fsm 058f31828c first commit 1 年之前 2605_vm 058f31828c first commit 1 年之前 2606 058f31828c first commit 1 年之前 2606_fsm 058f31828c first commit 1 年之前 2606_vm 058f31828c first commit 1 年之前 2607 058f31828c first commit 1 年之前 2607_fsm 058f31828c first commit 1 年之前 2607_vm 058f31828c first commit 1 年之前 2608 058f31828c first commit 1 年之前 2608_fsm 058f31828c first commit 1 年之前 2608_vm 058f31828c first commit 1 年之前 2609 058f31828c first commit 1 年之前 2609_fsm 058f31828c first commit 1 年之前 2609_vm 058f31828c first commit 1 年之前 2610 058f31828c first commit 1 年之前 2610_fsm 058f31828c first commit 1 年之前 2610_vm 058f31828c first commit 1 年之前 2611 058f31828c first commit 1 年之前 2612 058f31828c first commit 1 年之前 2612_fsm 058f31828c first commit 1 年之前 2612_vm 058f31828c first commit 1 年之前 2613 058f31828c first commit 1 年之前 2615 058f31828c first commit 1 年之前 2615_fsm 058f31828c first commit 1 年之前 2615_vm 058f31828c first commit 1 年之前 2616 058f31828c first commit 1 年之前 2616_fsm 058f31828c first commit 1 年之前 2616_vm 058f31828c first commit 1 年之前 2617 058f31828c first commit 1 年之前 2617_fsm 058f31828c first commit 1 年之前 2617_vm 058f31828c first commit 1 年之前 2618 058f31828c first commit 1 年之前 2618_fsm 058f31828c first commit 1 年之前 2618_vm 058f31828c first commit 1 年之前 2619 058f31828c first commit 1 年之前 2619_fsm 058f31828c first commit 1 年之前 2619_vm 058f31828c first commit 1 年之前 2620 058f31828c first commit 1 年之前 2620_fsm 058f31828c first commit 1 年之前 2650 058f31828c first commit 1 年之前 2651 058f31828c first commit 1 年之前 2652 058f31828c first commit 1 年之前 2653 058f31828c first commit 1 年之前 2654 058f31828c first commit 1 年之前 2655 058f31828c first commit 1 年之前 2656 058f31828c first commit 1 年之前 2657 058f31828c first commit 1 年之前 2658 058f31828c first commit 1 年之前 2659 058f31828c first commit 1 年之前 2660 058f31828c first commit 1 年之前 2661 058f31828c first commit 1 年之前 2662 058f31828c first commit 1 年之前 2663 058f31828c first commit 1 年之前 2664 058f31828c first commit 1 年之前 2665 058f31828c first commit 1 年之前 2666 058f31828c first commit 1 年之前 2667 058f31828c first commit 1 年之前 2668 058f31828c first commit 1 年之前 2669 058f31828c first commit 1 年之前 2670 058f31828c first commit 1 年之前 2673 058f31828c first commit 1 年之前 2674 058f31828c first commit 1 年之前 2675 058f31828c first commit 1 年之前 2678 058f31828c first commit 1 年之前 2679 058f31828c first commit 1 年之前 2680 058f31828c first commit 1 年之前 2681 058f31828c first commit 1 年之前 2682 058f31828c first commit 1 年之前 2683 058f31828c first commit 1 年之前 2684 058f31828c first commit 1 年之前 2685 058f31828c first commit 1 年之前 2686 058f31828c first commit 1 年之前 2687 058f31828c first commit 1 年之前 2688 058f31828c first commit 1 年之前 2689 058f31828c first commit 1 年之前 2690 058f31828c first commit 1 年之前 2691 058f31828c first commit 1 年之前 2692 058f31828c first commit 1 年之前 2693 058f31828c first commit 1 年之前 2696 058f31828c first commit 1 年之前 2699 058f31828c first commit 1 年之前 2701 058f31828c first commit 1 年之前 2702 058f31828c first commit 1 年之前 2703 058f31828c first commit 1 年之前 2704 058f31828c first commit 1 年之前 2753 058f31828c first commit 1 年之前 2753_fsm 058f31828c first commit 1 年之前 2753_vm 058f31828c first commit 1 年之前 2754 058f31828c first commit 1 年之前 2755 058f31828c first commit 1 年之前 2756 058f31828c first commit 1 年之前 2757 058f31828c first commit 1 年之前 2830 058f31828c first commit 1 年之前 2831 058f31828c first commit 1 年之前 2832 058f31828c first commit 1 年之前 2833 058f31828c first commit 1 年之前 2834 058f31828c first commit 1 年之前 2835 058f31828c first commit 1 年之前 2836 058f31828c first commit 1 年之前 2837 058f31828c first commit 1 年之前 2838 058f31828c first commit 1 年之前 2838_fsm 058f31828c first commit 1 年之前 2838_vm 058f31828c first commit 1 年之前 2839 058f31828c first commit 1 年之前 2840 058f31828c first commit 1 年之前 2840_fsm 058f31828c first commit 1 年之前 2840_vm 058f31828c first commit 1 年之前 2841 058f31828c first commit 1 年之前 2995 058f31828c first commit 1 年之前 2996 058f31828c first commit 1 年之前 3079 058f31828c first commit 1 年之前 3079_fsm 058f31828c first commit 1 年之前 3079_vm 058f31828c first commit 1 年之前 3080 058f31828c first commit 1 年之前 3081 058f31828c first commit 1 年之前 3085 058f31828c first commit 1 年之前 3118 058f31828c first commit 1 年之前 3119 058f31828c first commit 1 年之前 3164 058f31828c first commit 1 年之前 3256 058f31828c first commit 1 年之前 3257 058f31828c first commit 1 年之前 3258 058f31828c first commit 1 年之前 3350 058f31828c first commit 1 年之前 3351 058f31828c first commit 1 年之前 3379 058f31828c first commit 1 年之前 3380 058f31828c first commit 1 年之前 3381 058f31828c first commit 1 年之前 3394 058f31828c first commit 1 年之前 3394_fsm 058f31828c first commit 1 年之前 3394_vm 058f31828c first commit 1 年之前 3395 058f31828c first commit 1 年之前 3429 058f31828c first commit 1 年之前 3430 058f31828c first commit 1 年之前 3431 058f31828c first commit 1 年之前 3433 058f31828c first commit 1 年之前 3439 058f31828c first commit 1 年之前 3440 058f31828c first commit 1 年之前 3455 058f31828c first commit 1 年之前 3456 058f31828c first commit 1 年之前 3456_fsm 058f31828c first commit 1 年之前 3456_vm 058f31828c first commit 1 年之前 3466 058f31828c first commit 1 年之前 3467 058f31828c first commit 1 年之前 3468 058f31828c first commit 1 年之前 3501 058f31828c first commit 1 年之前 3502 058f31828c first commit 1 年之前 3503 058f31828c first commit 1 年之前 3534 058f31828c first commit 1 年之前 3541 058f31828c first commit 1 年之前 3541_fsm 058f31828c first commit 1 年之前 3541_vm 058f31828c first commit 1 年之前 3542 058f31828c first commit 1 年之前 3574 058f31828c first commit 1 年之前 3575 058f31828c first commit 1 年之前 3576 058f31828c first commit 1 年之前 3596 058f31828c first commit 1 年之前 3597 058f31828c first commit 1 年之前 3598 058f31828c first commit 1 年之前 3599 058f31828c first commit 1 年之前 3600 058f31828c first commit 1 年之前 3600_fsm 058f31828c first commit 1 年之前 3600_vm 058f31828c first commit 1 年之前 3601 058f31828c first commit 1 年之前 3601_fsm 058f31828c first commit 1 年之前 3601_vm 058f31828c first commit 1 年之前 3602 058f31828c first commit 1 年之前 3602_fsm 058f31828c first commit 1 年之前 3602_vm 058f31828c first commit 1 年之前 3603 058f31828c first commit 1 年之前 3603_fsm 058f31828c first commit 1 年之前 3603_vm 058f31828c first commit 1 年之前 3604 058f31828c first commit 1 年之前 3605 058f31828c first commit 1 年之前 3606 058f31828c first commit 1 年之前 3607 058f31828c first commit 1 年之前 3608 058f31828c first commit 1 年之前 3609 058f31828c first commit 1 年之前 3712 058f31828c first commit 1 年之前 3764 058f31828c first commit 1 年之前 3764_fsm 058f31828c first commit 1 年之前 3764_vm 058f31828c first commit 1 年之前 3766 058f31828c first commit 1 年之前 3767 058f31828c first commit 1 年之前 3997 058f31828c first commit 1 年之前 4143 058f31828c first commit 1 年之前 4144 058f31828c first commit 1 年之前 4145 058f31828c first commit 1 年之前 4146 058f31828c first commit 1 年之前 4147 058f31828c first commit 1 年之前 4148 058f31828c first commit 1 年之前 4149 058f31828c first commit 1 年之前 4150 058f31828c first commit 1 年之前 4151 058f31828c first commit 1 年之前 4152 058f31828c first commit 1 年之前 4153 058f31828c first commit 1 年之前 4154 058f31828c first commit 1 年之前 4155 058f31828c first commit 1 年之前 4156 058f31828c first commit 1 年之前 4157 058f31828c first commit 1 年之前 4158 058f31828c first commit 1 年之前 4159 058f31828c first commit 1 年之前 4160 058f31828c first commit 1 年之前 4161 058f31828c first commit 1 年之前 4162 058f31828c first commit 1 年之前 4163 058f31828c first commit 1 年之前 4164 058f31828c first commit 1 年之前 4165 058f31828c first commit 1 年之前 4166 058f31828c first commit 1 年之前 4167 058f31828c first commit 1 年之前 4168 058f31828c first commit 1 年之前 4169 058f31828c first commit 1 年之前 4170 058f31828c first commit 1 年之前 4171 058f31828c first commit 1 年之前 4172 058f31828c first commit 1 年之前 4173 058f31828c first commit 1 年之前 4174 058f31828c first commit 1 年之前 5002 058f31828c first commit 1 年之前 548 058f31828c first commit 1 年之前 549 058f31828c first commit 1 年之前 6102 058f31828c first commit 1 年之前 6104 058f31828c first commit 1 年之前 6106 058f31828c first commit 1 年之前 6110 058f31828c first commit 1 年之前 6111 058f31828c first commit 1 年之前 6112 058f31828c first commit 1 年之前 6113 058f31828c first commit 1 年之前 6117 058f31828c first commit 1 年之前 826 058f31828c first commit 1 年之前 827 058f31828c first commit 1 年之前 828 058f31828c first commit 1 年之前 PG_VERSION 058f31828c first commit 1 年之前 pg_filenode.map 058f31828c first commit 1 年之前 pg_internal.init 058f31828c first commit 1 年之前 tum/whitesports - Gogs: Simplico Git Service

暫無描述

options-permalink.php 19KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440
  1. <?php
  2. /**
  3. * Permalink Settings Administration Screen.
  4. *
  5. * @package WordPress
  6. * @subpackage Administration
  7. */
  8. /** WordPress Administration Bootstrap */
  9. require_once __DIR__ . '/admin.php';
  10. if ( ! current_user_can( 'manage_options' ) ) {
  11. wp_die( __( 'Sorry, you are not allowed to manage options for this site.' ) );
  12. }
  13. $title = __( 'Permalink Settings' );
  14. $parent_file = 'options-general.php';
  15. get_current_screen()->add_help_tab(
  16. array(
  17. 'id' => 'overview',
  18. 'title' => __( 'Overview' ),
  19. 'content' => '<p>' . __( 'Permalinks are the permanent URLs to your individual pages and blog posts, as well as your category and tag archives. A permalink is the web address used to link to your content. The URL to each post should be permanent, and never change &#8212; hence the name permalink.' ) . '</p>' .
  20. '<p>' . __( 'This screen allows you to choose your permalink structure. You can choose from common settings or create custom URL structures.' ) . '</p>' .
  21. '<p>' . __( 'You must click the Save Changes button at the bottom of the screen for new settings to take effect.' ) . '</p>',
  22. )
  23. );
  24. get_current_screen()->add_help_tab(
  25. array(
  26. 'id' => 'permalink-settings',
  27. 'title' => __( 'Permalink Settings' ),
  28. 'content' => '<p>' . __( 'Permalinks can contain useful information, such as the post date, title, or other elements. You can choose from any of the suggested permalink formats, or you can craft your own if you select Custom Structure.' ) . '</p>' .
  29. '<p>' . sprintf(
  30. /* translators: %s: Percent sign (%). */
  31. __( 'If you pick an option other than Plain, your general URL path with structure tags (terms surrounded by %s) will also appear in the custom structure field and your path can be further modified there.' ),
  32. '<code>%</code>'
  33. ) . '</p>' .
  34. '<p>' . sprintf(
  35. /* translators: 1: %category%, 2: %tag% */
  36. __( 'When you assign multiple categories or tags to a post, only one can show up in the permalink: the lowest numbered category. This applies if your custom structure includes %1$s or %2$s.' ),
  37. '<code>%category%</code>',
  38. '<code>%tag%</code>'
  39. ) . '</p>' .
  40. '<p>' . __( 'You must click the Save Changes button at the bottom of the screen for new settings to take effect.' ) . '</p>',
  41. )
  42. );
  43. get_current_screen()->add_help_tab(
  44. array(
  45. 'id' => 'custom-structures',
  46. 'title' => __( 'Custom Structures' ),
  47. 'content' => '<p>' . __( 'The Optional fields let you customize the &#8220;category&#8221; and &#8220;tag&#8221; base names that will appear in archive URLs. For example, the page listing all posts in the &#8220;Uncategorized&#8221; category could be <code>/topics/uncategorized</code> instead of <code>/category/uncategorized</code>.' ) . '</p>' .
  48. '<p>' . __( 'You must click the Save Changes button at the bottom of the screen for new settings to take effect.' ) . '</p>',
  49. )
  50. );
  51. get_current_screen()->set_help_sidebar(
  52. '<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
  53. '<p>' . __( '<a href="https://wordpress.org/support/article/settings-permalinks-screen/">Documentation on Permalinks Settings</a>' ) . '</p>' .
  54. '<p>' . __( '<a href="https://wordpress.org/support/article/using-permalinks/">Documentation on Using Permalinks</a>' ) . '</p>' .
  55. '<p>' . __( '<a href="https://wordpress.org/support/">Support</a>' ) . '</p>'
  56. );
  57. $home_path = get_home_path();
  58. $iis7_permalinks = iis7_supports_permalinks();
  59. $permalink_structure = get_option( 'permalink_structure' );
  60. $prefix = '';
  61. $blog_prefix = '';
  62. if ( ! got_url_rewrite() ) {
  63. $prefix = '/index.php';
  64. }
  65. /*
  66. * In a subdirectory configuration of multisite, the `/blog` prefix is used by
  67. * default on the main site to avoid collisions with other sites created on that
  68. * network. If the `permalink_structure` option has been changed to remove this
  69. * base prefix, WordPress core can no longer account for the possible collision.
  70. */
  71. if ( is_multisite() && ! is_subdomain_install() && is_main_site() && 0 === strpos( $permalink_structure, '/blog/' ) ) {
  72. $blog_prefix = '/blog';
  73. }
  74. $category_base = get_option( 'category_base' );
  75. $tag_base = get_option( 'tag_base' );
  76. $structure_updated = false;
  77. $htaccess_update_required = false;
  78. if ( isset( $_POST['permalink_structure'] ) || isset( $_POST['category_base'] ) ) {
  79. check_admin_referer( 'update-permalink' );
  80. if ( isset( $_POST['permalink_structure'] ) ) {
  81. if ( isset( $_POST['selection'] ) && 'custom' !== $_POST['selection'] ) {
  82. $permalink_structure = $_POST['selection'];
  83. } else {
  84. $permalink_structure = $_POST['permalink_structure'];
  85. }
  86. if ( ! empty( $permalink_structure ) ) {
  87. $permalink_structure = preg_replace( '#/+#', '/', '/' . str_replace( '#', '', $permalink_structure ) );
  88. if ( $prefix && $blog_prefix ) {
  89. $permalink_structure = $prefix . preg_replace( '#^/?index\.php#', '', $permalink_structure );
  90. } else {
  91. $permalink_structure = $blog_prefix . $permalink_structure;
  92. }
  93. }
  94. $permalink_structure = sanitize_option( 'permalink_structure', $permalink_structure );
  95. $wp_rewrite->set_permalink_structure( $permalink_structure );
  96. $structure_updated = true;
  97. }
  98. if ( isset( $_POST['category_base'] ) ) {
  99. $category_base = $_POST['category_base'];
  100. if ( ! empty( $category_base ) ) {
  101. $category_base = $blog_prefix . preg_replace( '#/+#', '/', '/' . str_replace( '#', '', $category_base ) );
  102. }
  103. $wp_rewrite->set_category_base( $category_base );
  104. }
  105. if ( isset( $_POST['tag_base'] ) ) {
  106. $tag_base = $_POST['tag_base'];
  107. if ( ! empty( $tag_base ) ) {
  108. $tag_base = $blog_prefix . preg_replace( '#/+#', '/', '/' . str_replace( '#', '', $tag_base ) );
  109. }
  110. $wp_rewrite->set_tag_base( $tag_base );
  111. }
  112. }
  113. if ( $iis7_permalinks ) {
  114. if ( ( ! file_exists( $home_path . 'web.config' ) && win_is_writable( $home_path ) ) || win_is_writable( $home_path . 'web.config' ) ) {
  115. $writable = true;
  116. } else {
  117. $writable = false;
  118. }
  119. } elseif ( $is_nginx ) {
  120. $writable = false;
  121. } else {
  122. if ( ( ! file_exists( $home_path . '.htaccess' ) && is_writable( $home_path ) ) || is_writable( $home_path . '.htaccess' ) ) {
  123. $writable = true;
  124. } else {
  125. $writable = false;
  126. $existing_rules = array_filter( extract_from_markers( $home_path . '.htaccess', 'WordPress' ) );
  127. $new_rules = array_filter( explode( "\n", $wp_rewrite->mod_rewrite_rules() ) );
  128. $htaccess_update_required = ( $new_rules !== $existing_rules );
  129. }
  130. }
  131. $using_index_permalinks = $wp_rewrite->using_index_permalinks();
  132. if ( $structure_updated ) {
  133. $message = __( 'Permalink structure updated.' );
  134. if ( ! is_multisite() && $permalink_structure && ! $using_index_permalinks ) {
  135. if ( $iis7_permalinks ) {
  136. if ( ! $writable ) {
  137. $message = sprintf(
  138. /* translators: %s: web.config */
  139. __( 'You should update your %s file now.' ),
  140. '<code>web.config</code>'
  141. );
  142. } else {
  143. $message = sprintf(
  144. /* translators: %s: web.config */
  145. __( 'Permalink structure updated. Remove write access on %s file now!' ),
  146. '<code>web.config</code>'
  147. );
  148. }
  149. } elseif ( ! $is_nginx && $htaccess_update_required && ! $writable ) {
  150. $message = sprintf(
  151. /* translators: %s: .htaccess */
  152. __( 'You should update your %s file now.' ),
  153. '<code>.htaccess</code>'
  154. );
  155. }
  156. }
  157. if ( ! get_settings_errors() ) {
  158. add_settings_error( 'general', 'settings_updated', $message, 'success' );
  159. }
  160. set_transient( 'settings_errors', get_settings_errors(), 30 );
  161. wp_redirect( admin_url( 'options-permalink.php?settings-updated=true' ) );
  162. exit;
  163. }
  164. flush_rewrite_rules();
  165. require_once ABSPATH . 'wp-admin/admin-header.php';
  166. ?>
  167. <div class="wrap">
  168. <h1><?php echo esc_html( $title ); ?></h1>
  169. <form name="form" action="options-permalink.php" method="post">
  170. <?php wp_nonce_field( 'update-permalink' ); ?>
  171. <p>
  172. <?php
  173. printf(
  174. /* translators: %s: Documentation URL. */
  175. __( 'WordPress offers you the ability to create a custom URL structure for your permalinks and archives. Custom URL structures can improve the aesthetics, usability, and forward-compatibility of your links. A <a href="%s">number of tags are available</a>, and here are some examples to get you started.' ),
  176. __( 'https://wordpress.org/support/article/using-permalinks/' )
  177. );
  178. ?>
  179. </p>
  180. <?php
  181. if ( is_multisite() && ! is_subdomain_install() && is_main_site() && 0 === strpos( $permalink_structure, '/blog/' ) ) {
  182. $permalink_structure = preg_replace( '|^/?blog|', '', $permalink_structure );
  183. $category_base = preg_replace( '|^/?blog|', '', $category_base );
  184. $tag_base = preg_replace( '|^/?blog|', '', $tag_base );
  185. }
  186. $structures = array(
  187. 0 => '',
  188. 1 => $prefix . '/%year%/%monthnum%/%day%/%postname%/',
  189. 2 => $prefix . '/%year%/%monthnum%/%postname%/',
  190. 3 => $prefix . '/' . _x( 'archives', 'sample permalink base' ) . '/%post_id%',
  191. 4 => $prefix . '/%postname%/',
  192. );
  193. ?>
  194. <h2 class="title"><?php _e( 'Common Settings' ); ?></h2>
  195. <table class="form-table permalink-structure">
  196. <tr>
  197. <th scope="row"><label><input name="selection" type="radio" value="" <?php checked( '', $permalink_structure ); ?> /> <?php _e( 'Plain' ); ?></label></th>
  198. <td><code><?php echo get_option( 'home' ); ?>/?p=123</code></td>
  199. </tr>
  200. <tr>
  201. <th scope="row"><label><input name="selection" type="radio" value="<?php echo esc_attr( $structures[1] ); ?>" <?php checked( $structures[1], $permalink_structure ); ?> /> <?php _e( 'Day and name' ); ?></label></th>
  202. <td><code><?php echo get_option( 'home' ) . $blog_prefix . $prefix . '/' . gmdate( 'Y' ) . '/' . gmdate( 'm' ) . '/' . gmdate( 'd' ) . '/' . _x( 'sample-post', 'sample permalink structure' ) . '/'; ?></code></td>
  203. </tr>
  204. <tr>
  205. <th scope="row"><label><input name="selection" type="radio" value="<?php echo esc_attr( $structures[2] ); ?>" <?php checked( $structures[2], $permalink_structure ); ?> /> <?php _e( 'Month and name' ); ?></label></th>
  206. <td><code><?php echo get_option( 'home' ) . $blog_prefix . $prefix . '/' . gmdate( 'Y' ) . '/' . gmdate( 'm' ) . '/' . _x( 'sample-post', 'sample permalink structure' ) . '/'; ?></code></td>
  207. </tr>
  208. <tr>
  209. <th scope="row"><label><input name="selection" type="radio" value="<?php echo esc_attr( $structures[3] ); ?>" <?php checked( $structures[3], $permalink_structure ); ?> /> <?php _e( 'Numeric' ); ?></label></th>
  210. <td><code><?php echo get_option( 'home' ) . $blog_prefix . $prefix . '/' . _x( 'archives', 'sample permalink base' ) . '/123'; ?></code></td>
  211. </tr>
  212. <tr>
  213. <th scope="row"><label><input name="selection" type="radio" value="<?php echo esc_attr( $structures[4] ); ?>" <?php checked( $structures[4], $permalink_structure ); ?> /> <?php _e( 'Post name' ); ?></label></th>
  214. <td><code><?php echo get_option( 'home' ) . $blog_prefix . $prefix . '/' . _x( 'sample-post', 'sample permalink structure' ) . '/'; ?></code></td>
  215. </tr>
  216. <tr>
  217. <th scope="row">
  218. <label><input name="selection" id="custom_selection" type="radio" value="custom" <?php checked( ! in_array( $permalink_structure, $structures, true ) ); ?> />
  219. <?php _e( 'Custom Structure' ); ?>
  220. </label>
  221. </th>
  222. <td>
  223. <code><?php echo get_option( 'home' ) . $blog_prefix; ?></code>
  224. <input name="permalink_structure" id="permalink_structure" type="text" value="<?php echo esc_attr( $permalink_structure ); ?>" class="regular-text code" />
  225. <div class="available-structure-tags hide-if-no-js">
  226. <div id="custom_selection_updated" aria-live="assertive" class="screen-reader-text"></div>
  227. <?php
  228. $available_tags = array(
  229. /* translators: %s: Permalink structure tag. */
  230. 'year' => __( '%s (The year of the post, four digits, for example 2004.)' ),
  231. /* translators: %s: Permalink structure tag. */
  232. 'monthnum' => __( '%s (Month of the year, for example 05.)' ),
  233. /* translators: %s: Permalink structure tag. */
  234. 'day' => __( '%s (Day of the month, for example 28.)' ),
  235. /* translators: %s: Permalink structure tag. */
  236. 'hour' => __( '%s (Hour of the day, for example 15.)' ),
  237. /* translators: %s: Permalink structure tag. */
  238. 'minute' => __( '%s (Minute of the hour, for example 43.)' ),
  239. /* translators: %s: Permalink structure tag. */
  240. 'second' => __( '%s (Second of the minute, for example 33.)' ),
  241. /* translators: %s: Permalink structure tag. */
  242. 'post_id' => __( '%s (The unique ID of the post, for example 423.)' ),
  243. /* translators: %s: Permalink structure tag. */
  244. 'postname' => __( '%s (The sanitized post title (slug).)' ),
  245. /* translators: %s: Permalink structure tag. */
  246. 'category' => __( '%s (Category slug. Nested sub-categories appear as nested directories in the URL.)' ),
  247. /* translators: %s: Permalink structure tag. */
  248. 'author' => __( '%s (A sanitized version of the author name.)' ),
  249. );
  250. /**
  251. * Filters the list of available permalink structure tags on the Permalinks settings page.
  252. *
  253. * @since 4.9.0
  254. *
  255. * @param string[] $available_tags An array of key => value pairs of available permalink structure tags.
  256. */
  257. $available_tags = apply_filters( 'available_permalink_structure_tags', $available_tags );
  258. /* translators: %s: Permalink structure tag. */
  259. $structure_tag_added = __( '%s added to permalink structure' );
  260. /* translators: %s: Permalink structure tag. */
  261. $structure_tag_already_used = __( '%s (already used in permalink structure)' );
  262. if ( ! empty( $available_tags ) ) :
  263. ?>
  264. <p><?php _e( 'Available tags:' ); ?></p>
  265. <ul role="list">
  266. <?php
  267. foreach ( $available_tags as $tag => $explanation ) {
  268. ?>
  269. <li>
  270. <button type="button"
  271. class="button button-secondary"
  272. aria-label="<?php echo esc_attr( sprintf( $explanation, $tag ) ); ?>"
  273. data-added="<?php echo esc_attr( sprintf( $structure_tag_added, $tag ) ); ?>"
  274. data-used="<?php echo esc_attr( sprintf( $structure_tag_already_used, $tag ) ); ?>">
  275. <?php echo '%' . $tag . '%'; ?>
  276. </button>
  277. </li>
  278. <?php
  279. }
  280. ?>
  281. </ul>
  282. <?php endif; ?>
  283. </div>
  284. </td>
  285. </tr>
  286. </table>
  287. <h2 class="title"><?php _e( 'Optional' ); ?></h2>
  288. <p>
  289. <?php
  290. /* translators: %s: Placeholder that must come at the start of the URL. */
  291. printf( __( 'If you like, you may enter custom structures for your category and tag URLs here. For example, using <code>topics</code> as your category base would make your category links like <code>%s/topics/uncategorized/</code>. If you leave these blank the defaults will be used.' ), get_option( 'home' ) . $blog_prefix . $prefix );
  292. ?>
  293. </p>
  294. <table class="form-table" role="presentation">
  295. <tr>
  296. <th><label for="category_base"><?php /* translators: Prefix for category permalinks. */ _e( 'Category base' ); ?></label></th>
  297. <td><?php echo $blog_prefix; ?> <input name="category_base" id="category_base" type="text" value="<?php echo esc_attr( $category_base ); ?>" class="regular-text code" /></td>
  298. </tr>
  299. <tr>
  300. <th><label for="tag_base"><?php _e( 'Tag base' ); ?></label></th>
  301. <td><?php echo $blog_prefix; ?> <input name="tag_base" id="tag_base" type="text" value="<?php echo esc_attr( $tag_base ); ?>" class="regular-text code" /></td>
  302. </tr>
  303. <?php do_settings_fields( 'permalink', 'optional' ); ?>
  304. </table>
  305. <?php do_settings_sections( 'permalink' ); ?>
  306. <?php submit_button(); ?>
  307. </form>
  308. <?php if ( ! is_multisite() ) { ?>
  309. <?php
  310. if ( $iis7_permalinks ) :
  311. if ( isset( $_POST['submit'] ) && $permalink_structure && ! $using_index_permalinks && ! $writable ) :
  312. if ( file_exists( $home_path . 'web.config' ) ) :
  313. ?>
  314. <p id="iis-description-a">
  315. <?php
  316. printf(
  317. /* translators: 1: web.config, 2: Documentation URL, 3: CTRL + a, 4: Element code. */
  318. __( 'If your %1$s file was <a href="%2$s">writable</a>, we could do this automatically, but it isn&#8217;t so this is the url rewrite rule you should have in your %1$s file. Click in the field and press %3$s to select all. Then insert this rule inside of the %4$s element in %1$s file.' ),
  319. '<code>web.config</code>',
  320. __( 'https://wordpress.org/support/article/changing-file-permissions/' ),
  321. '<kbd>CTRL + a</kbd>',
  322. '<code>/&lt;configuration&gt;/&lt;system.webServer&gt;/&lt;rewrite&gt;/&lt;rules&gt;</code>'
  323. );
  324. ?>
  325. </p>
  326. <form action="options-permalink.php" method="post">
  327. <?php wp_nonce_field( 'update-permalink' ); ?>
  328. <p><label for="rules"><?php _e( 'Rewrite rules:' ); ?></label><br /><textarea rows="9" class="large-text readonly" name="rules" id="rules" readonly="readonly" aria-describedby="iis-description-a"><?php echo esc_textarea( $wp_rewrite->iis7_url_rewrite_rules() ); ?></textarea></p>
  329. </form>
  330. <p>
  331. <?php
  332. printf(
  333. /* translators: %s: web.config */
  334. __( 'If you temporarily make your %s file writable for us to generate rewrite rules automatically, do not forget to revert the permissions after rule has been saved.' ),
  335. '<code>web.config</code>'
  336. );
  337. ?>
  338. </p>
  339. <?php else : ?>
  340. <p id="iis-description-b">
  341. <?php
  342. printf(
  343. /* translators: 1: Documentation URL, 2: web.config, 3: CTRL + a */
  344. __( 'If the root directory of your site was <a href="%1$s">writable</a>, we could do this automatically, but it isn&#8217;t so this is the url rewrite rule you should have in your %2$s file. Create a new file, called %2$s in the root directory of your site. Click in the field and press %3$s to select all. Then insert this code into the %2$s file.' ),
  345. __( 'https://wordpress.org/support/article/changing-file-permissions/' ),
  346. '<code>web.config</code>',
  347. '<kbd>CTRL + a</kbd>'
  348. );
  349. ?>
  350. </p>
  351. <form action="options-permalink.php" method="post">
  352. <?php wp_nonce_field( 'update-permalink' ); ?>
  353. <p><label for="rules"><?php _e( 'Rewrite rules:' ); ?></label><br /><textarea rows="18" class="large-text readonly" name="rules" id="rules" readonly="readonly" aria-describedby="iis-description-b"><?php echo esc_textarea( $wp_rewrite->iis7_url_rewrite_rules( true ) ); ?></textarea></p>
  354. </form>
  355. <p>
  356. <?php
  357. printf(
  358. /* translators: %s: web.config */
  359. __( 'If you temporarily make your site&#8217;s root directory writable for us to generate the %s file automatically, do not forget to revert the permissions after the file has been created.' ),
  360. '<code>web.config</code>'
  361. );
  362. ?>
  363. </p>
  364. <?php endif; ?>
  365. <?php endif; ?>
  366. <?php elseif ( $is_nginx ) : ?>
  367. <p><?php _e( '<a href="https://wordpress.org/support/article/nginx/">Documentation on Nginx configuration</a>.' ); ?></p>
  368. <?php
  369. else :
  370. if ( $permalink_structure && ! $using_index_permalinks && ! $writable && $htaccess_update_required ) :
  371. ?>
  372. <p id="htaccess-description">
  373. <?php
  374. printf(
  375. /* translators: 1: .htaccess, 2: Documentation URL, 3: CTRL + a */
  376. __( 'If your %1$s file was <a href="%2$s">writable</a>, we could do this automatically, but it isn&#8217;t so these are the mod_rewrite rules you should have in your %1$s file. Click in the field and press %3$s to select all.' ),
  377. '<code>.htaccess</code>',
  378. __( 'https://wordpress.org/support/article/changing-file-permissions/' ),
  379. '<kbd>CTRL + a</kbd>'
  380. );
  381. ?>
  382. </p>
  383. <form action="options-permalink.php" method="post">
  384. <?php wp_nonce_field( 'update-permalink' ); ?>
  385. <p><label for="rules"><?php _e( 'Rewrite rules:' ); ?></label><br /><textarea rows="8" class="large-text readonly" name="rules" id="rules" readonly="readonly" aria-describedby="htaccess-description"><?php echo esc_textarea( $wp_rewrite->mod_rewrite_rules() ); ?></textarea></p>
  386. </form>
  387. <?php endif; ?>
  388. <?php endif; ?>
  389. <?php } // End if ! is_multisite(). ?>
  390. </div>
  391. <?php require_once ABSPATH . 'wp-admin/admin-footer.php'; ?>