The Multisite Language Switcher provides some filters and actions, which are very useful for programmers who want to interact with the plugin from their functions and classes.
And again: Always backup your files and database prior to work on your site, better safe than sorry.
Read first the introduction provided by the WordPress community if you don't know what hooks are.
If you want to change the link of the admin icon in case there is no object connected then this filter is for you. The default is that the link points to the 'create new page' of this object type.
This would add the parameter 'abc' with the value 'xyz' to the url path.
If you want to add custom input fields to the existing sections in the settings of the plugin then you can use one of these actions.
This would add an input field 'custom field' to the main-section of the settings-page.
If you want to add a completely customized settings section to the configuration-pages of the Multisite Language Switcher then you can use this action.
This would add a section with the id 'custom section' and an input field 'custom field' to the settings-page of the plugin.
You can use this filter if you want to add some custom validation for an input field in the configuration page of the plugin.
This can be useful if you have added your own input fields to this page using an action hook like 'msls_admin_register'.
You can easily manipulate the blog collection.
This would exclude the blog with the ID 1 from the collection.
The description string of every blog is not fixed. You can override it.
This would give the blog with the ID 1 the description 'abc' and the blog with the ID 2 the name 'xyz.
You can override the string for the output of the translation hint. $output contains the original string and $links is an array of generated links to the available translations.
You can use the following code if you want to remove this filter completely:
remove_action( 'the_content', 'msls_content_filter' );
The plugin creates automatically hreflang annotations in the head of the generated HTML using the code of the language only (eg. en, de, fr). You can easily override this value:
You can use the following code if you want to remove these tags completely:
remove_action( 'wp_head', 'msls_head' );
There is also a way to manipulate the inner HTML in the generated links. Just create your own MslsLink class.
This adds label tags to the descriptional text after the flag icon.
With this action you can call a completely customized save-routine.
Use this action only if you exactly know what you do!
You can change or hide the button of the meta box in the edit-screen with this filter.
This wraps the code of the submit-button into HTML comments.
Maybe you will find it useful to be able to override the WP_Query $args for the auto-complete search-field in the meta box which you can see in the edit-screen of the various post-types or taxonomies of your WordPress site.
This would limit the output of the results to a maximum of 5 posts.
This is only valid for hierarchical post types that use the HTML select (and not the new autocomplete inputs)in the meta box.
This adds various poststati to the array _$args for wp\dropdown_pages even if this function does not expect this. But inside the function is a call to get\pages_ that can use this param.
You can even manipulate the WP_Post- or Term-objects in the result-set created in 'msls_meta_box_suggest_args' or 'msls_post_tag_suggest_args'.
This would add the post_id to the title of the posts in the autocomplete-field of the meta box.
You can create a custom function to filter the available languages used in the language section of the plugin-settings.
Even if it is still not fully tested, it seems to be a smart way to add a language without the language files installed. In this case it would solve the issue with the American flag and the Union Jack.
You can set the path to the flag-icons in the admin settings of the plugin but you can also override the path with a filter.
This 'sets' the path to the flag icons to the directory 'images' in the active theme.
I decided to add a filter to the implementation of get_permalink in the plugin so that I can offer a workaround for the issues with the possibility to localize the slugs of custom post types.
This replaces the 'products'-part in the URL with 'produkte' if $language is 'de_DE'.
You can use this filter if you want to change the format of the generated links to the translations in your blog.
This would transform the absolute URL in a relative one and would add the css-class 'current' to the link of the current blog.
You can configure the output-tags in the admin settings of the plugin but you can also override these with a filter.
This would override completely the configuration without looking for existing values.