我创建了一个自定义评论系统,当人们输入视频短代码时,它不会显示视频,而只显示echo的短代码。
我理解do\\u shortcode();命令,但注释可以包含注释和短代码。
有没有一个最佳实践可以让shortscodes发挥作用?
谢谢
-查基
编辑这是我的功能:
function display_match_comments() {
global $current_user; wp_get_current_user();
global $match_id;
global $wpdb;
global $comment_success;
echo \'<div class="latest_results" style="background:#ffffff; text-align:left !important;"">\';
echo \'<h6 style="text-align:center !important;">User Comments and Pictures\';
if ( is_user_logged_in() ) {
echo \' <a href="#add_comment">Add Comment</a>\';
}
echo \'</h6>\';
$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</span>\'; }
foreach($row2 as $row2) {
if(!$content_size){ $content_size = "one_half"; }
echo \'<div class="\'.$content_size.\'">\';
echo \'<div class="latest_results" style="background:#ffffff;">\';
echo \'<h6><a href="https://www.husupporters.club/forums/users/\'.$row2->comment_name.\'">\'.$row2->comment_name.\'</a></h6>\';
$comment_content = stripslashes_deep($row2->comment_content);
echo \'<span>\'.$comment_content.\'<br>\';
$react_id = $row2->id. \'_\' .$match_id;
echo do_shortcode(\'[reactions id="\'.$react_id.\'"]\');
echo \'</span><br>\';
$text_to_be_wrapped_in_shortcode = \'<span><a href="https://www.husupporters.club/wp-admin/admin.php?page=match_comments&id=\'.$row2->id.\'" class="gamedetail">Manage Comment</a></span>\';
echo do_shortcode( \'[UAS_role roles="administrator, moderator"]\' . $text_to_be_wrapped_in_shortcode . \'[/UAS_role]\' );
echo \'</div>\';
echo \'</div>\';
if ($content_size == "one_half") { $content_size = "one_half last_column"; goto skip2; }else{ $content_size = "one_half"; goto skip2; }
skip2:
}
echo \'<div id="add_comment" class="latest_results" style="background:#ffffff; text-align:left !important;"">\';
if ( is_user_logged_in() ) {
echo \'<h6 style="text-align:center !important;">Add your own comment and
pictures below</h6>\';
if(get_query_var( \'success\' ) != \'yes\') {
?>
<form method="POST" action="<?php the_permalink(); echo $match_id; ?>?success=yes">
<?php wp_editor($comment_content,"comment_content", array(\'textarea_rows\'=>12, \'editor_class\'=>\'comment_content_class\')); ?>
<input type="hidden" name="comment_name" value="<?php echo $current_user->user_login; ?>"/>
<input type="hidden" name="comment_gameid" value="<?php echo $match_id; ?>"/>
<input type="submit" name="submitComment" value="submit" />
</form>
<?php
}
$default_comment = array(
\'comment_name\' => \'\',
\'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 \'<span>Your comment has been sent for approval</span><br>\'; }
}else{
echo \'<h6 style="text-align:center !important;"> you must be <a href="https://www.husupporters.club/login-register/">logged in</a>
to comment</h6>\';
}
echo \'</div>\';
echo \'</div>\';
}
这是显示注释的部分
$comment_content = stripslashes_deep($row2->comment_content);
echo \'<span>\'.$comment_content.\'<br>\';
在此范围内,有人可以使用[视频]短代码,但它显示的是短代码文本,而不是视频。