WordPress主要有一个很好的功能wp_localize_script
要使用它,请首先将脚本排队:
wp_enqueue_script( \'My_Script_handle\', \'path/to/script.js\' );
 然后创建要本地化的字符串数组:
$data = array( 
   \'exit\' => __( \'Exit\',\'my-plugin-domain\' ),
   \'open\' => __( \'Open\',\'my-plugin-domain\' ),
   \'close\' => __( \'Close\',\'my-plugin-domain\' ),
   \'next\' => __( \'Next\',\'my-plugin-domain\' ),
   \'previous\' => __( \'Previous\',\'my-plugin-domain\' )
);
 并使用wp\\u localize\\u脚本调用它
wp_localize_script( \'My_Script_handle\', \'mystrings\', $data );
 然后,您可以使用JavaScript在页面中访问它,如下所示:
alert(mystrings.exit);
alert(mystrings.open);
 。。。
你明白了。