block. * * @return void */ public function enqueue_color_vars(): void { $color = get_option( self::OPT_PRIMARY_COLOR, self::DEFAULT_COLOR ); // Validate hex color. if ( ! preg_match( '/^#[0-9A-Fa-f]{6}$/', $color ) ) { $color = self::DEFAULT_COLOR; } if ( ! wp_style_is( 'aicommerce-brand', 'registered' ) ) { wp_register_style( 'aicommerce-brand', false, array(), AICOMMERCE_VERSION ); } wp_enqueue_style( 'aicommerce-brand' ); wp_add_inline_style( 'aicommerce-brand', ':root{--aicommerce-primary:' . sanitize_hex_color( $color ) . ';}' ); } /** * Replace plugin name in the admin page title. * * @param string $admin_title The admin page title. * * @return string Modified title. */ public function replace_admin_title( string $admin_title ): string { $custom_name = get_option( self::OPT_PLUGIN_NAME ); if ( empty( $custom_name ) ) { return $admin_title; } $custom_name = sanitize_text_field( $custom_name ); $admin_title = str_replace( 'Tyralix AI Discoverability', $custom_name, $admin_title ); $admin_title = str_replace( 'Tyralix AI Discoverability', $custom_name, $admin_title ); return $admin_title; } /** * Get the current white-label configuration. * * @return array{plugin_name: string, logo_url: string, primary_color: string} */ public function get_config(): array { return array( 'plugin_name' => get_option( self::OPT_PLUGIN_NAME, '' ), 'logo_url' => get_option( self::OPT_LOGO_URL, '' ), 'primary_color' => get_option( self::OPT_PRIMARY_COLOR, self::DEFAULT_COLOR ), ); } /** * Save white-label settings. * * @param array $data Settings data to save. * * @return void */ public function save_config( array $data ): void { if ( isset( $data['plugin_name'] ) ) { update_option( self::OPT_PLUGIN_NAME, sanitize_text_field( $data['plugin_name'] ), false ); } if ( isset( $data['logo_url'] ) ) { update_option( self::OPT_LOGO_URL, esc_url_raw( $data['logo_url'] ), false ); } if ( isset( $data['primary_color'] ) ) { $color = sanitize_hex_color( $data['primary_color'] ); if ( $color ) { update_option( self::OPT_PRIMARY_COLOR, $color, false ); } } } /** * Get the custom plugin name or default. * * @return string */ public static function get_plugin_name(): string { if ( self::is_agency() ) { $custom = get_option( self::OPT_PLUGIN_NAME ); if ( ! empty( $custom ) ) { return sanitize_text_field( $custom ); } } return 'Tyralix AI Discoverability'; } /** * Get the logo URL if set. * * @return string */ public static function get_logo_url(): string { if ( self::is_agency() ) { return get_option( self::OPT_LOGO_URL, '' ); } return ''; } }