【发布时间】:2017-03-05 21:06:35
【问题描述】:
我需要将核心 php 脚本转换为带有简码的 wordpress 插件,这样非技术人员也可以使用简码轻松执行相同的任务。 在脚本中,有很多函数,每个函数都有很多属性,所以我无法理解如何正确执行该部分。
$pdocrud = new PDOCrud();
$pdocrud->fieldTypes("about_yourself", "textarea");//change about_yourself 'textarea' to input type text
$pdocrud->fieldTypes("gender", "radio");//change gender to radio button
$pdocrud->fieldDataBinding("gender", array("male","female"), "", "","array");//add data for radio button
$pdocrud->fieldTypes("hobbies", "checkbox");//change hobbies to checkbox button
$pdocrud->fieldDataBinding("hobbies", array("Dance","Art","Games"), "", "","array");//add data for checkbox button
$pdocrud->fieldTypes("state", "select");//change state to select dropdown
$pdocrud->fieldDataBinding("state", array("Andhra Pradesh","Bihar","Patna","Gujarat","Madhya Pradesh"), "", "","array");//add data using array in select dropdown
$pdocrud->fieldTypes("country", "multiselect");//change country to multiselect dropdown
$pdocrud->fieldDataBinding("country", array("India","Brazil","UK","Pakistan"), "", "","array");//add data using array in multiselect
echo $pdocrud->dbTable("users")->render("insertform");
Here你可以找到更多关于脚本的细节。我唯一需要做的就是将脚本函数转换为 wordpress 简码。我只能使用 eval 函数来做到这一点,但由于它不安全,所以请提出一些更好的方法。请注意类的对象 在这里使用。
谢谢
【问题讨论】: