我试图检查函数中获得的变量。php用于调试目的。我通过执行shortcode来获取当前登录的用户,定义了一个变量$current\\u user。然后我使用if语句来验证是否有当前登录的用户,在这种情况下,应该应用函数前面定义的CSS样式。它当前不起作用,因此我正在尝试研究$current\\u用户变量,但我尝试过的所有变体都不起作用,包括error\\u log。
功能。php(片段):
add_shortcode(\'show_css_code_conditionally\', \'show_css_code_conditionally_fn\');
function show_css_code_conditionally_fn($atts) {
ob_start(); ?>
// CSS code to show the button conditionally
<style type="text/css">
.special-button {
display: block !important;
}
</style> <?php
$CSS_output = ob_get_clean();
$current_user = do_shortcode(\'[wpv-current-user]\');
error_log($current_user);
echo($current_user);
echo do_shortocde(\'[wpv-current-user]\');
print \'zzzy\';
?><pre><?php var_dump( $current_user ); echo do_shortocde(\'[wpv-current-user]\'); print \'zzzy\'; ?></pre><?php
if ($current_user) {
// this is confirmed that the user is logged in
return $CSS_output;
}
}