@wp-playground/wordpress 3.1.36 → 3.1.39

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.js CHANGED
@@ -1,8 +1,8 @@
1
- import { isLegacyPHPVersion as w, setPhpIniEntries as P, withPHPIniValues as N, sandboxedSpawnHandlerFactory as F, PHPRequestHandler as C, PHP as q, writeFiles as b } from "@php-wasm/universal";
2
- import { joinPaths as _, phpVar as $, phpVars as A, dirname as W, basename as G } from "@php-wasm/util";
3
- import { unzipFile as m, createMemoizedFetch as M } from "@wp-playground/common";
4
- import { logger as h } from "@php-wasm/logger";
5
- async function S(e) {
1
+ import { isLegacyPHPVersion as m, setPhpIniEntries as N, withPHPIniValues as A, sandboxedSpawnHandlerFactory as W, PHPRequestHandler as G, PHP as M, writeFiles as O } from "@php-wasm/universal";
2
+ import { joinPaths as a, phpVar as p, phpVars as P, dirname as B, basename as H } from "@php-wasm/util";
3
+ import { unzipFile as g, createMemoizedFetch as X } from "@wp-playground/common";
4
+ import { logger as d } from "@php-wasm/logger";
5
+ async function U(e) {
6
6
  await e.writeFile(
7
7
  "/internal/shared/mu-plugins/0-playground.php",
8
8
  `<?php
@@ -208,7 +208,7 @@ async function S(e) {
208
208
  `
209
209
  );
210
210
  }
211
- function v(e) {
211
+ function S(e) {
212
212
  return `
213
213
  /**
214
214
  * Loads the SQLite integration plugin before WordPress is loaded
@@ -281,7 +281,7 @@ $wpdb = $GLOBALS['wpdb'] = new Playground_SQLite_Integration_Loader();
281
281
  */
282
282
  `;
283
283
  }
284
- const H = `
284
+ const V = `
285
285
  if (function_exists('is_user_logged_in') && is_user_logged_in()) {
286
286
  return;
287
287
  }
@@ -375,7 +375,7 @@ const H = `
375
375
  return;
376
376
  }
377
377
  `;
378
- async function B(e) {
378
+ async function Y(e) {
379
379
  await e.mkdir("/internal/shared/mu-plugins"), await e.writeFile(
380
380
  "/internal/shared/auto_prepend_file.php",
381
381
  `<?php
@@ -639,7 +639,7 @@ function playground_load_mu_plugins() {
639
639
  if ((function_exists('wp_doing_ajax') && wp_doing_ajax()) || defined('REST_REQUEST')) {
640
640
  return;
641
641
  }
642
- ${H}
642
+ ${V}
643
643
  }
644
644
  add_action('init', 'playground_auto_login', 1);
645
645
 
@@ -666,7 +666,7 @@ function playground_load_mu_plugins() {
666
666
  return $interval;
667
667
  }
668
668
  `
669
- ), await S(e), await e.writeFile(
669
+ ), await U(e), await e.writeFile(
670
670
  "/internal/shared/preload/error-handler.php",
671
671
  `<?php
672
672
  $GLOBALS['_playground_consts'] = array();
@@ -677,13 +677,13 @@ if (file_exists('/internal/shared/consts.json')) {
677
677
  }
678
678
  function _playground_error_handler($severity, $message, $file, $line) {
679
679
  $playground_consts = $GLOBALS['_playground_consts'];
680
- ${V}
680
+ ${K}
681
681
  return false;
682
682
  }
683
683
  set_error_handler('_playground_error_handler');`
684
684
  );
685
685
  }
686
- const V = `
686
+ const K = `
687
687
  // http_api_transports is deprecated since 6.4.0 but Playground's
688
688
  // networking layer still registers it for wp_http_supports().
689
689
  // @see https://core.trac.wordpress.org/ticket/37708
@@ -726,62 +726,513 @@ const V = `
726
726
  return;
727
727
  }
728
728
  `;
729
- async function X(e, t) {
730
- const i = T(e, t);
729
+ function I(e) {
730
+ return [
731
+ // Parenthesized forms.
732
+ /(^|[^\w$])((?:require|include)(?:_once)?)\s*\(\s*(['"])(\.\.\/[^'"]+)\3\s*\)/g,
733
+ /(^|[^\w$])((?:require|include)(?:_once)?)\s*\(\s*(['"])(\.\/[^'"]+)\3\s*\)/g,
734
+ // Bare filename (e.g. 'admin-header.php'). Restrict to .php to
735
+ // avoid false positives.
736
+ /(^|[^\w$])((?:require|include)(?:_once)?)\s*\(\s*(['"])([a-z][\w-]*\.php)\3\s*\)/g,
737
+ // Statement forms without parentheses (WP 2.0 uses this).
738
+ /(^|[^\w$])((?:require|include)(?:_once)?)\s+(['"])(\.\.\/[^'"]+)\3/g,
739
+ /(^|[^\w$])((?:require|include)(?:_once)?)\s+(['"])(\.\/[^'"]+)\3/g,
740
+ /(^|[^\w$])((?:require|include)(?:_once)?)\s+(['"])([a-z][\w-]*\.php)\3/g
741
+ ].reduce(
742
+ (i, t) => i.replace(
743
+ t,
744
+ (s, r, o, _, l) => `${r}${o}(${Q(l)})`
745
+ ),
746
+ e
747
+ );
748
+ }
749
+ function Q(e) {
750
+ let n = e, i = 0;
751
+ for (; n.startsWith("../"); )
752
+ i++, n = n.slice(3);
753
+ for (; n.startsWith("./"); )
754
+ n = n.slice(2);
755
+ let t = "dirname(__FILE__)";
756
+ for (let s = 0; s < i; s++)
757
+ t = `dirname(${t})`;
758
+ return `${t} . '/${n}'`;
759
+ }
760
+ async function j(e, n) {
761
+ return R(e, n) ? (await Z(e, n), await J(e, n), await ee(e, n), await te(e, n), await ne(e, n), await se(e, n), await re(e, n), !0) : !1;
762
+ }
763
+ async function z(e) {
764
+ return R(e, e.documentRoot) ? (await e.run({
765
+ code: `<?php
766
+ $db_dir = getenv('DOCUMENT_ROOT') . '/wp-content/database/';
767
+ if (!is_dir($db_dir)) { @mkdir($db_dir, 0777, true); }
768
+ $db_path = $db_dir . '.ht.sqlite';
769
+ $pdo = new PDO('sqlite:' . $db_path);
770
+ $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
771
+ $now = date('Y-m-d H:i:s');
772
+
773
+ $tables_sql = array(
774
+ 'b2posts' => "CREATE TABLE IF NOT EXISTS b2posts (
775
+ ID INTEGER PRIMARY KEY AUTOINCREMENT,
776
+ post_author INTEGER NOT NULL DEFAULT 0,
777
+ post_date TEXT NOT NULL DEFAULT '0000-00-00 00:00:00',
778
+ post_content TEXT NOT NULL DEFAULT '',
779
+ post_title TEXT NOT NULL DEFAULT '',
780
+ post_category INTEGER NOT NULL DEFAULT 0,
781
+ post_excerpt TEXT NOT NULL DEFAULT '',
782
+ post_status TEXT NOT NULL DEFAULT 'publish',
783
+ comment_status TEXT NOT NULL DEFAULT 'open',
784
+ ping_status TEXT NOT NULL DEFAULT 'open',
785
+ post_password TEXT NOT NULL DEFAULT ''
786
+ )",
787
+ 'b2categories' => "CREATE TABLE IF NOT EXISTS b2categories (
788
+ cat_ID INTEGER PRIMARY KEY AUTOINCREMENT,
789
+ cat_name TEXT NOT NULL DEFAULT ''
790
+ )",
791
+ 'b2comments' => "CREATE TABLE IF NOT EXISTS b2comments (
792
+ comment_ID INTEGER PRIMARY KEY AUTOINCREMENT,
793
+ comment_post_ID INTEGER NOT NULL DEFAULT 0,
794
+ comment_author TEXT NOT NULL DEFAULT '',
795
+ comment_author_email TEXT NOT NULL DEFAULT '',
796
+ comment_author_url TEXT NOT NULL DEFAULT '',
797
+ comment_author_IP TEXT NOT NULL DEFAULT '',
798
+ comment_date TEXT NOT NULL DEFAULT '0000-00-00 00:00:00',
799
+ comment_content TEXT NOT NULL DEFAULT '',
800
+ comment_karma INTEGER NOT NULL DEFAULT 0
801
+ )",
802
+ 'b2settings' => "CREATE TABLE IF NOT EXISTS b2settings (
803
+ ID INTEGER NOT NULL DEFAULT 1,
804
+ posts_per_page INTEGER NOT NULL DEFAULT 20,
805
+ what_to_show TEXT NOT NULL DEFAULT 'posts',
806
+ archive_mode TEXT NOT NULL DEFAULT 'postbypost',
807
+ time_difference INTEGER NOT NULL DEFAULT 0,
808
+ AutoBR INTEGER NOT NULL DEFAULT 1,
809
+ time_format TEXT NOT NULL DEFAULT 'g:i a',
810
+ date_format TEXT NOT NULL DEFAULT 'n/j/Y',
811
+ PRIMARY KEY (ID)
812
+ )",
813
+ 'b2users' => "CREATE TABLE IF NOT EXISTS b2users (
814
+ ID INTEGER PRIMARY KEY AUTOINCREMENT,
815
+ user_login TEXT NOT NULL DEFAULT '',
816
+ user_pass TEXT NOT NULL DEFAULT '',
817
+ user_firstname TEXT NOT NULL DEFAULT '',
818
+ user_lastname TEXT NOT NULL DEFAULT '',
819
+ user_nickname TEXT NOT NULL DEFAULT '',
820
+ user_icq INTEGER NOT NULL DEFAULT 0,
821
+ user_email TEXT NOT NULL DEFAULT '',
822
+ user_url TEXT NOT NULL DEFAULT '',
823
+ user_ip TEXT NOT NULL DEFAULT '',
824
+ user_domain TEXT NOT NULL DEFAULT '',
825
+ user_browser TEXT NOT NULL DEFAULT '',
826
+ dateYMDhour TEXT NOT NULL DEFAULT '0000-00-00 00:00:00',
827
+ user_level INTEGER NOT NULL DEFAULT 0,
828
+ user_aim TEXT NOT NULL DEFAULT '',
829
+ user_msn TEXT NOT NULL DEFAULT '',
830
+ user_yim TEXT NOT NULL DEFAULT '',
831
+ user_idmode TEXT NOT NULL DEFAULT ''
832
+ )",
833
+ 'b2links' => "CREATE TABLE IF NOT EXISTS b2links (
834
+ link_id INTEGER PRIMARY KEY AUTOINCREMENT,
835
+ link_url TEXT NOT NULL DEFAULT '',
836
+ link_name TEXT NOT NULL DEFAULT '',
837
+ link_image TEXT NOT NULL DEFAULT '',
838
+ link_target TEXT NOT NULL DEFAULT '',
839
+ link_category INTEGER NOT NULL DEFAULT 0,
840
+ link_description TEXT NOT NULL DEFAULT '',
841
+ link_visible TEXT NOT NULL DEFAULT 'Y',
842
+ link_owner INTEGER NOT NULL DEFAULT 1,
843
+ link_rating INTEGER NOT NULL DEFAULT 0,
844
+ link_updated TEXT NOT NULL DEFAULT '0000-00-00 00:00:00',
845
+ link_rel TEXT NOT NULL DEFAULT '',
846
+ link_notes TEXT NOT NULL DEFAULT '',
847
+ link_rss TEXT NOT NULL DEFAULT ''
848
+ )",
849
+ 'b2linkcategories' => "CREATE TABLE IF NOT EXISTS b2linkcategories (
850
+ cat_id INTEGER PRIMARY KEY AUTOINCREMENT,
851
+ cat_name TEXT NOT NULL DEFAULT '',
852
+ auto_toggle TEXT NOT NULL DEFAULT 'N',
853
+ show_images TEXT NOT NULL DEFAULT 'Y',
854
+ show_description TEXT NOT NULL DEFAULT 'N',
855
+ show_rating TEXT NOT NULL DEFAULT 'Y',
856
+ show_updated TEXT NOT NULL DEFAULT 'Y',
857
+ sort_order TEXT NOT NULL DEFAULT 'name',
858
+ sort_desc TEXT NOT NULL DEFAULT 'ASC',
859
+ text_before_link TEXT NOT NULL DEFAULT '<li>',
860
+ text_after_link TEXT NOT NULL DEFAULT '<br />',
861
+ text_after_all TEXT NOT NULL DEFAULT '</li>',
862
+ list_limit INTEGER NOT NULL DEFAULT -1
863
+ )"
864
+ );
865
+ foreach ($tables_sql as $sql) {
866
+ $pdo->exec($sql);
867
+ }
868
+
869
+ if (!$pdo->query("SELECT COUNT(*) FROM b2categories")->fetchColumn()) {
870
+ $pdo->exec("INSERT INTO b2categories (cat_ID, cat_name) VALUES (1, 'General')");
871
+ }
872
+ if (!$pdo->query("SELECT COUNT(*) FROM b2settings")->fetchColumn()) {
873
+ $pdo->exec("INSERT INTO b2settings (ID, posts_per_page, what_to_show, archive_mode, time_difference, AutoBR, time_format, date_format) VALUES (1, 20, 'posts', 'postbypost', 0, 1, 'g:i a', 'n/j/Y')");
874
+ }
875
+ if (!$pdo->query("SELECT COUNT(*) FROM b2users")->fetchColumn()) {
876
+ $pass = md5('password');
877
+ $pdo->exec("INSERT INTO b2users (ID, user_login, user_pass, user_nickname, user_email, user_level, dateYMDhour, user_idmode) VALUES (1, 'admin', '{$pass}', 'admin', 'admin@localhost.com', 10, '{$now}', 'nickname')");
878
+ } else {
879
+ $pass = md5('password');
880
+ $pdo->exec("UPDATE b2users SET user_pass = '{$pass}', user_level = 10 WHERE user_login = 'admin'");
881
+ }
882
+ if (!$pdo->query("SELECT COUNT(*) FROM b2posts")->fetchColumn()) {
883
+ $content = 'Welcome to WordPress. This is the first post. Edit or delete it, then start blogging!';
884
+ $pdo->exec("INSERT INTO b2posts (ID, post_author, post_date, post_content, post_title, post_category, post_excerpt, post_status, comment_status, ping_status, post_password) VALUES (1, 1, '{$now}', '{$content}', 'Hello world!', 1, '', 'publish', 'open', 'open', '')");
885
+ }
886
+ if (!$pdo->query("SELECT COUNT(*) FROM b2comments")->fetchColumn()) {
887
+ $pdo->exec("INSERT INTO b2comments (comment_post_ID, comment_author, comment_author_email, comment_author_url, comment_author_IP, comment_date, comment_content, comment_karma) VALUES (1, 'Mr WordPress', 'mr@wordpress.org', 'http://wordpress.org', '127.0.0.1', '{$now}', 'Hi, this is a comment. To delete a comment, just log in and view the comments for this post.', 0)");
888
+ }
889
+ if (!$pdo->query("SELECT COUNT(*) FROM b2linkcategories")->fetchColumn()) {
890
+ $pdo->exec("INSERT INTO b2linkcategories (cat_id, cat_name) VALUES (1, 'General')");
891
+ }
892
+ if (!$pdo->query("SELECT COUNT(*) FROM b2links")->fetchColumn()) {
893
+ $pdo->exec("INSERT INTO b2links (link_url, link_name, link_category, link_visible, link_owner) VALUES ('http://wordpress.org', 'WordPress', 1, 'Y', 1)");
894
+ }
895
+ `,
896
+ env: {
897
+ DOCUMENT_ROOT: e.documentRoot
898
+ }
899
+ }), !0) : !1;
900
+ }
901
+ function R(e, n) {
902
+ const i = a(n, "b2config.php"), t = a(n, "b2-include/b2vars.php");
903
+ return !e.fileExists(i) || !e.fileExists(t) ? !1 : e.readFileAsText(t).includes("$b2_version = '0.71'");
904
+ }
905
+ async function Z(e, n) {
906
+ for (const i of [
907
+ a(n, "wp-includes"),
908
+ a(n, "wp-content"),
909
+ a(n, "wp-content/database")
910
+ ])
911
+ e.isDir(i) || await e.mkdir(i);
912
+ }
913
+ async function J(e, n) {
914
+ const i = a(n, "wp-includes/version.php");
915
+ await e.writeFile(
916
+ i,
917
+ `<?php
918
+ $wp_version = '0.71';
919
+ $wp_db_version = 71;
920
+ `
921
+ );
922
+ const t = a(n, "wp-config.php");
923
+ e.fileExists(t) || await e.writeFile(
924
+ t,
925
+ "<?php require_once dirname(__FILE__) . '/b2config.php';"
926
+ );
927
+ const s = a(n, "wp-load.php");
928
+ e.fileExists(s) || await e.writeFile(
929
+ s,
930
+ `<?php
931
+ if (!defined('ABSPATH')) {
932
+ define('ABSPATH', dirname(__FILE__) . '/');
933
+ }
934
+ require_once ABSPATH . 'b2config.php';
935
+ `
936
+ );
937
+ const r = a(n, "wp-admin/post.php");
938
+ e.fileExists(r) || await e.writeFile(
939
+ r,
940
+ "<?php require_once dirname(__FILE__) . '/b2edit.php';"
941
+ );
942
+ }
943
+ async function ee(e, n) {
944
+ const i = a(n, "b2config.php");
945
+ let t = e.readFileAsText(i);
946
+ const s = t;
947
+ t.includes("pg_wp07_bootstrap") || (t = t.replace(
948
+ "<?php",
949
+ `<?php
950
+ if (!defined('ABSPATH')) define('ABSPATH', dirname(__FILE__) . '/'); /* pg_wp07_bootstrap */
951
+ if (!defined('WPINC')) define('WPINC', 'b2-include');
952
+ if (!defined('WP_CONTENT_DIR')) define('WP_CONTENT_DIR', ABSPATH . 'wp-content');
953
+ if (!defined('DB_ENGINE')) define('DB_ENGINE', 'sqlite');
954
+ if (!isset($table_prefix)) $table_prefix = 'b2';
955
+ error_reporting(E_ALL & ~E_NOTICE & ~8192 & ~2048);
956
+ `
957
+ )), t = t.replace(
958
+ /\$siteurl\s*=\s*'http:\/\/example\.com';[^\n]*/,
959
+ "$siteurl = defined('WP_SITEURL') ? WP_SITEURL : 'http://localhost'; // pg_wp07_siteurl"
960
+ ).replace(
961
+ '$blogname = "my weblog";',
962
+ '$blogname = "My WordPress Website";'
963
+ ).replace(
964
+ '$blogdescription = "babblings !";',
965
+ '$blogdescription = "Just another WordPress weblog";'
966
+ ).replace(
967
+ "$admin_email = 'you@example.com';",
968
+ "$admin_email = 'admin@localhost.com';"
969
+ ).replace(
970
+ "$abspath = getenv('DOCUMENT_ROOT') . $relpath . '/';",
971
+ "$abspath = dirname(__FILE__) . '/';"
972
+ ), t !== s && await e.writeFile(i, t);
973
+ }
974
+ async function te(e, n) {
975
+ const i = a(n, "blog.header.php");
976
+ let t = e.readFileAsText(i);
977
+ const s = t;
978
+ t = t.replace(
979
+ `$where .= ' AND (post_status = "publish"';`,
980
+ `$where .= " AND (post_status = 'publish'";`
981
+ ), t !== s && await e.writeFile(i, t);
982
+ }
983
+ async function ne(e, n) {
984
+ const i = a(n, "b2-include/wp-db.php");
985
+ let t = e.readFileAsText(i);
986
+ const s = t;
987
+ t = ie(t), t = t.replace(
988
+ "$wpdb = new wpdb(DB_USER, DB_PASSWORD, DB_NAME, DB_HOST);",
989
+ `if (!isset($GLOBALS['wpdb'])) {
990
+ $GLOBALS['wpdb'] = new wpdb(DB_USER, DB_PASSWORD, DB_NAME, DB_HOST);
991
+ }
992
+ $wpdb = $GLOBALS['wpdb']; /* pg_wp07_preserve_sqlite_loader */`
993
+ ), t !== s && await e.writeFile(i, t);
994
+ }
995
+ function ie(e) {
996
+ const n = [];
997
+ if (e.includes("function set_prefix") || n.push(`
998
+ function set_prefix($prefix) {
999
+ $this->prefix = $prefix;
1000
+ $tables = array('posts', 'users', 'categories', 'comments', 'links', 'linkcategories', 'settings', 'options', 'postmeta', 'usermeta', 'terms', 'term_taxonomy', 'term_relationships');
1001
+ foreach ($tables as $table) {
1002
+ $this->$table = $prefix . $table;
1003
+ }
1004
+ return $prefix;
1005
+ }`), e.includes("function timer_start") || n.push(`
1006
+ function timer_start() {
1007
+ $this->time_start = microtime(true);
1008
+ return true;
1009
+ }`), e.includes("function timer_stop") || n.push(`
1010
+ function timer_stop() {
1011
+ return microtime(true) - $this->time_start;
1012
+ }`), e.includes("function init_charset") || n.push(`
1013
+ function init_charset() {
1014
+ if (defined('DB_CHARSET')) $this->charset = DB_CHARSET;
1015
+ if (defined('DB_COLLATE')) $this->collate = DB_COLLATE;
1016
+ }`), e.includes("function bail") || n.push(`
1017
+ function bail($message, $error_code = '500') {
1018
+ die($message);
1019
+ }`), e.includes("function check_connection") || n.push(`
1020
+ function check_connection($allow_bail = true) {
1021
+ return true;
1022
+ }`), n.length === 0) return e;
1023
+ const i = e.match(
1024
+ /^(\s*})\s*\n+(\$wpdb|if\s*\(\s*!\s*isset\(\s*\$GLOBALS\['wpdb'\]\s*\))/m
1025
+ );
1026
+ if (!i || i.index === void 0)
1027
+ throw new Error(
1028
+ "WP 0.7 wpdb polyfill anchor not found; b2-include/wp-db.php layout changed"
1029
+ );
1030
+ const t = `
1031
+ // Polyfills added by WordPress Playground for WP 0.7.
1032
+ ` + n.join(`
1033
+ `) + `
1034
+
1035
+ `;
1036
+ return e.substring(0, i.index) + t + e.substring(i.index);
1037
+ }
1038
+ async function se(e, n) {
1039
+ const i = a(
1040
+ n,
1041
+ "b2-include/b2template.functions.php"
1042
+ );
1043
+ let t = e.readFileAsText(i);
1044
+ const s = t;
1045
+ t.includes("pg_wp07_apply_filters") || (t = t.replace(
1046
+ `function apply_filters($tag, $string) {
1047
+ global $b2_filter;
1048
+ if (isset($b2_filter['all'])) {
1049
+ $b2_filter['all'] = (is_string($b2_filter['all'])) ? array($b2_filter['all']) : $b2_filter['all'];
1050
+ $b2_filter[$tag] = array_merge($b2_filter['all'], $b2_filter[$tag]);
1051
+ $b2_filter[$tag] = array_unique($b2_filter[$tag]);
1052
+ }
1053
+ if (isset($b2_filter[$tag])) {
1054
+ $b2_filter[$tags] = (is_string($b2_filter[$tag])) ? array($b2_filter[$tag]) : $b2_filter[$tag];
1055
+ $functions = $b2_filter[$tag];
1056
+ foreach($functions as $function) {
1057
+ $string = $function($string);
1058
+ }
1059
+ }
1060
+ return $string;
1061
+ }`,
1062
+ `function apply_filters($tag, $string) { /* pg_wp07_apply_filters */
1063
+ global $b2_filter;
1064
+ $functions = array();
1065
+ // WP_SQLite_DB uses apply_filters('query'); b2's all filter texturizes SQL.
1066
+ if ($tag != 'query' && isset($b2_filter['all'])) {
1067
+ $all = is_array($b2_filter['all']) ? $b2_filter['all'] : array($b2_filter['all']);
1068
+ $functions = array_merge($functions, $all);
1069
+ }
1070
+ if (isset($b2_filter[$tag])) {
1071
+ $tag_functions = is_array($b2_filter[$tag]) ? $b2_filter[$tag] : array($b2_filter[$tag]);
1072
+ $functions = array_merge($functions, $tag_functions);
1073
+ }
1074
+ $functions = array_unique($functions);
1075
+ foreach($functions as $function) {
1076
+ if (function_exists($function)) {
1077
+ $string = $function($string);
1078
+ }
1079
+ }
1080
+ return $string;
1081
+ }`
1082
+ ), t !== s && await e.writeFile(i, t));
1083
+ }
1084
+ async function re(e, n) {
1085
+ await ae(e, n), await oe(e, n), await _e(e, n), await le(e, n);
1086
+ }
1087
+ async function ae(e, n) {
1088
+ const i = a(n, "b2login.php");
1089
+ let t = e.readFileAsText(i);
1090
+ const s = t;
1091
+ t.includes("pg_wp07_login_auto_login") || (t = t.replace(
1092
+ "switch($action) {",
1093
+ `${x("pg_wp07_login_auto_login")}
1094
+ switch($action) {`
1095
+ )), t.includes("pg_wp07_logout_guard") || (t = t.replace(
1096
+ ` setcookie('wordpressuser');
1097
+ setcookie('wordpresspass');`,
1098
+ ` setcookie('wordpressuser', '', time() - 31536000);
1099
+ setcookie('wordpresspass', '', time() - 31536000);
1100
+ setcookie('wordpressblogid', '', time() - 31536000);
1101
+ setcookie('wordpressuser', '', time() - 31536000, '/');
1102
+ setcookie('wordpresspass', '', time() - 31536000, '/');
1103
+ setcookie('wordpressblogid', '', time() - 31536000, '/');
1104
+ setcookie('playground_auto_login_already_logged_out', '1', time() + 172800, '/'); /* pg_wp07_logout_guard */`
1105
+ ), t = t.replace(
1106
+ "header('Refresh: 0;url=b2login.php');",
1107
+ "header('Refresh: 0;url=b2login.php?loggedout=1');"
1108
+ ).replace(
1109
+ "header('Location: b2login.php');",
1110
+ "header('Location: b2login.php?loggedout=1');"
1111
+ )), t !== s && await e.writeFile(i, t);
1112
+ }
1113
+ async function oe(e, n) {
1114
+ const i = a(n, "wp-admin");
1115
+ if (e.isDir(i))
1116
+ for (const t of e.listFiles(i)) {
1117
+ if (!t.endsWith(".php")) continue;
1118
+ const s = a(i, t), r = e.readFileAsText(s), o = I(r);
1119
+ o !== r && await e.writeFile(s, o);
1120
+ }
1121
+ }
1122
+ async function _e(e, n) {
1123
+ const i = a(n, "wp-admin/b2menutop.php");
1124
+ let t = e.readFileAsText(i);
1125
+ const s = t;
1126
+ t = t.replace(
1127
+ 'file("./b2menutop.txt")',
1128
+ "file(dirname(__FILE__) . '/b2menutop.txt')"
1129
+ ).replace(
1130
+ '<a href="http://wordpress.org" rel="external"><span>WordPress</span></a>',
1131
+ '<a href="#" rel="external"><span>WordPress</span></a>'
1132
+ ), t !== s && await e.writeFile(i, t);
1133
+ }
1134
+ async function le(e, n) {
1135
+ const i = a(n, "wp-admin/b2verifauth.php");
1136
+ let t = e.readFileAsText(i);
1137
+ const s = t;
1138
+ t.includes("pg_wp07_auto_login") || (t = t.replace(
1139
+ "require_once('../b2config.php');",
1140
+ `require_once('../b2config.php');
1141
+ ${x("pg_wp07_auto_login")}`
1142
+ ), t !== s && await e.writeFile(i, t));
1143
+ }
1144
+ function x(e) {
1145
+ return `
1146
+ if (isset($_GET['loggedout']) || isset($HTTP_GET_VARS['loggedout'])) {
1147
+ $_COOKIE['playground_auto_login_already_logged_out'] = '1';
1148
+ unset($_COOKIE['wordpressuser']);
1149
+ unset($_COOKIE['wordpresspass']);
1150
+ unset($_COOKIE['wordpressblogid']);
1151
+ unset($HTTP_COOKIE_VARS['wordpressuser']);
1152
+ unset($HTTP_COOKIE_VARS['wordpresspass']);
1153
+ unset($HTTP_COOKIE_VARS['wordpressblogid']);
1154
+ if (!headers_sent()) {
1155
+ setcookie('playground_auto_login_already_logged_out', '1', time() + 172800, '/');
1156
+ }
1157
+ }
1158
+ if (
1159
+ defined('PLAYGROUND_AUTO_LOGIN_AS_USER') &&
1160
+ empty($_COOKIE['playground_auto_login_already_logged_out']) &&
1161
+ (!isset($action) || $action != 'logout')
1162
+ ) {
1163
+ $_pg_wp07_user = PLAYGROUND_AUTO_LOGIN_AS_USER;
1164
+ $_pg_wp07_pass = md5(md5('password'));
1165
+ $_COOKIE['wordpressuser'] = $_pg_wp07_user;
1166
+ $_COOKIE['wordpresspass'] = $_pg_wp07_pass;
1167
+ $_COOKIE['wordpressblogid'] = 1;
1168
+ $HTTP_COOKIE_VARS = $_COOKIE;
1169
+ $GLOBALS['HTTP_COOKIE_VARS'] = $HTTP_COOKIE_VARS;
1170
+ if (!headers_sent()) {
1171
+ $_pg_wp07_exp = time() + 172800;
1172
+ setcookie('wordpressuser', $_pg_wp07_user, $_pg_wp07_exp, '/');
1173
+ setcookie('wordpresspass', $_pg_wp07_pass, $_pg_wp07_exp, '/');
1174
+ setcookie('wordpressblogid', 1, $_pg_wp07_exp, '/');
1175
+ }
1176
+ } /* ${e} */
1177
+ `;
1178
+ }
1179
+ async function ce(e, n) {
1180
+ const i = E(e, n);
731
1181
  if (i === null) return;
732
- const n = parseFloat(i);
733
- if (!Number.isFinite(n) || n < 5 || n >= 6.2)
1182
+ const t = parseFloat(i);
1183
+ if (!Number.isFinite(t) || t < 5 || t >= 6.2)
734
1184
  return;
735
- const s = _(t, "wp-includes/load.php");
1185
+ const s = a(n, "wp-includes/load.php");
736
1186
  if (!e.fileExists(s)) return;
737
- const r = e.readFileAsText(s), a = r.replace(
1187
+ const r = e.readFileAsText(s), o = r.replace(
738
1188
  "extension_loaded( 'mysqli' )",
739
1189
  "function_exists( 'mysqli_connect' )"
740
1190
  );
741
- a !== r && await e.writeFile(s, a);
1191
+ o !== r && await e.writeFile(s, o);
742
1192
  }
743
- function T(e, t) {
744
- const i = _(t, "wp-includes/version.php");
1193
+ function E(e, n) {
1194
+ const i = a(n, "wp-includes/version.php");
745
1195
  if (!e.fileExists(i)) return null;
746
1196
  const s = e.readFileAsText(i).match(/\$wp_version\s*=\s*['"]([^'"]+)['"]/);
747
1197
  return s ? s[1] : null;
748
1198
  }
749
- const Y = 22527, L = "E_ALL & ~8192 & ~2048";
750
- async function K(e, t) {
751
- await se(e, t), await ae(e, t), await oe(e, t), await ue(e, t), await de(e, t), await Le(e, t), await fe(e, t), await we(e, t), await Z(e, t), await z(e, t);
752
- const i = T(e, t);
1199
+ const ue = 22527, w = "E_ALL & ~8192 & ~2048";
1200
+ async function pe(e, n) {
1201
+ if (await j(e, n)) return;
1202
+ await Le(e, n), await Oe(e, n), await be(e, n), await Ue(e, n), await Se(e, n), await We(e, n), await Re(e, n), await Fe(e, n), await he(e, n), await $e(e, n);
1203
+ const i = E(e, n);
753
1204
  if (i === null) return;
754
- const n = parseFloat(i);
755
- Number.isFinite(n) && (n < 1.2 && (await re(e, t), await ie(e, t)), n < 1.5 && await J(e, t), 1.5 <= n && n < 2 && await ge(e, t), n < 2 && (await ee(e, t), await ce(e, t)), 2.1 <= n && n < 2.3 && await ne(e, t), n < 2.5 && await $e(e, t), n < 2.8 && (await Ee(e, t), await Te(e, t)), 2.9 <= n && n < 3.6 && await j(e, t), 3.3 <= n && n < 3.4 && await te(e, t), n >= 4.7 && await Q(e, t));
1205
+ const t = parseFloat(i);
1206
+ Number.isFinite(t) && (t < 1.2 && (await ye(e, n), await we(e, n)), t < 1.5 && await ge(e, n), 1.5 <= t && t < 2 && await ve(e, n), t < 2 && (await me(e, n), await Pe(e, n)), 2.1 <= t && t < 2.3 && await Ee(e, n), t < 2.5 && await xe(e, n), t < 2.8 && (await Ce(e, n), await qe(e, n)), 2.9 <= t && t < 3.6 && await fe(e, n), 3.3 <= t && t < 3.4 && await Te(e, n), t >= 4.7 && await de(e, n));
756
1207
  }
757
- async function Q(e, t) {
758
- const i = _(t, "wp-content/themes");
1208
+ async function de(e, n) {
1209
+ const i = a(n, "wp-content/themes");
759
1210
  if (e.isDir(i))
760
- for (const n of e.listFiles(i)) {
761
- const s = _(i, n, "searchform.php");
1211
+ for (const t of e.listFiles(i)) {
1212
+ const s = a(i, t, "searchform.php");
762
1213
  e.fileExists(s) && e.unlink(s);
763
1214
  }
764
1215
  }
765
- async function j(e, t) {
766
- const i = _(t, "wp-admin/includes/dashboard.php");
1216
+ async function fe(e, n) {
1217
+ const i = a(n, "wp-admin/includes/dashboard.php");
767
1218
  if (e.fileExists(i)) {
768
1219
  let r = e.readFileAsText(i);
769
1220
  if (r.includes("function wp_dashboard_primary()") && !r.includes("/* pg_no_rss */")) {
770
- for (const a of [
1221
+ for (const o of [
771
1222
  "wp_dashboard_primary",
772
1223
  "wp_dashboard_secondary",
773
1224
  "wp_dashboard_plugins"
774
1225
  ])
775
1226
  r = r.replace(
776
- new RegExp(`function ${a}\\(\\)\\s*\\{`),
777
- `function ${a}() { /* pg_no_rss */ return;`
1227
+ new RegExp(`function ${o}\\(\\)\\s*\\{`),
1228
+ `function ${o}() { /* pg_no_rss */ return;`
778
1229
  );
779
1230
  await e.writeFile(i, r);
780
1231
  }
781
1232
  }
782
- const n = _(t, "wp-admin/admin.php");
783
- if (e.fileExists(n)) {
784
- let r = e.readFileAsText(n);
1233
+ const t = a(n, "wp-admin/admin.php");
1234
+ if (e.fileExists(t)) {
1235
+ let r = e.readFileAsText(t);
785
1236
  r.includes("do_action('admin_init');") && !r.includes("/* pg_admin_init_cleanup */") && (r = r.replace(
786
1237
  "do_action('admin_init');",
787
1238
  `/* pg_admin_init_cleanup */
@@ -794,16 +1245,16 @@ if (function_exists('remove_action')) {
794
1245
  @remove_action('admin_init', 'wp_update_themes');
795
1246
  }
796
1247
  do_action('admin_init');`
797
- ), await e.writeFile(n, r));
1248
+ ), await e.writeFile(t, r));
798
1249
  }
799
- const s = _(
800
- t,
1250
+ const s = a(
1251
+ n,
801
1252
  "wp-admin/includes/update.php"
802
1253
  );
803
1254
  if (e.fileExists(s)) {
804
1255
  let r = e.readFileAsText(s);
805
1256
  if (!r.includes("/* pg_admin_no_updates */")) {
806
- for (const a of [
1257
+ for (const o of [
807
1258
  "wp_plugin_update_rows",
808
1259
  "wp_plugin_update_row",
809
1260
  "wp_theme_update_rows",
@@ -811,11 +1262,11 @@ do_action('admin_init');`
811
1262
  "wp_update_plugins",
812
1263
  "wp_update_themes"
813
1264
  ]) {
814
- const o = new RegExp(
815
- `function ${a}\\s*\\([^)]*\\)\\s*\\{`
1265
+ const _ = new RegExp(
1266
+ `function ${o}\\s*\\([^)]*\\)\\s*\\{`
816
1267
  );
817
- o.test(r) && (r = r.replace(
818
- o,
1268
+ _.test(r) && (r = r.replace(
1269
+ _,
819
1270
  (l) => l + " /* pg_admin_no_updates */ return;"
820
1271
  ));
821
1272
  }
@@ -823,177 +1274,177 @@ do_action('admin_init');`
823
1274
  }
824
1275
  }
825
1276
  for (const r of [
826
- _(t, "wp-includes/SimplePie/File.php"),
827
- _(t, "wp-includes/class-simplepie.php")
1277
+ a(n, "wp-includes/SimplePie/File.php"),
1278
+ a(n, "wp-includes/class-simplepie.php")
828
1279
  ]) {
829
1280
  if (!e.fileExists(r)) continue;
830
- let a = e.readFileAsText(r);
831
- a.includes("function SimplePie_File(") && !a.includes("/* pg_no_fetch */") && (a = a.replace(
1281
+ let o = e.readFileAsText(r);
1282
+ o.includes("function SimplePie_File(") && !o.includes("/* pg_no_fetch */") && (o = o.replace(
832
1283
  /function SimplePie_File\([^)]*\)\s*\{/,
833
- (o) => o + `
1284
+ (_) => _ + `
834
1285
  /* pg_no_fetch */
835
1286
  $this->error = 'Network requests disabled in Playground';
836
1287
  $this->success = false;
837
1288
  return;`
838
- ), await e.writeFile(r, a));
1289
+ ), await e.writeFile(r, o));
839
1290
  }
840
1291
  }
841
- async function z(e, t) {
1292
+ async function $e(e, n) {
842
1293
  const i = [
843
1294
  ["function wp_new_blog_notification", "pg_no_blog_notification"],
844
1295
  [
845
1296
  "function wp_install_maybe_enable_pretty_permalinks",
846
1297
  "pg_no_permalink_check"
847
1298
  ]
848
- ], n = [
849
- _(t, "wp-admin/includes/upgrade.php"),
850
- _(t, "wp-admin/upgrade-functions.php")
1299
+ ], t = [
1300
+ a(n, "wp-admin/includes/upgrade.php"),
1301
+ a(n, "wp-admin/upgrade-functions.php")
851
1302
  ];
852
- for (const s of n) {
1303
+ for (const s of t) {
853
1304
  if (!e.fileExists(s)) continue;
854
- let r = e.readFileAsText(s), a = !1;
855
- for (const [o, l] of i) {
1305
+ let r = e.readFileAsText(s), o = !1;
1306
+ for (const [_, l] of i) {
856
1307
  if (r.includes(`/* ${l} */`)) continue;
857
- const c = r.indexOf(o);
1308
+ const c = r.indexOf(_);
858
1309
  if (c === -1) continue;
859
1310
  const u = r.indexOf("{", c);
860
- u !== -1 && (r = r.substring(0, u + 1) + ` /* ${l} */ return;` + r.substring(u + 1), a = !0);
1311
+ u !== -1 && (r = r.substring(0, u + 1) + ` /* ${l} */ return;` + r.substring(u + 1), o = !0);
861
1312
  }
862
- a && await e.writeFile(s, r);
1313
+ o && await e.writeFile(s, r);
863
1314
  }
864
1315
  }
865
- async function Z(e, t) {
866
- const i = _(t, "wp-load.php");
1316
+ async function he(e, n) {
1317
+ const i = a(n, "wp-load.php");
867
1318
  if (!e.fileExists(i)) return;
868
- const n = e.readFileAsText(i);
869
- if (!n.includes("error_reporting(") || n.includes("~8192") && n.includes("~2048")) return;
870
- const s = n.replace(
1319
+ const t = e.readFileAsText(i);
1320
+ if (!t.includes("error_reporting(") || t.includes("~8192") && t.includes("~2048")) return;
1321
+ const s = t.replace(
871
1322
  /error_reporting\(([^)]+)\)/g,
872
- (r, a) => `error_reporting((${a}) & ~8192 & ~2048)`
1323
+ (r, o) => `error_reporting((${o}) & ~8192 & ~2048)`
873
1324
  );
874
1325
  await e.writeFile(i, s);
875
1326
  }
876
- async function J(e, t) {
877
- const i = _(t, "wp-admin/menu.php");
1327
+ async function ge(e, n) {
1328
+ const i = a(n, "wp-admin/menu.php");
878
1329
  if (e.fileExists(i)) {
879
1330
  const r = e.readFileAsText(i);
880
1331
  if (!r.includes("/* pg_wp10_logo_link */")) {
881
- const a = '<h1 id="wphead"><a href="http://wordpress.org" rel="external">WordPress</a></h1>';
882
- if (r.includes(a)) {
883
- const o = r.replace(
884
- a,
1332
+ const o = '<h1 id="wphead"><a href="http://wordpress.org" rel="external">WordPress</a></h1>';
1333
+ if (r.includes(o)) {
1334
+ const _ = r.replace(
1335
+ o,
885
1336
  '<h1 id="wphead"><a href="#" rel="external">WordPress</a></h1> <!-- pg_wp10_logo_link -->'
886
1337
  );
887
- o !== r && await e.writeFile(i, o);
1338
+ _ !== r && await e.writeFile(i, _);
888
1339
  }
889
1340
  }
890
1341
  }
891
- const n = _(
892
- t,
1342
+ const t = a(
1343
+ n,
893
1344
  "wp-admin/admin-header.php"
894
1345
  );
895
- if (e.fileExists(n)) {
896
- const r = e.readFileAsText(n);
1346
+ if (e.fileExists(t)) {
1347
+ const r = e.readFileAsText(t);
897
1348
  if (!r.includes("/* pg_wp12_logo_link */")) {
898
- const a = '<a href="http://wordpress.org" rel="external"', o = "</a>", l = r.indexOf(a);
1349
+ const o = '<a href="http://wordpress.org" rel="external"', _ = "</a>", l = r.indexOf(o);
899
1350
  if (l !== -1) {
900
- const c = r.indexOf(o, l);
1351
+ const c = r.indexOf(_, l);
901
1352
  if (c !== -1) {
902
- const u = r.substring(0, l) + '<a href="#">WordPress</a><!-- pg_wp12_logo_link -->' + r.substring(c + o.length);
903
- u !== r && await e.writeFile(n, u);
1353
+ const u = r.substring(0, l) + '<a href="#">WordPress</a><!-- pg_wp12_logo_link -->' + r.substring(c + _.length);
1354
+ u !== r && await e.writeFile(t, u);
904
1355
  }
905
1356
  }
906
1357
  }
907
1358
  }
908
- const s = _(
909
- t,
1359
+ const s = a(
1360
+ n,
910
1361
  "wp-admin/admin-footer.php"
911
1362
  );
912
1363
  if (e.fileExists(s)) {
913
1364
  const r = e.readFileAsText(s);
914
1365
  if (!r.includes("/* pg_wp10_footer_link */")) {
915
- const a = r.replace(
1366
+ const o = r.replace(
916
1367
  '<a href="http://wordpress.org">WordPress</a>',
917
1368
  "WordPress<!-- pg_wp10_footer_link -->"
918
1369
  ).replace(
919
1370
  '<a href="http://wordpress.org/">WordPress</a>',
920
1371
  "WordPress<!-- pg_wp10_footer_link -->"
921
1372
  );
922
- a !== r && await e.writeFile(s, a);
1373
+ o !== r && await e.writeFile(s, o);
923
1374
  }
924
1375
  }
925
1376
  }
926
- async function ee(e, t) {
927
- const i = _(t, "wp-admin/edit.php");
1377
+ async function me(e, n) {
1378
+ const i = a(n, "wp-admin/edit.php");
928
1379
  if (!e.fileExists(i)) return;
929
- const n = e.readFileAsText(i);
930
- if (n.includes("/* pg_wp10_post_title_edit */")) return;
931
- let s = n;
1380
+ const t = e.readFileAsText(i);
1381
+ if (t.includes("/* pg_wp10_post_title_edit */")) return;
1382
+ let s = t;
932
1383
  const r = '<strong><a href="<?php permalink_link(); ?>" rel="permalink"><?php the_title() ?></a></strong>';
933
1384
  s.includes(r) && (s = s.replace(
934
1385
  r,
935
1386
  '<strong><a href="post.php?action=edit&amp;post=<?php echo $id /* pg_wp10_post_title_edit */ ?>"><?php the_title() ?></a></strong>'
936
1387
  ));
937
- const a = '<td><a href="<?php the_permalink(); ?>" rel="permalink">';
938
- s.includes(a) && (s = s.replace(
939
- a,
1388
+ const o = '<td><a href="<?php the_permalink(); ?>" rel="permalink">';
1389
+ s.includes(o) && (s = s.replace(
1390
+ o,
940
1391
  '<td><a href="post.php?action=edit&amp;post=<?php echo $id /* pg_wp10_post_title_edit */ ?>">'
941
1392
  ));
942
- const o = `<td><?php the_title() ?>
1393
+ const _ = `<td><?php the_title() ?>
943
1394
  <?php if ('private' == $post->post_status) _e(' - <strong>Private</strong>'); ?></td>`;
944
- s.includes(o) && (s = s.replace(
945
- o,
1395
+ s.includes(_) && (s = s.replace(
1396
+ _,
946
1397
  `<td><a href="post.php?action=edit&amp;post=<?php echo $id /* pg_wp10_post_title_edit */ ?>"><?php the_title() ?></a>
947
1398
  <?php if ('private' == $post->post_status) _e(' - <strong>Private</strong>'); ?></td>`
948
- )), s !== n && await e.writeFile(i, s);
1399
+ )), s !== t && await e.writeFile(i, s);
949
1400
  }
950
- async function te(e, t) {
951
- const i = _(t, "wp-admin/includes/screen.php");
1401
+ async function Te(e, n) {
1402
+ const i = a(n, "wp-admin/includes/screen.php");
952
1403
  if (!e.fileExists(i)) return;
953
- const n = e.readFileAsText(i);
954
- if (!n.includes("self::$this->_help_sidebar")) return;
955
- const s = n.replace(
1404
+ const t = e.readFileAsText(i);
1405
+ if (!t.includes("self::$this->_help_sidebar")) return;
1406
+ const s = t.replace(
956
1407
  /self::\$this->_help_sidebar/g,
957
1408
  "$this->_help_sidebar"
958
1409
  );
959
- s !== n && await e.writeFile(i, s);
1410
+ s !== t && await e.writeFile(i, s);
960
1411
  }
961
- async function ne(e, t) {
962
- const i = _(t, "wp-admin/plugins.php");
1412
+ async function Ee(e, n) {
1413
+ const i = a(n, "wp-admin/plugins.php");
963
1414
  if (!e.fileExists(i)) return;
964
- const n = e.readFileAsText(i);
965
- if (n.includes("/* pg_wp21_active_plugins_array */")) return;
1415
+ const t = e.readFileAsText(i);
1416
+ if (t.includes("/* pg_wp21_active_plugins_array */")) return;
966
1417
  const s = "$current = get_option('active_plugins');";
967
- if (!n.includes(s)) return;
968
- const r = n.replace(
1418
+ if (!t.includes(s)) return;
1419
+ const r = t.replace(
969
1420
  s,
970
1421
  s + `
971
1422
  if (!is_array($current)) $current = array(); /* pg_wp21_active_plugins_array */`
972
1423
  );
973
- r !== n && await e.writeFile(i, r);
1424
+ r !== t && await e.writeFile(i, r);
974
1425
  }
975
- async function ie(e, t) {
976
- const i = _(t, "wp-login.php");
1426
+ async function we(e, n) {
1427
+ const i = a(n, "wp-login.php");
977
1428
  if (!e.fileExists(i)) return;
978
- const n = e.readFileAsText(i), s = "AND user_pass = '$password'";
979
- if (!n.includes(s) || n.includes("pg_wp10_plain_or_md5")) return;
980
- let r = n.replace(
1429
+ const t = e.readFileAsText(i), s = "AND user_pass = '$password'";
1430
+ if (!t.includes(s) || t.includes("pg_wp10_plain_or_md5")) return;
1431
+ let r = t.replace(
981
1432
  s,
982
1433
  "AND (user_pass = '$password' OR user_pass = MD5('$password')) /* pg_wp10_plain_or_md5 */"
983
1434
  );
984
1435
  r = r.replace(
985
1436
  "$login->user_pass == $password",
986
1437
  "($login->user_pass == $password || $login->user_pass == md5($password))"
987
- ), r !== n && await e.writeFile(i, r);
1438
+ ), r !== t && await e.writeFile(i, r);
988
1439
  }
989
- async function se(e, t) {
990
- const i = _(t, "wp-includes");
1440
+ async function Le(e, n) {
1441
+ const i = a(n, "wp-includes");
991
1442
  if (!e.isDir(i)) return;
992
- const n = _(i, "version.php");
993
- e.fileExists(n) || await e.writeFile(n, "<?php $wp_version = '1.0';");
1443
+ const t = a(i, "version.php");
1444
+ e.fileExists(t) || await e.writeFile(t, "<?php $wp_version = '1.0';");
994
1445
  }
995
- async function re(e, t) {
996
- const i = _(t, "wp-blog-header.php");
1446
+ async function ye(e, n) {
1447
+ const i = a(n, "wp-blog-header.php");
997
1448
  if (e.fileExists(i)) {
998
1449
  const s = e.readFileAsText(i), r = `$where .= ' AND (post_status = "publish"';`;
999
1450
  s.includes(r) && await e.writeFile(
@@ -1004,11 +1455,11 @@ async function re(e, t) {
1004
1455
  )
1005
1456
  );
1006
1457
  }
1007
- const n = _(t, "wp-includes/vars.php");
1008
- if (e.fileExists(n)) {
1009
- const s = e.readFileAsText(n), r = "add_filter('all', 'wptexturize');";
1458
+ const t = a(n, "wp-includes/vars.php");
1459
+ if (e.fileExists(t)) {
1460
+ const s = e.readFileAsText(t), r = "add_filter('all', 'wptexturize');";
1010
1461
  s.includes(r) && await e.writeFile(
1011
- n,
1462
+ t,
1012
1463
  s.replace(
1013
1464
  r,
1014
1465
  `// ${r} // Disabled by Playground: mangles SQL literals.`
@@ -1016,8 +1467,8 @@ async function re(e, t) {
1016
1467
  );
1017
1468
  }
1018
1469
  }
1019
- async function ae(e, t) {
1020
- const i = _(t, "wp-load.php");
1470
+ async function Oe(e, n) {
1471
+ const i = a(n, "wp-load.php");
1021
1472
  e.fileExists(i) || await e.writeFile(
1022
1473
  i,
1023
1474
  `<?php
@@ -1028,18 +1479,18 @@ require_once(ABSPATH . 'wp-config.php');
1028
1479
  `
1029
1480
  );
1030
1481
  }
1031
- async function oe(e, t) {
1032
- const i = _(t, "wp-settings.php");
1482
+ async function be(e, n) {
1483
+ const i = a(n, "wp-settings.php");
1033
1484
  if (!e.fileExists(i)) return;
1034
- const n = e.readFileAsText(i);
1035
- let s = n;
1485
+ const t = e.readFileAsText(i);
1486
+ let s = t;
1036
1487
  s = s.replace(
1037
1488
  /if\s*\(\s*!extension_loaded\('mysql'\)\s*\)\s*\n\s*die/,
1038
1489
  `if ( false ) // Patched for SQLite
1039
1490
  die`
1040
1491
  ), s = s.replace(
1041
1492
  /error_reporting\(([^)]+)\)/g,
1042
- (r, a) => a.includes("~8192") && a.includes("~2048") ? r : `error_reporting((${a}) & ~8192 & ~2048)`
1493
+ (r, o) => o.includes("~8192") && o.includes("~2048") ? r : `error_reporting((${o}) & ~8192 & ~2048)`
1043
1494
  ), s = s.replace(
1044
1495
  /set_magic_quotes_runtime\(\s*0\s*\)\s*;/g,
1045
1496
  "// set_magic_quotes_runtime(0); // Removed"
@@ -1050,23 +1501,23 @@ async function oe(e, t) {
1050
1501
  /define\('WPINC',\s*'wp-includes'\);/,
1051
1502
  `define('WPINC', 'wp-includes');
1052
1503
  if (!defined('WP_CONTENT_DIR')) define('WP_CONTENT_DIR', ABSPATH . 'wp-content');`
1053
- )), s = s.replace(/unset\(\s*\$wp_filter\s*,/, "unset("), s = _e(s), s = le(s), s !== n && await e.writeFile(i, s);
1504
+ )), s = s.replace(/unset\(\s*\$wp_filter\s*,/, "unset("), s = Ne(s), s = Ae(s), s !== t && await e.writeFile(i, s);
1054
1505
  }
1055
- function _e(e) {
1056
- const t = e.indexOf("installed WP");
1057
- if (t === -1) return e;
1058
- const i = e.lastIndexOf("die(", t);
1506
+ function Ne(e) {
1507
+ const n = e.indexOf("installed WP");
1508
+ if (n === -1) return e;
1509
+ const i = e.lastIndexOf("die(", n);
1059
1510
  if (i === -1) return e;
1060
- let n = 0;
1511
+ let t = 0;
1061
1512
  for (let s = i + 3; s < e.length; s++)
1062
- if (e[s] === "(") n++;
1063
- else if (e[s] === ")" && (n--, n === 0)) {
1513
+ if (e[s] === "(") t++;
1514
+ else if (e[s] === ")" && (t--, t === 0)) {
1064
1515
  let r = s + 1;
1065
1516
  return e[r] === ";" && r++, e.substring(0, i) + "true; /* die removed by Playground */" + e.substring(r);
1066
1517
  }
1067
1518
  return e;
1068
1519
  }
1069
- function le(e) {
1520
+ function Ae(e) {
1070
1521
  return e.replace(
1071
1522
  "do_action('init');",
1072
1523
  `// Remove hooks that make outbound HTTP requests (crash WASM).
@@ -1098,43 +1549,43 @@ if (function_exists('add_filter')) {
1098
1549
  do_action('init');`
1099
1550
  );
1100
1551
  }
1101
- async function ce(e, t) {
1102
- const i = _(
1103
- t,
1552
+ async function Pe(e, n) {
1553
+ const i = a(
1554
+ n,
1104
1555
  "wp-includes/functions.php"
1105
1556
  );
1106
1557
  if (!e.fileExists(i)) return;
1107
- let n = e.readFileAsText(i), s = !1;
1108
- n.includes("$all_options->{$option->option_name}") && !n.includes("$all_options = new stdClass") && (n = n.replace(
1558
+ let t = e.readFileAsText(i), s = !1;
1559
+ t.includes("$all_options->{$option->option_name}") && !t.includes("$all_options = new stdClass") && (t = t.replace(
1109
1560
  "foreach ($options as $option) {",
1110
1561
  `$all_options = new stdClass;
1111
1562
  foreach ($options as $option) {`
1112
- ), s = !0), s && await e.writeFile(i, n);
1563
+ ), s = !0), s && await e.writeFile(i, t);
1113
1564
  }
1114
- async function ue(e, t) {
1115
- const i = _(t, "wp-admin/install.php");
1565
+ async function Ue(e, n) {
1566
+ const i = a(n, "wp-admin/install.php");
1116
1567
  if (!e.fileExists(i)) return;
1117
- const n = e.readFileAsText(i);
1118
- let s = n;
1119
- const r = _(t, "wp-admin");
1120
- s = s.replace(/'\.\.\/(wp-config\.php)'/g, `'${t}/$1'`).replace(/'\.\.\/(wp-load\.php)'/g, `'${t}/$1'`).replace(/'\.\/(upgrade-functions\.php)'/g, `'${r}/$1'`).replace(/'(upgrade-functions\.php)'/g, `'${r}/$1'`).replace(/'\.\/(includes\/upgrade\.php)'/g, `'${r}/$1'`).replace(/'\.\.\/(wp-includes\/[^']+)'/g, `'${t}/$1'`), s = s.replace(/\$HTTP_GET_VARS/g, "$_GET").replace(/\$HTTP_POST_VARS/g, "$_POST"), s !== n && await e.writeFile(i, s);
1568
+ const t = e.readFileAsText(i);
1569
+ let s = t;
1570
+ const r = a(n, "wp-admin");
1571
+ s = s.replace(/'\.\.\/(wp-config\.php)'/g, `'${n}/$1'`).replace(/'\.\.\/(wp-load\.php)'/g, `'${n}/$1'`).replace(/'\.\/(upgrade-functions\.php)'/g, `'${r}/$1'`).replace(/'(upgrade-functions\.php)'/g, `'${r}/$1'`).replace(/'\.\/(includes\/upgrade\.php)'/g, `'${r}/$1'`).replace(/'\.\.\/(wp-includes\/[^']+)'/g, `'${n}/$1'`), s = s.replace(/\$HTTP_GET_VARS/g, "$_GET").replace(/\$HTTP_POST_VARS/g, "$_POST"), s !== t && await e.writeFile(i, s);
1121
1572
  }
1122
- async function de(e, t) {
1123
- const i = _(t, "wp-includes/wp-db.php");
1573
+ async function Se(e, n) {
1574
+ const i = a(n, "wp-includes/wp-db.php");
1124
1575
  if (!e.fileExists(i)) return;
1125
- const n = e.readFileAsText(i);
1126
- let s = n;
1576
+ const t = e.readFileAsText(i);
1577
+ let s = t;
1127
1578
  s.includes("isset($wpdb)") || (s = s.replace(
1128
1579
  "$wpdb = new wpdb(DB_USER, DB_PASSWORD, DB_NAME, DB_HOST);",
1129
1580
  "if ( !isset($wpdb) ) { $wpdb = new wpdb(DB_USER, DB_PASSWORD, DB_NAME, DB_HOST); }"
1130
1581
  )), s.includes("db_connect") || (s = s.replace(
1131
1582
  /\$this->dbh\s*=\s*@mysql_connect\(\$dbhost\s*,\s*\$dbuser\s*,\s*\$dbpassword(?:\s*,\s*true)?\);/,
1132
1583
  'if (method_exists($this, "db_connect")) { $this->dbname = $dbname; $this->db_connect(); } else { $this->dbh = @mysql_connect($dbhost, $dbuser, $dbpassword); }'
1133
- )), s = pe(s), s !== n && await e.writeFile(i, s);
1584
+ )), s = Ie(s), s !== t && await e.writeFile(i, s);
1134
1585
  }
1135
- function pe(e) {
1136
- const t = [];
1137
- if (e.includes("function set_prefix") || t.push(`
1586
+ function Ie(e) {
1587
+ const n = [];
1588
+ if (e.includes("function set_prefix") || n.push(`
1138
1589
  function set_prefix($prefix) {
1139
1590
  $this->prefix = $prefix;
1140
1591
  $tables = array('posts', 'users', 'categories', 'post2cat', 'comments', 'link2cat', 'links', 'options', 'postmeta', 'usermeta', 'terms', 'term_taxonomy', 'term_relationships');
@@ -1142,134 +1593,106 @@ function pe(e) {
1142
1593
  $this->$t = $prefix . $t;
1143
1594
  }
1144
1595
  return $prefix;
1145
- }`), e.includes("function timer_start") || t.push(`
1596
+ }`), e.includes("function timer_start") || n.push(`
1146
1597
  function timer_start() {
1147
1598
  $this->time_start = microtime(true);
1148
1599
  return true;
1149
- }`), e.includes("function timer_stop") || t.push(`
1600
+ }`), e.includes("function timer_stop") || n.push(`
1150
1601
  function timer_stop() {
1151
1602
  return microtime(true) - $this->time_start;
1152
- }`), e.includes("function init_charset") || t.push(`
1603
+ }`), e.includes("function init_charset") || n.push(`
1153
1604
  function init_charset() {
1154
1605
  if (defined('DB_CHARSET')) $this->charset = DB_CHARSET;
1155
1606
  if (defined('DB_COLLATE')) $this->collate = DB_COLLATE;
1156
- }`), e.includes("function bail") || t.push(`
1607
+ }`), e.includes("function bail") || n.push(`
1157
1608
  function bail($message, $error_code = '500') {
1158
1609
  die($message);
1159
- }`), e.includes("function check_connection") || t.push(`
1610
+ }`), e.includes("function check_connection") || n.push(`
1160
1611
  function check_connection($allow_bail = true) {
1161
1612
  return true;
1162
- }`), t.length === 0) return e;
1613
+ }`), n.length === 0) return e;
1163
1614
  const i = e.match(
1164
1615
  /^(\s*})\s*\n+(\$wpdb|\?>\s*$|if\s*\(\s*!\s*isset\(\s*\$wpdb\s*\))/m
1165
1616
  );
1166
1617
  if (!i || i.index === void 0) return e;
1167
- const n = `
1618
+ const t = `
1168
1619
  // Polyfills added by WordPress Playground.
1169
- ` + t.join(`
1620
+ ` + n.join(`
1170
1621
  `) + `
1171
1622
 
1172
1623
  `;
1173
- return e.substring(0, i.index) + n + e.substring(i.index);
1174
- }
1175
- async function fe(e, t) {
1176
- const i = (a) => {
1177
- let o = a, l = 0;
1178
- for (; o.startsWith("../"); )
1179
- l++, o = o.slice(3);
1180
- for (; o.startsWith("./"); )
1181
- o = o.slice(2);
1182
- let c = "dirname(__FILE__)";
1183
- for (let u = 0; u < l; u++)
1184
- c = `dirname(${c})`;
1185
- return `${c} . '/${o}'`;
1186
- }, n = _(t, "wp-admin");
1187
- if (e.isDir(n))
1188
- for (const a of e.listFiles(n)) {
1189
- if (!a.endsWith(".php")) continue;
1190
- const o = _(n, a), l = e.readFileAsText(o), c = l.replace(
1191
- /((?:require|include)(?:_once)?)\s*\(\s*(['"])(\.\.\/[^'"]+)\2\s*\)/g,
1192
- (u, d, f, p) => `${d}(${i(p)})`
1193
- ).replace(
1194
- /((?:require|include)(?:_once)?)\s*\(\s*(['"])(\.\/[^'"]+)\2\s*\)/g,
1195
- (u, d, f, p) => `${d}(${i(p)})`
1196
- ).replace(
1197
- /((?:require|include)(?:_once)?)\s*\(\s*(['"])([a-z][\w-]*\.php)\2\s*\)/g,
1198
- (u, d, f, p) => `${d}(${i(p)})`
1199
- ).replace(
1200
- /((?:require|include)(?:_once)?)\s+(['"])(\.\.\/[^'"]+)\2/g,
1201
- (u, d, f, p) => `${d}(${i(p)})`
1202
- ).replace(
1203
- /((?:require|include)(?:_once)?)\s+(['"])(\.\/[^'"]+)\2/g,
1204
- (u, d, f, p) => `${d}(${i(p)})`
1205
- ).replace(
1206
- /((?:require|include)(?:_once)?)\s+(['"])([a-z][\w-]*\.php)\2/g,
1207
- (u, d, f, p) => `${d}(${i(p)})`
1208
- ).replace(/ABSPATH\s*\.\s*'\/wp-/g, "ABSPATH . 'wp-");
1209
- c !== l && await e.writeFile(o, c);
1624
+ return e.substring(0, i.index) + t + e.substring(i.index);
1625
+ }
1626
+ async function Re(e, n) {
1627
+ const i = a(n, "wp-admin");
1628
+ if (e.isDir(i))
1629
+ for (const r of e.listFiles(i)) {
1630
+ if (!r.endsWith(".php")) continue;
1631
+ const o = a(i, r), _ = e.readFileAsText(o), l = I(_).replace(/ABSPATH\s*\.\s*'\/wp-/g, "ABSPATH . 'wp-");
1632
+ l !== _ && await e.writeFile(o, l);
1210
1633
  }
1211
- const s = _(t, "wp-admin/index.php");
1212
- if (e.fileExists(s)) {
1213
- let a = e.readFileAsText(s);
1214
- a.includes("get_settings('siteurl')") && (a = a.replace(
1634
+ const t = a(n, "wp-admin/index.php");
1635
+ if (e.fileExists(t)) {
1636
+ let r = e.readFileAsText(t);
1637
+ r.includes("get_settings('siteurl')") && (r = r.replace(
1215
1638
  /get_settings\('siteurl'\)\s*\.\s*'\/wp-admin\//g,
1216
1639
  "'"
1217
- ), await e.writeFile(s, a));
1640
+ ), await e.writeFile(t, r));
1218
1641
  }
1219
- const r = _(t, "wp-admin/menu.php");
1220
- if (e.fileExists(r)) {
1221
- const a = e.readFileAsText(r), o = "file('./menu.txt')";
1222
- a.includes(o) && await e.writeFile(
1223
- r,
1224
- a.replace(o, "file(dirname(__FILE__) . '/menu.txt')")
1642
+ const s = a(n, "wp-admin/menu.php");
1643
+ if (e.fileExists(s)) {
1644
+ const r = e.readFileAsText(s), o = "file('./menu.txt')";
1645
+ r.includes(o) && await e.writeFile(
1646
+ s,
1647
+ r.replace(o, "file(dirname(__FILE__) . '/menu.txt')")
1225
1648
  );
1226
1649
  }
1227
1650
  }
1228
- async function $e(e, t) {
1229
- const i = _(
1230
- t,
1651
+ async function xe(e, n) {
1652
+ const i = a(
1653
+ n,
1231
1654
  "wp-admin/admin-functions.php"
1232
1655
  );
1233
1656
  if (!e.fileExists(i)) return;
1234
- const n = e.readFileAsText(i);
1235
- if (!n.includes("function check_admin_referer()") || !n.includes("$_SERVER['HTTP_REFERER']"))
1657
+ const t = e.readFileAsText(i);
1658
+ if (!t.includes("function check_admin_referer()") || !t.includes("$_SERVER['HTTP_REFERER']"))
1236
1659
  return;
1237
- const s = he(
1238
- n,
1660
+ const s = ke(
1661
+ t,
1239
1662
  "check_admin_referer",
1240
1663
  `
1241
1664
  do_action('check_admin_referer', '');
1242
1665
  `
1243
1666
  );
1244
- s !== n && await e.writeFile(i, s);
1667
+ s !== t && await e.writeFile(i, s);
1245
1668
  }
1246
- function he(e, t, i) {
1247
- const n = `function ${t}()`, s = e.indexOf(n);
1669
+ function ke(e, n, i) {
1670
+ const t = `function ${n}()`, s = e.indexOf(t);
1248
1671
  if (s === -1) return e;
1249
- const r = e.indexOf("{", s + n.length);
1672
+ const r = e.indexOf("{", s + t.length);
1250
1673
  if (r === -1) return e;
1251
- let a = 1;
1252
- for (let o = r + 1; o < e.length; o++) {
1253
- const l = e[o];
1254
- if (l === "{") a++;
1255
- else if (l === "}" && (a--, a === 0))
1256
- return e.substring(0, r + 1) + i + e.substring(o);
1674
+ let o = 1;
1675
+ for (let _ = r + 1; _ < e.length; _++) {
1676
+ const l = e[_];
1677
+ if (l === "{") o++;
1678
+ else if (l === "}" && (o--, o === 0))
1679
+ return e.substring(0, r + 1) + i + e.substring(_);
1257
1680
  }
1258
1681
  return e;
1259
1682
  }
1260
- async function ge(e, t) {
1261
- const i = _(t, "wp-admin/index.php");
1683
+ async function ve(e, n) {
1684
+ const i = a(n, "wp-admin/index.php");
1262
1685
  if (e.fileExists(i)) {
1263
- const n = e.readFileAsText(i), s = n.replace(/AND post_date_gmt < '\$today'/, "");
1264
- s !== n && await e.writeFile(i, s);
1686
+ const t = e.readFileAsText(i), s = t.replace(/AND post_date_gmt < '\$today'/, "");
1687
+ s !== t && await e.writeFile(i, s);
1265
1688
  }
1266
- await me(e, t);
1689
+ await De(e, n);
1267
1690
  }
1268
- async function me(e, t) {
1269
- const i = _(t, "wp-includes/rss-functions.php");
1691
+ async function De(e, n) {
1692
+ const i = a(n, "wp-includes/rss-functions.php");
1270
1693
  if (!e.fileExists(i)) return;
1271
- let n = e.readFileAsText(i);
1272
- !/^\s*error\s*\(/m.test(n) || /^function\s+error\s*\(/m.test(n) || (n = n.replace(
1694
+ let t = e.readFileAsText(i);
1695
+ !/^\s*error\s*\(/m.test(t) || /^function\s+error\s*\(/m.test(t) || (t = t.replace(
1273
1696
  /^(<\?php\s*)/,
1274
1697
  `$1
1275
1698
  if (!function_exists('error')) {
@@ -1280,22 +1703,22 @@ if (!function_exists('error')) {
1280
1703
  }
1281
1704
  }
1282
1705
  `
1283
- ), await e.writeFile(i, n));
1706
+ ), await e.writeFile(i, t));
1284
1707
  }
1285
- async function we(e, t) {
1286
- const i = _(t, "wp-login.php");
1708
+ async function Fe(e, n) {
1709
+ const i = a(n, "wp-login.php");
1287
1710
  if (!e.fileExists(i)) return;
1288
- let n = e.readFileAsText(i), s = !1;
1711
+ let t = e.readFileAsText(i), s = !1;
1289
1712
  for (const r of ["log", "pwd"]) {
1290
- const a = new RegExp(
1713
+ const o = new RegExp(
1291
1714
  `(\\bname=(['"])${r}\\2)(?![^>]*data-1p-ignore)`
1292
1715
  );
1293
- a.test(n) && (n = n.replace(a, "$1 data-1p-ignore"), s = !0);
1716
+ o.test(t) && (t = t.replace(o, "$1 data-1p-ignore"), s = !0);
1294
1717
  }
1295
- s && await e.writeFile(i, n);
1718
+ s && await e.writeFile(i, t);
1296
1719
  }
1297
- async function Ee(e, t) {
1298
- const i = _(t, "wp-admin/admin.php");
1720
+ async function Ce(e, n) {
1721
+ const i = a(n, "wp-admin/admin.php");
1299
1722
  if (e.fileExists(i)) {
1300
1723
  const s = e.readFileAsText(i);
1301
1724
  if (s.includes("auth_redirect()")) {
@@ -1314,7 +1737,7 @@ if (defined('PLAYGROUND_AUTO_LOGIN_AS_USER')) {
1314
1737
  $_COOKIE[LOGGED_IN_COOKIE] = wp_generate_auth_cookie($_pg_uid, $_pg_exp, 'logged_in');
1315
1738
  }
1316
1739
  } else {
1317
- ${x("PLAYGROUND_AUTO_LOGIN_AS_USER")}
1740
+ ${k("PLAYGROUND_AUTO_LOGIN_AS_USER")}
1318
1741
  // WP 2.0-2.4: kses_init() runs during do_action('init') inside
1319
1742
  // wp-settings.php and caches $current_user as WP_User(0) when
1320
1743
  // no cookies were set yet. Reset and re-evaluate so capability
@@ -1364,16 +1787,16 @@ if (defined('PLAYGROUND_AUTO_LOGIN_AS_USER')) {
1364
1787
  }
1365
1788
  }
1366
1789
  }
1367
- `, a = s.replace(
1790
+ `, o = s.replace(
1368
1791
  "auth_redirect();",
1369
1792
  r + "auth_redirect();"
1370
1793
  );
1371
- a !== s && await e.writeFile(i, a);
1794
+ o !== s && await e.writeFile(i, o);
1372
1795
  }
1373
1796
  }
1374
- const n = _(t, "wp-admin/auth.php");
1375
- if (e.fileExists(n)) {
1376
- const s = e.readFileAsText(n);
1797
+ const t = a(n, "wp-admin/auth.php");
1798
+ if (e.fileExists(t)) {
1799
+ const s = e.readFileAsText(t);
1377
1800
  if (s.includes("$cookiehash") && !s.includes("Playground: bypass auth")) {
1378
1801
  const r = `<?php
1379
1802
  require_once(ABSPATH . 'wp-config.php');
@@ -1415,27 +1838,27 @@ if (function_exists('get_userdatabylogin')) {
1415
1838
  }
1416
1839
  }
1417
1840
  ?>`;
1418
- r !== s && await e.writeFile(n, r);
1841
+ r !== s && await e.writeFile(t, r);
1419
1842
  }
1420
1843
  }
1421
1844
  }
1422
- async function Te(e, t) {
1423
- const i = _(t, "wp-admin/admin-ajax.php");
1845
+ async function qe(e, n) {
1846
+ const i = a(n, "wp-admin/admin-ajax.php");
1424
1847
  if (!e.fileExists(i)) return;
1425
- let n = e.readFileAsText(i);
1426
- if (!n.includes("is_user_logged_in")) return;
1848
+ let t = e.readFileAsText(i);
1849
+ if (!t.includes("is_user_logged_in")) return;
1427
1850
  const s = `
1428
1851
  // Playground: authenticate admin user for AJAX requests on WP < 2.8.
1429
1852
  if (defined('PLAYGROUND_AUTO_LOGIN_AS_USER')) {
1430
- ${x("PLAYGROUND_AUTO_LOGIN_AS_USER")}
1853
+ ${k("PLAYGROUND_AUTO_LOGIN_AS_USER")}
1431
1854
  }
1432
1855
  `;
1433
- n = n.replace(
1856
+ t = t.replace(
1434
1857
  /if\s*\(\s*!\s*is_user_logged_in\(\)\s*\)/,
1435
1858
  s + "if ( !is_user_logged_in() )"
1436
- ), await e.writeFile(i, n);
1859
+ ), await e.writeFile(i, t);
1437
1860
  }
1438
- function x(e) {
1861
+ function k(e) {
1439
1862
  return `
1440
1863
  $_pg_user = null;
1441
1864
  if (function_exists('wp_generate_auth_cookie')) {
@@ -1456,50 +1879,50 @@ if (function_exists('wp_generate_auth_cookie')) {
1456
1879
  }
1457
1880
  `;
1458
1881
  }
1459
- async function Le(e, t) {
1460
- const i = T(e, t);
1882
+ async function We(e, n) {
1883
+ const i = E(e, n);
1461
1884
  if (i === null) return;
1462
- const n = parseFloat(i);
1463
- if (!Number.isFinite(n) || n >= 3.3) return;
1464
- const s = _(
1465
- t,
1885
+ const t = parseFloat(i);
1886
+ if (!Number.isFinite(t) || t >= 3.3) return;
1887
+ const s = a(
1888
+ n,
1466
1889
  "wp-admin/includes/schema.php"
1467
1890
  );
1468
1891
  if (!e.fileExists(s)) return;
1469
1892
  const r = e.readFileAsText(s);
1470
- /\$wp_queries\s*=\s*"CREATE TABLE/.test(r) && !r.includes("function wp_get_db_schema") && await ye(e, t, s, r);
1893
+ /\$wp_queries\s*=\s*"CREATE TABLE/.test(r) && !r.includes("function wp_get_db_schema") && await Ge(e, n, s, r);
1471
1894
  }
1472
- async function ye(e, t, i, n) {
1473
- const s = n.match(/\$wp_queries\s*=\s*"CREATE TABLE/);
1895
+ async function Ge(e, n, i, t) {
1896
+ const s = t.match(/\$wp_queries\s*=\s*"CREATE TABLE/);
1474
1897
  if (!s || s.index === void 0)
1475
1898
  return;
1476
- const r = s.index, a = '";', o = n.indexOf(a, r);
1477
- if (o === -1)
1899
+ const r = s.index, o = '";', _ = t.indexOf(o, r);
1900
+ if (_ === -1)
1478
1901
  return;
1479
- const l = o + a.length, u = `function wp_get_db_schema( $scope = 'all', $blog_id = null ) {
1902
+ const l = _ + o.length, u = `function wp_get_db_schema( $scope = 'all', $blog_id = null ) {
1480
1903
  global $wpdb, $wp_queries, $charset_collate;
1481
1904
  $charset_collate = '';
1482
1905
  if ( ! empty($wpdb->charset) )
1483
1906
  $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
1484
1907
  if ( ! empty($wpdb->collate) )
1485
1908
  $charset_collate .= " COLLATE $wpdb->collate";
1486
- ${n.substring(r, l)}
1909
+ ${t.substring(r, l)}
1487
1910
  return $wp_queries;
1488
- }`, d = n.substring(0, r) + u + n.substring(l);
1489
- await e.writeFile(i, d);
1490
- const f = _(
1491
- t,
1911
+ }`, f = t.substring(0, r) + u + t.substring(l);
1912
+ await e.writeFile(i, f);
1913
+ const $ = a(
1914
+ n,
1492
1915
  "wp-admin/includes/upgrade.php"
1493
1916
  );
1494
- if (e.fileExists(f)) {
1495
- const p = e.readFileAsText(f), y = p.replace(
1917
+ if (e.fileExists($)) {
1918
+ const L = e.readFileAsText($), y = L.replace(
1496
1919
  /(\$alterations\s*=\s*dbDelta\(\s*\$wp_queries\s*\))/g,
1497
1920
  "if ( function_exists('wp_get_db_schema') ) { $wp_queries = wp_get_db_schema(); } $1"
1498
1921
  );
1499
- y !== p && await e.writeFile(f, y);
1922
+ y !== L && await e.writeFile($, y);
1500
1923
  }
1501
1924
  }
1502
- function be() {
1925
+ function Me() {
1503
1926
  return `<?php
1504
1927
  // @playground-managed — Playground-generated db.php.
1505
1928
  // WP < 3.0 loads only db.php and skips wp-db.php, so we pull
@@ -1551,11 +1974,12 @@ if (!function_exists('mysqli_close')) {
1551
1974
  }
1552
1975
  `;
1553
1976
  }
1554
- async function Oe(e, t) {
1977
+ async function Be(e, n) {
1978
+ if (await z(e)) return;
1555
1979
  let i = null;
1556
- const n = _(e.documentRoot, "wp-includes/version.php");
1557
- if (e.fileExists(n)) {
1558
- const r = e.readFileAsText(n).match(/\$wp_version\s*=\s*['"]([^'"]+)['"]/);
1980
+ const t = a(e.documentRoot, "wp-includes/version.php");
1981
+ if (e.fileExists(t)) {
1982
+ const r = e.readFileAsText(t).match(/\$wp_version\s*=\s*['"]([^'"]+)['"]/);
1559
1983
  r && (i = r[1]);
1560
1984
  }
1561
1985
  const s = i !== null && parseFloat(i) < 3.5;
@@ -1564,7 +1988,7 @@ async function Oe(e, t) {
1564
1988
  code: `<?php
1565
1989
  // WP_INSTALLING bypasses WP 1.x's "not installed" die() in wp-settings.php.
1566
1990
  define('WP_INSTALLING', true);
1567
- error_reporting(${L});
1991
+ error_reporting(${w});
1568
1992
  ini_set('display_errors', '0');
1569
1993
  ob_start();
1570
1994
  $_pg_db_path = getenv('DOCUMENT_ROOT') . '/wp-content/database/.ht.sqlite';
@@ -1706,11 +2130,11 @@ async function Oe(e, t) {
1706
2130
  `,
1707
2131
  env: {
1708
2132
  DOCUMENT_ROOT: e.documentRoot,
1709
- PLAYGROUND_SITE_URL: t || ""
2133
+ PLAYGROUND_SITE_URL: n || ""
1710
2134
  }
1711
2135
  });
1712
2136
  } catch (r) {
1713
- h.warn("Legacy WP post-install fixups failed (non-fatal):", r);
2137
+ d.warn("Legacy WP post-install fixups failed (non-fatal):", r);
1714
2138
  }
1715
2139
  if (s)
1716
2140
  try {
@@ -2011,14 +2435,14 @@ async function Oe(e, t) {
2011
2435
  `,
2012
2436
  env: {
2013
2437
  DOCUMENT_ROOT: e.documentRoot,
2014
- PLAYGROUND_SITE_URL: t || ""
2438
+ PLAYGROUND_SITE_URL: n || ""
2015
2439
  }
2016
2440
  });
2017
2441
  } catch (r) {
2018
- h.warn("Legacy WP PDO fallback failed (non-fatal):", r);
2442
+ d.warn("Legacy WP PDO fallback failed (non-fatal):", r);
2019
2443
  }
2020
2444
  }
2021
- const Pe = `
2445
+ const He = `
2022
2446
  // Connection stubs — wpdb::__construct bails on a falsy return.
2023
2447
  if (!function_exists('mysqli_connect')) {
2024
2448
  function mysqli_connect() { return true; }
@@ -2036,6 +2460,9 @@ if (!function_exists('mysql_select_db')) {
2036
2460
  if (!function_exists('mysql_set_charset')) {
2037
2461
  function mysql_set_charset() { return true; }
2038
2462
  }
2463
+ if (!defined('MYSQL_ASSOC')) define('MYSQL_ASSOC', 1);
2464
+ if (!defined('MYSQL_NUM')) define('MYSQL_NUM', 2);
2465
+ if (!defined('MYSQL_BOTH')) define('MYSQL_BOTH', 3);
2039
2466
  // Functional mysql_* stubs that delegate to $wpdb (SQLite driver).
2040
2467
  $GLOBALS['_mysql_results'] = array();
2041
2468
  $GLOBALS['_mysql_result_id'] = 0;
@@ -2101,6 +2528,23 @@ if (!function_exists('mysql_fetch_row')) {
2101
2528
  return array_values((array)$row);
2102
2529
  }
2103
2530
  }
2531
+ if (!function_exists('mysql_fetch_assoc')) {
2532
+ function mysql_fetch_assoc($result) {
2533
+ if (!isset($GLOBALS['_mysql_results'][$result])) return null;
2534
+ $r = &$GLOBALS['_mysql_results'][$result];
2535
+ if ($r['index'] >= count($r['rows'])) return null;
2536
+ return (array)$r['rows'][$r['index']++];
2537
+ }
2538
+ }
2539
+ if (!function_exists('mysql_fetch_array')) {
2540
+ function mysql_fetch_array($result, $result_type = null) {
2541
+ $row = mysql_fetch_assoc($result);
2542
+ if ($row === null) return null;
2543
+ if ($result_type === MYSQL_ASSOC) return $row;
2544
+ if ($result_type === MYSQL_NUM) return array_values($row);
2545
+ return array_merge(array_values($row), $row);
2546
+ }
2547
+ }
2104
2548
  if (!function_exists('mysql_fetch_object')) {
2105
2549
  function mysql_fetch_object($result) {
2106
2550
  if (!isset($GLOBALS['_mysql_results'][$result])) return null;
@@ -2159,28 +2603,28 @@ if (!function_exists('mysql_real_escape_string')) {
2159
2603
  if (!function_exists('mysql_escape_string')) {
2160
2604
  function mysql_escape_string($s) { return addslashes($s); }
2161
2605
  }`;
2162
- async function Ne(e, t, i = {}) {
2606
+ async function Xe(e, n, i = {}) {
2163
2607
  await e.isDir("/tmp/sqlite-database-integration") && await e.rmdir("/tmp/sqlite-database-integration", {
2164
2608
  recursive: !0
2165
- }), await e.mkdir("/tmp/sqlite-database-integration"), await m(e, t, "/tmp/sqlite-database-integration");
2166
- const n = "/internal/shared/sqlite-database-integration", s = `/tmp/sqlite-database-integration/${(await e.listFiles("/tmp/sqlite-database-integration"))[0]}`;
2167
- await e.mv(s, n), await Ae(e, n), await e.defineConstant("SQLITE_MAIN_FILE", "1");
2168
- let a = (await e.readFileAsText(
2169
- _(n, "db.copy")
2609
+ }), await e.mkdir("/tmp/sqlite-database-integration"), await g(e, n, "/tmp/sqlite-database-integration");
2610
+ const t = "/internal/shared/sqlite-database-integration", s = `/tmp/sqlite-database-integration/${(await e.listFiles("/tmp/sqlite-database-integration"))[0]}`;
2611
+ await e.mv(s, t), await Ve(e, t), await e.defineConstant("SQLITE_MAIN_FILE", "1");
2612
+ let o = (await e.readFileAsText(
2613
+ a(t, "db.copy")
2170
2614
  )).replace(
2171
2615
  "'{SQLITE_IMPLEMENTATION_FOLDER_PATH}'",
2172
- $(n)
2616
+ p(t)
2173
2617
  ).replace(
2174
2618
  "'{SQLITE_PLUGIN}'",
2175
- $(_(n, "load.php"))
2619
+ p(a(t, "load.php"))
2176
2620
  );
2177
- a = a.replace(
2621
+ o = o.replace(
2178
2622
  /^add_action\(/gm,
2179
2623
  'function_exists("add_action") && add_action('
2180
2624
  );
2181
- const o = _(await e.documentRoot, "wp-content/db.php"), l = "/internal/shared/mu-plugins/sqlite-database-integration.php", c = `
2182
- if(file_exists(${$(o)})) {
2183
- $_pg_db_php = @file_get_contents(${$(o)});
2625
+ const _ = a(await e.documentRoot, "wp-content/db.php"), l = "/internal/shared/mu-plugins/sqlite-database-integration.php", c = `
2626
+ if(file_exists(${p(_)})) {
2627
+ $_pg_db_php = @file_get_contents(${p(_)});
2184
2628
  if (strpos($_pg_db_php, '@playground-managed') === false) {
2185
2629
  return;
2186
2630
  }
@@ -2188,9 +2632,9 @@ if(file_exists(${$(o)})) {
2188
2632
  }
2189
2633
  `;
2190
2634
  await e.writeFile(l, `<?php
2191
- ${c}?>` + a), await e.writeFile(
2635
+ ${c}?>` + o), await e.writeFile(
2192
2636
  "/internal/shared/preload/0-sqlite.php",
2193
- Se(c, l)
2637
+ Ye(c, l)
2194
2638
  ), await e.writeFile(
2195
2639
  "/internal/shared/mu-plugins/sqlite-test.php",
2196
2640
  `<?php
@@ -2202,19 +2646,19 @@ ${c}?>` + a), await e.writeFile(
2202
2646
  `
2203
2647
  );
2204
2648
  }
2205
- async function Ae(e, t) {
2206
- const i = _(
2207
- t,
2649
+ async function Ve(e, n) {
2650
+ const i = a(
2651
+ n,
2208
2652
  "wp-includes/database/sqlite/class-wp-pdo-mysql-on-sqlite.php"
2209
2653
  );
2210
2654
  if (!await e.fileExists(i)) return;
2211
- const n = await e.readFileAsText(i), s = n.replace(
2655
+ const t = await e.readFileAsText(i), s = t.replace(
2212
2656
  /\$active_sql_modes\s*=\s*array\s*\([^)]*\)\s*;/,
2213
2657
  "$active_sql_modes = array();"
2214
2658
  );
2215
- s !== n && await e.writeFile(i, s);
2659
+ s !== t && await e.writeFile(i, s);
2216
2660
  }
2217
- function Se(e, t) {
2661
+ function Ye(e, n) {
2218
2662
  return `<?php
2219
2663
  ${e}?>
2220
2664
  <?php
@@ -2247,11 +2691,11 @@ if (
2247
2691
  }
2248
2692
  ?>
2249
2693
  <?php
2250
- ${v(
2694
+ ${S(
2251
2695
  // WP < 3.0's wpdb does mysql_connect() inline so the SQLite
2252
2696
  // plugin's db_connect() never runs; reinitialize_sqlite()
2253
2697
  // swaps the dbh in place after the integration is loaded.
2254
- `require_once ${$(t)};
2698
+ `require_once ${p(n)};
2255
2699
  if (
2256
2700
  isset($GLOBALS['wpdb']) &&
2257
2701
  method_exists($GLOBALS['wpdb'], 'reinitialize_sqlite')
@@ -2259,18 +2703,18 @@ ${v(
2259
2703
  $GLOBALS['wpdb']->reinitialize_sqlite();
2260
2704
  }`
2261
2705
  )}
2262
- ${Pe}
2706
+ ${He}
2263
2707
  if (PHP_MAJOR_VERSION < 7) {
2264
2708
  // E_DEPRECATED (8192) / E_STRICT (2048) are PHP 5.3+ symbols;
2265
2709
  // LEGACY_WP_ERROR_REPORTING_PHP_EXPR uses numeric literals.
2266
- $level = ${L};
2710
+ $level = ${w};
2267
2711
  error_reporting($level);
2268
2712
  ini_set('error_reporting', $level);
2269
2713
  }
2270
2714
 
2271
2715
  `;
2272
2716
  }
2273
- const U = `<?php
2717
+ const v = `<?php
2274
2718
 
2275
2719
  /**
2276
2720
  * Transforms the "wp-config.php" file.
@@ -2742,32 +3186,32 @@ class WP_Config_Transformer {
2742
3186
  }
2743
3187
  }
2744
3188
  `;
2745
- async function ve(e, t) {
2746
- const i = _(t, "wp-config.php");
2747
- !e.fileExists(i) && e.fileExists(_(t, "wp-config-sample.php")) && await e.writeFile(
3189
+ async function Ke(e, n) {
3190
+ const i = a(n, "wp-config.php");
3191
+ !e.fileExists(i) && e.fileExists(a(n, "wp-config-sample.php")) && await e.writeFile(
2748
3192
  i,
2749
3193
  await e.readFileAsBuffer(
2750
- _(t, "wp-config-sample.php")
3194
+ a(n, "wp-config-sample.php")
2751
3195
  )
2752
- ), e.fileExists(i) && await xe(e, i, {
3196
+ ), e.fileExists(i) && await Qe(e, i, {
2753
3197
  DB_NAME: "wordpress"
2754
3198
  });
2755
3199
  }
2756
- async function st(e, t, i) {
2757
- const n = A({ wpConfigPath: t, constants: i });
3200
+ async function Lt(e, n, i) {
3201
+ const t = P({ wpConfigPath: n, constants: i });
2758
3202
  if ((await e.run({
2759
- code: `${U}
2760
- $wp_config_path = ${n.wpConfigPath};
3203
+ code: `${v}
3204
+ $wp_config_path = ${t.wpConfigPath};
2761
3205
  $transformer = WP_Config_Transformer::from_file($wp_config_path);
2762
- $transformer->define_constants(${n.constants});
3206
+ $transformer->define_constants(${t.constants});
2763
3207
  $transformer->to_file($wp_config_path);
2764
3208
  `
2765
3209
  })).errors.length > 0)
2766
3210
  throw new Error("Failed to rewrite constants in wp-config.php.");
2767
3211
  }
2768
- async function xe(e, t, i) {
2769
- const n = Object.keys(i), s = A({ wpConfigPath: t, constantNames: n }), r = await e.run({
2770
- code: `${U}
3212
+ async function Qe(e, n, i) {
3213
+ const t = Object.keys(i), s = P({ wpConfigPath: n, constantNames: t }), r = await e.run({
3214
+ code: `${v}
2771
3215
  $transformer = WP_Config_Transformer::from_file(${s.wpConfigPath});
2772
3216
  $missing = [];
2773
3217
  foreach (${s.constantNames} as $name) {
@@ -2780,42 +3224,42 @@ async function xe(e, t, i) {
2780
3224
  });
2781
3225
  if (r.errors.length > 0)
2782
3226
  throw new Error("Failed to check wp-config.php for constants.");
2783
- let a;
3227
+ let o;
2784
3228
  try {
2785
- a = JSON.parse(r.text);
3229
+ o = JSON.parse(r.text);
2786
3230
  } catch {
2787
3231
  throw new Error(
2788
3232
  `Failed to parse wp-config.php constant check output: ${r.text}`
2789
3233
  );
2790
3234
  }
2791
- for (const o of a)
2792
- await e.defineConstant(o, i[o]);
3235
+ for (const _ of o)
3236
+ await e.defineConstant(_, i[_]);
2793
3237
  }
2794
- async function E(e, {
2795
- usesSqlite: t,
3238
+ async function T(e, {
3239
+ usesSqlite: n,
2796
3240
  hasCustomDatabasePath: i
2797
3241
  }) {
2798
- const n = await e.getPrimaryPhp();
2799
- if (n.isFile("/internal/shared/preload/0-sqlite.php"))
3242
+ const t = await e.getPrimaryPhp();
3243
+ if (t.isFile("/internal/shared/preload/0-sqlite.php"))
2800
3244
  return;
2801
- const s = _(
3245
+ const s = a(
2802
3246
  e.documentRoot,
2803
3247
  "wp-content/mu-plugins/sqlite-database-integration"
2804
3248
  );
2805
- if (!n.isDir(s) && !t && !i && !Ue(n))
3249
+ if (!t.isDir(s) && !n && !i && !je(t))
2806
3250
  throw new Error("Error connecting to the MySQL database.");
2807
3251
  }
2808
- function Ue(e) {
2809
- const t = _(e.documentRoot, "wp-config.php");
2810
- if (!e.isFile(t)) return !1;
2811
- const i = e.readFileAsText(t), n = i.match(
3252
+ function je(e) {
3253
+ const n = a(e.documentRoot, "wp-config.php");
3254
+ if (!e.isFile(n)) return !1;
3255
+ const i = e.readFileAsText(n), t = i.match(
2812
3256
  /define\s*\(\s*['"]DB_NAME['"]\s*,\s*['"]([^'"]*)['"]/
2813
3257
  ), s = i.match(
2814
3258
  /define\s*\(\s*['"]DB_USER['"]\s*,\s*['"]([^'"]*)['"]/
2815
3259
  );
2816
- return !n || !s ? !1 : n[1] !== "database_name_here" && s[1] !== "username_here";
3260
+ return !t || !s ? !1 : t[1] !== "database_name_here" && s[1] !== "username_here";
2817
3261
  }
2818
- const R = [
3262
+ const D = [
2819
3263
  "fsockopen",
2820
3264
  "pfsockopen",
2821
3265
  "curl_init",
@@ -2823,77 +3267,77 @@ const R = [
2823
3267
  "curl_multi_exec",
2824
3268
  "mail"
2825
3269
  ];
2826
- function Re(e, t) {
2827
- var r, a;
2828
- if (!w(t.phpVersion)) return;
2829
- const i = (((r = t.phpIniEntries) == null ? void 0 : r.disable_functions) ?? "").split(",").map((o) => o.trim()).filter((o) => o), s = {
3270
+ function ze(e, n) {
3271
+ var r, o;
3272
+ if (!m(n.phpVersion)) return;
3273
+ const i = (((r = n.phpIniEntries) == null ? void 0 : r.disable_functions) ?? "").split(",").map((_) => _.trim()).filter((_) => _), s = {
2830
3274
  disable_functions: Array.from(
2831
- /* @__PURE__ */ new Set([...i, ...R])
3275
+ /* @__PURE__ */ new Set([...i, ...D])
2832
3276
  ).join(","),
2833
3277
  allow_url_fopen: "0"
2834
3278
  };
2835
- (a = t.phpIniEntries) != null && a["date.timezone"] || (s["date.timezone"] = "UTC"), P(e, s);
3279
+ (o = n.phpIniEntries) != null && o["date.timezone"] || (s["date.timezone"] = "UTC"), N(e, s);
2836
3280
  }
2837
- async function ke(e, t) {
2838
- var a, o;
3281
+ async function Ze(e, n) {
3282
+ var o, _;
2839
3283
  const i = await e.getPrimaryPhp();
2840
- if ((a = t.hooks) != null && a.beforeWordPressFiles && await t.hooks.beforeWordPressFiles(i), t.wordPressZip && await D(i, await t.wordPressZip), t.constants)
2841
- for (const l in t.constants)
2842
- i.defineConstant(l, t.constants[l]);
2843
- i.defineConstant("WP_HOME", t.siteUrl), i.defineConstant("WP_SITEURL", t.siteUrl), await Ie(i, e.documentRoot), await K(i, e.documentRoot), (o = t.hooks) != null && o.beforeDatabaseSetup && await t.hooks.beforeDatabaseSetup(i);
2844
- let n = !1;
2845
- t.sqliteIntegrationPluginZip && (n = !0, await I(
3284
+ if ((o = n.hooks) != null && o.beforeWordPressFiles && await n.hooks.beforeWordPressFiles(i), n.wordPressZip && await q(i, await n.wordPressZip), n.constants)
3285
+ for (const l in n.constants)
3286
+ i.defineConstant(l, n.constants[l]);
3287
+ i.defineConstant("WP_HOME", n.siteUrl), i.defineConstant("WP_SITEURL", n.siteUrl), await Je(i, e.documentRoot), await pe(i, e.documentRoot), (_ = n.hooks) != null && _.beforeDatabaseSetup && await n.hooks.beforeDatabaseSetup(i);
3288
+ let t = !1;
3289
+ n.sqliteIntegrationPluginZip && (t = !0, await C(
2846
3290
  i,
2847
- await t.sqliteIntegrationPluginZip,
2848
- { phpVersion: t.phpVersion }
2849
- ), await De(i, e.documentRoot));
2850
- const s = t.wordpressInstallMode ?? "download-and-install", r = !!t.dataSqlPath;
3291
+ await n.sqliteIntegrationPluginZip,
3292
+ { phpVersion: n.phpVersion }
3293
+ ), await et(i, e.documentRoot));
3294
+ const s = n.wordpressInstallMode ?? "download-and-install", r = !!n.dataSqlPath;
2851
3295
  return (s === "download-and-install" || s === "install-from-existing-files" || // Legacy PHP: isWordPressInstalled() can trigger a WASM trap
2852
3296
  // (not a PHP exception) on old WordPress (< 3.0) and corrupt
2853
3297
  // the runtime beyond recovery. Always run the installer; it
2854
3298
  // is idempotent and its post-install fixups short-circuit
2855
3299
  // cheaply when the schema already exists.
2856
- s === "install-from-existing-files-if-needed") && (await E(e, {
2857
- usesSqlite: n,
3300
+ s === "install-from-existing-files-if-needed") && (await T(e, {
3301
+ usesSqlite: t,
2858
3302
  hasCustomDatabasePath: r
2859
- }), await Fe(i, e)), e;
3303
+ }), await tt(i, e)), e;
2860
3304
  }
2861
- async function Ie(e, t) {
2862
- const i = _(t, "wp-config.php"), n = _(t, "wp-config-sample.php");
2863
- !e.fileExists(i) && e.fileExists(n) && await e.writeFile(
3305
+ async function Je(e, n) {
3306
+ const i = a(n, "wp-config.php"), t = a(n, "wp-config-sample.php");
3307
+ !e.fileExists(i) && e.fileExists(t) && await e.writeFile(
2864
3308
  i,
2865
- await e.readFileAsBuffer(n)
3309
+ await e.readFileAsBuffer(t)
2866
3310
  );
2867
3311
  }
2868
- async function De(e, t) {
2869
- const i = _(t, "wp-content"), n = _(i, "db.php");
2870
- e.isDir(i) && !e.fileExists(n) && await e.writeFile(n, be());
3312
+ async function et(e, n) {
3313
+ const i = a(n, "wp-content"), t = a(i, "db.php");
3314
+ e.isDir(i) && !e.fileExists(t) && await e.writeFile(t, Me());
2871
3315
  }
2872
- async function Fe(e, t) {
3316
+ async function tt(e, n) {
2873
3317
  try {
2874
- await Ce(e);
3318
+ await nt(e);
2875
3319
  } catch (i) {
2876
- h.warn("Legacy PHP WordPress installation error:", i);
3320
+ d.warn("Legacy PHP WordPress installation error:", i);
2877
3321
  }
2878
- await Oe(e, t.absoluteUrl);
2879
- }
2880
- async function Ce(e) {
2881
- var r, a, o, l, c, u;
2882
- const t = Ge(e, e.documentRoot);
2883
- if (t !== null) {
2884
- const d = parseFloat(t);
2885
- if (d < 2.1)
3322
+ await Be(e, n.absoluteUrl);
3323
+ }
3324
+ async function nt(e) {
3325
+ var r, o, _, l, c, u;
3326
+ const n = rt(e, e.documentRoot);
3327
+ if (n !== null) {
3328
+ const f = parseFloat(n);
3329
+ if (f < 2.1)
2886
3330
  return;
2887
- if (d <= 3) {
2888
- await We(e);
3331
+ if (f <= 3) {
3332
+ await st(e);
2889
3333
  return;
2890
3334
  }
2891
3335
  }
2892
3336
  const i = {
2893
- disable_functions: R.join(","),
3337
+ disable_functions: D.join(","),
2894
3338
  allow_url_fopen: "0",
2895
- error_reporting: String(Y)
2896
- }, n = await N(
3339
+ error_reporting: String(ue)
3340
+ }, t = await A(
2897
3341
  e,
2898
3342
  i,
2899
3343
  async () => await e.request({
@@ -2912,16 +3356,16 @@ async function Ce(e) {
2912
3356
  }
2913
3357
  })
2914
3358
  );
2915
- if (!(((r = n.text) == null ? void 0 : r.includes("Success")) || ((a = n.text) == null ? void 0 : a.includes("successful")) || ((o = n.text) == null ? void 0 : o.includes("Finished")) || ((l = n.text) == null ? void 0 : l.includes("Already Installed")) || ((c = n.text) == null ? void 0 : c.includes("already have WordPress installed")) || !1))
3359
+ if (!(((r = t.text) == null ? void 0 : r.includes("Success")) || ((o = t.text) == null ? void 0 : o.includes("successful")) || ((_ = t.text) == null ? void 0 : _.includes("Finished")) || ((l = t.text) == null ? void 0 : l.includes("Already Installed")) || ((c = t.text) == null ? void 0 : c.includes("already have WordPress installed")) || !1))
2916
3360
  throw new Error(
2917
- `Failed to install WordPress – installer responded with "${(u = n.text) == null ? void 0 : u.substring(
3361
+ `Failed to install WordPress – installer responded with "${(u = t.text) == null ? void 0 : u.substring(
2918
3362
  0,
2919
3363
  100
2920
3364
  )}"`
2921
3365
  );
2922
- await qe(e);
3366
+ await it(e);
2923
3367
  }
2924
- async function qe(e) {
3368
+ async function it(e) {
2925
3369
  try {
2926
3370
  (await e.run({
2927
3371
  code: `<?php
@@ -2947,21 +3391,21 @@ async function qe(e) {
2947
3391
  echo $check === $nice_permalinks ? '1' : '0';
2948
3392
  `,
2949
3393
  env: { DOCUMENT_ROOT: e.documentRoot }
2950
- })).text !== "1" && h.warn(
3394
+ })).text !== "1" && d.warn(
2951
3395
  "Failed to default to pretty permalinks after WP install."
2952
3396
  );
2953
3397
  } catch {
2954
- h.warn(
3398
+ d.warn(
2955
3399
  "Failed to set pretty permalinks after WP install (non-fatal)."
2956
3400
  );
2957
3401
  }
2958
3402
  }
2959
- async function We(e) {
3403
+ async function st(e) {
2960
3404
  try {
2961
3405
  await e.run({
2962
3406
  code: `<?php
2963
3407
  define('WP_INSTALLING', true);
2964
- error_reporting(${L});
3408
+ error_reporting(${w});
2965
3409
  ini_set('display_errors', '0');
2966
3410
  ob_start();
2967
3411
  require getenv('DOCUMENT_ROOT') . '/wp-load.php';
@@ -2983,85 +3427,85 @@ async function We(e) {
2983
3427
  `,
2984
3428
  env: { DOCUMENT_ROOT: e.documentRoot }
2985
3429
  });
2986
- } catch (t) {
2987
- h.warn("runDbDeltaOnly failed (non-fatal):", t);
3430
+ } catch (n) {
3431
+ d.warn("runDbDeltaOnly failed (non-fatal):", n);
2988
3432
  }
2989
3433
  }
2990
- function Ge(e, t) {
2991
- const i = _(t, "wp-includes/version.php");
3434
+ function rt(e, n) {
3435
+ const i = a(n, "wp-includes/version.php");
2992
3436
  if (!e.fileExists(i)) return null;
2993
3437
  const s = e.readFileAsText(i).match(/\$wp_version\s*=\s*['"]([^'"]+)['"]/);
2994
3438
  return s ? s[1] : null;
2995
3439
  }
2996
- async function rt(e) {
2997
- const t = await He(e);
2998
- return await Me(t, e), t;
3440
+ async function yt(e) {
3441
+ const n = await ot(e);
3442
+ return await at(n, e), n;
2999
3443
  }
3000
- async function Me(e, t) {
3001
- var a, o;
3002
- if (w(t.phpVersion))
3003
- return ke(e, t);
3444
+ async function at(e, n) {
3445
+ var o, _;
3446
+ if (m(n.phpVersion))
3447
+ return Ze(e, n);
3004
3448
  const i = await e.getPrimaryPhp();
3005
- if ((a = t.hooks) != null && a.beforeWordPressFiles && await t.hooks.beforeWordPressFiles(i), t.wordPressZip && await D(i, await t.wordPressZip), t.constants)
3006
- for (const l in t.constants)
3007
- i.defineConstant(l, t.constants[l]);
3008
- t.dataSqlPath && (i.defineConstant("DB_DIR", W(t.dataSqlPath)), i.defineConstant("DB_FILE", G(t.dataSqlPath))), i.defineConstant("WP_HOME", t.siteUrl), i.defineConstant("WP_SITEURL", t.siteUrl), await ve(i, e.documentRoot), (o = t.hooks) != null && o.beforeDatabaseSetup && await t.hooks.beforeDatabaseSetup(i);
3009
- let n = !1;
3010
- t.sqliteIntegrationPluginZip && (n = !0, await I(
3449
+ if ((o = n.hooks) != null && o.beforeWordPressFiles && await n.hooks.beforeWordPressFiles(i), n.wordPressZip && await q(i, await n.wordPressZip), n.constants)
3450
+ for (const l in n.constants)
3451
+ i.defineConstant(l, n.constants[l]);
3452
+ n.dataSqlPath && (i.defineConstant("DB_DIR", B(n.dataSqlPath)), i.defineConstant("DB_FILE", H(n.dataSqlPath))), i.defineConstant("WP_HOME", n.siteUrl), i.defineConstant("WP_SITEURL", n.siteUrl), await Ke(i, e.documentRoot), (_ = n.hooks) != null && _.beforeDatabaseSetup && await n.hooks.beforeDatabaseSetup(i);
3453
+ let t = !1;
3454
+ n.sqliteIntegrationPluginZip && (t = !0, await C(
3011
3455
  i,
3012
- await t.sqliteIntegrationPluginZip,
3013
- { phpVersion: t.phpVersion }
3014
- ), await X(i, e.documentRoot));
3015
- const s = t.wordpressInstallMode ?? "download-and-install", r = !!t.dataSqlPath;
3456
+ await n.sqliteIntegrationPluginZip,
3457
+ { phpVersion: n.phpVersion }
3458
+ ), await ce(i, e.documentRoot));
3459
+ const s = n.wordpressInstallMode ?? "download-and-install", r = !!n.dataSqlPath;
3016
3460
  if (["download-and-install", "install-from-existing-files"].includes(
3017
3461
  s
3018
3462
  )) {
3019
- await E(e, {
3020
- usesSqlite: n,
3463
+ await T(e, {
3464
+ usesSqlite: t,
3021
3465
  hasCustomDatabasePath: r
3022
3466
  });
3023
3467
  try {
3024
- await O(i);
3468
+ await b(i);
3025
3469
  } catch (l) {
3026
- throw r || await g(e), l;
3470
+ throw r || await h(e), l;
3027
3471
  }
3028
- r || await g(e);
3472
+ r || await h(e);
3029
3473
  } else if (s === "install-from-existing-files-if-needed") {
3030
- if (await E(e, {
3031
- usesSqlite: n,
3474
+ if (await T(e, {
3475
+ usesSqlite: t,
3032
3476
  hasCustomDatabasePath: r
3033
- }), !await k(i))
3477
+ }), !await F(i))
3034
3478
  try {
3035
- await O(i);
3479
+ await b(i);
3036
3480
  } catch (l) {
3037
- throw r || await g(e), l;
3481
+ throw r || await h(e), l;
3038
3482
  }
3039
- r || await g(e);
3483
+ r || await h(e);
3040
3484
  }
3041
3485
  return e;
3042
3486
  }
3043
- async function g(e) {
3044
- const t = await e.getPrimaryPhp();
3045
- if (await Ve(t))
3487
+ async function h(e) {
3488
+ const n = await e.getPrimaryPhp();
3489
+ if (await lt(n))
3046
3490
  return;
3047
- if (t.isFile("/internal/shared/preload/0-sqlite.php"))
3491
+ if (n.isFile("/internal/shared/preload/0-sqlite.php"))
3048
3492
  throw new Error("Error connecting to the SQLite database.");
3049
- const n = _(
3493
+ const t = a(
3050
3494
  e.documentRoot,
3051
3495
  "wp-content/mu-plugins/sqlite-database-integration"
3052
3496
  );
3053
- throw t.isDir(n) ? new Error("Error connecting to the SQLite database.") : new Error("Error connecting to the MySQL database.");
3497
+ throw n.isDir(t) ? new Error("Error connecting to the SQLite database.") : new Error("Error connecting to the MySQL database.");
3054
3498
  }
3055
- async function He(e) {
3056
- const t = e.spawnHandler ?? F;
3499
+ async function ot(e) {
3500
+ const n = e.spawnHandler ?? W;
3057
3501
  async function i(s, r = !1) {
3058
- const a = await e.createPhpRuntime(r), o = new q(a);
3059
- if (e.sapiName && o.setSapiName(e.sapiName), s && (o.requestHandler = s), e.phpIniEntries && P(o, e.phpIniEntries), Re(o, {
3502
+ const o = await e.createPhpRuntime(r), _ = new M(o);
3503
+ if (e.sapiName && _.setSapiName(e.sapiName), s && (_.requestHandler = s), e.phpIniEntries && N(_, e.phpIniEntries), ze(_, {
3060
3504
  phpVersion: e.phpVersion,
3061
3505
  phpIniEntries: e.phpIniEntries
3062
- }), o.defineConstant("WP_SQLITE_AST_DRIVER", !0), e.constants)
3506
+ }), _.defineConstant("WP_SQLITE_AST_DRIVER", !0), e.constants)
3063
3507
  for (const l in e.constants)
3064
- o.defineConstant(l, e.constants[l]);
3508
+ _.defineConstant(l, e.constants[l]);
3065
3509
  return r && /**
3066
3510
  * Only the first PHP instance of the first worker created
3067
3511
  * during WordPress boot writes these files – otherwise we'll keep
@@ -3072,28 +3516,28 @@ async function He(e) {
3072
3516
  * mechanism. It works, because secondary workers are only booted
3073
3517
  * once the primary worker has fully booted.
3074
3518
  */
3075
- !o.isFile("/internal/.boot-files-written") && (await Ke(o, {
3519
+ !_.isFile("/internal/.boot-files-written") && (await pt(_, {
3076
3520
  phpVersion: e.phpVersion
3077
- }), await b(o, "/", e.createFiles || {}), await Qe(
3078
- o,
3079
- _(new URL(e.siteUrl).pathname, "phpinfo.php")
3080
- ), await b(o, "/internal", {
3521
+ }), await O(_, "/", e.createFiles || {}), await dt(
3522
+ _,
3523
+ a(new URL(e.siteUrl).pathname, "phpinfo.php")
3524
+ ), await O(_, "/internal", {
3081
3525
  ".boot-files-written": ""
3082
- })), t && await o.setSpawnHandler(
3083
- t(
3526
+ })), n && await _.setSpawnHandler(
3527
+ n(
3084
3528
  s ? () => s.instanceManager.acquirePHPInstance() : void 0
3085
3529
  )
3086
- ), o.enableRuntimeRotation({
3530
+ ), _.enableRuntimeRotation({
3087
3531
  recreateRuntime: e.createPhpRuntime,
3088
3532
  maxRequests: 400
3089
- }), e.onPHPInstanceCreated && await e.onPHPInstanceCreated(o, { isPrimary: r }), o;
3533
+ }), e.onPHPInstanceCreated && await e.onPHPInstanceCreated(_, { isPrimary: r }), _;
3090
3534
  }
3091
- const n = new C({
3535
+ const t = new G({
3092
3536
  documentRoot: e.documentRoot || "/wordpress",
3093
3537
  absoluteUrl: e.siteUrl,
3094
- rewriteRules: Ye,
3538
+ rewriteRules: ut,
3095
3539
  pathAliases: e.pathAliases,
3096
- getFileNotFoundAction: e.getFileNotFoundAction ?? Be,
3540
+ getFileNotFoundAction: e.getFileNotFoundAction ?? _t,
3097
3541
  cookieStore: e.cookieStore,
3098
3542
  /**
3099
3543
  * If maxPhpInstances is 1, the PHPRequestHandler constructor needs
@@ -3106,12 +3550,12 @@ async function He(e) {
3106
3550
  * a PHP factory function. Internally, it creates a PHPProcessManager that
3107
3551
  * maintains a pool of reusable PHP instances.
3108
3552
  */
3109
- phpFactory: e.maxPhpInstances !== 1 ? async ({ isPrimary: s }) => i(n, s) : void 0,
3553
+ phpFactory: e.maxPhpInstances !== 1 ? async ({ isPrimary: s }) => i(t, s) : void 0,
3110
3554
  maxPhpInstances: e.maxPhpInstances
3111
3555
  });
3112
- return n;
3556
+ return t;
3113
3557
  }
3114
- async function k(e) {
3558
+ async function F(e) {
3115
3559
  return (await e.run({
3116
3560
  code: `<?php
3117
3561
  ob_start();
@@ -3130,9 +3574,9 @@ async function k(e) {
3130
3574
  }
3131
3575
  })).text === "1";
3132
3576
  }
3133
- async function O(e) {
3134
- var n;
3135
- const t = await N(
3577
+ async function b(e) {
3578
+ var t;
3579
+ const n = await A(
3136
3580
  e,
3137
3581
  {
3138
3582
  disable_functions: "fsockopen",
@@ -3155,9 +3599,9 @@ async function O(e) {
3155
3599
  }
3156
3600
  })
3157
3601
  );
3158
- if (!await k(e))
3602
+ if (!await F(e))
3159
3603
  throw new Error(
3160
- `Failed to install WordPress – installer responded with "${(n = t.text) == null ? void 0 : n.substring(
3604
+ `Failed to install WordPress – installer responded with "${(t = n.text) == null ? void 0 : t.substring(
3161
3605
  0,
3162
3606
  100
3163
3607
  )}"`
@@ -3187,15 +3631,15 @@ async function O(e) {
3187
3631
  env: {
3188
3632
  DOCUMENT_ROOT: e.documentRoot
3189
3633
  }
3190
- })).text !== "1" && h.warn("Failed to default to pretty permalinks after WP install.");
3634
+ })).text !== "1" && d.warn("Failed to default to pretty permalinks after WP install.");
3191
3635
  }
3192
- function Be(e) {
3636
+ function _t(e) {
3193
3637
  return {
3194
3638
  type: "internal-redirect",
3195
3639
  uri: "/index.php"
3196
3640
  };
3197
3641
  }
3198
- async function Ve(e) {
3642
+ async function lt(e) {
3199
3643
  return (await e.run({
3200
3644
  code: `<?php
3201
3645
  ob_start();
@@ -3214,10 +3658,10 @@ async function Ve(e) {
3214
3658
  }
3215
3659
  })).text === "1";
3216
3660
  }
3217
- async function at(e) {
3218
- const { php: t, reap: i } = await e.instanceManager.acquirePHPInstance();
3661
+ async function Ot(e) {
3662
+ const { php: n, reap: i } = await e.instanceManager.acquirePHPInstance();
3219
3663
  try {
3220
- const s = (await t.run({
3664
+ const s = (await n.run({
3221
3665
  code: `<?php
3222
3666
  require '${e.documentRoot}/wp-includes/version.php';
3223
3667
  echo $wp_version;
@@ -3225,20 +3669,20 @@ async function at(e) {
3225
3669
  })).text;
3226
3670
  if (!s)
3227
3671
  throw new Error("Unable to read loaded WordPress version.");
3228
- return Xe(s);
3672
+ return ct(s);
3229
3673
  } finally {
3230
3674
  i();
3231
3675
  }
3232
3676
  }
3233
- function Xe(e) {
3677
+ function ct(e) {
3234
3678
  if (/-(alpha|beta|RC)\d*-\d+$/.test(e))
3235
3679
  return "trunk";
3236
3680
  if (/-(beta|RC)\d*$/.test(e))
3237
3681
  return "beta";
3238
- const n = e.match(/^(\d+\.\d+)(?:\.\d+)?$/);
3239
- return n !== null ? n[1] : e;
3682
+ const t = e.match(/^(\d+\.\d+)(?:\.\d+)?$/);
3683
+ return t !== null ? t[1] : e;
3240
3684
  }
3241
- const Ye = [
3685
+ const ut = [
3242
3686
  /**
3243
3687
  * Substitutes the multisite WordPress rewrite rule:
3244
3688
  *
@@ -3254,9 +3698,9 @@ const Ye = [
3254
3698
  replacement: "$2"
3255
3699
  }
3256
3700
  ];
3257
- async function Ke(e, t = {}) {
3258
- if (w(t.phpVersion))
3259
- return B(e);
3701
+ async function pt(e, n = {}) {
3702
+ if (m(n.phpVersion))
3703
+ return Y(e);
3260
3704
  await e.mkdir("/internal/shared/mu-plugins"), await e.writeFile(
3261
3705
  "/internal/shared/preload/env.php",
3262
3706
  `<?php
@@ -3444,7 +3888,7 @@ async function Ke(e, t = {}) {
3444
3888
  return $interval;
3445
3889
  });
3446
3890
  `
3447
- ), await S(e), await e.writeFile(
3891
+ ), await U(e), await e.writeFile(
3448
3892
  "/internal/shared/preload/error-handler.php",
3449
3893
  `<?php
3450
3894
  (function() {
@@ -3497,13 +3941,13 @@ async function Ke(e, t = {}) {
3497
3941
  })();`
3498
3942
  );
3499
3943
  }
3500
- async function Qe(e, t = "/phpinfo.php") {
3944
+ async function dt(e, n = "/phpinfo.php") {
3501
3945
  await e.writeFile(
3502
3946
  "/internal/shared/preload/phpinfo.php",
3503
3947
  `<?php
3504
3948
  // Render PHPInfo if the requested page is /phpinfo.php
3505
- if ( isset($_SERVER['REQUEST_URI']) && ${$(
3506
- t
3949
+ if ( isset($_SERVER['REQUEST_URI']) && ${p(
3950
+ n
3507
3951
  )} === $_SERVER['REQUEST_URI'] ) {
3508
3952
  phpinfo();
3509
3953
  exit;
@@ -3511,43 +3955,43 @@ async function Qe(e, t = "/phpinfo.php") {
3511
3955
  `
3512
3956
  );
3513
3957
  }
3514
- async function I(e, t, i = {}) {
3515
- if (w(i.phpVersion))
3516
- return Ne(e, t, i);
3958
+ async function C(e, n, i = {}) {
3959
+ if (m(i.phpVersion))
3960
+ return Xe(e, n, i);
3517
3961
  await e.isDir("/tmp/sqlite-database-integration") && await e.rmdir("/tmp/sqlite-database-integration", {
3518
3962
  recursive: !0
3519
- }), await e.mkdir("/tmp/sqlite-database-integration"), await m(e, t, "/tmp/sqlite-database-integration");
3520
- const n = "/internal/shared/sqlite-database-integration", s = `/tmp/sqlite-database-integration/${(await e.listFiles("/tmp/sqlite-database-integration"))[0]}`;
3521
- await e.mv(s, n);
3522
- const r = _(
3523
- n,
3963
+ }), await e.mkdir("/tmp/sqlite-database-integration"), await g(e, n, "/tmp/sqlite-database-integration");
3964
+ const t = "/internal/shared/sqlite-database-integration", s = `/tmp/sqlite-database-integration/${(await e.listFiles("/tmp/sqlite-database-integration"))[0]}`;
3965
+ await e.mv(s, t);
3966
+ const r = a(
3967
+ t,
3524
3968
  "wp-includes/sqlite/class-wp-sqlite-db.php"
3525
3969
  );
3526
3970
  if (await e.fileExists(r)) {
3527
- const d = await e.readFileAsText(r), f = d.replace(
3971
+ const f = await e.readFileAsText(r), $ = f.replace(
3528
3972
  "private $allow_unsafe_unquoted_parameters",
3529
3973
  "protected $allow_unsafe_unquoted_parameters"
3530
3974
  );
3531
- f !== d && await e.writeFile(r, f);
3975
+ $ !== f && await e.writeFile(r, $);
3532
3976
  }
3533
3977
  await e.defineConstant("SQLITE_MAIN_FILE", "1");
3534
- const o = (await e.readFileAsText(
3535
- _(n, "db.copy")
3978
+ const _ = (await e.readFileAsText(
3979
+ a(t, "db.copy")
3536
3980
  )).replace(
3537
3981
  "'{SQLITE_IMPLEMENTATION_FOLDER_PATH}'",
3538
- $(n)
3982
+ p(t)
3539
3983
  ).replace(
3540
3984
  "'{SQLITE_PLUGIN}'",
3541
- $(_(n, "load.php"))
3542
- ), l = _(await e.documentRoot, "wp-content/db.php"), c = `<?php
3985
+ p(a(t, "load.php"))
3986
+ ), l = a(await e.documentRoot, "wp-content/db.php"), c = `<?php
3543
3987
  // Do not preload this if WordPress comes with a custom db.php file.
3544
- if(file_exists(${$(l)})) {
3988
+ if(file_exists(${p(l)})) {
3545
3989
  return;
3546
3990
  }
3547
3991
  ?>`, u = "/internal/shared/mu-plugins/sqlite-database-integration.php";
3548
- await e.writeFile(u, c + o), await e.writeFile(
3992
+ await e.writeFile(u, c + _), await e.writeFile(
3549
3993
  "/internal/shared/preload/0-sqlite.php",
3550
- je(c, u)
3994
+ ft(c, u)
3551
3995
  ), await e.writeFile(
3552
3996
  "/internal/shared/mu-plugins/sqlite-test.php",
3553
3997
  `<?php
@@ -3559,104 +4003,104 @@ async function I(e, t, i = {}) {
3559
4003
  `
3560
4004
  );
3561
4005
  }
3562
- function je(e, t) {
4006
+ function ft(e, n) {
3563
4007
  return e + `<?php
3564
4008
 
3565
- ${v(`require_once ${$(t)};`)}
4009
+ ${S(`require_once ${p(n)};`)}
3566
4010
  if(!function_exists('mysqli_connect')) {
3567
4011
  function mysqli_connect() {}
3568
4012
  }
3569
4013
 
3570
4014
  `;
3571
4015
  }
3572
- async function D(e, t) {
3573
- e.mkdir("/tmp/unzipped-wordpress"), await m(e, t, "/tmp/unzipped-wordpress"), e.fileExists("/tmp/unzipped-wordpress/wordpress.zip") && await m(
4016
+ async function q(e, n) {
4017
+ e.mkdir("/tmp/unzipped-wordpress"), await g(e, n, "/tmp/unzipped-wordpress"), e.fileExists("/tmp/unzipped-wordpress/wordpress.zip") && await g(
3574
4018
  e,
3575
4019
  "/tmp/unzipped-wordpress/wordpress.zip",
3576
4020
  "/tmp/unzipped-wordpress"
3577
4021
  );
3578
4022
  let i = e.fileExists("/tmp/unzipped-wordpress/wordpress") ? "/tmp/unzipped-wordpress/wordpress" : e.fileExists("/tmp/unzipped-wordpress/build") ? "/tmp/unzipped-wordpress/build" : "/tmp/unzipped-wordpress";
3579
- if (!e.fileExists(_(i, "wp-config-sample.php"))) {
4023
+ if (!e.fileExists(a(i, "wp-config-sample.php"))) {
3580
4024
  const s = e.listFiles(i);
3581
4025
  if (s.length) {
3582
4026
  const r = s[0];
3583
4027
  e.fileExists(
3584
- _(i, r, "wp-config-sample.php")
3585
- ) && (i = _(i, r));
4028
+ a(i, r, "wp-config-sample.php")
4029
+ ) && (i = a(i, r));
3586
4030
  }
3587
4031
  }
3588
- const n = (s, r, a) => {
3589
- if (a.isDir(s) && a.isDir(r))
3590
- for (const o of a.listFiles(s)) {
3591
- const l = _(s, o), c = _(r, o);
3592
- n(l, c, a);
4032
+ const t = (s, r, o) => {
4033
+ if (o.isDir(s) && o.isDir(r))
4034
+ for (const _ of o.listFiles(s)) {
4035
+ const l = a(s, _), c = a(r, _);
4036
+ t(l, c, o);
3593
4037
  }
3594
4038
  else {
3595
- if (a.fileExists(r)) {
3596
- const o = s.replace(
4039
+ if (o.fileExists(r)) {
4040
+ const _ = s.replace(
3597
4041
  /^\/tmp\/unzipped-wordpress\//,
3598
4042
  "/"
3599
4043
  );
3600
- h.warn(
3601
- `Cannot unzip WordPress files at ${r}: ${o} already exists.`
4044
+ d.warn(
4045
+ `Cannot unzip WordPress files at ${r}: ${_} already exists.`
3602
4046
  );
3603
4047
  return;
3604
4048
  }
3605
- a.mv(s, r);
4049
+ o.mv(s, r);
3606
4050
  }
3607
4051
  };
3608
- n(i, e.documentRoot, e), e.fileExists(i) && e.rmdir(i, { recursive: !0 }), !e.fileExists(_(e.documentRoot, "wp-config.php")) && e.fileExists(_(e.documentRoot, "wp-config-sample.php")) && e.writeFile(
3609
- _(e.documentRoot, "wp-config.php"),
4052
+ t(i, e.documentRoot, e), e.fileExists(i) && e.rmdir(i, { recursive: !0 }), !e.fileExists(a(e.documentRoot, "wp-config.php")) && e.fileExists(a(e.documentRoot, "wp-config-sample.php")) && e.writeFile(
4053
+ a(e.documentRoot, "wp-config.php"),
3610
4054
  e.readFileAsText(
3611
- _(e.documentRoot, "/wp-config-sample.php")
4055
+ a(e.documentRoot, "/wp-config-sample.php")
3612
4056
  )
3613
4057
  );
3614
4058
  }
3615
- const ze = M(fetch), Ze = "https://github.com/WordPress/WordPress/archive/refs/heads/master.zip";
3616
- async function ot(e = "latest") {
4059
+ const $t = X(fetch), ht = "https://github.com/WordPress/WordPress/archive/refs/heads/master.zip";
4060
+ async function bt(e = "latest") {
3617
4061
  if (e === null)
3618
4062
  e = "latest";
3619
4063
  else if (e.startsWith("https://") || e.startsWith("http://")) {
3620
- const n = await crypto.subtle.digest(
4064
+ const t = await crypto.subtle.digest(
3621
4065
  "SHA-1",
3622
4066
  new TextEncoder().encode(e)
3623
- ), s = Array.from(new Uint8Array(n)).map((r) => r.toString(16).padStart(2, "0")).join("");
4067
+ ), s = Array.from(new Uint8Array(t)).map((r) => r.toString(16).padStart(2, "0")).join("");
3624
4068
  return {
3625
4069
  releaseUrl: e,
3626
4070
  version: "custom-" + s.substring(0, 8),
3627
4071
  source: "inferred"
3628
4072
  };
3629
4073
  } else if (e === "trunk" || e === "nightly") {
3630
- const n = (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
4074
+ const t = (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
3631
4075
  return {
3632
- releaseUrl: `${Ze}?ts=${n}`,
4076
+ releaseUrl: `${ht}?ts=${t}`,
3633
4077
  version: "trunk",
3634
4078
  source: "inferred"
3635
4079
  };
3636
4080
  }
3637
- let i = await (await ze(
4081
+ let i = await (await $t(
3638
4082
  "https://api.wordpress.org/core/version-check/1.7/?channel=beta"
3639
4083
  )).json();
3640
4084
  i = i.offers.filter(
3641
- (n) => n.response === "autoupdate"
4085
+ (t) => t.response === "autoupdate"
3642
4086
  );
3643
- for (const n of i) {
3644
- if (e === "beta" && (n.version.includes("beta") || n.version.includes("RC")))
4087
+ for (const t of i) {
4088
+ if (e === "beta" && (t.version.includes("beta") || t.version.includes("RC")))
3645
4089
  return {
3646
- releaseUrl: n.download,
3647
- version: n.version,
4090
+ releaseUrl: t.download,
4091
+ version: t.version,
3648
4092
  source: "api"
3649
4093
  };
3650
- if (e === "latest" && !n.version.includes("beta") && !n.version.includes("RC"))
4094
+ if (e === "latest" && !t.version.includes("beta") && !t.version.includes("RC"))
3651
4095
  return {
3652
- releaseUrl: n.download,
3653
- version: n.version,
4096
+ releaseUrl: t.download,
4097
+ version: t.version,
3654
4098
  source: "api"
3655
4099
  };
3656
- if (n.version.substring(0, e.length) === e)
4100
+ if (t.version.substring(0, e.length) === e)
3657
4101
  return {
3658
- releaseUrl: n.download,
3659
- version: n.version,
4102
+ releaseUrl: t.download,
4103
+ version: t.version,
3660
4104
  source: "api"
3661
4105
  };
3662
4106
  }
@@ -3667,19 +4111,19 @@ async function ot(e = "latest") {
3667
4111
  };
3668
4112
  }
3669
4113
  export {
3670
- He as bootRequestHandler,
3671
- Me as bootWordPress,
3672
- rt as bootWordPressAndRequestHandler,
3673
- st as defineWpConfigConstants,
3674
- ve as ensureWpConfig,
3675
- Be as getFileNotFoundActionForWordPress,
3676
- at as getLoadedWordPressVersion,
3677
- Qe as preloadPhpInfoRoute,
3678
- I as preloadSqliteIntegration,
3679
- ot as resolveWordPressRelease,
3680
- Ke as setupPlatformLevelMuPlugins,
3681
- D as unzipWordPress,
3682
- Xe as versionStringToLoadedWordPressVersion,
3683
- Ye as wordPressRewriteRules
4114
+ ot as bootRequestHandler,
4115
+ at as bootWordPress,
4116
+ yt as bootWordPressAndRequestHandler,
4117
+ Lt as defineWpConfigConstants,
4118
+ Ke as ensureWpConfig,
4119
+ _t as getFileNotFoundActionForWordPress,
4120
+ Ot as getLoadedWordPressVersion,
4121
+ dt as preloadPhpInfoRoute,
4122
+ C as preloadSqliteIntegration,
4123
+ bt as resolveWordPressRelease,
4124
+ pt as setupPlatformLevelMuPlugins,
4125
+ q as unzipWordPress,
4126
+ ct as versionStringToLoadedWordPressVersion,
4127
+ ut as wordPressRewriteRules
3684
4128
  };
3685
4129
  //# sourceMappingURL=index.js.map