| @@ -1,237 +1,469 @@ | ||
| 1 | 1 | <?php |
| 2 | -if (!function_exists('blockspare_posts_style_control_list')) { | |
| 3 | - function blockspare_posts_style_control_list($blockuniqueclass, $attributes) | |
| 4 | - { | |
| 5 | - $inline_css = ''; | |
| 6 | - $inline_css .= blockspare_visibility_css($attributes, $blockuniqueclass); | |
| 7 | - $inline_css .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-wrap{ | |
| 8 | - margin-top:' . $attributes['marginTop'] . 'px; | |
| 9 | - margin-bottom:' . $attributes['marginBottom'] . 'px; | |
| 10 | - margin-left:' . $attributes['marginLeft'] . 'px; | |
| 11 | - margin-right:' . $attributes['marginRight'] . 'px; | |
| 12 | - }'; | |
| 2 | + if(!function_exists('blockspare_render_block_core_latest_posts_list')){ | |
| 3 | + function blockspare_render_block_core_latest_posts_list($attributes) | |
| 4 | + { | |
| 5 | + | |
| 6 | + if($attributes['enablePagination']){ | |
| 7 | + wp_enqueue_script('blockspare-pagination-js'); | |
| 8 | + } | |
| 9 | + ob_start(); | |
| 10 | + $unq_class = mt_rand(100000,999999); | |
| 11 | + $blockuniqueclass = ''; | |
| 12 | + | |
| 13 | + if($attributes['enableTwoColumn']){ | |
| 14 | + $design = $attributes['design'].' list-col-2'; | |
| 15 | + }else{ | |
| 16 | + $design = $attributes['design'].' '.$attributes['columns']; | |
| 17 | + } | |
| 18 | + | |
| 19 | + | |
| 20 | + if(!empty($attributes['uniqueClass'])){ | |
| 21 | + $blockuniqueclass = $attributes['uniqueClass']; | |
| 22 | + }else{ | |
| 23 | + $blockuniqueclass = 'blockspare-posts-block-list-'.$unq_class; | |
| 24 | + } | |
| 25 | + $hasimgclass = 'featured-img-not-enabaled'; | |
| 26 | + if($attributes['enableFeatureImage'] == true){ | |
| 27 | + $hasimgclass = $attributes['imageSize'].'-'.$attributes['ImageUnit']; | |
| 28 | + | |
| 29 | + } | |
| 30 | + $blockName= 'post-list'; | |
| 31 | + $layoutClass= false; | |
| 32 | + if($attributes['design'] != 'blockspare-posts-block-list-layout-4' && $attributes['design'] != 'blockspare-posts-block-list-layout-5' && $attributes['design'] != 'blockspare-posts-block-list-layout-6') { | |
| 33 | + $layoutClass= true; | |
| 34 | + } | |
| 35 | + | |
| 36 | + $block_class = 'blockspare-posts-block-is-list '.$hasimgclass .' has-gutter-'.$attributes['gutterSpace']; | |
| 37 | + if($attributes['displayPostExcerpt'] == true) { | |
| 38 | + $block_class .= ' blockspare-post-expert-enabled'; | |
| 39 | + } | |
| 40 | + if($attributes['imageSize'] == 'thumbnail') { | |
| 41 | + $block_class .= ' blockspare-has-thumbnail-image'; | |
| 42 | + } | |
| 43 | + blockspare_query_loop_and_wrapper($attributes,$block_class,$design,$blockName,$layoutClass); | |
| 44 | + | |
| 45 | + $data_content = blockspare_post_style_css($blockuniqueclass ,$attributes); | |
| 46 | + $data_content .= ob_get_clean(); | |
| 47 | + return $data_content; | |
| 48 | + | |
| 49 | + } | |
| 50 | +} | |
| 51 | + | |
| 52 | + /** | |
| 53 | + * Registers the post grid block on server | |
| 54 | + */ | |
| 55 | + if(!function_exists('blockspare_register_block_core_latest_posts_list')){ | |
| 56 | + function blockspare_register_block_core_latest_posts_list() | |
| 57 | + { | |
| 58 | + | |
| 59 | + if (!function_exists('register_block_type')) { | |
| 60 | + return; | |
| 61 | + } | |
| 62 | + | |
| 63 | + | |
| 64 | + ob_start(); | |
| 65 | + include BLOCKSPARE_PLUGIN_DIR . 'inc/latest-post-block/posts-list/block.json'; | |
| 66 | + $metadata = json_decode(ob_get_clean(), true); | |
| 67 | + | |
| 68 | + | |
| 69 | + /* Block attributes */ | |
| 70 | + register_block_type( | |
| 71 | + 'blockspare/blockspare-latest-posts-list', | |
| 72 | + array( | |
| 73 | + 'attributes' =>$metadata['attributes'], | |
| 74 | + 'render_callback' => 'blockspare_render_block_core_latest_posts_list', | |
| 75 | + ) | |
| 76 | + ); | |
| 77 | + } | |
| 78 | + | |
| 79 | + add_action('init', 'blockspare_register_block_core_latest_posts_list'); | |
| 80 | +} | |
| 81 | + | |
| 82 | + | |
| 83 | + /** | |
| 84 | + * Create API fields for additional info | |
| 85 | + */ | |
| 86 | + if(!function_exists('blockspare_post_register_rest_fields')){ | |
| 87 | + function blockspare_post_register_rest_fields() | |
| 88 | + { | |
| 89 | + | |
| 90 | + register_rest_field('post', 'featured_image_urls', | |
| 91 | + array( | |
| 92 | + 'get_callback' => 'blockspare_featured_image_urls', | |
| 93 | + 'update_callback' => null, | |
| 94 | + 'schema' => array( | |
| 95 | + 'description' => __('Different sized featured images', 'blockspare'), | |
| 96 | + 'type' => 'array', | |
| 97 | + ), | |
| 98 | + ) | |
| 99 | + ); | |
| 100 | + | |
| 101 | + // Excer | |
| 102 | + | |
| 103 | + /* Add author info */ | |
| 104 | + register_rest_field( | |
| 105 | + 'post', | |
| 106 | + 'author_info', | |
| 107 | + array( | |
| 108 | + 'get_callback' => 'blockspare_get_author_infos', | |
| 109 | + 'update_callback' => null, | |
| 110 | + 'schema' => null, | |
| 111 | + ) | |
| 112 | + ); | |
| 113 | + | |
| 114 | + /* Add author info */ | |
| 115 | + register_rest_field( | |
| 116 | + 'post', | |
| 117 | + 'category_info', | |
| 118 | + array( | |
| 119 | + 'get_callback' => 'blockspare_get_category_infos', | |
| 120 | + 'update_callback' => null, | |
| 121 | + 'schema' => null, | |
| 122 | + ) | |
| 123 | + ); | |
| 124 | + | |
| 125 | + /* Add author info */ | |
| 126 | + register_rest_field( | |
| 127 | + 'post', | |
| 128 | + 'tag_info', | |
| 129 | + array( | |
| 130 | + 'get_callback' => 'blockspare_get_tag_infos', | |
| 131 | + 'update_callback' => null, | |
| 132 | + 'schema' => null, | |
| 133 | + ) | |
| 134 | + ); | |
| 135 | + | |
| 136 | + register_rest_field( | |
| 137 | + 'post', | |
| 138 | + 'comment_count', | |
| 139 | + array( | |
| 140 | + 'get_callback' => 'blockspare_get_comment_count', | |
| 141 | + 'update_callback' => null, | |
| 142 | + 'schema' => null, | |
| 143 | + ) | |
| 144 | + ); | |
| 145 | + } | |
| 146 | + | |
| 147 | + add_action('rest_api_init', 'blockspare_post_register_rest_fields'); | |
| 148 | +} | |
| 149 | + | |
| 150 | + | |
| 151 | + /** | |
| 152 | + * Get author info for the rest field | |
| 153 | + * | |
| 154 | + * @param String $object The object type. | |
| 155 | + * @param String $field_name Name of the field to retrieve. | |
| 156 | + * @param String $request The current request object. | |
| 157 | + */ | |
| 158 | + if(!function_exists('blockspare_get_author_infos')){ | |
| 159 | + function blockspare_get_author_infos($object, $field_name, $request){ | |
| 160 | + if(!isset($object['author'])) | |
| 161 | + return; | |
| 162 | + global $post; | |
| 163 | + $author_id = get_post_field( 'post_author', $object['author'] ); | |
| 164 | + $blocspare = new BlocksapreMultiAuthorForBackend(); | |
| 165 | + $author_data= $blocspare->blockspare_by_author($post); | |
| 166 | + return $author_data; | |
| 167 | + } | |
| 168 | + } | |
| 169 | + if(!function_exists('blockspare_get_category_infos')){ | |
| 170 | + function blockspare_get_category_infos($object, $field_name, $request){ | |
| 171 | + return get_the_category_list(' ', '', $object['id']); | |
| 172 | + | |
| 173 | + } | |
| 174 | + } | |
| 175 | + | |
| 176 | + if(!function_exists('blockspare_get_tag_infos')){ | |
| 177 | + function blockspare_get_tag_infos($object, $field_name, $request) { | |
| 178 | + | |
| 179 | + ob_start(); | |
| 180 | + $cate_name = ''; | |
| 181 | + if (!empty($object)) { | |
| 182 | + foreach ($object['categories'] as $cat_id) { | |
| 183 | + $cate_name = get_cat_name($cat_id); | |
| 184 | + } | |
| 185 | + } | |
| 186 | + ob_clean(); | |
| 187 | + return $cate_name; | |
| 188 | + | |
| 189 | + } | |
| 190 | + } | |
| 191 | + | |
| 192 | + if(!function_exists('blockspare_get_comment_count')){ | |
| 193 | + function blockspare_get_comment_count($object, $field_name, $reques){ | |
| 194 | + | |
| 195 | + return get_comments_number( $object['id'] ); | |
| 196 | + | |
| 197 | + } | |
| 198 | + } | |
| 199 | + | |
| 200 | + if (!function_exists('blockspare_featured_image_urls')) { | |
| 201 | + /** | |
| 202 | + * Get the different featured image sizes that the blog will use. | |
| 203 | + * Used in the custom REST API endpoint. | |
| 204 | + * | |
| 205 | + * @since 1.7 | |
| 206 | + */ | |
| 207 | + function blockspare_featured_image_urls($object, $field_name, $request) | |
| 208 | + { | |
| 209 | + return blockspare_featured_image_urls_from_url(!empty($object['featured_media']) ? $object['featured_media'] : ''); | |
| 210 | + } | |
| 211 | + } | |
| 212 | + | |
| 213 | + | |
| 214 | + if (!function_exists('blockspare_featured_image_urls_from_url')) { | |
| 215 | + /** | |
| 216 | + * Get the different featured image sizes that the blog will use. | |
| 217 | + * | |
| 218 | + * @since 2.0 | |
| 219 | + */ | |
| 220 | + function blockspare_featured_image_urls_from_url($attachment_id) | |
| 221 | + { | |
| 222 | + | |
| 223 | + $image = wp_get_attachment_image_src($attachment_id, 'full', false); | |
| 224 | + $sizes = get_intermediate_image_sizes(); | |
| 225 | + | |
| 226 | + $imageSizes = array( | |
| 227 | + 'full' => is_array($image) ? $image : '', | |
| 228 | + ); | |
| 229 | + | |
| 230 | + foreach ($sizes as $size) { | |
| 231 | + $imageSizes[$size] = is_array($image) ? wp_get_attachment_image_src($attachment_id, $size, false) : ''; | |
| 232 | + } | |
| 233 | + | |
| 234 | + return $imageSizes; | |
| 235 | + } | |
| 236 | + } | |
| 237 | + if(!function_exists('blockspare_post_style_css')){ | |
| 238 | + function blockspare_post_style_css($blockuniqueclass ,$attributes){ | |
| 239 | + | |
| 240 | + | |
| 241 | + $block_content =''; | |
| 242 | + $block_content .= '<style type="text/css">'; | |
| 243 | + $block_content .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-wrap{ | |
| 244 | + margin-top:' . $attributes['marginTop'] . 'px; | |
| 245 | + margin-bottom:' . $attributes['marginBottom'] . 'px; | |
| 246 | + margin-left:' . $attributes['marginLeft'] . 'px; | |
| 247 | + margin-right:' . $attributes['marginRight'] . 'px; | |
| 248 | + }'; | |
| 249 | + | |
| 250 | + $block_content .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-content{ | |
| 251 | + padding-top:' . $attributes['contentPaddingTop'] . 'px; | |
| 252 | + padding-right:' . $attributes['contentPaddingRight'] . 'px; | |
| 253 | + padding-bottom:' . $attributes['contentPaddingBottom'] . 'px; | |
| 254 | + padding-left:' . $attributes['contentPaddingLeft'] . 'px; | |
| 255 | + }'; | |
| 256 | + | |
| 13 | 257 | |
| 14 | - $inline_css .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-content{ | |
| 15 | - padding-top:' . $attributes['contentPaddingTop'] . 'px; | |
| 16 | - padding-right:' . $attributes['contentPaddingRight'] . 'px; | |
| 17 | - padding-bottom:' . $attributes['contentPaddingBottom'] . 'px; | |
| 18 | - padding-left:' . $attributes['contentPaddingLeft'] . 'px; | |
| 19 | - }'; | |
| 20 | - | |
| 21 | - $inline_css .= blockspare_posts_category_style( | |
| 22 | - $inline_css, | |
| 23 | - $attributes, | |
| 24 | - $blockuniqueclass, | |
| 25 | - $attributes['categoryTextColor'], | |
| 26 | - $attributes['categoryBackgroundColor'], | |
| 27 | - $attributes['categoryBorderColor'], | |
| 28 | - $attributes['secondCategoryTextColor'], | |
| 29 | - $attributes['secondCategoryBackgroundColor'], | |
| 30 | - $attributes['secondCategoryBorderColor'], | |
| 31 | - $attributes['thirdCategoryTextColor'], | |
| 32 | - $attributes['thirdCategoryBackgroundColor'], | |
| 33 | - $attributes['thirdCategoryBorderColor'], | |
| 34 | - ); | |
| 35 | - | |
| 36 | - $inline_css .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-grid-byline{ | |
| 37 | - margin-top:' . $attributes['metaMarginTop'] . 'px' . '; | |
| 38 | - margin-bottom:' . $attributes['metaMarginBottom'] . 'px' . '; | |
| 39 | - margin-left:' . $attributes['metaMarginLeft'] . 'px' . '; | |
| 40 | - margin-right:' . $attributes['metaMarginRight'] . 'px' . '; | |
| 41 | - }'; | |
| 42 | - | |
| 43 | - $inline_css .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-grid-more-link{ | |
| 44 | - margin-top:' . $attributes['moreLinkMarginTop'] . 'px' . '; | |
| 45 | - margin-bottom:' . $attributes['moreLinkMarginBottom'] . 'px' . '; | |
| 46 | - margin-left:' . $attributes['moreLinkMarginLeft'] . 'px' . '; | |
| 47 | - margin-right:' . $attributes['moreLinkMarginRight'] . 'px' . '; | |
| 48 | - }'; | |
| 49 | - | |
| 50 | - $inline_css .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-grid-title a span{ | |
| 51 | - color: ' . $attributes['postTitleColor'] . '; | |
| 52 | - }'; | |
| 53 | - | |
| 54 | - $inline_css .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-grid-author a span{ | |
| 55 | - color:' . $attributes['linkColor'] . '; | |
| 56 | - }'; | |
| 57 | - | |
| 58 | - $inline_css .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-grid-more-link span{ | |
| 59 | - color:' . $attributes['linkColor'] . '; | |
| 60 | - }'; | |
| 61 | - | |
| 62 | - $inline_css .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-grid-date{ | |
| 63 | - color:' . $attributes['generalColor'] . '; | |
| 64 | - }'; | |
| 65 | - | |
| 66 | - $inline_css .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-grid-excerpt-content{ | |
| 67 | - color:' . $attributes['generalColor'] . '; | |
| 68 | - }'; | |
| 69 | - | |
| 70 | - $inline_css .= ' .' . $blockuniqueclass . ' .comment_count{ | |
| 71 | - color:' . $attributes['generalColor'] . '; | |
| 72 | - }'; | |
| 73 | - | |
| 74 | - $inline_css .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-grid-title{ | |
| 75 | - margin-top:' . $attributes['titleMarginTop'] . 'px' . '; | |
| 76 | - margin-bottom:' . $attributes['titleMarginBottom'] . 'px' . '; | |
| 77 | - margin-left:' . $attributes['titleMarginLeft'] . 'px' . '; | |
| 78 | - margin-right:' . $attributes['titleMarginRight'] . 'px' . '; | |
| 79 | - }'; | |
| 80 | - | |
| 81 | - $inline_css .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-grid-excerpt-content{ | |
| 82 | - margin-top:' . $attributes['exceprtMarginTop'] . 'px' . '; | |
| 83 | - margin-bottom:' . $attributes['exceprtMarginBottom'] . 'px' . '; | |
| 84 | - margin-left:' . $attributes['exceprtMarginLeft'] . 'px' . '; | |
| 85 | - margin-right:' . $attributes['exceprtMarginRight'] . 'px' . '; | |
| 86 | - }'; | |
| 87 | - | |
| 88 | - $layoutstyle = explode('-', $attributes['design']); | |
| 89 | - | |
| 90 | - if ($layoutstyle[5] > 3) { | |
| 91 | - $inline_css .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-single .blockspare-posts-block-post-img { | |
| 92 | - border-radius:' . $attributes['borderRadius'] . 'px' . '; | |
| 258 | + if ($attributes['categoryLayoutOption'] == 'solid') { | |
| 259 | + | |
| 260 | + $block_content .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-category a{ | |
| 261 | + color:' . $attributes['categoryTextColor'] . "!important" . '; | |
| 262 | + background-color:' . $attributes['categoryBackgroundColor'] . "!important" . '; | |
| 263 | + border-radius:' . $attributes['categoryBorderRadius'] . "px" . '; | |
| 264 | + }'; | |
| 265 | + | |
| 266 | + | |
| 267 | + } else if ($attributes['categoryLayoutOption'] == 'border') { | |
| 268 | + | |
| 269 | + | |
| 270 | + $block_content .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-category a{ | |
| 271 | + color:' . $attributes['categoryTextColor'] . "!important" . '; | |
| 272 | + background-color:' . "transparent" . '; | |
| 273 | + border:' . "1px solid" . $attributes['categoryBorderColor'] . '; | |
| 274 | + border-radius:' . $attributes['categoryBorderRadius'] . "px" . '; | |
| 275 | + border-width:' . $attributes['categoryBorderWidth'] . "px" . '; | |
| 93 | 276 | }'; |
| 94 | - if ($attributes['enableBoxShadow']) { | |
| 95 | - $inline_css .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-single .blockspare-posts-block-post-img { | |
| 96 | - box-shadow: ' . $attributes['xOffset'] . 'px ' . $attributes['yOffset'] . 'px ' . $attributes['blur'] . 'px ' . $attributes['spread'] . 'px ' . $attributes['shadowColor'] . '; | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + } else { | |
| 281 | + $block_content .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-category a{ | |
| 282 | + color:' . $attributes['categoryTextColor'] . "!important" . '; | |
| 97 | 283 | }'; |
| 98 | - } | |
| 99 | - } else { | |
| 100 | - $inline_css .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-single{ | |
| 101 | - border-radius:' . $attributes['borderRadius'] . 'px' . '; | |
| 102 | - background-color:' . $attributes['backGroundColor'] . ' | |
| 284 | + } | |
| 285 | + | |
| 286 | + | |
| 287 | + $block_content .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-category{ | |
| 288 | + margin-top:' . $attributes['categoryMarginTop'] . 'px' . '; | |
| 289 | + margin-bottom:' . $attributes['categoryMarginBottom'] . 'px' . '; | |
| 290 | + margin-left:' . $attributes['categoryMarginLeft'] . 'px' . '; | |
| 291 | + margin-right:' . $attributes['categoryMarginRight'] . 'px' . '; | |
| 292 | + }'; | |
| 293 | + | |
| 294 | + | |
| 295 | + $block_content .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-grid-byline{ | |
| 296 | + | |
| 297 | + margin-top:' . $attributes['metaMarginTop'] . 'px' . '; | |
| 298 | + margin-bottom:' . $attributes['metaMarginBottom'] . 'px' . '; | |
| 299 | + margin-left:' . $attributes['metaMarginLeft'] . 'px' . '; | |
| 300 | + margin-right:' . $attributes['metaMarginRight'] . 'px' . '; | |
| 301 | + }'; | |
| 302 | + | |
| 303 | + | |
| 304 | + $block_content .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-grid-more-link{ | |
| 305 | + margin-top:' . $attributes['moreLinkMarginTop'] . 'px' . '; | |
| 306 | + margin-bottom:' . $attributes['moreLinkMarginBottom'] . 'px' . '; | |
| 307 | + margin-left:' . $attributes['moreLinkMarginLeft'] . 'px' . '; | |
| 308 | + margin-right:' . $attributes['moreLinkMarginRight'] . 'px' . '; | |
| 309 | + }'; | |
| 310 | + | |
| 311 | + $block_content .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-grid-title a span{ | |
| 312 | + color: ' . $attributes['postTitleColor'] . '; | |
| 313 | + | |
| 314 | + }'; | |
| 315 | + | |
| 316 | + $block_content .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-grid-author a span{ | |
| 317 | + color:' . $attributes['linkColor'] . '; | |
| 318 | + }'; | |
| 319 | + | |
| 320 | + | |
| 321 | + $block_content .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-grid-more-link span{ | |
| 322 | + color:' . $attributes['linkColor'] . '; | |
| 323 | + }'; | |
| 324 | + | |
| 325 | + $block_content .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-grid-date{ | |
| 326 | + color:' . $attributes['generalColor'] . '; | |
| 327 | + }'; | |
| 328 | + | |
| 329 | + $block_content .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-grid-excerpt-content,'.' .' . $blockuniqueclass . ' .comment_count{ | |
| 330 | + color:' . $attributes['generalColor'] . '; | |
| 331 | + | |
| 332 | + }'; | |
| 333 | + | |
| 334 | + | |
| 335 | + $block_content .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-grid-title{ | |
| 336 | + margin-top:' . $attributes['titleMarginTop'] . 'px' . '; | |
| 337 | + margin-bottom:' . $attributes['titleMarginBottom'] . 'px' . '; | |
| 338 | + margin-left:' . $attributes['titleMarginLeft'] . 'px' . '; | |
| 339 | + margin-right:' . $attributes['titleMarginRight'] . 'px' . '; | |
| 103 | 340 | }'; |
| 104 | - | |
| 105 | - if ($attributes['enableBoxShadow']) { | |
| 106 | - $inline_css .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-single{ | |
| 107 | - box-shadow: ' . $attributes['xOffset'] . 'px ' . $attributes['yOffset'] . 'px ' . $attributes['blur'] . 'px ' . $attributes['spread'] . 'px ' . $attributes['shadowColor'] . '; | |
| 341 | + | |
| 342 | + | |
| 343 | + $block_content .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-grid-excerpt-content{ | |
| 344 | + margin-top:' . $attributes['exceprtMarginTop'] . 'px' . '; | |
| 345 | + margin-bottom:' . $attributes['exceprtMarginBottom'] . 'px' . '; | |
| 346 | + margin-left:' . $attributes['exceprtMarginLeft'] . 'px' . '; | |
| 347 | + margin-right:' . $attributes['exceprtMarginRight'] . 'px' . '; | |
| 108 | 348 | }'; |
| 109 | - } | |
| 110 | - } | |
| 111 | 349 | |
| 112 | - //Title Hover | |
| 350 | + | |
| 351 | + | |
| 352 | + $layoutstyle = explode('-',$attributes['design']); | |
| 353 | + if($layoutstyle[5] >3){ | |
| 354 | + $block_content .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-single .blockspare-posts-block-post-img img{ | |
| 355 | + border-radius:' . $attributes['borderRadius'] . 'px'.'; | |
| 356 | + | |
| 357 | + }'; | |
| 358 | + if($attributes['enableBoxShadow']){ | |
| 359 | + $block_content .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-single .blockspare-posts-block-post-img img{ | |
| 360 | + box-shadow: ' . $attributes['xOffset'] . 'px ' . $attributes['yOffset'] . 'px ' . $attributes['blur'] . 'px ' . $attributes['spread'] . 'px ' . $attributes['shadowColor'] . '; | |
| 361 | + }'; | |
| 362 | + } | |
| 363 | + }else{ | |
| 364 | + $block_content .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-single{ | |
| 365 | + border-radius:' . $attributes['borderRadius'] . 'px'.'; | |
| 366 | + background-color:'.$attributes['backGroundColor'].' | |
| 367 | + }'; | |
| 368 | + | |
| 369 | + if($attributes['enableBoxShadow']){ | |
| 370 | + $block_content .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-single{ | |
| 371 | + box-shadow: ' . $attributes['xOffset'] . 'px ' . $attributes['yOffset'] . 'px ' . $attributes['blur'] . 'px ' . $attributes['spread'] . 'px ' . $attributes['shadowColor'] . '; | |
| 372 | + }'; | |
| 373 | + } | |
| 374 | + } | |
| 375 | + | |
| 113 | 376 | |
| 114 | - if ($attributes['titleOnHover'] == 'lpc-title-hover') { | |
| 115 | - $inline_css .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-content .blockspare-posts-block-title-link:hover span{ | |
| 116 | - color: ' . $attributes['titleOnHoverColor'] . '; | |
| 377 | + //Title Hover | |
| 378 | + | |
| 379 | + if($attributes['titleOnHover']=='lpc-title-hover') { | |
| 380 | + $block_content .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-content .blockspare-posts-block-title-link:hover span{ | |
| 381 | + color: ' . $attributes['titleOnHoverColor'] . '; | |
| 382 | + | |
| 117 | 383 | }'; |
| 118 | - } | |
| 384 | + } | |
| 119 | 385 | |
| 120 | - if ($attributes['titleOnHover'] == 'lpc-title-border') { | |
| 121 | - $inline_css .= ' .' . $blockuniqueclass . ' .lpc-title-border .blockspare-posts-block-post-grid-title .blockspare-posts-block-title-link span:hover{ | |
| 122 | - box-shadow: inset 0 -2px 0 0 ' . $attributes['titleOnHoverColor'] . '; | |
| 123 | - }'; | |
| 386 | + if($attributes['titleOnHover']=='lpc-title-border') { | |
| 387 | + $block_content .= ' .' . $blockuniqueclass . ' .lpc-title-border .blockspare-posts-block-post-grid-title .blockspare-posts-block-title-link span:hover{ | |
| 388 | + box-shadow: inset 0 -2px 0 0 ' . $attributes['titleOnHoverColor'] . '; | |
| 389 | + | |
| 390 | + }'; | |
| 124 | 391 | } |
| 125 | - | |
| 126 | - //Font Settings | |
| 127 | - | |
| 128 | - $inline_css .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-grid-title a span{ | |
| 129 | - font-size: ' . $attributes['postTitleFontSize'] . $attributes['titleFontSizeType'] . '; | |
| 130 | - ' . bscheckFontfamily($attributes['titleFontFamily']) . '; | |
| 131 | - ' . bscheckFontfamilyWeight($attributes['titleFontWeight']) . '; | |
| 132 | - line-height: ' . $attributes['postTitleLineHeight'] . '; | |
| 133 | - }'; | |
| 134 | - | |
| 135 | - $inline_css .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-content .blockspare-posts-block-post-grid-excerpt .blockspare-posts-block-post-grid-excerpt-content { | |
| 136 | - font-size:' . $attributes['descriptionFontSize'] . $attributes['descriptionFontSizeType'] . '; | |
| 137 | - ' . bscheckFontfamily($attributes['descriptionFontFamily']) . '; | |
| 138 | - ' . bscheckFontfamilyWeight($attributes['descriptionFontWeight']) . '; | |
| 139 | - }'; | |
| 140 | - | |
| 141 | - $inline_css .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-grid-author a span { | |
| 142 | - font-size:' . $attributes['postMetaFontSize'] . $attributes['postMetaFontSizeType'] . '; | |
| 143 | - ' . bscheckFontfamily($attributes['postMetaFontFamily']) . '; | |
| 144 | - ' . bscheckFontfamilyWeight($attributes['postMetaFontWeight']) . '; | |
| 145 | - }'; | |
| 146 | - | |
| 147 | - $inline_css .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-grid-date { | |
| 148 | - font-size:' . $attributes['postMetaFontSize'] . $attributes['postMetaFontSizeType'] . '; | |
| 149 | - ' . bscheckFontfamily($attributes['postMetaFontFamily']) . '; | |
| 150 | - ' . bscheckFontfamilyWeight($attributes['postMetaFontWeight']) . '; | |
| 151 | - }'; | |
| 152 | - | |
| 153 | - $inline_css .= ' .' . $blockuniqueclass . ' .comment_count { | |
| 154 | - font-size:' . $attributes['postMetaFontSize'] . $attributes['postMetaFontSizeType'] . '; | |
| 155 | - ' . bscheckFontfamily($attributes['postMetaFontFamily']) . '; | |
| 156 | - ' . bscheckFontfamilyWeight($attributes['postMetaFontWeight']) . '; | |
| 157 | - }'; | |
| 158 | - | |
| 159 | - $inline_css .= '@media (max-width: 1025px) { '; | |
| 160 | - | |
| 161 | - $inline_css .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-grid-title a span{ | |
| 162 | - font-size: ' . $attributes['titleFontSizeTablet'] . $attributes['titleFontSizeType'] . '; | |
| 163 | - }'; | |
| 164 | - $inline_css .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-content .blockspare-posts-block-post-grid-excerpt .blockspare-posts-block-post-grid-excerpt-content { | |
| 165 | - font-size:' . $attributes['descriptionFontSizeTablet'] . $attributes['descriptionFontSizeType'] . ' | |
| 166 | - }'; | |
| 167 | - $inline_css .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-grid-author a span { | |
| 168 | - font-size:' . $attributes['postMetaFontSizeTablet'] . $attributes['postMetaFontSizeType'] . ' | |
| 169 | - }'; | |
| 170 | - $inline_css .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-grid-date { | |
| 171 | - font-size:' . $attributes['postMetaFontSizeTablet'] . $attributes['postMetaFontSizeType'] . ' | |
| 172 | - }'; | |
| 173 | - $inline_css .= ' .' . $blockuniqueclass . ' .comment_count { | |
| 174 | - font-size:' . $attributes['postMetaFontSizeTablet'] . $attributes['postMetaFontSizeType'] . ' | |
| 175 | - }'; | |
| 176 | - | |
| 177 | - $inline_css .= '}'; | |
| 178 | - | |
| 179 | - | |
| 180 | - $inline_css .= '@media (max-width: 767px) { '; | |
| 181 | - | |
| 182 | - $inline_css .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-grid-title a span{ | |
| 183 | - font-size: ' . $attributes['titleFontSizeMobile'] . $attributes['titleFontSizeType'] . '; | |
| 184 | - }'; | |
| 185 | - $inline_css .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-content .blockspare-posts-block-post-grid-excerpt .blockspare-posts-block-post-grid-excerpt-content { | |
| 186 | - font-size:' . $attributes['descriptionFontSizeMobile'] . $attributes['descriptionFontSizeType'] . ' | |
| 187 | - }'; | |
| 188 | - $inline_css .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-grid-author a span { | |
| 189 | - font-size:' . $attributes['postMetaFontSizeMobile'] . $attributes['postMetaFontSizeType'] . ' | |
| 190 | - }'; | |
| 191 | - $inline_css .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-grid-date { | |
| 192 | - font-size:' . $attributes['postMetaFontSizeMobile'] . $attributes['postMetaFontSizeType'] . ' | |
| 193 | - }'; | |
| 194 | - $inline_css .= ' .' . $blockuniqueclass . ' .comment_count { | |
| 195 | - font-size:' . $attributes['postMetaFontSizeMobile'] . $attributes['postMetaFontSizeType'] . ' | |
| 196 | - }'; | |
| 197 | - | |
| 198 | - $inline_css .= '}'; | |
| 199 | - | |
| 200 | - //Pagination | |
| 201 | - | |
| 202 | - if ($attributes['enablePagination']) { | |
| 203 | - if ($attributes['loadMoreStyle'] == 'bs-loadmore-solid') { | |
| 204 | - $inline_css .= ' .' . $blockuniqueclass . ' .bs_blockspare_loadmore a.blockspare-readmore .load-btn{ | |
| 205 | - color:' . $attributes['loadMoreSolidTextColor'] . '; | |
| 206 | - background-color:' . $attributes['loadMoreTextBgColor'] . '; | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + //Font Settings | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + $block_content .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-grid-title a span{ | |
| 400 | + | |
| 401 | + font-size: ' . $attributes['postTitleFontSize'] . $attributes['titleFontSizeType'] . '; | |
| 402 | + | |
| 403 | + '.bscheckFontfamily($attributes['titleFontFamily']).'; | |
| 404 | + '.bscheckFontfamilyWeight($attributes['titleFontWeight']).'; | |
| 405 | + }'; | |
| 406 | + | |
| 407 | + $block_content .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-content .blockspare-posts-block-post-grid-excerpt .blockspare-posts-block-post-grid-excerpt-content { | |
| 408 | + font-size:' . $attributes['descriptionFontSize'] . $attributes['descriptionFontSizeType'] . '; | |
| 409 | + | |
| 410 | + '.bscheckFontfamily($attributes['descriptionFontFamily']).'; | |
| 411 | + '.bscheckFontfamilyWeight($attributes['descriptionFontWeight']).'; | |
| 412 | + | |
| 207 | 413 | }'; |
| 208 | - $inline_css .= ' .' . $blockuniqueclass . ' .bs_blockspare_loadmore a.blockspare-readmore .load-btn:hover{ | |
| 209 | - color:' . $attributes['loadMoreSolidTextHoverColor'] . '; | |
| 210 | - background-color:' . $attributes['loadMoreTextBgHoverColor'] . '; | |
| 414 | + | |
| 415 | + $block_content .= '@media (max-width: 1025px) { '; | |
| 416 | + $block_content .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-grid-title a span{ | |
| 417 | + font-size: ' . $attributes['titleFontSizeTablet'] . $attributes['titleFontSizeType'] . '; | |
| 211 | 418 | }'; |
| 212 | - } else { | |
| 213 | - $inline_css .= ' .' . $blockuniqueclass . ' .bs_blockspare_loadmore a.blockspare-readmore .load-btn{ | |
| 214 | - color:' . $attributes['loadMoreTextColor'] . '; | |
| 419 | + $block_content .= ' .' . $blockuniqueclass .' .blockspare-posts-block-post-content .blockspare-posts-block-post-grid-excerpt .blockspare-posts-block-post-grid-excerpt-content { | |
| 420 | + font-size:' . $attributes['descriptionFontSizeTablet'].$attributes['descriptionFontSizeType'].' | |
| 215 | 421 | }'; |
| 216 | - $inline_css .= ' .' . $blockuniqueclass . ' .bs_blockspare_loadmore a.blockspare-readmore .load-btn:hover{ | |
| 217 | - color:' . $attributes['loadMoreTextHoverColor'] . '; | |
| 422 | + $block_content .= '}'; | |
| 423 | + | |
| 424 | + | |
| 425 | + $block_content .= '@media (max-width: 767px) { '; | |
| 426 | + $block_content .= ' .' . $blockuniqueclass . ' .blockspare-posts-block-post-grid-title a span{ | |
| 427 | + font-size: ' . $attributes['titleFontSizeMobile'] . $attributes['titleFontSizeType'] . '; | |
| 218 | 428 | }'; |
| 219 | - } | |
| 220 | - | |
| 221 | - $inline_css .= ' .' . $blockuniqueclass . ' .bs_blockspare_loadmore{ | |
| 222 | - text-align:' . $attributes['loadMoreAlignment'] . '; | |
| 429 | + $block_content .= ' .' . $blockuniqueclass .' .blockspare-posts-block-post-content .blockspare-posts-block-post-grid-excerpt .blockspare-posts-block-post-grid-excerpt-content { | |
| 430 | + font-size:' . $attributes['descriptionFontSizeMobile'].$attributes['descriptionFontSizeType'].' | |
| 223 | 431 | }'; |
| 224 | - $inline_css .= ' .' . $blockuniqueclass . ' .bs_blockspare_loadmore a.blockspare-readmore .ajax-loader-enabled{ | |
| 225 | - border-top-color:' . $attributes['loadMoreColor'] . '; | |
| 226 | - }'; | |
| 227 | - $inline_css .= '}'; | |
| 432 | + $block_content .= '}'; | |
| 433 | + | |
| 434 | + //Pagination | |
| 435 | + if($attributes['enablePagination']){ | |
| 436 | + if($attributes['loadMoreStyle'] == 'bs-loadmore-solid') { | |
| 437 | + $block_content .=' .' . $blockuniqueclass . ' .bs_blockspare_loadmore a.blockspare-readmore .load-btn{ | |
| 438 | + color:'.$attributes['loadMoreSolidTextColor'].'; | |
| 439 | + background-color:'.$attributes['loadMoreTextBgColor'].'; | |
| 440 | + }'; | |
| 441 | + $block_content .=' .' . $blockuniqueclass . ' .bs_blockspare_loadmore a.blockspare-readmore .load-btn:hover{ | |
| 442 | + color:'.$attributes['loadMoreSolidTextHoverColor'].'; | |
| 443 | + background-color:'.$attributes['loadMoreTextBgHoverColor'].'; | |
| 444 | + }'; | |
| 445 | + } else { | |
| 446 | + $block_content .=' .' . $blockuniqueclass . ' .bs_blockspare_loadmore a.blockspare-readmore .load-btn{ | |
| 447 | + color:'.$attributes['loadMoreTextColor'].'; | |
| 448 | + }'; | |
| 449 | + $block_content .=' .' . $blockuniqueclass . ' .bs_blockspare_loadmore a.blockspare-readmore .load-btn:hover{ | |
| 450 | + color:'.$attributes['loadMoreTextHoverColor'].'; | |
| 451 | + }'; | |
| 452 | + } | |
| 453 | + | |
| 454 | + $block_content .=' .' . $blockuniqueclass . ' .bs_blockspare_loadmore{ | |
| 455 | + text-align:'.$attributes['loadMoreAlignment'].'; | |
| 456 | + }'; | |
| 457 | + $block_content .=' .' . $blockuniqueclass . ' .bs_blockspare_loadmore a.blockspare-readmore .ajax-loader-enabled{ | |
| 458 | + border-top-color:'.$attributes['loadMoreColor'].'; | |
| 459 | + }'; | |
| 460 | + $block_content .= '}'; | |
| 461 | + } | |
| 462 | + | |
| 463 | + | |
| 464 | + $block_content .= '</style>'; | |
| 465 | + return $block_content; | |
| 228 | 466 | } |
| 229 | - | |
| 230 | - | |
| 231 | - if (!empty($inline_css)) { | |
| 232 | - wp_register_style('bs-post-list', false); | |
| 233 | - wp_enqueue_style('bs-post-list'); | |
| 234 | - wp_add_inline_style('bs-post-list', blockspare_minify_css($inline_css)); | |
| 235 | - } | |
| 236 | - } | |
| 237 | 467 | } |
| 468 | + | |
| 469 | + | |