| 1 |
<?php |
| 2 |
if (!function_exists('blockspare_latest_posts_style_control')) { |
| 3 |
|
| 4 |
function blockspare_latest_posts_style_control($blockuniqueclass, $attributes) |
| 5 |
{ |
| 6 |
|
| 7 |
|
| 8 |
// Build CSS separately |
| 9 |
$inline_css = ''; |
| 10 |
$inline_css .= blockspare_visibility_css($attributes, $blockuniqueclass); |
| 11 |
$inline_css .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-wrap{ |
| 12 |
margin-top:' . $attributes['marginTop'] . 'px; |
| 13 |
margin-bottom:' . $attributes['marginBottom'] . 'px; |
| 14 |
margin-left:' . $attributes['marginLeft'] . 'px; |
| 15 |
margin-right:' . $attributes['marginRight'] . 'px; |
| 16 |
}'; |
| 17 |
|
| 18 |
$inline_css .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-content{ |
| 19 |
padding-top:' . $attributes['contentPaddingTop'] . 'px; |
| 20 |
padding-right:' . $attributes['contentPaddingRight'] . 'px; |
| 21 |
padding-bottom:' . $attributes['contentPaddingBottom'] . 'px; |
| 22 |
padding-left:' . $attributes['contentPaddingLeft'] . 'px; |
| 23 |
}'; |
| 24 |
|
| 25 |
$inline_css .= blockspare_posts_category_style( |
| 26 |
$inline_css, |
| 27 |
$attributes, |
| 28 |
$blockuniqueclass, |
| 29 |
$attributes['categoryTextColor'], |
| 30 |
$attributes['categoryBackgroundColor'], |
| 31 |
$attributes['categoryBorderColor'], |
| 32 |
$attributes['secondCategoryTextColor'], |
| 33 |
$attributes['secondCategoryBackgroundColor'], |
| 34 |
$attributes['secondCategoryBorderColor'], |
| 35 |
$attributes['thirdCategoryTextColor'], |
| 36 |
$attributes['thirdCategoryBackgroundColor'], |
| 37 |
$attributes['thirdCategoryBorderColor'], |
| 38 |
); |
| 39 |
|
| 40 |
$inline_css .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-grid-byline{ |
| 41 |
margin-top:' . $attributes['metaMarginTop'] . 'px' . '; |
| 42 |
margin-bottom:' . $attributes['metaMarginBottom'] . 'px' . '; |
| 43 |
margin-left:' . $attributes['metaMarginLeft'] . 'px' . '; |
| 44 |
margin-right:' . $attributes['metaMarginRight'] . 'px' . '; |
| 45 |
}'; |
| 46 |
|
| 47 |
|
| 48 |
$inline_css .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-grid-more-link{ |
| 49 |
margin-top:' . $attributes['moreLinkMarginTop'] . 'px' . '; |
| 50 |
margin-bottom:' . $attributes['moreLinkMarginBottom'] . 'px' . '; |
| 51 |
margin-left:' . $attributes['moreLinkMarginLeft'] . 'px' . '; |
| 52 |
margin-right:' . $attributes['moreLinkMarginRight'] . 'px' . '; |
| 53 |
}'; |
| 54 |
|
| 55 |
$inline_css .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-grid-title a span{ |
| 56 |
color: ' . $attributes['postTitleColor'] . '; |
| 57 |
}'; |
| 58 |
|
| 59 |
$inline_css .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-grid-author a span{ |
| 60 |
color:' . $attributes['linkColor'] . '; |
| 61 |
}'; |
| 62 |
|
| 63 |
$inline_css .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-grid-more-link span{ |
| 64 |
color:' . $attributes['linkColor'] . '; |
| 65 |
}'; |
| 66 |
|
| 67 |
$inline_css .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-grid-date{ |
| 68 |
color:' . $attributes['generalColor'] . '; |
| 69 |
}'; |
| 70 |
|
| 71 |
$inline_css .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-grid-excerpt-content{ |
| 72 |
color:' . $attributes['generalColor'] . '; |
| 73 |
}'; |
| 74 |
$inline_css .= ' .' . $blockuniqueclass . ' .comment_count{ |
| 75 |
color:' . $attributes['generalColor'] . '; |
| 76 |
}'; |
| 77 |
|
| 78 |
$layoutstyle = explode('-', $attributes['express']); |
| 79 |
|
| 80 |
if ($layoutstyle[6] > 3) { |
| 81 |
$inline_css .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-single .blockspare-posts-block-post-img { |
| 82 |
border-radius:' . $attributes['borderRadius'] . 'px' . '; |
| 83 |
}'; |
| 84 |
if ($attributes['enableBoxShadow']) { |
| 85 |
$inline_css .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-single .blockspare-posts-block-post-img { |
| 86 |
box-shadow: ' . $attributes['xOffset'] . 'px ' . $attributes['yOffset'] . 'px ' . $attributes['blur'] . 'px ' . $attributes['spread'] . 'px ' . $attributes['shadowColor'] . '; |
| 87 |
}'; |
| 88 |
} |
| 89 |
} else { |
| 90 |
$inline_css .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-single{ |
| 91 |
border-radius:' . $attributes['borderRadius'] . 'px' . '; |
| 92 |
background-color:' . $attributes['backGroundColor'] . ' |
| 93 |
}'; |
| 94 |
|
| 95 |
if ($attributes['enableBoxShadow']) { |
| 96 |
$inline_css .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-single{ |
| 97 |
box-shadow: ' . $attributes['xOffset'] . 'px ' . $attributes['yOffset'] . 'px ' . $attributes['blur'] . 'px ' . $attributes['spread'] . 'px ' . $attributes['shadowColor'] . '; |
| 98 |
}'; |
| 99 |
} |
| 100 |
|
| 101 |
$inline_css .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-content{ |
| 102 |
padding-top:' . $attributes['contentPaddingTop'] . 'px; |
| 103 |
padding-right:' . $attributes['contentPaddingRight'] . 'px; |
| 104 |
padding-bottom:' . $attributes['contentPaddingBottom'] . 'px; |
| 105 |
padding-left:' . $attributes['contentPaddingLeft'] . 'px; |
| 106 |
}'; |
| 107 |
} |
| 108 |
|
| 109 |
$inline_css .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-grid-title{ |
| 110 |
margin-top:' . $attributes['titleMarginTop'] . 'px' . '; |
| 111 |
margin-bottom:' . $attributes['titleMarginBottom'] . 'px' . '; |
| 112 |
margin-left:' . $attributes['titleMarginLeft'] . 'px' . '; |
| 113 |
margin-right:' . $attributes['titleMarginRight'] . 'px' . '; |
| 114 |
}'; |
| 115 |
|
| 116 |
$inline_css .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-grid-excerpt-content{ |
| 117 |
margin-top:' . $attributes['exceprtMarginTop'] . 'px' . '; |
| 118 |
margin-bottom:' . $attributes['exceprtMarginBottom'] . 'px' . '; |
| 119 |
margin-left:' . $attributes['exceprtMarginLeft'] . 'px' . '; |
| 120 |
margin-right:' . $attributes['exceprtMarginRight'] . 'px' . '; |
| 121 |
}'; |
| 122 |
|
| 123 |
//Title Hover |
| 124 |
if ($attributes['titleOnHover'] == 'lpc-title-hover') { |
| 125 |
$inline_css .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-content .blockspare-posts-block-title-link:hover span{ |
| 126 |
color: ' . $attributes['titleOnHoverColor'] . '; |
| 127 |
}'; |
| 128 |
} |
| 129 |
|
| 130 |
if ($attributes['titleOnHover'] == 'lpc-title-border') { |
| 131 |
$inline_css .= ' .' . $blockuniqueclass . ' .lpc-title-border .blockspare-posts-block-post-grid-title .blockspare-posts-block-title-link span:hover{ |
| 132 |
box-shadow: inset 0 -2px 0 0 ' . $attributes['titleOnHoverColor'] . '; |
| 133 |
}'; |
| 134 |
} |
| 135 |
|
| 136 |
|
| 137 |
//Font Settings |
| 138 |
$inline_css .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-grid-title a span{ |
| 139 |
font-size: ' . $attributes['postTitleFontSize'] . $attributes['titleFontSizeType'] . '; |
| 140 |
' . bscheckFontfamily($attributes['titleFontFamily']) . '; |
| 141 |
' . bscheckFontfamilyWeight($attributes['titleFontWeight']) . '; |
| 142 |
line-height: ' . $attributes['postTitleLineHeight'] . '; |
| 143 |
}'; |
| 144 |
|
| 145 |
$inline_css .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-content .blockspare-posts-block-post-grid-excerpt .blockspare-posts-block-post-grid-excerpt-content{ |
| 146 |
font-size:' . $attributes['descriptionFontSize'] . $attributes['descriptionFontSizeType'] . '; |
| 147 |
' . bscheckFontfamily($attributes['descriptionFontFamily']) . '; |
| 148 |
' . bscheckFontfamilyWeight($attributes['descriptionFontWeight']) . '; |
| 149 |
}'; |
| 150 |
|
| 151 |
$inline_css .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-grid-author a span { |
| 152 |
font-size:' . $attributes['postMetaFontSize'] . $attributes['postMetaFontSizeType'] . '; |
| 153 |
' . bscheckFontfamily($attributes['postMetaFontFamily']) . '; |
| 154 |
' . bscheckFontfamilyWeight($attributes['postMetaFontWeight']) . '; |
| 155 |
}'; |
| 156 |
|
| 157 |
$inline_css .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-grid-date { |
| 158 |
font-size:' . $attributes['postMetaFontSize'] . $attributes['postMetaFontSizeType'] . '; |
| 159 |
' . bscheckFontfamily($attributes['postMetaFontFamily']) . '; |
| 160 |
' . bscheckFontfamilyWeight($attributes['postMetaFontWeight']) . '; |
| 161 |
}'; |
| 162 |
|
| 163 |
$inline_css .= ' .' . $blockuniqueclass . ' .comment_count { |
| 164 |
font-size:' . $attributes['postMetaFontSize'] . $attributes['postMetaFontSizeType'] . '; |
| 165 |
' . bscheckFontfamily($attributes['postMetaFontFamily']) . '; |
| 166 |
' . bscheckFontfamilyWeight($attributes['postMetaFontWeight']) . '; |
| 167 |
}'; |
| 168 |
|
| 169 |
$inline_css .= '@media (max-width: 1025px) { '; |
| 170 |
|
| 171 |
$inline_css .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-grid-title a span{ |
| 172 |
font-size: ' . $attributes['titleFontSizeTablet'] . $attributes['titleFontSizeType'] . '; |
| 173 |
}'; |
| 174 |
|
| 175 |
$inline_css .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-content .blockspare-posts-block-post-grid-excerpt .blockspare-posts-block-post-grid-excerpt-content{ |
| 176 |
font-size:' . $attributes['descriptionFontSizeTablet'] . $attributes['descriptionFontSizeType'] . ' |
| 177 |
}'; |
| 178 |
$inline_css .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-grid-author a span { |
| 179 |
font-size:' . $attributes['postMetaFontSizeTablet'] . $attributes['postMetaFontSizeType'] . ' |
| 180 |
}'; |
| 181 |
$inline_css .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-grid-date { |
| 182 |
font-size:' . $attributes['postMetaFontSizeTablet'] . $attributes['postMetaFontSizeType'] . ' |
| 183 |
}'; |
| 184 |
$inline_css .= ' .' . $blockuniqueclass . ' .comment_count { |
| 185 |
font-size:' . $attributes['postMetaFontSizeTablet'] . $attributes['postMetaFontSizeType'] . ' |
| 186 |
}'; |
| 187 |
|
| 188 |
$inline_css .= '}'; |
| 189 |
|
| 190 |
$inline_css .= '@media (max-width: 767px) { '; |
| 191 |
|
| 192 |
$inline_css .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-grid-title a span{ |
| 193 |
font-size: ' . $attributes['titleFontSizeMobile'] . $attributes['titleFontSizeType'] . '; |
| 194 |
}'; |
| 195 |
|
| 196 |
$inline_css .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-content .blockspare-posts-block-post-grid-excerpt .blockspare-posts-block-post-grid-excerpt-content{ |
| 197 |
font-size:' . $attributes['descriptionFontSizeMobile'] . $attributes['descriptionFontSizeType'] . ' |
| 198 |
}'; |
| 199 |
$inline_css .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-grid-author a span { |
| 200 |
font-size:' . $attributes['postMetaFontSizeMobile'] . $attributes['postMetaFontSizeType'] . ' |
| 201 |
}'; |
| 202 |
$inline_css .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-grid-date { |
| 203 |
font-size:' . $attributes['postMetaFontSizeMobile'] . $attributes['postMetaFontSizeType'] . ' |
| 204 |
}'; |
| 205 |
$inline_css .= ' .' . $blockuniqueclass . ' .comment_count { |
| 206 |
font-size:' . $attributes['postMetaFontSizeMobile'] . $attributes['postMetaFontSizeType'] . ' |
| 207 |
}'; |
| 208 |
|
| 209 |
$inline_css .= '}'; |
| 210 |
|
| 211 |
if ($attributes['express'] != 'blockspare-posts-block-express-grid-layout-3' && $attributes['express'] != 'blockspare-posts-block-express-grid-layout-6') { |
| 212 |
$inline_css .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-single:nth-child(1) .blockspare-posts-block-post-grid-title a span{ |
| 213 |
font-size: ' . $attributes['spostTitleFontSize'] . $attributes['spostTitleFontSizeType'] . '; |
| 214 |
' . bscheckFontfamily($attributes['spostTitleFontFamily']) . '; |
| 215 |
' . bscheckFontfamilyWeight($attributes['spostTitleFontWeight']) . '; |
| 216 |
}'; |
| 217 |
|
| 218 |
$inline_css .= '@media (max-width: 1025px) { '; |
| 219 |
|
| 220 |
$inline_css .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-single:nth-child(1) .blockspare-posts-block-post-grid-title a span{ |
| 221 |
font-size: ' . $attributes['spostTitleFontSizeTablet'] . $attributes['spostTitleFontSizeType'] . '; |
| 222 |
}'; |
| 223 |
|
| 224 |
$inline_css .= '}'; |
| 225 |
$inline_css .= '@media (max-width: 767px) { '; |
| 226 |
$inline_css .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-single:nth-child(1) .blockspare-posts-block-post-grid-title a span{ |
| 227 |
font-size: ' . $attributes['spostTitleFontSizeMobile'] . $attributes['spostTitleFontSizeType'] . '; |
| 228 |
}'; |
| 229 |
|
| 230 |
$inline_css .= '}'; |
| 231 |
} else { |
| 232 |
$inline_css .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-single:nth-child(1) .blockspare-posts-block-post-grid-title a span{ |
| 233 |
font-size: ' . $attributes['spostTitleFontSize'] . $attributes['spostTitleFontSizeType'] . '; |
| 234 |
' . bscheckFontfamily($attributes['spostTitleFontFamily']) . '; |
| 235 |
' . bscheckFontfamilyWeight($attributes['spostTitleFontWeight']) . '; |
| 236 |
}'; |
| 237 |
|
| 238 |
$inline_css .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-single:nth-child(2) .blockspare-posts-block-post-grid-title a span{ |
| 239 |
font-size: ' . $attributes['spostTitleFontSize'] . $attributes['spostTitleFontSizeType'] . '; |
| 240 |
' . bscheckFontfamily($attributes['spostTitleFontFamily']) . '; |
| 241 |
' . bscheckFontfamilyWeight($attributes['spostTitleFontWeight']) . '; |
| 242 |
}'; |
| 243 |
|
| 244 |
$inline_css .= '@media (max-width: 1025px) { '; |
| 245 |
|
| 246 |
$inline_css .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-single:nth-child(1) .blockspare-posts-block-post-grid-title a span{ |
| 247 |
font-size: ' . $attributes['spostTitleFontSizeTablet'] . $attributes['spostTitleFontSizeType'] . '; |
| 248 |
}'; |
| 249 |
|
| 250 |
$inline_css .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-single:nth-child(2) .blockspare-posts-block-post-grid-title a span{ |
| 251 |
font-size: ' . $attributes['spostTitleFontSizeTablet'] . $attributes['spostTitleFontSizeType'] . '; |
| 252 |
}'; |
| 253 |
|
| 254 |
$inline_css .= '}'; |
| 255 |
|
| 256 |
$inline_css .= '@media (max-width: 767px) { '; |
| 257 |
|
| 258 |
$inline_css .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-single:nth-child(1) .blockspare-posts-block-post-grid-title a span{ |
| 259 |
font-size: ' . $attributes['spostTitleFontSizeMobile'] . $attributes['spostTitleFontSizeType'] . '; |
| 260 |
}'; |
| 261 |
$inline_css .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-single:nth-child(2) .blockspare-posts-block-post-grid-title a span{ |
| 262 |
font-size: ' . $attributes['spostTitleFontSizeMobile'] . $attributes['spostTitleFontSizeType'] . '; |
| 263 |
}'; |
| 264 |
|
| 265 |
$inline_css .= '}'; |
| 266 |
} |
| 267 |
|
| 268 |
//Pagination |
| 269 |
if ($attributes['enablePagination']) { |
| 270 |
if ($attributes['loadMoreStyle'] == 'bs-loadmore-solid') { |
| 271 |
$inline_css .= ' .' . $blockuniqueclass . ' .bs_blockspare_loadmore a.blockspare-readmore .load-btn{ |
| 272 |
color:' . $attributes['loadMoreSolidTextColor'] . '; |
| 273 |
background-color:' . $attributes['loadMoreTextBgColor'] . '; |
| 274 |
}'; |
| 275 |
$inline_css .= ' .' . $blockuniqueclass . ' .bs_blockspare_loadmore a.blockspare-readmore .load-btn:hover{ |
| 276 |
color:' . $attributes['loadMoreSolidTextHoverColor'] . '; |
| 277 |
background-color:' . $attributes['loadMoreTextBgHoverColor'] . '; |
| 278 |
}'; |
| 279 |
} else { |
| 280 |
$inline_css .= ' .' . $blockuniqueclass . ' .bs_blockspare_loadmore a.blockspare-readmore .load-btn{ |
| 281 |
color:' . $attributes['loadMoreTextColor'] . '; |
| 282 |
}'; |
| 283 |
$inline_css .= ' .' . $blockuniqueclass . ' .bs_blockspare_loadmore a.blockspare-readmore .load-btn:hover{ |
| 284 |
color:' . $attributes['loadMoreTextHoverColor'] . '; |
| 285 |
}'; |
| 286 |
} |
| 287 |
|
| 288 |
$inline_css .= ' .' . $blockuniqueclass . ' .bs_blockspare_loadmore{ |
| 289 |
text-align:' . $attributes['loadMoreAlignment'] . '; |
| 290 |
}'; |
| 291 |
$inline_css .= ' .' . $blockuniqueclass . ' .bs_blockspare_loadmore a.blockspare-readmore .ajax-loader-enabled{ |
| 292 |
border-top-color:' . $attributes['loadMoreColor'] . '; |
| 293 |
}'; |
| 294 |
$inline_css .= '}'; |
| 295 |
} |
| 296 |
|
| 297 |
|
| 298 |
// $block_content .= blockspare_minify_css($inline_css); |
| 299 |
|
| 300 |
// $block_content .= '</style>'; |
| 301 |
// return $block_content; |
| 302 |
if (!empty($inline_css)) { |
| 303 |
wp_register_style('bs-express-grid', false); |
| 304 |
wp_enqueue_style('bs-express-grid'); |
| 305 |
wp_add_inline_style('bs-express-grid', blockspare_minify_css($inline_css)); |
| 306 |
} |
| 307 |
} |
| 308 |
} |
| 309 |
|
| 310 |
|
| 311 |
function blockspare_epxpress_query_loop_and_wrapper($attributes, $blockclass = '', $design = '', $blockName = '', $layoutClass = false) |
| 312 |
{ |
| 313 |
$unq_class = mt_rand(100000, 999999); |
| 314 |
$blockuniqueclass = ''; |
| 315 |
|
| 316 |
if (!empty($attributes['uniqueClass'])) { |
| 317 |
$blockuniqueclass = $attributes['uniqueClass']; |
| 318 |
} else { |
| 319 |
$blockuniqueclass = 'blockspare-posts-block-list-' . $unq_class; |
| 320 |
} |
| 321 |
|
| 322 |
$grid_query = blockspare_post_query($attributes); |
| 323 |
|
| 324 |
$count = 0; |
| 325 |
if ($grid_query->have_posts()) { |
| 326 |
$alignclass = blockspare_checkalignment($attributes['align']); |
| 327 |
|
| 328 |
|
| 329 |
/* Build the block classes */ |
| 330 |
$class = "wp-block-blockspare-posts-block-blockspare-posts-block-latest-posts align" . $alignclass . " " . $attributes['blockHoverEffect']; |
| 331 |
|
| 332 |
if (isset($attributes['className'])) { |
| 333 |
$class .= ' ' . $attributes['className']; |
| 334 |
} |
| 335 |
|
| 336 |
if ($attributes['animation']) { |
| 337 |
$class .= ' blockspare-block-animation'; |
| 338 |
} |
| 339 |
|
| 340 |
|
| 341 |
|
| 342 |
$list_layout_class = $design; |
| 343 |
$listgridClass = $blockclass . " "; |
| 344 |
|
| 345 |
|
| 346 |
/* Layout orientation class */ |
| 347 |
$grid_class = 'blockspare-posts-block-latest-post-wrap ' . $listgridClass . ' ' . $list_layout_class; |
| 348 |
$class .= ' ' . $blockuniqueclass; |
| 349 |
$category_class = 'blockspare-posts-block-post-category'; |
| 350 |
|
| 351 |
if ($attributes['categoryLayoutOption'] == 'none') { |
| 352 |
$category_class .= ' has-no-category-style'; |
| 353 |
} ?> |
| 354 |
|
| 355 |
<section class="blockspare-posts-block-post-wrap"> |
| 356 |
<div class="<?php echo esc_attr($grid_class); ?>"> |
| 357 |
<?php while ($grid_query->have_posts()) { |
| 358 |
$grid_query->the_post(); |
| 359 |
|
| 360 |
/* Setup the post ID */ |
| 361 |
$post_id = get_the_ID(); |
| 362 |
|
| 363 |
/* Setup the featured image ID */ |
| 364 |
$post_thumb_id = get_post_thumbnail_id($post_id); |
| 365 |
|
| 366 |
$has_img_class = ''; |
| 367 |
|
| 368 |
if (!$post_thumb_id) { |
| 369 |
$has_img_class = "post-has-no-image"; |
| 370 |
} |
| 371 |
|
| 372 |
|
| 373 |
|
| 374 |
|
| 375 |
if ($attributes['enableEqualHeight']) { |
| 376 |
$has_img_class .= ' bs-has-equal-height'; |
| 377 |
} |
| 378 |
$contentOrderClass = ''; |
| 379 |
if ($attributes['contentOrder'] == 'content-order-1') { |
| 380 |
$contentOrderClass .= 'contentorderone'; |
| 381 |
} |
| 382 |
if ($attributes['contentOrder'] == 'content-order-2') { |
| 383 |
$contentOrderClass .= 'contentordertwo'; |
| 384 |
} |
| 385 |
|
| 386 |
/* Setup the post classes */ |
| 387 |
$post_classes = 'blockspare-posts-block-post-single blockspare-hover-item ' . $contentOrderClass; |
| 388 |
|
| 389 |
if ($layoutClass) { |
| 390 |
$post_classes .= ' has-background'; |
| 391 |
} else { |
| 392 |
$post_classes .= ' blockspare-hover-child'; |
| 393 |
} |
| 394 |
|
| 395 |
$className = ''; |
| 396 |
|
| 397 |
if (isset($attributes['full'])) { |
| 398 |
if ($attributes['full'] == 'blockspare-posts-block-full-layout-6') { |
| 399 |
$post_classes .= ' blockspare-hover-child'; |
| 400 |
$className .= 'hover-child'; |
| 401 |
} |
| 402 |
} |
| 403 |
|
| 404 |
|
| 405 |
/* Add sticky class */ |
| 406 |
if (is_sticky($post_id)) { |
| 407 |
$post_classes .= ' sticky'; |
| 408 |
} else { |
| 409 |
$post_classes .= null; |
| 410 |
} |
| 411 |
$post_classes .= ' has-background'; |
| 412 |
?> |
| 413 |
<div id="<?php echo esc_attr($post_id); ?>" class="<?php echo esc_attr($post_classes) . ' ' . $has_img_class; ?>"> |
| 414 |
<?php blockspare_express_post_image($attributes, $post_id, $category_class, $blockName, $className, $count); ?> |
| 415 |
<?php blockspare_express_post_content($attributes, $post_id, $category_class, $blockName, $className, $count); ?> |
| 416 |
</div> |
| 417 |
|
| 418 |
<?php $count++; |
| 419 |
} ?> |
| 420 |
|
| 421 |
</div> |
| 422 |
<?php |
| 423 |
if ($attributes['enablePagination'] == 'true' && $grid_query->max_num_pages > 1) { |
| 424 |
$loadmore_class = ''; |
| 425 |
if ($attributes['loadMoreStyle']) { |
| 426 |
$loadmore_class = $attributes['loadMoreStyle']; |
| 427 |
} |
| 428 |
if ($attributes['loadMoreAlignment']) { |
| 429 |
$loadmore_class .= ' bs_blockspare_loadmore_' . $attributes['loadMoreAlignment']; |
| 430 |
} |
| 431 |
?> |
| 432 |
<div class="bs_blockspare_loadmore blockspare-readmore-wrapper <?php echo esc_attr($loadmore_class); ?>" data-layout="<?php echo $layoutClass; ?>" block-name="express" data-page='2' blockspare-att=<?php echo "'" . wp_kses_post(wp_json_encode($attributes)) . "'"; ?> max-paged="<?php echo $grid_query->max_num_pages; ?>"> |
| 433 |
<a href="#" class="blockspare-readmore"> |
| 434 |
<div class="load-btn "><?php echo ($attributes['loadMoreText']); ?><span class="ajax-loader"></span></div> |
| 435 |
</a> |
| 436 |
</div><?php |
| 437 |
} |
| 438 |
?> |
| 439 |
</section> |
| 440 |
|
| 441 |
<?php |
| 442 |
} |
| 443 |
|
| 444 |
wp_reset_postdata(); |
| 445 |
} |
| 446 |
|
| 447 |
function blockspare_express_post_image($attributes, $post_id, $cat_class, $blockName = '', $className = '', $count = '') |
| 448 |
{ |
| 449 |
|
| 450 |
|
| 451 |
$spotlightItems = 0; |
| 452 |
if ($attributes['express'] == 'blockspare-posts-block-express-grid-layout-3' || $attributes['express'] == 'blockspare-posts-block-express-grid-layout-6') { |
| 453 |
$spotlightItems = 1; |
| 454 |
} |
| 455 |
/* Setup the featured image ID */ |
| 456 |
$post_thumb_id = get_post_thumbnail_id($post_id); |
| 457 |
|
| 458 |
|
| 459 |
if (!empty($attributes['imageSize'])) { |
| 460 |
$post_thumb_size = $attributes['imageSize']; |
| 461 |
} |
| 462 |
|
| 463 |
$content_order = false; |
| 464 |
if ($attributes['contentOrder'] == 'content-order-1' || $attributes['contentOrder'] == 'content-order-2') { |
| 465 |
$content_order = true; |
| 466 |
} |
| 467 |
|
| 468 |
|
| 469 |
|
| 470 |
|
| 471 |
if (isset($attributes['enableFeatureImage']) && $attributes['enableFeatureImage'] == 'true') { |
| 472 |
?> |
| 473 |
<figure class="blockspare-posts-block-post-img hover-child"> |
| 474 |
<a href="<?php echo esc_url(get_permalink($post_id)); ?>" aria-label="<?php echo esc_attr(get_the_title($post_id)); ?>"> |
| 475 |
<?php |
| 476 |
if (has_post_thumbnail($post_id)) { |
| 477 |
if ($count <= $spotlightItems) { |
| 478 |
echo wp_kses_post(wp_get_attachment_image($post_thumb_id, $attributes['spotslightImageSize'])); |
| 479 |
} |
| 480 |
if ($count > $spotlightItems) { |
| 481 |
echo wp_kses_post(wp_get_attachment_image($post_thumb_id, $post_thumb_size)); |
| 482 |
} |
| 483 |
} else { ?> |
| 484 |
<div class="bs-no-thumbnail-img"> </div> |
| 485 |
<?php } ?> |
| 486 |
</a> |
| 487 |
<?php if ($attributes['displaySpotlightPostCategory'] == 'true' && $content_order == true && $count <= $spotlightItems) { ?> |
| 488 |
<!-- Spotlight Category --> |
| 489 |
<div class="<?php echo esc_attr($cat_class); ?>"> |
| 490 |
<?php blockspare_get_cat_tax_tags($attributes['taxType'], $post_id, $attributes['postType']); ?> |
| 491 |
</div> |
| 492 |
<!-- Spotlight Category --> |
| 493 |
<?php } ?> |
| 494 |
<?php if ($attributes['displayPostCategory'] == 'true' && $content_order == true && $count > $spotlightItems) { ?> |
| 495 |
<!-- Category --> |
| 496 |
<div class="<?php echo esc_attr($cat_class); ?>"> |
| 497 |
<?php blockspare_get_cat_tax_tags($attributes['taxType'], $post_id, $attributes['postType']); ?> |
| 498 |
</div> |
| 499 |
<!-- Category --> |
| 500 |
<?php } ?> |
| 501 |
</figure> |
| 502 |
<?php |
| 503 |
} |
| 504 |
} |
| 505 |
|
| 506 |
function blockspare_express_post_content($attributes, $post_id, $cat_class, $blockName = '', $className = '', $count = '') |
| 507 |
{ |
| 508 |
$spotlightItems = 0; |
| 509 |
if ($attributes['express'] == 'blockspare-posts-block-express-grid-layout-3' || $attributes['express'] == 'blockspare-posts-block-express-grid-layout-6') { |
| 510 |
$spotlightItems = 1; |
| 511 |
} |
| 512 |
$content_order = false; |
| 513 |
if ($attributes['contentOrder'] == 'content-order-1' || $attributes['contentOrder'] == 'content-order-2') { |
| 514 |
$content_order = true; |
| 515 |
} |
| 516 |
if ($blockName == 'full') { |
| 517 |
$content_order = false; |
| 518 |
} |
| 519 |
?> |
| 520 |
<div class="blockspare-posts-block-post-content <?php echo esc_attr($className); ?> <?php echo esc_attr($attributes['contentOrder']); ?> <?php echo esc_attr($attributes['titleOnHover']) ?>"> |
| 521 |
<div class="blockspare-posts-block-bg-overlay"></div> |
| 522 |
<!-- blockspare-posts-block-post-grid-header --> |
| 523 |
<header class="blockspare-posts-block-post-grid-header"> |
| 524 |
<!--display category when feature image is disable --> |
| 525 |
<?php if ($attributes['displayPostCategory'] == 'true' && $attributes['enableFeatureImage'] != 'true') { ?> |
| 526 |
<!-- Category --> |
| 527 |
<div class="<?php echo esc_attr($cat_class); ?>"> |
| 528 |
<?php blockspare_get_cat_tax_tags($attributes['taxType'], $post_id, $attributes['postType']); ?> |
| 529 |
</div> |
| 530 |
<!-- Category --> |
| 531 |
<?php } ?> |
| 532 |
<!--display category when feature image is enable--> |
| 533 |
<?php if ($attributes['displayPostCategory'] == 'true' && $attributes['enableFeatureImage'] == 'true' && $content_order == false) { ?> |
| 534 |
<!-- Category --> |
| 535 |
<div class="<?php echo esc_attr($cat_class); ?>"> |
| 536 |
<?php blockspare_get_cat_tax_tags($attributes['taxType'], $post_id, $attributes['postType']); ?> |
| 537 |
</div> |
| 538 |
<!-- Category --> |
| 539 |
<?php } ?> |
| 540 |
<!-- blockspare-posts-block-post-grid-title --> |
| 541 |
|
| 542 |
<?php if ($attributes['displaySpotlightPostTitle'] == 'true' && $count <= $spotlightItems) { ?> |
| 543 |
<h2 class="blockspare-posts-block-post-grid-title"> |
| 544 |
<a href="<?php echo esc_url(get_permalink($post_id)); ?>" class="blockspare-posts-block-title-link" |
| 545 |
rel="bookmark"> |
| 546 |
<span><?php echo get_the_title(); ?></span> |
| 547 |
</a> |
| 548 |
</h2> |
| 549 |
<?php } ?> |
| 550 |
<?php if ($attributes['displayPostTitle'] == 'true' && $count > $spotlightItems) { ?> |
| 551 |
<h2 class="blockspare-posts-block-post-grid-title"> |
| 552 |
<a href="<?php echo esc_url(get_permalink($post_id)); ?>" class="blockspare-posts-block-title-link" |
| 553 |
rel="bookmark"> |
| 554 |
<span><?php echo get_the_title(); ?></span> |
| 555 |
</a> |
| 556 |
</h2> |
| 557 |
|
| 558 |
<?php } ?> |
| 559 |
|
| 560 |
<!-- blockspare-posts-block-post-grid-title --> |
| 561 |
|
| 562 |
<!-- blockspare-posts-block-post-grid-byline --> |
| 563 |
<div class="blockspare-posts-block-post-grid-byline"> |
| 564 |
<!-- blockspare-posts-block-post-grid-author --> |
| 565 |
<?php if (isset($attributes['displaySpotlightPostAuthor']) && $attributes['displaySpotlightPostAuthor'] == 'true' && $count <= $spotlightItems) { ?> |
| 566 |
<div class="blockspare-posts-block-post-grid-author"> |
| 567 |
|
| 568 |
<?php |
| 569 |
$author_id = get_post_field('post_author', $post_id); |
| 570 |
$blockspare_get_multiauthor = new BlocksapreMultiAuthorForFrontend(); |
| 571 |
$blockspare_get_multiauthor->blockspare_front_by_author($post_id, $attributes['authorIcon'], $author_id); |
| 572 |
?> |
| 573 |
</div> |
| 574 |
<?php } ?> |
| 575 |
<!-- spotlight blockspare-posts-block-post-grid-author --> |
| 576 |
<!-- blockspare-posts-block-post-grid-author --> |
| 577 |
<?php if (isset($attributes['displayPostAuthor']) && $attributes['displayPostAuthor'] == 'true' && $count > $spotlightItems) { ?> |
| 578 |
<div class="blockspare-posts-block-post-grid-author"> |
| 579 |
|
| 580 |
<?php |
| 581 |
$author_id = get_post_field('post_author', $post_id); |
| 582 |
$blockspare_get_multiauthor = new BlocksapreMultiAuthorForFrontend(); |
| 583 |
$blockspare_get_multiauthor->blockspare_front_by_author($post_id, $attributes['authorIcon'], $author_id); |
| 584 |
?> |
| 585 |
</div> |
| 586 |
<?php } ?> |
| 587 |
<!-- blockspare-posts-block-post-grid-author --> |
| 588 |
|
| 589 |
<!-- Spotlight blockspare-posts-block-post-grid-date --> |
| 590 |
<?php if (isset($attributes['displaySpotlightPostDate']) && $attributes['displaySpotlightPostDate'] == 'true' && $count <= $spotlightItems) { ?> |
| 591 |
<time datetime="<?php echo esc_attr(get_the_date('c', $post_id)); ?>" class="blockspare-posts-block-post-grid-date" itemprop="datePublished"><i class="<?php echo esc_attr($attributes['dateIcon']); ?>" aria-hidden="true"></i><?php echo esc_html(get_the_date('', $post_id)); ?></time> |
| 592 |
<?php } ?> |
| 593 |
<!-- Spotlight blockspare-posts-block-post-grid-date --> |
| 594 |
<!-- blockspare-posts-block-post-grid-date --> |
| 595 |
<?php if (isset($attributes['displayPostDate']) && $attributes['displayPostDate'] == 'true' && $count > $spotlightItems) { ?> |
| 596 |
<time datetime="<?php echo esc_attr(get_the_date('c', $post_id)); ?>" class="blockspare-posts-block-post-grid-date" itemprop="datePublished"><i class="<?php echo esc_attr($attributes['dateIcon']); ?>" aria-hidden="true"></i><?php echo esc_html(get_the_date('', $post_id)); ?></time> |
| 597 |
<?php } ?> |
| 598 |
<!-- blockspare-posts-block-post-grid-date --> |
| 599 |
|
| 600 |
<!-- Spotlight comment_count --> |
| 601 |
<?php if ($attributes['enableSpotlightComment'] == 'true' && $count <= $spotlightItems) { ?> |
| 602 |
<span class="comment_count"><i class='<?php echo esc_attr($attributes['commentIcon']); ?>' aria-hidden="true"></i><?php echo esc_html(get_comments_number($post_id)); ?></span> |
| 603 |
<?php } ?> |
| 604 |
<!-- Spotlight --> |
| 605 |
<?php if ($attributes['enableComment'] == 'true' && $count > $spotlightItems) { ?> |
| 606 |
<span class="comment_count"><i class='<?php echo esc_attr($attributes['commentIcon']); ?>' aria-hidden="true"></i><?php echo esc_html(get_comments_number($post_id)); ?></span> |
| 607 |
<?php } ?> |
| 608 |
<!-- comment_count --> |
| 609 |
</div> |
| 610 |
<!-- blockspare-posts-block-post-grid-byline --> |
| 611 |
</header> |
| 612 |
<!-- blockspare-posts-block-post-grid-header --> |
| 613 |
|
| 614 |
|
| 615 |
<?php |
| 616 |
|
| 617 |
if ($attributes['displaySpotlightPostExcerpt'] == 'true' && $count <= $spotlightItems) { |
| 618 |
$excerpts = blockspare_excerpt($post_id, $attributes['excerptSpotlightLength']); |
| 619 |
$new_excerpt = apply_filters('the_excerpt', $excerpts); ?> |
| 620 |
<!-- Spotlight blockspare-posts-block-post-grid-excerpt --> |
| 621 |
<?php if ($attributes['displaySpotlightPostExcerpt'] && $new_excerpt != null) { ?> |
| 622 |
<div class="blockspare-posts-block-post-grid-excerpt"> |
| 623 |
<!-- blockspare-posts-block-post-grid-excerpt-content --> |
| 624 |
<?php if (isset($attributes['displaySpotlightPostExcerpt']) && $attributes['displaySpotlightPostExcerpt'] == 'true') { ?> |
| 625 |
<div class="blockspare-posts-block-post-grid-excerpt-content"> |
| 626 |
<?php echo wp_kses_post($excerpts); ?> |
| 627 |
</div> |
| 628 |
<?php } ?> |
| 629 |
<!-- blockspare-posts-block-post-grid-excerpt-content --> |
| 630 |
<!-- blockspare-posts-block-post-grid-more-link --> |
| 631 |
<?php if (isset($attributes['displaySpotPostLink']) && $attributes['displaySpotPostLink'] == 'true') { ?> |
| 632 |
<p> |
| 633 |
|
| 634 |
|
| 635 |
<a |
| 636 |
class="blockspare-posts-block-post-grid-more-link blockspare-posts-block-text-link" |
| 637 |
href="<?php echo esc_url(get_permalink($post_id)); ?>" |
| 638 |
aria-label="<?php echo sprintf(esc_attr__('Read more about %s', 'blockspare'), esc_html(get_the_title($post_id))); ?>"> |
| 639 |
<span aria-hidden="true"><?php echo esc_html($attributes['readMoreText']); ?></span> |
| 640 |
</a> |
| 641 |
|
| 642 |
</p> |
| 643 |
<?php } ?> |
| 644 |
<!-- blockspare-posts-block-post-grid-more-link --> |
| 645 |
</div> |
| 646 |
<?php } |
| 647 |
} ?> |
| 648 |
<!-- Spotlight blockspare-posts-block-post-grid-excerpt --> |
| 649 |
<?php |
| 650 |
if ($attributes['displayPostExcerpt'] == 'true' && $count > $spotlightItems) { |
| 651 |
|
| 652 |
$excerpt = blockspare_excerpt($post_id, $attributes['excerptLength']); |
| 653 |
$new_excerpt = apply_filters('the_excerpt', $excerpt); ?> |
| 654 |
<!-- blockspare-posts-block-post-grid-excerpt --> |
| 655 |
<?php if ($attributes['displayPostExcerpt'] && $new_excerpt != null) { ?> |
| 656 |
<div class="blockspare-posts-block-post-grid-excerpt"> |
| 657 |
<!-- blockspare-posts-block-post-grid-excerpt-content --> |
| 658 |
<?php if (isset($attributes['displayPostExcerpt']) && $attributes['displayPostExcerpt'] == 'true' && $count > $spotlightItems) { ?> |
| 659 |
<div class="blockspare-posts-block-post-grid-excerpt-content"> |
| 660 |
<?php echo wp_kses_post($excerpt); ?> |
| 661 |
</div> |
| 662 |
<?php } ?> |
| 663 |
<!-- blockspare-posts-block-post-grid-excerpt-content --> |
| 664 |
<!-- blockspare-posts-block-post-grid-more-link --> |
| 665 |
<?php if (isset($attributes['displayPostLink']) && $attributes['displayPostLink'] == 'true' && $count > $spotlightItems) { ?> |
| 666 |
<p> |
| 667 |
<a |
| 668 |
class="blockspare-posts-block-post-grid-more-link blockspare-posts-block-text-link" |
| 669 |
href="<?php echo esc_url(get_permalink($post_id)); ?>" |
| 670 |
aria-label="<?php echo sprintf(esc_attr__('Read more about %s', 'blockspare'), esc_html(get_the_title($post_id))); ?>"> |
| 671 |
<span aria-hidden="true"><?php echo esc_html($attributes['readMoreText']); ?></span> |
| 672 |
</a> |
| 673 |
|
| 674 |
</p> |
| 675 |
<?php } ?> |
| 676 |
<!-- blockspare-posts-block-post-grid-more-link --> |
| 677 |
</div> |
| 678 |
<?php } |
| 679 |
} ?> |
| 680 |
<!-- blockspare-posts-block-post-grid-excerpt --> |
| 681 |
|
| 682 |
</div> |
| 683 |
<?php } |
| 684 |
|