Skip to content
Snippets Groups Projects
Commit 2e70413f authored by Erick Hitter's avatar Erick Hitter
Browse files

Support string notation for plugin options, in addition to preferred array notation.

WP has set the expectation that arguments can be specified as strings joined by ampersands. While I think it's an unnecessarily-confusing way of specifying arguments, some users seem to like it.

See http://wordpress.org/support/topic/unable-to-customise-plugin-behaviour-in-non-widget-implementation.
parent 37309408
No related branches found
No related tags found
No related merge requests found
......@@ -257,7 +257,7 @@ class taxonomy_dropdown_widget_plugin {
/**
* Sanitize plugin options
* @param array $options
* @param array|string $options
* @uses taxonomy_exists
* @uses sanitize_text_field
* @uses absint
......@@ -265,6 +265,12 @@ class taxonomy_dropdown_widget_plugin {
* @return array
*/
public function sanitize_options( $options ) {
// WP supports strings for arguments in place of arrays.
// Match the expectation, though arrays are preferred.
if ( is_string( $options ) ) {
wp_parse_str( $options, $options );
}
$options_sanitized = array(
'hide_empty' => true,
'post_counts' => false,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment