Skip to content

Instantly share code, notes, and snippets.

@l00f00
Created May 11, 2023 10:35
Show Gist options
  • Save l00f00/fe592b8e8d06a06f34838c8a90f11b01 to your computer and use it in GitHub Desktop.
Save l00f00/fe592b8e8d06a06f34838c8a90f11b01 to your computer and use it in GitHub Desktop.
boilerplate code to render a custom component, we need to define a class that extends Oxygen's internal OxyEl class. We do this in the WordPress 'plugins_loaded' action to ensure the Oxygen plugin is loaded and OxyEl is available.
<?php
add_action('plugins_loaded', function() {
class HeadingElement extends OxyEl {
function init()
{
}
function name() {
return 'Custom Heading';
}
function slug() {
return "custom-heading";
}
function icon() {
return CT_FW_URI . '/toolbar/UI/oxygen-icons/add-icons/heading.svg';
}
function controls()
{
}
function render($options, $defaults, $content) {
?>
<h1> Hello from an Oxygen Custom Element</h1>
<?php
}
}
new HeadingElement();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment