snippet_std_setting is a dedicated function for making the settings dialog
You can easily implement the configuration dialog using the troublesome ajax it is to create
Format:
snippet_std_setting ('dialog title', 'any of the ID');
With only one line, and the setting dialog, related javascript is created
After, on php side, it is OK if you implement initialization function and save function as ajax
The initialization, the value of ajax is, in any of the ID name
To save, "save_ any ID" will come flying in the form of $_post ['ajax']
In addition, each input please with a data-input attribute
ot.plugin_test();
Settings screen opens in
ot.plugin_test(id);
It was now the argument is available from v1.3x ※
ot.plugin_test(id,data);
※ data will be posted to the ajax handler
$_POST['data']
Example: a simple example to set the title
snippet_std_setting('Page folder setting','plugin_test'); if (isset($_POST['ajax']) && $_POST['ajax'] == 'plugin_test') { $r = array(); $r['result'] = true; $r['html'] = <<<EOT <table> <tr> <td >Title</td> <td> <input type='text' value='任意の値' data-input='title' /> </td> </tr> </table> EOT; echo(json_encode($r)); exit(); } if (isset($_POST['ajax']) && $_POST['ajax'] == 'save_plugin_test') { $r = array(); $r['result'] = false; if (isset($_POST['title'])) { $r['title'] = sanitize_str($_POST['title']); //保存処理 } echo(json_encode($r)); exit(); }