| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* Plugin Name: Advanced Posts Listing |
| 5 |
* Plugin URI: https://wordpress.org/plugins/advanced-posts-listing |
| 6 |
* Description: A Gutenberg block that enables site admins to add & display beautiful blog posts listing / custom post type listing on frontend with live preview in editor. |
| 7 |
* Requires at least: 5.5 |
| 8 |
* Requires PHP: 7.0 |
| 9 |
* Version: 1.0.7 |
| 10 |
* Author: flippercode |
| 11 |
* Author URI: https://weplugins.com/ |
| 12 |
* License: GPLv2 or later |
| 13 |
* License URI: https://www.gnu.org/licenses/gpl-2.0.html |
| 14 |
* Text Domain: advanced-posts-listing |
| 15 |
* Domain Path: /lang/ |
| 16 |
*/ |
| 17 |
|
| 18 |
if (!defined('ABSPATH')) { |
| 19 |
die('You are not allowed to call this page directly.'); |
| 20 |
} |
| 21 |
|
| 22 |
if (!class_exists('Advanced_Post_Listing_Block')) { |
| 23 |
|
| 24 |
class Advanced_Post_Listing_Block |
| 25 |
{ |
| 26 |
|
| 27 |
public function __construct() |
| 28 |
{ |
| 29 |
$this->aplb_register_plugin_hooks(); |
| 30 |
} |
| 31 |
|
| 32 |
function aplb_register_plugin_hooks() |
| 33 |
{ |
| 34 |
add_action('init', [$this, 'aplb_advance_posts_listing_block_callback']); |
| 35 |
add_action('rest_api_init', [$this, 'aplb_register_custom_endpoints']); |
| 36 |
add_action('rest_api_init', [$this, 'aplb_register_custom_rest_fields']); |
| 37 |
add_action('plugins_loaded', [$this, 'aplb_load_plugin_languages']); |
| 38 |
add_action('enqueue_block_editor_assets', [$this, 'aplb_get_server_side_pass']); |
| 39 |
} |
| 40 |
|
| 41 |
function aplb_load_plugin_languages() |
| 42 |
{ |
| 43 |
|
| 44 |
load_plugin_textdomain('advanced-posts-listing', false, dirname(plugin_basename(__FILE__)) . '/lang'); |
| 45 |
} |
| 46 |
|
| 47 |
function aplb_advance_posts_listing_block_callback() |
| 48 |
{ |
| 49 |
register_block_type(__DIR__ . '/build', array( |
| 50 |
'render_callback' => array($this, 'aplb_advance_post_listing_block'), |
| 51 |
)); |
| 52 |
} |
| 53 |
function aplb_advance_post_listing_block($attributes) |
| 54 |
{ |
| 55 |
$post_type_names = strtolower($attributes['selectedCustomPostType']); |
| 56 |
|
| 57 |
if (strpos($post_type_names, 'pages') !== false || strpos($post_type_names, 'posts') !== false) { |
| 58 |
if (substr($post_type_names, -1) === 's') { |
| 59 |
$post_type_names = substr($post_type_names, 0, -1); |
| 60 |
} |
| 61 |
} |
| 62 |
|
| 63 |
|
| 64 |
if (isset($attributes['sortBy'])) { |
| 65 |
|
| 66 |
switch ($attributes['sortBy']) { |
| 67 |
case 'new-to-old': |
| 68 |
$order = 'DESC'; |
| 69 |
$orderby = 'date'; |
| 70 |
break; |
| 71 |
case 'old-to-new': |
| 72 |
$order = 'ASC'; |
| 73 |
$orderby = 'date'; |
| 74 |
break; |
| 75 |
case 'A-Z': |
| 76 |
$order = 'ASC'; |
| 77 |
$orderby = 'title'; |
| 78 |
break; |
| 79 |
case 'Z-A': |
| 80 |
$order = 'DESC'; |
| 81 |
$orderby = 'title'; |
| 82 |
break; |
| 83 |
default: |
| 84 |
$order = 'DESC'; |
| 85 |
$orderby = 'date'; |
| 86 |
break; |
| 87 |
} |
| 88 |
} else { |
| 89 |
$orderby = 'date'; |
| 90 |
$order = 'DESC'; |
| 91 |
} |
| 92 |
|
| 93 |
$post_ids_to_remove = $attributes['RemoveCommaSeparatedIds'] ?? []; |
| 94 |
$post_ids_to_show = $attributes['commaSeparatedIds'] ?? []; |
| 95 |
|
| 96 |
$args = array( |
| 97 |
'posts_per_page' => $attributes['numPostsToShow'] ?? 10, |
| 98 |
'post_status' => 'publish', |
| 99 |
// 'post_type' => $post_type_names, |
| 100 |
// 'ignore_sticky_posts' => true, |
| 101 |
'order' => $order, |
| 102 |
'orderby' => $orderby, |
| 103 |
); |
| 104 |
if (!empty($post_ids_to_remove) && !empty($post_ids_to_show)) { |
| 105 |
$post_ids_to_show = array_diff($post_ids_to_show, $post_ids_to_remove); |
| 106 |
$args['post__in'] = $post_ids_to_show; |
| 107 |
} elseif (!empty($post_ids_to_show)) { |
| 108 |
$args['post__in'] = $post_ids_to_show; |
| 109 |
} elseif (!empty($post_ids_to_remove)) { |
| 110 |
$args['post__not_in'] = $post_ids_to_remove; |
| 111 |
} |
| 112 |
if (!empty($post_ids_to_show)) { |
| 113 |
$args['post_type'] = 'any'; |
| 114 |
} else { |
| 115 |
$args['post_type'] = $post_type_names; |
| 116 |
} |
| 117 |
|
| 118 |
if (isset($attributes['customTaxonomyPosts']) && !empty($attributes['customTaxonomyPosts'])) { |
| 119 |
|
| 120 |
$tax_query = array( |
| 121 |
'relation' => 'AND', |
| 122 |
); |
| 123 |
|
| 124 |
foreach ($attributes['customTaxonomyPosts'] as $key => $terms) { |
| 125 |
if ($key === 'tags') { |
| 126 |
$taxonomy = 'post_tag'; |
| 127 |
} elseif ($key === 'categories') { |
| 128 |
$taxonomy = 'category'; |
| 129 |
} else { |
| 130 |
$taxonomy = $key; |
| 131 |
} |
| 132 |
foreach ($terms as $slug) { |
| 133 |
$tax_query[] = array( |
| 134 |
'taxonomy' => $taxonomy, |
| 135 |
'field' => 'slug', |
| 136 |
'terms' => $slug, |
| 137 |
); |
| 138 |
} |
| 139 |
} |
| 140 |
|
| 141 |
$args['tax_query'] = $tax_query; |
| 142 |
} |
| 143 |
|
| 144 |
if (isset($tax_query)) { |
| 145 |
$args['tax_query'] = $tax_query; |
| 146 |
} |
| 147 |
|
| 148 |
$args = apply_filters('aplb_frontend_query_args', $args); |
| 149 |
$selectedLayout = $attributes['selectedLayout']; |
| 150 |
$plugin_url = plugin_dir_url(__FILE__); |
| 151 |
if (isset($selectedLayout) && !empty($selectedLayout)) { |
| 152 |
$list_items_markup = null; |
| 153 |
switch ($selectedLayout) { |
| 154 |
case 'listing-layout': |
| 155 |
$list_items_markup = $this->aplb_listing_layout($args, $attributes); |
| 156 |
break; |
| 157 |
case 'listing-layout-two': |
| 158 |
$list_items_markup = $this->aplb_listing_layout_two($args, $attributes); |
| 159 |
break; |
| 160 |
case 'grid-layout': |
| 161 |
$list_items_markup = $this->aplb_grid_layout($args, $attributes); |
| 162 |
break; |
| 163 |
case 'overlay-layout': |
| 164 |
$list_items_markup = $this->aplb_overlay_layout($args, $attributes); |
| 165 |
break; |
| 166 |
case 'slider-layout': |
| 167 |
$list_items_markup = $this->aplb_slider_layout($args, $attributes); |
| 168 |
break; |
| 169 |
case 'masonry-layout': |
| 170 |
$list_items_markup = $this->aplb_masonry_layout($args, $attributes); |
| 171 |
break; |
| 172 |
default: |
| 173 |
$list_items_markup = "Invalid layout selected."; |
| 174 |
break; |
| 175 |
} |
| 176 |
} |
| 177 |
|
| 178 |
$classes = array('wp-block-latest-posts__list'); |
| 179 |
|
| 180 |
$wrapper_attributes = get_block_wrapper_attributes(array('class' => implode(' ', $classes))); |
| 181 |
|
| 182 |
return sprintf( |
| 183 |
'<div %1$s>%2$s</div>', |
| 184 |
$wrapper_attributes, |
| 185 |
$list_items_markup |
| 186 |
); |
| 187 |
} |
| 188 |
|
| 189 |
|
| 190 |
function aplb_listing_layout($args, $attributes) |
| 191 |
{ |
| 192 |
|
| 193 |
|
| 194 |
$title_Manage_styling = !empty($attributes['title_Manage_styling']) ? 'true' : 'false'; |
| 195 |
$title_font_size = !empty($attributes['title_font_size']) ? $attributes['title_font_size'] : '1.5rem'; |
| 196 |
|
| 197 |
$Meta_Manage_styling = !empty($attributes['Meta_Manage_styling']) ? 'true' : 'false'; |
| 198 |
$Meta_font_size = !empty($attributes['Meta_font_size']) ? $attributes['Meta_font_size'] : '0.875rem'; |
| 199 |
|
| 200 |
$Content_Manage_styling = !empty($attributes['Content_Manage_styling']) ? 'true' : 'false'; |
| 201 |
$Content_font_size = !empty($attributes['Content_font_size']) ? $attributes['Content_font_size'] : '1.5rem'; |
| 202 |
|
| 203 |
|
| 204 |
$showReadMoreToggler = !empty($attributes['showReadMoreToggler']) ? 'true' : 'false'; |
| 205 |
$css = ''; |
| 206 |
|
| 207 |
if ($showReadMoreToggler === 'true') { |
| 208 |
$button_Top_bottom_Padding = !empty($attributes['button_Top_bottom_Padding']) ? $attributes['button_Top_bottom_Padding'] : '8px'; |
| 209 |
$button_Right_Left_Padding = !empty($attributes['button_Right_Left_Padding']) ? $attributes['button_Right_Left_Padding'] : '16px'; |
| 210 |
$ReadMoreTextColor = !empty($attributes['ReadMoreTextColor']) ? $attributes['ReadMoreTextColor'] : '#FFFFFF'; |
| 211 |
$ReadMoreBgColor = !empty($attributes['ReadMoreBgColor']) ? $attributes['ReadMoreBgColor'] : '#000000'; |
| 212 |
|
| 213 |
$css .= ' |
| 214 |
.read-more-button { |
| 215 |
background-color: ' . $ReadMoreBgColor . '!important; |
| 216 |
color: ' . $ReadMoreTextColor . ' !important; |
| 217 |
padding: ' . $button_Top_bottom_Padding . ' ' . $button_Right_Left_Padding . ' !important; |
| 218 |
} |
| 219 |
.pagination .page-numbers:hover, .pagination .page-numbers.current { |
| 220 |
background-color:' . $ReadMoreBgColor . '!important; |
| 221 |
color: ' . $ReadMoreTextColor . '!important; |
| 222 |
border-color: ' . $ReadMoreBgColor . '!important; |
| 223 |
}'; |
| 224 |
} |
| 225 |
$customCSS = !empty($attributes['customCSS']) ? $attributes['customCSS'] : ''; |
| 226 |
|
| 227 |
|
| 228 |
$row_gap = isset($attributes['rowGap']) && !empty($attributes['rowGap']) ? $attributes['rowGap'] : '30px'; |
| 229 |
$row_gap = str_replace("px", "", $row_gap); |
| 230 |
$row_gap .= 'px'; |
| 231 |
if (!empty($customCSS)) { |
| 232 |
$css .= $customCSS; |
| 233 |
} |
| 234 |
$css .= ' |
| 235 |
.post-container { |
| 236 |
margin-bottom: ' . $row_gap . ' !important; |
| 237 |
}'; |
| 238 |
$css = apply_filters('apl_listing_style', $css, $attributes); |
| 239 |
$custom_css = "<style>" . $css . "</style>"; |
| 240 |
|
| 241 |
$list_items_markup = ''; |
| 242 |
$list_items_markup .= $custom_css; |
| 243 |
$list_items_markup .= '<div class="listing-layout">'; |
| 244 |
if (isset($attributes['PaginationOnToggler']) && !empty($attributes['PaginationOnToggler'])) { |
| 245 |
$args['paged'] = get_query_var('paged') ? get_query_var('paged') : 1; |
| 246 |
} |
| 247 |
$query = new WP_Query($args); |
| 248 |
|
| 249 |
|
| 250 |
if ($query->have_posts()) : |
| 251 |
while ($query->have_posts()) : $query->the_post(); |
| 252 |
$post_title = get_the_title(); |
| 253 |
$post_date = get_the_date(); |
| 254 |
$post_permalink = get_permalink(); |
| 255 |
$post_author = get_the_author(); |
| 256 |
$post_categories = get_the_category(); |
| 257 |
$category_names = array(); |
| 258 |
|
| 259 |
if (empty($post_categories)) { |
| 260 |
$taxonomies = get_object_taxonomies(get_post(), 'names'); |
| 261 |
foreach ($taxonomies as $taxonomy) { |
| 262 |
$terms = get_the_terms(get_the_ID(), $taxonomy); |
| 263 |
if ($terms && !is_wp_error($terms)) { |
| 264 |
foreach ($terms as $term) { |
| 265 |
$category_names[] = $term->name; |
| 266 |
} |
| 267 |
} |
| 268 |
} |
| 269 |
} else { |
| 270 |
foreach ($post_categories as $category) { |
| 271 |
$category_names[] = $category->name; |
| 272 |
} |
| 273 |
} |
| 274 |
|
| 275 |
$category_list = implode(', ', $category_names); |
| 276 |
$list_items_markup .= '<div class="post-container">'; |
| 277 |
$image_url = get_the_post_thumbnail_url(get_the_ID(), 'large'); |
| 278 |
if (!empty($image_url)) { |
| 279 |
|
| 280 |
if (isset($attributes['showImgToggler']) && $attributes['showImgToggler'] == 1) { |
| 281 |
if (isset($attributes['imageUrl'])) { |
| 282 |
$image_url = get_the_post_thumbnail_url(get_the_ID(), 'large'); |
| 283 |
|
| 284 |
if (empty($attributes['selectedImageTogggler']) && empty($attributes['widthPercentageState'])) { |
| 285 |
$custom_width = isset($attributes['ImgWidth']) ? $attributes['ImgWidth'] : ''; |
| 286 |
$custom_height = isset($attributes['height']) ? $attributes['height'] : ''; |
| 287 |
} elseif (isset($attributes['widthPercentageState']) && $attributes['widthPercentageState'] == true && empty($attributes['selectedImageTogggler'])) { |
| 288 |
$custom_width = $attributes['widthPercentage']; |
| 289 |
$custom_height = $attributes['widthPercentage']; |
| 290 |
} |
| 291 |
} |
| 292 |
$list_items_markup .= ' <div class="image-container">'; |
| 293 |
if (!empty($custom_width) && !empty($custom_height)) { |
| 294 |
if(wp_is_mobile()){ |
| 295 |
$list_items_markup .= '<img class="block-image" src="' . esc_url($image_url) . '" >'; |
| 296 |
}else{ |
| 297 |
$list_items_markup .= '<img class="block-image" src="' . esc_url($image_url) . '" style="max-width: ' . esc_attr($custom_width) . '; max-height: ' . esc_attr($custom_height) . ';">'; |
| 298 |
} |
| 299 |
|
| 300 |
} else { |
| 301 |
$list_items_markup .= '<img class="block-image" src="' . esc_url($image_url) . '">'; |
| 302 |
} |
| 303 |
$list_items_markup .= ' </div>'; |
| 304 |
} |
| 305 |
} |
| 306 |
|
| 307 |
if (isset($attributes['showPostTitle']) && $attributes['showPostTitle'] == 1) { |
| 308 |
$list_items_markup .= ' <div class="post-title" '; |
| 309 |
if ($title_Manage_styling === 'true') { |
| 310 |
$list_items_markup .= ' style="font-size:' . esc_html($title_font_size) . '"'; |
| 311 |
} |
| 312 |
$list_items_markup .= '>'; |
| 313 |
$list_items_markup .= '<a href="' . esc_url($post_permalink) . '" class="title">' . esc_html($post_title) . '</a>'; |
| 314 |
$list_items_markup .= ' </div>'; |
| 315 |
} |
| 316 |
|
| 317 |
if (isset($attributes['showMeta']) && $attributes['showMeta'] == 1) { |
| 318 |
$list_items_markup .= ' <div class="meta-data" '; |
| 319 |
if ($Meta_Manage_styling === 'true') { |
| 320 |
$list_items_markup .= ' style="font-size:' . esc_html($Meta_font_size) . '"'; |
| 321 |
} |
| 322 |
$list_items_markup .= '>'; |
| 323 |
$list_items_markup .= '<p>' . esc_html($post_date) . ' | Author: ' . esc_html($post_author) . ' | Categories: ' . esc_html($category_list) . '</p>'; |
| 324 |
$list_items_markup .= ' </div>'; |
| 325 |
} |
| 326 |
|
| 327 |
if (isset($attributes['showContent']) && $attributes['showContent'] == 1) { |
| 328 |
if (isset($attributes['contentType'])) { |
| 329 |
if ($attributes['contentType'] == 'Excerpt') { |
| 330 |
$words_limit = isset($attributes['wordsLimit']) ? intval($attributes['wordsLimit']) : 100; |
| 331 |
$excerpt = get_the_excerpt(); |
| 332 |
$words = explode(' ', $excerpt); |
| 333 |
$post_content = implode(' ', array_slice($words, 0, $words_limit)); |
| 334 |
} elseif ($attributes['contentType'] == 'Full-Post') { |
| 335 |
$post_content = get_the_content(); |
| 336 |
} |
| 337 |
} |
| 338 |
$list_items_markup .= ' <div class="post-content"'; |
| 339 |
if ($Content_Manage_styling === 'true') { |
| 340 |
$list_items_markup .= ' style="font-size: ' . esc_html($Content_font_size) . ';"'; |
| 341 |
} |
| 342 |
$list_items_markup .= ' ><p>'; |
| 343 |
$list_items_markup .= apply_filters('adv_post_content', $post_content); |
| 344 |
$list_items_markup .= ' </p></div>'; |
| 345 |
} |
| 346 |
|
| 347 |
$list_items_markup .= ' <div class="read-more-btn">'; |
| 348 |
$list_items_markup .= ' <a target="_blank" href="' . esc_url($post_permalink) . '" class="read-more-button"'; |
| 349 |
$Read_more_font_size = !empty($attributes['Read_more_font_size']) ? $attributes['Read_more_font_size'] : '1rem'; |
| 350 |
|
| 351 |
if ($showReadMoreToggler === 'true') { |
| 352 |
|
| 353 |
$list_items_markup .= ' style="font-size:' . esc_html($Read_more_font_size) . '"'; |
| 354 |
} |
| 355 |
$ReadMoreText = !empty($attributes['ReadMoreText']) ? $attributes['ReadMoreText'] : 'Read More'; |
| 356 |
$list_items_markup .= '>' . $ReadMoreText . '</a>'; |
| 357 |
$list_items_markup .= ' </div>'; |
| 358 |
$list_items_markup .= '</div>'; |
| 359 |
|
| 360 |
endwhile; |
| 361 |
|
| 362 |
// Pagination |
| 363 |
|
| 364 |
wp_reset_postdata(); |
| 365 |
|
| 366 |
endif; |
| 367 |
|
| 368 |
$list_items_markup .= '</div>'; |
| 369 |
|
| 370 |
if (isset($attributes['PaginationOnToggler']) && !empty($attributes['PaginationOnToggler'])) { |
| 371 |
$pagination_args = array( |
| 372 |
'total' => $query->max_num_pages, |
| 373 |
'current' => $args['paged'], |
| 374 |
'mid_size' => 2, |
| 375 |
'prev_text' => isset($attributes['prevName']) ? __($attributes['prevName']) : __('Prev'), |
| 376 |
'next_text' => isset($attributes['nextName']) ? __($attributes['nextName']) : __('Next'), |
| 377 |
'type' => 'array', |
| 378 |
); |
| 379 |
|
| 380 |
$pagination_links = paginate_links($pagination_args); |
| 381 |
|
| 382 |
if ($pagination_links) { |
| 383 |
$alignment_class = isset($attributes['paginationAline']) ? $attributes['paginationAline'] : 'center'; |
| 384 |
$list_items_markup .= '<nav class="pagination wep-pagination ' . esc_attr($alignment_class) . '">'; |
| 385 |
|
| 386 |
// Output the pagination links |
| 387 |
foreach ($pagination_links as $link) { |
| 388 |
$list_items_markup .= str_replace( |
| 389 |
array('<a', '</a>', 'page-numbers'), |
| 390 |
array('<a class="page-numbers"', '</a>', 'page-numbers'), |
| 391 |
$link |
| 392 |
); |
| 393 |
} |
| 394 |
|
| 395 |
$list_items_markup .= '</nav>'; |
| 396 |
} |
| 397 |
} |
| 398 |
|
| 399 |
return $list_items_markup; |
| 400 |
} |
| 401 |
|
| 402 |
|
| 403 |
function aplb_listing_layout_two($args, $attributes) |
| 404 |
{ |
| 405 |
|
| 406 |
|
| 407 |
$title_Manage_styling = !empty($attributes['title_Manage_styling']) ? 'true' : 'false'; |
| 408 |
$title_font_size = !empty($attributes['title_font_size']) ? $attributes['title_font_size'] : '1.5rem'; |
| 409 |
|
| 410 |
$Meta_Manage_styling = !empty($attributes['Meta_Manage_styling']) ? 'true' : 'false'; |
| 411 |
$Meta_font_size = !empty($attributes['Meta_font_size']) ? $attributes['Meta_font_size'] : '0.875rem'; |
| 412 |
|
| 413 |
$Content_Manage_styling = !empty($attributes['Content_Manage_styling']) ? 'true' : 'false'; |
| 414 |
$Content_font_size = !empty($attributes['Content_font_size']) ? $attributes['Content_font_size'] : '1.5rem'; |
| 415 |
|
| 416 |
|
| 417 |
$showReadMoreToggler = !empty($attributes['showReadMoreToggler']) ? 'true' : 'false'; |
| 418 |
$css = ''; |
| 419 |
|
| 420 |
if ($showReadMoreToggler === 'true') { |
| 421 |
$button_Top_bottom_Padding = !empty($attributes['button_Top_bottom_Padding']) ? $attributes['button_Top_bottom_Padding'] : '8px'; |
| 422 |
$button_Right_Left_Padding = !empty($attributes['button_Right_Left_Padding']) ? $attributes['button_Right_Left_Padding'] : '16px'; |
| 423 |
$ReadMoreTextColor = !empty($attributes['ReadMoreTextColor']) ? $attributes['ReadMoreTextColor'] : '#FFFFFF'; |
| 424 |
$ReadMoreBgColor = !empty($attributes['ReadMoreBgColor']) ? $attributes['ReadMoreBgColor'] : '#000000'; |
| 425 |
|
| 426 |
$css .= ' |
| 427 |
.wep-btn { |
| 428 |
background-color: ' . $ReadMoreBgColor . '!important; |
| 429 |
color: ' . $ReadMoreTextColor . ' !important; |
| 430 |
padding: ' . $button_Top_bottom_Padding . ' ' . $button_Right_Left_Padding . ' !important; |
| 431 |
} |
| 432 |
.pagination .page-numbers:hover, .pagination .page-numbers.current { |
| 433 |
background-color:' . $ReadMoreBgColor . '!important; |
| 434 |
color: ' . $ReadMoreTextColor . '!important; |
| 435 |
border-color: ' . $ReadMoreBgColor . '!important; |
| 436 |
}'; |
| 437 |
} |
| 438 |
$customCSS = !empty($attributes['customCSS']) ? $attributes['customCSS'] : ''; |
| 439 |
|
| 440 |
|
| 441 |
$row_gap = isset($attributes['rowGap']) && !empty($attributes['rowGap']) ? $attributes['rowGap'] : '30px'; |
| 442 |
$row_gap = str_replace("px", "", $row_gap); |
| 443 |
$row_gap .= 'px'; |
| 444 |
if (!empty($customCSS)) { |
| 445 |
$css .= $customCSS; |
| 446 |
} |
| 447 |
$css .= ' |
| 448 |
.wep-card-text { |
| 449 |
margin-bottom: ' . $row_gap . ' !important; |
| 450 |
} |
| 451 |
.listing-layout { |
| 452 |
gap: ' . $row_gap . ' !important; |
| 453 |
}'; |
| 454 |
$css = apply_filters('apl_listing_style', $css, $attributes); |
| 455 |
$custom_css = "<style>" . $css . "</style>"; |
| 456 |
|
| 457 |
$list_items_markup = ''; |
| 458 |
$list_items_markup .= $custom_css; |
| 459 |
$list_items_markup .= '<div class="wep-root"><div class="listing-layout" style="gap: 30px;">'; |
| 460 |
if (isset($attributes['PaginationOnToggler']) && !empty($attributes['PaginationOnToggler'])) { |
| 461 |
$args['paged'] = get_query_var('paged') ? get_query_var('paged') : 1; |
| 462 |
} |
| 463 |
$query = new WP_Query($args); |
| 464 |
|
| 465 |
|
| 466 |
if ($query->have_posts()) : |
| 467 |
while ($query->have_posts()) : $query->the_post(); |
| 468 |
$post_title = get_the_title(); |
| 469 |
$post_date = get_the_date(); |
| 470 |
$post_permalink = get_permalink(); |
| 471 |
$post_author = get_the_author(); |
| 472 |
$post_categories = get_the_category(); |
| 473 |
$category_names = array(); |
| 474 |
|
| 475 |
if (empty($post_categories)) { |
| 476 |
$taxonomies = get_object_taxonomies(get_post(), 'names'); |
| 477 |
foreach ($taxonomies as $taxonomy) { |
| 478 |
$terms = get_the_terms(get_the_ID(), $taxonomy); |
| 479 |
if ($terms && !is_wp_error($terms)) { |
| 480 |
foreach ($terms as $term) { |
| 481 |
$category_names[] = $term->name; |
| 482 |
} |
| 483 |
} |
| 484 |
} |
| 485 |
} else { |
| 486 |
foreach ($post_categories as $category) { |
| 487 |
$category_names[] = $category->name; |
| 488 |
} |
| 489 |
} |
| 490 |
|
| 491 |
$category_list = implode(', ', $category_names); |
| 492 |
$list_items_markup .= '<div class="wep-card wep-card-horizontal">'; |
| 493 |
$image_url = get_the_post_thumbnail_url(get_the_ID(), 'large'); |
| 494 |
if (!empty($image_url)) { |
| 495 |
|
| 496 |
if (isset($attributes['showImgToggler']) && $attributes['showImgToggler'] == 1) { |
| 497 |
if (isset($attributes['imageUrl'])) { |
| 498 |
$image_url = get_the_post_thumbnail_url(get_the_ID(), 'large'); |
| 499 |
|
| 500 |
if (empty($attributes['selectedImageTogggler']) && empty($attributes['widthPercentageState'])) { |
| 501 |
$custom_width = isset($attributes['ImgWidth']) ? $attributes['ImgWidth'] : ''; |
| 502 |
$custom_height = isset($attributes['height']) ? $attributes['height'] : ''; |
| 503 |
} elseif (isset($attributes['widthPercentageState']) && $attributes['widthPercentageState'] == true && empty($attributes['selectedImageTogggler'])) { |
| 504 |
$custom_width = $attributes['widthPercentage']; |
| 505 |
$custom_height = $attributes['widthPercentage']; |
| 506 |
} |
| 507 |
} |
| 508 |
$list_items_markup .= ' <div class="wep-card-img">'; |
| 509 |
if (!empty($custom_width) && !empty($custom_height)) { |
| 510 |
$list_items_markup .= '<img src="' . esc_url($image_url) . '" style="max-width: ' . esc_attr($custom_width) . '; max-height: ' . esc_attr($custom_height) . ';">'; |
| 511 |
} else { |
| 512 |
$list_items_markup .= '<img src="' . esc_url($image_url) . '">'; |
| 513 |
} |
| 514 |
$list_items_markup .= ' </div>'; |
| 515 |
} |
| 516 |
} |
| 517 |
$list_items_markup .= '<div class="wep-card-body"><div class="wep-card-heading">'; |
| 518 |
if (isset($attributes['showPostTitle']) && $attributes['showPostTitle'] == 1) { |
| 519 |
$list_items_markup .= ' <h4 class="wep-card-title" '; |
| 520 |
if ($title_Manage_styling === 'true') { |
| 521 |
$list_items_markup .= ' style="font-size:' . esc_html($title_font_size) . '"'; |
| 522 |
} |
| 523 |
$list_items_markup .= '>'; |
| 524 |
$list_items_markup .= '<a href="' . esc_url($post_permalink) . '" >' . esc_html($post_title) . '</a>'; |
| 525 |
$list_items_markup .= ' </h4>'; |
| 526 |
} |
| 527 |
|
| 528 |
if (isset($attributes['showMeta']) && $attributes['showMeta'] == 1) { |
| 529 |
$list_items_markup .= ' <div class="meta-data" '; |
| 530 |
if ($Meta_Manage_styling === 'true') { |
| 531 |
$list_items_markup .= ' style="font-size:' . esc_html($Meta_font_size) . '"'; |
| 532 |
} |
| 533 |
$list_items_markup .= '>'; |
| 534 |
$list_items_markup .= esc_html($post_date) . ' | Author: ' . esc_html($post_author) . ' | Categories: ' . esc_html($category_list); |
| 535 |
$list_items_markup .= ' </div>'; |
| 536 |
} |
| 537 |
$list_items_markup .= '</div>'; |
| 538 |
if (isset($attributes['showContent']) && $attributes['showContent'] == 1) { |
| 539 |
if (isset($attributes['contentType'])) { |
| 540 |
if ($attributes['contentType'] == 'Excerpt') { |
| 541 |
$words_limit = isset($attributes['wordsLimit']) ? intval($attributes['wordsLimit']) : 100; |
| 542 |
$excerpt = get_the_excerpt(); |
| 543 |
$words = explode(' ', $excerpt); |
| 544 |
$post_content = implode(' ', array_slice($words, 0, $words_limit)); |
| 545 |
} elseif ($attributes['contentType'] == 'Full-Post') { |
| 546 |
$post_content = get_the_content(); |
| 547 |
} |
| 548 |
} |
| 549 |
$list_items_markup .= ' <div class="wep-card-text"'; |
| 550 |
if ($Content_Manage_styling === 'true') { |
| 551 |
$list_items_markup .= ' style="font-size: ' . esc_html($Content_font_size) . ';"'; |
| 552 |
} |
| 553 |
$list_items_markup .= ' ><p>'; |
| 554 |
$list_items_markup .= apply_filters('adv_post_content', $post_content); |
| 555 |
$list_items_markup .= ' </p></div>'; |
| 556 |
} |
| 557 |
$list_items_markup .= '</div>'; |
| 558 |
|
| 559 |
$list_items_markup .= ' <div class="wep-card-footer">'; |
| 560 |
$list_items_markup .= ' <a target="_blank" href="' . esc_url($post_permalink) . '" class="wep-btn wep-btn-primary"'; |
| 561 |
$Read_more_font_size = !empty($attributes['Read_more_font_size']) ? $attributes['Read_more_font_size'] : '1rem'; |
| 562 |
|
| 563 |
if ($showReadMoreToggler === 'true') { |
| 564 |
|
| 565 |
$list_items_markup .= ' style="font-size:' . esc_html($Read_more_font_size) . '"'; |
| 566 |
} |
| 567 |
$ReadMoreText = !empty($attributes['ReadMoreText']) ? $attributes['ReadMoreText'] : 'Read More'; |
| 568 |
$list_items_markup .= '>' . $ReadMoreText . '</a>'; |
| 569 |
$list_items_markup .= ' </div>'; |
| 570 |
$list_items_markup .= '</div>'; |
| 571 |
|
| 572 |
endwhile; |
| 573 |
|
| 574 |
// Pagination |
| 575 |
|
| 576 |
wp_reset_postdata(); |
| 577 |
|
| 578 |
endif; |
| 579 |
|
| 580 |
$list_items_markup .= '</div></div>'; |
| 581 |
|
| 582 |
if (isset($attributes['PaginationOnToggler']) && !empty($attributes['PaginationOnToggler'])) { |
| 583 |
$pagination_args = array( |
| 584 |
'total' => $query->max_num_pages, |
| 585 |
'current' => $args['paged'], |
| 586 |
'mid_size' => 2, |
| 587 |
'prev_text' => isset($attributes['prevName']) ? __($attributes['prevName']) : __('Prev'), |
| 588 |
'next_text' => isset($attributes['nextName']) ? __($attributes['nextName']) : __('Next'), |
| 589 |
'type' => 'array', |
| 590 |
); |
| 591 |
|
| 592 |
$pagination_links = paginate_links($pagination_args); |
| 593 |
|
| 594 |
if ($pagination_links) { |
| 595 |
$alignment_class = isset($attributes['paginationAline']) ? $attributes['paginationAline'] : 'center'; |
| 596 |
$list_items_markup .= '<nav class="pagination wep-pagination ' . esc_attr($alignment_class) . '">'; |
| 597 |
|
| 598 |
// Output the pagination links |
| 599 |
foreach ($pagination_links as $link) { |
| 600 |
$list_items_markup .= str_replace( |
| 601 |
array('<a', '</a>', 'page-numbers'), |
| 602 |
array('<a class="page-numbers"', '</a>', 'page-numbers'), |
| 603 |
$link |
| 604 |
); |
| 605 |
} |
| 606 |
|
| 607 |
$list_items_markup .= '</nav>'; |
| 608 |
} |
| 609 |
} |
| 610 |
|
| 611 |
return $list_items_markup; |
| 612 |
} |
| 613 |
|
| 614 |
function aplb_grid_layout($args, $attributes) |
| 615 |
{ |
| 616 |
|
| 617 |
$title_Manage_styling = !empty($attributes['title_Manage_styling']) ? 'true' : 'false'; |
| 618 |
$title_font_size = !empty($attributes['title_font_size']) ? $attributes['title_font_size'] : '1.5rem'; |
| 619 |
|
| 620 |
$Meta_Manage_styling = !empty($attributes['Meta_Manage_styling']) ? 'true' : 'false'; |
| 621 |
$Meta_font_size = !empty($attributes['Meta_font_size']) ? $attributes['Meta_font_size'] : '8px'; |
| 622 |
|
| 623 |
$Content_Manage_styling = !empty($attributes['Content_Manage_styling']) ? 'true' : 'false'; |
| 624 |
$Content_font_size = !empty($attributes['Content_font_size']) ? $attributes['Content_font_size'] : '8px'; |
| 625 |
|
| 626 |
$Read_more_font_size = !empty($attributes['Read_more_font_size']) ? $attributes['Read_more_font_size'] : '1rem'; |
| 627 |
|
| 628 |
$showReadMoreToggler = !empty($attributes['showReadMoreToggler']) ? 'true' : 'false'; |
| 629 |
$css = ''; |
| 630 |
|
| 631 |
if ($showReadMoreToggler === 'true') { |
| 632 |
$button_Top_bottom_Padding = !empty($attributes['button_Top_bottom_Padding']) ? $attributes['button_Top_bottom_Padding'] : '8px'; |
| 633 |
$button_Right_Left_Padding = !empty($attributes['button_Right_Left_Padding']) ? $attributes['button_Right_Left_Padding'] : '16px'; |
| 634 |
$ReadMoreTextColor = !empty($attributes['ReadMoreTextColor']) ? $attributes['ReadMoreTextColor'] : '#FFFFFF'; |
| 635 |
$ReadMoreBgColor = !empty($attributes['ReadMoreBgColor']) ? $attributes['ReadMoreBgColor'] : '#000000'; |
| 636 |
|
| 637 |
$css .= ' |
| 638 |
|
| 639 |
.grid-layout .wep-btn { |
| 640 |
padding: ' . $button_Top_bottom_Padding . ' ' . $button_Right_Left_Padding . ' !important; |
| 641 |
background-color:' . $ReadMoreBgColor . '!important; |
| 642 |
color: ' . $ReadMoreTextColor . '!important; |
| 643 |
} |
| 644 |
.pagination .page-numbers:hover, .pagination .page-numbers.current { |
| 645 |
background-color:' . $ReadMoreBgColor . '!important; |
| 646 |
color: ' . $ReadMoreTextColor . '!important; |
| 647 |
border-color: ' . $ReadMoreBgColor . '!important; |
| 648 |
} |
| 649 |
|
| 650 |
'; |
| 651 |
} |
| 652 |
|
| 653 |
|
| 654 |
$columns = !empty($attributes['totalColoms']) ? $attributes['totalColoms'] : 3; |
| 655 |
$column_gap = isset($attributes['columnGap']) && !empty($attributes['columnGap']) ? $attributes['columnGap'] : '20px'; |
| 656 |
$row_gap = isset($attributes['rowGap']) && !empty($attributes['rowGap']) ? $attributes['rowGap'] : '30px'; |
| 657 |
$row_gap = str_replace("px", "", $row_gap); |
| 658 |
$row_gap .= 'px'; |
| 659 |
$column_gap = str_replace("px", "", $column_gap); |
| 660 |
$column_gap .= 'px'; |
| 661 |
|
| 662 |
$customCSS = !empty($attributes['customCSS']) ? $attributes['customCSS'] : ''; |
| 663 |
if (!empty($customCSS)) { |
| 664 |
$css .= $customCSS; |
| 665 |
} |
| 666 |
|
| 667 |
|
| 668 |
$css .= ' |
| 669 |
.grid-layout { |
| 670 |
gap: ' . $row_gap . ' ' . $column_gap . ' !important; |
| 671 |
} |
| 672 |
|
| 673 |
@media (min-width: 992px) { |
| 674 |
.grid-layout { |
| 675 |
grid-template-columns: repeat(' . $columns . ', 1fr) !important; |
| 676 |
} |
| 677 |
} |
| 678 |
|
| 679 |
/* For very large screens */ |
| 680 |
@media (min-width: 1200px) { |
| 681 |
.grid-layout { |
| 682 |
grid-template-columns: repeat(' . $columns . ', 1fr) !important; |
| 683 |
} |
| 684 |
} |
| 685 |
'; |
| 686 |
|
| 687 |
|
| 688 |
|
| 689 |
$css = apply_filters('apl_grid_style', $css, $attributes); |
| 690 |
$custom_css = "<style>" . $css . "</style>"; |
| 691 |
|
| 692 |
$list_items_markup = ''; |
| 693 |
$list_items_markup .= $custom_css; |
| 694 |
$list_items_markup .= '<div class="wep-root" ><div class="grid-layout" >'; |
| 695 |
if (isset($attributes['PaginationOnToggler']) && !empty($attributes['PaginationOnToggler'])) { |
| 696 |
$args['paged'] = get_query_var('paged') ? get_query_var('paged') : 1; |
| 697 |
} |
| 698 |
$query = new WP_Query($args); |
| 699 |
|
| 700 |
if ($query->have_posts()) : |
| 701 |
while ($query->have_posts()) : $query->the_post(); |
| 702 |
$post_title = get_the_title(); |
| 703 |
$post_date = get_the_date(); |
| 704 |
$post_permalink = get_permalink(); |
| 705 |
$post_author = get_the_author(); |
| 706 |
$post_categories = get_the_category(); |
| 707 |
$category_names = array(); |
| 708 |
|
| 709 |
if (empty($post_categories)) { |
| 710 |
$taxonomies = get_object_taxonomies(get_post(), 'names'); |
| 711 |
foreach ($taxonomies as $taxonomy) { |
| 712 |
$terms = get_the_terms(get_the_ID(), $taxonomy); |
| 713 |
if ($terms && !is_wp_error($terms)) { |
| 714 |
foreach ($terms as $term) { |
| 715 |
$category_names[] = $term->name; |
| 716 |
} |
| 717 |
} |
| 718 |
} |
| 719 |
} else { |
| 720 |
foreach ($post_categories as $category) { |
| 721 |
$category_names[] = $category->name; |
| 722 |
} |
| 723 |
} |
| 724 |
|
| 725 |
$category_list = implode(', ', $category_names); |
| 726 |
$list_items_markup .= '<div class="wep-card">'; |
| 727 |
if (isset($attributes['showImgToggler']) && $attributes['showImgToggler'] == 1) { |
| 728 |
if (isset($attributes['imageUrl'])) { |
| 729 |
$image_url = get_the_post_thumbnail_url(get_the_ID(), 'medium'); |
| 730 |
|
| 731 |
if (empty($attributes['selectedImageTogggler']) && empty($attributes['widthPercentageState'])) { |
| 732 |
$custom_width = isset($attributes['ImgWidth']) ? $attributes['ImgWidth'] : ''; |
| 733 |
$custom_height = isset($attributes['height']) ? $attributes['height'] : ''; |
| 734 |
} elseif (isset($attributes['widthPercentageState']) && $attributes['widthPercentageState'] == true && empty($attributes['selectedImageTogggler'])) { |
| 735 |
$custom_width = $attributes['widthPercentage']; |
| 736 |
$custom_height = $attributes['widthPercentage']; |
| 737 |
} |
| 738 |
} |
| 739 |
if (isset($image_url) && !empty($image_url)) { |
| 740 |
$list_items_markup .= ' <div class="wep-card-img">'; |
| 741 |
if (!empty($custom_width) && !empty($custom_height)) { |
| 742 |
$list_items_markup .= '<img src="' . esc_url($image_url) . '">'; |
| 743 |
} else { |
| 744 |
$list_items_markup .= '<img src="' . esc_url($image_url) . '">'; |
| 745 |
} |
| 746 |
$list_items_markup .= ' <span class="wep-chip">' . esc_html($category_list) . '</span>'; |
| 747 |
$list_items_markup .= ' </div>'; |
| 748 |
} |
| 749 |
} |
| 750 |
|
| 751 |
$list_items_markup .= '<div class="wep-card-body"><div class="wep-card-heading">'; |
| 752 |
if (isset($attributes['showPostTitle']) && $attributes['showPostTitle'] == 1) { |
| 753 |
$list_items_markup .= ' <h4 class="wep-card-title" '; |
| 754 |
if ($title_Manage_styling === 'true') { |
| 755 |
$list_items_markup .= ' style="font-size:' . esc_html($title_font_size) . '"'; |
| 756 |
} |
| 757 |
$list_items_markup .= '>'; |
| 758 |
$list_items_markup .= ' <a href="' . esc_url($post_permalink) . '">' . esc_html($post_title) . '</a>'; |
| 759 |
$list_items_markup .= ' </h4>'; |
| 760 |
} |
| 761 |
|
| 762 |
if (isset($attributes['showMeta']) && $attributes['showMeta'] == 1) { |
| 763 |
$list_items_markup .= ' <div class="meta-data" '; |
| 764 |
if ($Meta_Manage_styling === 'true') { |
| 765 |
$list_items_markup .= ' style="font-size:' . esc_html($Meta_font_size) . '"'; |
| 766 |
} |
| 767 |
$list_items_markup .= '>'; |
| 768 |
$list_items_markup .= '<p>' . esc_html($post_date) . ' | Author: ' . esc_html($post_author) . '</p>'; |
| 769 |
$list_items_markup .= ' </div>'; |
| 770 |
} |
| 771 |
$list_items_markup .= '</div>'; |
| 772 |
if (isset($attributes['showContent']) && $attributes['showContent'] == 1) { |
| 773 |
if (isset($attributes['contentType'])) { |
| 774 |
if ($attributes['contentType'] == 'Excerpt') { |
| 775 |
$words_limit = isset($attributes['wordsLimit']) ? intval($attributes['wordsLimit']) : 100; |
| 776 |
$excerpt = get_the_excerpt(); |
| 777 |
$words = explode(' ', $excerpt); |
| 778 |
$post_content = implode(' ', array_slice($words, 0, $words_limit)); |
| 779 |
} elseif ($attributes['contentType'] == 'Full-Post') { |
| 780 |
$post_content = get_the_content(); |
| 781 |
} |
| 782 |
} |
| 783 |
$list_items_markup .= ' <div class="wep-card-text"'; |
| 784 |
if ($Content_Manage_styling === 'true') { |
| 785 |
$list_items_markup .= ' style="font-size: ' . esc_html($Content_font_size) . ';"'; |
| 786 |
} |
| 787 |
$list_items_markup .= ' ><p>'; |
| 788 |
$list_items_markup .= apply_filters('adv_post_content', $post_content); |
| 789 |
$list_items_markup .= ' </p></div>'; |
| 790 |
} |
| 791 |
$list_items_markup .= '</div>'; |
| 792 |
|
| 793 |
$list_items_markup .= ' <div class="wep-card-footer">'; |
| 794 |
$list_items_markup .= ' <a target="_blank" href="' . esc_url($post_permalink) . '" class="wep-btn wep-btn-primary"'; |
| 795 |
if ($showReadMoreToggler === 'true') { |
| 796 |
$list_items_markup .= ' style="font-size:' . esc_html($Read_more_font_size) . '"'; |
| 797 |
} |
| 798 |
$ReadMoreText = !empty($attributes['ReadMoreText']) ? $attributes['ReadMoreText'] : 'Read More'; |
| 799 |
$list_items_markup .= '>' . $ReadMoreText . '</a>'; |
| 800 |
$list_items_markup .= ' </div>'; |
| 801 |
$list_items_markup .= '</div>'; |
| 802 |
|
| 803 |
endwhile; |
| 804 |
|
| 805 |
|
| 806 |
wp_reset_postdata(); |
| 807 |
|
| 808 |
endif; |
| 809 |
|
| 810 |
$list_items_markup .= '</div></div>'; |
| 811 |
if (isset($attributes['PaginationOnToggler']) && !empty($attributes['PaginationOnToggler'])) { |
| 812 |
$pagination_args = array( |
| 813 |
'total' => $query->max_num_pages, |
| 814 |
'current' => $args['paged'], |
| 815 |
'mid_size' => 2, |
| 816 |
'prev_text' => isset($attributes['prevName']) ? __($attributes['prevName']) : __('Prev'), |
| 817 |
'next_text' => isset($attributes['nextName']) ? __($attributes['nextName']) : __('Next'), |
| 818 |
'type' => 'array', |
| 819 |
); |
| 820 |
|
| 821 |
$pagination_links = paginate_links($pagination_args); |
| 822 |
if ($pagination_links) { |
| 823 |
$alignment_class = isset($attributes['paginationAline']) ? $attributes['paginationAline'] : 'center'; |
| 824 |
$list_items_markup .= '<nav class="pagination wep-pagination ' . esc_attr($alignment_class) . '">'; |
| 825 |
|
| 826 |
// Output the pagination links |
| 827 |
foreach ($pagination_links as $link) { |
| 828 |
$list_items_markup .= str_replace( |
| 829 |
array('<a', '</a>', 'page-numbers'), |
| 830 |
array('<a class="page-numbers"', '</a>', 'page-numbers'), |
| 831 |
$link |
| 832 |
); |
| 833 |
} |
| 834 |
|
| 835 |
$list_items_markup .= '</nav>'; |
| 836 |
} |
| 837 |
} |
| 838 |
return $list_items_markup; |
| 839 |
} |
| 840 |
|
| 841 |
function aplb_overlay_layout($args, $attributes) |
| 842 |
{ |
| 843 |
|
| 844 |
$title_Manage_styling = !empty($attributes['title_Manage_styling']) ? 'true' : 'false'; |
| 845 |
$title_font_size = !empty($attributes['title_font_size']) ? $attributes['title_font_size'] : '1.5rem'; |
| 846 |
|
| 847 |
$Meta_Manage_styling = !empty($attributes['Meta_Manage_styling']) ? 'true' : 'false'; |
| 848 |
$Meta_font_size = !empty($attributes['Meta_font_size']) ? $attributes['Meta_font_size'] : '8px'; |
| 849 |
|
| 850 |
$Content_Manage_styling = !empty($attributes['Content_Manage_styling']) ? 'true' : 'false'; |
| 851 |
$Content_font_size = !empty($attributes['Content_font_size']) ? $attributes['Content_font_size'] : '8px'; |
| 852 |
|
| 853 |
$Read_more_font_size = !empty($attributes['Read_more_font_size']) ? $attributes['Read_more_font_size'] : '1rem'; |
| 854 |
|
| 855 |
$showReadMoreToggler = !empty($attributes['showReadMoreToggler']) ? 'true' : 'false'; |
| 856 |
$css = ''; |
| 857 |
|
| 858 |
if ($showReadMoreToggler === 'true') { |
| 859 |
$button_Top_bottom_Padding = !empty($attributes['button_Top_bottom_Padding']) ? $attributes['button_Top_bottom_Padding'] : '8px'; |
| 860 |
$button_Right_Left_Padding = !empty($attributes['button_Right_Left_Padding']) ? $attributes['button_Right_Left_Padding'] : '16px'; |
| 861 |
$ReadMoreTextColor = !empty($attributes['ReadMoreTextColor']) ? $attributes['ReadMoreTextColor'] : '#FFFFFF'; |
| 862 |
$ReadMoreBgColor = !empty($attributes['ReadMoreBgColor']) ? $attributes['ReadMoreBgColor'] : '#000000'; |
| 863 |
|
| 864 |
$css .= ' |
| 865 |
.overlay-layout .wep-btn { |
| 866 |
padding: ' . $button_Top_bottom_Padding . ' ' . $button_Right_Left_Padding . ' !important; |
| 867 |
|
| 868 |
background-color:' . $ReadMoreBgColor . '!important; |
| 869 |
color: ' . $ReadMoreTextColor . '!important; |
| 870 |
|
| 871 |
} |
| 872 |
.pagination .page-numbers:hover, .pagination .page-numbers.current { |
| 873 |
background-color:' . $ReadMoreBgColor . '!important; |
| 874 |
color: ' . $ReadMoreTextColor . '!important; |
| 875 |
border-color:' . $ReadMoreBgColor . '!important; |
| 876 |
} |
| 877 |
'; |
| 878 |
} |
| 879 |
|
| 880 |
|
| 881 |
$columns = !empty($attributes['totalColoms']) ? $attributes['totalColoms'] : 3; |
| 882 |
$width_percentage = 100 / $columns; |
| 883 |
$column_gap = isset($attributes['columnGap']) && !empty($attributes['columnGap']) ? $attributes['columnGap'] : '20px'; |
| 884 |
$row_gap = isset($attributes['rowGap']) && !empty($attributes['rowGap']) ? $attributes['rowGap'] : '30px'; |
| 885 |
$row_gap = str_replace("px", "", $row_gap); |
| 886 |
$row_gap .= 'px'; |
| 887 |
$column_gap = str_replace("px", "", $column_gap); |
| 888 |
$column_gap .= 'px'; |
| 889 |
$customCSS = !empty($attributes['customCSS']) ? $attributes['customCSS'] : ''; |
| 890 |
if (!empty($customCSS)) { |
| 891 |
$css .= $customCSS; |
| 892 |
} |
| 893 |
|
| 894 |
if( wp_is_mobile()){ |
| 895 |
$css .= ' |
| 896 |
.overlay-layout{ |
| 897 |
gap: ' . $row_gap . ' ' . $column_gap . ' !important; |
| 898 |
grid-template-columns: repeat(1, 1fr); |
| 899 |
}'; |
| 900 |
}else{ |
| 901 |
$css .= ' |
| 902 |
.overlay-layout{ |
| 903 |
gap: ' . $row_gap . ' ' . $column_gap . ' !important; |
| 904 |
grid-template-columns: repeat('.$attributes["totalColoms"].', 1fr); |
| 905 |
}'; |
| 906 |
} |
| 907 |
|
| 908 |
|
| 909 |
$css = apply_filters('wpl_overlay_style', $css, $attributes); |
| 910 |
$custom_css = "<style>" . $css . "</style>"; |
| 911 |
|
| 912 |
|
| 913 |
$list_items_markup = ''; |
| 914 |
$list_items_markup .= $custom_css; |
| 915 |
|
| 916 |
$list_items_markup .= '<div class="wep-root"><div class="overlay-layout">'; |
| 917 |
if (isset($attributes['PaginationOnToggler']) && !empty($attributes['PaginationOnToggler'])) { |
| 918 |
$args['paged'] = get_query_var('paged') ? get_query_var('paged') : 1; |
| 919 |
} |
| 920 |
|
| 921 |
$query = new WP_Query($args); |
| 922 |
|
| 923 |
if ($query->have_posts()) : |
| 924 |
while ($query->have_posts()) : $query->the_post(); |
| 925 |
$post_title = get_the_title(); |
| 926 |
$post_date = get_the_date(); |
| 927 |
$post_permalink = get_permalink(); |
| 928 |
$post_author = get_the_author(); |
| 929 |
$post_categories = get_the_category(); |
| 930 |
$category_names = array(); |
| 931 |
|
| 932 |
if (empty($post_categories)) { |
| 933 |
$taxonomies = get_object_taxonomies(get_post(), 'names'); |
| 934 |
foreach ($taxonomies as $taxonomy) { |
| 935 |
$terms = get_the_terms(get_the_ID(), $taxonomy); |
| 936 |
if ($terms && !is_wp_error($terms)) { |
| 937 |
foreach ($terms as $term) { |
| 938 |
$category_names[] = $term->name; |
| 939 |
} |
| 940 |
} |
| 941 |
} |
| 942 |
} else { |
| 943 |
foreach ($post_categories as $category) { |
| 944 |
$category_names[] = $category->name; |
| 945 |
} |
| 946 |
} |
| 947 |
|
| 948 |
$category_list = implode(', ', $category_names); |
| 949 |
if (isset($attributes['showImgToggler']) && $attributes['showImgToggler'] == 1) { |
| 950 |
if (isset($attributes['imageUrl'])) { |
| 951 |
$image_url = get_the_post_thumbnail_url(get_the_ID(), 'medium'); |
| 952 |
|
| 953 |
if (empty($attributes['selectedImageTogggler']) && empty($attributes['widthPercentageState'])) { |
| 954 |
$custom_width = isset($attributes['ImgWidth']) ? $attributes['ImgWidth'] : ''; |
| 955 |
$custom_height = isset($attributes['height']) ? $attributes['height'] : ''; |
| 956 |
} elseif (isset($attributes['widthPercentageState']) && $attributes['widthPercentageState'] == true && empty($attributes['selectedImageTogggler'])) { |
| 957 |
$custom_width = $attributes['widthPercentage']; |
| 958 |
$custom_height = $attributes['widthPercentage']; |
| 959 |
} |
| 960 |
} |
| 961 |
if (!empty($custom_width) && !empty($custom_height)) { |
| 962 |
$list_items_markup .= ' <div class="wep-card" style = "background-image:url(' . esc_url($image_url) . ');background-repeat: no-repeat; |
| 963 |
background-size: cover;">'; |
| 964 |
} else { |
| 965 |
$list_items_markup .= ' <div class="wep-card" style = "background-image:url(' . esc_url($image_url) . ');background-repeat: no-repeat; background-size: cover;">'; |
| 966 |
} |
| 967 |
$list_items_markup .= ' <div class="wep-card-img-overlay">'; |
| 968 |
$list_items_markup .= ' <div class="wep-card-body"><div class="wep-card-heading">'; |
| 969 |
} |
| 970 |
|
| 971 |
if (isset($attributes['showPostTitle']) && $attributes['showPostTitle'] == 1) { |
| 972 |
$list_items_markup .= ' <h4 class="wep-card-title" '; |
| 973 |
if ($title_Manage_styling === 'true') { |
| 974 |
$list_items_markup .= ' style="font-size:' . esc_html($title_font_size) . '"'; |
| 975 |
} |
| 976 |
$list_items_markup .= '>'; |
| 977 |
$list_items_markup .= '<a href="' . esc_url($post_permalink) . '" class="title">' . esc_html($post_title) . '</a>'; |
| 978 |
$list_items_markup .= ' </h4>'; |
| 979 |
} |
| 980 |
|
| 981 |
if (isset($attributes['showMeta']) && $attributes['showMeta'] == 1) { |
| 982 |
$list_items_markup .= ' <div class="meta-data" '; |
| 983 |
if ($Meta_Manage_styling === 'true') { |
| 984 |
$list_items_markup .= ' style="font-size:' . esc_html($Meta_font_size) . '"'; |
| 985 |
} |
| 986 |
$list_items_markup .= '>'; |
| 987 |
$list_items_markup .= '<p>' . esc_html($post_date) . ' | Author: ' . esc_html($post_author) . ' | Categories: ' . esc_html($category_list) . '</p>'; |
| 988 |
$list_items_markup .= ' </div>'; |
| 989 |
} |
| 990 |
$list_items_markup .= ' </div>'; |
| 991 |
if (isset($attributes['showContent']) && $attributes['showContent'] == 1) { |
| 992 |
if (isset($attributes['contentType'])) { |
| 993 |
if ($attributes['contentType'] == 'Excerpt') { |
| 994 |
$words_limit = isset($attributes['wordsLimit']) ? intval($attributes['wordsLimit']) : 100; |
| 995 |
$excerpt = get_the_excerpt(); |
| 996 |
$words = explode(' ', $excerpt); |
| 997 |
$post_content = implode(' ', array_slice($words, 0, $words_limit)) . '...'; |
| 998 |
} elseif ($attributes['contentType'] == 'Full-Post') { |
| 999 |
$post_content = get_the_content(); |
| 1000 |
} |
| 1001 |
} |
| 1002 |
$list_items_markup .= ' <div class="wep-card-text"'; |
| 1003 |
if ($Content_Manage_styling === 'true') { |
| 1004 |
$list_items_markup .= ' style="font-size: ' . esc_html($Content_font_size) . ';"'; |
| 1005 |
} |
| 1006 |
$list_items_markup .= ' ><p>'; |
| 1007 |
$list_items_markup .= apply_filters('adv_post_content', $post_content); |
| 1008 |
$list_items_markup .= ' </p></div>'; |
| 1009 |
} |
| 1010 |
$list_items_markup .= '</div>'; |
| 1011 |
$list_items_markup .= ' <div class="wep-card-footer">'; |
| 1012 |
$list_items_markup .= ' <a target="_blank" href="' . esc_url($post_permalink) . '" class="wep-btn wep-btn-primary"'; |
| 1013 |
if ($showReadMoreToggler === 'true') { |
| 1014 |
$list_items_markup .= ' style="font-size:' . esc_html($Read_more_font_size) . '"'; |
| 1015 |
} |
| 1016 |
$ReadMoreText = !empty($attributes['ReadMoreText']) ? $attributes['ReadMoreText'] : 'Read More'; |
| 1017 |
$list_items_markup .= '>' . $ReadMoreText . '</a>'; |
| 1018 |
$list_items_markup .= ' </div>'; |
| 1019 |
$list_items_markup .= ' </div>'; |
| 1020 |
$list_items_markup .= ' </div>'; |
| 1021 |
|
| 1022 |
endwhile; |
| 1023 |
wp_reset_postdata(); |
| 1024 |
|
| 1025 |
endif; |
| 1026 |
|
| 1027 |
$list_items_markup .= '</div></div>'; |
| 1028 |
|
| 1029 |
if (isset($attributes['PaginationOnToggler']) && !empty($attributes['PaginationOnToggler'])) { |
| 1030 |
|
| 1031 |
$pagination_args = array( |
| 1032 |
'total' => $query->max_num_pages, |
| 1033 |
'current' => $args['paged'], |
| 1034 |
'mid_size' => 2, |
| 1035 |
'prev_text' => isset($attributes['prevName']) ? __($attributes['prevName']) : __('Prev'), |
| 1036 |
'next_text' => isset($attributes['nextName']) ? __($attributes['nextName']) : __('Next'), |
| 1037 |
'type' => 'array', |
| 1038 |
); |
| 1039 |
|
| 1040 |
$pagination_links = paginate_links($pagination_args); |
| 1041 |
|
| 1042 |
if ($pagination_links) { |
| 1043 |
$alignment_class = isset($attributes['paginationAline']) ? $attributes['paginationAline'] : 'center'; |
| 1044 |
$list_items_markup .= '<nav class="pagination wep-pagination ' . esc_attr($alignment_class) . '">'; |
| 1045 |
|
| 1046 |
// Output the pagination links |
| 1047 |
foreach ($pagination_links as $link) { |
| 1048 |
$list_items_markup .= str_replace( |
| 1049 |
array('<a', '</a>', 'page-numbers'), |
| 1050 |
array('<a class="page-numbers"', '</a>', 'page-numbers'), |
| 1051 |
$link |
| 1052 |
); |
| 1053 |
} |
| 1054 |
|
| 1055 |
$list_items_markup .= '</nav>'; |
| 1056 |
} |
| 1057 |
} |
| 1058 |
|
| 1059 |
return $list_items_markup; |
| 1060 |
} |
| 1061 |
|
| 1062 |
function aplb_slider_layout($args, $attributes) |
| 1063 |
{ |
| 1064 |
|
| 1065 |
$title_Manage_styling = !empty($attributes['title_Manage_styling']) ? 'true' : 'false'; |
| 1066 |
$title_font_size = !empty($attributes['title_font_size']) ? $attributes['title_font_size'] : '1.5rem'; |
| 1067 |
|
| 1068 |
$Meta_Manage_styling = !empty($attributes['Meta_Manage_styling']) ? 'true' : 'false'; |
| 1069 |
$Meta_font_size = !empty($attributes['Meta_font_size']) ? $attributes['Meta_font_size'] : '8px'; |
| 1070 |
|
| 1071 |
$Content_Manage_styling = !empty($attributes['Content_Manage_styling']) ? 'true' : 'false'; |
| 1072 |
$Content_font_size = !empty($attributes['Content_font_size']) ? $attributes['Content_font_size'] : '8px'; |
| 1073 |
|
| 1074 |
$Read_more_font_size = !empty($attributes['Read_more_font_size']) ? $attributes['Read_more_font_size'] : '1rem'; |
| 1075 |
|
| 1076 |
$showReadMoreToggler = !empty($attributes['showReadMoreToggler']) ? 'true' : 'false'; |
| 1077 |
$css = ''; |
| 1078 |
|
| 1079 |
if ($showReadMoreToggler === 'true') { |
| 1080 |
$button_Top_bottom_Padding = !empty($attributes['button_Top_bottom_Padding']) ? $attributes['button_Top_bottom_Padding'] : '8px'; |
| 1081 |
$button_Right_Left_Padding = !empty($attributes['button_Right_Left_Padding']) ? $attributes['button_Right_Left_Padding'] : '16px'; |
| 1082 |
$ReadMoreTextColor = !empty($attributes['ReadMoreTextColor']) ? $attributes['ReadMoreTextColor'] : '#FFFFFF'; |
| 1083 |
$ReadMoreBgColor = !empty($attributes['ReadMoreBgColor']) ? $attributes['ReadMoreBgColor'] : '#000000'; |
| 1084 |
$css .= ' |
| 1085 |
.slider-container .wep-btn { |
| 1086 |
padding: ' . $button_Top_bottom_Padding . ' ' . $button_Right_Left_Padding . ' !important; |
| 1087 |
|
| 1088 |
background-color:' . $ReadMoreBgColor . '!important; |
| 1089 |
color: ' . $ReadMoreTextColor . '!important; |
| 1090 |
|
| 1091 |
} |
| 1092 |
'; |
| 1093 |
} |
| 1094 |
$customCSS = !empty($attributes['customCSS']) ? $attributes['customCSS'] : ''; |
| 1095 |
|
| 1096 |
if (!empty($customCSS)) { |
| 1097 |
$css .= $customCSS; |
| 1098 |
} |
| 1099 |
|
| 1100 |
$css = apply_filters('apl_slider_style', $css, $attributes); |
| 1101 |
$custom_css = "<style>" . $css . "</style>"; |
| 1102 |
$list_items_markup = ''; |
| 1103 |
$list_items_markup .= $custom_css; |
| 1104 |
$list_items_markup .= '<div class="wep-root"><div class="slider-container">'; |
| 1105 |
$list_items_markup .= '<div class="slider">'; |
| 1106 |
$query = new WP_Query($args); |
| 1107 |
if ($query->have_posts()) : |
| 1108 |
while ($query->have_posts()) : $query->the_post(); |
| 1109 |
$post_title = get_the_title(); |
| 1110 |
$post_date = get_the_date(); |
| 1111 |
$post_permalink = get_permalink(); |
| 1112 |
$post_author = get_the_author(); |
| 1113 |
$post_categories = get_the_category(); |
| 1114 |
$category_names = array(); |
| 1115 |
$image_url = get_the_post_thumbnail_url(get_the_ID(), 'large'); |
| 1116 |
if (empty($post_categories)) { |
| 1117 |
$taxonomies = get_object_taxonomies(get_post(), 'names'); |
| 1118 |
foreach ($taxonomies as $taxonomy) { |
| 1119 |
$terms = get_the_terms(get_the_ID(), $taxonomy); |
| 1120 |
if ($terms && !is_wp_error($terms)) { |
| 1121 |
foreach ($terms as $term) { |
| 1122 |
$category_names[] = $term->name; |
| 1123 |
} |
| 1124 |
} |
| 1125 |
} |
| 1126 |
} else { |
| 1127 |
foreach ($post_categories as $category) { |
| 1128 |
$category_names[] = $category->name; |
| 1129 |
} |
| 1130 |
} |
| 1131 |
|
| 1132 |
$category_list = implode(', ', $category_names); |
| 1133 |
$list_items_markup .= '<div class="slide">'; |
| 1134 |
$list_items_markup .= '<div class="wep-card">'; |
| 1135 |
if (isset($attributes['showImgToggler']) && $attributes['showImgToggler'] == 1) { |
| 1136 |
if ($image_url) { |
| 1137 |
|
| 1138 |
if (isset($attributes['imageUrl'])) { |
| 1139 |
$image_url = get_the_post_thumbnail_url(get_the_ID(), 'large'); |
| 1140 |
|
| 1141 |
if (empty($attributes['selectedImageTogggler']) && empty($attributes['widthPercentageState'])) { |
| 1142 |
$custom_width = isset($attributes['ImgWidth']) ? $attributes['ImgWidth'] : ''; |
| 1143 |
$custom_height = isset($attributes['height']) ? $attributes['height'] : ''; |
| 1144 |
} elseif (isset($attributes['widthPercentageState']) && $attributes['widthPercentageState'] == true && empty($attributes['selectedImageTogggler'])) { |
| 1145 |
$custom_width = $attributes['widthPercentage']; |
| 1146 |
$custom_height = $attributes['widthPercentage']; |
| 1147 |
} |
| 1148 |
$list_items_markup .= ' <div class="wep-card-img">'; |
| 1149 |
if (!empty($custom_width) && !empty($custom_height)) { |
| 1150 |
$list_items_markup .= '<img src="' . esc_url($image_url) . '">'; |
| 1151 |
} else { |
| 1152 |
$list_items_markup .= '<img src="' . esc_url($image_url) . '">'; |
| 1153 |
} |
| 1154 |
$list_items_markup .= ' </div>'; |
| 1155 |
} |
| 1156 |
} |
| 1157 |
} |
| 1158 |
|
| 1159 |
$list_items_markup .= '<div class="wep-card-body"><div class="wep-card-heading">'; |
| 1160 |
if (isset($attributes['showPostTitle']) && $attributes['showPostTitle'] == 1) { |
| 1161 |
$list_items_markup .= ' <h4 class="wep-card-title" '; |
| 1162 |
if ($title_Manage_styling === 'true') { |
| 1163 |
$list_items_markup .= ' style="font-size:' . esc_html($title_font_size) . '"'; |
| 1164 |
} |
| 1165 |
$list_items_markup .= '>'; |
| 1166 |
$list_items_markup .= '<a href="' . esc_url($post_permalink) . '">' . esc_html($post_title) . '</a>'; |
| 1167 |
$list_items_markup .= ' </h4>'; |
| 1168 |
} |
| 1169 |
|
| 1170 |
if (isset($attributes['showMeta']) && $attributes['showMeta'] == 1) { |
| 1171 |
$list_items_markup .= ' <div class="meta-data" '; |
| 1172 |
if ($Meta_Manage_styling === 'true') { |
| 1173 |
$list_items_markup .= ' style="font-size:' . esc_html($Meta_font_size) . '"'; |
| 1174 |
} |
| 1175 |
$list_items_markup .= '>'; |
| 1176 |
$list_items_markup .= '<p>' . esc_html($post_date) . ' | Author: ' . esc_html($post_author) . ' | Categories: ' . esc_html($category_list) . '</p>'; |
| 1177 |
$list_items_markup .= ' </div>'; |
| 1178 |
} |
| 1179 |
|
| 1180 |
$list_items_markup .= '</div>'; |
| 1181 |
if (isset($attributes['showContent']) && $attributes['showContent'] == 1) { |
| 1182 |
if (isset($attributes['contentType'])) { |
| 1183 |
if ($attributes['contentType'] == 'Excerpt') { |
| 1184 |
$words_limit = isset($attributes['wordsLimit']) ? intval($attributes['wordsLimit']) : 100; |
| 1185 |
$excerpt = get_the_excerpt(); |
| 1186 |
$words = explode(' ', $excerpt); |
| 1187 |
$post_content = implode(' ', array_slice($words, 0, $words_limit)); |
| 1188 |
} elseif ($attributes['contentType'] == 'Full-Post') { |
| 1189 |
$post_content = get_the_content(); |
| 1190 |
} |
| 1191 |
} |
| 1192 |
$list_items_markup .= ' <div class="wep-card-text"'; |
| 1193 |
if ($Content_Manage_styling === 'true') { |
| 1194 |
$list_items_markup .= ' style="font-size: ' . esc_html($Content_font_size) . ';"'; |
| 1195 |
} |
| 1196 |
$list_items_markup .= ' ><p>'; |
| 1197 |
$list_items_markup .= apply_filters('adv_post_content', $post_content); |
| 1198 |
$list_items_markup .= ' </p></div>'; |
| 1199 |
} |
| 1200 |
$list_items_markup .= '</div>'; |
| 1201 |
|
| 1202 |
$list_items_markup .= ' <div class="wep-card-footer">'; |
| 1203 |
$list_items_markup .= ' <a target="_blank" href="' . esc_url($post_permalink) . '" class="wep-btn wep-btn-primary"'; |
| 1204 |
if ($showReadMoreToggler === 'true') { |
| 1205 |
$list_items_markup .= ' style="font-size:' . esc_html($Read_more_font_size) . '"'; |
| 1206 |
} |
| 1207 |
$ReadMoreText = !empty($attributes['ReadMoreText']) ? $attributes['ReadMoreText'] : 'Read More'; |
| 1208 |
$list_items_markup .= '>' . $ReadMoreText . '</a>'; |
| 1209 |
$list_items_markup .= ' </div>'; |
| 1210 |
$list_items_markup .= '</div>'; |
| 1211 |
$list_items_markup .= '</div>'; |
| 1212 |
endwhile; |
| 1213 |
wp_reset_postdata(); |
| 1214 |
|
| 1215 |
endif; |
| 1216 |
|
| 1217 |
$list_items_markup .= '</div>'; |
| 1218 |
$list_items_markup .= ' <button class="slider-button prev">❮</button>'; |
| 1219 |
$list_items_markup .= ' <button class="slider-button next">❯</button>'; |
| 1220 |
$list_items_markup .= '</div>'; |
| 1221 |
$list_items_markup .= '</div></div>'; |
| 1222 |
|
| 1223 |
$js = "document.addEventListener('DOMContentLoaded', function() { |
| 1224 |
let currentIndex = 0; |
| 1225 |
const slides = document.querySelectorAll('.slide'); |
| 1226 |
|
| 1227 |
function showSlide(index) { |
| 1228 |
slides.forEach((slide, i) => { |
| 1229 |
slide.style.display = i === index ? 'block' : 'none'; |
| 1230 |
}); |
| 1231 |
} |
| 1232 |
|
| 1233 |
function nextSlide() { |
| 1234 |
currentIndex = (currentIndex + 1) % slides.length; |
| 1235 |
showSlide(currentIndex); |
| 1236 |
} |
| 1237 |
|
| 1238 |
function prevSlide() { |
| 1239 |
currentIndex = (currentIndex - 1 + slides.length) % slides.length; |
| 1240 |
showSlide(currentIndex); |
| 1241 |
} |
| 1242 |
|
| 1243 |
document.querySelector('.next').addEventListener('click', nextSlide); |
| 1244 |
document.querySelector('.prev').addEventListener('click', prevSlide); |
| 1245 |
|
| 1246 |
setInterval(nextSlide, 3000); |
| 1247 |
|
| 1248 |
showSlide(currentIndex); |
| 1249 |
});"; |
| 1250 |
|
| 1251 |
$js = apply_filters('apl_slider_script', $js, $attributes); |
| 1252 |
$custom_js = "<script>" . $js . "</script>"; |
| 1253 |
$list_items_markup .= $custom_js; |
| 1254 |
|
| 1255 |
|
| 1256 |
return $list_items_markup; |
| 1257 |
} |
| 1258 |
|
| 1259 |
function aplb_masonry_layout($args, $attributes) |
| 1260 |
{ |
| 1261 |
|
| 1262 |
$title_Manage_styling = !empty($attributes['title_Manage_styling']) ? 'true' : 'false'; |
| 1263 |
$title_font_size = !empty($attributes['title_font_size']) ? $attributes['title_font_size'] : '1.5rem'; |
| 1264 |
|
| 1265 |
$Meta_Manage_styling = !empty($attributes['Meta_Manage_styling']) ? 'true' : 'false'; |
| 1266 |
$Meta_font_size = !empty($attributes['Meta_font_size']) ? $attributes['Meta_font_size'] : '8px'; |
| 1267 |
|
| 1268 |
$Content_Manage_styling = !empty($attributes['Content_Manage_styling']) ? 'true' : 'false'; |
| 1269 |
$Content_font_size = !empty($attributes['Content_font_size']) ? $attributes['Content_font_size'] : '8px'; |
| 1270 |
|
| 1271 |
$Read_more_font_size = !empty($attributes['Read_more_font_size']) ? $attributes['Read_more_font_size'] : '1rem'; |
| 1272 |
|
| 1273 |
$showReadMoreToggler = !empty($attributes['showReadMoreToggler']) ? 'true' : 'false'; |
| 1274 |
$css = ''; |
| 1275 |
|
| 1276 |
if ($showReadMoreToggler === 'true') { |
| 1277 |
$button_Top_bottom_Padding = !empty($attributes['button_Top_bottom_Padding']) ? $attributes['button_Top_bottom_Padding'] : '8px'; |
| 1278 |
$button_Right_Left_Padding = !empty($attributes['button_Right_Left_Padding']) ? $attributes['button_Right_Left_Padding'] : '16px'; |
| 1279 |
$ReadMoreTextColor = !empty($attributes['ReadMoreTextColor']) ? $attributes['ReadMoreTextColor'] : '#FFFFFF'; |
| 1280 |
$ReadMoreBgColor = !empty($attributes['ReadMoreBgColor']) ? $attributes['ReadMoreBgColor'] : '#000000'; |
| 1281 |
|
| 1282 |
$css .= ' |
| 1283 |
.masonry-layout .wep-btn { |
| 1284 |
padding: ' . $button_Top_bottom_Padding . ' ' . $button_Right_Left_Padding . ' !important; |
| 1285 |
|
| 1286 |
background-color:' . $ReadMoreBgColor . '!important; |
| 1287 |
color: ' . $ReadMoreTextColor . '!important ; |
| 1288 |
|
| 1289 |
} |
| 1290 |
.pagination .page-numbers:hover, .pagination .page-numbers.current { |
| 1291 |
background-color:' . $ReadMoreBgColor . '!important; |
| 1292 |
color: ' . $ReadMoreTextColor . '!important; |
| 1293 |
border-color: ' . $ReadMoreBgColor . '!important; |
| 1294 |
} |
| 1295 |
|
| 1296 |
'; |
| 1297 |
} |
| 1298 |
|
| 1299 |
$customCSS = !empty($attributes['customCSS']) ? $attributes['customCSS'] : ''; |
| 1300 |
|
| 1301 |
$columns = !empty($attributes['totalColoms']) ? $attributes['totalColoms'] : 3; |
| 1302 |
$column_gap = isset($attributes['columnGap']) && !empty($attributes['columnGap']) ? $attributes['columnGap'] : '20px'; |
| 1303 |
$row_gap = isset($attributes['rowGap']) && !empty($attributes['rowGap']) ? $attributes['rowGap'] : '30px'; |
| 1304 |
$row_gap = str_replace("px", "", $row_gap); |
| 1305 |
$row_gap .= 'px'; |
| 1306 |
$column_gap = str_replace("px", "", $column_gap); |
| 1307 |
$column_gap .= 'px'; |
| 1308 |
if (!empty($customCSS)) { |
| 1309 |
$css .= $customCSS; |
| 1310 |
} |
| 1311 |
|
| 1312 |
if( wp_is_mobile()){ |
| 1313 |
$css .= '.masonry-layout { |
| 1314 |
column-gap: ' . $column_gap . ' !important; |
| 1315 |
column-count: 1; |
| 1316 |
}'; |
| 1317 |
}else{ |
| 1318 |
$css .= '.masonry-layout { |
| 1319 |
column-gap: ' . $column_gap . ' !important; |
| 1320 |
column-count: '.$attributes["totalColoms"].'; |
| 1321 |
}'; |
| 1322 |
} |
| 1323 |
|
| 1324 |
$css .= ' |
| 1325 |
.masonry-layout .wep-card-text { |
| 1326 |
margin-bottom: ' . $row_gap . ' !important; |
| 1327 |
} |
| 1328 |
@media (min-width: 992px) { |
| 1329 |
.masonry-layout { |
| 1330 |
column-count: ' . $columns . ' !important; |
| 1331 |
} |
| 1332 |
} |
| 1333 |
|
| 1334 |
.pagination{ |
| 1335 |
margin-top: ' . $row_gap . ' !important; |
| 1336 |
} |
| 1337 |
/* Extra large screens (large desktops, 1200px and up) */ |
| 1338 |
@media (min-width: 1200px) { |
| 1339 |
.masonry-layout { |
| 1340 |
column-count: ' . $columns . ' !important; |
| 1341 |
} |
| 1342 |
} |
| 1343 |
|
| 1344 |
'; |
| 1345 |
|
| 1346 |
$css = apply_filters('apl_masanory_style', $css, $attributes); |
| 1347 |
$custom_css = "<style> " . $css . " </style>"; |
| 1348 |
$list_items_markup = ''; |
| 1349 |
$list_items_markup .= $custom_css; |
| 1350 |
$list_items_markup .= '<div class="wep-root" ><div class="masonry-layout">'; |
| 1351 |
if (isset($attributes['PaginationOnToggler']) && !empty($attributes['PaginationOnToggler'])) { |
| 1352 |
$args['paged'] = get_query_var('paged') ? get_query_var('paged') : 1; |
| 1353 |
} |
| 1354 |
$query = new WP_Query($args); |
| 1355 |
|
| 1356 |
if ($query->have_posts()) : |
| 1357 |
while ($query->have_posts()) : $query->the_post(); |
| 1358 |
$post_title = get_the_title(); |
| 1359 |
$post_date = get_the_date(); |
| 1360 |
$post_permalink = get_permalink(); |
| 1361 |
$post_author = get_the_author(); |
| 1362 |
$post_categories = get_the_category(); |
| 1363 |
$category_names = array(); |
| 1364 |
|
| 1365 |
if (empty($post_categories)) { |
| 1366 |
$taxonomies = get_object_taxonomies(get_post(), 'names'); |
| 1367 |
foreach ($taxonomies as $taxonomy) { |
| 1368 |
$terms = get_the_terms(get_the_ID(), $taxonomy); |
| 1369 |
if ($terms && !is_wp_error($terms)) { |
| 1370 |
foreach ($terms as $term) { |
| 1371 |
$category_names[] = $term->name; |
| 1372 |
} |
| 1373 |
} |
| 1374 |
} |
| 1375 |
} else { |
| 1376 |
foreach ($post_categories as $category) { |
| 1377 |
$category_names[] = $category->name; |
| 1378 |
} |
| 1379 |
} |
| 1380 |
|
| 1381 |
$category_list = implode(', ', $category_names); |
| 1382 |
$list_items_markup .= '<div class="wep-card" style="margin-bottom: 30px;">'; |
| 1383 |
$image_url = get_the_post_thumbnail_url(get_the_ID(), 'medium'); |
| 1384 |
if (!empty($image_url)) { |
| 1385 |
if (isset($attributes['showImgToggler']) && $attributes['showImgToggler'] == 1) { |
| 1386 |
if (isset($attributes['imageUrl'])) { |
| 1387 |
$image_url = get_the_post_thumbnail_url(get_the_ID(), 'medium'); |
| 1388 |
|
| 1389 |
if (empty($attributes['selectedImageTogggler']) && empty($attributes['widthPercentageState'])) { |
| 1390 |
$custom_width = isset($attributes['ImgWidth']) ? $attributes['ImgWidth'] : ''; |
| 1391 |
$custom_height = isset($attributes['height']) ? $attributes['height'] : ''; |
| 1392 |
} elseif (isset($attributes['widthPercentageState']) && $attributes['widthPercentageState'] == true && empty($attributes['selectedImageTogggler'])) { |
| 1393 |
$custom_width = $attributes['widthPercentage']; |
| 1394 |
$custom_height = $attributes['widthPercentage']; |
| 1395 |
} |
| 1396 |
} |
| 1397 |
$list_items_markup .= ' <div class="wep-card-img">'; |
| 1398 |
if (!empty($custom_width) && !empty($custom_height)) { |
| 1399 |
$list_items_markup .= '<img src="' . esc_url($image_url) . '">'; |
| 1400 |
} else { |
| 1401 |
$list_items_markup .= '<img src="' . esc_url($image_url) . '">'; |
| 1402 |
} |
| 1403 |
$list_items_markup .= '<span class="wep-chip">'.$category_list.'</span> </div>'; |
| 1404 |
} |
| 1405 |
} |
| 1406 |
$list_items_markup .= '<div class="wep-card-body"><div class="wep-card-heading">'; |
| 1407 |
if (isset($attributes['showPostTitle']) && $attributes['showPostTitle'] == 1) { |
| 1408 |
$list_items_markup .= ' <h4 class="wep-card-title" '; |
| 1409 |
if ($title_Manage_styling === 'true') { |
| 1410 |
$list_items_markup .= ' style="font-size:' . esc_html($title_font_size) . '"'; |
| 1411 |
} |
| 1412 |
$list_items_markup .= '>'; |
| 1413 |
$list_items_markup .= '<a href="' . esc_url($post_permalink) . '" >' . esc_html($post_title) . '</a>'; |
| 1414 |
$list_items_markup .= ' </h4>'; |
| 1415 |
} |
| 1416 |
|
| 1417 |
|
| 1418 |
if (isset($attributes['showMeta']) && $attributes['showMeta'] == 1) { |
| 1419 |
$list_items_markup .= ' <div class="meta-data" '; |
| 1420 |
if ($Meta_Manage_styling === 'true') { |
| 1421 |
$list_items_markup .= ' style="font-size:' . esc_html($Meta_font_size) . '"'; |
| 1422 |
} |
| 1423 |
$list_items_markup .= '>'; |
| 1424 |
$list_items_markup .= '<p>' . esc_html($post_date) . ' | Author: ' . esc_html($post_author) . ' | Categories: ' . esc_html($category_list) . '</p>'; |
| 1425 |
$list_items_markup .= ' </div>'; |
| 1426 |
} |
| 1427 |
$list_items_markup .= '</div>'; |
| 1428 |
if (isset($attributes['showContent']) && $attributes['showContent'] == 1) { |
| 1429 |
if (isset($attributes['contentType'])) { |
| 1430 |
if ($attributes['contentType'] == 'Excerpt') { |
| 1431 |
$words_limit = isset($attributes['wordsLimit']) ? intval($attributes['wordsLimit']) : 100; |
| 1432 |
$excerpt = get_the_excerpt(); |
| 1433 |
$words = explode(' ', $excerpt); |
| 1434 |
$post_content = implode(' ', array_slice($words, 0, $words_limit)); |
| 1435 |
} elseif ($attributes['contentType'] == 'Full-Post') { |
| 1436 |
$post_content = get_the_content(); |
| 1437 |
} |
| 1438 |
} |
| 1439 |
$list_items_markup .= ' <div class="wep-card-text"'; |
| 1440 |
if ($Content_Manage_styling === 'true') { |
| 1441 |
$list_items_markup .= ' style="font-size: ' . esc_html($Content_font_size) . ';"'; |
| 1442 |
} |
| 1443 |
$list_items_markup .= ' ><p>'; |
| 1444 |
$list_items_markup .= apply_filters('adv_post_content', $post_content); |
| 1445 |
$list_items_markup .= ' </p></div>'; |
| 1446 |
} |
| 1447 |
$list_items_markup .= '</div>'; |
| 1448 |
|
| 1449 |
$list_items_markup .= ' <div class="wep-card-footer">'; |
| 1450 |
$list_items_markup .= ' <a target="_blank" class="wep-btn wep-btn-primary" href="' . esc_url($post_permalink) . '"'; |
| 1451 |
if ($showReadMoreToggler === 'true') { |
| 1452 |
$list_items_markup .= ' style="font-size:' . esc_html($Read_more_font_size) . '"'; |
| 1453 |
} |
| 1454 |
$ReadMoreText = !empty($attributes['ReadMoreText']) ? $attributes['ReadMoreText'] : 'Read More'; |
| 1455 |
$list_items_markup .= '>' . $ReadMoreText . '</a>'; |
| 1456 |
$list_items_markup .= ' </div>'; |
| 1457 |
$list_items_markup .= '</div>'; |
| 1458 |
|
| 1459 |
endwhile; |
| 1460 |
wp_reset_postdata(); |
| 1461 |
|
| 1462 |
endif; |
| 1463 |
|
| 1464 |
$list_items_markup .= '</div></div>'; |
| 1465 |
if (isset($attributes['PaginationOnToggler']) && !empty($attributes['PaginationOnToggler'])) { |
| 1466 |
|
| 1467 |
$pagination_args = array( |
| 1468 |
'total' => $query->max_num_pages, |
| 1469 |
'current' => $args['paged'], |
| 1470 |
'mid_size' => 2, |
| 1471 |
'prev_text' => isset($attributes['prevName']) ? __($attributes['prevName']) : __('Prev'), |
| 1472 |
'next_text' => isset($attributes['nextName']) ? __($attributes['nextName']) : __('Next'), |
| 1473 |
'type' => 'array', |
| 1474 |
); |
| 1475 |
|
| 1476 |
$pagination_links = paginate_links($pagination_args); |
| 1477 |
|
| 1478 |
if ($pagination_links) { |
| 1479 |
$alignment_class = isset($attributes['paginationAline']) ? $attributes['paginationAline'] : 'center'; |
| 1480 |
$list_items_markup .= '<nav class="pagination wep-pagination ' . esc_attr($alignment_class) . '">'; |
| 1481 |
|
| 1482 |
// Output the pagination links |
| 1483 |
foreach ($pagination_links as $link) { |
| 1484 |
$list_items_markup .= str_replace( |
| 1485 |
array('<a', '</a>', 'page-numbers'), |
| 1486 |
array('<a class="page-numbers"', '</a>', 'page-numbers'), |
| 1487 |
$link |
| 1488 |
); |
| 1489 |
} |
| 1490 |
|
| 1491 |
$list_items_markup .= '</nav>'; |
| 1492 |
} |
| 1493 |
} |
| 1494 |
|
| 1495 |
return $list_items_markup; |
| 1496 |
} |
| 1497 |
|
| 1498 |
function aplb_register_custom_endpoints() |
| 1499 |
{ |
| 1500 |
register_rest_route( |
| 1501 |
'wpppro/v1', |
| 1502 |
'/list-cpt/', |
| 1503 |
array( |
| 1504 |
'methods' => 'GET', |
| 1505 |
'callback' => array($this, 'aplb_get_custom_post_types_and_tax'), |
| 1506 |
'permission_callback' => '__return_true', |
| 1507 |
) |
| 1508 |
); |
| 1509 |
|
| 1510 |
register_rest_route( |
| 1511 |
'wpppro/v1', |
| 1512 |
'/get-post-by-id/', |
| 1513 |
array( |
| 1514 |
'methods' => 'GET', |
| 1515 |
'callback' => array($this, 'aplb_get_posts_type_by_id'), |
| 1516 |
'permission_callback' => '__return_true', |
| 1517 |
) |
| 1518 |
); |
| 1519 |
} |
| 1520 |
|
| 1521 |
function aplb_get_posts_type_by_id($request) |
| 1522 |
{ |
| 1523 |
$id = $request['id']; |
| 1524 |
$id_array = explode(',', $id); |
| 1525 |
|
| 1526 |
$args = array( |
| 1527 |
'post_type' => 'any', |
| 1528 |
'post__in' => $id_array, |
| 1529 |
'orderby' => 'post__in', |
| 1530 |
'posts_per_page' => -1, |
| 1531 |
); |
| 1532 |
|
| 1533 |
|
| 1534 |
$query = new WP_Query($args); |
| 1535 |
|
| 1536 |
$posts_data = array(); |
| 1537 |
|
| 1538 |
if ($query->have_posts()) { |
| 1539 |
while ($query->have_posts()) { |
| 1540 |
$query->the_post(); |
| 1541 |
$post_id = get_the_ID(); |
| 1542 |
|
| 1543 |
// Prepare the post data array |
| 1544 |
$post_data = array( |
| 1545 |
'id' => $post_id, |
| 1546 |
'date' => get_the_date('c'), |
| 1547 |
'date_gmt' => get_gmt_from_date(get_the_date('Y-m-d H:i:s')), |
| 1548 |
'guid' => array('rendered' => get_the_guid()), |
| 1549 |
'modified' => get_the_modified_date('c'), |
| 1550 |
'modified_gmt' => get_gmt_from_date(get_the_modified_date('Y-m-d H:i:s')), |
| 1551 |
'slug' => get_post_field('post_name', $post_id), |
| 1552 |
'status' => get_post_status($post_id), |
| 1553 |
'type' => get_post_type($post_id), |
| 1554 |
'link' => get_permalink($post_id), |
| 1555 |
'title' => array('rendered' => get_the_title($post_id)), |
| 1556 |
'content' => array('rendered' => apply_filters('the_content', get_the_content($post_id)), 'protected' => false), |
| 1557 |
'featured_media' => get_post_thumbnail_id($post_id), |
| 1558 |
'template' => get_page_template_slug($post_id), |
| 1559 |
'meta' => get_post_meta($post_id), |
| 1560 |
'featured_image_url' => array( |
| 1561 |
'thumbnail' => get_the_post_thumbnail_url($post_id, 'thumbnail'), |
| 1562 |
'medium' => get_the_post_thumbnail_url($post_id, 'medium'), |
| 1563 |
'medium_large' => get_the_post_thumbnail_url($post_id, 'medium_large'), |
| 1564 |
'large' => get_the_post_thumbnail_url($post_id, 'large'), |
| 1565 |
'1536x1536' => get_the_post_thumbnail_url($post_id, '1536x1536'), |
| 1566 |
'2048x2048' => get_the_post_thumbnail_url($post_id, '2048x2048') |
| 1567 |
), |
| 1568 |
'post_author' => get_the_author_meta('display_name', get_post_field('post_author', $post_id)), |
| 1569 |
'assigned_categories' => wp_get_post_categories($post_id, array('fields' => 'names')), |
| 1570 |
); |
| 1571 |
|
| 1572 |
$posts_data[] = $post_data; |
| 1573 |
} |
| 1574 |
} |
| 1575 |
|
| 1576 |
wp_reset_postdata(); |
| 1577 |
|
| 1578 |
return new WP_REST_Response($posts_data, 200); |
| 1579 |
} |
| 1580 |
|
| 1581 |
|
| 1582 |
function aplb_get_custom_post_types_and_tax() |
| 1583 |
{ |
| 1584 |
$args = array('public' => true, '_builtin' => false); |
| 1585 |
|
| 1586 |
$custom_post_types = get_post_types($args, 'objects'); |
| 1587 |
|
| 1588 |
$cpt_minial_info = []; |
| 1589 |
|
| 1590 |
if ($custom_post_types) { |
| 1591 |
|
| 1592 |
foreach ($custom_post_types as $post_type) { |
| 1593 |
$cpt_minial_info[$post_type->name] = $post_type->label; |
| 1594 |
} |
| 1595 |
} |
| 1596 |
|
| 1597 |
$custom_post_types = $cpt_minial_info; |
| 1598 |
|
| 1599 |
$post_type_taxonomies = array(); |
| 1600 |
|
| 1601 |
$all_cpts = array_merge(array('post' => 'Posts', 'page' => 'Pages'), $custom_post_types); |
| 1602 |
|
| 1603 |
foreach ($all_cpts as $post_type => $postName) { |
| 1604 |
|
| 1605 |
$taxonomies = get_object_taxonomies($post_type, 'objects'); |
| 1606 |
|
| 1607 |
$taxonomy_info = array(); |
| 1608 |
|
| 1609 |
foreach ($taxonomies as $taxonomy) { |
| 1610 |
|
| 1611 |
$taxonomy_info[] = array( |
| 1612 |
'slug' => $taxonomy->name, |
| 1613 |
'label' => $taxonomy->label, |
| 1614 |
); |
| 1615 |
} |
| 1616 |
|
| 1617 |
|
| 1618 |
$post_type_taxonomies[$post_type] = $taxonomy_info; |
| 1619 |
} |
| 1620 |
|
| 1621 |
$response = array('cpt_list' => $custom_post_types, 'post_type_and_taxonomies' => $post_type_taxonomies); |
| 1622 |
|
| 1623 |
return rest_ensure_response($response); |
| 1624 |
} |
| 1625 |
|
| 1626 |
// Register REST fields for various post types |
| 1627 |
|
| 1628 |
function aplb_register_custom_rest_fields() |
| 1629 |
{ |
| 1630 |
|
| 1631 |
$post_types = get_post_types(array('public' => true, '_builtin' => false), 'names', 'and'); |
| 1632 |
$post_types = array_merge($post_types, array('post', 'page')); |
| 1633 |
|
| 1634 |
foreach ($post_types as $post_type) { |
| 1635 |
|
| 1636 |
$this->aplb_register_featured_image_rest_field($post_type); |
| 1637 |
$this->aplb_register_author_rest_field($post_type); |
| 1638 |
$this->aplb_register_assigned_categories_rest_field($post_type); |
| 1639 |
} |
| 1640 |
} |
| 1641 |
|
| 1642 |
// Register 'featured_image_url' REST field |
| 1643 |
function aplb_register_featured_image_rest_field($post_type) |
| 1644 |
{ |
| 1645 |
|
| 1646 |
register_rest_field($post_type, 'featured_image_url', array( |
| 1647 |
'get_callback' => array($this, 'aplb_get_featured_image_callback'), |
| 1648 |
'schema' => array( |
| 1649 |
'description' => esc_html__('Featured Image', 'advanced-posts-listing'), |
| 1650 |
'type' => 'string' |
| 1651 |
), |
| 1652 |
)); |
| 1653 |
} |
| 1654 |
|
| 1655 |
function aplb_get_featured_image_callback($post) |
| 1656 |
{ |
| 1657 |
|
| 1658 |
$featured_image_id = get_post_thumbnail_id($post['id']); |
| 1659 |
$image_sizes = get_intermediate_image_sizes(); |
| 1660 |
$all_sizes = array(); |
| 1661 |
|
| 1662 |
if (!empty($image_sizes)) { |
| 1663 |
foreach ($image_sizes as $size) { |
| 1664 |
$image_url = wp_get_attachment_image_src($featured_image_id, $size); |
| 1665 |
if (isset($image_url[0])) { |
| 1666 |
$all_sizes[$size] = $image_url[0]; |
| 1667 |
} |
| 1668 |
} |
| 1669 |
} |
| 1670 |
|
| 1671 |
return $all_sizes; |
| 1672 |
} |
| 1673 |
|
| 1674 |
function aplb_register_author_rest_field($post_type) |
| 1675 |
{ |
| 1676 |
|
| 1677 |
register_rest_field($post_type, 'post_author', array( |
| 1678 |
'get_callback' => array($this, 'aplb_get_author_callback'), |
| 1679 |
'schema' => array( |
| 1680 |
'description' => esc_html__('Author Name', 'advanced-posts-listing'), |
| 1681 |
'type' => 'string' |
| 1682 |
), |
| 1683 |
)); |
| 1684 |
} |
| 1685 |
|
| 1686 |
function aplb_get_author_callback($post) |
| 1687 |
{ |
| 1688 |
|
| 1689 |
$author_name = ''; |
| 1690 |
|
| 1691 |
if (isset($post['author']) && !empty($post['author'])) { |
| 1692 |
$author = get_userdata($post['author']); |
| 1693 |
|
| 1694 |
if ($author && !is_wp_error($author)) { |
| 1695 |
if ($author->first_name && $author->last_name) { |
| 1696 |
$author_name = $author->first_name . ' ' . $author->last_name; |
| 1697 |
} elseif ($author->display_name) { |
| 1698 |
$author_name = $author->display_name; |
| 1699 |
} else { |
| 1700 |
$author_name = $author->user_login; |
| 1701 |
} |
| 1702 |
} |
| 1703 |
} |
| 1704 |
|
| 1705 |
return $author_name; |
| 1706 |
} |
| 1707 |
|
| 1708 |
function aplb_register_assigned_categories_rest_field($post_type) |
| 1709 |
{ |
| 1710 |
|
| 1711 |
register_rest_field($post_type, 'assigned_categories', array( |
| 1712 |
'get_callback' => array($this, 'aplb_get_assigned_categories_callback'), |
| 1713 |
'schema' => array( |
| 1714 |
'description' => esc_html__('Assigned Categories', 'advanced-posts-listing'), |
| 1715 |
'type' => 'string' |
| 1716 |
), |
| 1717 |
)); |
| 1718 |
} |
| 1719 |
|
| 1720 |
function aplb_get_assigned_categories_callback($post) |
| 1721 |
{ |
| 1722 |
|
| 1723 |
$categories = get_the_category($post['id']); |
| 1724 |
$category_names = array(); |
| 1725 |
|
| 1726 |
if (empty($categories)) { |
| 1727 |
$post_id = $post['id']; |
| 1728 |
$post_type = $post['type']; |
| 1729 |
$taxonomies = get_object_taxonomies($post_type); |
| 1730 |
|
| 1731 |
foreach ($taxonomies as $taxonomy) { |
| 1732 |
$terms = wp_get_post_terms($post_id, $taxonomy); |
| 1733 |
if (!empty($terms)) { |
| 1734 |
foreach ($terms as $term) { |
| 1735 |
$category_names[] = $term->name; |
| 1736 |
} |
| 1737 |
} |
| 1738 |
} |
| 1739 |
$category_names = array_unique($category_names); |
| 1740 |
} else { |
| 1741 |
foreach ($categories as $category) { |
| 1742 |
$category_names[] = $category->name; |
| 1743 |
} |
| 1744 |
} |
| 1745 |
|
| 1746 |
return implode(', ', $category_names); |
| 1747 |
} |
| 1748 |
|
| 1749 |
function aplb_get_server_side_pass() |
| 1750 |
{ |
| 1751 |
wp_localize_script('advanced-posts-listing-advanced-posts-listing-block-editor-script', 'aplb_server_data', array( |
| 1752 |
'rest_url' => esc_url(get_rest_url(null)), |
| 1753 |
)); |
| 1754 |
} |
| 1755 |
} |
| 1756 |
|
| 1757 |
return new Advanced_Post_Listing_Block(); |
| 1758 |
} |
| 1759 |
|