Function Reference: geodir_show_detail_page_tabs
Summary
The main function responsible for displaying tabs in frontend detail page.
Global Values
- $post
- (object) (required) The current post object.
- Default: None
- $post_images
- (array) (required) List of images attached to the post.
- Default: None
- $video
- (string) (required) The video embed content.
- Default: None
- $special_offers
- (string) (required) Special offers content.
- Default: None
- $related_listing
- (string) (required) Related listing html.
- Default: None
- $geodir_post_detail_fields
- (string) (required) Detail field html.
- Default: None
Package
GeoDirectory
Change Log
Since: 1.0.0
Actions
‘geodir_before_tab_list’ [Line: 1637]
‘geodir_before_tab_content’ [Line: 1677]
‘geodir_before_.$tab_index._tab_content’ [Line: 1687]
‘geodir_after_tab_content’ [Line: 1765]
‘geodir_after_.$tab_index._tab_content’ [Line: 1775]
‘geodir_after_tab_list’ [Line: 1793]
‘geodir_add_tab_content’ [Line: 1810]
Filters
‘geodir_tab_list_title’ [Line: 1666]
‘geodir_modify_.$detail_page_tab[tab_content]._tab_content’ [Line: 1783]
Source File
geodir_show_detail_page_tabs() is located in geodirectory-functions/custom_functions.php [Line: 1443]
Source Code
function geodir_show_detail_page_tabs() { global $post, $post_images, $video, $special_offers, $related_listing, $geodir_post_detail_fields, $preview; $post_id = ! empty( $post ) && isset( $post->ID ) ? (int) $post->ID : 0; $request_post_id = ! empty( $_REQUEST['p'] ) ? (int) $_REQUEST['p'] : 0; $is_backend_preview = ( is_single() && ! empty( $_REQUEST['post_type'] ) && ! empty( $_REQUEST['preview'] ) && ! empty( $_REQUEST['p'] ) ) && is_super_admin() ? true : false; // skip if preview from backend if ( $is_backend_preview && ! $post_id > 0 && $request_post_id > 0 ) { $post = geodir_get_post_info( $request_post_id ); setup_postdata( $post ); } $geodir_post_detail_fields = geodir_show_listing_info( 'moreinfo' ); $package_info = geodir_post_package_info(array(), $post, (!empty($post->post_type) ? $post->post_type : '')); $image_limit = ''; if (defined('GEODIRPAYMENT_VERSION') && !empty($package_info) && isset($package_info->image_limit) && $package_info->image_limit !== '') { $image_limit = (int)$package_info->image_limit; } if ( geodir_is_page( 'detail' ) ) { $video = geodir_get_video( $post->ID ); $special_offers = geodir_get_special_offers( $post->ID ); $related_listing_array = array(); if ( get_option( 'geodir_add_related_listing_posttypes' ) ) { $related_listing_array = get_option( 'geodir_add_related_listing_posttypes' ); } $excluded_tabs = get_option( 'geodir_detail_page_tabs_excluded' ); if ( ! $excluded_tabs ) { $excluded_tabs = array(); } $related_listing = ''; if ( in_array( $post->post_type, $related_listing_array ) && ! in_array( 'related_listing', $excluded_tabs ) ) { $request = array( 'post_number' => get_option( 'geodir_related_post_count' ), 'relate_to' => get_option( 'geodir_related_post_relate_to' ), 'layout' => get_option( 'geodir_related_post_listing_view' ), 'add_location_filter' => get_option( 'geodir_related_post_location_filter' ), 'list_sort' => get_option( 'geodir_related_post_sortby' ), 'character_count' => get_option( 'geodir_related_post_excerpt' ) ); if ( $post->post_type == 'gd_event' && defined( 'GDEVENTS_VERSION' ) ) { $related_listing = geodir_get_detail_page_related_events( $request ); } else { $related_listing = geodir_related_posts_display( $request ); } } $post_images = geodir_get_images( $post->ID, 'thumbnail' ); $thumb_image = ''; if ( ! empty( $post_images ) ) { $count = 1; foreach ( $post_images as $image ) { if ($image_limit !== '' && $count > $image_limit) { break; } $caption = ( ! empty( $image->caption ) ) ? $image->caption : ''; $thumb_image .= ''; $thumb_image .= geodir_show_image( $image, 'thumbnail', true, false ); $thumb_image .= ''; $count++; } } $map_args = array(); $map_args['map_canvas_name'] = 'detail_page_map_canvas'; $map_args['width'] = '600'; $map_args['height'] = '300'; if ( $post->post_mapzoom ) { $map_args['zoom'] = '' . $post->post_mapzoom . ''; } $map_args['autozoom'] = false; $map_args['scrollwheel'] = ( get_option( 'geodir_add_listing_mouse_scroll' ) ) ? 0 : 1; $map_args['child_collapse'] = '0'; $map_args['enable_cat_filters'] = false; $map_args['enable_text_search'] = false; $map_args['enable_post_type_filters'] = false; $map_args['enable_location_filters'] = false; $map_args['enable_jason_on_load'] = true; $map_args['enable_map_direction'] = true; $map_args['map_class_name'] = 'geodir-map-detail-page'; $map_args['maptype'] = ( ! empty( $post->post_mapview ) ) ? $post->post_mapview : 'ROADMAP'; } else if ( geodir_is_page( 'preview' ) ) { $video = isset( $post->geodir_video ) ? $post->geodir_video : ''; $special_offers = isset( $post->geodir_special_offers ) ? $post->geodir_special_offers : ''; if ( isset( $post->post_images ) ) { $post->post_images = trim( $post->post_images, "," ); } if ( isset( $post->post_images ) && ! empty( $post->post_images ) ) { $post_images = explode( ",", $post->post_images ); } $thumb_image = ''; if ( ! empty( $post_images ) ) { $count = 1; foreach ( $post_images as $image ) { if ( $image != '' ) { if ($image_limit !== '' && $count > $image_limit) { break; } $thumb_image .= ''; $thumb_image .= geodir_show_image( array( 'src' => $image ), 'thumbnail', true, false ); $thumb_image .= ''; $count++; } } } global $map_jason; $marker_json = $post->marker_json != '' ? json_decode( $post->marker_json, true ) : array(); $marker_icon = ( ! empty( $marker_json ) && ! empty( $marker_json['i'] ) ) ? $marker_json['i'] : ''; $icon_size = geodir_get_marker_size( $marker_icon ); $marker_json['w'] = $icon_size['w']; $marker_json['h'] = $icon_size['h']; $map_jason[] = json_encode( $marker_json ); $address_latitude = isset( $post->post_latitude ) ? $post->post_latitude : ''; $address_longitude = isset( $post->post_longitude ) ? $post->post_longitude : ''; $mapview = isset( $post->post_mapview ) ? $post->post_mapview : ''; $mapzoom = isset( $post->post_mapzoom ) ? $post->post_mapzoom : ''; if ( ! $mapzoom ) { $mapzoom = 12; } $map_args = array(); $map_args['map_canvas_name'] = 'preview_map_canvas'; $map_args['width'] = '950'; $map_args['height'] = '300'; $map_args['child_collapse'] = '0'; $map_args['maptype'] = $mapview; $map_args['autozoom'] = false; $map_args['zoom'] = "$mapzoom"; $map_args['latitude'] = $address_latitude; $map_args['longitude'] = $address_longitude; $map_args['enable_cat_filters'] = false; $map_args['enable_text_search'] = false; $map_args['enable_post_type_filters'] = false; $map_args['enable_location_filters'] = false; $map_args['enable_jason_on_load'] = true; $map_args['enable_map_direction'] = true; $map_args['map_class_name'] = 'geodir-map-preview-page'; } $arr_detail_page_tabs = geodir_detail_page_tabs_list();// get this sooner so we can get the active tab for the user $active_tab = ''; $active_tab_name = ''; $default_tab = ''; $default_tab_name = ''; foreach ( $arr_detail_page_tabs as $tab_index => $tabs ) { if ( isset( $tabs['is_active_tab'] ) && $tabs['is_active_tab'] && ! empty( $tabs['is_display'] ) && isset( $tabs['heading_text'] ) && $tabs['heading_text'] ) { $active_tab = $tab_index; $active_tab_name = __( $tabs['heading_text'], 'geodirectory' ); } if ( $default_tab === '' && ! empty( $tabs['is_display'] ) && ! empty( $tabs['heading_text'] ) ) { $default_tab = $tab_index; $default_tab_name = __( $tabs['heading_text'], 'geodirectory' ); } } if ( $active_tab === '' && $default_tab !== '' ) { // Make first tab as a active tab if not any tab is active. if ( isset( $arr_detail_page_tabs[ $active_tab ] ) && isset( $arr_detail_page_tabs[ $active_tab ]['is_active_tab'] ) ) { $arr_detail_page_tabs[ $active_tab ]['is_active_tab'] = false; } $arr_detail_page_tabs[ $default_tab ]['is_active_tab'] = true; $active_tab = $default_tab; $active_tab_name = $default_tab_name; } $tab_list = ( get_option( 'geodir_disable_tabs', false ) ) ? true : false; ?>$detail_page_tab ) { if ( $detail_page_tab['is_display'] ) { if ( ! $tab_list ) { ?>
- class="geodir-tab-active" >
' . __( $detail_page_tab['heading_text'], 'geodirectory' ) . '
'; /** * Filter the tab list title html. * * @since 1.6.1 * * @param string $tab_title The html for the tab title. * @param string $tab_index The tab index type. * @param array $detail_page_tab The array of values including title text. */ echo apply_filters( 'geodir_tab_list_title', $tab_title, $tab_index, $detail_page_tab ); } ?> post_desc ) ); } /** * Called after the listing description content on the details page tab. * * @since 1.0.0 */ do_action( 'geodir_after_description_on_listing_detail' ); break; case 'post_info': echo $geodir_post_detail_fields; break; case 'post_images': echo $thumb_image; break; case 'post_video': // some browsers hide $_POST data if used for embeds so we replace with a placeholder if ( $preview ) { if ( $video ) { echo " "; } } else { // stop payment manager filtering content length $filter_priority = has_filter( 'the_content', 'geodir_payments_the_content' ); if ( false !== $filter_priority ) { remove_filter( 'the_content', 'geodir_payments_the_content', $filter_priority ); } /** This action is documented in geodirectory_template_actions.php */ echo apply_filters( 'the_content', stripslashes( $video ) );// we apply the_content filter so oembed works also; if ( false !== $filter_priority ) { add_filter( 'the_content', 'geodir_payments_the_content', $filter_priority ); } } break; case 'special_offers': echo apply_filters( 'gd_special_offers_content', wpautop( stripslashes( $special_offers ) ) ); break; case 'post_map': geodir_draw_map( $map_args ); break; case 'reviews': comments_template(); break; case 'related_listing': echo $related_listing; break; default: { if ( ( isset( $post->{$tab_index} ) || ( ! isset( $post->{$tab_index} ) && ( strpos( $tab_index, 'gd_tab_' ) !== false || $tab_index == 'link_business' ) ) ) && ! empty( $detail_page_tab['tab_content'] ) ) { echo $detail_page_tab['tab_content']; } } break; } /** * Called after the details tab content is output per tab. * * @since 1.0.0 */ do_action( 'geodir_after_tab_content', $tab_index ); /** * Called after the details tab content is output per tab. * * Uses dynamic hook name: geodir_after_$tab_index_tab_content * * @since 1.0.0 * @todo do we need this if we have the hook above? 'geodir_after_tab_content' */ do_action( 'geodir_after_' . $tab_index . '_tab_content' ); ?>