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