Поэтому меня попросили создать плагин, который преобразует массив (я полагаю, взятый из пользовательского ввода) и преобразует его в файл данных и наоборот.
Я не уверен, как бы я конвертировалмассив в файл данных и наоборот, будет ли он загружен пользователем и загружен пользователем?
index.html
<html>
<body>
<form>
<script type="text/javascript" src="script.js"></script>
<h1>arraytodatafile</h1>
<input type="text" id="userInput"></input>
<button onClick="arrayBuild()">Submit</button>
</form>
</body>
</html>
script.js
var userInput = [];
function arrayBuild(){
var currentInput = document.getElementById("userInput").innerHTML();
userInput.push(currentInput);
}
console.log(userInput);
index.php
<?php
/**
* Plugin Name: arraytodatafile
* Plugin URI: http://www.mywebsite.com/my-first-plugin
* Description: Exports array to data file, vice versa.
* Version: 1.0
* Author: Steven Curnow
* Author URI: codexx1.000webhostapp.com
*/
add_action( 'wp_enqueue_scripts', 'displayHTMLpage' );
function displayHTMLpage() {
include( 'index.html' );
}
?>