更好的是,您可以使用WP的函数来实现这一点,例如多语言:
add_action( \'admin_enqueue_scripts\', \'add_scripts\' );
function add_scripts($where) {
wp_localize_script( \'post2media\', \'post2media_strings\', $this->localize_vars() );
}
function localize_vars() {
$strings = array(
\'btntext\' => __( \'Link with post\', INPSYDE_P2M_TEXTDOMAIN ),
\'txtallnone\' => __( \'Include in gallery:\', INPSYDE_P2M_TEXTDOMAIN ),
\'txtall\' => __( \'All\', INPSYDE_P2M_TEXTDOMAIN ),
\'txtnone\' => __( \'None\', INPSYDE_P2M_TEXTDOMAIN ),
\'ttlcb\' => __( \'Include image in this gallery\', INPSYDE_P2M_TEXTDOMAIN )
);
return $strings;
}
在js文件中使用:
jQuery(function ($) {
buttonaddfunc = function() {
btntext = post2media_strings.btntext;
reg = /\\d+/;
$( \'.savesend > .button\' ) . each( function() {
inputname = $( this ) . attr( \'name\' );
number = reg . exec( inputname );
$( this ) . after( \'<input type="submit" value="\' + btntext + \'" name="link[\' + number + \']" class="button">\' );
} );
$( \'.describe-toggle-on\' ).unbind( \'click\', buttonaddfunc );
};
$( \'.describe-toggle-on\' ).bind( \'click\', buttonaddfunc );
});
另请参见post from Otto