Login with SSO'; } add_shortcode( 'sso_login_button', 'sso_login_button_shortcode' ); /** * Enqueue scripts and styles. */ function sso_enqueue_scripts() { // Only enqueue the script if the shortcode is present on the page. // Note: This is a simplified check. A more robust solution might be needed for complex cases. global $post; if ( is_a( $post, 'WP_Post' ) && has_shortcode( $post->post_content, 'sso_login_button' ) ) { wp_enqueue_script( 'sso-login-script', plugin_dir_url( __FILE__ ) . 'js/sso-login.js', array(), '1.0.0', true ); // Pass the SSO URL to the script. // We'll make this dynamic with a settings page later. $sso_url = get_option('sso_plugin_url', 'http://localhost:5000/'); wp_localize_script( 'sso-login-script', 'ssoSettings', array( 'ssoUrl' => esc_url( $sso_url ), ) ); } } add_action( 'wp_enqueue_scripts', 'sso_enqueue_scripts' ); /** * Admin Menu and Settings */ // Add the settings page to the admin menu function sso_plugin_add_settings_page() { add_options_page( 'SSO Settings', 'SSO Login', 'manage_options', 'sso-plugin-settings', 'sso_plugin_render_settings_page' ); } add_action( 'admin_menu', 'sso_plugin_add_settings_page' ); // Render the settings page HTML function sso_plugin_render_settings_page() { ?>

SSO Login Settings

'string', 'sanitize_callback' => 'esc_url_raw', 'default' => '', ] ); add_settings_section( 'sso_plugin_main_section', 'Main Settings', null, 'sso_plugin_settings' ); } add_action( 'admin_init', 'sso_plugin_register_settings' );