{"id":904,"date":"2020-03-26T09:04:53","date_gmt":"2020-03-26T09:04:53","guid":{"rendered":"https:\/\/meetanshi.com\/blog\/2020\/03\/26\/remove-insert-variable-insert-widget-from-wysiwyg-editor-in-magento-2\/"},"modified":"2025-05-22T14:40:11","modified_gmt":"2025-05-22T09:10:11","slug":"remove-insert-variable-insert-widget-from-wysiwyg-editor-in-magento-2","status":"publish","type":"post","link":"https:\/\/meetanshi.com\/blog\/remove-insert-variable-insert-widget-from-wysiwyg-editor-in-magento-2\/","title":{"rendered":"How To Remove Insert Variable &#038; Insert Widget From WYSIWYG Editor In Magento 2"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">WYSIWYG editor in Magento 2 is an HTML editor that offers&nbsp;<em>\u201cwhat you see is what you get\u201d<\/em>&nbsp; functionality. It makes the task of adding, editing and formatting the content easier.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">However, sometimes offering this editor gives unnecessary rights and features by allowing them to insert the variable and widget.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For example, the Magento marketplace has multiple users and vendors who can use the WYSIWYG editor from the admin panel. The super admin would not want them to use all the widgets but only allow designing with the editor. In such cases, one can use the below solution.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The default WYSIWYG editor in the Magento 2 is as shown here:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/meetanshi.com\/blog\/wp-content\/uploads\/2020\/03\/Default-WYSIWYG-Editor-1024x207.png\" alt=\"Default WYSIWYG Editor - Meetanshi\" class=\"wp-image-8258\"\/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">After implementing the below code, the WYSIWYG editor is as shown here:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/meetanshi.com\/blog\/wp-content\/uploads\/2020\/03\/Custom-editor-Meetanshi-1024x343.png\" alt=\"Custom editor - Meetanshi\" class=\"wp-image-8259\"\/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Method to remove add variable &amp; add widget from WYSIWYG editor in Magento 2:<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">1. Add below code in the&nbsp;<strong>system.xml<\/strong>&nbsp;file<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;field id=\"description\" translate=\"label comment\" type=\"editor\" sortOrder=\"20\" showInDefault=\"1\"\n                       showInWebsite=\"1\" showInStore=\"1\">\n    &lt;label>Description &lt;\/label>\n    &lt;frontend_model>Vendor\\Extension\\Block\\Adminhtml\\Editor&lt;\/frontend_model>\n&lt;\/field><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">2. Create new file&nbsp;<strong><em>Editor.php<\/em><\/strong>&nbsp;at&nbsp;<strong><strong>Vendor\\Extension\\Block\\Adminhtml<\/strong><\/strong>&nbsp;folder<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;?php\n \nnamespace Vendor\\Extension\\Block\\Adminhtml;\n \nuse Magento\\Backend\\Block\\Template\\Context;\nuse Magento\\Cms\\Model\\Wysiwyg\\Config as WysiwygConfig;\n \nclass Editor extends \\Magento\\Config\\Block\\System\\Config\\Form\\Field\n{\n    public function __construct(\n        Context $context,\n        WysiwygConfig $wysiwygConfig,\n        array $data = []\n    )\n    {\n        $this->_wysiwygConfig = $wysiwygConfig;\n        parent::__construct($context, $data);\n    }\n \n    protected function _getElementHtml(\\Magento\\Framework\\Data\\Form\\Element\\AbstractElement $element)\n    {\n        $element->setWysiwyg(true);\n        $confgiData = $this->wysiwygConfig->getConfig($element);\n        $confgiData->setplugins([]);\n        $confgiData->setadd_variables(0);\n        $confgiData->setadd_widgets(0);\n\n        $element->setConfig($confgiData);\n        return parent::_getElementHtml($element);\n    }\n}<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">That\u2019s it.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Please share the solution with the Magento community via social media.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Thank you.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>WYSIWYG editor in Magento 2 is an HTML editor that offers&nbsp;\u201cwhat you see is what you get\u201d&nbsp; functionality. It makes the task of adding, editing&#8230;<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[34],"tags":[],"class_list":["post-904","post","type-post","status-publish","format-standard","hentry","category-magento"],"acf":[],"_links":{"self":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/904","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/comments?post=904"}],"version-history":[{"count":4,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/904\/revisions"}],"predecessor-version":[{"id":15008,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/904\/revisions\/15008"}],"wp:attachment":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/media?parent=904"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/categories?post=904"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/tags?post=904"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}