Dennis Ploetner
Forum Replies Created
-
Forum: Plugins
In reply to: [Multisite Language Switcher] How to add to subheader menuI would suggest a slight change, because it would give you more flexibility and it is a bit more future-proof. You could use do_action when you want to print the output of MSLS in various parts of your templates. Let’s assume you just put this in your subheader:
<?php
$args = array(); // this could held some config
do_action( 'zwibasti_language_switcher_output', $args ); // this triggers an actionIn the functions.php (or in a custom plugin) you could have something like this:
<?php
function zwibasti_msls_print( array $args ): void {
if ( ! function_exists( 'the_msls' ) ) {
return;
}
$tags array(
'before_item' => '<li>',
'after_item' => '</li>',
'before_output' => '<ul class="your-css-class">,
'after_output' => '</ul>',
);
the_msls( wp_parse_args( $tags, $args ) );
}
add_action( 'zwibasti_language_switcher_output', 'zwibasti_msls_print' );What is the advantage? You can do it without looking in all files whenever you decide to change something or even use another solution. Also, with the centralized functionality, you can decide the minimal setup.
Forum: Plugins
In reply to: [Multisite Language Switcher] Manually create associationGreat! We can maybe give the importer some of the love it deserves. I will see what I can do there.
Forum: Plugins
In reply to: [Multisite Language Switcher] How to add to subheader menuWhere did you add the code? To a functions.php file in your theme or a custom plugin?
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://wordpress.org/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://wordpress.org/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/).