Skip to content

Commit 1aae76c

Browse files
apermoclaude
andcommitted
feat: make msls_get_switcher() $attr optional
Give $attr a default of array() so the documented template tag can be called with no arguments. The body already coerced any non-array value to array(), so $attr was effectively optional; the missing default made msls_get_switcher() throw an ArgumentCountError on the natural no-arg call. The parameter stays untyped to preserve the is_array() coercion, which keeps the [sc_msls] shortcode working (WordPress passes '' when a shortcode has no attributes). Closes #643 Co-Authored-By: Claude <noreply@anthropic.com>
1 parent f8d6cea commit 1aae76c

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

includes/api.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@
1010
* Get the output for using the links to the translations in your code
1111
*
1212
* @package Msls
13-
* @param mixed $attr
13+
* @since 3.0.0 The $attr parameter is optional and defaults to an empty array.
14+
* @param mixed $attr Optional. Attributes forwarded to the switcher output. Default empty array.
1415
* @return string
1516
*/
16-
function msls_get_switcher( $attr ): string {
17+
function msls_get_switcher( $attr = array() ): string {
1718
$arr = is_array( $attr ) ? $attr : array();
1819
$obj = apply_filters( 'msls_get_output', null );
1920

0 commit comments

Comments
 (0)