HEX
Server: Apache
System: Linux pdx1-shared-a1-31 6.6.104-grsec-jammy+ #3 SMP Tue Sep 16 00:28:11 UTC 2025 x86_64
User: dh_5jabqq (6436002)
PHP: 8.2.29
Disabled: NONE
Upload Files
File: /home/dh_5jabqq/bermudashipwreckarchive.com/wp-content/themes/loquet/includes/schema.php
<?php
/*======
*
* Schema
*
======*/
if( function_exists( 'rwmb_meta' ) ) {

	if( !function_exists( 'loquet_schema' ) ) {

		function loquet_schema() {

			$output = '' ;

			if( is_singular( 'museum' ) or is_singular( 'exhibition' ) or is_singular( 'collection' ) or is_singular( 'magazine' ) ) {

				$output .= '<script type="application/ld+json">';

					if( is_singular( 'museum' ) ) {

						/* Meta fields */
						$museum_establishment_date = rwmb_meta( 'loquet-museum-establishment-date', '', get_the_ID() );
						$museum_collection_size = rwmb_meta( 'loquet-museum-collection-size', '', get_the_ID() );
						$museum_area = rwmb_meta( 'loquet-museum-area', '', get_the_ID() );
						$museum_visitors = rwmb_meta( 'loquet-museum-visitors', '', get_the_ID() );
						$museum_opening_hours = rwmb_meta( 'loquet-museum-opening-hours', '', get_the_ID() );
						$museum_opening_hours_weekdays = rwmb_meta( 'loquet-museum-opening-hours-weekdays', '', get_the_ID() );
						$museum_opening_hours_saturday = rwmb_meta( 'loquet-museum-opening-hours-saturday', '', get_the_ID() );
						$museum_opening_hours_sunday = rwmb_meta( 'loquet-museum-opening-hours-sunday', '', get_the_ID() );
						$museum_accessible_for_free = rwmb_meta( 'loquet-museum-accessible-for-free', '', get_the_ID() );
						$museum_public_access = rwmb_meta( 'loquet-museum-public-access', '', get_the_ID() );
						$museum_smoking_allowed = rwmb_meta( 'loquet-museum-smoking-allowed', '', get_the_ID() );
						$museum_maximum_attendee_capacity = rwmb_meta( 'loquet-museum-maximum-attendee-capacity', '', get_the_ID() );
						$museum_logo = rwmb_meta( 'loquet-museum-logo', '', get_the_ID() );
						$museum_photos = rwmb_meta( 'loquet-museum-photos', '', get_the_ID() );
						$museum_video = rwmb_meta( 'loquet-museum-video', '', get_the_ID() );
						$museum_videos = rwmb_meta( 'loquet-museum-videos', '', get_the_ID() );
						$museum_address = rwmb_meta( 'loquet-museum-address', '', get_the_ID() );
						$museum_postal_code = rwmb_meta( 'loquet-museum-postal-code', '', get_the_ID() );
						$museum_map_view = rwmb_get_value( 'loquet-museum-map-view', '', get_the_ID() );
						$museum_phone = rwmb_meta( 'loquet-museum-phone', '', get_the_ID() );
						$museum_social_media_sites = rwmb_meta( 'loquet-museum-social-media-sites', '', get_the_ID() );
						$museum_sponsors = rwmb_meta( 'loquet-museum-sponsors', '', get_the_ID() );

						/* Taxonomies */
						$categories = wp_get_post_terms( get_the_ID(), 'museum-category' );
						$countries = wp_get_post_terms( get_the_ID(), 'museum-country' );
						$curators = wp_get_post_terms( get_the_ID(), 'museum-curator' );
						$directors = wp_get_post_terms( get_the_ID(), 'museum-director' );
						$tags = wp_get_post_terms( get_the_ID(), 'museum-tag' );

						/* HTML Output */
						$output .= '{';

							$output .= '"@context": "https://schema.org",';

							/* Type */
							$output .= '"@type": "Museum",'; 

							/* Title */
							$output .= '"name": "' . get_the_title() . '",';

							/* Summary or description */
							if( !empty( get_the_excerpt() ) ) {

								$output .= '"description": "' . get_the_excerpt() . '",';

							}

							/* Additional Property */
							if( !empty( $museum_establishment_date ) or !empty( $museum_collection_size ) or !empty( $museum_area ) or !empty( $museum_visitors ) ) {

								$output .= '"additionalProperty": [';

									if( !empty( $museum_establishment_date ) ) {

										$output .= '{';
											$output .= '"name": "' . esc_html__( 'Establishment Date', 'loquet' ) . '",';
											$output .= '"value": "' . esc_attr( $museum_establishment_date ) . '"';
										$output .= '},';

									}

									if( !empty( $museum_collection_size ) ) {

										$output .= '{';
											$output .= '"name": "' . esc_html__( 'Collection Size', 'loquet' ) . '",';
											$output .= '"value": "' . esc_attr( $museum_collection_size ) . '"';
										$output .= '},';

									}

									if( !empty( $museum_area ) ) {

										$output .= '{';
											$output .= '"name": "' . esc_html__( 'Area', 'loquet' ) . '",';
											$output .= '"value": "' . esc_attr( $museum_area ) . '"';
										$output .= '},';

									}

									if( !empty( $museum_visitors ) ) {

										$output .= '{';
											$output .= '"name": "' . esc_html__( 'Visitors', 'loquet' ) . '",';
											$output .= '"value": "' . esc_attr( $museum_visitors ) . '"';
										$output .= '},';

									}


									$output .= '{';
										$output .= '"name": "' . esc_html__( 'Page Created Date', 'loquet' ) . '",';
										$output .= '"value": "' . get_the_date() . '"';
									$output .= '}';

								$output .= '],';


							}

							/* Opening Hours */
							if( !empty( $museum_opening_hours_weekdays ) or !empty( $museum_opening_hours_saturday ) or !empty( $museum_opening_hours_sunday ) ) {

								$output .= '"openingHours":[';

									if( !empty( $museum_opening_hours_weekdays ) ) {

										$output .= '"Mo-Fr ' . esc_attr( $museum_opening_hours_weekdays ) . '"';

									}

									if( !empty( $museum_opening_hours_weekdays ) and !empty( $museum_opening_hours_saturday ) ) {

										$output .= ',';

									}

									if( !empty( $museum_opening_hours_weekdays ) and empty( $museum_opening_hours_saturday ) and !empty( $museum_opening_hours_sunday ) ) {

										$output .= ',';

									}

									if( !empty( $museum_opening_hours_saturday ) ) {

										$output .= '"Sa ' . esc_attr( $museum_opening_hours_saturday ) . '"';

									}

									if( !empty( $museum_opening_hours_saturday ) and !empty( $museum_opening_hours_sunday ) ) {

										$output .= ',';

									}

									if( !empty( $museum_opening_hours_sunday ) ) {

										$output .= '"Su ' . esc_attr( $museum_opening_hours_sunday ) . '"';

									}

								$output .= '],';

							}

							/* Address */
							if( !empty( $museum_address ) ) {

								$output .= '"address": {';
									$output .= '"@type": "PostalAddress",';

									if( !empty( $museum_postal_code ) ) {

										$output .= '"postalCode": "' . esc_attr( $museum_postal_code ) . '",';

									}

									$output .= '"streetAddress": "' . esc_attr( $museum_address ) . '"';
								$output .= '},';

							}

							/* Geo */
							if( !empty( $museum_address ) ) {

								if( !empty( $museum_map_view ) ) {

									if( !empty( $museum_map_view['latitude'] ) and !empty( $museum_map_view['longitude'] ) ) {

										$output .= '"geo": {';
											$output .= '"@type": "GeoCoordinates",';
											$output .= '"latitude": "' . esc_attr( $museum_map_view['latitude'] ) . '",';
											$output .= '"longitude": "' . esc_attr( $museum_map_view['longitude'] ) . '"';
										$output .= '},';

									}

								}

							}

							/* Has Map */
							if( !empty( $museum_address ) ) {

								$output .= '"hasMap": "' . esc_url( 'https://maps.google.com/?q=' . esc_attr( $museum_address ) ) . '",';

							}

							/* is Accessible For Free */
							if( !empty( $museum_accessible_for_free ) and $museum_accessible_for_free == "1" ) {

								$output .= '"isAccessibleForFree": "true",';

							}

							/* Keywords (Tags) */
							if( !empty( $tags ) ) {

								$tag_last = end( $tags );

								$output .= '"keywords": [';

								foreach( $tags as $tag ) {

									if( !empty( $tag ) ) {

										if( !empty( $tag->name ) ) {

											$output .= '"';
												$output .= esc_attr( $tag->name );
											$output .= '"';

											if ( $tag !== $tag_last ) {
												
												$output .= ',';

											}

										}

									}

								}

								$output .= '],';

							}

							/* Logo */
							if( !empty( $museum_logo ) ) {

								if( !empty( $museum_logo ) ) {

									foreach( $museum_logo as $logo_item ) {

										if( !empty( $logo_item ) ) {

											$output .= '"logo": "' . wp_get_attachment_image_src( esc_attr( $logo_item["ID"] ), 'full' )[0] . '",';

										}

									}

								}

							}

							/* Maximum Attendee Capacity */
							if( !empty( $museum_maximum_attendee_capacity ) ) {

								$output .= '"maximumAttendeeCapacity": "' . esc_attr( $museum_maximum_attendee_capacity ) . '",';

							}

							/* Photo */
							if( !empty( $museum_photos ) ) {

								$photo_last = end( $museum_photos );

								$output .= '"photo": [';

									foreach( $museum_photos as $photo ) {

										if( !empty( $photo ) ) {

											if( !empty( $photo ) ) {

												$output .= '"' . esc_url( wp_get_attachment_image_src( esc_attr( $photo["ID"] ), 'full' )[0] ) . '"';

												if ( $photo !== $photo_last ) {
													
													$output .= ',';

												}

											}

										}

									}

								$output .= '],';

							}

							/* Public Access */
							if( !empty( $museum_public_access ) and $museum_public_access == "1" ) {

								$output .= '"publicAccess": "true",';

							}

							/* Review */
							$comment_args = array(
								'post_id' => get_the_ID(),
							);
							$comments = get_comments( $comment_args );

							if( $comments ) {

								$comment_last = end( $comments );

								$output .= '"review": [';

									foreach ( $comments as $comment ) {

										$output .= '{';
											$output .= '"@type": "Review",';

											if( !empty( $comment->comment_author ) ) {

												$output .= '"author": "' . esc_attr( $comment->comment_author ) . '",';

											}

											if( !empty( $comment->comment_content ) ) {

												$output .= '"reviewBody": "' . esc_attr( $comment->comment_content ) . '",';

											}

											$output .= '"datePublished": "' . esc_attr( $comment->comment_date ) . '"';

										$output .= '}';

										if ( $comment !== $comment_last ) {
											
											$output .= ',';

										}

									}

								$output .= '],';

							}

							/* Smoking Allowed */
							if( !empty( $museum_smoking_allowed ) and $museum_smoking_allowed == "1" ) {

								$output .= '"smokingAllowed": "true",';

							}

							/* Telephone */
							if( !empty( $museum_phone ) ) {

								$output .= '"telephone": "' . esc_attr( $museum_phone ) . '",';

							}

							/* Image URL */
							if( !empty( get_the_post_thumbnail_url( get_the_ID() ) ) ) {

								$output .= '"image": "' . get_the_post_thumbnail_url( get_the_ID(), 'full' ) . '",';

							}

							/* URL */
							$output .= '"url": "' . get_the_permalink() . '"';

						$output .= '}';

					} elseif( is_singular( 'exhibition' ) ) {

						/* Meta fields */
						$exhibition_museum = rwmb_meta( 'loquet-exhibition-museum', '', get_the_ID() );
						$exhibition_start_date = rwmb_meta( 'loquet-exhibition-start-date', '', get_the_ID() );
						$exhibition_end_date = rwmb_meta( 'loquet-exhibition-end-date', '', get_the_ID() );
						$exhibition_duration = rwmb_meta( 'loquet-exhibition-duration', '', get_the_ID() );
						$exhibition_accessible_for_free = rwmb_meta( 'loquet-exhibition-accessible-for-free', '', get_the_ID() );
						$exhibition_maximum_attendee_capacity = rwmb_meta( 'loquet-exhibition-maximum-attendee-capacity', '', get_the_ID() );
						$exhibition_attendance_mode = rwmb_meta( 'loquet-exhibition-attendance-mode', '', get_the_ID() );
						$exhibition_status = rwmb_meta( 'loquet-exhibition-status', '', get_the_ID() );
						$exhibition_logo = rwmb_meta( 'loquet-exhibition-logo', '', get_the_ID() );
						$exhibition_address = rwmb_meta( 'loquet-exhibition-address', '', get_the_ID() );
						$exhibition_postal_code = rwmb_meta( 'loquet-exhibition-postal-code', '', get_the_ID() );
						$exhibition_map_view = rwmb_get_value( 'loquet-exhibition-map-view', '', get_the_ID() );
						$exhibition_phone = rwmb_meta( 'loquet-exhibition-phone', '', get_the_ID() );
						$exhibition_email = rwmb_meta( 'loquet-exhibition-email', '', get_the_ID() );
						$exhibition_website = rwmb_meta( 'loquet-exhibition-website', '', get_the_ID() );
						$exhibition_sponsors = rwmb_meta( 'loquet-exhibition-sponsors', '', get_the_ID() );

						/* Taxonomies */
						$categories = wp_get_post_terms( get_the_ID(), 'exhibition-category' );
						$countries = wp_get_post_terms( get_the_ID(), 'exhibition-country' );
						$curators = wp_get_post_terms( get_the_ID(), 'exhibition-curator' );
						$tags = wp_get_post_terms( get_the_ID(), 'exhibition-tag' );

						/* HTML Output */
						$output .= '{';

							$output .= '"@context": "https://schema.org",';

							/* Type */
							$output .= '"@type": "ExhibitionEvent",'; 

							/* Title */
							$output .= '"name": "' . get_the_title() . '",';

							/* Summary or description */
							if( !empty( get_the_excerpt() ) ) {

								$output .= '"description": "' . get_the_excerpt() . '",';

							}

							/* About */
							if( !empty( wp_strip_all_tags( get_the_content() ) ) ) {

								$output .= '"about": "' . wp_strip_all_tags( get_the_content() ) . '",';

							}

							/* Duration */
							if( !empty( $exhibition_duration ) ) {

								$output .= '"duration": "' . esc_attr( $exhibition_duration ) . '",';

							}

							/* End Date */
							if( !empty( $exhibition_end_date ) ) {

								$output .= '"endDate": "' . esc_attr( $exhibition_end_date ) . '",';

							}

							/* Event Attendance Mode */
							if( $exhibition_attendance_mode == "mixed" ) {

								$output .= '"eventAttendanceMode": "mix",';

							} elseif( $exhibition_attendance_mode == "online" ) {

								$output .= '"eventAttendanceMode": "online",';

							} else {

								$output .= '"eventAttendanceMode": "offline",';

							}

							/* Event Status */
							if( $exhibition_status == "cancelled" ) {

								$output .= '"eventStatus": "EventCancelled",';

							} elseif( $exhibition_status == "postponed" ) {

								$output .= '"eventStatus": "EventPostponed",';

							} elseif( $exhibition_status == "rescheduled" ) {

								$output .= '"eventStatus": "EventRescheduled",';

							} elseif( $exhibition_status == "moved-online" ) {

								$output .= '"eventStatus": "EventMovedOnline",';

							} else {

								$output .= '"eventStatus": "EventScheduled",';

							}

							/* is Accessible For Free */
							if( !empty( $exhibition_accessible_for_free ) and $exhibition_accessible_for_free == "1" ) {

								$output .= '"isAccessibleForFree": "true",';

							}

							/* Keywords (Tags) */
							if( !empty( $tags ) ) {

								$tag_last = end( $tags );

								$output .= '"keywords": [';

								foreach( $tags as $tag ) {

									if( !empty( $tag ) ) {

										if( !empty( $tag->name ) ) {

											$output .= '"';
												$output .= esc_attr( $tag->name );
											$output .= '"';

											if ( $tag !== $tag_last ) {
												
												$output .= ',';

											}

										}

									}

								}

								$output .= '],';

							}

							/* Location */
							if( !empty( $exhibition_address ) ) {

								$output .= '"location": {';
									$output .= '"@type": "Place",';
									$output .= '"address": {';
										$output .= '"@type": "PostalAddress",';

										if( !empty( $exhibition_postal_code ) ) {

											$output .= '"postalCode": "' . esc_attr( $exhibition_postal_code ) . '",';

										}

										$output .= '"streetAddress": "' . esc_attr( $exhibition_address ) . '"';

									if( !empty( $exhibition_map_view ) ) {

										if( !empty( $exhibition_map_view['latitude'] ) and !empty( $exhibition_map_view['longitude'] ) ) {

											$output .= '},';

										} else {

											$output .= '}';

										}

									} else {

										$output .= '}';

									}

									if( !empty( $exhibition_map_view ) ) {

										if( !empty( $exhibition_map_view['latitude'] ) and !empty( $exhibition_map_view['longitude'] ) ) {

											$output .= '"geo": {';
												$output .= '"@type": "GeoCoordinates",';
												$output .= '"latitude": "' . esc_attr( $exhibition_map_view['latitude'] ) . '",';
												$output .= '"longitude": "' . esc_attr( $exhibition_map_view['longitude'] ) . '"';
											$output .= '}';

										}

									}

								$output .= '},';

							}

							/* Maximum Attendee Capacity */
							if( !empty( $exhibition_maximum_attendee_capacity ) ) {

								$output .= '"maximumAttendeeCapacity": "' . esc_attr( $exhibition_maximum_attendee_capacity ) . '",';

							}

							/* Organizer */
							if( !empty( $curators ) ) {

								$curator_last = end( $curators );

								$output .= '"organizer": [';

								foreach( $curators as $curator ) {

									if( !empty( $curator ) ) {

										if( !empty( $curator->name ) ) {

											$output .= '{';
												$output .= '"@type": "Person",';

												if( !empty( $curator->name ) ) {

													$output .= '"name": "' . esc_attr( $curator->name ) . '",';

												}

												$output .= '"url": "' . get_term_link( $curator->term_id ) . '"';

											$output .= '}';

											if ( $curator !== $curator_last ) {
												
												$output .= ',';

											}

										}

									}

								}

								$output .= '],';

							}

							/* Review */
							$comment_args = array(
								'post_id' => get_the_ID(),
							);
							$comments = get_comments( $comment_args );

							if( $comments ) {

								$comment_last = end( $comments );

								$output .= '"review": [';

									foreach ( $comments as $comment ) {

										$output .= '{';
											$output .= '"@type": "Review",';

											if( !empty( $comment->comment_author ) ) {

												$output .= '"author": {';
													$output .= '"@type": "Person",';
													$output .= '"name": "' . esc_attr( $comment->comment_author ) . '"';
												$output .= '},';

											}

											if( !empty( $comment->comment_content ) ) {

												$output .= '"reviewBody": "' . esc_attr( $comment->comment_content ) . '",';

											}

											$output .= '"datePublished": "' . esc_attr( $comment->comment_date ) . '"';

										$output .= '}';

										if ( $comment !== $comment_last ) {
											
											$output .= ',';

										}

									}

								$output .= '],';

							}

							/* Sponsor */
							if( !empty( $exhibition_sponsors ) ) {

								$sponsor_last = end( $exhibition_sponsors );

								$output .= '"sponsor": [';

									foreach( $exhibition_sponsors as $sponsor ) {

										if( !empty( $sponsor ) ) {

											if( !empty( $sponsor ) ) {

												$output .= '{';

													if( !empty( $sponsor["title"] ) ) {

														$output .= '"name": "' . esc_attr( $sponsor["title"] ) . '",';

													}

													if( !empty( $sponsor["logo"] ) ) {

														$output .= '"logo": "' . esc_url( wp_get_attachment_image_src( esc_attr( $sponsor["logo"][0] ), 'full' )[0] ) . '",';

													}

													if( !empty( $sponsor["url"] ) ) {

														$output .= '"url": "' . esc_attr( $sponsor["url"] ) . '",';

													}

													$output .= '"@type": "Organization"';

												$output .= '}';

												if ( $sponsor !== $sponsor_last ) {
													
													$output .= ',';

												}

											}

										}

									}

								$output .= '],';

							}

							/* Start Date */
							if( !empty( $exhibition_start_date ) ) {

								$output .= '"startDate": "' . esc_attr( $exhibition_start_date ) . '",';

							}

							/* Image URL */
							if( !empty( get_the_post_thumbnail_url( get_the_ID() ) ) ) {

								$output .= '"image": "' . get_the_post_thumbnail_url( get_the_ID(), 'full' ) . '",';

							}

							/* URL */
							$output .= '"url": "' . get_the_permalink() . '"';

						$output .= '}';

					} elseif( is_singular( 'collection' ) ) {

						/* Meta fields */
						$collection_size = rwmb_meta( 'loquet-collection-size', '', get_the_ID() );
						$collection_date = rwmb_meta( 'loquet-collection-date', '', get_the_ID() );
						$collection_period = rwmb_meta( 'loquet-collection-period', '', get_the_ID() );
						$collection_classification = rwmb_meta( 'loquet-collection-classification', '', get_the_ID() );
						$collection_dimensions = rwmb_meta( 'loquet-collection-dimensions', '', get_the_ID() );
						$collection_accessible_for_free = rwmb_meta( 'loquet-collection-accessible-for-free', '', get_the_ID() );
						$collection_address = rwmb_meta( 'loquet-collection-address', '', get_the_ID() );
						$collection_postal_code = rwmb_meta( 'loquet-collection-postal-code', '', get_the_ID() );
						$collection_map_view = rwmb_get_value( 'loquet-collection-map-view', '', get_the_ID() );
						$collection_sponsors = rwmb_get_value( 'loquet-collection-sponsors', '', get_the_ID() );

						/* Taxonomies */
						$categories = wp_get_post_terms( get_the_ID(), 'collection-category' );
						$curators = wp_get_post_terms( get_the_ID(), 'collection-curator' );
						$countries = wp_get_post_terms( get_the_ID(), 'collection-country' );
						$tags = wp_get_post_terms( get_the_ID(), 'collection-tag' );

						/* HTML Output */
						$output .= '{';

							$output .= '"@context": "https://schema.org",';

							/* Type */
							$output .= '"@type": "Collection",'; 

							/* Title */
							$output .= '"name": "' . get_the_title() . '",';

							/* Summary or description */
							if( !empty( get_the_excerpt() ) ) {

								$output .= '"description": "' . get_the_excerpt() . '",';
								$output .= '"abstract": "' . get_the_excerpt() . '",';

							}

							/* About */
							if( !empty( wp_strip_all_tags( get_the_content() ) ) ) {

								$output .= '"about": "' . wp_strip_all_tags( get_the_content() ) . '",';

							}

							/* Collection Size */
							if( !empty( $collection_size ) ) {

								$output .= '"collectionSize": "' . esc_attr( $collection_size ) . '",';

							}

							/* Comment */
							$comment_args = array(
								'post_id' => get_the_ID(),
							);
							$comments = get_comments( $comment_args );

							$total_comment_args = array(
								'post_id' => get_the_ID(),
								'count'   => true,
							);
							$total_comments = get_comments( $total_comment_args );

							if( $comments ) {

								$comment_last = end( $comments );

								$output .= '"comment": [';

									foreach ( $comments as $comment ) {

										$output .= '{';
											$output .= '"@type": "Comment",';

											if( !empty( $comment->comment_author ) ) {

												$output .= '"author": {';
													$output .= '"@type": "Person",';
													$output .= '"name": "' . esc_attr( $comment->comment_author ) . '"';
												$output .= '},';

											}

											if( !empty( $comment->comment_content ) ) {

												$output .= '"text": "' . esc_attr( $comment->comment_content ) . '",';

											}

											$output .= '"dateCreated": "' . esc_attr( $comment->comment_date ) . '"';

										$output .= '}';

										if ( $comment !== $comment_last ) {
											
											$output .= ',';

										}

									}

								$output .= '],';
								$output .= '"commentCount": "' . esc_attr( $total_comments ) . '",';

							}

							/* Content Location */
							if( !empty( $collection_address ) ) {

								$output .= '"contentLocation": {';
									$output .= '"@type": "Place",';
									$output .= '"address": {';
										$output .= '"@type": "PostalAddress",';

										if( !empty( $collection_postal_code ) ) {

											$output .= '"postalCode": "' . esc_attr( $collection_postal_code ) . '",';

										}

										$output .= '"streetAddress": "' . esc_attr( $collection_address ) . '"';

									if( !empty( $collection_map_view ) ) {

										if( !empty( $collection_map_view['latitude'] ) and !empty( $collection_map_view['longitude'] ) ) {

											$output .= '},';

										} else {

											$output .= '}';

										}

									} else {

										$output .= '}';

									}

									if( !empty( $collection_map_view ) ) {

										if( !empty( $collection_map_view['latitude'] ) and !empty( $collection_map_view['longitude'] ) ) {

											$output .= '"geo": {';
												$output .= '"@type": "GeoCoordinates",';
												$output .= '"latitude": "' . esc_attr( $collection_map_view['latitude'] ) . '",';
												$output .= '"longitude": "' . esc_attr( $collection_map_view['longitude'] ) . '"';
											$output .= '}';

										}

									}

								$output .= '},';

							}

							/* Country Of Origin */
							if( !empty( $countries ) ) {

								$country_last = end( $countries );

								$output .= '"countryOfOrigin": [';

								foreach( $countries as $country ) {

									if( !empty( $country ) ) {

										if( !empty( $country->name ) ) {

											$output .= '{';
												$output .= '"@type": "Country",';
												$output .= '"name": "' . esc_attr( $country->name ) . '",';
												$output .= '"url": "' . get_term_link( $country->term_id ) . '"';
											$output .= '}';

											if ( $country !== $country_last ) {
												
												$output .= ',';

											}

										}

									}

								}

								$output .= '],';

							}

							/* Creator */
							if( !empty( $curators ) ) {

								$curator_last = end( $curators );

								$output .= '"creator": [';

								foreach( $curators as $curator ) {

									if( !empty( $curator ) ) {

										if( !empty( $curator->name ) ) {

											$output .= '{';
												$output .= '"@type": "Person",';
												$output .= '"name": "' . esc_attr( $curator->name ) . '",';
												$output .= '"url": "' . get_term_link( $curator->term_id ) . '"';
											$output .= '}';

											if ( $curator !== $curator_last ) {
												
												$output .= ',';

											}

										}

									}

								}

								$output .= '],';

							}

							/* Date Created */
							if( !empty( $collection_date ) ) {

								$output .= '"dateCreated": "' . esc_attr( $collection_date ) . '",';
								$output .= '"sdDatePublished": "' . esc_attr( $collection_date ) . '",';

							}

							/* Genre */
							if( !empty( $collection_classification ) ) {

								$output .= '"genre": "' . esc_attr( $collection_classification ) . '",';

							}

							/* is Accessible For Free */
							if( !empty( $collection_accessible_for_free ) and $collection_accessible_for_free == "1" ) {

								$output .= '"isAccessibleForFree": "true",';

							}

							/* Keywords (Tags) */
							if( !empty( $tags ) ) {

								$tag_last = end( $tags );

								$output .= '"keywords": [';

								foreach( $tags as $tag ) {

									if( !empty( $tag ) ) {

										if( !empty( $tag->name ) ) {

											$output .= '"';
												$output .= esc_attr( $tag->name );
											$output .= '"';

											if ( $tag !== $tag_last ) {
												
												$output .= ',';

											}

										}

									}

								}

								$output .= '],';

							}

							/* Size */
							if( !empty( $collection_dimensions ) ) {

								$output .= '"size": "' . esc_attr( $collection_dimensions ) . '",';

							}

							/* Sponsor */
							if( !empty( $collection_sponsors ) ) {

								$sponsor_last = end( $collection_sponsors );

								$output .= '"sponsor": [';

									foreach( $collection_sponsors as $sponsor ) {

										if( !empty( $sponsor ) ) {

											if( !empty( $sponsor ) ) {

												$output .= '{';

													if( !empty( $sponsor["title"] ) ) {

														$output .= '"name": "' . esc_attr( $sponsor["title"] ) . '",';

													}

													if( !empty( $sponsor["logo"] ) ) {

														$output .= '"logo": "' . esc_url( wp_get_attachment_image_src( esc_attr( $sponsor["logo"][0] ), 'full' )[0] ) . '",';

													}

													if( !empty( $sponsor["url"] ) ) {

														$output .= '"url": "' . esc_attr( $sponsor["url"] ) . '",';

													}

													$output .= '"@type": "Organization"';

												$output .= '}';

												if ( $sponsor !== $sponsor_last ) {
													
													$output .= ',';

												}

											}

										}

									}

								$output .= '],';

							}

							/* Temporal Coverage */
							if( !empty( $collection_period ) ) {

								$output .= '"temporalCoverage": "' . esc_attr( $collection_period ) . '",';

							}

							/* Image URL */
							if( !empty( get_the_post_thumbnail_url( get_the_ID() ) ) ) {

								$output .= '"image": "' . get_the_post_thumbnail_url( get_the_ID(), 'full' ) . '",';

							}

							/* URL */
							$output .= '"url": "' . get_the_permalink() . '"';

						$output .= '}';

					} elseif( is_singular( 'magazine' ) ) {

						/* Meta fields */
						$magazine_type = rwmb_meta( 'loquet-magazine-type', '', get_the_ID() );
						$magazine_release_date = rwmb_meta( 'loquet-magazine-release-date', '', get_the_ID() );
						$magazine_end_date = rwmb_meta( 'loquet-magazine-end-date', '', get_the_ID() );
						$magazine_frequency = rwmb_meta( 'loquet-magazine-frequency', '', get_the_ID() );
						$magazine_price = rwmb_meta( 'loquet-magazine-price', '', get_the_ID() );
						$magazine_stock_status = rwmb_meta( 'loquet-magazine-stock-status', '', get_the_ID() );
						$magazine_issn = rwmb_meta( 'loquet-magazine-issn', '', get_the_ID() );
						$magazine_accessible_for_free = rwmb_meta( 'loquet-magazine-accessible-for-free', '', get_the_ID() );
						$magazine_cover = rwmb_meta( 'loquet-magazine-cover', '', get_the_ID() );
						$magazine_logo = rwmb_meta( 'loquet-magazine-logo', '', get_the_ID() );
						$magazine_address = rwmb_meta( 'loquet-magazine-address', '', get_the_ID() );
						$magazine_postal_code = rwmb_meta( 'loquet-magazine-postal-code', '', get_the_ID() );
						$magazine_map_view = rwmb_meta( 'loquet-magazine-map-view', '', get_the_ID() );
						$magazine_phone = rwmb_meta( 'loquet-magazine-phone', '', get_the_ID() );
						$magazine_email = rwmb_meta( 'loquet-magazine-email', '', get_the_ID() );

						/* Taxonomies */
						$categories = wp_get_post_terms( get_the_ID(), 'magazine-category' );
						$publishers = wp_get_post_terms( get_the_ID(), 'magazine-publisher' );
						$languages = wp_get_post_terms( get_the_ID(), 'magazine-language' );
						$tags = wp_get_post_terms( get_the_ID(), 'magazine-tag' );

						/* HTML Output */
						$output .= '{';

							$output .= '"@context": "https://schema.org",';

							/* Type */
							if( $magazine_type == "publication-issue" ) {

								$output .= '"@type": "PublicationIssue",'; 

							} elseif( $magazine_stock_status == "book" ) {

								$output .= '"@type": "Book",'; 

							} elseif( $magazine_stock_status == "newspaper" ) {

								$output .= '"@type": "Newspaper",'; 

							} else {

								$output .= '"@type": "Periodical",';

							}

							/* Title */
							$output .= '"name": "' . get_the_title() . '",';

							/* Summary or description */
							if( !empty( get_the_excerpt() ) ) {

								$output .= '"description": "' . get_the_excerpt() . '",';
								$output .= '"abstract": "' . get_the_excerpt() . '",';

							}

							/* End Date */
							if( !empty( $magazine_end_date ) ) {

								$output .= '"endDate": "' . esc_attr( $magazine_end_date ) . '",';

							}

							/* ISSN */
							if( !empty( $magazine_issn ) ) {

								$output .= '"issn": "' . esc_attr( $magazine_issn ) . '",';

							}

							/* Start Date */
							if( !empty( $magazine_release_date ) ) {

								$output .= '"startDate": "' . esc_attr( $magazine_release_date ) . '",';

							}

							/* About */
							if( !empty( wp_strip_all_tags( get_the_content() ) ) ) {

								$output .= '"about": "' . wp_strip_all_tags( get_the_content() ) . '",';

							}

							$output .= '"archivedAt": "' . get_post_type_archive_link( 'magazine' ) . '",';

							/* Comment */
							$comment_args = array(
								'post_id' => get_the_ID(),
							);
							$comments = get_comments( $comment_args );

							$total_comment_args = array(
								'post_id' => get_the_ID(),
								'count'   => true,
							);
							$total_comments = get_comments( $total_comment_args );

							if( $comments ) {

								$comment_last = end( $comments );

								$output .= '"comment": [';

									foreach ( $comments as $comment ) {

										$output .= '{';
											$output .= '"@type": "Comment",';

											if( !empty( $comment->comment_author ) ) {

												$output .= '"author": {';
													$output .= '"@type": "Person",';
													$output .= '"name": "' . esc_attr( $comment->comment_author ) . '"';
												$output .= '},';

											}

											if( !empty( $comment->comment_content ) ) {

												$output .= '"text": "' . esc_attr( $comment->comment_content ) . '",';

											}

											$output .= '"dateCreated": "' . esc_attr( $comment->comment_date ) . '"';

										$output .= '}';

										if ( $comment !== $comment_last ) {
											
											$output .= ',';

										}

									}

								$output .= '],';
								$output .= '"commentCount": "' . esc_attr( $total_comments ) . '",';

							}

							/* Content Location */
							if( !empty( $magazine_address ) ) {

								$output .= '"contentLocation": {';
									$output .= '"@type": "Place",';
									$output .= '"address": {';
										$output .= '"@type": "PostalAddress",';

										if( !empty( $magazine_postal_code ) ) {

											$output .= '"postalCode": "' . esc_attr( $magazine_postal_code ) . '",';

										}

										$output .= '"streetAddress": "' . esc_attr( $magazine_address ) . '"';

									if( !empty( $magazine_map_view ) ) {

										if( !empty( $magazine_map_view['latitude'] ) and !empty( $magazine_map_view['longitude'] ) ) {

											$output .= '},';

										} else {

											$output .= '}';

										}

									} else {

										$output .= '}';

									}

									if( !empty( $magazine_map_view ) ) {

										if( !empty( $magazine_map_view['latitude'] ) and !empty( $magazine_map_view['longitude'] ) ) {

											$output .= '"geo": {';
												$output .= '"@type": "GeoCoordinates",';
												$output .= '"latitude": "' . esc_attr( $magazine_map_view['latitude'] ) . '",';
												$output .= '"longitude": "' . esc_attr( $magazine_map_view['longitude'] ) . '"';
											$output .= '}';

										}

									}

								$output .= '},';

							}

							/* in Language */
							if( !empty( $languages ) ) {

								$language_last = end( $languages );

								$output .= '"inLanguage": [';

								foreach( $languages as $language ) {

									if( !empty( $language ) ) {

										if( !empty( $language->name ) ) {

											$output .= '"';
												$output .= esc_attr( $language->name );
											$output .= '"';

											if ( $language !== $language_last ) {
												
												$output .= ',';

											}

										}

									}

								}

								$output .= '],';

							}

							/* Publisher */
							if( !empty( $publishers ) ) {

								$publisher_last = end( $publishers );

								$output .= '"publisher": [';

								foreach( $publishers as $publisher ) {

									if( !empty( $publisher ) ) {

										if( !empty( $publisher->name ) ) {

											$output .= '{';
												$output .= '"@type": "Organization",';
												$output .= '"name": "' . esc_attr( $publisher->name ) . '",';
												$output .= '"url": "' . get_term_link( $publisher->term_id ) . '"';
											$output .= '}';

											if( $publisher !== $publisher_last ) {
												
												$output .= ',';

											}

										}

									}

								}

								$output .= '],';

							}

							/* Offer */
							if( !empty( $magazine_price ) or !empty( $magazine_stock_status ) ) {

								$output .= '"offers": {';
									$output .= '"@type": "Offer",';

									if( !empty( $magazine_price ) ) {

										$output .= '"price": "' . esc_attr( $magazine_price ) . '",';

									}

									if( !empty( $magazine_stock_status ) ) {

										if( $magazine_stock_status == "out-of-stock" ) {

											$output .= '"availability": "OutOfStock",';

										} elseif( $magazine_stock_status == "pre-order" ) {

											$output .= '"availability": "PreOrder",';

										} elseif( $magazine_stock_status == "sold-out" ) {

											$output .= '"availability": "SoldOut",';

										} elseif( $magazine_stock_status == "discontinued" ) {

											$output .= '"availability": "Discontinued",';

										} elseif( $magazine_stock_status == "back-order" ) {

											$output .= '"availability": "BackOrder",';

										} elseif( $magazine_stock_status == "in-store-only" ) {

											$output .= '"availability": "InStoreOnly",';

										} elseif( $magazine_stock_status == "limited-availability" ) {

											$output .= '"availability": "LimitedAvailability",';

										} elseif( $magazine_stock_status == "online-only" ) {

											$output .= '"availability": "OnlineOnly",';

										} elseif( $magazine_stock_status == "pre-sale" ) {

											$output .= '"availability": "PreSale",';

										} else {

											$output .= '"availability": "InStock",';
											
										}

									}

									$output .= '"url": "' . get_the_permalink() . '"';

								$output .= '},';

							}

							/* Genre */
							if( !empty( $categories ) ) {

								$category_last = end( $categories );

								$output .= '"genre": [';

								foreach( $categories as $category ) {

									if( !empty( $category ) ) {

										if( !empty( $category->name ) ) {

											$output .= '"' . esc_attr( $category->name ) . '"';

											if ( $category !== $category_last ) {
												
												$output .= ',';

											}

										}

									}

								}

								$output .= '],';

							}

							/* Date Created */
							if( !empty( get_the_date() ) ) {

								$output .= '"dateCreated": "' . get_the_date() . '",';
								$output .= '"sdDatePublished": "' . get_the_date() . '",';

							}

							/* Discussion Url */
							$output .= '"discussionUrl": "' . get_the_permalink() . '#comments",';

							/* is Accessible For Free */
							if( !empty( $magazine_accessible_for_free ) and $magazine_accessible_for_free == "1" ) {

								$output .= '"isAccessibleForFree": "true",';

							}

							/* Keywords (Tags) */
							if( !empty( $tags ) ) {

								$tag_last = end( $tags );

								$output .= '"keywords": [';

								foreach( $tags as $tag ) {

									if( !empty( $tag ) ) {

										if( !empty( $tag->name ) ) {

											$output .= '"';
												$output .= esc_attr( $tag->name );
											$output .= '"';

											if ( $tag !== $tag_last ) {
												
												$output .= ',';

											}

										}

									}

								}

								$output .= '],';

							}

							/* Temporal Coverage */
							if( !empty( $magazine_frequency ) ) {

								$output .= '"temporalCoverage": "' . esc_attr( $magazine_frequency ) . '",';

							}

							/* Image URL */
							if( !empty( $magazine_cover ) ) {

								foreach( $magazine_cover as $cover_item ) {

									if( !empty( $cover_item ) ) {

										$output .= '"image": "' . wp_get_attachment_image_src( esc_attr( $cover_item["ID"] ), 'full' )[0] . '",';

									} elseif ( !empty( get_the_post_thumbnail_url( get_the_ID() ) ) ) {

										$output .= '"image": "' . get_the_post_thumbnail_url( get_the_ID(), 'full' ) . '",';

									}

								}

							} elseif ( !empty( get_the_post_thumbnail_url( get_the_ID() ) ) ) {

								$output .= '"image": "' . get_the_post_thumbnail_url( get_the_ID(), 'full' ) . '",';

							}

							/* URL */
							$output .= '"url": "' . get_the_permalink() . '"';

						$output .= '}';

					}

				$output .= '</script>';

			}

			echo $output;

		}
		add_action( 'wp_head', 'loquet_schema' );

	}

}