post_content, 'aio_redirect')) { // Enqueue the script for countdown functionality wp_register_script('aiosc_redirect_js', '', [], null, true); wp_enqueue_script('aiosc_redirect_js'); } } // Define the [aio_redirect] shortcode add_shortcode('aio_redirect', 'aiosc_do_redirect'); function aiosc_do_redirect($atts) { ob_start(); // Define default attributes for the shortcode $atts = shortcode_atts( array( 'url' => '', // URL for redirection 'sec' => '0', // Seconds to wait before redirect 'sec_text' => '', // Custom text after seconds numbers 'before_text' => '', // Custom before text 'after_text' => '', // Custom after text 'countdown' => 'yes', // Display countdown ("yes" or "no") 'sec_class' => '', // Custom class for the seconds element 'sec_text_class' => '', // Custom class for the sec_text element 'before_text_class' => '', // Custom class for the before_text element 'after_text_class' => '', // Custom class for the after_text element 'class' => '', // Custom class for the entire shortcode output ), $atts, 'aio_redirect' ); // Extract the attributes for easy access $myURL = esc_url($atts['url']); $mySEC = (int)$atts['sec']; $mySECtext = esc_html($atts['sec_text']); $mybeforetext = esc_html($atts['before_text']); $myafteretext = esc_html($atts['after_text']); $show_countdown = ($atts['countdown'] === 'yes'); $sec_class = esc_attr($atts['sec_class']); $sec_text_class = esc_attr($atts['sec_text_class']); $before_text_class = esc_attr($atts['before_text_class']); $after_text_class = esc_attr($atts['after_text_class']); $class = esc_attr($atts['class']); // Check if URL is empty, and return a message if it is if (empty($myURL)) { return 'No redirect URL provided.'; } // Output the HTML content for the redirect inside a tag ?>