function sst_if_logged_in_shortcode( $atts, $content = null ) {
 if ( is_user_logged_in() ) {
 return do_shortcode( $content );
 }
 return '';
}
add_shortcode( 'if_logged_in', 'sst_if_logged_in_shortcode' );

function stt_user_greeting() {
 if ( is_user_logged_in() ) {
 $user = wp_get_current_user();
 return 'Halo, ' . esc_html( $user->display_name );
 }
 return '';
}
add_shortcode( 'user_greeting', 'stt_user_greeting' ); // <-- TAMBAHKAN BARIS INI
function stt_report_absensi_link() {
 if ( current_user_can( 'manage_options' ) ) {
 // Admin: ke report ALL
 return 'https://solusitransformateknologi.com/employee-absence/';
 }
 // Non-admin: ke report per user
 return 'https://solusitransformateknologi.com/e/';
}
add_shortcode( 'report_absensi_link', 'stt_report_absensi_link' );
function stt_force_login_whitelist( $whitelist ) {
 // Contoh: izinkan halaman depan & contact dibuka tanpa login
 $whitelist[] = home_url( '/' ); // homepage
 // $whitelist[] = home_url( '/contact/' ); // kalau ada halaman contact

 return $whitelist;
}
add_filter( 'v_forcelogin_whitelist', 'stt_force_login_whitelist' );
function stt_protect_absensi_pages() {
 if ( is_page( array( 'absensi', 'e', 'employee-absence' ) ) ) {
 if ( ! is_user_logged_in() ) {
 // Redirect ke halaman login WordPress
 wp_redirect( wp_login_url( get_permalink() ) );
 exit;
 }
 }
}
add_action( 'template_redirect', 'stt_protect_absensi_pages' );
// Hitung gagal login per IP dan redirect ke page khusus setelah 3x gagal
