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