rebase on oct-10-2023
This commit is contained in:
@@ -74,29 +74,21 @@ if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema_Event' ) ) {
|
||||
public static function prepare_location( $schema, $data, $offline = true ) {
|
||||
|
||||
if ( $offline ) {
|
||||
if ( isset( $data['location'] ) && ! empty( $data['location'] ) ) {
|
||||
if ( ! empty( $data['location'] ) ) {
|
||||
$schema['location']['@type'] = 'Place';
|
||||
$schema['location']['name'] = wp_strip_all_tags( $data['location'] );
|
||||
$schema['location']['name'] = wp_strip_all_tags( (string)$data['location'] );
|
||||
}
|
||||
|
||||
$schema['location']['@type'] = 'Place';
|
||||
$schema['location']['address']['@type'] = 'PostalAddress';
|
||||
if ( isset( $data['location-street'] ) && ! empty( $data['location-street'] ) ) {
|
||||
$schema['location']['address']['streetAddress'] = wp_strip_all_tags( $data['location-street'] );
|
||||
}
|
||||
if ( isset( $data['location-locality'] ) && ! empty( $data['location-locality'] ) ) {
|
||||
$schema['location']['address']['addressLocality'] = wp_strip_all_tags( $data['location-locality'] );
|
||||
}
|
||||
if ( isset( $data['location-postal'] ) && ! empty( $data['location-postal'] ) ) {
|
||||
$schema['location']['address']['postalCode'] = wp_strip_all_tags( $data['location-postal'] );
|
||||
}
|
||||
if ( isset( $data['location-region'] ) && ! empty( $data['location-region'] ) ) {
|
||||
$schema['location']['address']['addressRegion'] = wp_strip_all_tags( $data['location-region'] );
|
||||
}
|
||||
if ( isset( $data['location-country'] ) && ! empty( $data['location-country'] ) ) {
|
||||
$schema['location']['address']['streetAddress'] = ! empty( $data['location-street'] ) ? wp_strip_all_tags( (string)$data['location-street'] ) : NULL;
|
||||
$schema['location']['address']['addressLocality'] = ! empty( $data['location-locality'] ) ? wp_strip_all_tags( (string)$data['location-locality'] ) : NULL;
|
||||
$schema['location']['address']['postalCode'] = ! empty( $data['location-postal'] ) ? wp_strip_all_tags( (string)$data['location-postal'] ) : NULL;
|
||||
$schema['location']['address']['addressRegion'] = ! empty( $data['location-region'] ) ? wp_strip_all_tags( (string)$data['location-region'] ) : NULL;
|
||||
if ( ! empty( $data['location-country'] ) ) {
|
||||
|
||||
$schema['location']['address']['addressCountry']['@type'] = 'Country';
|
||||
$schema['location']['address']['addressCountry']['name'] = wp_strip_all_tags( $data['location-country'] );
|
||||
$schema['location']['address']['addressCountry']['name'] = wp_strip_all_tags( (string)$data['location-country'] );
|
||||
}
|
||||
} else {
|
||||
$schema['location']['@type'] = 'VirtualLocation';
|
||||
@@ -116,18 +108,10 @@ if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema_Event' ) ) {
|
||||
|
||||
$schema['offers']['@type'] = 'Offer';
|
||||
$schema['offers']['price'] = '0';
|
||||
if ( isset( $data['price'] ) && ! empty( $data['price'] ) ) {
|
||||
$schema['offers']['price'] = wp_strip_all_tags( $data['price'] );
|
||||
}
|
||||
if ( isset( $data['avail'] ) && ! empty( $data['avail'] ) ) {
|
||||
$schema['offers']['availability'] = wp_strip_all_tags( $data['avail'] );
|
||||
}
|
||||
if ( isset( $data['currency'] ) && ! empty( $data['currency'] ) ) {
|
||||
$schema['offers']['priceCurrency'] = wp_strip_all_tags( $data['currency'] );
|
||||
}
|
||||
if ( isset( $data['valid-from'] ) && ! empty( $data['valid-from'] ) ) {
|
||||
$schema['offers']['validFrom'] = wp_strip_all_tags( $data['valid-from'] );
|
||||
}
|
||||
$schema['offers']['price'] = ! empty( $data['price'] ) ? wp_strip_all_tags( (string)$data['price'] ) : NULL;
|
||||
$schema['offers']['availability'] = ! empty( $data['avail'] ) ? wp_strip_all_tags( (string)$data['avail'] ) : NULL;
|
||||
$schema['offers']['priceCurrency'] = ! empty( $data['currency'] ) ? wp_strip_all_tags( (string)$data['currency'] ) : NULL;
|
||||
$schema['offers']['validFrom'] = ! empty( $data['valid-from'] ) ? wp_strip_all_tags( (string)$data['valid-from'] ) : NULL;
|
||||
if ( isset( $data['ticket-buy-url'] ) && ! empty( $data['ticket-buy-url'] ) ) {
|
||||
$schema['offers']['url'] = esc_url( $data['ticket-buy-url'] );
|
||||
}
|
||||
@@ -145,17 +129,13 @@ if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema_Event' ) ) {
|
||||
*/
|
||||
public static function prepare_performer( $schema, $data ) {
|
||||
|
||||
if ( isset( $data['performer'] ) && ! empty( $data['performer'] ) ) {
|
||||
if ( ! empty( $data['performer'] ) ) {
|
||||
$schema['performer']['@type'] = 'Person';
|
||||
$schema['performer']['name'] = wp_strip_all_tags( $data['performer'] );
|
||||
$schema['performer']['name'] = wp_strip_all_tags( (string)$data['performer'] );
|
||||
}
|
||||
$schema['organizer']['@type'] = 'Organization';
|
||||
if ( isset( $data['event-organizer-name'] ) && ! empty( $data['event-organizer-name'] ) ) {
|
||||
$schema['organizer']['name'] = wp_strip_all_tags( $data['event-organizer-name'] );
|
||||
}
|
||||
if ( isset( $data['event-organizer-url'] ) && ! empty( $data['event-organizer-url'] ) ) {
|
||||
$schema['organizer']['url'] = wp_strip_all_tags( $data['event-organizer-url'] );
|
||||
}
|
||||
$schema['organizer']['name'] = ! empty( $data['event-organizer-name'] ) ? wp_strip_all_tags( (string)$data['event-organizer-name'] ) : NULL;
|
||||
$schema['organizer']['url'] = ! empty( $data['event-organizer-url'] ) ? wp_strip_all_tags( (string)$data['event-organizer-url'] ) : NULL;
|
||||
|
||||
return $schema;
|
||||
}
|
||||
@@ -170,17 +150,11 @@ if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema_Event' ) ) {
|
||||
public static function prepare_dates( $schema, $data ) {
|
||||
|
||||
$start_date = gmdate( DATE_ISO8601, strtotime( $data['start-date'] ) );
|
||||
if ( isset( $start_date ) && ! empty( $start_date ) ) {
|
||||
$schema['startDate'] = wp_strip_all_tags( $start_date );
|
||||
}
|
||||
$schema['startDate'] = ! empty( $start_date ) ? wp_strip_all_tags( (string)$start_date ) : NULL;
|
||||
|
||||
if ( isset( $data['end-date'] ) && ! empty( $data['end-date'] ) ) {
|
||||
$schema['endDate'] = wp_strip_all_tags( $data['end-date'] );
|
||||
}
|
||||
$schema['endDate'] = ! empty( $data['end-date'] ) ? wp_strip_all_tags( (string)$data['end-date'] ) : NULL;
|
||||
|
||||
if ( 'EventRescheduled' === $data['event-status'] ) {
|
||||
$schema['previousStartDate'] = wp_strip_all_tags( $data['previous-date'] );
|
||||
}
|
||||
$schema['previousStartDate'] = 'EventRescheduled' === $data['event-status'] ? wp_strip_all_tags( (string)$data['previous-date'] ) : NULL;
|
||||
|
||||
return $schema;
|
||||
}
|
||||
@@ -193,10 +167,8 @@ if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema_Event' ) ) {
|
||||
* @return array
|
||||
*/
|
||||
public static function prepare_attendence_mode( $schema, $data ) {
|
||||
if ( isset( $data['schema-type'] ) && isset( $data['event-attendance-mode'] ) && ! empty( $data['event-attendance-mode'] ) ) {
|
||||
|
||||
$schema['eventAttendanceMode'] = 'https://schema.org/' . wp_strip_all_tags( $data['event-attendance-mode'] );
|
||||
}
|
||||
$schema['eventAttendanceMode'] = isset( $data['schema-type'] ) && ! empty( $data['event-attendance-mode'] ) ? 'https://schema.org/' . wp_strip_all_tags( (string)$data['event-attendance-mode'] ) : NULL;
|
||||
|
||||
return $schema;
|
||||
}
|
||||
@@ -210,21 +182,15 @@ if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema_Event' ) ) {
|
||||
*/
|
||||
public static function prepare_basics( $schema, $data ) {
|
||||
|
||||
if ( isset( $data['name'] ) && ! empty( $data['name'] ) ) {
|
||||
$schema['name'] = wp_strip_all_tags( $data['name'] );
|
||||
}
|
||||
$schema['name'] = ! empty( $data['name'] ) ? wp_strip_all_tags( (string)$data['name'] ) : NULL;
|
||||
|
||||
if ( isset( $data['event-status'] ) && ! empty( $data['event-status'] ) ) {
|
||||
$schema['eventStatus'] = 'https://schema.org/' . wp_strip_all_tags( $data['event-status'] );
|
||||
}
|
||||
$schema['eventStatus'] = ! empty( $data['event-status'] ) ? 'https://schema.org/' . wp_strip_all_tags( (string)$data['event-status'] ) : NULL;
|
||||
|
||||
if ( isset( $data['image'] ) && ! empty( $data['image'] ) ) {
|
||||
$schema['image'] = BSF_AIOSRS_Pro_Schema_Template::get_image_schema( $data['image'] );
|
||||
}
|
||||
|
||||
if ( isset( $data['description'] ) && ! empty( $data['description'] ) ) {
|
||||
$schema['description'] = wp_strip_all_tags( $data['description'] );
|
||||
}
|
||||
$schema['description'] = ! empty( $data['description'] ) ? wp_strip_all_tags( (string)$data['description'] ) : NULL;
|
||||
|
||||
return $schema;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user