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
或css
text/x-diff
或x-diff
或diff
text/html
或html
text/javascript
或javascript
或js
application/json
或json
text/x-markdown
或markdown
或md
application/x-httpd-php
或x-httpd-php
或php
text/x-python
或x-python
或python
text/x-ruby
或x-ruby
或ruby
text/x-sh
或x-sh
或sh
text/x-mysql
或x-mysql
或mysql
text/x-mariadb
或x-mariadb
或mariadb
application/xml
或xml
text/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) 很久以来。