Dennis Ploetner
Forum Replies Created
-
Forum: Plugins
In reply to: [Multisite Language Switcher] Manually create associationI wrote something in the past that can illustrate a bit what you want to achieve: Msls Importer
It is quite outdated code but it wanted to backup the MSLS options in a JSON file and provides also functionality to import those files back.
Forum: Plugins
In reply to: [Multisite Language Switcher] msls with custom post typeI guess that your code has a small flaw. The expected input for that function is an integer not an array:
<?php
$post_id = get_queried_object_id(); // or any number of your choice
$msls_post = msls_get_post( $post_id );
print_r( $msls_post );Forum: Plugins
In reply to: [Multisite Language Switcher] How to add to subheader menuThe MslsMenu add-on is doing this for classical NavMenus. Here an example (taken from the msls.co website):
function my_custom_menu_item( $items, $args ) {
if ( function_exists ( 'msls_output' ) && 'primary' == $args->theme_location ) {
$arr = msls_output()->get( 2 );
if ( !empty( $arr ) ) {
$items .= '<li>' . implode( '</li><li>', $arr ) . '</li>';
}
}
return $items;
}
add_filter( 'wp_nav_menu_items', 'my_custom_menu_item', 10, 2 );And yes, you can also use the API functions provided by the plugin. You can pass an array to the function to the function the_msls() that gives you even more flexibility:
<?php
$tags array(
'before_item' => '<li>',
'after_item' => '</li>',
'before_output' => '<ul class="your-css-class">,
'after_output' => '</ul>',
);
the_msls( $tags );Forum: Plugins
In reply to: [Multisite Language Switcher] msls with custom post typeYou should be able to see an icon whenever you write a post (or other type of content) like in my example here: https://imgur.com/a/3Ck7ZPe
Forum: Plugins
In reply to: [Multisite Language Switcher] Content import not working.If you also see a Japanese flag (or label) on the English website and vice versa, yes. This means it is configured.
With Twenty Twenty Five you should be able to use the plugins’ block to show the flags in the frontend too. I will try to setup a website with the settings you mentioned and see what is happening.
Forum: Plugins
In reply to: [Multisite Language Switcher] Content import not working.The most important things are that you have at least 2 websites with different languages, and that you configured them in the settings for the Multisite Language Switcher: https://msls.co/
Can you confirm that this has been done?
Forum: Plugins
In reply to: [Multisite Language Switcher] Content import not working.I will try to reproduce it. Is there anything I should know: What theme is active for example…
With version 2.9.2, I did start to provide more API functions and less access to the internals of various objects/classes. The API function that you’re looking for is called msls_output in would be safe to use in future versions too:
/** * Gets the MslsOutput instance * * @return \lloc\Msls\MslsOutput */ function msls_output(): \lloc\Msls\MslsOutput { return \lloc\Msls\MslsOutput::create(); }Forum: Plugins
In reply to: [Multisite Language Switcher] Hreflang tag issuesI guess I answered that here: https://ww.wp.xz.cn/support/topic/i-wanted-to-add-x-default-tag-to-every-page-of-my-website/
But I don’t know what you want to do with CSV.It looks like some JS is not working as expected. At least I see some warning in the console that lets me think that. Another possibility could be an incorrect redirect rule.
But those are things that are not coming from the plugin.
Forum: Plugins
In reply to: [Multisite Language Switcher] International SEOPlease, remain in the thread that you started already: https://ww.wp.xz.cn/support/topic/i-wanted-to-add-x-default-tag-to-every-page-of-my-website/
How can you conditionally check if a translation exists? How can you retrieve the URL of the translation of the current page in another language?
You can probably hook into msls_filter_string (read on here https://msls.co/developer-docs/hook-reference/) or use an API function like get_msls_permalink() (read on here https://msls.co/developer-docs/api-functions/).
For the question that started the thread: MSLS will add “alternate” links for the “hreflang” in the header. As an example, the output at https://msls.co/:
<link rel="alternate" hreflang="de" href="https://msls.co/de/" title="Deutsch" />
<link rel="alternate" hreflang="en" href="https://msls.co/" title="English" />You can customize the outcome by using filter-hooks:
For a single result with no translation
add_filter( 'mlsl_output_get_alternate_links_default', function( string $default ) {
// your code here
return $default;
} );For an array of contents including the current content
add_filter( 'mlsl_output_get_alternate_links_arr', function ( array $arr ) {
// your code here
return $arr;
} );Forum: Plugins
In reply to: [Multisite Language Switcher] Hreflang tag issuesHey, thanks for the message. Can you elaborate a bit what you’d like to achieve?
Forum: Plugins
In reply to: [Multisite Language Switcher] New Japanese Posts Overwriting Previous PostsI would need more information. How is your setup, which version uses it? How are the languages set?