As documented (always read the docs), printf()
returns:
…the length of the outputted string.
That’s why you’re getting 30.
If you’re adding a value to an array or a string you need to use a function that returns a value. Not one that prints. printf()
prints the value and returns the length of the printed value. To return a formatted string, you need to use sprintf()
:
'label' => sprintf( __('Option to share on %s', 'theme-name'), 'name'),
See here for more on the difference between returning and printing/echoing.