| 1 |
<?php |
| 2 |
|
| 3 |
if(!function_exists('blockspare_render_block_core_latest_posts_grid')){ |
| 4 |
function blockspare_render_block_core_latest_posts_grid($attributes) |
| 5 |
{ |
| 6 |
|
| 7 |
ob_start(); |
| 8 |
$unq_class = mt_rand(100000,999999); |
| 9 |
$blockuniqueclass = ''; |
| 10 |
|
| 11 |
if(!empty($attributes['uniqueClass'])){ |
| 12 |
$blockuniqueclass = $attributes['uniqueClass']; |
| 13 |
}else{ |
| 14 |
$blockuniqueclass = 'blockspare-posts-block-list-'.$unq_class; |
| 15 |
} |
| 16 |
|
| 17 |
$block_class = 'blockspare-posts-block-is-grid'.' has-gutter-'.$attributes['gutterSpace'];;; |
| 18 |
$design = $attributes['grid']; |
| 19 |
|
| 20 |
blockspare_query_loop_and_wrapper($attributes,$block_class,$design); |
| 21 |
$data_content = latest_posts_style_control_grid($blockuniqueclass ,$attributes); |
| 22 |
$data_content .= ob_get_clean(); |
| 23 |
return $data_content; |
| 24 |
|
| 25 |
} |
| 26 |
} |
| 27 |
|
| 28 |
/** |
| 29 |
* Registers the post grid block on server |
| 30 |
*/ |
| 31 |
if(!function_exists('blockspare_register_block_core_latest_posts_grid')){ |
| 32 |
function blockspare_register_block_core_latest_posts_grid() |
| 33 |
{ |
| 34 |
|
| 35 |
if (!function_exists('register_block_type')) { |
| 36 |
return; |
| 37 |
} |
| 38 |
|
| 39 |
|
| 40 |
ob_start(); |
| 41 |
include BLOCKSPARE_PLUGIN_DIR . 'inc/latest-post-block/posts-grid/block.json'; |
| 42 |
$metadata = json_decode(ob_get_clean(), true); |
| 43 |
|
| 44 |
/* Block attributes */ |
| 45 |
register_block_type( |
| 46 |
'blockspare/blockspare-latest-posts-grid', |
| 47 |
array( |
| 48 |
'attributes' =>$metadata['attributes'], |
| 49 |
'render_callback' => 'blockspare_render_block_core_latest_posts_grid', |
| 50 |
) |
| 51 |
); |
| 52 |
} |
| 53 |
|
| 54 |
add_action('init', 'blockspare_register_block_core_latest_posts_grid'); |
| 55 |
} |
| 56 |
|
| 57 |
if(!function_exists('latest_posts_style_control_grid')){ |
| 58 |
function latest_posts_style_control_grid($blockuniqueclass ,$attributes){ |
| 59 |
|
| 60 |
|
| 61 |
$block_content =''; |
| 62 |
$block_content .= '<style type="text/css">'; |
| 63 |
$block_content .= ' .' . $blockuniqueclass . '.blockspare-posts-block-latest-post-wrap{ |
| 64 |
margin-top:' . $attributes['marginTop'] . 'px; |
| 65 |
margin-bottom:' . $attributes['marginBottom'] . 'px; |
| 66 |
margin-left:' . $attributes['marginLeft'] . 'px; |
| 67 |
margin-right:' . $attributes['marginRight'] . 'px; |
| 68 |
}'; |
| 69 |
|
| 70 |
$block_content .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-content{ |
| 71 |
padding-top:' . $attributes['contentPaddingTop'] . 'px; |
| 72 |
padding-right:' . $attributes['contentPaddingRight'] . 'px; |
| 73 |
padding-bottom:' . $attributes['contentPaddingBottom'] . 'px; |
| 74 |
padding-left:' . $attributes['contentPaddingLeft'] . 'px; |
| 75 |
}'; |
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
if ($attributes['categoryLayoutOption'] == 'solid') { |
| 81 |
|
| 82 |
|
| 83 |
$block_content .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-category a{ |
| 84 |
color:' . $attributes['categoryTextColor'] . "!important" . '; |
| 85 |
background-color:' . $attributes['categoryBackgroundColor'] . "!important" . '; |
| 86 |
border-radius:' . $attributes['categoryBorderRadius'] . "px" . '; |
| 87 |
}'; |
| 88 |
|
| 89 |
} else if ($attributes['categoryLayoutOption'] == 'border') { |
| 90 |
|
| 91 |
|
| 92 |
$block_content .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-category a{ |
| 93 |
color:' . $attributes['categoryTextColor'] . "!important" . '; |
| 94 |
background-color:' . "transparent" . '; |
| 95 |
border:' . "1px solid" . $attributes['categoryBorderColor'] . '; |
| 96 |
border-radius:' . $attributes['categoryBorderRadius'] . "px" . '; |
| 97 |
border-width:' . $attributes['categoryBorderWidth'] . "px" . '; |
| 98 |
}'; |
| 99 |
|
| 100 |
|
| 101 |
|
| 102 |
} else { |
| 103 |
$block_content .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-category a{ |
| 104 |
color:' . $attributes['categoryTextColor'] . "!important" . '; |
| 105 |
}'; |
| 106 |
} |
| 107 |
|
| 108 |
|
| 109 |
$block_content .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-category{ |
| 110 |
margin-top:' . $attributes['categoryMarginTop'] . 'px' . '; |
| 111 |
margin-bottom:' . $attributes['categoryMarginBottom'] . 'px' . '; |
| 112 |
margin-left:' . $attributes['categoryMarginLeft'] . 'px' . '; |
| 113 |
margin-right:' . $attributes['categoryMarginRight'] . 'px' . '; |
| 114 |
}'; |
| 115 |
|
| 116 |
|
| 117 |
$block_content .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-grid-byline{ |
| 118 |
|
| 119 |
margin-top:' . $attributes['metaMarginTop'] . 'px' . '; |
| 120 |
margin-bottom:' . $attributes['metaMarginBottom'] . 'px' . '; |
| 121 |
margin-left:' . $attributes['metaMarginLeft'] . 'px' . '; |
| 122 |
margin-right:' . $attributes['metaMarginRight'] . 'px' . '; |
| 123 |
}'; |
| 124 |
|
| 125 |
|
| 126 |
$block_content .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-grid-more-link{ |
| 127 |
margin-top:' . $attributes['moreLinkMarginTop'] . 'px' . '; |
| 128 |
margin-bottom:' . $attributes['moreLinkMarginBottom'] . 'px' . '; |
| 129 |
margin-left:' . $attributes['moreLinkMarginLeft'] . 'px' . '; |
| 130 |
margin-right:' . $attributes['moreLinkMarginRight'] . 'px' . '; |
| 131 |
}'; |
| 132 |
|
| 133 |
|
| 134 |
|
| 135 |
|
| 136 |
|
| 137 |
$block_content .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-grid-title a span{ |
| 138 |
color: ' . $attributes['postTitleColor'] . '; |
| 139 |
|
| 140 |
}'; |
| 141 |
|
| 142 |
$block_content .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-grid-author a span{ |
| 143 |
color:' . $attributes['linkColor'] . '; |
| 144 |
}'; |
| 145 |
|
| 146 |
|
| 147 |
$block_content .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-grid-more-link span{ |
| 148 |
color:' . $attributes['linkColor'] . '; |
| 149 |
}'; |
| 150 |
|
| 151 |
$block_content .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-grid-date{ |
| 152 |
color:' . $attributes['generalColor'] . '; |
| 153 |
}'; |
| 154 |
|
| 155 |
$block_content .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-grid-excerpt-content,'.' .' . $blockuniqueclass . ' .comment_count{ |
| 156 |
color:' . $attributes['generalColor'] . '; |
| 157 |
|
| 158 |
}'; |
| 159 |
|
| 160 |
|
| 161 |
$block_content .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-grid-title{ |
| 162 |
margin-top:' . $attributes['titleMarginTop'] . 'px' . '; |
| 163 |
margin-bottom:' . $attributes['titleMarginBottom'] . 'px' . '; |
| 164 |
margin-left:' . $attributes['titleMarginLeft'] . 'px' . '; |
| 165 |
margin-right:' . $attributes['titleMarginRight'] . 'px' . '; |
| 166 |
}'; |
| 167 |
|
| 168 |
|
| 169 |
$block_content .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-grid-excerpt-content{ |
| 170 |
margin-top:' . $attributes['exceprtMarginTop'] . 'px' . '; |
| 171 |
margin-bottom:' . $attributes['exceprtMarginBottom'] . 'px' . '; |
| 172 |
margin-left:' . $attributes['exceprtMarginLeft'] . 'px' . '; |
| 173 |
margin-right:' . $attributes['exceprtMarginRight'] . 'px' . '; |
| 174 |
}'; |
| 175 |
|
| 176 |
$layoutstyle = explode('-',$attributes['grid']); |
| 177 |
if($layoutstyle[5] >3){ |
| 178 |
$block_content .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-single .blockspare-posts-block-post-img img{ |
| 179 |
border-radius:' . $attributes['borderRadius'] . 'px'.'; |
| 180 |
|
| 181 |
}'; |
| 182 |
if($attributes['enableBoxShadow']){ |
| 183 |
$block_content .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-single .blockspare-posts-block-post-img img{ |
| 184 |
box-shadow: ' . $attributes['xOffset'] . 'px ' . $attributes['yOffset'] . 'px ' . $attributes['blur'] . 'px ' . $attributes['spread'] . 'px ' . $attributes['shadowColor'] . '; |
| 185 |
}'; |
| 186 |
} |
| 187 |
}else{ |
| 188 |
$block_content .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-single{ |
| 189 |
border-radius:' . $attributes['borderRadius'] . 'px'.'; |
| 190 |
background-color:'.$attributes['backGroundColor'].' |
| 191 |
}'; |
| 192 |
|
| 193 |
if($attributes['enableBoxShadow']){ |
| 194 |
$block_content .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-single{ |
| 195 |
box-shadow: ' . $attributes['xOffset'] . 'px ' . $attributes['yOffset'] . 'px ' . $attributes['blur'] . 'px ' . $attributes['spread'] . 'px ' . $attributes['shadowColor'] . '; |
| 196 |
}'; |
| 197 |
} |
| 198 |
} |
| 199 |
|
| 200 |
|
| 201 |
|
| 202 |
|
| 203 |
|
| 204 |
//Title Hover |
| 205 |
|
| 206 |
if($attributes['titleOnHover']=='lpc-title-hover') { |
| 207 |
$block_content .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-content .blockspare-posts-block-title-link:hover span{ |
| 208 |
color: ' . $attributes['titleOnHoverColor'] . '; |
| 209 |
|
| 210 |
}'; |
| 211 |
} |
| 212 |
|
| 213 |
if($attributes['titleOnHover']=='lpc-title-border') { |
| 214 |
$block_content .= ' .' . $blockuniqueclass . ' .lpc-title-border .blockspare-posts-block-post-grid-title .blockspare-posts-block-title-link span:hover{ |
| 215 |
box-shadow: inset 0 -2px 0 0 ' . $attributes['titleOnHoverColor'] . '; |
| 216 |
|
| 217 |
}'; |
| 218 |
} |
| 219 |
|
| 220 |
//Font Settings |
| 221 |
|
| 222 |
$block_content .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-grid-title a span{ |
| 223 |
|
| 224 |
font-size: ' . $attributes['postTitleFontSize'] . $attributes['titleFontSizeType'] . '; |
| 225 |
|
| 226 |
'.bscheckFontfamily($attributes['titleFontFamily']).'; |
| 227 |
font-weight: ' . $attributes['titleFontWeight'] . '; |
| 228 |
}'; |
| 229 |
|
| 230 |
$block_content .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-content .blockspare-posts-block-post-grid-excerpt .blockspare-posts-block-post-grid-excerpt-content { |
| 231 |
font-size:' . $attributes['descriptionFontSize'] . $attributes['descriptionFontSizeType'] . '; |
| 232 |
|
| 233 |
'.bscheckFontfamily($attributes['descriptionFontFamily']).'; |
| 234 |
font-weight: ' . $attributes['descriptionFontWeight'] . '; |
| 235 |
}'; |
| 236 |
|
| 237 |
$block_content .= '@media (max-width: 1025px) { '; |
| 238 |
$block_content .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-grid-title a span{ |
| 239 |
font-size: ' . $attributes['titleFontSizeTablet'] . $attributes['titleFontSizeType'] . '; |
| 240 |
}'; |
| 241 |
$block_content .= ' .' . $blockuniqueclass .' .blockspare-posts-block-post-content .blockspare-posts-block-post-grid-excerpt .blockspare-posts-block-post-grid-excerpt-content { |
| 242 |
font-size:' . $attributes['descriptionFontSizeTablet'].$attributes['descriptionFontSizeType'].' |
| 243 |
}'; |
| 244 |
$block_content .= '}'; |
| 245 |
|
| 246 |
|
| 247 |
$block_content .= '@media (max-width: 768px) { '; |
| 248 |
$block_content .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-grid-title a span{ |
| 249 |
font-size: ' . $attributes['titleFontSizeMobile'] . $attributes['titleFontSizeType'] . '; |
| 250 |
}'; |
| 251 |
$block_content .= ' .' . $blockuniqueclass .' .blockspare-posts-block-post-content .blockspare-posts-block-post-grid-excerpt .blockspare-posts-block-post-grid-excerpt-content { |
| 252 |
font-size:' . $attributes['descriptionFontSizeMobile'].$attributes['descriptionFontSizeType'].' |
| 253 |
}'; |
| 254 |
$block_content .= '}'; |
| 255 |
|
| 256 |
//Pagination |
| 257 |
if($attributes['enablePagination']){ |
| 258 |
$block_content .=' .' . $blockuniqueclass . ' + .bs_blockspare_loadmore a.blockspare-readmore .load-btn{ |
| 259 |
color:'.$attributes['loadMoreTextColor'].'; |
| 260 |
background-color:'.$attributes['loadMoreTextBgColor'].'; |
| 261 |
'.bscheckFontfamily($attributes['titleFontFamily']).'; |
| 262 |
}'; |
| 263 |
$block_content .=' .' . $blockuniqueclass . ' + .bs_blockspare_loadmore a.blockspare-readmore .ajax-loader-enabled{ |
| 264 |
border-top-color:'.$attributes['loadMoreColor'].'; |
| 265 |
}'; |
| 266 |
$block_content .= '}'; |
| 267 |
|
| 268 |
} |
| 269 |
|
| 270 |
|
| 271 |
$block_content .= '</style>'; |
| 272 |
return $block_content; |
| 273 |
} |
| 274 |
} |
| 275 |
|
| 276 |
|