我很难理解如何用WordPress转义翻译的字符串。。。
以下代码来自Wordpress codex:
function wpdocs_kantbtrue_init()
{
$args = array(
\'labels\' => array(
\'name\' => _x( \'Recipes\', \'Post type general name\', \'recipe\' ),
\'singular_name\' => _x( \'Recipe\', \'Post type singular name\', \'recipe\' ),
\'menu_name\' => _x( \'Recipes\', \'Admin Menu text\', \'recipe\' ),
\'name_admin_bar\' => _x( \'Recipe\', \'Add New on Toolbar\', \'recipe\' ),
\'add_new\' => __( \'Add New\', \'recipe\' ),
\'add_new_item\' => __( \'Add New recipe\', \'recipe\' ),
\'new_item\' => __( \'New recipe\', \'recipe\' ),
\'edit_item\' => __( \'Edit recipe\', \'recipe\' ),
...
)
);
register_post_type(\'Recipe\', $args);
}
add_action(\'init\', \'wpdocs_kantbtrue_init\');
我想我在某个地方读到过,所有的东西都应该转义,我很确定,\\uuu()函数不会转义任何东西,它只是返回翻译后的文本。。。
我在某处也看到过:
$wp_customize->add_setting(\'address\', array(
\'default\' => esc_html__(\'Enter your Address in this field\', \'themename\'),
\'sanitize_callback\' => \'sanitize_text_field\',
\'transport\' => \'postMessage\'
));
那么最安全的方法是什么呢?