| 1 |
<?php |
| 2 |
|
| 3 |
namespace UltimatePostKit\Modules\HazelGrid\Widgets; |
| 4 |
|
| 5 |
use Elementor\Controls_Manager; |
| 6 |
use Elementor\Group_Control_Border; |
| 7 |
use Elementor\Group_Control_Box_Shadow; |
| 8 |
use Elementor\Group_Control_Typography; |
| 9 |
use Elementor\Group_Control_Text_Shadow; |
| 10 |
use Elementor\Group_Control_Image_Size; |
| 11 |
use Elementor\Group_Control_Background; |
| 12 |
use UltimatePostKit\Utils; |
| 13 |
|
| 14 |
use UltimatePostKit\Traits\Global_Widget_Controls; |
| 15 |
use UltimatePostKit\Traits\Global_Widget_Functions; |
| 16 |
use UltimatePostKit\Includes\Controls\GroupQuery\Group_Control_Query; |
| 17 |
use WP_Query; |
| 18 |
|
| 19 |
if (!defined('ABSPATH')) { |
| 20 |
exit; |
| 21 |
} // Exit if accessed directly |
| 22 |
|
| 23 |
class Hazel_Grid extends Group_Control_Query { |
| 24 |
|
| 25 |
use Global_Widget_Controls; |
| 26 |
use Global_Widget_Functions; |
| 27 |
|
| 28 |
private $_query = null; |
| 29 |
|
| 30 |
public function get_name() { |
| 31 |
return 'upk-hazel-grid'; |
| 32 |
} |
| 33 |
|
| 34 |
public function get_title() { |
| 35 |
return BDTUPK . esc_html__('Hazel Grid', 'ultimate-post-kit'); |
| 36 |
} |
| 37 |
|
| 38 |
public function get_icon() { |
| 39 |
return 'upk-widget-icon upk-icon-hazel-grid'; |
| 40 |
} |
| 41 |
|
| 42 |
public function get_categories() { |
| 43 |
return ['ultimate-post-kit']; |
| 44 |
} |
| 45 |
|
| 46 |
public function get_keywords() { |
| 47 |
return ['post', 'grid', 'blog', 'recent', 'news', 'hazel']; |
| 48 |
} |
| 49 |
|
| 50 |
public function get_style_depends() { |
| 51 |
if ($this->upk_is_edit_mode()) { |
| 52 |
return ['upk-all-styles']; |
| 53 |
} else { |
| 54 |
return ['upk-font', 'upk-hazel-grid']; |
| 55 |
} |
| 56 |
} |
| 57 |
|
| 58 |
public function get_script_depends() { |
| 59 |
if ($this->upk_is_edit_mode()) { |
| 60 |
return ['upk-all-scripts']; |
| 61 |
} else { |
| 62 |
return ['upk-ajax-loadmore']; |
| 63 |
} |
| 64 |
} |
| 65 |
|
| 66 |
public function get_custom_help_url() { |
| 67 |
return 'https://youtu.be/Uy_rOg8lQJM'; |
| 68 |
} |
| 69 |
|
| 70 |
public function get_query() { |
| 71 |
return $this->_query; |
| 72 |
} |
| 73 |
|
| 74 |
public function has_widget_inner_wrapper(): bool { |
| 75 |
return ! \Elementor\Plugin::$instance->experiments->is_feature_active( 'e_optimized_markup' ); |
| 76 |
} |
| 77 |
|
| 78 |
|
| 79 |
protected function register_controls() { |
| 80 |
$this->start_controls_section( |
| 81 |
'section_content_layout', |
| 82 |
[ |
| 83 |
'label' => esc_html__('Layout', 'ultimate-post-kit'), |
| 84 |
] |
| 85 |
); |
| 86 |
|
| 87 |
$this->add_control( |
| 88 |
'grid_style', |
| 89 |
[ |
| 90 |
'label' => esc_html__('Layout Style', 'ultimate-post-kit'), |
| 91 |
'type' => Controls_Manager::SELECT, |
| 92 |
'default' => '1', |
| 93 |
'options' => [ |
| 94 |
'1' => esc_html__('Style 01', 'ultimate-post-kit'), |
| 95 |
'2' => esc_html__('Style 02', 'ultimate-post-kit'), |
| 96 |
'3' => esc_html__('Style 03', 'ultimate-post-kit'), |
| 97 |
'4' => esc_html__('Style 04', 'ultimate-post-kit'), |
| 98 |
'5' => esc_html__('Style 05', 'ultimate-post-kit'), |
| 99 |
'6' => esc_html__('Style 06', 'ultimate-post-kit'), |
| 100 |
'7' => esc_html__('Style 07', 'ultimate-post-kit'), |
| 101 |
'8' => esc_html__('Style 08', 'ultimate-post-kit'), |
| 102 |
'9' => esc_html__('Style 09', 'ultimate-post-kit'), |
| 103 |
'10' => esc_html__('Style 10', 'ultimate-post-kit'), |
| 104 |
], |
| 105 |
] |
| 106 |
); |
| 107 |
|
| 108 |
// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- established hook name relied on across the plugin family; renaming would break integration. |
| 109 |
$column_size = apply_filters('upk_column_size', ''); |
| 110 |
|
| 111 |
$this->add_responsive_control( |
| 112 |
'columns', |
| 113 |
[ |
| 114 |
'label' => __('Columns', 'ultimate-post-kit') . BDTUPK_PC, |
| 115 |
'type' => Controls_Manager::SELECT, |
| 116 |
'default' => '3', |
| 117 |
'tablet_default' => '2', |
| 118 |
'mobile_default' => '1', |
| 119 |
'options' => [ |
| 120 |
'1' => '1', |
| 121 |
'2' => '2', |
| 122 |
'3' => '3', |
| 123 |
'4' => '4', |
| 124 |
'5' => '5', |
| 125 |
'6' => '6', |
| 126 |
], |
| 127 |
'selectors' => [ |
| 128 |
'{{WRAPPER}} .upk-hazel-grid .upk-post-grid.upk-style-1' => $column_size, |
| 129 |
], |
| 130 |
'condition' => [ |
| 131 |
'grid_style' => ['1'] |
| 132 |
], |
| 133 |
'classes' => BDTUPK_IS_PC |
| 134 |
] |
| 135 |
); |
| 136 |
|
| 137 |
$this->add_responsive_control( |
| 138 |
'row_gap', |
| 139 |
[ |
| 140 |
'label' => esc_html__('Row Gap', 'ultimate-post-kit'), |
| 141 |
'type' => Controls_Manager::SLIDER, |
| 142 |
'default' => [ |
| 143 |
'size' => 20, |
| 144 |
], |
| 145 |
'selectors' => [ |
| 146 |
'{{WRAPPER}} .upk-hazel-grid .upk-post-grid' => 'grid-row-gap: {{SIZE}}{{UNIT}};', |
| 147 |
], |
| 148 |
] |
| 149 |
); |
| 150 |
|
| 151 |
$this->add_responsive_control( |
| 152 |
'column_gap', |
| 153 |
[ |
| 154 |
'label' => esc_html__('Column Gap', 'ultimate-post-kit'), |
| 155 |
'type' => Controls_Manager::SLIDER, |
| 156 |
'default' => [ |
| 157 |
'size' => 20, |
| 158 |
], |
| 159 |
'selectors' => [ |
| 160 |
'{{WRAPPER}} .upk-hazel-grid .upk-post-grid' => 'grid-column-gap: {{SIZE}}{{UNIT}};', |
| 161 |
], |
| 162 |
] |
| 163 |
); |
| 164 |
|
| 165 |
$this->add_control( |
| 166 |
'content_style', |
| 167 |
[ |
| 168 |
'label' => esc_html__('Content Style', 'ultimate-post-kit'), |
| 169 |
'type' => Controls_Manager::SELECT, |
| 170 |
'default' => '1', |
| 171 |
'options' => [ |
| 172 |
'1' => esc_html__('Style 01', 'ultimate-post-kit'), |
| 173 |
'2' => esc_html__('Style 02', 'ultimate-post-kit'), |
| 174 |
'3' => esc_html__('Style 03', 'ultimate-post-kit'), |
| 175 |
], |
| 176 |
] |
| 177 |
); |
| 178 |
|
| 179 |
$this->add_control( |
| 180 |
'content_position', |
| 181 |
[ |
| 182 |
'label' => esc_html__('Content Position', 'ultimate-post-kit'), |
| 183 |
'type' => Controls_Manager::SELECT, |
| 184 |
'default' => 'bottom-left', |
| 185 |
'options' => [ |
| 186 |
'top-left' => esc_html__('Top Left', 'ultimate-post-kit'), |
| 187 |
'top-right' => esc_html__('Top Right', 'ultimate-post-kit'), |
| 188 |
'center-center' => esc_html__('Center', 'ultimate-post-kit'), |
| 189 |
'bottom-left' => esc_html__('Bottom Left', 'ultimate-post-kit'), |
| 190 |
'bottom-right' => esc_html__('Bottom Right', 'ultimate-post-kit'), |
| 191 |
'bottom-center' => esc_html__('Bottom Center', 'ultimate-post-kit'), |
| 192 |
], |
| 193 |
] |
| 194 |
); |
| 195 |
|
| 196 |
$this->add_responsive_control( |
| 197 |
'default_item_height', |
| 198 |
[ |
| 199 |
'label' => esc_html__('Default Item Height', 'ultimate-post-kit'), |
| 200 |
'type' => Controls_Manager::SLIDER, |
| 201 |
'range' => [ |
| 202 |
'px' => [ |
| 203 |
'min' => 200, |
| 204 |
'max' => 800, |
| 205 |
], |
| 206 |
], |
| 207 |
'selectors' => [ |
| 208 |
'{{WRAPPER}} .upk-hazel-grid .upk-post-grid.upk-style-1 .upk-item, {{WRAPPER}} .upk-hazel-grid .upk-post-grid.upk-style-8 .upk-item:nth-child(n+1)' => 'height: {{SIZE}}px;', |
| 209 |
], |
| 210 |
'condition' => [ |
| 211 |
'grid_style' => ['1', '8'] |
| 212 |
] |
| 213 |
] |
| 214 |
); |
| 215 |
|
| 216 |
$this->add_responsive_control( |
| 217 |
'primary_item_height', |
| 218 |
[ |
| 219 |
'label' => esc_html__('Primary Item Height', 'ultimate-post-kit'), |
| 220 |
'type' => Controls_Manager::SLIDER, |
| 221 |
'range' => [ |
| 222 |
'px' => [ |
| 223 |
'min' => 200, |
| 224 |
'max' => 800, |
| 225 |
], |
| 226 |
], |
| 227 |
'selectors' => [ |
| 228 |
'{{WRAPPER}} .upk-hazel-grid .upk-post-grid.upk-style-5 .upk-item:nth-child(5n+1), {{WRAPPER}} .upk-hazel-grid .upk-post-grid.upk-style-5 .upk-item:nth-child(5n+2), {{WRAPPER}} .upk-hazel-grid .upk-post-grid.upk-style-5 .upk-item:nth-child(5n+4)' => 'height: {{SIZE}}px;', |
| 229 |
], |
| 230 |
'condition' => [ |
| 231 |
'grid_style' => ['5'] |
| 232 |
] |
| 233 |
] |
| 234 |
); |
| 235 |
|
| 236 |
$this->add_responsive_control( |
| 237 |
'secondary_item_height', |
| 238 |
[ |
| 239 |
'label' => esc_html__('Secondary Item Height', 'ultimate-post-kit'), |
| 240 |
'type' => Controls_Manager::SLIDER, |
| 241 |
'range' => [ |
| 242 |
'px' => [ |
| 243 |
'min' => 200, |
| 244 |
'max' => 800, |
| 245 |
], |
| 246 |
], |
| 247 |
'selectors' => [ |
| 248 |
'{{WRAPPER}} .upk-hazel-grid .upk-style-2 .upk-item:nth-child(6n+2), {{WRAPPER}} .upk-hazel-grid .upk-style-2 .upk-item:nth-child(6n+3), {{WRAPPER}} .upk-hazel-grid .upk-style-2 .upk-item:nth-child(6n+4), {{WRAPPER}} .upk-hazel-grid .upk-style-2 .upk-item:nth-child(6n+5), {{WRAPPER}} .upk-hazel-grid .upk-style-2 .upk-item:nth-child(6n+6), {{WRAPPER}} .upk-hazel-grid .upk-style-3 .upk-item:nth-child(5n+2), {{WRAPPER}} .upk-hazel-grid .upk-style-3 .upk-item:nth-child(5n+3), {{WRAPPER}} .upk-hazel-grid .upk-style-3 .upk-item:nth-child(5n+4), {{WRAPPER}} .upk-hazel-grid .upk-style-3 .upk-item:nth-child(5n+5), {{WRAPPER}} .upk-hazel-grid .upk-style-4 .upk-item:nth-child(5n+1), {{WRAPPER}} .upk-hazel-grid .upk-style-4 .upk-item:nth-child(5n+3), {{WRAPPER}} .upk-hazel-grid .upk-style-4 .upk-item:nth-child(5n+4), {{WRAPPER}} .upk-hazel-grid .upk-style-4 .upk-item:nth-child(5n+5), {{WRAPPER}} .upk-hazel-grid .upk-style-5 .upk-item:nth-child(5n+3), {{WRAPPER}} .upk-hazel-grid .upk-style-5 .upk-item:nth-child(5n+5), {{WRAPPER}} .upk-hazel-grid .upk-style-6 .upk-item:nth-child(5n+1), {{WRAPPER}} .upk-hazel-grid .upk-style-6 .upk-item:nth-child(5n+2), {{WRAPPER}} .upk-hazel-grid .upk-style-6 .upk-item:nth-child(5n+4), {{WRAPPER}} .upk-hazel-grid .upk-style-6 .upk-item:nth-child(5n+5), {{WRAPPER}} .upk-hazel-grid .upk-style-7 .upk-item:nth-child(7n+2), {{WRAPPER}} .upk-hazel-grid .upk-style-7 .upk-item:nth-child(7n+3), {{WRAPPER}} .upk-hazel-grid .upk-style-7 .upk-item:nth-child(7n+4), {{WRAPPER}} .upk-hazel-grid .upk-style-7 .upk-item:nth-child(7n+6), {{WRAPPER}} .upk-hazel-grid .upk-style-7 .upk-item:nth-child(7n+7), {{WRAPPER}} .upk-hazel-grid .upk-style-9 .upk-item:nth-child(4n+2), {{WRAPPER}} .upk-hazel-grid .upk-style-9 .upk-item:nth-child(4n+3), {{WRAPPER}} .upk-hazel-grid .upk-style-9 .upk-item:nth-child(4n+4), {{WRAPPER}} .upk-hazel-grid .upk-style-10 .upk-item:nth-child(6n+1), {{WRAPPER}} .upk-hazel-grid .upk-style-10 .upk-item:nth-child(6n+2), {{WRAPPER}} .upk-hazel-grid .upk-style-10 .upk-item:nth-child(6n+3), {{WRAPPER}} .upk-hazel-grid .upk-style-10 .upk-item:nth-child(6n+4), {{WRAPPER}} .upk-hazel-grid .upk-style-10 .upk-item:nth-child(6n+6)' => 'height: {{SIZE}}px;', |
| 249 |
'(mobile){{WRAPPER}} .upk-hazel-grid .upk-style-2 .upk-item:nth-child(6n+1)' => 'height: {{SIZE}}px;', |
| 250 |
'(mobile){{WRAPPER}} .upk-hazel-grid .upk-style-3 .upk-item:nth-child(5n+1)' => 'height: {{SIZE}}px;', |
| 251 |
'(mobile){{WRAPPER}} .upk-hazel-grid .upk-style-4 .upk-item:nth-child(5n+2)' => 'height: {{SIZE}}px;', |
| 252 |
'(mobile){{WRAPPER}} .upk-hazel-grid .upk-style-6 .upk-item:nth-child(5n+3)' => 'height: {{SIZE}}px;', |
| 253 |
'(mobile){{WRAPPER}} .upk-hazel-grid .upk-style-7 .upk-item:nth-child(7n+1)' => 'height: {{SIZE}}px;', |
| 254 |
'(mobile){{WRAPPER}} .upk-hazel-grid .upk-style-7 .upk-item:nth-child(7n+5)' => 'height: {{SIZE}}px;', |
| 255 |
'(mobile){{WRAPPER}} .upk-hazel-grid .upk-style-9 .upk-item:nth-child(4n+1)' => 'height: {{SIZE}}px;', |
| 256 |
'(mobile){{WRAPPER}} .upk-hazel-grid .upk-style-10 .upk-item:nth-child(6n+5)' => 'height: {{SIZE}}px;', |
| 257 |
], |
| 258 |
'condition' => [ |
| 259 |
'grid_style!' => ['1', '8'] |
| 260 |
] |
| 261 |
] |
| 262 |
); |
| 263 |
|
| 264 |
$this->add_group_control( |
| 265 |
Group_Control_Image_Size::get_type(), |
| 266 |
[ |
| 267 |
'name' => 'primary_thumbnail', |
| 268 |
// phpcs:ignore WordPressVIPMinimum.Performance.WPQueryParams.PostNotIn_exclude -- Elementor widget query built from user-configured controls; expected behaviour. |
| 269 |
'exclude' => ['custom'], |
| 270 |
'default' => 'medium', |
| 271 |
] |
| 272 |
); |
| 273 |
|
| 274 |
$this->end_controls_section(); |
| 275 |
|
| 276 |
// Query Settings |
| 277 |
$this->start_controls_section( |
| 278 |
'section_post_query_builder', |
| 279 |
[ |
| 280 |
'label' => esc_html__('Query', 'ultimate-post-kit'), |
| 281 |
'tab' => Controls_Manager::TAB_CONTENT, |
| 282 |
] |
| 283 |
); |
| 284 |
|
| 285 |
$this->add_control( |
| 286 |
'item_limit', |
| 287 |
[ |
| 288 |
'label' => esc_html__('Item Limit', 'ultimate-post-kit'), |
| 289 |
'type' => Controls_Manager::SLIDER, |
| 290 |
'range' => [ |
| 291 |
'px' => [ |
| 292 |
'min' => 0, |
| 293 |
'max' => 18, |
| 294 |
'step' => 6 |
| 295 |
], |
| 296 |
], |
| 297 |
'default' => [ |
| 298 |
'size' => 6, |
| 299 |
], |
| 300 |
'condition' => [ |
| 301 |
'grid_style' => ['1', '2', '8', '10'], |
| 302 |
'posts_source!' => 'current_query' |
| 303 |
] |
| 304 |
] |
| 305 |
); |
| 306 |
|
| 307 |
$this->add_control( |
| 308 |
'item_limit_3_4_5_6', |
| 309 |
[ |
| 310 |
'label' => esc_html__('Item Limit', 'ultimate-post-kit'), |
| 311 |
'type' => Controls_Manager::SLIDER, |
| 312 |
'range' => [ |
| 313 |
'px' => [ |
| 314 |
'min' => 0, |
| 315 |
'max' => 20, |
| 316 |
'step' => 5 |
| 317 |
], |
| 318 |
], |
| 319 |
'default' => [ |
| 320 |
'size' => 5, |
| 321 |
], |
| 322 |
'condition' => [ |
| 323 |
'grid_style' => ['3', '4', '5', '6'], |
| 324 |
'posts_source!' => 'current_query' |
| 325 |
] |
| 326 |
] |
| 327 |
); |
| 328 |
|
| 329 |
$this->add_control( |
| 330 |
'item_limit_7', |
| 331 |
[ |
| 332 |
'label' => esc_html__('Item Limit', 'ultimate-post-kit'), |
| 333 |
'type' => Controls_Manager::SLIDER, |
| 334 |
'range' => [ |
| 335 |
'px' => [ |
| 336 |
'min' => 0, |
| 337 |
'max' => 21, |
| 338 |
'step' => 7 |
| 339 |
], |
| 340 |
], |
| 341 |
'default' => [ |
| 342 |
'size' => 7, |
| 343 |
], |
| 344 |
'condition' => [ |
| 345 |
'grid_style' => ['7'], |
| 346 |
'posts_source!' => 'current_query' |
| 347 |
] |
| 348 |
] |
| 349 |
); |
| 350 |
|
| 351 |
$this->add_control( |
| 352 |
'item_limit_9', |
| 353 |
[ |
| 354 |
'label' => esc_html__('Item Limit', 'ultimate-post-kit'), |
| 355 |
'type' => Controls_Manager::SLIDER, |
| 356 |
'range' => [ |
| 357 |
'px' => [ |
| 358 |
'min' => 0, |
| 359 |
'max' => 20, |
| 360 |
'step' => 4 |
| 361 |
], |
| 362 |
], |
| 363 |
'default' => [ |
| 364 |
'size' => 4, |
| 365 |
], |
| 366 |
'condition' => [ |
| 367 |
'grid_style' => ['9'], |
| 368 |
'posts_source!' => 'current_query' |
| 369 |
] |
| 370 |
] |
| 371 |
); |
| 372 |
|
| 373 |
$this->register_query_builder_controls(); |
| 374 |
|
| 375 |
$this->end_controls_section(); |
| 376 |
|
| 377 |
$this->start_controls_section( |
| 378 |
'section_content_additional', |
| 379 |
[ |
| 380 |
'label' => esc_html__('Additional Options', 'ultimate-post-kit'), |
| 381 |
] |
| 382 |
); |
| 383 |
|
| 384 |
//Global Title Controls |
| 385 |
$this->register_title_controls(); |
| 386 |
|
| 387 |
$this->add_control( |
| 388 |
'show_category', |
| 389 |
[ |
| 390 |
'label' => esc_html__('Show Category', 'ultimate-post-kit'), |
| 391 |
'type' => Controls_Manager::SWITCHER, |
| 392 |
'default' => 'yes', |
| 393 |
] |
| 394 |
); |
| 395 |
|
| 396 |
$this->add_control( |
| 397 |
'show_author', |
| 398 |
[ |
| 399 |
'label' => esc_html__('Show Author', 'ultimate-post-kit'), |
| 400 |
'type' => Controls_Manager::SWITCHER, |
| 401 |
'default' => 'yes', |
| 402 |
] |
| 403 |
); |
| 404 |
|
| 405 |
//Global Date Controls |
| 406 |
$this->register_date_controls(); |
| 407 |
|
| 408 |
//Global Reading Time Controls |
| 409 |
$this->register_reading_time_controls(); |
| 410 |
|
| 411 |
$this->add_control( |
| 412 |
'meta_separator', |
| 413 |
[ |
| 414 |
'label' => esc_html__('Separator', 'ultimate-post-kit'), |
| 415 |
'type' => Controls_Manager::TEXT, |
| 416 |
'default' => '-', |
| 417 |
'label_block' => false, |
| 418 |
] |
| 419 |
); |
| 420 |
|
| 421 |
$this->add_control( |
| 422 |
'show_pagination', |
| 423 |
[ |
| 424 |
'label' => esc_html__('Show Pagination', 'ultimate-post-kit'), |
| 425 |
'type' => Controls_Manager::SWITCHER, |
| 426 |
'separator' => 'before' |
| 427 |
] |
| 428 |
); |
| 429 |
|
| 430 |
//Global Ajax Controls |
| 431 |
$this->register_ajax_loadmore_controls(); |
| 432 |
|
| 433 |
$this->add_control( |
| 434 |
'global_link', |
| 435 |
[ |
| 436 |
'label' => __('Item Wrapper Link', 'ultimate-post-kit'), |
| 437 |
'type' => Controls_Manager::SWITCHER, |
| 438 |
'prefix_class' => 'upk-global-link-', |
| 439 |
'description' => __('Be aware! When Item Wrapper Link activated then title link and read more link will not work', 'ultimate-post-kit'), |
| 440 |
] |
| 441 |
); |
| 442 |
|
| 443 |
$this->end_controls_section(); |
| 444 |
|
| 445 |
$this->start_controls_section( |
| 446 |
'upk_section_style', |
| 447 |
[ |
| 448 |
'label' => esc_html__('Items', 'ultimate-post-kit'), |
| 449 |
'tab' => Controls_Manager::TAB_STYLE, |
| 450 |
] |
| 451 |
); |
| 452 |
|
| 453 |
$this->add_control( |
| 454 |
'overlay_blur_effect', |
| 455 |
[ |
| 456 |
'label' => esc_html__('Glassmorphism', 'ultimate-post-kit'), |
| 457 |
'type' => Controls_Manager::SWITCHER, |
| 458 |
// translators: %1s: Opening anchor tag with link to MDN backdrop-filter documentation, %2s: Closing anchor tag |
| 459 |
'description' => sprintf(__('This feature will not work in the Firefox browser untill you enable browser compatibility so please %1$s look here %2$s', 'ultimate-post-kit'), '<a href="https://developer.mozilla.org/en-US/docs/Web/CSS/backdrop-filter#Browser_compatibility" target="_blank">', '</a>'), |
| 460 |
'default' => 'yes', |
| 461 |
'condition' => [ |
| 462 |
'content_style' => '2', |
| 463 |
] |
| 464 |
] |
| 465 |
); |
| 466 |
|
| 467 |
$this->add_control( |
| 468 |
'overlay_blur_level', |
| 469 |
[ |
| 470 |
'label' => __('Blur Level', 'ultimate-post-kit'), |
| 471 |
'type' => Controls_Manager::SLIDER, |
| 472 |
'range' => [ |
| 473 |
'px' => [ |
| 474 |
'min' => 0, |
| 475 |
'step' => 1, |
| 476 |
'max' => 50, |
| 477 |
] |
| 478 |
], |
| 479 |
'default' => [ |
| 480 |
'size' => 10 |
| 481 |
], |
| 482 |
'selectors' => [ |
| 483 |
'{{WRAPPER}} .upk-hazel-grid .upk-content-style-2 .upk-content' => 'backdrop-filter: blur({{SIZE}}px); -webkit-backdrop-filter: blur({{SIZE}}px);' |
| 484 |
], |
| 485 |
'condition' => [ |
| 486 |
'overlay_blur_effect' => 'yes', |
| 487 |
'content_style' => '2', |
| 488 |
] |
| 489 |
] |
| 490 |
); |
| 491 |
|
| 492 |
$this->add_control( |
| 493 |
'overlay_background', |
| 494 |
[ |
| 495 |
'label' => esc_html__('Overlay Color', 'ultimate-post-kit'), |
| 496 |
'type' => Controls_Manager::COLOR, |
| 497 |
'selectors' => [ |
| 498 |
'{{WRAPPER}} .upk-hazel-grid .upk-content-style-1 .upk-item-box:before, {{WRAPPER}} .upk-hazel-grid .upk-content-style-2 .upk-content, {{WRAPPER}} .upk-hazel-grid .upk-content-style-3 .upk-item .upk-item-box:before' => 'background-color: {{VALUE}};' |
| 499 |
], |
| 500 |
] |
| 501 |
); |
| 502 |
|
| 503 |
$this->add_group_control( |
| 504 |
Group_Control_Border::get_type(), |
| 505 |
[ |
| 506 |
'name' => 'item_border', |
| 507 |
'label' => __('Border', 'ultimate-post-kit'), |
| 508 |
'placeholder' => '1px', |
| 509 |
'default' => '1px', |
| 510 |
'selector' => '{{WRAPPER}} .upk-hazel-grid .upk-item', |
| 511 |
] |
| 512 |
); |
| 513 |
|
| 514 |
$this->add_responsive_control( |
| 515 |
'item_border_radius', |
| 516 |
[ |
| 517 |
'label' => esc_html__('Border Radius', 'ultimate-post-kit'), |
| 518 |
'type' => Controls_Manager::DIMENSIONS, |
| 519 |
'size_units' => ['px', '%'], |
| 520 |
'selectors' => [ |
| 521 |
'{{WRAPPER}} .upk-hazel-grid .upk-item' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 522 |
], |
| 523 |
] |
| 524 |
); |
| 525 |
|
| 526 |
$this->add_responsive_control( |
| 527 |
'content_padding', |
| 528 |
[ |
| 529 |
'label' => __('Content Padding', 'ultimate-post-kit'), |
| 530 |
'type' => Controls_Manager::DIMENSIONS, |
| 531 |
'size_units' => ['px', 'em', '%'], |
| 532 |
'selectors' => [ |
| 533 |
'{{WRAPPER}} .upk-hazel-grid .upk-content' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 534 |
], |
| 535 |
] |
| 536 |
); |
| 537 |
|
| 538 |
$this->end_controls_section(); |
| 539 |
|
| 540 |
$this->start_controls_section( |
| 541 |
'section_style_title', |
| 542 |
[ |
| 543 |
'label' => esc_html__('Title', 'ultimate-post-kit'), |
| 544 |
'tab' => Controls_Manager::TAB_STYLE, |
| 545 |
'condition' => [ |
| 546 |
'show_title' => 'yes', |
| 547 |
], |
| 548 |
] |
| 549 |
); |
| 550 |
|
| 551 |
$this->add_control( |
| 552 |
'title_style', |
| 553 |
[ |
| 554 |
'label' => esc_html__('Style', 'ultimate-post-kit'), |
| 555 |
'type' => Controls_Manager::SELECT, |
| 556 |
'default' => '', |
| 557 |
'options' => [ |
| 558 |
'' => esc_html__('Default', 'ultimate-post-kit'), |
| 559 |
'underline' => esc_html__('Underline', 'ultimate-post-kit'), |
| 560 |
'middle-underline' => esc_html__('Middle Underline', 'ultimate-post-kit'), |
| 561 |
'overline' => esc_html__('Overline', 'ultimate-post-kit'), |
| 562 |
'middle-overline' => esc_html__('Middle Overline', 'ultimate-post-kit'), |
| 563 |
], |
| 564 |
'condition' => [ |
| 565 |
'content_style!' => '3' |
| 566 |
] |
| 567 |
] |
| 568 |
); |
| 569 |
|
| 570 |
$this->add_control( |
| 571 |
'title_color', |
| 572 |
[ |
| 573 |
'label' => esc_html__('Color', 'ultimate-post-kit'), |
| 574 |
'type' => Controls_Manager::COLOR, |
| 575 |
'selectors' => [ |
| 576 |
'{{WRAPPER}} .upk-hazel-grid .upk-title a' => 'color: {{VALUE}};', |
| 577 |
], |
| 578 |
] |
| 579 |
); |
| 580 |
|
| 581 |
$this->add_control( |
| 582 |
'title_hover_color', |
| 583 |
[ |
| 584 |
'label' => esc_html__('Hover Color', 'ultimate-post-kit'), |
| 585 |
'type' => Controls_Manager::COLOR, |
| 586 |
'selectors' => [ |
| 587 |
'{{WRAPPER}} .upk-hazel-grid .upk-title a:hover' => 'color: {{VALUE}};', |
| 588 |
], |
| 589 |
] |
| 590 |
); |
| 591 |
|
| 592 |
$this->add_group_control( |
| 593 |
Group_Control_Typography::get_type(), |
| 594 |
[ |
| 595 |
'name' => 'title_typography', |
| 596 |
'label' => esc_html__('Typography', 'ultimate-post-kit'), |
| 597 |
'selector' => '{{WRAPPER}} .upk-hazel-grid .upk-title', |
| 598 |
] |
| 599 |
); |
| 600 |
|
| 601 |
$this->add_group_control( |
| 602 |
Group_Control_Typography::get_type(), |
| 603 |
[ |
| 604 |
'name' => 'secondary_title_typography', |
| 605 |
'label' => esc_html__('Secondary Typography', 'ultimate-post-kit'), |
| 606 |
'selector' => '{{WRAPPER}} .upk-hazel-grid .upk-style-2 .upk-item:nth-child(6n+2) .upk-title, {{WRAPPER}} .upk-hazel-grid .upk-style-2 .upk-item:nth-child(6n+3) .upk-title, {{WRAPPER}} .upk-hazel-grid .upk-style-2 .upk-item:nth-child(6n+4) .upk-title, {{WRAPPER}} .upk-hazel-grid .upk-style-2 .upk-item:nth-child(6n+5) .upk-title, {{WRAPPER}} .upk-hazel-grid .upk-style-2 .upk-item:nth-child(6n+6) .upk-title, {{WRAPPER}} .upk-hazel-grid .upk-style-3 .upk-item:nth-child(5n+2) .upk-title, {{WRAPPER}} .upk-hazel-grid .upk-style-3 .upk-item:nth-child(5n+3) .upk-title, {{WRAPPER}} .upk-hazel-grid .upk-style-3 .upk-item:nth-child(5n+4) .upk-title, {{WRAPPER}} .upk-hazel-grid .upk-style-3 .upk-item:nth-child(5n+5) .upk-title, {{WRAPPER}} .upk-hazel-grid .upk-style-4 .upk-item:nth-child(5n+1) .upk-title, {{WRAPPER}} .upk-hazel-grid .upk-style-4 .upk-item:nth-child(5n+3) .upk-title, {{WRAPPER}} .upk-hazel-grid .upk-style-4 .upk-item:nth-child(5n+4) .upk-title, {{WRAPPER}} .upk-hazel-grid .upk-style-4 .upk-item:nth-child(5n+5) .upk-title, {{WRAPPER}} .upk-hazel-grid .upk-style-5 .upk-item:nth-child(5n+2) .upk-title, {{WRAPPER}} .upk-hazel-grid .upk-style-5 .upk-item:nth-child(5n+3) .upk-title, {{WRAPPER}} .upk-hazel-grid .upk-style-5 .upk-item:nth-child(5n+5) .upk-title, {{WRAPPER}} .upk-hazel-grid .upk-style-6 .upk-item:nth-child(5n+1) .upk-title, {{WRAPPER}} .upk-hazel-grid .upk-style-6 .upk-item:nth-child(5n+2) .upk-title, {{WRAPPER}} .upk-hazel-grid .upk-style-6 .upk-item:nth-child(5n+4) .upk-title, {{WRAPPER}} .upk-hazel-grid .upk-style-6 .upk-item:nth-child(5n+5) .upk-title, {{WRAPPER}} .upk-hazel-grid .upk-style-7 .upk-item:nth-child(7n+2) .upk-title, {{WRAPPER}} .upk-hazel-grid .upk-style-7 .upk-item:nth-child(7n+3) .upk-title, {{WRAPPER}} .upk-hazel-grid .upk-style-7 .upk-item:nth-child(7n+4) .upk-title, {{WRAPPER}} .upk-hazel-grid .upk-style-7 .upk-item:nth-child(7n+6) .upk-title, {{WRAPPER}} .upk-hazel-grid .upk-style-7 .upk-item:nth-child(7n+7) .upk-title, {{WRAPPER}} .upk-hazel-grid .upk-style-9 .upk-item:nth-child(4n+2) .upk-title, {{WRAPPER}} .upk-hazel-grid .upk-style-9 .upk-item:nth-child(4n+3) .upk-title, {{WRAPPER}} .upk-hazel-grid .upk-style-9 .upk-item:nth-child(4n+4) .upk-title, {{WRAPPER}} .upk-hazel-grid .upk-style-10 .upk-item:nth-child(6n+1) .upk-title, {{WRAPPER}} .upk-hazel-grid .upk-style-10 .upk-item:nth-child(6n+2) .upk-title, {{WRAPPER}} .upk-hazel-grid .upk-style-10 .upk-item:nth-child(6n+3) .upk-title, {{WRAPPER}} .upk-hazel-grid .upk-style-10 .upk-item:nth-child(6n+4) .upk-title, {{WRAPPER}} .upk-hazel-grid .upk-style-10 .upk-item:nth-child(6n+6) .upk-title', |
| 607 |
'condition' => [ |
| 608 |
'grid_style!' => ['1', '8'] |
| 609 |
] |
| 610 |
] |
| 611 |
); |
| 612 |
|
| 613 |
$this->add_control( |
| 614 |
'title_advanced_style', |
| 615 |
[ |
| 616 |
'label' => esc_html__('Advanced Style', 'ultimate-post-kit'), |
| 617 |
'type' => Controls_Manager::SWITCHER, |
| 618 |
] |
| 619 |
); |
| 620 |
|
| 621 |
$this->add_group_control( |
| 622 |
Group_Control_Background::get_type(), |
| 623 |
[ |
| 624 |
'name' => 'title_background', |
| 625 |
'label' => __('Background', 'ultimate-post-kit'), |
| 626 |
'selector' => '{{WRAPPER}} .upk-hazel-grid .upk-title a', |
| 627 |
'condition' => [ |
| 628 |
'title_advanced_style' => 'yes' |
| 629 |
] |
| 630 |
] |
| 631 |
); |
| 632 |
|
| 633 |
$this->add_group_control( |
| 634 |
Group_Control_Text_Shadow::get_type(), |
| 635 |
[ |
| 636 |
'name' => 'title_text_shadow', |
| 637 |
'label' => __('Text Shadow', 'ultimate-post-kit'), |
| 638 |
'selector' => '{{WRAPPER}} .upk-hazel-grid .upk-title a', |
| 639 |
'condition' => [ |
| 640 |
'title_advanced_style' => 'yes' |
| 641 |
] |
| 642 |
] |
| 643 |
); |
| 644 |
|
| 645 |
$this->add_group_control( |
| 646 |
Group_Control_Border::get_type(), |
| 647 |
[ |
| 648 |
'name' => 'title_border', |
| 649 |
'selector' => '{{WRAPPER}} .upk-hazel-grid .upk-title a', |
| 650 |
'condition' => [ |
| 651 |
'title_advanced_style' => 'yes' |
| 652 |
] |
| 653 |
] |
| 654 |
); |
| 655 |
|
| 656 |
$this->add_responsive_control( |
| 657 |
'title_border_radius', |
| 658 |
[ |
| 659 |
'label' => __('Border Radius', 'ultimate-post-kit'), |
| 660 |
'type' => Controls_Manager::DIMENSIONS, |
| 661 |
'size_units' => ['px', '%'], |
| 662 |
'selectors' => [ |
| 663 |
'{{WRAPPER}} .upk-hazel-grid .upk-title a' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 664 |
], |
| 665 |
'condition' => [ |
| 666 |
'title_advanced_style' => 'yes' |
| 667 |
] |
| 668 |
] |
| 669 |
); |
| 670 |
|
| 671 |
$this->add_group_control( |
| 672 |
Group_Control_Box_Shadow::get_type(), |
| 673 |
[ |
| 674 |
'name' => 'title_box_shadow', |
| 675 |
'selector' => '{{WRAPPER}} .upk-hazel-grid .upk-title a', |
| 676 |
'condition' => [ |
| 677 |
'title_advanced_style' => 'yes' |
| 678 |
] |
| 679 |
] |
| 680 |
); |
| 681 |
|
| 682 |
$this->add_responsive_control( |
| 683 |
'title_text_padding', |
| 684 |
[ |
| 685 |
'label' => __('Padding', 'ultimate-post-kit'), |
| 686 |
'type' => Controls_Manager::DIMENSIONS, |
| 687 |
'size_units' => ['px', 'em', '%'], |
| 688 |
'selectors' => [ |
| 689 |
'{{WRAPPER}} .upk-hazel-grid .upk-title a' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 690 |
], |
| 691 |
'condition' => [ |
| 692 |
'title_advanced_style' => 'yes' |
| 693 |
] |
| 694 |
] |
| 695 |
); |
| 696 |
|
| 697 |
$this->add_responsive_control( |
| 698 |
'title_text_margin', |
| 699 |
[ |
| 700 |
'label' => __('Margin', 'ultimate-post-kit'), |
| 701 |
'type' => Controls_Manager::DIMENSIONS, |
| 702 |
'size_units' => ['px', 'em', '%'], |
| 703 |
'selectors' => [ |
| 704 |
'{{WRAPPER}} .upk-hazel-grid .upk-title' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 705 |
], |
| 706 |
'condition' => [ |
| 707 |
'title_advanced_style' => 'yes' |
| 708 |
] |
| 709 |
] |
| 710 |
); |
| 711 |
|
| 712 |
$this->end_controls_section(); |
| 713 |
|
| 714 |
$this->start_controls_section( |
| 715 |
'section_style_author_date', |
| 716 |
[ |
| 717 |
'label' => esc_html__('Meta', 'ultimate-post-kit'), |
| 718 |
'tab' => Controls_Manager::TAB_STYLE, |
| 719 |
'conditions' => [ |
| 720 |
'relation' => 'or', |
| 721 |
'terms' => [ |
| 722 |
[ |
| 723 |
'name' => 'show_author', |
| 724 |
'value' => 'yes' |
| 725 |
], |
| 726 |
[ |
| 727 |
'name' => 'show_date', |
| 728 |
'value' => 'yes' |
| 729 |
] |
| 730 |
] |
| 731 |
], |
| 732 |
] |
| 733 |
); |
| 734 |
|
| 735 |
$this->add_group_control( |
| 736 |
Group_Control_Background::get_type(), |
| 737 |
[ |
| 738 |
'name' => 'author_date_background', |
| 739 |
'selector' => '{{WRAPPER}} .upk-hazel-grid .upk-content-style-3 .upk-content .upk-meta', |
| 740 |
'condition' => [ |
| 741 |
'content_style' => '3', |
| 742 |
], |
| 743 |
] |
| 744 |
); |
| 745 |
|
| 746 |
$this->add_control( |
| 747 |
'author_divider', |
| 748 |
[ |
| 749 |
'type' => Controls_Manager::DIVIDER, |
| 750 |
'condition' => [ |
| 751 |
'content_style' => '3', |
| 752 |
], |
| 753 |
] |
| 754 |
); |
| 755 |
|
| 756 |
$this->add_control( |
| 757 |
'author_color', |
| 758 |
[ |
| 759 |
'label' => esc_html__('Text Color', 'ultimate-post-kit'), |
| 760 |
'type' => Controls_Manager::COLOR, |
| 761 |
'selectors' => [ |
| 762 |
'{{WRAPPER}} .upk-hazel-grid .upk-meta *' => 'color: {{VALUE}};', |
| 763 |
], |
| 764 |
] |
| 765 |
); |
| 766 |
|
| 767 |
$this->add_control( |
| 768 |
'author_hover_color', |
| 769 |
[ |
| 770 |
'label' => esc_html__('Hover Text Color', 'ultimate-post-kit'), |
| 771 |
'type' => Controls_Manager::COLOR, |
| 772 |
'selectors' => [ |
| 773 |
'{{WRAPPER}} .upk-hazel-grid .upk-meta .upk-blog-author a:hover' => 'color: {{VALUE}};', |
| 774 |
], |
| 775 |
] |
| 776 |
); |
| 777 |
|
| 778 |
$this->add_responsive_control( |
| 779 |
'meta_space_between', |
| 780 |
[ |
| 781 |
'label' => esc_html__('Space Between', 'ultimate-post-kit'), |
| 782 |
'type' => Controls_Manager::SLIDER, |
| 783 |
'range' => [ |
| 784 |
'px' => [ |
| 785 |
'min' => 0, |
| 786 |
'max' => 50, |
| 787 |
], |
| 788 |
], |
| 789 |
'selectors' => [ |
| 790 |
'{{WRAPPER}} .upk-hazel-grid .upk-meta > div:before' => 'margin: 0 {{SIZE}}{{UNIT}};', |
| 791 |
], |
| 792 |
] |
| 793 |
); |
| 794 |
|
| 795 |
$this->add_group_control( |
| 796 |
Group_Control_Typography::get_type(), |
| 797 |
[ |
| 798 |
'name' => 'author_typography', |
| 799 |
'label' => esc_html__('Typography', 'ultimate-post-kit'), |
| 800 |
'selector' => '{{WRAPPER}} .upk-hazel-grid .upk-meta, {{WRAPPER}} .upk-hazel-grid .upk-meta *', |
| 801 |
] |
| 802 |
); |
| 803 |
|
| 804 |
$this->end_controls_section(); |
| 805 |
|
| 806 |
$this->start_controls_section( |
| 807 |
'section_style_category', |
| 808 |
[ |
| 809 |
'label' => esc_html__('Category', 'ultimate-post-kit'), |
| 810 |
'tab' => Controls_Manager::TAB_STYLE, |
| 811 |
'condition' => [ |
| 812 |
'show_category' => 'yes', |
| 813 |
], |
| 814 |
] |
| 815 |
); |
| 816 |
|
| 817 |
$this->start_controls_tabs('tabs_category_style'); |
| 818 |
|
| 819 |
$this->start_controls_tab( |
| 820 |
'tab_category_normal', |
| 821 |
[ |
| 822 |
'label' => esc_html__('Normal', 'ultimate-post-kit'), |
| 823 |
] |
| 824 |
); |
| 825 |
|
| 826 |
$this->add_control( |
| 827 |
'category_color', |
| 828 |
[ |
| 829 |
'label' => esc_html__('Color', 'ultimate-post-kit'), |
| 830 |
'type' => Controls_Manager::COLOR, |
| 831 |
'selectors' => [ |
| 832 |
'{{WRAPPER}} .upk-hazel-grid .upk-category a' => 'color: {{VALUE}};', |
| 833 |
], |
| 834 |
] |
| 835 |
); |
| 836 |
|
| 837 |
$this->add_group_control( |
| 838 |
Group_Control_Background::get_type(), |
| 839 |
[ |
| 840 |
'name' => 'category_background', |
| 841 |
'selector' => '{{WRAPPER}} .upk-hazel-grid .upk-category a', |
| 842 |
] |
| 843 |
); |
| 844 |
|
| 845 |
$this->add_group_control( |
| 846 |
Group_Control_Border::get_type(), |
| 847 |
[ |
| 848 |
'name' => 'category_border', |
| 849 |
'selector' => '{{WRAPPER}} .upk-hazel-grid .upk-category a', |
| 850 |
] |
| 851 |
); |
| 852 |
|
| 853 |
$this->add_responsive_control( |
| 854 |
'category_border_radius', |
| 855 |
[ |
| 856 |
'label' => esc_html__('Border Radius', 'ultimate-post-kit'), |
| 857 |
'type' => Controls_Manager::DIMENSIONS, |
| 858 |
'size_units' => ['px', '%'], |
| 859 |
'selectors' => [ |
| 860 |
'{{WRAPPER}} .upk-hazel-grid .upk-category a' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 861 |
], |
| 862 |
] |
| 863 |
); |
| 864 |
|
| 865 |
$this->add_responsive_control( |
| 866 |
'category_padding', |
| 867 |
[ |
| 868 |
'label' => esc_html__('Padding', 'ultimate-post-kit'), |
| 869 |
'type' => Controls_Manager::DIMENSIONS, |
| 870 |
'size_units' => ['px', 'em', '%'], |
| 871 |
'selectors' => [ |
| 872 |
'{{WRAPPER}} .upk-hazel-grid .upk-category a' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 873 |
], |
| 874 |
] |
| 875 |
); |
| 876 |
|
| 877 |
$this->add_responsive_control( |
| 878 |
'category_spacing', |
| 879 |
[ |
| 880 |
'label' => esc_html__('Space Between', 'ultimate-post-kit'), |
| 881 |
'type' => Controls_Manager::SLIDER, |
| 882 |
'range' => [ |
| 883 |
'px' => [ |
| 884 |
'min' => 0, |
| 885 |
'max' => 50, |
| 886 |
'step' => 2, |
| 887 |
], |
| 888 |
], |
| 889 |
'selectors' => [ |
| 890 |
'{{WRAPPER}} .upk-hazel-grid .upk-category a+a' => 'margin-left: {{SIZE}}{{UNIT}};', |
| 891 |
], |
| 892 |
] |
| 893 |
); |
| 894 |
|
| 895 |
|
| 896 |
$this->add_group_control( |
| 897 |
Group_Control_Box_Shadow::get_type(), |
| 898 |
[ |
| 899 |
'name' => 'category_shadow', |
| 900 |
'selector' => '{{WRAPPER}} .upk-hazel-grid .upk-category a', |
| 901 |
] |
| 902 |
); |
| 903 |
|
| 904 |
$this->add_group_control( |
| 905 |
Group_Control_Typography::get_type(), |
| 906 |
[ |
| 907 |
'name' => 'category_typography', |
| 908 |
'label' => esc_html__('Typography', 'ultimate-post-kit'), |
| 909 |
'selector' => '{{WRAPPER}} .upk-hazel-grid .upk-category a', |
| 910 |
] |
| 911 |
); |
| 912 |
|
| 913 |
$this->end_controls_tab(); |
| 914 |
|
| 915 |
$this->start_controls_tab( |
| 916 |
'tab_category_hover', |
| 917 |
[ |
| 918 |
'label' => esc_html__('Hover', 'ultimate-post-kit'), |
| 919 |
] |
| 920 |
); |
| 921 |
|
| 922 |
$this->add_control( |
| 923 |
'category_hover_color', |
| 924 |
[ |
| 925 |
'label' => esc_html__('Color', 'ultimate-post-kit'), |
| 926 |
'type' => Controls_Manager::COLOR, |
| 927 |
'selectors' => [ |
| 928 |
'{{WRAPPER}} .upk-hazel-grid .upk-category a:hover' => 'color: {{VALUE}};', |
| 929 |
], |
| 930 |
] |
| 931 |
); |
| 932 |
|
| 933 |
$this->add_group_control( |
| 934 |
Group_Control_Background::get_type(), |
| 935 |
[ |
| 936 |
'name' => 'category_hover_background', |
| 937 |
'selector' => '{{WRAPPER}} .upk-hazel-grid .upk-category a:hover', |
| 938 |
] |
| 939 |
); |
| 940 |
|
| 941 |
$this->add_control( |
| 942 |
'category_hover_border_color', |
| 943 |
[ |
| 944 |
'label' => esc_html__('Border Color', 'ultimate-post-kit'), |
| 945 |
'type' => Controls_Manager::COLOR, |
| 946 |
'condition' => [ |
| 947 |
'category_border_border!' => '', |
| 948 |
], |
| 949 |
'selectors' => [ |
| 950 |
'{{WRAPPER}} .upk-hazel-grid .upk-category a:hover' => 'border-color: {{VALUE}};', |
| 951 |
], |
| 952 |
] |
| 953 |
); |
| 954 |
|
| 955 |
$this->end_controls_tab(); |
| 956 |
|
| 957 |
$this->end_controls_tabs(); |
| 958 |
|
| 959 |
$this->end_controls_section(); |
| 960 |
|
| 961 |
//Global Pagination Controls |
| 962 |
$this->register_pagination_controls(); |
| 963 |
|
| 964 |
//Global Ajax Loadmore Controls |
| 965 |
$this->register_ajax_loadmore_style_controls(); |
| 966 |
} |
| 967 |
|
| 968 |
/** |
| 969 |
* Get post query builder arguments |
| 970 |
*/ |
| 971 |
public function query_posts( $posts_per_page ) { |
| 972 |
$settings = $this->get_settings(); |
| 973 |
$posts_per_page = isset( $posts_per_page ) ? (int) $posts_per_page : 0; |
| 974 |
$args = $this->getGroupControlQueryArgs(); |
| 975 |
$is_current_query = ( ! empty( $settings['posts_source'] ) && $settings['posts_source'] === 'current_query' ); |
| 976 |
|
| 977 |
if ( $is_current_query ) { |
| 978 |
unset( $args['offset'] ); |
| 979 |
unset( $args['no_found_rows'] ); |
| 980 |
$posts_per_page = 0; |
| 981 |
} |
| 982 |
|
| 983 |
if ( $posts_per_page > 0 ) { |
| 984 |
$args['posts_per_page'] = $posts_per_page; |
| 985 |
} else { |
| 986 |
$args['posts_per_page'] = (int) get_option( 'posts_per_page', 10 ); |
| 987 |
} |
| 988 |
|
| 989 |
if ( $settings['show_pagination'] ) { |
| 990 |
$args['paged'] = max( 1, (int) get_query_var( 'paged' ), (int) get_query_var( 'page' ) ); |
| 991 |
} |
| 992 |
|
| 993 |
$this->_query = new \WP_Query( $args ); |
| 994 |
} |
| 995 |
|
| 996 |
public function render_author() { |
| 997 |
|
| 998 |
if (!$this->get_settings('show_author')) { |
| 999 |
return; |
| 1000 |
} |
| 1001 |
|
| 1002 |
?> |
| 1003 |
|
| 1004 |
<div class="upk-blog-author"> |
| 1005 |
<span class="by"><?php echo esc_html_x('By', 'Frontend', 'ultimate-post-kit') ?></span> |
| 1006 |
<span class="upk-post-grid-author"> |
| 1007 |
<a href="<?php echo esc_url( get_author_posts_url(get_the_author_meta('ID')) ); ?>"> |
| 1008 |
<?php echo esc_html( get_the_author() ) ?> |
| 1009 |
</a> |
| 1010 |
</span> |
| 1011 |
</div> |
| 1012 |
|
| 1013 |
<?php |
| 1014 |
} |
| 1015 |
|
| 1016 |
public function render_date() { |
| 1017 |
$settings = $this->get_settings_for_display(); |
| 1018 |
|
| 1019 |
if (!$this->get_settings('show_date')) { |
| 1020 |
return; |
| 1021 |
} |
| 1022 |
|
| 1023 |
if ($settings['human_diff_time'] == 'yes') { |
| 1024 |
echo esc_html( ultimate_post_kit_post_time_diff( ($settings['human_diff_time_short'] == 'yes') ? 'short' : '' ) ); |
| 1025 |
} else { |
| 1026 |
echo get_the_date(); |
| 1027 |
} |
| 1028 |
} |
| 1029 |
|
| 1030 |
public function render_post_grid_item($post_id, $image_size) { |
| 1031 |
$settings = $this->get_settings_for_display(); |
| 1032 |
|
| 1033 |
if ('yes' == $settings['global_link']) { |
| 1034 |
|
| 1035 |
$this->add_render_attribute('grid-item', 'onclick', "window.open('" . esc_url(get_permalink()) . "', '_self')", true); |
| 1036 |
} |
| 1037 |
$this->add_render_attribute('grid-item', 'class', 'upk-item', true); |
| 1038 |
|
| 1039 |
?> |
| 1040 |
<div <?php $this->print_render_attribute_string('grid-item'); ?>> |
| 1041 |
<div class="upk-item-box"> |
| 1042 |
<?php $this->render_image(get_post_thumbnail_id($post_id), $image_size); ?> |
| 1043 |
|
| 1044 |
<div class="upk-content"> |
| 1045 |
<?php $this->render_category(); ?> |
| 1046 |
|
| 1047 |
<div class="upk-title-wrap"> |
| 1048 |
<?php $this->render_title(substr($this->get_name(), 4)); ?> |
| 1049 |
</div> |
| 1050 |
|
| 1051 |
<?php if ($settings['show_author'] or $settings['show_date'] or $settings['show_reading_time']) : ?> |
| 1052 |
<div class="upk-meta"> |
| 1053 |
<?php $this->render_author(); ?> |
| 1054 |
|
| 1055 |
<?php if ($settings['show_date']) : ?> |
| 1056 |
<div data-separator="<?php echo esc_attr($settings['meta_separator']); ?>"> |
| 1057 |
<div class="upk-date"> |
| 1058 |
<i class="upk-icon-calendar" aria-hidden="true"></i><?php $this->render_date(); ?> |
| 1059 |
</div> |
| 1060 |
|
| 1061 |
<?php if ($settings['show_time']) : ?> |
| 1062 |
<div class="upk-post-time"> |
| 1063 |
<i class="upk-icon-clock" aria-hidden="true"></i> |
| 1064 |
<?php echo esc_html( get_the_time() ); ?> |
| 1065 |
</div> |
| 1066 |
<?php endif; ?> |
| 1067 |
</div> |
| 1068 |
<?php endif; ?> |
| 1069 |
|
| 1070 |
<?php if (_is_upk_pro_activated()) : |
| 1071 |
if ('yes' === $settings['show_reading_time']) : ?> |
| 1072 |
<div class="upk-reading-time" data-separator="<?php echo esc_attr($settings['meta_separator']); ?>"> |
| 1073 |
<?php echo esc_html( ultimate_post_kit_reading_time( get_the_content(), $settings['avg_reading_speed'], $settings['hide_seconds'] ?? 'no', $settings['hide_minutes'] ?? 'no' ) ); ?> |
| 1074 |
</div> |
| 1075 |
<?php endif; ?> |
| 1076 |
<?php endif; ?> |
| 1077 |
</div> |
| 1078 |
<?php endif; ?> |
| 1079 |
|
| 1080 |
|
| 1081 |
</div> |
| 1082 |
</div> |
| 1083 |
</div> |
| 1084 |
<?php |
| 1085 |
} |
| 1086 |
|
| 1087 |
protected function render() { |
| 1088 |
$settings = $this->get_settings_for_display(); |
| 1089 |
|
| 1090 |
if ($settings['grid_style'] == '9') { |
| 1091 |
$this->query_posts($settings['item_limit_9']['size']); |
| 1092 |
} elseif ($settings['grid_style'] == '7') { |
| 1093 |
$this->query_posts($settings['item_limit_7']['size']); |
| 1094 |
} elseif ($settings['grid_style'] == '3' or $settings['grid_style'] == '4' or $settings['grid_style'] == '5' or $settings['grid_style'] == '6') { |
| 1095 |
$this->query_posts($settings['item_limit_3_4_5_6']['size']); |
| 1096 |
} else { |
| 1097 |
$this->query_posts($settings['item_limit']['size']); |
| 1098 |
} |
| 1099 |
|
| 1100 |
$wp_query = $this->get_query(); |
| 1101 |
|
| 1102 |
if (!$wp_query->found_posts) { |
| 1103 |
return; |
| 1104 |
} |
| 1105 |
|
| 1106 |
$this->add_render_attribute('grid-wrap', 'class', 'upk-post-grid upk-ajax-grid-wrap'); |
| 1107 |
$this->add_render_attribute('grid-wrap', 'class', 'upk-style-' . $settings['grid_style']); |
| 1108 |
$this->add_render_attribute('grid-wrap', 'class', 'upk-text-position-' . $settings['content_position']); |
| 1109 |
$this->add_render_attribute('grid-wrap', 'class', 'upk-content-style-' . $settings['content_style']); |
| 1110 |
|
| 1111 |
$this->add_render_attribute( |
| 1112 |
[ |
| 1113 |
'upk-hazel-grid' => [ |
| 1114 |
'class' => 'upk-hazel-grid upk-ajax-grid', |
| 1115 |
'data-loadmore' => [ |
| 1116 |
wp_json_encode( |
| 1117 |
array_filter( |
| 1118 |
[ |
| 1119 |
'loadmore_enable' => $settings['ajax_loadmore_enable'], |
| 1120 |
'loadmore_btn' => $settings['ajax_loadmore_btn'], |
| 1121 |
'infinite_scroll' => $settings['ajax_loadmore_infinite_scroll'], |
| 1122 |
] |
| 1123 |
) |
| 1124 |
), |
| 1125 |
], |
| 1126 |
], |
| 1127 |
] |
| 1128 |
); |
| 1129 |
|
| 1130 |
if ( $settings['ajax_loadmore_enable'] === 'yes' ) { |
| 1131 |
$ajax_settings = [ |
| 1132 |
'posts_source' => isset( $settings['posts_source'] ) ? $settings['posts_source'] : 'post', |
| 1133 |
'posts_per_page' => isset( $posts_load ) ? $posts_load : 6, |
| 1134 |
'ajax_item_load' => isset( $settings['ajax_loadmore_items'] ) ? $settings['ajax_loadmore_items'] : 3, |
| 1135 |
'posts_selected_ids' => isset( $settings['posts_selected_ids'] ) ? $settings['posts_selected_ids'] : '', |
| 1136 |
'posts_include_by' => isset( $settings['posts_include_by'] ) ? $settings['posts_include_by'] : [], |
| 1137 |
'posts_include_author_ids' => isset( $settings['posts_include_author_ids'] ) ? $settings['posts_include_author_ids'] : '', |
| 1138 |
'posts_include_term_ids' => isset( $settings['posts_include_term_ids'] ) ? $settings['posts_include_term_ids'] : '', |
| 1139 |
'posts_exclude_by' => isset( $settings['posts_exclude_by'] ) ? $settings['posts_exclude_by'] : [], |
| 1140 |
'posts_exclude_ids' => isset( $settings['posts_exclude_ids'] ) ? $settings['posts_exclude_ids'] : '', |
| 1141 |
'posts_exclude_author_ids' => isset( $settings['posts_exclude_author_ids'] ) ? $settings['posts_exclude_author_ids'] : '', |
| 1142 |
'posts_exclude_term_ids' => isset( $settings['posts_exclude_term_ids'] ) ? $settings['posts_exclude_term_ids'] : '', |
| 1143 |
'posts_offset' => isset( $settings['posts_offset'] ) ? $settings['posts_offset'] : 0, |
| 1144 |
'posts_select_date' => isset( $settings['posts_select_date'] ) ? $settings['posts_select_date'] : '', |
| 1145 |
'posts_date_before' => isset( $settings['posts_date_before'] ) ? $settings['posts_date_before'] : '', |
| 1146 |
'posts_date_after' => isset( $settings['posts_date_after'] ) ? $settings['posts_date_after'] : '', |
| 1147 |
'posts_orderby' => isset( $settings['posts_orderby'] ) ? $settings['posts_orderby'] : 'date', |
| 1148 |
'posts_order' => isset( $settings['posts_order'] ) ? $settings['posts_order'] : 'DESC', |
| 1149 |
'posts_ignore_sticky_posts' => isset( $settings['posts_ignore_sticky_posts'] ) ? $settings['posts_ignore_sticky_posts'] : 'no', |
| 1150 |
'posts_only_with_featured_image' => isset( $settings['posts_only_with_featured_image'] ) ? $settings['posts_only_with_featured_image'] : 'no', |
| 1151 |
// Grid Settings |
| 1152 |
'show_title' => isset( $settings['show_title'] ) ? $settings['show_title'] : 'yes', |
| 1153 |
'title_tags' => isset( $settings['title_tags'] ) ? $settings['title_tags'] : 'h3', |
| 1154 |
'show_excerpt' => isset( $settings['show_excerpt'] ) ? $settings['show_excerpt'] : 'yes', |
| 1155 |
'show_author' => isset( $settings['show_author'] ) ? $settings['show_author'] : 'yes', |
| 1156 |
'show_date' => isset( $settings['show_date'] ) ? $settings['show_date'] : 'yes', |
| 1157 |
'show_time' => isset( $settings['show_time'] ) ? $settings['show_time'] : 'no', |
| 1158 |
'show_category' => isset( $settings['show_category'] ) ? $settings['show_category'] : 'yes', |
| 1159 |
'show_reading_time' => isset( $settings['show_reading_time'] ) ? $settings['show_reading_time'] : 'no', |
| 1160 |
'avg_reading_speed' => isset( $settings['avg_reading_speed'] ) ? $settings['avg_reading_speed'] : 200, |
| 1161 |
'hide_seconds' => isset( $settings['hide_seconds'] ) ? $settings['hide_seconds'] : 'no', |
| 1162 |
'hide_minutes' => isset( $settings['hide_minutes'] ) ? $settings['hide_minutes'] : 'no', |
| 1163 |
'upk_link_new_tab' => isset( $settings['upk_link_new_tab'] ) ? $settings['upk_link_new_tab'] : 'no', |
| 1164 |
'meta_separator' => isset( $settings['meta_separator'] ) ? $settings['meta_separator'] : '|', |
| 1165 |
'human_diff_time' => isset( $settings['human_diff_time'] ) ? $settings['human_diff_time'] : 'no', |
| 1166 |
'human_diff_time_short' => isset( $settings['human_diff_time_short'] ) ? $settings['human_diff_time_short'] : 'no', |
| 1167 |
'excerpt_length' => isset( $settings['excerpt_length'] ) ? $settings['excerpt_length'] : 20, |
| 1168 |
'title_style' => isset( $settings['title_style'] ) ? $settings['title_style'] : 'underline', |
| 1169 |
'global_link' => isset( $settings['global_link'] ) ? $settings['global_link'] : 'no', |
| 1170 |
]; |
| 1171 |
|
| 1172 |
$this->add_render_attribute( |
| 1173 |
[ |
| 1174 |
'upk-hazel-grid' => [ |
| 1175 |
'data-settings' => [ |
| 1176 |
wp_json_encode( $ajax_settings ), |
| 1177 |
], |
| 1178 |
], |
| 1179 |
] |
| 1180 |
); |
| 1181 |
} |
| 1182 |
|
| 1183 |
if (isset($settings['upk_in_animation_show']) && ($settings['upk_in_animation_show'] == 'yes')) { |
| 1184 |
$this->add_render_attribute('grid-wrap', 'class', 'upk-in-animation'); |
| 1185 |
if (isset($settings['upk_in_animation_delay']['size'])) { |
| 1186 |
$this->add_render_attribute('grid-wrap', 'data-in-animation-delay', $settings['upk_in_animation_delay']['size']); |
| 1187 |
} |
| 1188 |
} |
| 1189 |
|
| 1190 |
?> |
| 1191 |
<div <?php $this->print_render_attribute_string('upk-hazel-grid'); ?>> |
| 1192 |
<div <?php $this->print_render_attribute_string('grid-wrap'); ?>> |
| 1193 |
|
| 1194 |
<?php while ($wp_query->have_posts()) : |
| 1195 |
$wp_query->the_post(); |
| 1196 |
|
| 1197 |
$thumbnail_size = $settings['primary_thumbnail_size']; |
| 1198 |
|
| 1199 |
?> |
| 1200 |
|
| 1201 |
<?php $this->render_post_grid_item(get_the_ID(), $thumbnail_size); ?> |
| 1202 |
|
| 1203 |
<?php endwhile; ?> |
| 1204 |
</div> |
| 1205 |
</div> |
| 1206 |
|
| 1207 |
<?php $this->render_ajax_loadmore(); ?> |
| 1208 |
|
| 1209 |
<?php |
| 1210 |
|
| 1211 |
if ($settings['show_pagination']) { ?> |
| 1212 |
<div class="ep-pagination"> |
| 1213 |
<?php ultimate_post_kit_post_pagination($wp_query, $this->get_id()); ?> |
| 1214 |
</div> |
| 1215 |
<?php |
| 1216 |
} |
| 1217 |
wp_reset_postdata(); |
| 1218 |
} |
| 1219 |
} |
| 1220 |
|