diff --git a/src/Integrations/MultilingualPress.php b/src/Integrations/MultilingualPress.php new file mode 100644 index 0000000..7c632d3 --- /dev/null +++ b/src/Integrations/MultilingualPress.php @@ -0,0 +1,68 @@ +type() + ) { + return $remoteUrl; + } + + $postType = get_queried_post_type(); + switch_to_blog($remoteSiteId); + $remoteArchivePageId = get_archive_page_id($postType); + if (0 !== $remoteArchivePageId) { + $remoteUrl = get_permalink($remoteArchivePageId); + } + restore_current_blog(); + + return $remoteUrl; + } +} \ No newline at end of file diff --git a/src/Types/CustomPostType.php b/src/Types/CustomPostType.php index 049f514..623ef55 100644 --- a/src/Types/CustomPostType.php +++ b/src/Types/CustomPostType.php @@ -4,6 +4,7 @@ namespace Itineris\PageAsPostTypeArchive\Types; +use Itineris\PageAsPostTypeArchive\Integrations\MultilingualPress; use WP_Post; use WP_Post_Type; @@ -18,6 +19,13 @@ class CustomPostType extends AbstractType { */ public ?array $archivePages = null; + /** + * @var array|\class-string[] $integrations + */ + public array $integrations = [ + MultilingualPress::class, + ]; + public function __construct() { add_filter('display_post_states', [$this, 'addPageStates'], 10, 2); @@ -27,6 +35,10 @@ public function __construct() add_action('admin_init', [$this, 'addCustomPostTypePageSelectorOptions']); add_action('deleted_post', [$this, 'deletedPost']); add_action('transition_post_status', [$this, 'transitionPostStatus'], 10, 3); + + foreach ($this->integrations as $integration) { + $integration::init(); + } } /**