Astra_Polylang_Compatibility::get_advanced_hook_polylang_object( object $current_posts, string $post_type )
Pass the current page advanced hook display posts to Polylang’s object filter to allow strings to be translated.
Description
Parameters
- $current_posts
-
(object) (Required) Posts.
- $post_type
-
(string) (Required) Post Type.
Return
(object) Posts.
Source
File: compatibility/class-astra-polylang-compatibility.php
public function get_advanced_hook_polylang_object( $current_posts, $post_type ) {
if ( 'astra-advanced-hook' === $post_type ) {
$pll_filter_posts = $current_posts;
foreach ( $current_posts as $post_id => $post_data ) {
$pll_filter_id = apply_filters( 'pll_get_post', $post_id, pll_current_language() ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound
if ( null !== $pll_filter_id && $post_id !== $pll_filter_id && isset( $pll_filter_posts[ $post_id ] ) ) {
$pll_filter_posts[ $pll_filter_id ] = $pll_filter_posts[ $post_id ];
$pll_filter_posts[ $pll_filter_id ]['id'] = $pll_filter_id;
unset( $pll_filter_posts[ $post_id ] );
}
}
$current_posts = $pll_filter_posts;
}
return $current_posts;
}
Expand full source code Collapse full source code View on Trac
Changelog
| Version | Description |
|---|---|
| 4.12.0 | Introduced. |