'abds_ln_bot_token', 'nt_chat_id' => 'abds_ln_chat_id', 'nt_enabled' => 'abds_ln_enabled', ) as $old => $new ) { $v = get_option( $old, null ); if ( null !== $v && '' === (string) get_option( $new, '' ) ) { update_option( $new, $v ); } } /** Lets the Pro add-on run its own migrations (e.g. ensure its chat tables). */ do_action( 'abds_connect_migrate' ); } add_action( 'admin_init', 'abds_connect_migrate' ); /* ------------------------- Налаштування ------------------------- */ /** * Registers the free plugin's own setting: the shared licence key (read by * both this plugin and, once installed, the Pro add-on). */ function abds_connect_register_core() { register_setting( 'abds_connect', 'abds_license_key', array( 'sanitize_callback' => 'sanitize_text_field', 'default' => '', ) ); } add_action( 'admin_init', 'abds_connect_register_core' ); /** * The admin-menu icon as a base64 SVG data URI — a monochrome silhouette (a * chat bubble with three text-line cutouts, single flat grey fill), the same * pattern as ABDS SEO's own menu_icon(): WordPress dims a data-URI menu icon * via opacity rather than recoloring it per admin colour scheme, so a single * flat grey (not a per-scheme colour swap) is the correct source colour here. * The full-colour logo for real inline-image contexts (the settings page * header) lives separately in assets/img/icon.svg. * * Source: assets-wporg/menu-icon.svg, verified against the sidebar at 20/40/80px * — used as-is, not redrawn. * * @return string A data:image/svg+xml;base64 URI. */ function abds_connect_menu_icon() { $svg = ''; // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.obfuscation_base64_encode -- encoding an inline SVG for a menu-icon data URI, not code obfuscation. return 'data:image/svg+xml;base64,' . base64_encode( $svg ); } /** * Registers the top-level ABDS Connect admin menu page. */ function abds_connect_menu() { $hook = add_menu_page( 'ABDS Connect', 'ABDS Connect', 'manage_options', 'abds-connect', 'abds_connect_page', abds_connect_menu_icon(), 58 ); add_action( 'admin_enqueue_scripts', function ( $current_hook ) use ( $hook ) { abds_connect_enqueue_settings_assets( $current_hook, $hook ); } ); $plans_hook = add_submenu_page( 'abds-connect', __( 'Plans', 'abds-connect' ), __( 'Plans', 'abds-connect' ), 'manage_options', 'abds-connect-plans', 'abds_connect_render_plans_page' ); add_action( 'admin_enqueue_scripts', function ( $current_hook ) use ( $plans_hook ) { abds_connect_enqueue_plans_assets( $current_hook, $plans_hook ); } ); } add_action( 'admin_menu', 'abds_connect_menu' ); /** * Loads the Plans screen's CSS, only on that one screen. * * @param string $current_hook The hook suffix of the screen being rendered. * @param string $our_hook The Plans screen's own hook suffix. */ function abds_connect_enqueue_plans_assets( $current_hook, $our_hook ) { if ( $current_hook !== $our_hook ) { return; } wp_enqueue_style( 'abds-connect-tokens', ABDS_CONNECT_URL . 'assets/css/tokens.css', array(), ABDS_CONNECT_VER ); wp_enqueue_style( 'abds-connect-plans', ABDS_CONNECT_URL . 'assets/css/plans-page.css', array( 'abds-connect-tokens' ), ABDS_CONNECT_VER ); } /** * Renders the Plans screen from its own partial (no markup in this file). */ function abds_connect_render_plans_page() { if ( ! current_user_can( 'manage_options' ) ) { return; } $pro = abds_is_pro(); require ABDS_CONNECT_DIR . 'includes/admin/plans-page.php'; } /** * Loads the settings screen's JS/CSS, only on that one screen. * * @param string $current_hook The hook suffix of the screen being rendered. * @param string $our_hook The ABDS Connect settings screen's own hook suffix. */ function abds_connect_enqueue_settings_assets( $current_hook, $our_hook ) { if ( $current_hook !== $our_hook ) { return; } wp_enqueue_style( 'abds-connect-tokens', ABDS_CONNECT_URL . 'assets/css/tokens.css', array(), ABDS_CONNECT_VER ); wp_enqueue_style( 'abds-connect-admin', ABDS_CONNECT_URL . 'assets/css/admin-settings.css', array( 'abds-connect-tokens' ), ABDS_CONNECT_VER ); wp_enqueue_script( 'abds-connect-admin', ABDS_CONNECT_URL . 'assets/js/admin-settings.js', array( 'wp-i18n' ), ABDS_CONNECT_VER, true ); wp_set_script_translations( 'abds-connect-admin', 'abds-connect', ABDS_CONNECT_DIR . 'languages' ); wp_localize_script( 'abds-connect-admin', 'abdsConnectSettings', array( 'ajaxUrl' => admin_url( 'admin-ajax.php' ), 'nonce' => wp_create_nonce( 'abds_connect_test_message' ), ) ); } /** * Adds a "Налаштування" (Settings) link to the plugin's row on the Plugins * screen. * * @param string[] $links Existing action links. * @return string[] */ function abds_connect_action_links( $links ) { $links[] = '' . esc_html__( 'Settings', 'abds-connect' ) . ''; return $links; } add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), 'abds_connect_action_links' ); /** * Renders the ABDS Connect settings page: the leads → Telegram module, the * detected form sources, the licence field, and (via action hooks) the Pro * add-on's own sections when it's installed. Native wp-admin `.card` groups, * in onboarding order — Telegram first, since it's the only thing a fresh * install needs before it does anything useful. */ function abds_connect_page() { if ( ! current_user_can( 'manage_options' ) ) { return; } $pro = abds_is_pro(); $has_token = '' !== trim( (string) get_option( 'abds_ln_bot_token', '' ) ); $tg = abds_ln_telegram_status(); ?>
ABDS Connect Pro' // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- static trusted brand-name markup, not user input. ); ?>
%s