Support » Plugin: Multisite Language Switcher » Switcher for private pages

  • Resolved webbistro

    (@webbistro)


    Hi,

    Very nice plugin! Is there a way or maybe a workaround to set two private pages as translations of each other? The problem is that there is no private page in the language dropdown. I tried to make both public and connected them, but once I make one of them private again – the connection is lost.

    Thanks in advance!

    Best,
    -Nadia

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter webbistro

    (@webbistro)

    The same question about custom post types with 'public' => false,. Public custom post types are being connected just perfectly.

    Plugin Author Dennis Ploetner

    (@realloc)

    I guess this is the reason: https://github.com/lloc/Multisite-Language-Switcher/blob/master/includes/MslsPostType.php#L23

    Not sure if a hook could solve this. Would you like to provide a PR?

    Thread Starter webbistro

    (@webbistro)

    Hi Dennis,

    Thanks for the quick response! I was able to get what I need with these two hooks:

    // include non-public post types
    add_filter ( 'msls_supported_post_types', function( $post_types ) {
    
        $post_types = array_merge(
            [ 'post', 'page' ],
            get_post_types( [ '_builtin' => false ], 'names', 'and' ) 
        );
        return $post_types;
    
    }, 10 );
    
    // add private pages (hierarchical post types) to the drop down
    add_filter ( 'msls_meta_box_render_select_hierarchical', function( $args ) {
    
        $args['post_status'] = [ 'publish', 'private' ];
        return $args;
    
    }, 10 );

    For everyone interested: this might be better to just add a post type you need but not list all the not-built-in post types. Because sometimes there could be some unexpected and unwanted non-public post types in the list.

    Like this:

    // include exactly team_member post type
    add_filter ( 'msls_supported_post_types', function( $post_types ) {
    
        $post_types = array_merge(
            [ 'post', 'page', 'team_member' ], // adding a particular post type
            get_post_types( [ 'public' => true, '_builtin' => false ], 'names', 'and' ) 
        );
        return $post_types;
    
    }, 10 );

    Best,
    -Nadia

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.