File "generated-classname.php"

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

Download   Open   Edit   Advanced Editor   Back

<?php

function wp_get_block_default_classname($block_name)
{
    $classname = 'wp-block-' . preg_replace('/^core-/', '', str_replace('/', '-', $block_name));
    $classname = apply_filters('block_default_classname', $classname, $block_name);
    return $classname;
}
function wp_apply_generated_classname_support($block_type, $block_attributes)
{
    $has_generated_classname_support = true;
    $attributes = array();
    if (property_exists($block_type, 'supports')) {
        $has_generated_classname_support = _wp_array_get($block_type->supports, array('className'), true);
    }
    if ($has_generated_classname_support) {
        $block_classname = wp_get_block_default_classname($block_type->name);
        if ($block_classname) {
            $attributes['class'] = $block_classname;
        }
    }
    return $attributes;
}
WP_Block_Supports::get_instance()->register('generated-classname', array('apply' => 'wp_apply_generated_classname_support'));