PluginProbe
Polylang / 2.6.2
Polylang v2.6.2
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
polylang / admin / admin-filters-post-base.php

admin-filters-post-base.php in Polylang 2.6.2, at admin/admin-filters-post-base.php

46 lines 1.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Some common code for PLL_Admin_Filters_Post and PLL_Admin_Filters_Media
5 *
6 * @since 1.5
7 */
8 abstract class PLL_Admin_Filters_Post_Base {
9 public $links, $model, $pref_lang;
10
11 /**
12 * Constructor: setups filters and actions
13 *
14 * @since 1.2
15 *
16 * @param object $polylang
17 */
18 public function __construct( &$polylang ) {
19 $this->links = &$polylang->links;
20 $this->model = &$polylang->model;
21 $this->pref_lang = &$polylang->pref_lang;
22 }
23
24 /**
25 * Save translations from language metabox
26 *
27 * @since 1.5
28 *
29 * @param int $post_id
30 * @param array $arr
31 * @return array
32 */
33 protected function save_translations( $post_id, $arr ) {
34 // Security check as 'wp_insert_post' can be called from outside WP admin
35 check_admin_referer( 'pll_language', '_pll_nonce' );
36
37 // Save translations after checking the translated post is in the right language
38 foreach ( $arr as $lang => $tr_id ) {
39 $translations[ $lang ] = ( $tr_id && $this->model->post->get_language( (int) $tr_id )->slug == $lang ) ? (int) $tr_id : 0;
40 }
41
42 $this->model->post->save_translations( $post_id, $translations );
43 return $translations;
44 }
45 }
46