推荐:在customizer.php的翻译函数中找到可能的变量$i

问题描述 投票:0回答:1

我正在从插件主题检查器检查我的主题并收到以下消息:

推荐:在 inc/customizer.php 的翻译函数中找到可能的变量 $i。

我在定制器中使用循环,如下所示:

类别定制器

$category_count = 4;

for ($i=1; $i <= $category_count ; $i++) { 
$wp_customize->add_setting( 'set_category'.$i, array(
'default'           => 0,
'sanitize_callback' => 'absint',
) );

$wp_customize->add_control( new My_Dropdown_Category_Control( $wp_customize, 'set_category'.$i, array(
'section'       => 'sec_home_page',
'label'         => __( 'Select the category '.$i, 'pahla-store' ),
'description'   => __( 'If no category is selected, the category will be disabled.', 'pahla-store' ),
) ) );
}

我从 stackoverflow 搜索但找不到有用的答案。我期待提供解决方案以通过主题检查插件传递我的主题。

wordpress wordpress-theming theme-development
1个回答
0
投票

您不应在字符串翻译中使用变量。

相反,您应该使用 sprintf 将变量添加到翻译中,例如:

sprintf( __( 'Select the category %d', 'pahla-store' ), $i);
© www.soinside.com 2019 - 2024. All rights reserved.