• Hi,

    i create box means syntax highlighter for my website and all is good.

    how i can make an embed code for my boxes, means a user come to my site and get an embed code to display that box on their website.

    Embed Code look like this

    <script src="https://mywebsite.com/embed/mlo8.js/"></script>

    What i created

    So what is the best way to make an embed code

    Thanks

Viewing 1 replies (of 1 total)
  • Hello,

    there are html tags that are specifically used to embed code: <code></code>

    You first have to escape the code that you want to embed. You can use the wordpress function esc_html()

    For example:

    function myPersonalFunctionEmbedCode($atts = array(), $content = null) {
    	$embedCodehtml = "<code>".esc_html($content)."</code>";
    	return $embedCodehtml;
    }
    
    add_shortcode('my_shortcode_to_embed_code', 'myPersonalFunctionEmbedCode');

    You can use this shortcode like so:

    [my_shortcode_to_embed_code]<script>alert('Hello World!');</script>[/my_shortcode_to_embed_code]

    The <script> tags will not be seen as real HTML and will be embedded in a <code></code> element.

    • This reply was modified 1 year, 6 months ago by !Benni.
    • This reply was modified 1 year, 6 months ago by !Benni.
Viewing 1 replies (of 1 total)
  • The topic ‘Creating a embed system’ is closed to new replies.