PluginProbe
bBlocks – Essential Gutenberg Blocks & Patterns Collection / 1.5.3
bBlocks – Essential Gutenberg Blocks & Patterns Collection v1.5.3
2.1.7 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 All 107 releases
b-blocks / inc / team-members.php

team-members.php in bBlocks – Essential Gutenberg Blocks & Patterns Collection 1.5.3, at inc/team-members.php

230 lines 13.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 class BBlocksTeamMembers extends BBlocks{
3 public function __construct(){
4 add_action( 'init', [$this, 'register'] );
5 }
6
7 function register(){
8 $this::registerScripts( 'team-members', array(
9 'attributes' => $this->attributes(),
10 'render_callback' => [$this, 'render']
11 ) );
12 }
13
14 function attributes(){
15 return array(
16 'align' => array( 'type' => 'string', 'default' => '' ),
17 'cId' => array( 'type' => 'string', 'default' => '' ),
18
19 'members' => array( 'type' => 'array', 'default' => array(
20 array(
21 'background' => array( 'color' => '#0000' ),
22 'border' => array( 'radius' => '3px' ),
23 'shadow' => array(),
24 'photo' => array( 'id' => NULL, 'url' => '', 'alt' => '', 'title' => '' ),
25 'photoBorder' => array( 'radius' => '50%' ),
26 'name' => 'Martin',
27 'nameColor' => '#333',
28 'title' => 'Founder',
29 'titleColor' => '#333',
30 'separator' => array( 'width' => '20%', 'height' => '3px', 'color' => '#777' ),
31 'bio' => 'I am a self-motivated and self-taught professional who likes to solve problems.',
32 'bioColor' => '#333',
33 'social' => array(
34 array( 'link' => '#', 'icon' => array( 'class' => 'fa fa-facebook' ) ),
35 array( 'link' => '#', 'icon' => array( 'class' => 'fa fa-twitter' ) ),
36 array( 'link' => '#', 'icon' => array( 'class' => 'fa fa-linkedin' ) )
37 ),
38 'socialIconColors' => array( 'type' => 'object', 'default' => array( 'color' => '#fff', 'bg' => '#4527a4' ) )
39 ),
40 array(
41 'background' => array( 'color' => '#0000' ),
42 'border' => array( 'radius' => '3px' ),
43 'shadow' => array(),
44 'photo' => array( 'id' => NULL, 'url' => '', 'alt' => '', 'title' => '' ),
45 'photoBorder' => array( 'radius' => '50%' ),
46 'name' => 'Mary',
47 'nameColor' => '#333',
48 'title' => 'Co-Founder',
49 'titleColor' => '#333',
50 'separator' => array( 'width' => '20%', 'height' => '3px', 'color' => '#777' ),
51 'bio' => 'I am a self-motivated and self-taught professional who likes to solve problems.',
52 'bioColor' => '#333',
53 'social' => array(
54 array( 'link' => '#', 'icon' => array( 'class' => 'fa fa-facebook' ) ),
55 array( 'link' => '#', 'icon' => array( 'class' => 'fa fa-twitter' ) ),
56 array( 'link' => '#', 'icon' => array( 'class' => 'fa fa-linkedin' ) )
57 ),
58 'socialIconColors' => array( 'type' => 'object', 'default' => array( 'color' => '#fff', 'bg' => '#4527a4' ) )
59 ),
60 array(
61 'background' => array( 'color' => '#0000' ),
62 'border' => array( 'radius' => '3px' ),
63 'shadow' => array(),
64 'photo' => array( 'id' => NULL, 'url' => '', 'alt' => '', 'title' => '' ),
65 'photoBorder' => array( 'radius' => '50%' ),
66 'name' => 'John Doe',
67 'nameColor' => '#333',
68 'title' => 'CEO',
69 'titleColor' => '#333',
70 'separator' => array( 'width' => '20%', 'height' => '3px', 'color' => '#777' ),
71 'bio' => 'I am a self-motivated and self-taught professional who likes to solve problems.',
72 'bioColor' => '#333',
73 'social' => array(
74 array( 'link' => '#', 'icon' => array( 'class' => 'fa fa-facebook' ) ),
75 array( 'link' => '#', 'icon' => array( 'class' => 'fa fa-twitter' ) ),
76 array( 'link' => '#', 'icon' => array( 'class' => 'fa fa-linkedin' ) )
77 ),
78 'socialIconColors' => array( 'type' => 'object', 'default' => array( 'color' => '#fff', 'bg' => '#4527a4' ) )
79 )
80 ) ),
81
82 'columns' => array( 'type' => 'object', 'default' => array( 'desktop' => 3, 'tablet' => 2, 'mobile' => 1 ) ),
83
84 'columnGap' => array( 'type' => 'string', 'default' => '30px' ),
85 'rowGap' => array( 'type' => 'string', 'default' => '30px' ),
86
87 'layout' => array( 'type' => 'string', 'default' => 'vertical' ),
88 'style' => array( 'type' => 'string', 'default' => 'default' ),
89
90 'textAlign' => array( 'type' => 'string', 'default' => 'center' ),
91 'padding' => array( 'type' => 'object', 'default' => array( 'vertical' => '50px', 'horizontal' => '20px' ) ),
92
93 'photoWidth' => array( 'type' => 'string', 'default' => '170px' ),
94 'photoMargin' => array( 'type' => 'object', 'default' => array( 'bottom' => '20px' ) ),
95
96 'nameTypo' => array( 'type' => 'object', 'default' => array( 'fontSize' => 20, 'fontWeight' => 600 ) ),
97 'nameMargin' => array( 'type' => 'object', 'default' => array( 'bottom' => '10px' ) ),
98
99 'isTitle' => array( 'type' => 'boolean', 'default' => true ),
100 'titleTypo' => array( 'type' => 'object', 'default' => array( 'fontSize' => 16 ) ),
101 'titleMargin' => array( 'type' => 'object', 'default' => array( 'bottom' => '10px' ) ),
102
103 'isSep' => array( 'type' => 'boolean', 'default' => true ),
104 'sepMargin' => array( 'type' => 'object', 'default' => array( 'bottom' => '15px' ) ),
105
106 'isBio' => array( 'type' => 'boolean', 'default' => true ),
107 'bioTypo' => array( 'type' => 'object', 'default' => array( 'fontSize' => 15 ) ),
108 'bioMargin' => array( 'type' => 'object', 'default' => array( 'bottom' => '15px' ) ),
109
110 'isSocial' => array( 'type' => 'boolean', 'default' => true ),
111 'socialIconMargin' => array( 'type' => 'object', 'default' => array( 'side' => 2, 'vertical' => '10px', 'horizontal' => '10px' ) )
112 );
113 }
114
115 function render( $attributes ){
116 extract( $attributes );
117
118 // Generate Styles
119 $teamMembersStyle = new BBlocksStyleGenerator();
120 $teamMembersStyle::addStyle( "#bBlocksTeamMembers-$cId .bBlocksTeamMembers", array(
121 'grid-gap' => "$rowGap $columnGap"
122 ) );
123 $teamMembersStyle::addStyle( "#bBlocksTeamMembers-$cId .bBlocksTeamMembers .bBlocksMember", array(
124 'text-align' => $textAlign,
125 'padding' => $padding['styles'] ?? '50px 20px'
126 ) );
127 $teamMembersStyle::addStyle( "#bBlocksTeamMembers-$cId .bBlocksTeamMembers .bBlocksMember .memberPhoto", array(
128 'width' => $photoWidth,
129 'margin' => 'horizontal' === $layout ? '0 20px 0 0' : $photoMargin['styles'] ?? '0 0 20px 0'
130 ) );
131 $teamMembersStyle::addStyle( "#bBlocksTeamMembers-$cId .bBlocksTeamMembers .bBlocksMember .memberDetails .memberName", array(
132 $nameTypo['styles'] ?? 'font-size: 20px; font-weight: 600;' => '',
133 'margin' => $nameMargin['styles'] ?? '0 0 10px 0'
134 ) );
135 $teamMembersStyle::addStyle( "#bBlocksTeamMembers-$cId .bBlocksTeamMembers .bBlocksMember .memberDetails .memberTitle", array(
136 $titleTypo['styles'] ?? 'font-size: 16px;' => '',
137 'margin' => $titleMargin['styles'] ?? '0 0 10px 0'
138 ) );
139 $teamMembersStyle::addStyle( "#bBlocksTeamMembers-$cId .bBlocksTeamMembers .bBlocksMember .memberDetails .memberSeparator", array(
140 'margin' => $sepMargin['styles'] ?? '0 0 15px 0'
141 ) );
142 $teamMembersStyle::addStyle( "#bBlocksTeamMembers-$cId .bBlocksTeamMembers .bBlocksMember .memberDetails .memberBio", array(
143 $bioTypo['styles'] ?? 'font-size: 15px;' => '',
144 'margin' => $bioMargin['styles'] ?? '0 0 15px 0'
145 ) );
146 $teamMembersStyle::addStyle( "#bBlocksTeamMembers-$cId .bBlocksTeamMembers .bBlocksMember .memberDetails .memberSocial .icon", array(
147 'margin' => $socialIconMargin['styles'] ?? '10px 10px'
148 ) );
149
150 ob_start(); ?>
151 <div class='wp-block-b-blocks-team-members <?php echo 'align' . esc_attr( $align ); ?>' id='bBlocksTeamMembers-<?php echo esc_attr( $cId ); ?>'>
152 <style>
153 @import url(<?php echo esc_url( $nameTypo['googleFontLink'] ?? '' ); ?>);
154 @import url(<?php echo esc_url( $titleTypo['googleFontLink'] ?? '' ); ?>);
155 @import url(<?php echo esc_url( $bioTypo['googleFontLink'] ?? '' ); ?>);
156 <?php echo wp_kses( $teamMembersStyle::renderStyle(), array() ); ?>
157 </style>
158
159 <div class='bBlocksTeamMembers <?php echo esc_attr( $layout ?? 'vertical' ); ?> columns-<?php echo esc_attr( $columns['desktop'] ); ?> columns-tablet-<?php echo esc_attr( $columns['tablet'] ); ?> columns-mobile-<?php echo esc_attr( $columns['mobile'] ); ?>'>
160 <?php foreach ( $members as $index => $member ) {
161 extract( $member );
162
163 $memberStyle = new BBlocksStyleGenerator();
164 $memberStyle::addStyle( "#bBlocksTeamMembers-$cId #bBlocksMember-$index", array(
165 $background['styles'] ?? 'background-color: #0000;' => '',
166 $border['styles'] ?? 'border-radius: 3px;' => '',
167 'box-shadow' => $shadow['styles'] ?? 'none'
168 ) );
169 $memberStyle::addStyle( "#bBlocksTeamMembers-$cId #bBlocksMember-$index .memberPhoto", array(
170 $photoBorder['styles'] ?? 'border-radius: 50%;' => ''
171 ) );
172 $memberStyle::addStyle( "#bBlocksTeamMembers-$cId #bBlocksMember-$index .memberDetails .memberName", array(
173 'color' => $nameColor
174 ) );
175 $memberStyle::addStyle( "#bBlocksTeamMembers-$cId #bBlocksMember-$index .memberDetails .memberTitle", array(
176 'color' => $titleColor
177 ) );
178 $memberStyle::addStyle( "#bBlocksTeamMembers-$cId #bBlocksMember-$index .memberSeparator", array(
179 $separator['styles'] ?? 'width: 20%; border-top: 3px solid #777;' => ''
180 ) );
181 $memberStyle::addStyle( "#bBlocksTeamMembers-$cId #bBlocksMember-$index .memberDetails .memberBio", array(
182 'color' => $bioColor
183 ) );
184 $memberStyle::addStyle( "#bBlocksTeamMembers-$cId #bBlocksMember-$index .memberDetails .memberSocial", array(
185 'justify-content' => 'center' === $textAlign ? 'center' : ( 'right' === $textAlign ? 'flex-end' : 'flex-start' )
186 ) );
187 $memberStyle::addStyle( "#bBlocksTeamMembers-$cId #bBlocksMember-$index .memberDetails .memberSocial .icon a", array(
188 $socialIconColors['styles'] ?? 'color: #fff; background: #4527a4;' => '',
189 ) );
190
191 // Classes
192 $photoClass = isset( $photo['id'] ) ? 'wp-image-'.$photo['id'] : '';
193 ?>
194
195 <div class='bBlocksMember' id='bBlocksMember-<?php echo esc_attr( $index ); ?>'>
196 <style><?php echo wp_kses( $memberStyle::renderStyle(), array() ); ?></style>
197
198 <?php echo $photo['url'] ? "<img class='memberPhoto ". esc_attr( $photoClass ) ."' src='". esc_url( $photo['url'] ) ."' alt='". esc_attr( $photo['alt'] ) ."' />" : ''; ?>
199
200 <div class='memberDetails'>
201 <?php echo $name ? "<h4 class='memberName'>". wp_kses_post( $name ) ."</h4>" : ''; ?>
202
203 <?php echo $isTitle && $title ? "<p class='memberTitle'>". wp_kses_post( $title ) ."</p>" : ''; ?>
204
205 <?php echo $isSep ? "<span class='memberSeparator'></span>" : ''; ?>
206
207 <?php echo $isBio && $bio ? "<p class='memberBio'>". wp_kses_post( $bio ) ."</p>" : ''; ?>
208
209 <ul class='memberSocial'>
210 <?php foreach ( $social as $socialIndex => $socialItem ) {
211 extract( $socialItem ); ?>
212
213 <li class='icon icon-<?php echo esc_attr( $index ); ?>-<?php echo esc_attr( $socialIndex ); ?>'>
214 <a href='<?php echo esc_url( $link ); ?>'>
215 <i class='<?php echo esc_attr( $icon['class'] ); ?>'></i>
216 </a>
217 </li>
218 <?php } ?>
219 </ul>
220 </div>
221 </div>
222 <?php $memberStyle::$styles = array(); } ?>
223 </div>
224 </div>
225
226 <?php $teamMembersStyle::$styles = array(); // Empty styles
227 return ob_get_clean();
228 }
229 }
230 new BBlocksTeamMembers();