| 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 |
/** |
| 13 |
* @var PLL_Model |
| 14 |
*/ |
| 15 |
public $model; |
| 16 |
|
| 17 |
/** |
| 18 |
* @var PLL_Admin_Links |
| 19 |
*/ |
| 20 |
public $links; |
| 21 |
|
| 22 |
/** |
| 23 |
* Language selected in the admin language filter. |
| 24 |
* |
| 25 |
* @var PLL_Language|null |
| 26 |
*/ |
| 27 |
public $filter_lang; |
| 28 |
|
| 29 |
/** |
| 30 |
* Preferred language to assign to new contents. |
| 31 |
* |
| 32 |
* @var PLL_Language|null |
| 33 |
*/ |
| 34 |
public $pref_lang; |
| 35 |
|
| 36 |
/** |
| 37 |
* Constructor: setups filters and actions |
| 38 |
* |
| 39 |
* @since 1.2 |
| 40 |
* |
| 41 |
* @param object $polylang The Polylang object. |
| 42 |
*/ |
| 43 |
public function __construct( &$polylang ) { |
| 44 |
$this->links = &$polylang->links; |
| 45 |
$this->model = &$polylang->model; |
| 46 |
$this->pref_lang = &$polylang->pref_lang; |
| 47 |
} |
| 48 |
|
| 49 |
/** |
| 50 |
* Save translations from the languages metabox. |
| 51 |
* |
| 52 |
* @since 1.5 |
| 53 |
* |
| 54 |
* @param int $post_id Post id of the post being saved. |
| 55 |
* @param int[] $arr An array with language codes as key and post id as value. |
| 56 |
* @return int[] The array of translated post ids. |
| 57 |
*/ |
| 58 |
protected function save_translations( $post_id, $arr ) { |
| 59 |
// Security check as 'wp_insert_post' can be called from outside WP admin. |
| 60 |
check_admin_referer( 'pll_language', '_pll_nonce' ); |
| 61 |
|
| 62 |
$translations = $this->model->post->save_translations( $post_id, $arr ); |
| 63 |
return $translations; |
| 64 |
} |
| 65 |
} |
| 66 |
|