我有一个要在执行PHP函数时切换的模式。
模式代码
<div class="modal-normalise modal fade" tabindex="-1" role="dialog" id="free-modal">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><i class="far fa-times-circle"></i></button>
<br>
<img class="img-center img-responsive" src="/wp-content/themes/x/assets/images/x@2x.png">
</div>
<div class="modal-body text-center">
<p class="login-title head-title">test</p>
<?php echo do_shortcode('[mepr-login-form]'); ?>
<p class="subtitle fancy"><span>OR</span></p>
<?php echo do_shortcode('[nextend_social_login]'); ?>
<p class="login-title join-title">Not a member? Join now!</p>
<a href="/join/" class="btn btn-fg">Join Now</a>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
当前php代码
// x
if (get_user_subscr_level() == "X") {
echo '<script type="text/javascript"> $("#free-modal").modal("show")</script>';
} elseif (get_user_subscr_level() != "X") {
echo '<script type="text/javascript"> $("#free-modal").modal("show")</script>';
};
在上述情况下,没有显示#free-modal
尝试了echo js代码的多种变体