getolympus / olympus-dionysos-field-code
代码字段,此组件是Olympus Dionysos字段的一部分。
v0.0.14
2023-12-20 22:09 UTC
Requires (Dev)
- phpunit/phpunit: ~5.3
README
狄俄尼索斯代码字段
该组件是针对WordPress的Olympus Dionysos字段的一部分。
它使用默认的WordPress代码字段,与codemirror JS组件完全集成。
composer require getolympus/olympus-dionysos-field-code
目录
字段初始化 • 变量定义 • 接受模式 • 检索数据 • 发布历史 • 贡献
字段初始化
使用以下行在您的WordPress管理页面或自定义文章类型元字段中添加代码字段
return \GetOlympus\Dionysos\Field\Code::build('my_code_field_id', [ 'title' => 'How do Penguins code their icebergs?', 'default' => 'With a frozen bug.', 'description' => 'A simple question to let you know how to seduce a penguin.', 'mode' => 'json', 'rows' => 4, /** * Code mirror settings * @see https://developer.wordpress.org/reference/functions/wp_get_code_editor_settings/ */ 'settings' => [ 'indentUnit' => 2, 'indentWithTabs' => false, 'tabSize' => 2, ], ]);
变量定义
接受模式
text/css或csstext/x-diff或x-diff或difftext/html或htmltext/javascript或javascript或jsapplication/json或jsontext/x-markdown或markdown或mdapplication/x-httpd-php或x-httpd-php或phptext/x-python或x-python或pythontext/x-ruby或x-ruby或rubytext/x-sh或x-sh或shtext/x-mysql或x-mysql或mysqltext/x-mariadb或x-mariadb或mariadbapplication/xml或xmltext/x-yaml或x-yaml或yaml
使用示例
正确填写表单(本例中使用JSON)
{
"response": "With a frozen bug."
}
检索数据
使用简单的 get_option('my_code_field_id', '') 从数据库中检索您的值(见 WordPress参考)
// Get code from Database $code = get_option('my_code_field_id', ''); // Display code in HTML tag echo '<pre>'.htmlspecialchars($code).'</pre>';
发布历史
贡献
- 分支它 (https://github.com/GetOlympus/olympus-dionysos-field-code/fork)
- 创建您的功能分支 (
git checkout -b feature/fooBar) - 提交您的更改 (
git commit -am 'Add some fooBar') - 将更改推送到分支 (
git push origin feature/fooBar) - 创建新的Pull Request
由Achraf Chouk构建于GitHub https://github.com/crewstyle ~ (c) 很久以来。
