PluginProbe
Polylang / 2.6.3
Polylang v2.6.3
3.8.9 3.8.8 3.8.7 3.8.6 3.8.5 3.8.4 3.8.3 2.7 2.7.0.1 2.7.1 2.7.2 2.7.3 2.7.4 2.8 2.8.1 2.8.2 2.8.3 2.8.4 2.9 2.9.1 2.9.2 3.0 3.0.1 3.0.2 3.0.3 All 233 releases
← All changes | admin/admin-filters-columns.php +16 -29 2.7.42.6.3 View file →
@@ -20,30 +20,27 @@
20 20 $this->links = &$polylang->links;
21 21 $this->model = &$polylang->model;
22 22 $this->filter_lang = &$polylang->filter_lang;
23 23
24 - // Hide the column of the filtered language.
25 - add_filter( 'hidden_columns', array( $this, 'hidden_columns' ) ); // Since WP 4.4.
26 -
27 - // Add the language and translations columns in 'All Posts', 'All Pages' and 'Media library' panels.
24 + // Add the language and translations columns in 'All Posts', 'All Pages' and 'Media library' panels
28 25 foreach ( $this->model->get_translated_post_types() as $type ) {
29 26 // Use the latest filter late as some plugins purely overwrite what's done by others :(
30 - // Specific case for media.
27 + // Specific case for media
31 28 add_filter( 'manage_' . ( 'attachment' == $type ? 'upload' : 'edit-' . $type ) . '_columns', array( $this, 'add_post_column' ), 100 );
32 29 add_action( 'manage_' . ( 'attachment' == $type ? 'media' : $type . '_posts' ) . '_custom_column', array( $this, 'post_column' ), 10, 2 );
33 30 }
34 31
35 - // Quick edit and bulk edit.
32 + // Quick edit and bulk edit
36 33 add_filter( 'quick_edit_custom_box', array( $this, 'quick_edit_custom_box' ), 10, 2 );
37 34 add_filter( 'bulk_edit_custom_box', array( $this, 'quick_edit_custom_box' ), 10, 2 );
38 35
39 - // Adds the language column in the 'Categories' and 'Post Tags' tables.
36 + // Adds the language column in the 'Categories' and 'Post Tags' tables
40 37 foreach ( $this->model->get_translated_taxonomies() as $tax ) {
41 38 add_filter( 'manage_edit-' . $tax . '_columns', array( $this, 'add_term_column' ) );
42 39 add_filter( 'manage_' . $tax . '_custom_column', array( $this, 'term_column' ), 10, 3 );
43 40 }
44 41
45 - // Ajax responses to update list table rows.
42 + // Ajax responses to update list table rows
46 43 add_action( 'wp_ajax_pll_update_post_rows', array( $this, 'ajax_update_post_rows' ) );
47 44 add_action( 'wp_ajax_pll_update_term_rows', array( $this, 'ajax_update_term_rows' ) );
48 45 }
49 46
@@ -62,9 +59,12 @@
62 59 $columns = array_slice( $columns, 0, $n );
63 60 }
64 61
65 62 foreach ( $this->model->get_languages_list() as $language ) {
66 - $columns[ 'language_' . $language->slug ] = $language->flag ? $language->flag . '<span class="screen-reader-text">' . esc_html( $language->name ) . '</span>' : esc_html( $language->slug );
63 + // Don't add the column for the filtered language
64 + if ( empty( $this->filter_lang ) || $language->slug != $this->filter_lang->slug ) {
65 + $columns[ 'language_' . $language->slug ] = $language->flag ? $language->flag . '<span class="screen-reader-text">' . esc_html( $language->name ) . '</span>' : esc_html( $language->slug );
66 + }
67 67 }
68 68
69 69 return isset( $end ) ? array_merge( $columns, $end ) : $columns;
70 70 }
@@ -76,12 +76,12 @@
76 76 *
77 77 * @return string first language column name
78 78 */
79 79 protected function get_first_language_column() {
80 - $columns = array();
81 -
82 80 foreach ( $this->model->get_languages_list() as $language ) {
83 - $columns[] = 'language_' . $language->slug;
81 + if ( empty( $this->filter_lang ) || $language->slug != $this->filter_lang->slug ) {
82 + $columns[] = 'language_' . $language->slug;
83 + }
84 84 }
85 85
86 86 return empty( $columns ) ? '' : reset( $columns );
87 87 }
@@ -86,23 +86,8 @@
86 86 return empty( $columns ) ? '' : reset( $columns );
87 87 }
88 88
89 89 /**
90 - * Hide the column for the filtered language
91 - *
92 - * @since 2.7
93 - *
94 - * @param array $hidden Array of hidden columns
95 - * @return array
96 - */
97 - public function hidden_columns( $hidden ) {
98 - if ( ! empty( $this->filter_lang ) ) {
99 - $hidden[] = 'language_' . $this->filter_lang->slug;
100 - }
101 - return $hidden;
102 - }
103 -
104 - /**
105 90 * Adds the language and translations columns ( before the comments column ) in the posts, pages and media library tables
106 91 *
107 92 * @since 0.1
108 93 *
@@ -136,8 +121,10 @@
136 121 if ( $column == $this->get_first_language_column() ) {
137 122 printf( '<div class="hidden" id="lang_%d">%s</div>', intval( $post_id ), esc_html( $lang->slug ) );
138 123 }
139 124
125 + $post_type_object = get_post_type_object( get_post_type( $post_id ) );
126 +
140 127 // Link to edit post ( or a translation )
141 128 if ( $id = $this->model->post->get( $post_id, $language ) ) {
142 129 // get_edit_post_link returns nothing if the user cannot edit the post
143 130 // Thanks to Solinx. See http://wordpress.org/support/topic/feature-request-incl-code-check-for-capabilities-in-admin-screens
@@ -200,9 +187,9 @@
200 187 </label>
201 188 </div>
202 189 </fieldset>',
203 190 esc_html__( 'Language', 'polylang' ),
204 - $dropdown->walk( $elements, -1, array( 'name' => 'inline_lang_choice', 'id' => '' ) ) // phpcs:ignore WordPress.Security.EscapeOutput
191 + $dropdown->walk( $elements, array( 'name' => 'inline_lang_choice', 'id' => '' ) ) // phpcs:ignore WordPress.Security.EscapeOutput
205 192 );
206 193 }
207 194 return $column;
208 195 }
@@ -285,9 +272,9 @@
285 272 esc_url( $link ),
286 273 esc_html( $s )
287 274 );
288 275 } elseif ( $id === $term_id ) {
289 - $out .= sprintf(
276 + $out .= printf(
290 277 '<span class="pll_icon_tick"><span class="screen-reader-text">%s</span></span>',
291 278 /* translators: accessibility text, %s is a native language name */
292 279 esc_html( sprintf( __( 'This item is in %s', 'polylang' ), $language->name ) )
293 280 );