object->get_tax_translations(); } /** * Saves the object's translations. * * @since 1.0 * @since 1.9 Returns the translations. * @since 1.9 Type-hinted. * * @param int[] $translations An associative array of translations with language code as key and translation ID as value. * @return int[] An associative array with language codes as key and object IDs as values. * * @phpstan-param non-empty-array $translations * @phpstan-return array */ public function save_translations( $translations ): array { return (array) $this->object->save_translations( reset( $translations ), $translations ); } /** * Returns an array of translations of an object. * * @since 1.0 * @since 1.9 Type-hinted. * * @param int $id Object ID. * @return int[] An associative array of translations with language code as key and translation ID as value. * * @phpstan-return array */ public function get_translations( $id ): array { return (array) $this->object->get_translations( $id ); } /** * Among the object and its translations, returns the ID of the object which is in `$lang`. * * @since 1.0 * * @param int $id Object ID. * @param PLL_Language|string|null $lang Optional language (object or slug), defaults to the current language. * @return int|null The translation object ID if exists, `0` otherwise. `null` if the language is not defined yet. * * @phpstan-return int<0, max>|null */ public function get( $id, $lang = null ) { $lang = ! empty( $lang ) ? $lang : pll_current_language( \OBJECT ); if ( empty( $lang ) ) { return null; } return $this->object->get( $id, $lang ); } }