Astra_Wpml_Compatibility::get_advanced_hook_wpml_object( object $current_posts, string $post_type )
Pass the current page advanced hook display posts to WPML’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-wpml-compatibility.php
public function get_advanced_hook_wpml_object( $current_posts, $post_type ) {
if ( 'astra-advanced-hook' === $post_type ) {
$wpml_filter_posts = $current_posts;
foreach ( $current_posts as $post_id => $post_data ) {
// Get tralated post id here.
$wpml_filter_id = apply_filters( 'wpml_object_id', $post_id, 'astra-advanced-hook', true );
if ( null !== $wpml_filter_id ) {
if ( $post_id !== $wpml_filter_id && isset( $wpml_filter_posts[ $post_id ] ) ) {
$wpml_filter_posts[ $wpml_filter_id ] = $wpml_filter_posts[ $post_id ];
$wpml_filter_posts[ $wpml_filter_id ]['id'] = $wpml_filter_id;
unset( $wpml_filter_posts[ $post_id ] );
}
}
}
$current_posts = $wpml_filter_posts;
}
return $current_posts;
}
Expand full source code Collapse full source code View on Trac
Changelog
| Version | Description |
|---|---|
| 1.1.0 | Introduced. |