=== Dropdown Multisite Selector ===

Contributors: alordiel
Tags: multisite, dropdown, redirect, select, network
Requires at least: 6.0
Tested up to: 7.1
Stable tag: 1.0.0
Requires PHP: 8.3
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Build a configurable dropdown whose options redirect visitors to the URLs you choose: network sites, or your own custom links.

== Description ==

This plugin lets you build a fully configurable dropdown field whose options act as links: when a visitor picks one, they are redirected to the matching URL. It was originally built for multisite networks to make navigation between subsites faster, but it now supports custom links as dropdown options too.

= Ways to populate the dropdown =

* **Manual list** - define each option yourself: enter a name and the URL the visitor is redirected to when they choose it.
* **All network sites** - automatically list every site in your WordPress Multisite Network as an option.
* **The user's sites only** - list only the network sites where the current logged-in user is registered.

= What you can customize =

* **Label** - set a label for the dropdown, or leave it empty for no label.
* **Placeholder** - the first, non-clickable option (for example "Select branch", "Select country", "Choose side").
* **Sorting** - order your manual list alphabetically, or reverse it so your most recent entries appear first.
* **Behaviour** - send the visitor to the selected URL, or treat the URLs as images and load the chosen one into the `[dms_target]` container on the same page, without leaving it.

Once your settings are saved, display the dropdown with the `[dms]` shortcode or the bundled widget.

= Shortcodes =

**[dms]** - Renders the dropdown exactly as configured on the admin settings page.

**[dms_manual name="" placeholder="" target="" options=""]** - Renders a standalone dropdown that is independent of your saved settings. Accepts these attributes:

* `name` - the dropdown label (leave empty for no label).
* `placeholder` - the first option shown in the menu (for example "-- Select --").
* `target` - "default" to open links in the same tab, or "blank" to open them in a new tab.
* `options` - comma-separated URL/name pairs in the form "url1|name1, url2|name2, url3|name3". The order within each pair is detected automatically, so "name|url" works too. Option names cannot contain a comma or a vertical bar, as both are used to separate the values.

Example:

`[dms_manual name="Label" placeholder="--Select--" target="blank" options="https://duckduckgo.com|Trusted search engine, https://google.bg|Tracking search engine"]`

**[dms_target]** - Marks the spot where the selected image is loaded. Place it anywhere on the same page as `[dms]` and set the behaviour to "Open in target section" on the settings page: choosing an option then swaps the image in this container instead of redirecting the visitor. If the behaviour is set to images but this shortcode is missing from the page, the dropdown shows a warning. Developers can also replace the container markup through the `dms_target_filter` filter.

Need extra functionality? Open an issue on [GitHub](https://github.com/alordiel/dropdown-multisite-selector) or ask in the support forum, and I'll see whether it can be added. Thanks to everyone who has shared ideas for improving this plugin.

= Filters =

Here are the filters you can use to modify the plugin's output:

* `dms_sites_arguments` - control the attributes passed to `get_sites()` when the "Show all sites in the WordPress Multisite Network" option is selected.
* `dms_multisite_pairs` - filter the results returned from `get_sites()`.
* `dms_users_sites` - control the sites when the "Show only the sites where the user is registered" option is selected.
* `dms_target_filter` - replace the markup returned by the `[dms_target]` shortcode.

== Installation ==

= From your WordPress dashboard =

1. Visit 'Plugins > Add New'.
1. Search for 'Dropdown Multisite Selector'.
1. Activate Dropdown Multisite Selector from your Plugins page. To start building your dropdown, go to Settings -> Dropdown Multisite.

= From WordPress.org =

1. Download 'Dropdown Multisite Selector'.
1. Upload the 'dropdown-multisite-selector' directory to your '/wp-content/plugins/' directory, using your favorite method (ftp, sftp, scp, etc...).
1. Activate it from your Plugins page.

== Screenshots ==

1. The admin part
2. The front end - widget area + shortcode in post

== Changelog ==

= 1.0.0 =
* Date: 12 September 2026
* Security patch
* Admin face lift
* [Added] Image behaviour: the dropdown can load the selected URL as an image into the new `[dms_target]` container instead of redirecting
* [Added] `dms_target_filter` filter, to replace the markup of the `[dms_target]` container
* Minimum required PHP raised to 8.3

= 0.9.5 =
* Date: 26 March 2025
* Security patch

= 0.9.4 =
* Date: 26 March 2025
* Maintenance: fixes to the automated WordPress.org deployment

= 0.9.3 =
* Date: 25 March 2025
* Maintenance: added automated deployment to the WordPress.org repository

= 0.9.2.1 =
* Date: 20 January 2024
* Security patch

= 0.9.2 =
* Date: 03 April 2023
* [Fix] PHP 8 deprecation notice
* [Fix] PHP 8 fatal error when saving content containing the [dms] shortcode (solved by @zodiac1978)

= 0.9.1 =
* Date: 10 April 2022
* [Fix] issue with the [dms_manual] shortcode

= 0.9.0 =
* Date: 10 April 2022
* Some more code refactored and organized
* [Added] Numeric sorting
* [Fix] [dms_manual] not working

= 0.8.6 =
* Date: 10 February 2022
* Applied the sorting fix to all options, not only to the network ones

= 0.8.5 =
* Date: 09 February 2022
* [Fix] Sorting now respects UTF-8 characters

= 0.8.4 =
* Date: 10 November 2021
* Applied changes from /trunk (deleted old files and folders)

= 0.8.3 =
* Date: 10 November 2021
* Merged a pull request from GitHub by @andykillen (the 'dms_sites_arguments' filter was never actually applied)
* https://github.com/alordiel/dropdown-multisite-selector/pull/14
* Spelling and typo fixes in the readme

= 0.8.2 =
* Date: 27 January 2021
* [Fix] Typo, and added one more parameter to the `get_sites()` function

= 0.8.1 =
* Date: 27 January 2021
* Increased the site limit for the network from 100 to 1000
* Merged a pull request (thanks to @lisandi https://github.com/alordiel/dropdown-multisite-selector/pull/10)

= 0.8.0 =
* Date: 27 January 2021
* [Added] Alphabetical sorting of blog names when the network options are used
* Removed a deprecated function, to support PHP 7.4
* The plugin's script and style are now loaded on the DMS settings page
* Some small code improvements and styling

= 0.7.0 =
* Date: 09 June 2020
* Thanks for the GitHub issues and code suggestions to @toremo and @zodiac1978
* And a huge apology to everyone who has been waiting for an update, and for making the code compatible with WP 5.x.x
* This update includes:
* Added a jQuery dependency for the plugin's script
* [Added] filter `dms_sites_arguments` - control the attributes when "Show all sites in the network" is selected
* [Added] filter `dms_multisite_pairs` - change the results returned from `get_sites()`
* [Added] filter `dms_users_sites` - control the sites when "Show only the sites where the user is registered" is selected
* Code styling brought in line with the WordPress Coding Standards (PHPCS)
* Small code fixes and clean-up
* Added default styles to the admin button

= 0.6.4 =
* [Fix] Redirect with target "blank" when an option without a value is selected

= 0.6.3 =
* [Fix] Issue with the WordPress repository and the last commit

= 0.6.2 =
* [Fix] Issue with including PHP files, and with trailing slashes on XAMPP and possibly some Windows server systems

= 0.6.1 =
* Implemented better security
* Folder restructuring
* Code refactoring

= 0.6 =
* [Added] Sorting options for the custom list of options
* Small refactoring and security improvements
* The "Add more" button was replaced with an option to add a new row after each row
* CSS and JS tweaks on the admin side

= 0.5 =
* [Fix] Deprecated function `wp_get_sites()`
* [Fix] Widget without a save button (plugins like Dynamic Widgets should now work)
* [Added] Shortcode with attributes

= 0.4.1 =
* [Fix] Some SVN issues

= 0.4 =
* [Fix] Some PHP notices
* [Added] Option to choose the name of the first option in the select field (thanks for the idea, @Ruth Maude)
* [Removed] The requirement for a label. You can now build the dropdown from the select element alone (option name and URL), without a label.

= 0.3.3 =
* [Fix] The previous release didn't work as expected - this one should fix the problem

= 0.3.2 =
* [Fix] Issues when updating from 0.1 to any higher version (thanks for reporting, @jfullerton)

= 0.3.1 =
* [Fix] Not working when two or more select fields are on the same page (thanks for reporting, @Steve Borsch)

= 0.2 =
* [Added] Widget option
* [Added] Automatically generated option list of all sites in the current WordPress Multisite Network
* [Added] Automatically generated option list of the sites in the current network where the logged-in user is registered
* [Fix] Problem with loading the JS before jQuery
* Code refactoring

= 0.1 =
* Start : )

== Upgrade Notice ==

= 1.0.0 =
Security fixes. This version requires PHP 8.3 or newer - sites running older PHP will not be offered the update.
