admin管理员组文章数量:1200781
I have created a plugin wherein I have a custom post type. I am using post_content
for some simple text. I do not need to offer any fancy editing or insertion of data for this field, so I looked for a way to remove the buttons from the tinyMCE editor.
I never found a very good solution so I removed the editor
from the custom post type supports in the register function.
'supports' => array('title','revisions','thumbnail'),
Then to create an area for the content to go I simply echo a textarea
in the back end form with the name
and id
attribute as "content"
.
<tr>
<th scope="row">
<label for="content">Review body</label>
</th>
<td>
<textarea style="height: 300px; width: 100%" autocomplete="off" cols="40" name="content" id="content">' . $post->post_content . '</textarea>
</td>
</tr>
This works exactly as I want, and is pretty simple.
The question is, am I losing sanitation or skipping security measures by doing this?
I have created a plugin wherein I have a custom post type. I am using post_content
for some simple text. I do not need to offer any fancy editing or insertion of data for this field, so I looked for a way to remove the buttons from the tinyMCE editor.
I never found a very good solution so I removed the editor
from the custom post type supports in the register function.
'supports' => array('title','revisions','thumbnail'),
Then to create an area for the content to go I simply echo a textarea
in the back end form with the name
and id
attribute as "content"
.
<tr>
<th scope="row">
<label for="content">Review body</label>
</th>
<td>
<textarea style="height: 300px; width: 100%" autocomplete="off" cols="40" name="content" id="content">' . $post->post_content . '</textarea>
</td>
</tr>
This works exactly as I want, and is pretty simple.
The question is, am I losing sanitation or skipping security measures by doing this?
Share Improve this question asked Aug 27, 2015 at 13:56 Nathan PowellNathan Powell 1,6151 gold badge13 silver badges31 bronze badges1 Answer
Reset to default 6No need to reinvent the wheel - put your editor
support back and tweak the settings:
function wpse_199918_wp_editor_settings( $settings, $editor_id ) {
if ( $editor_id === 'content' && get_current_screen()->post_type === 'custom_post_type' ) {
$settings['tinymce'] = false;
$settings['quicktags'] = false;
$settings['media_buttons'] = false;
}
return $settings;
}
add_filter( 'wp_editor_settings', 'wpse_199918_wp_editor_settings', 10, 2 );
本文标签: custom post typesRemove tinyMCE from admin and replace with textarea
版权声明:本文标题:custom post types - Remove tinyMCE from admin and replace with textarea 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1738575620a2100860.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论