Alchemy Options Docs
v0.9
v0.9
  • Read Me
  • Installation
  • Configuration
  • Meta Boxes
  • Theme mode
  • Samples
  • Field types
    • Text
    • Password
    • URL
    • Email
    • Tel
    • Textarea
    • Editor (WYSIWYG)
    • Datepicker
    • Image upload
    • Radio buttons
    • Select
    • Checkbox
    • Colorpicker
    • Image radio
    • Post type select
    • Datalist
    • Sections
    • Repeater
    • Button group
    • Slider
    • Taxonomy select
    • Field group
  • Functions
    • alch_options_id
    • alch_network_options_id
    • alch_get_option
    • alch_get_network_option
    • alch_delete_value
    • alch_get_post_meta
  • Javascript
    • getOption
    • getNetworkOption
    • getPostMeta
  • Filters
    • alch_options_id
    • alch_network_options_id
    • alch_options_id() . '_args'
    • alch_network_options_id() . '_args'
    • alch_allowed_editor_html_tags
    • alch_allowed_editor_protocols
    • alch_value_{ $optionID }
    • alch_network_value_{ $optionID }
Powered by GitBook
On this page
  1. Filters

alch_allowed_editor_html_tags

Previousalch_network_options_id() . '_args'Nextalch_allowed_editor_protocols

Last updated 4 years ago

Filter alch_allowed_editor_html_tags can be used to change the default HTML tags that are allowed in the field, which uses the global $allowedposttags; as a default value.

Consider taking a look at [wordpress directory]/wp-includes/kses.php to see what $allowedposttags really is.

This filter is applied just before saving the value to the database.

Example

Say we want our Editor fields to allow only <p> and <strong> tags which in their turn may only have the class attribute

function change_alchemy_options_editor_html_tags() {
    return array(
        'p' => array(
            'class' => true,
        ),
        'strong' => array(
             'class' => true,
         ),
    );
}

add_filter( 'alch_allowed_editor_html_tags', 'change_alchemy_options_editor_html_tags' );

Or you can take the passed $tags argument and correct it to your needs. Say we don't want any attributes on h1 tags and leave the rest as defaults

function change_alchemy_options_editor_html_tags( $tags ) {
    $tags['h1'] = array(); // no attributes for the `h1` tag will be allowed

    // do not forget to pass them further
    return $tags;
}

add_filter( 'alch_allowed_editor_html_tags', 'change_alchemy_options_editor_html_tags' );
Editor