这个comment_text
筛选器将注释作为其参数之一传递:
echo apply_filters( \'comment_text\', $comment_text, $comment, $args );
所以你不需要打电话
get_comment_ID()
, 您只需从
$comment
对象
更改:
add_filter( \'comment_text\', \'modify_comment\');
收件人:
add_filter( \'comment_text\', \'modify_comment\', 0, 3 );
然后:
function modify_comment( $comment_text, $comment, $args ){
wp_enqueue_script( \'cmt-player\', plugins_url( \'js/cmt-player.js\',__FILE__ ), array( \'jquery\' ), \'\', true );
$comment_id = absint( $comment->comment_ID );
$file_url = get_comment_meta( $comment_id, \'record_file\', true );
$site_parameters = array(
\'file_url\' => $file_url,
\'plugin_url\' => plugins_url(),
\'theme_directory\' => get_template_directory_uri(),
\'comment_id\' => $comment_id,
);
wp_localize_script( \'cmt-player\', \'wpvr_cmtvar\', $site_parameters );
require( \'lib/cmtplayer-interface.php\' );
}