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