get_contents( VELISCHAT_PATH . 'assets/images/velischat-menu-icon.svg' ) ), // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.obfuscation_base64_encode -- the plugin's own menu icon, as a data URI 80 ); $hooks[] = add_submenu_page( 'velischat', __( 'Settings', 'velischat' ), __( 'Settings', 'velischat' ), 'manage_options', 'velischat', 'velischat_render_admin_page' ); $hooks[] = add_submenu_page( 'velischat', __( 'Instructions and content', 'velischat' ), __( 'Instructions and content', 'velischat' ), 'manage_options', 'velischat-contents', 'velischat_render_contents_page' ); $hooks[] = add_submenu_page( 'velischat', __( 'Design and texts', 'velischat' ), __( 'Design and texts', 'velischat' ), 'manage_options', 'velischat-design', 'velischat_render_design_page' ); $hooks[] = add_submenu_page( 'velischat', __( 'Contact form', 'velischat' ), __( 'Contact form', 'velischat' ), 'manage_options', 'velischat-contact-form', 'velischat_render_contact_form_page' ); $hooks[] = add_submenu_page( 'velischat', __( 'Setup wizard', 'velischat' ), __( 'Setup wizard', 'velischat' ), 'manage_options', 'velischat-wizard', 'velischat_render_wizard_page' ); $hooks[] = add_submenu_page( 'velischat', __( 'Support', 'velischat' ), __( 'Support', 'velischat' ), 'manage_options', 'velischat-support', 'velischat_render_support_page' ); // The upgrade banner at the bottom of every plugin page, after the page itself foreach( array_unique( array_filter( $hooks ) ) as $hook ){ add_action( $hook, 'velischat_render_upgrade_banner', 20 ); } } add_action( 'admin_menu', 'velischat_admin_menu' ); function velischat_admin_enqueue_scripts( $hook ){ // Only load assets on the plugin's admin pages if( strpos( $hook, 'velischat' ) === false ){ return; } wp_enqueue_style( 'velischat-admin', VELISCHAT_URL . 'assets/css/admin.css', array(), filemtime( VELISCHAT_PATH . 'assets/css/admin.css' ) ); wp_enqueue_script( 'velischat-admin', VELISCHAT_URL . 'assets/js/admin.js', array( 'jquery' ), filemtime( VELISCHAT_PATH . 'assets/js/admin.js' ), true ); // Fonts for the font choice and the color preview of the "Design e testi" page if( $hook === 'toplevel_page_velischat' || strpos( $hook, 'velischat-design' ) !== false ){ foreach( velischat_get_fonts() as $font_key => $config ){ wp_enqueue_style( 'velischat-font-' . $font_key, VELISCHAT_URL . $config[ 'css' ], array(), filemtime( VELISCHAT_PATH . $config[ 'css' ] ) ); } } } add_action( 'admin_enqueue_scripts', 'velischat_admin_enqueue_scripts' ); function velischat_sanitize_rate_limit_max( $value ){ // Between 1 and 1000 requests an hour, 30 when left empty $value = absint( $value ); return $value ? min( 1000, $value ) : 30; } function velischat_sanitize_max_chat_messages( $value ){ // Between 0 (no limit) and 1000 messages of one conversation, the default number when left empty return '' === trim( (string) $value ) ? '' : (string) min( 1000, absint( $value ) ); } function velischat_sanitize_checkbox( $value ){ // Store checkboxes as '1' or '' return $value ? '1' : ''; } function velischat_sanitize_display_mode( $value ){ // Only the two supported layouts are accepted return $value === 'compact' ? 'compact' : 'extended'; } function velischat_sanitize_compact_offset( $value ){ // Distance of the compact icon from the page edge, in px. Empty keeps the default distance if( $value === '' || $value === null ){ return ''; } return (string) min( absint( $value ), 1000 ); } function velischat_get_default_compact_icon(){ // Default launcher icon of the compact layout: the VelisChat logo in a blue circle return VELISCHAT_URL . 'assets/images/velischat-launcher.svg'; } function velischat_get_compact_icon(){ // Icon of the compact layout: the plugin's own, unless an add-on gives another one return (string) apply_filters( 'velischat_compact_icon', velischat_get_default_compact_icon() ); } function velischat_get_site_logo(){ // Logo at the top of the chat and of the conversation PDF: none, unless an add-on gives one return (string) apply_filters( 'velischat_site_logo', '' ); } function velischat_get_floating_image(){ // Icon next to the text field: the plugin's own, unless an add-on gives another one return (string) apply_filters( 'velischat_floating_image', velischat_get_default_floating_image() ); } function velischat_get_default_floating_image(){ // Default icon next to the text field: the VelisChat symbol return VELISCHAT_URL . 'assets/images/velischat-symbol.png'; } function velischat_format_dollars( $value ){ // Price in dollars written the Italian way: "0,50 $", "24 $" return number_format_i18n( $value, $value < 10 ? 2 : 0 ) . ' $'; } function velischat_render_ai_pricing_dialog( $providers ){ // Popup with the list prices of the AI services and how many conversations a million tokens are (admin.js opens it) $conversations = wp_list_pluck( wp_list_pluck( $providers, 'pricing' ), 'conversations' ); ?>
Connectors and what to do if // not: only the chosen one is shown (admin.js switches them). Used in the settings and in the wizard $providers = velischat_get_ai_providers(); $provider = velischat_get_ai_provider(); $moved = isset( $_GET[ 'velischat_key' ] ) ? sanitize_key( wp_unslash( $_GET[ 'velischat_key' ] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- only says which message to show, after velischat_move_legacy_api_key() ?>