ContentTabController.php
8 months ago
SectionTitleSettingsStyle.php
8 months ago
SettingsTabController.php
8 months ago
StyleTabController.php
8 months ago
TimelineContentTabController.php
8 months ago
ContentTabController.php
463 lines
| 1 | <?php |
| 2 | |
| 3 | namespace RT\ThePostGrid\Controllers\Blocks\BlockController; |
| 4 | |
| 5 | use RT\ThePostGrid\Helpers\Fns; |
| 6 | |
| 7 | //phpcs:disable WordPressVIPMinimum.Performance.WPQueryParams.PostNotIn_exclude |
| 8 | |
| 9 | class ContentTabController { |
| 10 | |
| 11 | /** |
| 12 | * @param $attribute_args |
| 13 | * |
| 14 | * @return mixed|void |
| 15 | */ |
| 16 | public static function get_controller( $attribute_args ) { |
| 17 | $prefix = $attribute_args['prefix']; |
| 18 | $default_layout = $attribute_args['default_layout']; |
| 19 | |
| 20 | $content_attribute = [ |
| 21 | 'uniqueId' => [ |
| 22 | 'type' => 'string', |
| 23 | 'default' => '', |
| 24 | ], |
| 25 | |
| 26 | 'preview' => [ |
| 27 | 'type' => 'boolean', |
| 28 | 'default' => false, |
| 29 | ], |
| 30 | |
| 31 | 'prefix' => [ |
| 32 | 'type' => 'string', |
| 33 | 'default' => $prefix, |
| 34 | ], |
| 35 | |
| 36 | 'offset_img_position' => [ |
| 37 | 'type' => 'string', |
| 38 | 'default' => 'offset-image-left', |
| 39 | ], |
| 40 | |
| 41 | 'is_builder' => [ |
| 42 | 'type' => 'string', |
| 43 | 'default' => '', |
| 44 | ], |
| 45 | |
| 46 | // Layouts |
| 47 | |
| 48 | 'query_change' => [ |
| 49 | 'type' => 'boolean', |
| 50 | 'default' => false, |
| 51 | ], |
| 52 | |
| 53 | $prefix . '_layout' => [ |
| 54 | 'type' => 'string', |
| 55 | 'default' => $default_layout, |
| 56 | ], |
| 57 | |
| 58 | 'middle_border' => [ |
| 59 | 'type' => 'string', |
| 60 | 'default' => 'no', |
| 61 | ], |
| 62 | |
| 63 | 'grid_column' => [ |
| 64 | 'type' => 'object', |
| 65 | 'default' => (object) [ |
| 66 | 'lg' => '', |
| 67 | 'md' => '', |
| 68 | 'sm' => '', |
| 69 | ], |
| 70 | ], |
| 71 | |
| 72 | 'block_primary_color' => [ |
| 73 | 'type' => 'string', |
| 74 | 'default' => '', |
| 75 | 'style' => [ |
| 76 | (object) [ |
| 77 | 'selector' => '{{RTTPG}} .tpg-el-main-wrapper {--tpg-primary-color: {{block_primary_color}}; }', |
| 78 | ], |
| 79 | ], |
| 80 | ], |
| 81 | |
| 82 | 'block_secondary_color' => [ |
| 83 | 'type' => 'string', |
| 84 | 'default' => '', |
| 85 | 'style' => [ |
| 86 | (object) [ |
| 87 | 'selector' => '{{RTTPG}} .tpg-el-main-wrapper {--tpg-secondary-color: {{block_secondary_color}}; }', |
| 88 | ], |
| 89 | ], |
| 90 | ], |
| 91 | |
| 92 | 'grid_layout_style' => [ |
| 93 | 'type' => 'string', |
| 94 | 'default' => 'tpg-even', |
| 95 | ], |
| 96 | |
| 97 | 'list_layout_alignment' => [ |
| 98 | 'type' => 'string', |
| 99 | 'default' => '', |
| 100 | 'style' => [ |
| 101 | (object) [ |
| 102 | 'selector' => '{{RTTPG}} .tpg-el-main-wrapper .list-behaviour .rt-holder .rt-el-content-wrapper {align-items: {{list_layout_alignment}}; }', |
| 103 | ], |
| 104 | ], |
| 105 | ], |
| 106 | |
| 107 | 'list_flex_direction' => [ |
| 108 | 'type' => 'string', |
| 109 | 'default' => '', |
| 110 | 'style' => [ |
| 111 | (object) [ |
| 112 | 'selector' => '{{RTTPG}} .tpg-el-main-wrapper .list-behaviour .rt-holder .rt-el-content-wrapper {flex-direction: {{list_flex_direction}}; }', |
| 113 | ], |
| 114 | ], |
| 115 | ], |
| 116 | |
| 117 | 'main_wrapper_hover_tab' => [ |
| 118 | 'type' => 'string', |
| 119 | 'default' => 'normal', |
| 120 | ], |
| 121 | |
| 122 | 'grid_offset_col_width' => [ |
| 123 | 'type' => 'string', |
| 124 | 'default' => '', |
| 125 | ], |
| 126 | |
| 127 | 'full_wrapper_align' => [ |
| 128 | 'type' => 'object', |
| 129 | 'default' => [], |
| 130 | 'style' => [ |
| 131 | (object) [ |
| 132 | 'selector' => '{{RTTPG}} .tpg-post-holder div {text-align: {{full_wrapper_align}}; } |
| 133 | {{RTTPG}} .rt-tpg-container .rt-el-post-meta {justify-content: {{full_wrapper_align}}; }', |
| 134 | ], |
| 135 | ], |
| 136 | ], |
| 137 | |
| 138 | // Query Build. |
| 139 | |
| 140 | 'show_title' => [ |
| 141 | 'type' => 'string', |
| 142 | 'default' => '', |
| 143 | ], |
| 144 | |
| 145 | 'multiple_post_type' => [ |
| 146 | 'type' => 'string', |
| 147 | 'default' => '', |
| 148 | ], |
| 149 | |
| 150 | 'post_type' => [ |
| 151 | 'type' => 'string', |
| 152 | 'default' => 'post', |
| 153 | ], |
| 154 | |
| 155 | 'post_types' => [ |
| 156 | 'type' => 'array', |
| 157 | 'default' => [], |
| 158 | ], |
| 159 | |
| 160 | 'post_id' => [ |
| 161 | 'type' => 'string', |
| 162 | 'default' => '', |
| 163 | ], |
| 164 | |
| 165 | 'exclude' => [ |
| 166 | 'type' => 'string', |
| 167 | 'default' => '', |
| 168 | ], |
| 169 | |
| 170 | 'post_limit' => [ |
| 171 | 'type' => 'string', |
| 172 | 'default' => '', |
| 173 | ], |
| 174 | |
| 175 | 'offset' => [ |
| 176 | 'type' => 'string', |
| 177 | 'default' => '', |
| 178 | ], |
| 179 | |
| 180 | 'instant_query' => [ |
| 181 | 'type' => 'string', |
| 182 | 'default' => '', |
| 183 | ], |
| 184 | |
| 185 | // Query Advance Filter give below |
| 186 | |
| 187 | 'taxonomy_lists' => [ |
| 188 | 'type' => 'object', |
| 189 | 'default' => [], |
| 190 | ], |
| 191 | |
| 192 | 'author' => [ |
| 193 | 'type' => 'string', |
| 194 | 'default' => '', |
| 195 | ], |
| 196 | |
| 197 | 'post_keyword' => [ |
| 198 | 'type' => 'string', |
| 199 | 'default' => '', |
| 200 | ], |
| 201 | |
| 202 | 'relation' => [ |
| 203 | 'type' => 'string', |
| 204 | 'default' => 'OR', |
| 205 | ], |
| 206 | |
| 207 | 'start_date' => [ |
| 208 | 'type' => 'string', |
| 209 | 'default' => '', |
| 210 | ], |
| 211 | 'end_date' => [ |
| 212 | 'type' => 'string', |
| 213 | 'default' => '', |
| 214 | ], |
| 215 | |
| 216 | 'orderby' => [ |
| 217 | 'type' => 'string', |
| 218 | 'default' => 'date', |
| 219 | ], |
| 220 | |
| 221 | 'order' => [ |
| 222 | 'type' => 'string', |
| 223 | 'default' => 'desc', |
| 224 | ], |
| 225 | |
| 226 | 'ignore_sticky_posts' => [ |
| 227 | 'type' => 'string', |
| 228 | 'default' => '', |
| 229 | ], |
| 230 | |
| 231 | 'no_posts_found_text' => [ |
| 232 | 'type' => 'string', |
| 233 | 'default' => 'No posts found.', |
| 234 | ], |
| 235 | |
| 236 | // Front-end Filter Settings. |
| 237 | |
| 238 | 'multiple_taxonomy' => [ |
| 239 | 'type' => 'string', |
| 240 | 'default' => '', |
| 241 | ], |
| 242 | |
| 243 | 'show_taxonomy_filter' => [ |
| 244 | 'type' => 'string', |
| 245 | 'default' => '', |
| 246 | ], |
| 247 | |
| 248 | 'show_author_filter' => [ |
| 249 | 'type' => 'string', |
| 250 | 'default' => '', |
| 251 | ], |
| 252 | |
| 253 | 'show_order_by' => [ |
| 254 | 'type' => 'string', |
| 255 | 'default' => '', |
| 256 | ], |
| 257 | |
| 258 | 'show_sort_order' => [ |
| 259 | 'type' => 'string', |
| 260 | 'default' => '', |
| 261 | ], |
| 262 | |
| 263 | 'show_search' => [ |
| 264 | 'type' => 'string', |
| 265 | 'default' => '', |
| 266 | ], |
| 267 | |
| 268 | 'search_by' => [ |
| 269 | 'type' => 'string', |
| 270 | 'default' => 'all_content', |
| 271 | ], |
| 272 | |
| 273 | 'filter_type' => [ |
| 274 | 'type' => 'string', |
| 275 | 'default' => 'dropdown', |
| 276 | ], |
| 277 | |
| 278 | 'filter_taxonomy' => [ |
| 279 | 'type' => 'string', |
| 280 | 'default' => 'category', |
| 281 | ], |
| 282 | |
| 283 | 'filter_taxonomies' => [ |
| 284 | 'type' => 'array', |
| 285 | 'default' => [], |
| 286 | ], |
| 287 | |
| 288 | 'filter_btn_style' => [ |
| 289 | 'type' => 'string', |
| 290 | 'default' => 'default', |
| 291 | ], |
| 292 | |
| 293 | 'filter_btn_item_per_page' => [ |
| 294 | 'type' => 'string', |
| 295 | 'default' => 'auto', |
| 296 | ], |
| 297 | |
| 298 | 'filter_post_count' => [ |
| 299 | 'type' => 'string', |
| 300 | 'default' => 'no', |
| 301 | ], |
| 302 | |
| 303 | 'tgp_filter_taxonomy_hierarchical' => [ |
| 304 | 'type' => 'string', |
| 305 | 'default' => 'yes', |
| 306 | ], |
| 307 | |
| 308 | 'tpg_hide_all_button' => [ |
| 309 | 'type' => 'string', |
| 310 | 'default' => 'yes', |
| 311 | ], |
| 312 | |
| 313 | 'tax_filter_all_text' => [ |
| 314 | 'type' => 'string', |
| 315 | 'default' => '', |
| 316 | ], |
| 317 | |
| 318 | 'custom_taxonomy_order' => [ |
| 319 | 'type' => 'string', |
| 320 | 'default' => 'yes', |
| 321 | ], |
| 322 | |
| 323 | 'author_filter_all_text' => [ |
| 324 | 'type' => 'string', |
| 325 | 'default' => '', |
| 326 | ], |
| 327 | |
| 328 | // Pagination |
| 329 | |
| 330 | 'show_pagination' => [ |
| 331 | 'type' => 'string', |
| 332 | 'default' => '', |
| 333 | ], |
| 334 | |
| 335 | 'page' => [ |
| 336 | 'type' => 'number', |
| 337 | 'default' => 1, |
| 338 | ], |
| 339 | |
| 340 | 'display_per_page' => [ |
| 341 | 'type' => 'string', |
| 342 | 'default' => '', |
| 343 | ], |
| 344 | |
| 345 | 'pagination_type' => [ |
| 346 | 'type' => 'string', |
| 347 | 'default' => 'pagination', |
| 348 | ], |
| 349 | |
| 350 | 'ajax_pagination_type' => [ |
| 351 | 'type' => 'string', |
| 352 | 'default' => '', |
| 353 | ], |
| 354 | |
| 355 | 'load_more_button_text' => [ |
| 356 | 'type' => 'string', |
| 357 | 'default' => 'Load More', |
| 358 | ], |
| 359 | |
| 360 | // Links |
| 361 | |
| 362 | 'post_link_type' => [ |
| 363 | 'type' => 'string', |
| 364 | 'default' => 'default', |
| 365 | ], |
| 366 | |
| 367 | 'link_target' => [ |
| 368 | 'type' => 'string', |
| 369 | 'default' => '_self', |
| 370 | ], |
| 371 | |
| 372 | 'is_thumb_linked' => [ |
| 373 | 'type' => 'string', |
| 374 | 'default' => 'yes', |
| 375 | ], |
| 376 | |
| 377 | 'pagination_btn_position' => [ |
| 378 | 'type' => 'string', |
| 379 | 'default' => '', |
| 380 | 'style' => [ |
| 381 | (object) [ |
| 382 | 'selector' => '{{RTTPG}} .rt-pagination-wrap {position: {{pagination_btn_position}};margin:0;}', |
| 383 | ], |
| 384 | ], |
| 385 | ], |
| 386 | |
| 387 | 'pagination_pos_val' => [ |
| 388 | 'type' => 'object', |
| 389 | 'default' => (object) [ |
| 390 | 'lg' => '', |
| 391 | 'md' => '', |
| 392 | 'sm' => '', |
| 393 | ], |
| 394 | 'style' => [ |
| 395 | (object) [ |
| 396 | 'selector' => '{{RTTPG}} .rt-pagination-wrap{top:{{pagination_pos_val}};}', |
| 397 | ], |
| 398 | ], |
| 399 | ], |
| 400 | |
| 401 | 'pagination_pos_val_left' => [ |
| 402 | 'type' => 'object', |
| 403 | 'default' => (object) [ |
| 404 | 'lg' => '', |
| 405 | 'md' => '', |
| 406 | 'sm' => '', |
| 407 | ], |
| 408 | 'style' => [ |
| 409 | (object) [ |
| 410 | 'selector' => '{{RTTPG}} .rt-pagination-wrap{left:{{pagination_pos_val_left}};}', |
| 411 | ], |
| 412 | ], |
| 413 | ], |
| 414 | |
| 415 | 'pagination_btn_space_btween' => [ |
| 416 | 'type' => 'string', |
| 417 | 'default' => '', |
| 418 | ], |
| 419 | ]; |
| 420 | |
| 421 | $post_types = Fns::get_post_types(); |
| 422 | |
| 423 | // Field Selections |
| 424 | |
| 425 | $cf = Fns::is_acf(); |
| 426 | if ( $cf && rtTPG()->hasPro() ) { |
| 427 | $content_attribute['show_acf'] = [ |
| 428 | 'type' => 'string', |
| 429 | 'default' => '', |
| 430 | ]; |
| 431 | |
| 432 | foreach ( $post_types as $post_type => $post_type_title ) { |
| 433 | $get_acf_field = Fns::get_groups_by_post_type( $post_type ); |
| 434 | $selected_acf_id = ''; |
| 435 | if ( ! empty( $get_acf_field ) && is_array( $get_acf_field ) ) { |
| 436 | $selected_acf_id = array_key_first( $get_acf_field ); |
| 437 | } |
| 438 | |
| 439 | $content_attribute[ $post_type . '_cf_group' ] = [ |
| 440 | 'type' => 'string', |
| 441 | 'default' => '', |
| 442 | ]; |
| 443 | } |
| 444 | |
| 445 | $content_attribute['cf_hide_empty_value'] = [ |
| 446 | 'type' => 'string', |
| 447 | 'default' => 'yes', |
| 448 | ]; |
| 449 | $content_attribute['cf_hide_group_title'] = [ |
| 450 | 'type' => 'string', |
| 451 | 'default' => 'yes', |
| 452 | ]; |
| 453 | $content_attribute['cf_show_only_value'] = [ |
| 454 | 'type' => 'string', |
| 455 | 'default' => 'yes', |
| 456 | ]; |
| 457 | } |
| 458 | |
| 459 | return apply_filters( 'rttpg_guten_content_attribute', $content_attribute ); |
| 460 | } |
| 461 | |
| 462 | } |
| 463 |