From 2e70413f327ed0c7bc3dce213377cb03569bbd4f Mon Sep 17 00:00:00 2001 From: Erick Hitter <ehitter@gmail.com> Date: Sun, 29 Dec 2013 17:22:13 -0500 Subject: [PATCH] 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. --- tag-dropdown-widget.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tag-dropdown-widget.php b/tag-dropdown-widget.php index e5259d1..8f582e1 100644 --- a/tag-dropdown-widget.php +++ b/tag-dropdown-widget.php @@ -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, -- GitLab