~canonical-sysadmins/wordpress/4.5.2

« back to all changes in this revision

Viewing changes to wp-admin/edit-tags.php

  • Committer: Manuel Seelaus
  • Date: 2015-12-09 17:47:18 UTC
  • mfrom: (1.1.11 upstream)
  • Revision ID: manuel.seelaus@canonical.com-20151209174718-coxethm2swbeqksy
Merge WP4.4 from upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
if ( ! $tax )
18
18
        wp_die( __( 'Invalid taxonomy' ) );
19
19
 
20
 
if ( ! current_user_can( $tax->cap->manage_terms ) )
21
 
        wp_die( __( 'Cheatin’ uh?' ), 403 );
 
20
if ( ! in_array( $tax->name, get_taxonomies( array( 'show_ui' => true ) ) ) ) {
 
21
   wp_die( __( 'You are not allowed to manage these items.' ) );
 
22
}
 
23
 
 
24
if ( ! current_user_can( $tax->cap->manage_terms ) ) {
 
25
        wp_die(
 
26
                '<h1>' . __( 'Cheatin&#8217; uh?' ) . '</h1>' .
 
27
                '<p>' . __( 'You are not allowed to manage these items.' ) . '</p>',
 
28
                403
 
29
        );
 
30
}
22
31
 
23
32
/**
24
33
 * $post_type is set when the WP_Terms_List_Table instance is created
45
54
 
46
55
add_screen_option( 'per_page', array( 'default' => 20, 'option' => 'edit_' . $tax->name . '_per_page' ) );
47
56
 
 
57
get_current_screen()->set_screen_reader_content( array(
 
58
        'heading_pagination' => $tax->labels->items_list_navigation,
 
59
        'heading_list'       => $tax->labels->items_list,
 
60
) );
 
61
 
48
62
$location = false;
 
63
$referer = wp_get_referer();
49
64
 
50
65
switch ( $wp_list_table->current_action() ) {
51
66
 
53
68
 
54
69
        check_admin_referer( 'add-tag', '_wpnonce_add-tag' );
55
70
 
56
 
        if ( !current_user_can( $tax->cap->edit_terms ) )
57
 
                wp_die( __( 'Cheatin&#8217; uh?' ), 403 );
 
71
        if ( ! current_user_can( $tax->cap->edit_terms ) ) {
 
72
                wp_die(
 
73
                        '<h1>' . __( 'Cheatin&#8217; uh?' ) . '</h1>' .
 
74
                        '<p>' . __( 'You are not allowed to add this item.' ) . '</p>',
 
75
                        403
 
76
                );
 
77
        }
58
78
 
59
79
        $ret = wp_insert_term( $_POST['tag-name'], $taxonomy, $_POST );
60
80
        $location = 'edit-tags.php?taxonomy=' . $taxonomy;
61
81
        if ( 'post' != $post_type )
62
82
                $location .= '&post_type=' . $post_type;
63
83
 
64
 
        if ( $referer = wp_get_original_referer() ) {
65
 
                if ( false !== strpos( $referer, 'edit-tags.php' ) )
66
 
                        $location = $referer;
 
84
        if ( $referer && false !== strpos( $referer, 'edit-tags.php' ) ) {
 
85
                $location = $referer;
67
86
        }
68
87
 
69
88
        if ( $ret && !is_wp_error( $ret ) )
77
96
        $location = 'edit-tags.php?taxonomy=' . $taxonomy;
78
97
        if ( 'post' != $post_type )
79
98
                $location .= '&post_type=' . $post_type;
80
 
        if ( $referer = wp_get_referer() ) {
81
 
                if ( false !== strpos( $referer, 'edit-tags.php' ) )
82
 
                        $location = $referer;
 
99
 
 
100
        if ( $referer && false !== strpos( $referer, 'edit-tags.php' ) ) {
 
101
                $location = $referer;
83
102
        }
84
103
 
85
104
        if ( ! isset( $_REQUEST['tag_ID'] ) ) {
89
108
        $tag_ID = (int) $_REQUEST['tag_ID'];
90
109
        check_admin_referer( 'delete-tag_' . $tag_ID );
91
110
 
92
 
        if ( !current_user_can( $tax->cap->delete_terms ) )
93
 
                wp_die( __( 'Cheatin&#8217; uh?' ), 403 );
 
111
        if ( ! current_user_can( $tax->cap->delete_terms ) ) {
 
112
                wp_die(
 
113
                        '<h1>' . __( 'Cheatin&#8217; uh?' ) . '</h1>' .
 
114
                        '<p>' . __( 'You are not allowed to delete this item.' ) . '</p>',
 
115
                        403
 
116
                );
 
117
        }
94
118
 
95
119
        wp_delete_term( $tag_ID, $taxonomy );
96
120
 
101
125
case 'bulk-delete':
102
126
        check_admin_referer( 'bulk-tags' );
103
127
 
104
 
        if ( !current_user_can( $tax->cap->delete_terms ) )
105
 
                wp_die( __( 'Cheatin&#8217; uh?' ), 403 );
 
128
        if ( ! current_user_can( $tax->cap->delete_terms ) ) {
 
129
                wp_die(
 
130
                        '<h1>' . __( 'Cheatin&#8217; uh?' ) . '</h1>' .
 
131
                        '<p>' . __( 'You are not allowed to delete these items.' ) . '</p>',
 
132
                        403
 
133
                );
 
134
        }
106
135
 
107
136
        $tags = (array) $_REQUEST['delete_tags'];
108
137
        foreach ( $tags as $tag_ID ) {
112
141
        $location = 'edit-tags.php?taxonomy=' . $taxonomy;
113
142
        if ( 'post' != $post_type )
114
143
                $location .= '&post_type=' . $post_type;
115
 
        if ( $referer = wp_get_referer() ) {
116
 
                if ( false !== strpos( $referer, 'edit-tags.php' ) )
117
 
                        $location = $referer;
 
144
        if ( $referer && false !== strpos( $referer, 'edit-tags.php' ) ) {
 
145
                $location = $referer;
118
146
        }
119
147
 
120
148
        $location = add_query_arg( 'message', 6, $location );
139
167
        $tag_ID = (int) $_POST['tag_ID'];
140
168
        check_admin_referer( 'update-tag_' . $tag_ID );
141
169
 
142
 
        if ( !current_user_can( $tax->cap->edit_terms ) )
143
 
                wp_die( __( 'Cheatin&#8217; uh?' ), 403 );
 
170
        if ( ! current_user_can( $tax->cap->edit_terms ) ) {
 
171
                wp_die(
 
172
                        '<h1>' . __( 'Cheatin&#8217; uh?' ) . '</h1>' .
 
173
                        '<p>' . __( 'You are not allowed to edit this item.' ) . '</p>',
 
174
                        403
 
175
                );
 
176
        }
144
177
 
145
178
        $tag = get_term( $tag_ID, $taxonomy );
146
179
        if ( ! $tag )
152
185
        if ( 'post' != $post_type )
153
186
                $location .= '&post_type=' . $post_type;
154
187
 
155
 
        if ( $referer = wp_get_original_referer() ) {
156
 
                if ( false !== strpos( $referer, 'edit-tags.php' ) )
157
 
                        $location = $referer;
 
188
        if ( $referer && false !== strpos( $referer, 'edit-tags.php' ) ) {
 
189
                $location = $referer;
158
190
        }
159
191
 
160
192
        if ( $ret && !is_wp_error( $ret ) )
215
247
                        $help = '<p>' . __( 'When adding a new tag on this screen, you&#8217;ll fill in the following fields:' ) . '</p>';
216
248
 
217
249
                $help .= '<ul>' .
218
 
                '<li>' . __( '<strong>Name</strong> - The name is how it appears on your site.' ) . '</li>';
 
250
                '<li>' . __( '<strong>Name</strong> &mdash; The name is how it appears on your site.' ) . '</li>';
219
251
 
220
252
                if ( ! global_terms_enabled() )
221
 
                        $help .= '<li>' . __( '<strong>Slug</strong> - The &#8220;slug&#8221; is the URL-friendly version of the name. It is usually all lowercase and contains only letters, numbers, and hyphens.' ) . '</li>';
 
253
                        $help .= '<li>' . __( '<strong>Slug</strong> &mdash; The &#8220;slug&#8221; is the URL-friendly version of the name. It is usually all lowercase and contains only letters, numbers, and hyphens.' ) . '</li>';
222
254
 
223
255
                if ( 'category' == $taxonomy )
224
 
                        $help .= '<li>' . __( '<strong>Parent</strong> - Categories, unlike tags, can have a hierarchy. You might have a Jazz category, and under that have child categories for Bebop and Big Band. Totally optional. To create a subcategory, just choose another category from the Parent dropdown.' ) . '</li>';
 
256
                        $help .= '<li>' . __( '<strong>Parent</strong> &mdash; Categories, unlike tags, can have a hierarchy. You might have a Jazz category, and under that have child categories for Bebop and Big Band. Totally optional. To create a subcategory, just choose another category from the Parent dropdown.' ) . '</li>';
225
257
 
226
 
                $help .= '<li>' . __( '<strong>Description</strong> - The description is not prominent by default; however, some themes may display it.' ) . '</li>' .
 
258
                $help .= '<li>' . __( '<strong>Description</strong> &mdash; The description is not prominent by default; however, some themes may display it.' ) . '</li>' .
227
259
                '</ul>' .
228
260
                '<p>' . __( 'You can change the display of this screen using the Screen Options tab to set how many items are displayed per screen and to display/hide columns in the table.' ) . '</p>';
229
261
 
252
284
 
253
285
require_once( ABSPATH . 'wp-admin/admin-header.php' );
254
286
 
255
 
if ( !current_user_can($tax->cap->edit_terms) )
256
 
        wp_die( __('You are not allowed to edit this item.') );
257
 
 
258
 
$messages = array();
259
 
$messages['_item'] = array(
260
 
        0 => '', // Unused. Messages start at index 1.
261
 
        1 => __( 'Item added.' ),
262
 
        2 => __( 'Item deleted.' ),
263
 
        3 => __( 'Item updated.' ),
264
 
        4 => __( 'Item not added.' ),
265
 
        5 => __( 'Item not updated.' ),
266
 
        6 => __( 'Items deleted.' )
267
 
);
268
 
$messages['category'] = array(
269
 
        0 => '', // Unused. Messages start at index 1.
270
 
        1 => __( 'Category added.' ),
271
 
        2 => __( 'Category deleted.' ),
272
 
        3 => __( 'Category updated.' ),
273
 
        4 => __( 'Category not added.' ),
274
 
        5 => __( 'Category not updated.' ),
275
 
        6 => __( 'Categories deleted.' )
276
 
);
277
 
$messages['post_tag'] = array(
278
 
        0 => '', // Unused. Messages start at index 1.
279
 
        1 => __( 'Tag added.' ),
280
 
        2 => __( 'Tag deleted.' ),
281
 
        3 => __( 'Tag updated.' ),
282
 
        4 => __( 'Tag not added.' ),
283
 
        5 => __( 'Tag not updated.' ),
284
 
        6 => __( 'Tags deleted.' )
285
 
);
286
 
 
287
 
/**
288
 
 * Filter the messages displayed when a tag is updated.
289
 
 *
290
 
 * @since 3.7.0
291
 
 *
292
 
 * @param array $messages The messages to be displayed.
293
 
 */
294
 
$messages = apply_filters( 'term_updated_messages', $messages );
295
 
 
296
 
$message = false;
297
 
if ( isset( $_REQUEST['message'] ) && ( $msg = (int) $_REQUEST['message'] ) ) {
298
 
        if ( isset( $messages[ $taxonomy ][ $msg ] ) )
299
 
                $message = $messages[ $taxonomy ][ $msg ];
300
 
        elseif ( ! isset( $messages[ $taxonomy ] ) && isset( $messages['_item'][ $msg ] ) )
301
 
                $message = $messages['_item'][ $msg ];
 
287
if ( ! current_user_can( $tax->cap->edit_terms ) ) {
 
288
        wp_die(
 
289
                '<h1>' . __( 'Cheatin&#8217; uh?' ) . '</h1>' .
 
290
                '<p>' . __( 'You are not allowed to edit this item.' ) . '</p>',
 
291
                403
 
292
        );
302
293
}
303
294
 
 
295
/** Also used by the Edit Tag  form */
 
296
require_once( ABSPATH . 'wp-admin/includes/edit-tag-messages.php' );
 
297
 
304
298
$class = ( isset( $_REQUEST['error'] ) ) ? 'error' : 'updated';
305
299
 
306
300
if ( is_plugin_active( 'wpcat2tag-importer/wpcat2tag-importer.php' ) ) {
349
343
<div class="form-wrap">
350
344
<p>
351
345
        <?php
352
 
        /** This filter is documented in wp-includes/category-template.php */
353
 
        printf( __( '<strong>Note:</strong><br />Deleting a category does not delete the posts in that category. Instead, posts that were only assigned to the deleted category are set to the category <strong>%s</strong>.' ), apply_filters( 'the_category', get_cat_name( get_option( 'default_category') ) ) );
 
346
        echo '<strong>' . __( 'Note:' ) . '</strong><br />';
 
347
        printf(
 
348
                /* translators: %s: default category */
 
349
                __( 'Deleting a category does not delete the posts in that category. Instead, posts that were only assigned to the deleted category are set to the category %s.' ),
 
350
                /** This filter is documented in wp-includes/category-template.php */
 
351
                '<strong>' . apply_filters( 'the_category', get_cat_name( get_option( 'default_category') ) ) . '</strong>'
 
352
        );
354
353
        ?>
355
354
</p>
356
355
<?php if ( current_user_can( 'import' ) ) : ?>
392
391
        if ( $tag_cloud ) :
393
392
        ?>
394
393
<div class="tagcloud">
395
 
<h3><?php echo $tax->labels->popular_items; ?></h3>
 
394
<h2><?php echo $tax->labels->popular_items; ?></h2>
396
395
<?php echo $tag_cloud; unset( $tag_cloud ); ?>
397
396
</div>
398
397
<?php
445
444
?>
446
445
 
447
446
<div class="form-wrap">
448
 
<h3><?php echo $tax->labels->add_new_item; ?></h3>
 
447
<h2><?php echo $tax->labels->add_new_item; ?></h2>
449
448
<form id="addtag" method="post" action="edit-tags.php" class="validate"
450
449
<?php
451
450
/**