' );
}
/**
* Function to get the block image.
*
* @param array $attrs Block attributes data.
* @param string $size Image size.
* @param string $class Attachment image class.
*
* @return string The HTML image element.
*/
protected function get_image( $attrs, $size = 'thumbnail', $class = 'class=alignright' ) {
$image_id = empty( $attrs['imageID'] ) ? '' : absint( $attrs['imageID'] );
if ( ! $image_id ) {
return '';
}
$html = wp_get_attachment_image( $image_id, $size, false, $class );
return $html ? $html : wp_get_attachment_image( $image_id, 'full', false, $class );
}
/**
* Get styles
*
* @param array $attributes Array of attributes.
*
* @return string
*/
protected function get_styles( $attributes ) {
return empty( $attributes['textAlign'] ) || 'left' === $attributes['textAlign']
? ''
: ' style="' . join( ';', [ 'text-align:' . $attributes['textAlign'] ] ) . '"';
}
/**
* Get list style
*
* @param string $style Style.
*
* @return string
*/
protected function get_list_style( $style ) {
if ( 'numbered' === $style ) {
return 'ol';
}
return 'unordered' === $style ? 'ul' : 'div';
}
/**
* Get list item style
*
* @param string $style Style.
*
* @return string
*/
protected function get_list_item_style( $style ) {
return in_array( $style, [ 'numbered', 'unordered' ], true ) ? 'li' : 'div';
}
/**
* Normalize the block text.
*
* @param string $text Text.
* @param string $block Block name.
*
* @return string
*/
protected function normalize_text( $text, $block ) {
/**
* Filter: Allow developers to preserve line breaks.
*
* @param bool $return If set, this will convert all remaining line breaks after paragraphing.
* @param string $block Block name.
*/
return wpautop( $text, apply_filters( 'rank_math/block/preserve_line_breaks', true, $block ) );
}
}