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