我已经创建了一个自定义评论系统,当人们输入视频短代码时,它不会显示视频,而只是回显出了短代码。
我理解do_shortcode();命令,但是注释可以包含注释和短代码。
有什么最佳的做法是让短分球工作吗?
谢谢
-Chalkie
编辑这是我的功能:
function display_match_comments() {
global $current_user; wp_get_current_user();
global $match_id;
global $wpdb;
global $comment_success;
echo '';
echo 'User Comments and Pictures';
if ( is_user_logged_in() ) {
echo ' Add Comment';
}
echo '';
$content_size = 'one_half';
$table_name = 'wp_match_comments';
$row2 = $wpdb->get_results( "SELECT * FROM $table_name WHERE comment_gameid = $match_id AND comment_moderation = '1'");
if(!$row2) { echo 'No Comments Found'; }
foreach($row2 as $row2) {
if(!$content_size){ $content_size = "one_half"; }
echo '';
echo '';
echo ''.$row2->comment_name.'';
$comment_content = stripslashes_deep($row2->comment_content);
echo ''.$comment_content.'
';
$react_id = $row2->id. '_' .$match_id;
echo do_shortcode('[reactions id="'.$react_id.'"]');
echo '
';
$text_to_be_wrapped_in_shortcode = 'Manage Comment';
echo do_shortcode( '[UAS_role roles="administrator, moderator"]' . $text_to_be_wrapped_in_shortcode . '[/UAS_role]' );
echo '';
echo '';
if ($content_size == "one_half") { $content_size = "one_half last_column"; goto skip2; }else{ $content_size = "one_half"; goto skip2; }
skip2:
}
echo '';
if ( is_user_logged_in() ) {
echo 'Add your own comment and
pictures below';
if(get_query_var( 'success' ) != 'yes') {
?>
12, 'editor_class'=>'comment_content_class')); ?>
'',
'comment_content' => '',
'comment_moderation' => '0',
'comment_gameid' => '',
);
$item = shortcode_atts( $default_comment, $_REQUEST );
if($_POST['submitComment']) {
$wpdb->prepare($wpdb->insert( $table_name, $item ));
}
if(get_query_var( 'success' ) == 'yes') { echo 'Your comment has been sent for approval
'; }
}else{
echo ' you must be logged in
to comment';
}
echo '';
echo '';
}这是显示注释的部分。
$comment_content = stripslashes_deep($row2->comment_content);
echo ''.$comment_content.'
';其中有人可以使用短代码,但它显示的是短代码文本,而不是视频。
发布于 2021-01-03 20:27:33
如果您的一些评论将包含短代码,而有些则不包含这些代码,那么通过do_shortcode()运行它们并不会有什么害处。如果内容中没有短代码,它将被简单地返回,如果它包含了短代码,它们将被解析并返回内容。
所以你应该可以改变
echo ''.$comment_content.'
';至
echo do_shortcode( ''.$comment_content.'
' );https://wordpress.stackexchange.com/questions/380850
复制相似问题