| 1 |
<?php |
| 2 |
|
| 3 |
if(!function_exists('blockspare_render_block_core_latest_posts_express_grid')){ |
| 4 |
function blockspare_render_block_core_latest_posts_express_grid($attributes) |
| 5 |
{ |
| 6 |
|
| 7 |
if($attributes['enablePagination']){ |
| 8 |
wp_enqueue_script('blockspare-pagination-js'); |
| 9 |
} |
| 10 |
ob_start(); |
| 11 |
$unq_class = mt_rand(100000,999999); |
| 12 |
$blockuniqueclass = ''; |
| 13 |
|
| 14 |
if(!empty($attributes['uniqueClass'])){ |
| 15 |
$blockuniqueclass = $attributes['uniqueClass']; |
| 16 |
}else{ |
| 17 |
$blockuniqueclass = 'blockspare-posts-block-list-'.$unq_class; |
| 18 |
} |
| 19 |
|
| 20 |
$design = 'blockspare-posts-block-latestpost-express-grid '; |
| 21 |
|
| 22 |
|
| 23 |
$block_class = 'blockspare-posts-block-is-express'. ' has-gutter-'.$attributes['gutterSpace']; |
| 24 |
if($attributes['enableEqualHeight']){ |
| 25 |
$block_class .= ' bs-has-equal-height'; |
| 26 |
} |
| 27 |
|
| 28 |
if($attributes['displaySpotLightExceprt']){ |
| 29 |
$block_class .= ' has-spotlight-excerpt '; |
| 30 |
} |
| 31 |
$layoutClass = false; |
| 32 |
|
| 33 |
if ($attributes['express'] != 'blockspare-posts-block-express-grid-layout-4' && $attributes['express'] != 'blockspare-posts-block-express-grid-layout-5' && $attributes['express'] != 'blockspare-posts-block-express-grid-layout-6') { |
| 34 |
$layoutClass = true; |
| 35 |
} |
| 36 |
|
| 37 |
$design .= $attributes['express']; |
| 38 |
$blockName= 'express'; |
| 39 |
|
| 40 |
blockspare_epxpress_query_loop_and_wrapper($attributes,$block_class,$design,$blockName,$layoutClass); |
| 41 |
|
| 42 |
$data_content = blockspare_latest_posts_style_control($blockuniqueclass ,$attributes); |
| 43 |
$data_content .= ob_get_clean(); |
| 44 |
return $data_content; |
| 45 |
|
| 46 |
|
| 47 |
} |
| 48 |
} |
| 49 |
|
| 50 |
/** |
| 51 |
* Registers the post grid block on server |
| 52 |
*/ |
| 53 |
|
| 54 |
if(!function_exists('blockspare_register_block_core_latest_posts_express_grid')){ |
| 55 |
function blockspare_register_block_core_latest_posts_express_grid() |
| 56 |
{ |
| 57 |
|
| 58 |
if (!function_exists('register_block_type')) { |
| 59 |
return; |
| 60 |
} |
| 61 |
|
| 62 |
|
| 63 |
ob_start(); |
| 64 |
include BLOCKSPARE_PLUGIN_DIR . 'inc/latest-post-block/posts-express-grid/block.json'; |
| 65 |
$metadata = json_decode(ob_get_clean(), true); |
| 66 |
|
| 67 |
/* Block attributes */ |
| 68 |
register_block_type( |
| 69 |
'blockspare/latest-posts-express-grid', |
| 70 |
array( |
| 71 |
'attributes' =>$metadata['attributes'], |
| 72 |
'render_callback' => 'blockspare_render_block_core_latest_posts_express_grid', |
| 73 |
) |
| 74 |
); |
| 75 |
} |
| 76 |
|
| 77 |
add_action('init', 'blockspare_register_block_core_latest_posts_express_grid'); |
| 78 |
} |
| 79 |
|
| 80 |
|
| 81 |
if(!function_exists('blockspare_latest_posts_style_control')){ |
| 82 |
|
| 83 |
function blockspare_latest_posts_style_control($blockuniqueclass ,$attributes){ |
| 84 |
|
| 85 |
$block_content =''; |
| 86 |
$block_content .= '<style type="text/css">'; |
| 87 |
$block_content .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-wrap{ |
| 88 |
margin-top:' . $attributes['marginTop'] . 'px; |
| 89 |
margin-bottom:' . $attributes['marginBottom'] . 'px; |
| 90 |
margin-left:' . $attributes['marginLeft'] . 'px; |
| 91 |
margin-right:' . $attributes['marginRight'] . 'px; |
| 92 |
}'; |
| 93 |
|
| 94 |
$block_content .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-content{ |
| 95 |
padding-top:' . $attributes['contentPaddingTop'] . 'px; |
| 96 |
padding-right:' . $attributes['contentPaddingRight'] . 'px; |
| 97 |
padding-bottom:' . $attributes['contentPaddingBottom'] . 'px; |
| 98 |
padding-left:' . $attributes['contentPaddingLeft'] . 'px; |
| 99 |
}'; |
| 100 |
|
| 101 |
|
| 102 |
|
| 103 |
if ($attributes['categoryLayoutOption'] == 'solid') { |
| 104 |
|
| 105 |
|
| 106 |
$block_content .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-category a{ |
| 107 |
color:' . $attributes['categoryTextColor'] . "!important" . '; |
| 108 |
background-color:' . $attributes['categoryBackgroundColor'] . "!important" . '; |
| 109 |
border-radius:' . $attributes['categoryBorderRadius'] . "px" . '; |
| 110 |
}'; |
| 111 |
|
| 112 |
} else if ($attributes['categoryLayoutOption'] == 'border') { |
| 113 |
|
| 114 |
|
| 115 |
$block_content .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-category a{ |
| 116 |
color:' . $attributes['categoryTextColor'] . "!important" . '; |
| 117 |
background-color:' . "transparent" . '; |
| 118 |
border:' . "1px solid" . $attributes['categoryBorderColor'] . '; |
| 119 |
border-radius:' . $attributes['categoryBorderRadius'] . "px" . '; |
| 120 |
border-width:' . $attributes['categoryBorderWidth'] . "px" . '; |
| 121 |
}'; |
| 122 |
|
| 123 |
|
| 124 |
|
| 125 |
|
| 126 |
} else { |
| 127 |
$block_content .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-category a{ |
| 128 |
color:' . $attributes['categoryTextColor'] . "!important" . '; |
| 129 |
}'; |
| 130 |
} |
| 131 |
|
| 132 |
|
| 133 |
$block_content .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-category{ |
| 134 |
margin-top:' . $attributes['categoryMarginTop'] . 'px' . '; |
| 135 |
margin-bottom:' . $attributes['categoryMarginBottom'] . 'px' . '; |
| 136 |
margin-left:' . $attributes['categoryMarginLeft'] . 'px' . '; |
| 137 |
margin-right:' . $attributes['categoryMarginRight'] . 'px' . '; |
| 138 |
}'; |
| 139 |
|
| 140 |
|
| 141 |
$block_content .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-grid-byline{ |
| 142 |
|
| 143 |
margin-top:' . $attributes['metaMarginTop'] . 'px' . '; |
| 144 |
margin-bottom:' . $attributes['metaMarginBottom'] . 'px' . '; |
| 145 |
margin-left:' . $attributes['metaMarginLeft'] . 'px' . '; |
| 146 |
margin-right:' . $attributes['metaMarginRight'] . 'px' . '; |
| 147 |
}'; |
| 148 |
|
| 149 |
|
| 150 |
$block_content .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-grid-more-link{ |
| 151 |
margin-top:' . $attributes['moreLinkMarginTop'] . 'px' . '; |
| 152 |
margin-bottom:' . $attributes['moreLinkMarginBottom'] . 'px' . '; |
| 153 |
margin-left:' . $attributes['moreLinkMarginLeft'] . 'px' . '; |
| 154 |
margin-right:' . $attributes['moreLinkMarginRight'] . 'px' . '; |
| 155 |
}'; |
| 156 |
|
| 157 |
|
| 158 |
|
| 159 |
|
| 160 |
|
| 161 |
|
| 162 |
|
| 163 |
|
| 164 |
$block_content .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-grid-title a span{ |
| 165 |
color: ' . $attributes['postTitleColor'] . '; |
| 166 |
|
| 167 |
}'; |
| 168 |
|
| 169 |
$block_content .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-grid-author a span{ |
| 170 |
color:' . $attributes['linkColor'] . '; |
| 171 |
}'; |
| 172 |
|
| 173 |
|
| 174 |
$block_content .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-grid-more-link span{ |
| 175 |
color:' . $attributes['linkColor'] . '; |
| 176 |
}'; |
| 177 |
|
| 178 |
$block_content .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-grid-date{ |
| 179 |
color:' . $attributes['generalColor'] . '; |
| 180 |
}'; |
| 181 |
|
| 182 |
$block_content .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-grid-excerpt-content, '.' .' . $blockuniqueclass . ' .comment_count{ |
| 183 |
color:' . $attributes['generalColor'] . '; |
| 184 |
|
| 185 |
}'; |
| 186 |
|
| 187 |
|
| 188 |
$layoutstyle = explode('-',$attributes['express']); |
| 189 |
|
| 190 |
if($layoutstyle[6] >3){ |
| 191 |
$block_content .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-single .blockspare-posts-block-post-img img{ |
| 192 |
border-radius:' . $attributes['borderRadius'] . 'px'.'; |
| 193 |
|
| 194 |
}'; |
| 195 |
if($attributes['enableBoxShadow']){ |
| 196 |
$block_content .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-single .blockspare-posts-block-post-img img{ |
| 197 |
box-shadow: ' . $attributes['xOffset'] . 'px ' . $attributes['yOffset'] . 'px ' . $attributes['blur'] . 'px ' . $attributes['spread'] . 'px ' . $attributes['shadowColor'] . '; |
| 198 |
}'; |
| 199 |
} |
| 200 |
}else{ |
| 201 |
$block_content .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-single{ |
| 202 |
border-radius:' . $attributes['borderRadius'] . 'px'.'; |
| 203 |
background-color:'.$attributes['backGroundColor'].' |
| 204 |
}'; |
| 205 |
|
| 206 |
if($attributes['enableBoxShadow']){ |
| 207 |
$block_content .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-single{ |
| 208 |
box-shadow: ' . $attributes['xOffset'] . 'px ' . $attributes['yOffset'] . 'px ' . $attributes['blur'] . 'px ' . $attributes['spread'] . 'px ' . $attributes['shadowColor'] . '; |
| 209 |
}'; |
| 210 |
} |
| 211 |
|
| 212 |
|
| 213 |
$block_content .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-content{ |
| 214 |
padding-top:' . $attributes['contentPaddingTop'] . 'px; |
| 215 |
padding-right:' . $attributes['contentPaddingRight'] . 'px; |
| 216 |
padding-bottom:' . $attributes['contentPaddingBottom'] . 'px; |
| 217 |
padding-left:' . $attributes['contentPaddingLeft'] . 'px; |
| 218 |
}'; |
| 219 |
|
| 220 |
} |
| 221 |
|
| 222 |
|
| 223 |
|
| 224 |
|
| 225 |
|
| 226 |
|
| 227 |
$block_content .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-grid-title{ |
| 228 |
margin-top:' . $attributes['titleMarginTop'] . 'px' . '; |
| 229 |
margin-bottom:' . $attributes['titleMarginBottom'] . 'px' . '; |
| 230 |
margin-left:' . $attributes['titleMarginLeft'] . 'px' . '; |
| 231 |
margin-right:' . $attributes['titleMarginRight'] . 'px' . '; |
| 232 |
}'; |
| 233 |
|
| 234 |
|
| 235 |
$block_content .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-grid-excerpt-content{ |
| 236 |
margin-top:' . $attributes['exceprtMarginTop'] . 'px' . '; |
| 237 |
margin-bottom:' . $attributes['exceprtMarginBottom'] . 'px' . '; |
| 238 |
margin-left:' . $attributes['exceprtMarginLeft'] . 'px' . '; |
| 239 |
margin-right:' . $attributes['exceprtMarginRight'] . 'px' . '; |
| 240 |
}'; |
| 241 |
|
| 242 |
|
| 243 |
|
| 244 |
//Title Hover |
| 245 |
if($attributes['titleOnHover']=='lpc-title-hover') { |
| 246 |
$block_content .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-content .blockspare-posts-block-title-link:hover span{ |
| 247 |
color: ' . $attributes['titleOnHoverColor'] . '; |
| 248 |
|
| 249 |
}'; |
| 250 |
} |
| 251 |
|
| 252 |
if($attributes['titleOnHover']=='lpc-title-border') { |
| 253 |
$block_content .= ' .' . $blockuniqueclass . ' .lpc-title-border .blockspare-posts-block-post-grid-title .blockspare-posts-block-title-link span:hover{ |
| 254 |
box-shadow: inset 0 -2px 0 0 ' . $attributes['titleOnHoverColor'] . '; |
| 255 |
|
| 256 |
}'; |
| 257 |
} |
| 258 |
|
| 259 |
|
| 260 |
//Font Settings |
| 261 |
|
| 262 |
$block_content .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-content .blockspare-posts-block-post-grid-excerpt .blockspare-posts-block-post-grid-excerpt-content{ |
| 263 |
font-size:' . $attributes['descriptionFontSize'] . $attributes['descriptionFontSizeType'] . '; |
| 264 |
'.bscheckFontfamily($attributes['descriptionFontFamily']).'; |
| 265 |
'.bscheckFontfamilyWeight($attributes['descriptionFontWeight']).'; |
| 266 |
}'; |
| 267 |
|
| 268 |
$block_content .= '@media (max-width: 1025px) { '; |
| 269 |
|
| 270 |
$block_content .= ' .' . $blockuniqueclass .' .blockspare-posts-block-post-content .blockspare-posts-block-post-grid-excerpt .blockspare-posts-block-post-grid-excerpt-content{ |
| 271 |
font-size:' . $attributes['descriptionFontSizeTablet'].$attributes['descriptionFontSizeType'].' |
| 272 |
}'; |
| 273 |
|
| 274 |
$block_content .= '}'; |
| 275 |
$block_content .= '@media (max-width: 767px) { '; |
| 276 |
$block_content .= ' .' . $blockuniqueclass .' .blockspare-posts-block-post-content .blockspare-posts-block-post-grid-excerpt .blockspare-posts-block-post-grid-excerpt-content{ |
| 277 |
font-size:' . $attributes['descriptionFontSizeMobile'].$attributes['descriptionFontSizeType'].' |
| 278 |
}'; |
| 279 |
|
| 280 |
$block_content .= '}'; |
| 281 |
|
| 282 |
|
| 283 |
if($attributes['express']!='blockspare-posts-block-express-grid-layout-3'&& $attributes['express']!='blockspare-posts-block-express-grid-layout-6' ){ |
| 284 |
|
| 285 |
$block_content .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-single:nth-child(1) .blockspare-posts-block-post-grid-title a span{ |
| 286 |
|
| 287 |
font-size: ' . $attributes['spostTitleFontSize'] . $attributes['titleFontSizeType'] . '; |
| 288 |
'.bscheckFontfamily($attributes['spostTitleFontFamily']).'; |
| 289 |
'.bscheckFontfamilyWeight($attributes['spostTitleFontWeight']).'; |
| 290 |
|
| 291 |
}'; |
| 292 |
|
| 293 |
$block_content .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-grid-title a span{ |
| 294 |
|
| 295 |
font-size: ' . $attributes['postTitleFontSize'] . $attributes['titleFontSizeType'] . '; |
| 296 |
'.bscheckFontfamily($attributes['titleFontFamily']).'; |
| 297 |
'.bscheckFontfamilyWeight($attributes['titleFontWeight']).'; |
| 298 |
|
| 299 |
}'; |
| 300 |
|
| 301 |
$block_content .= '@media (max-width: 1025px) { '; |
| 302 |
|
| 303 |
$block_content .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-single:nth-child(1) .blockspare-posts-block-post-grid-title a span{ |
| 304 |
font-size: ' . $attributes['spostTitleFontSizeTablet'] . $attributes['titleFontSizeType'] . '; |
| 305 |
}'; |
| 306 |
|
| 307 |
|
| 308 |
$block_content .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-grid-title a span{ |
| 309 |
font-size: ' . $attributes['titleFontSizeTablet'] . $attributes['titleFontSizeType'] . '; |
| 310 |
}'; |
| 311 |
|
| 312 |
|
| 313 |
$block_content .= '}'; |
| 314 |
$block_content .= '@media (max-width: 767px) { '; |
| 315 |
$block_content .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-single:nth-child(1) .blockspare-posts-block-post-grid-title a span{ |
| 316 |
font-size: ' . $attributes['spostTitleFontSizeMobile'] . $attributes['titleFontSizeType'] . '; |
| 317 |
}'; |
| 318 |
|
| 319 |
$block_content .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-grid-title a span{ |
| 320 |
font-size: ' . $attributes['titleFontSizeMobile'] . $attributes['titleFontSizeType'] . '; |
| 321 |
}'; |
| 322 |
|
| 323 |
$block_content .= '}'; |
| 324 |
}else{ |
| 325 |
|
| 326 |
|
| 327 |
$block_content .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-single:nth-child(1) .blockspare-posts-block-post-grid-title a span,'.' .' . $blockuniqueclass . ' .blockspare-posts-block-post-single:nth-child(2) .blockspare-posts-block-post-grid-title a span{ |
| 328 |
|
| 329 |
font-size: ' . $attributes['spostTitleFontSize'] . $attributes['titleFontSizeType'] . '; |
| 330 |
|
| 331 |
'.bscheckFontfamily($attributes['spostTitleFontFamily']).'; |
| 332 |
'.bscheckFontfamilyWeight($attributes['spostTitleFontWeight']).'; |
| 333 |
|
| 334 |
}'; |
| 335 |
|
| 336 |
$block_content .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-grid-title a span{ |
| 337 |
|
| 338 |
font-size: ' . $attributes['postTitleFontSize'] . $attributes['titleFontSizeType'] . '; |
| 339 |
'.bscheckFontfamily($attributes['titleFontFamily']).'; |
| 340 |
'.bscheckFontfamilyWeight($attributes['titleFontWeight']).'; |
| 341 |
|
| 342 |
}'; |
| 343 |
|
| 344 |
|
| 345 |
$block_content .= '@media (max-width: 1025px) { '; |
| 346 |
|
| 347 |
$block_content .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-single:nth-child(1) .blockspare-posts-block-post-grid-title a span,'.' .' . $blockuniqueclass . ' .blockspare-posts-block-post-single:nth-child(2) .blockspare-posts-block-post-grid-title a span{ |
| 348 |
font-size: ' . $attributes['spostTitleFontSizeTablet'] . $attributes['titleFontSizeType'] . '; |
| 349 |
}'; |
| 350 |
|
| 351 |
$block_content .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-grid-title a span{ |
| 352 |
font-size: ' . $attributes['titleFontSizeTablet'] . $attributes['titleFontSizeType'] . '; |
| 353 |
}'; |
| 354 |
|
| 355 |
$block_content .= '}'; |
| 356 |
$block_content .= '@media (max-width: 767px) { '; |
| 357 |
$block_content .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-single:nth-child(1) .blockspare-posts-block-post-grid-title a span,'.' .' . $blockuniqueclass . ' .blockspare-posts-block-post-single:nth-child(2) .blockspare-posts-block-post-grid-title a span{ |
| 358 |
font-size: ' . $attributes['spostTitleFontSizeMobile'] . $attributes['titleFontSizeType'] . '; |
| 359 |
}'; |
| 360 |
|
| 361 |
$block_content .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-grid-title a span{ |
| 362 |
font-size: ' . $attributes['titleFontSizeMobile'] . $attributes['titleFontSizeType'] . '; |
| 363 |
}'; |
| 364 |
|
| 365 |
$block_content .= '}'; |
| 366 |
|
| 367 |
} |
| 368 |
|
| 369 |
//Pagination |
| 370 |
if($attributes['enablePagination']){ |
| 371 |
if($attributes['loadMoreStyle'] == 'bs-loadmore-solid') { |
| 372 |
$block_content .=' .' . $blockuniqueclass . ' .bs_blockspare_loadmore a.blockspare-readmore .load-btn{ |
| 373 |
color:'.$attributes['loadMoreSolidTextColor'].'; |
| 374 |
background-color:'.$attributes['loadMoreTextBgColor'].'; |
| 375 |
}'; |
| 376 |
$block_content .=' .' . $blockuniqueclass . ' .bs_blockspare_loadmore a.blockspare-readmore .load-btn:hover{ |
| 377 |
color:'.$attributes['loadMoreSolidTextHoverColor'].'; |
| 378 |
background-color:'.$attributes['loadMoreTextBgHoverColor'].'; |
| 379 |
}'; |
| 380 |
} else { |
| 381 |
$block_content .=' .' . $blockuniqueclass . ' .bs_blockspare_loadmore a.blockspare-readmore .load-btn{ |
| 382 |
color:'.$attributes['loadMoreTextColor'].'; |
| 383 |
}'; |
| 384 |
$block_content .=' .' . $blockuniqueclass . ' .bs_blockspare_loadmore a.blockspare-readmore .load-btn:hover{ |
| 385 |
color:'.$attributes['loadMoreTextHoverColor'].'; |
| 386 |
}'; |
| 387 |
} |
| 388 |
|
| 389 |
$block_content .=' .' . $blockuniqueclass . ' .bs_blockspare_loadmore{ |
| 390 |
text-align:'.$attributes['loadMoreAlignment'].'; |
| 391 |
}'; |
| 392 |
$block_content .=' .' . $blockuniqueclass . ' .bs_blockspare_loadmore a.blockspare-readmore .ajax-loader-enabled{ |
| 393 |
border-top-color:'.$attributes['loadMoreColor'].'; |
| 394 |
}'; |
| 395 |
$block_content .= '}'; |
| 396 |
} |
| 397 |
|
| 398 |
|
| 399 |
|
| 400 |
$block_content .= '</style>'; |
| 401 |
return $block_content; |
| 402 |
} |
| 403 |
} |