PluginProbe
Polylang / 2.8.2
Polylang v2.8.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.8.2, at admin/admin-filters-post-base.php

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