Skip to content

Commit 5908a25

Browse files
remove sprintf usage in hot path
1 parent c77efb1 commit 5908a25

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

includes/integrations/class-integration.php

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -211,8 +211,9 @@ public function checkbox_was_checked()
211211
*/
212212
protected function get_wrapper_attributes()
213213
{
214+
$classes = join(' ', $this->wrapper_classes);
214215
$html_attrs = [
215-
'class' => sprintf('mc4wp-checkbox mc4wp-checkbox-%s %s', $this->slug, join(' ', $this->wrapper_classes)),
216+
'class' => "mc4wp-checkbox mc4wp-checkbox-{$this->slug} $classes",
216217
];
217218
return $this->array_to_attr_string($html_attrs);
218219
}
@@ -291,7 +292,7 @@ public function get_checkbox_html()
291292

292293
ob_start();
293294

294-
echo sprintf('<!-- Mailchimp for WordPress v%s - https://www.mc4wp.com/ -->', MC4WP_VERSION);
295+
echo '<!-- Mailchimp for WordPress v', MC4WP_VERSION,' - https://www.mc4wp.com/ -->';
295296

296297
/** @ignore */
297298
do_action('mc4wp_integration_before_checkbox_wrapper', $this);
@@ -303,13 +304,13 @@ public function get_checkbox_html()
303304
$wrapper_attrs = $this->get_wrapper_attributes();
304305

305306
// Hidden field to make sure "0" is sent to server
306-
echo sprintf('<input type="hidden" name="%s" value="0" />', esc_attr($this->checkbox_name));
307-
echo sprintf('<%s %s>', $wrapper_tag, $wrapper_attrs);
307+
echo '<input type="hidden" name="', esc_attr($this->checkbox_name), '" value="0" />';
308+
echo "<$wrapper_tag $wrapper_attrs>";
308309
echo '<label>';
309-
echo sprintf('<input type="checkbox" name="%s" value="1" %s />', esc_attr($this->checkbox_name), $this->get_checkbox_attributes());
310-
echo sprintf('<span>%s</span>', $this->get_label_text());
310+
echo '<input type="checkbox" name="', esc_attr($this->checkbox_name), '" value="1" ', $this->get_checkbox_attributes(), '>';
311+
echo '<span>', $this->get_label_text(), '</span>';
311312
echo '</label>';
312-
echo sprintf('</%s>', $wrapper_tag);
313+
echo "</$wrapper_tag>";
313314

314315
/** @ignore */
315316
do_action('mc4wp_integration_after_checkbox_wrapper', $this);
@@ -572,7 +573,10 @@ protected function array_to_attr_string(array $attrs)
572573
{
573574
$str = '';
574575
foreach ($attrs as $key => $value) {
575-
$str .= sprintf('%s="%s" ', $key, esc_attr($value));
576+
$str .= $key;
577+
$str .= '="';
578+
$str .= esc_attr($value);
579+
$str .= '"';
576580
}
577581
return $str;
578582
}

0 commit comments

Comments
 (0)