<?php
if (! defined("\x41\x42\x53\x50\x41\x54\x48")) exit;   function unipixel_page_tiktok_setup() { global $wpdb; $platform_table = $wpdb->prefix . "\x75\x6E\x69\x70\x69\x78\x65\x6C\x5F\x70\x6C\x61\x74\x66\x6F\x72\x6D\x5F\x73\x65\x74\x74\x69\x6E\x67\x73"; $platformId = 3; $platformName = 'TikTok'; $pixelNameFriendly = 'TikTok Pixel';  $query = $wpdb->prepare(  "SELECT * FROM %i WHERE id = %d", $platform_table, $platformId );  $platform = $wpdb->get_row($query, ARRAY_A);  if ($platform) { $platform_id = (int) $platform["\x69\x64"]; $pixel_id = isset($platform["\x70\x69\x78\x65\x6C\x5F\x69\x64"]) ? $platform["\x70\x69\x78\x65\x6C\x5F\x69\x64"] : ""; $access_token = isset($platform["\x61\x63\x63\x65\x73\x73\x5F\x74\x6F\x6B\x65\x6E"]) ? $platform["\x61\x63\x63\x65\x73\x73\x5F\x74\x6F\x6B\x65\x6E"] : ""; $platform_enabled = isset($platform["\x70\x6C\x61\x74\x66\x6F\x72\x6D\x5F\x65\x6E\x61\x62\x6C\x65\x64"]) ? (int) $platform["\x70\x6C\x61\x74\x66\x6F\x72\x6D\x5F\x65\x6E\x61\x62\x6C\x65\x64"] : 0; $pixel_setting = isset($platform["\x70\x69\x78\x65\x6C\x5F\x73\x65\x74\x74\x69\x6E\x67"]) ? $platform["\x70\x69\x78\x65\x6C\x5F\x73\x65\x74\x74\x69\x6E\x67"] : "\x69\x6E\x63\x6C\x75\x64\x65"; $serverside_global_enabled = isset($platform["\x73\x65\x72\x76\x65\x72\x73\x69\x64\x65\x5F\x67\x6C\x6F\x62\x61\x6C\x5F\x65\x6E\x61\x62\x6C\x65\x64"]) ? (int) $platform["\x73\x65\x72\x76\x65\x72\x73\x69\x64\x65\x5F\x67\x6C\x6F\x62\x61\x6C\x5F\x65\x6E\x61\x62\x6C\x65\x64"] : 0; } else { $platform_id = 0; $pixel_id = ''; $access_token = ''; $platform_enabled = 1; $pixel_setting = 'include'; $serverside_global_enabled = 0; }  $icon_allow = unipixel_get_popover_allowlist(); ?>
    <div class="UniPixelShell position-relative">

        <div class="UniPixelSpinner d-none">
            <div class="spinner-border text-primary" role="status">
                <span class="visually-hidden"><?php echo esc_html__('Loading…', 'unipixel'); ?></span>
            </div>
        </div>

        <?php unipixel_render_platform_header_nav("\x74\x69\x6B\x74\x6F\x6B","\x73\x65\x74\x75\x70");?>

        <h1 class="mb-0">Tag <?php echo esc_html__('Setup', 'unipixel'); ?></h1>
        <p><small><?php echo esc_html__('Configure your connection and core settings for', 'unipixel'); ?> <?php echo esc_html($platformName); ?>.</small></p>

        <!-- Feedback message container (used by ajax-platform-settings.js) -->
        <div id="platform-settings-feedback-message" class="alert" role="alert" style="display:none;"></div>

    
        <!-- Platform (Tag/Connection) form -->
        <form id="platform-settings-form" class="form-horizontal">
            <input type="hidden" id="platform_id" name="platform_id" value="<?php echo esc_attr((string) $platform_id); ?>">

            <div class="mb-3 row">
                <div class="col-12 col-sm-3">
                    <label class="form-check-label" for="platform_enabled">
                        <?php echo esc_html__('Turn On/Enabled?', 'unipixel'); ?>
                        <?php echo wp_kses(unipixel_get_help_icon("\x54\x69\x6B\x54\x6F\x6B\x5F\x45\x6E\x61\x62\x6C\x65\x64"), $icon_allow); ?>
                    </label>
                </div>
                <div class="col-12 col-sm-9">
                    <div class="form-check form-switch">
                        <input class="form-check-input" type="checkbox" role="switch" id="platform_enabled" name="platform_enabled" value="1" <?php checked($platform_enabled, 1); ?>>
                    </div>
                </div>
            </div>

<div id="platform-fields">

            <div class="mb-3 row">
                <label class="col-sm-3 col-form-label"><?php echo esc_html__('Pixel Setting:', 'unipixel'); ?></label>
                <div class="col-sm-9">
                    <div class="form-check">
                        <input class="form-check-input" type="radio" name="pixel_setting" id="pixel_setting_include" value="include" <?php checked($pixel_setting, "\x69\x6E\x63\x6C\x75\x64\x65"); ?>>
                        <label class="form-check-label" for="pixel_setting_include">
                            <?php echo esc_html__('Include', 'unipixel'); ?> <?php echo esc_html($platformName); ?><?php echo esc_html__('\'s Tracking Pixel for me', 'unipixel'); ?>
                            <?php echo wp_kses(unipixel_get_help_icon("\x54\x69\x6B\x54\x6F\x6B\x5F\x49\x6E\x63\x6C\x75\x64\x65"), $icon_allow); ?>
                        </label>
                    </div>
                    <div class="form-check">
                        <input class="form-check-input" type="radio" name="pixel_setting" id="pixel_setting_already_included" value="already_included" <?php checked($pixel_setting, "\x61\x6C\x72\x65\x61\x64\x79\x5F\x69\x6E\x63\x6C\x75\x64\x65\x64"); ?>>
                        <label class="form-check-label" for="pixel_setting_already_included">
                            <?php echo esc_html($platformName); ?><?php echo esc_html__('\'s Tracking Pixel is already on my site', 'unipixel'); ?>
                            <?php echo wp_kses(unipixel_get_help_icon("\x54\x69\x6B\x54\x6F\x6B\x5F\x41\x6C\x72\x65\x61\x64\x79"), $icon_allow); ?>
                        </label>
                    </div>
                </div>
            </div>

            <div class="mb-3 row">
                <label for="pixel_id" class="col-sm-3 col-form-label">
                    <?php echo esc_html__('Pixel ID:', 'unipixel'); ?>
                    <?php echo wp_kses(unipixel_get_help_icon("\x54\x69\x6B\x54\x6F\x6B\x5F\x50\x69\x78\x65\x6C\x49\x64"), $icon_allow); ?>
                </label>
                <div class="col-sm-9">
                    <input type="text" id="pixel_id" name="pixel_id" class="form-control" value="<?php echo esc_attr($pixel_id); ?>" required>
                </div>
            </div>

            <div id="serverside-well" class="bg-light-blue">
                <p class="mb-1"><i class="fa-solid fa-bolt-lightning"></i> <strong><?php echo esc_html__('Server-Side Tracking', 'unipixel'); ?></strong></p>
                <p class="mb-2"><small><?php echo esc_html__('Supercharge your event tracking with TikTok\'s Events API. In addition to traditional client-side sending, events are sent directly from your server, bypassing ad blockers and browser restrictions. Events are matched-up at TikTok avoiding double counting and improving your measurement and reporting.', 'unipixel'); ?></small></p>

                <div class="mb-3 row">
                    <div class="col-12 col-sm-3">
                        <label class="form-check-label" for="serverside_global_enabled">
                            <?php echo esc_html__('Enable Server-Side Tracking', 'unipixel'); ?>
                            <?php echo wp_kses(unipixel_get_help_icon("\x53\x65\x72\x76\x65\x72\x53\x69\x64\x65\x47\x6C\x6F\x62\x61\x6C\x45\x6E\x61\x62\x6C\x65\x64"), $icon_allow); ?>
                        </label>
                    </div>
                    <div class="col-12 col-sm-9">
                        <div class="form-check form-switch">
                            <input class="form-check-input" type="checkbox" role="switch" id="serverside_global_enabled" name="serverside_global_enabled" value="1" <?php checked($serverside_global_enabled, 1); ?>>
                        </div>
                    </div>
                </div>

                <div id="serverside-fields">
                <div class="mb-3 row">
                    <label for="access_token" class="col-sm-3 col-form-label">
                        <?php echo esc_html__('Access Token:', 'unipixel'); ?>
                        <?php echo wp_kses(unipixel_get_help_icon("\x54\x69\x6B\x54\x6F\x6B\x5F\x41\x63\x63\x65\x73\x73\x54\x6F\x6B\x65\x6E"), $icon_allow); ?>
                    </label>
                    <div class="col-sm-9">
                        <input type="password" id="access_token" name="access_token" class="form-control" value="<?php echo esc_attr($access_token); ?>">
                    </div>
                </div>
                </div>
            </div>

</div>

            <div class="mb-3 row">
                <div class="col-sm-9 offset-sm-3">
                    <input type="submit" value="<?php echo esc_attr__('Update Settings', 'unipixel'); ?>" id="btnUniPixelUpdatePlatformSettings" name="btnUniPixelUpdatePlatformSettings" class="btn btn-primary">
                </div>
            </div>
        </form>
    </div>
    <?php
} 