Complete the code to check if a user is logged in WordPress.
<?php if ([1]()) { echo 'User is logged in'; } ?>
The function is_user_logged_in() returns true if a user is logged in, which is essential for security checks.
Complete the code to sanitize user input in WordPress.
<?php $safe_input = [1]($_POST['user_input']); ?>
sanitize_text_field() cleans input to prevent harmful data, which is important for security.
Fix the error in the code to properly enqueue a secure script in WordPress.
<?php wp_enqueue_script('my-script', get_template_directory_uri() . '/js/script.js', array(), [1], true); ?>
The version parameter should be a string like '1.0.0' to help with cache busting and security.
Fill both blanks to create a nonce field for security in a WordPress form.
<?php wp_nonce_field([1], [2]); ?>
The first parameter is the action name, and the second is the name of the nonce field. Both are strings.
Fill all three blanks to verify a nonce in WordPress before processing form data.
<?php if (isset($_POST[[1]]) && wp_verify_nonce($_POST[[2]], [3])) { /* process form */ } ?>
The nonce field name is used in both isset and wp_verify_nonce calls, and the action name is the second parameter in wp_verify_nonce.