File "custom-classname.php"

Full path: /home/kosmetik/public_html/wp-includes/block-supports/custom-classname.php
File size: 1.32 B
MIME-type: text/x-php
Charset: utf-8

Download   Open   Edit   Advanced Editor   Back

<?php

function wp_register_custom_classname_support($block_type)
{
    $has_custom_classname_support = true;
    if (property_exists($block_type, 'supports')) {
        $has_custom_classname_support = _wp_array_get($block_type->supports, array('customClassName'), true);
    }
    if ($has_custom_classname_support) {
        if (!$block_type->attributes) {
            $block_type->attributes = array();
        }
        if (!array_key_exists('className', $block_type->attributes)) {
            $block_type->attributes['className'] = array('type' => 'string');
        }
    }
}
function wp_apply_custom_classname_support($block_type, $block_attributes)
{
    $has_custom_classname_support = true;
    $attributes = array();
    if (property_exists($block_type, 'supports')) {
        $has_custom_classname_support = _wp_array_get($block_type->supports, array('customClassName'), true);
    }
    if ($has_custom_classname_support) {
        $has_custom_classnames = array_key_exists('className', $block_attributes);
        if ($has_custom_classnames) {
            $attributes['class'] = $block_attributes['className'];
        }
    }
    return $attributes;
}
WP_Block_Supports::get_instance()->register('custom-classname', array('register_attribute' => 'wp_register_custom_classname_support', 'apply' => 'wp_apply_custom_classname_support'));