PluginProbe
BlockSpare – Gutenberg Blocks for News, Magazine, Blog & Business Websites / 3.1.4
BlockSpare – Gutenberg Blocks for News, Magazine, Blog & Business Websites v3.1.4
4.1.0 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.1.0 1.1.1 1.1.2 1.2.0 1.2.1 1.2.2 1.2.3 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 2.1.2 2.5.0 2.5.3 2.6.1 All 38 releases
blockspare / inc / other-block / date-time / index.php

index.php in BlockSpare – Gutenberg Blocks for News, Magazine, Blog & Business Websites 3.1.4, at inc/other-block/date-time/index.php

227 lines 9.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if(!function_exists('blockspare_date_time_render')){
3 function blockspare_date_time_render($attributes){
4
5 ob_start();
6 $unq_class = mt_rand(100000,999999);
7 $blockuniqueclass = '';
8 if(!empty($attributes['uniqueClass'])){
9 $blockuniqueclass = $attributes['uniqueClass'];
10 }else{
11 $blockuniqueclass = 'blockspare-date-time-'.$unq_class;
12 }
13
14 $wrapperClass = $blockuniqueclass;
15 $mainClass = $attributes['layoutOption'].' ' .$attributes['layoutType'].' '.$attributes['dateOrder'].' bs-date-time-'.$attributes['sectionAlign'].' ';
16 $mainClass .= $attributes['borderRadius'];
17 if($attributes['animation']){
18 $mainClass .= ' blockspare-block-animation ';
19 }else{
20 $mainClass .=' ';
21 }
22 $mainClass .=$attributes['animation'].' '.$attributes['blockHoverEffect'];
23
24
25 $separator = ',';
26
27 $alignclass = blockspare_checkalignment($attributes['align']);
28
29 $dateClass = 'bs-date-time bs-date-wrapper blockspare-hover-item';
30 if($attributes['layoutOption'] == 'date-time-style-1') {
31 $dateClass .= ' blockspare-hover-text ';
32 }
33
34 $timeClass = 'bs-date-time bs-time-wrapper blockspare-hover-item';
35 if($attributes['layoutOption'] == 'date-time-style-1') {
36 $timeClass .= ' blockspare-hover-text ';
37 }
38
39 $date_format = date_i18n(get_option('date_format'), current_time('timestamp'));
40 ?>
41
42 <div class="<?php echo esc_attr($wrapperClass); ?> align<?php echo esc_attr($alignclass) ?>">
43 <?php echo blockspare_date_time_style_control($blockuniqueclass ,$attributes);?>
44 <div class="bs-date-time-widget <?php echo esc_attr($mainClass);?>">
45 <?php if($attributes['date']){ ?>
46 <div class="<?php echo esc_attr($dateClass); ?>">
47 <?php if($attributes['dateIconToggle']) { ?>
48 <div class='bs-icon-wrapper'>
49 <i class="bs-date-icon <?php echo esc_attr($attributes['dateIcon']);?>"></i>
50 </div>
51 <?php } ?>
52
53 <div class="bs-date">
54 <?php if($attributes['textBeforeDate'] !=''){ ?>
55 <span class="bs-before-date-text">
56 <?php echo $attributes['textBeforeDate'];?>
57 </span>
58 <?php } ?>
59 <span class="bs-date-text" ><?php echo $date_format;?></span>
60 <?php if($attributes['textAfterDate'] !=''){ ?>
61 <span class="bs-after-date-text">
62 <?php echo $attributes['textAfterDate'];?>
63 </span>
64 <?php } ?>
65 </div>
66 </div>
67 <?php } ?>
68
69 <?php if($attributes['time']){ ?>
70 <div class="<?php echo esc_attr($timeClass); ?>" bs-fromat="<?php echo $date_format;?>" id="bs-date-time">
71 <?php if($attributes['timeIconToggle']){ ?>
72 <div class="bs-icon-wrapper">
73 <i class="bs-time-icon <?php echo esc_attr( $attributes['timeIcon'])?>"></i>
74 </div>
75 <?php } ?>
76 <span class="bs-time-text"></span>
77 </div>
78
79 <?php } ?>
80 </div>
81 </div>
82 <?php
83
84 return ob_get_clean();
85 }
86 }
87
88 if(!function_exists('blockspare_date_time_init')){
89 add_action('init', 'blockspare_date_time_init');
90 function blockspare_date_time_init(){
91 if (!function_exists('register_block_type')) {
92 return;
93 }
94
95 ob_start();
96 include BLOCKSPARE_PLUGIN_DIR . 'inc/other-block/date-time/block.json';
97 $metadata = json_decode(ob_get_clean(), true);
98
99 /* Block attributes */
100 register_block_type(
101 'blockspare/date-time',
102 array(
103 'attributes' =>$metadata['attributes'],
104 'render_callback' => 'blockspare_date_time_render',
105 )
106 );
107
108 }
109 }
110 if(!function_exists('blockspare_date_time_style_control')){
111 function blockspare_date_time_style_control($blockuniqueclass ,$attributes){
112 $block_content = '';
113 $block_content .= '<style type="text/css">';
114
115 $block_content .= ' .' . $blockuniqueclass . ' .bs-date-time-widget{
116 margin-top:' . $attributes['marginTop'] . 'px;
117 margin-right:' . $attributes['marginRight'] . 'px;
118 margin-bottom:' . $attributes['marginBottom'] . 'px;
119 margin-left:' . $attributes['marginLeft'] . 'px;
120 }';
121
122 $block_content .= ' .' . $blockuniqueclass . ' .bs-date-wrapper i.bs-date-icon{
123 color:' . $attributes['dateIconColor'].';
124 font-size: ' . $attributes['dateIconSize'] . $attributes['dateFontSizeType'] . ';
125 }';
126
127 $block_content .= ' .' . $blockuniqueclass . ' .bs-date-wrapper span.bs-date-text{
128 color:' . $attributes['dateColor'].';
129 }';
130
131 $block_content .= ' .' . $blockuniqueclass . ' .bs-date-wrapper .bs-date .bs-before-date-text{
132 color:' . $attributes['textBeforeColor'].';
133 }';
134
135
136 $block_content .= ' .' . $blockuniqueclass . ' .bs-date-wrapper .bs-date .bs-after-date-text{
137 color:' . $attributes['textAfterColor'].';
138 }';
139
140 $block_content .= ' .' . $blockuniqueclass . ' .bs-time-wrapper i.bs-time-icon{
141 color:' . $attributes['timeIconColor'].';
142 font-size: ' . $attributes['timeIconSize'] . $attributes['dateFontSizeType'] . ';
143 }';
144
145 $block_content .= ' .' . $blockuniqueclass . ' .bs-time-wrapper span.bs-time-text{
146 color:' . $attributes['timeColor'].';
147 }';
148
149 $block_content .= ' .' . $blockuniqueclass . ' .bs-date-time-widget:not(.date-time-style-1) .bs-time-wrapper{
150 background-color:' . $attributes['bgColor'].';
151 }';
152
153 $block_content .= ' .' . $blockuniqueclass . ' .bs-date-time-widget:not(.date-time-style-1) .bs-date-wrapper{
154 background-color:' . $attributes['bgColor'].';
155 }';
156
157 //Font Settings
158
159 $block_content .= ' .' . $blockuniqueclass . ' .bs-date-text{
160 font-size: ' . $attributes['dateFontSize'] . $attributes['dateFontSizeType'] . ';
161 '.bscheckFontfamily($attributes['dateFontFamily']).';
162 '.bscheckFontfamilyWeight($attributes['dateFontWeight']).';
163
164 }';
165
166 $block_content .= ' .' . $blockuniqueclass . ' .bs-before-date-text{
167 font-size: ' . $attributes['beforeDateFontSize'] . $attributes['beforeDateFontSizeType'] . ';
168 '.bscheckFontfamily($attributes['beforeDateFontFamily']).';
169 '.bscheckFontfamilyWeight($attributes['beforeDateFontWeight']).';
170 }';
171
172 $block_content .= ' .' . $blockuniqueclass . ' .bs-after-date-text{
173 font-size: ' . $attributes['afterDateFontSize'] . $attributes['afterDateFontSizeType'] . ';
174 '.bscheckFontfamily($attributes['afterDateFontFamily']).';
175 '.bscheckFontfamilyWeight($attributes['afterDateFontWeight']).';
176
177 }';
178
179 $block_content .= ' .' . $blockuniqueclass . ' .bs-time-text{
180 font-size: ' . $attributes['timeFontSize'] . $attributes['timeFontSizeType'] . ';
181 '.bscheckFontfamily($attributes['timeFontFamily']).';
182 '.bscheckFontfamilyWeight($attributes['timeFontWeight']).';
183 }';
184
185
186 $block_content .= '@media (max-width: 1025px) { ';
187 $block_content .= ' .' . $blockuniqueclass . ' .bs-date-text{
188 font-size: ' . $attributes['dateFontSizeTablet'] . $attributes['dateFontSizeType'] . ';
189 }';
190
191 $block_content .= ' .' . $blockuniqueclass . ' .bs-before-date-text{
192 font-size: ' . $attributes['beforeDateFontSizeTablet'] . $attributes['beforeDateFontSizeTablet'] . ';
193 }';
194
195 $block_content .= ' .' . $blockuniqueclass . ' .bs-after-date-text{
196 font-size: ' . $attributes['afterDateFontSizeTablet'] . $attributes['afterDateFontSizeType'] . ';
197 }';
198 $block_content .= ' .' . $blockuniqueclass . ' .bs-time-text{
199 font-size: ' . $attributes['timeFontSizeTablet'] . $attributes['timeFontSizeType'] . ';
200 }';
201 $block_content .= '}';
202
203 $block_content .= '@media (max-width: 767px) { ';
204 $block_content .= ' .' . $blockuniqueclass . ' .bs-date-text{
205 font-size: ' . $attributes['dateFontSizeMobile'] . $attributes['dateFontSizeType'] . ';
206 }';
207
208 $block_content .= ' .' . $blockuniqueclass . ' .bs-before-date-text{
209 font-size: ' . $attributes['beforeDateFontSizeMobile'] . $attributes['beforeDateFontSizeType'] . ';
210 }';
211
212 $block_content .= ' .' . $blockuniqueclass . ' .bs-after-date-text{
213 font-size: ' . $attributes['afterDateFontSizeMobile'] . $attributes['afterDateFontSizeType'] . ';
214 }';
215
216 $block_content .= ' .' . $blockuniqueclass . ' .bs-time-text{
217 font-size: ' . $attributes['timeFontSizeMobile'] . $attributes['timeFontSizeType'] . ';
218 }';
219 $block_content .= '}';
220
221
222 $block_content .= '</style>';
223 return $block_content;
224
225
226 }
227 }