wp_apply_generated_classname_support

The timeline below displays how wordpress function wp_apply_generated_classname_support has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 6.4

/**
 * Adds the generated classnames to the output.
 *
 * @since 5.6.0
 *
 * @access private
 *
 * @param WP_Block_Type $block_type Block Type.
 * @return array Block CSS classes and inline styles.
 */
function wp_apply_generated_classname_support($block_type)
{
    $attributes = array();
    $has_generated_classname_support = block_has_support($block_type, '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;
}

WordPress Version: 6.2

/**
 * Adds the generated classnames to the output.
 *
 * @since 5.6.0
 *
 * @access private
 *
 * @param WP_Block_Type $block_type Block Type.
 * @return array Block CSS classes and inline styles.
 */
function wp_apply_generated_classname_support($block_type)
{
    $attributes = array();
    $has_generated_classname_support = block_has_support($block_type, 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;
}

WordPress Version: 5.8

/**
 * Add the generated classnames to the output.
 *
 * @since 5.6.0
 *
 * @access private
 *
 * @param  WP_Block_Type $block_type       Block Type.
 *
 * @return array Block CSS classes and inline styles.
 */
function wp_apply_generated_classname_support($block_type)
{
    $attributes = array();
    $has_generated_classname_support = block_has_support($block_type, 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;
}

WordPress Version: 5.7

/**
 * Add the generated classnames to the output.
 *
 * @since 5.6.0
 *
 * @access private
 *
 * @param  WP_Block_Type $block_type       Block Type.
 * @param  array         $block_attributes Block attributes.
 *
 * @return array Block CSS classes and inline styles.
 */
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;
}

WordPress Version: 5.6

/**
 * Add the generated classnames to the output.
 *
 * @access private
 *
 * @param  WP_Block_Type $block_type       Block Type.
 * @param  array         $block_attributes Block attributes.
 *
 * @return array Block CSS classes and inline styles.
 */
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;
}