Safely store code(html/js..) into database

there are two possible injection vectors, server side and client side

  • server side – Just don’t write your own SQL and use the more high level DB access APIs, in your case probably update_option. If you must to access the DB at lower level make sure the API use wpdb::prepare while generating the SQL, which is true for insert but not true for query which requires the use of prepare if you use placeholders in the query.

  • client side – You should never let anyone that is not the admin of the site to admin the plugin. This means it is not suitable to use in a network unless you will restrict the access there to only the super admin. Any other configuration will enable the site’s users to do XSS attacks against other users of the site.