您应该使用wp_localize_script()
将调用countdown
方法我假设您将日期存储在一个名为date_name
喜欢January 1, 2015 13:30:00
.
在您的情况下,您将其存储为an array with month, day, year, and time in the correct format
, 所以您应该将其转换为January 1, 2015 13:30:00
总体安排
wp_enqueue_script( \'jsfilename\' );
$stored_date = get_option( \'date_name\', \'default value\' );
// process stored date so that it gets to the January 1, 2015 13:30:00 format
$date_options = array( \'mydate\' => $stored_date );
wp_localize_script( \'jsfilename\', \'dateopts\', $date_options );
然后在JS文件中调用:
$(\'.live-countdown\').countdown({ date: dateopts.mydate });