| @@ -1,8 +1,5 @@ | ||
| 1 | 1 | <?php |
| 2 | -/** | |
| 3 | - * @package Polylang | |
| 4 | - */ | |
| 5 | 2 | |
| 6 | 3 | /** |
| 7 | 4 | * Manages filters and actions related to posts on admin side |
| 8 | 5 | * |
| @@ -49,9 +46,8 @@ | ||
| 49 | 46 | |
| 50 | 47 | // Hierarchical taxonomies |
| 51 | 48 | if ( 'edit' == $screen->base && $taxonomies = get_object_taxonomies( $screen->post_type, 'object' ) ) { |
| 52 | 49 | // Get translated hierarchical taxonomies |
| 53 | - $hierarchical_taxonomies = array(); | |
| 54 | 50 | foreach ( $taxonomies as $taxonomy ) { |
| 55 | 51 | if ( $taxonomy->hierarchical && $taxonomy->show_in_quick_edit && $this->model->is_translated_taxonomy( $taxonomy->name ) ) { |
| 56 | 52 | $hierarchical_taxonomies[] = $taxonomy->name; |
| 57 | 53 | } |
| @@ -57,10 +53,9 @@ | ||
| 57 | 53 | } |
| 58 | 54 | } |
| 59 | 55 | |
| 60 | 56 | if ( ! empty( $hierarchical_taxonomies ) ) { |
| 61 | - $terms = get_terms( $hierarchical_taxonomies, array( 'get' => 'all' ) ); | |
| 62 | - $term_languages = array(); | |
| 57 | + $terms = get_terms( $hierarchical_taxonomies, array( 'get' => 'all' ) ); | |
| 63 | 58 | |
| 64 | 59 | foreach ( $terms as $term ) { |
| 65 | 60 | if ( $lang = $this->model->term->get_language( $term->term_id ) ) { |
| 66 | 61 | $term_languages[ $lang->slug ][ $term->taxonomy ][] = $term->term_id; |
| @@ -75,13 +70,10 @@ | ||
| 75 | 70 | } |
| 76 | 71 | |
| 77 | 72 | // Hierarchical post types |
| 78 | 73 | if ( 'edit' == $screen->base && is_post_type_hierarchical( $screen->post_type ) ) { |
| 79 | - $pages = get_pages( array( 'sort_column' => 'menu_order, post_title' ) ); // Same arguments as the parent pages dropdown to avoid an extra query. | |
| 80 | - update_post_caches( $pages, $screen->post_type ); | |
| 74 | + $pages = get_pages(); | |
| 81 | 75 | |
| 82 | - $page_languages = array(); | |
| 83 | - | |
| 84 | 76 | foreach ( $pages as $page ) { |
| 85 | 77 | if ( $lang = $this->model->post->get_language( $page->ID ) ) { |
| 86 | 78 | $page_languages[ $lang->slug ][] = $page->ID; |
| 87 | 79 | } |
| @@ -111,9 +103,9 @@ | ||
| 111 | 103 | * |
| 112 | 104 | * @since 2.3 |
| 113 | 105 | */ |
| 114 | 106 | public function edit_post() { |
| 115 | - if ( isset( $_POST['post_lang_choice'], $_POST['post_ID'] ) && $post_id = (int) $_POST['post_ID'] ) { // phpcs:ignore WordPress.Security.NonceVerification | |
| 107 | + if ( isset( $_POST['post_lang_choice'], $_POST['post_ID'] ) && $post_id = (int) $_POST['post_ID'] ) { | |
| 116 | 108 | check_admin_referer( 'pll_language', '_pll_nonce' ); |
| 117 | 109 | |
| 118 | 110 | $post = get_post( $post_id ); |
| 119 | 111 | $post_type_object = get_post_type_object( $post->post_type ); |
| @@ -118,12 +110,12 @@ | ||
| 118 | 110 | $post = get_post( $post_id ); |
| 119 | 111 | $post_type_object = get_post_type_object( $post->post_type ); |
| 120 | 112 | |
| 121 | 113 | if ( current_user_can( $post_type_object->cap->edit_post, $post_id ) ) { |
| 122 | - $this->model->post->set_language( $post_id, $this->model->get_language( sanitize_key( $_POST['post_lang_choice'] ) ) ); | |
| 114 | + $this->model->post->set_language( $post_id, $this->model->get_language( $_POST['post_lang_choice'] ) ); | |
| 123 | 115 | |
| 124 | 116 | if ( isset( $_POST['post_tr_lang'] ) ) { |
| 125 | - $this->save_translations( $post_id, array_map( 'absint', $_POST['post_tr_lang'] ) ); | |
| 117 | + $this->save_translations( $post_id, $_POST['post_tr_lang'] ); | |
| 126 | 118 | } |
| 127 | 119 | } |
| 128 | 120 | } |
| 129 | 121 | } |
| @@ -167,12 +159,12 @@ | ||
| 167 | 159 | * |
| 168 | 160 | * @since 2.3 |
| 169 | 161 | */ |
| 170 | 162 | public function bulk_edit_posts() { |
| 171 | - if ( isset( $_GET['bulk_edit'], $_GET['inline_lang_choice'], $_REQUEST['post'] ) && -1 !== $_GET['inline_lang_choice'] ) { // phpcs:ignore WordPress.Security.NonceVerification | |
| 163 | + if ( isset( $_GET['bulk_edit'], $_GET['inline_lang_choice'] ) && -1 !== $_GET['inline_lang_choice'] ) { | |
| 172 | 164 | check_admin_referer( 'bulk-posts' ); |
| 173 | 165 | |
| 174 | - if ( $lang = $this->model->get_language( sanitize_key( $_GET['inline_lang_choice'] ) ) ) { | |
| 166 | + if ( $lang = $this->model->get_language( $_GET['inline_lang_choice'] ) ) { | |
| 175 | 167 | $post_ids = array_map( 'intval', (array) $_REQUEST['post'] ); |
| 176 | 168 | foreach ( $post_ids as $post_id ) { |
| 177 | 169 | $this->inline_save_language( $post_id, $lang ); |
| 178 | 170 | } |
| @@ -189,9 +181,9 @@ | ||
| 189 | 181 | check_admin_referer( 'inlineeditnonce', '_inline_edit' ); |
| 190 | 182 | |
| 191 | 183 | if ( isset( $_POST['post_ID'], $_POST['inline_lang_choice'] ) ) { |
| 192 | 184 | $post_id = (int) $_POST['post_ID']; |
| 193 | - $lang = $this->model->get_language( sanitize_key( $_POST['inline_lang_choice'] ) ); | |
| 185 | + $lang = $this->model->get_language( $_POST['inline_lang_choice'] ); | |
| 194 | 186 | if ( $post_id && $lang ) { |
| 195 | 187 | $this->inline_save_language( $post_id, $lang ); |
| 196 | 188 | } |
| 197 | 189 | } |