Custom Code
emcp-tools/add-custom-js (free)
Section titled “emcp-tools/add-custom-js (free)”Adds a JavaScript snippet to a page via an Elementor HTML widget. The plugin auto-wraps the snippet in <script> tags (optionally inside a DOMContentLoaded listener).
Input:
post_idparent_id: container to add the HTML widget intoposition: child index,-1to appendjs: JavaScript code (no<script>wrapper)wrap_dom_ready: wrap inDOMContentLoadedlistener (defaulttrue)
Returns: { element_id }.
Capability: edit_post + unfiltered_html on the calling user.
emcp-tools/add-custom-css (Pro)
Section titled “emcp-tools/add-custom-css (Pro)”Adds custom CSS to a specific element (using Elementor Pro’s per-element custom CSS) or to the entire page (using the page-level custom CSS panel). The selector keyword is supported and rewritten to the actual element’s CSS selector.
Input:
post_idtarget:pageor anelement_idcss: CSS code, can useselectorkeyword when targeting an element
Returns: { success: true }.
Requires Elementor Pro’s custom CSS module. Capability: edit_post + ownership.
emcp-tools/add-code-snippet (Pro)
Section titled “emcp-tools/add-code-snippet (Pro)”Creates a site-wide Custom Code snippet using Elementor Pro’s Custom Code feature: injects code into <head>, <body> start, or <body> end of every page on the site.
Input:
title: descriptive namecode: full code including<script>/<style>tagslocation:head,body_start, orbody_endpriority: load order (1-10, default 10)status:publish,draft
Returns: { snippet_id, edit_url }.
Requires Elementor Pro custom code module + manage_options + unfiltered_html.
emcp-tools/list-code-snippets (Pro)
Section titled “emcp-tools/list-code-snippets (Pro)”Lists every Custom Code snippet on the site with location, priority, status.
Returns: array of { id, title, location, priority, status, modified }.
Requires Elementor Pro custom code module + manage_options.
Typical use cases
Section titled “Typical use cases”Analytics on one page: add-custom-js with a page tracker snippet. Stays scoped to that page only.
Element-level CSS tweak: add-custom-css with target set to a specific element ID and css using the selector keyword:
selector .some-child { background: red;}Site-wide third-party script: add-code-snippet with location: 'head' and the script tag. Loads on every page.
Security
Section titled “Security”All three write tools require unfiltered_html (or manage_options for snippets). On multisite, only super-admins have unfiltered_html by default, so on multisite, regular admins can’t use these tools unless capabilities are explicitly granted. This matches WordPress’s own custom-HTML widget behavior.
Switching the tools on
Section titled “Switching the tools on”All four sit in the Custom Code section of the Elementor tab on EMCP Tools → Tools (the tab appears while Elementor is the builder selected on EMCP Tools → Page Builders). add-custom-js is on by default. The three Pro tools register only while Elementor Pro is active, and on a new install they start switched off: switch them on in that section, then choose Save changes in the save bar. See Disabling tools.
These tools are separate from the PHP Snippets in the EMCP Sandbox, which run PHP rather than front-end code.
