HEX
Server: nginx/1.28.3
System: Linux VM-0-7-opencloudos 6.6.117-45.oc9.x86_64 #1 SMP Thu Dec 4 10:26:39 CST 2025 x86_64
User: www (1000)
PHP: 8.2.28
Disabled: passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv
Upload Files
File: /www/wwwroot/www.213n.cn/wp-content/themes/rk-blogger/wbc/settings/vite.php
<?php
// Helpers here serve as example. Change to suit your needs.
const VITE_HOST = 'http://localhost:5173';

// For a real-world example check here:
// https://github.com/wp-bond/bond/blob/master/src/Tooling/Vite.php
// https://github.com/wp-bond/boilerplate/tree/master/app/themes/boilerplate

// you might check @vitejs/plugin-legacy if you need to support older browsers
// https://github.com/vitejs/vite/tree/main/packages/plugin-legacy



// Prints all the html entries needed for Vite

function vite(string $entry): string
{
  return "\n" . jsTag($entry)
    . "\n" . jsPreloadImports($entry)
    . "\n" . cssTag($entry);
}


// Some dev/prod mechanism would exist in your project

function isDev(string $entry): bool
{
  // This method is very useful for the local server
  // if we try to access it, and by any means, didn't started Vite yet
  // it will fallback to load the production files from manifest
  // so you still navigate your site as you intended!

  // static $exists = null;
  // if ($exists !== null) {
  //   return $exists;
  // }

  // $handle = curl_init(VITE_HOST . '/' . $entry);
  // curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
  // curl_setopt($handle, CURLOPT_NOBODY, true);

  // curl_exec($handle);
  // $error = curl_errno($handle);
  // curl_close($handle);

  // return $exists = !$error;
  return false;
}


// Helpers to print tags

function jsTag(string $entry): string
{
  $url = isDev($entry)
    ? VITE_HOST . '/' . $entry
    : assetUrl($entry);

  if (!$url) {
    return '';
  }
  if (isDev($entry)) {
    return '<script type="module" src="' . VITE_HOST . '/@vite/client"></script>' . "\n"
      . '<script type="module" src="' . $url . '"></script>';
  }
  return '<script type="module" src="' . $url . '"></script>';
}

function jsPreloadImports(string $entry): string
{
  if (isDev($entry)) {
    return '';
  }

  $res = '';
  foreach (importsUrls($entry) as $url) {
    $res .= '<link rel="modulepreload" href="'
      . $url
      . '">';
  }
  return $res;
}

function cssTag(string $entry): string
{
  // not needed on dev, it's inject by Vite
  if (isDev($entry)) {
    return '';
  }

  $tags = '';
  foreach (cssUrls($entry) as $url) {
    $tags .= '<link rel="stylesheet" href="'
      . $url
      . '">';
  }
  return $tags;
}


// Helpers to locate files

function getManifest(): array
{
  $manifest_path = get_theme_file_path('wbc/settings/assets/.vite/manifest.json');
  $content = file_get_contents($manifest_path);

  return json_decode($content, true);
}

function assetUrl(string $entry): string
{
  $manifest = getManifest();

  return isset($manifest[$entry])
    ? get_theme_file_uri('wbc/settings/assets/' . $manifest[$entry]['file'])
    : '';
}

function importsUrls(string $entry): array
{
  $urls = [];
  $manifest = getManifest();

  if (!empty($manifest[$entry]['imports'])) {
    foreach ($manifest[$entry]['imports'] as $imports) {
      $urls[] = get_theme_file_uri('wbc/settings/assets/' . $manifest[$imports]['file']);
    }
  }
  return $urls;
}

function cssUrls(string $entry): array
{
  $urls = [];
  $manifest = getManifest();

  if (!empty($manifest[$entry]['css'])) {
    foreach ($manifest[$entry]['css'] as $file) {
      $urls[] = get_theme_file_uri('wbc/settings/assets/' . $file);
    }
  }
  return $urls;
}