PluginProbe
bBlocks – Essential Gutenberg Blocks & Patterns Collection / trunk
bBlocks – Essential Gutenberg Blocks & Patterns Collection vtrunk
2.1.6 2.1.5 2.1.4 2.1.3 2.1.2 2.1.1 2.1.0 2.0.43 2.0.42 2.0.41 2.0.40 2.0.39 2.0.38 trunk 1.0 1.1 1.2 1.3 1.4 1.5 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 All 106 releases
b-blocks / build / table-head / render.php

render.php in bBlocks – Essential Gutenberg Blocks & Patterns Collection trunk, at build/table-head/render.php

73 lines 2.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 $id = wp_unique_id( 'bBlocksTableHead-' );
3 $wrapper_attributes = get_block_wrapper_attributes();
4 $colSpan= $attributes['settings']['colSpan'];
5 $rowSpan= $attributes['settings']['rowSpan'];
6 $styles = $attributes['styles'];
7 $alignment = $styles['alignment'];
8 $normal = $styles['normal'];
9 $hover = $styles['hover'];
10
11 if ( ! function_exists( 'b_blocks_table_cell_isValidCSS' ) ) {
12 function b_blocks_table_cell_isValidCSS($property, $value) {
13 if ( empty( $value ) && $value !== '0' && $value !== 0 ) {
14 return '';
15 }
16 return "$property: $value;";
17 }
18
19 function b_blocks_table_cell_getBackgroundCSS( $bg, $isSolid = true, $isGradient = true, $isImage = true ) {
20 if ( ! is_array( $bg ) ) {
21 $bg = array();
22 }
23 extract( $bg );
24 $type = $type ?? 'solid';
25 $color = $color ?? '';
26 $gradient = $gradient ?? 'linear-gradient(135deg, #0040E3, #18D4FD)';
27 $image = $image ?? [];
28 $position = $position ?? 'center center';
29 $attachment = $attachment ?? '';
30 $repeat = $repeat ?? '';
31 $size = $size ?? '';
32 $overlayColor = $overlayColor ?? '';
33
34 if ( 'gradient' === $type && $isGradient ) {
35 $styles = b_blocks_table_cell_isValidCSS('background', $gradient);
36 } elseif ( 'image' === $type && $isImage ) {
37 $imgUrl = $image['url'] ?? '';
38 $styles = "background: url($imgUrl);"
39 . b_blocks_table_cell_isValidCSS('background-color', $overlayColor)
40 . b_blocks_table_cell_isValidCSS('background-position', $position)
41 . b_blocks_table_cell_isValidCSS('background-size', $size)
42 . b_blocks_table_cell_isValidCSS('background-repeat', $repeat)
43 . b_blocks_table_cell_isValidCSS('background-attachment', $attachment)
44 . b_blocks_table_cell_isValidCSS('background-repeat', $repeat)
45 . "background-blend-mode: overlay;";
46 } else {
47 $styles = $isSolid ? b_blocks_table_cell_isValidCSS('background', $color) : '';
48 }
49
50 return $styles;
51 }
52 }
53 ?>
54 <style>
55 #<?php echo esc_attr( $id ); ?> {
56 <?php
57 echo b_blocks_table_cell_getBackgroundCSS($normal['bg']);
58 echo $hover['transition']? "transition: background " . $hover['transition'] . "s ease-in-out;": "";
59 ?>
60 }
61 #<?php echo esc_attr( $id ); ?>:hover {
62 <?php
63 echo b_blocks_table_cell_getBackgroundCSS($hover['bg']);
64 ?>
65 }
66
67 </style>
68
69 <thead <?php echo wp_kses_post(get_block_wrapper_attributes()); ?> id='<?php echo esc_attr( $id ); ?>'>
70 <?php echo $content; ?>
71 </thead>
72
73