'' ), $atts, 'aivastark' ); $key = sanitize_text_field( (string) $atts['key'] ); aivastark_widget_enqueue( $key ); return ''; } ); /** * Site-wide rendering — runs on every front-end page when a key is configured. * * Must hook on wp_enqueue_scripts (not wp_footer): WordPress prints footer * scripts at wp_footer priority 20, so anything enqueued later in wp_footer * silently never reaches the page. Priority 20 here fires after the script * registration above (default priority 10). */ add_action( 'wp_enqueue_scripts', function () { if ( is_admin() ) { return; } $opts = aivastark_widget_get_options(); $key = trim( (string) $opts['widget_key'] ); if ( '' === $key ) { return; } aivastark_widget_enqueue( $key ); }, 20 );