Created
May 11, 2023 10:35
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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