Plugin Updates

This commit is contained in:
Tony Volpe
2024-04-02 20:23:21 +00:00
parent 96800520e8
commit 94170ec2c4
1514 changed files with 133309 additions and 105985 deletions

View File

@@ -473,7 +473,12 @@ if ( ! class_exists( 'BSF_AIOSRS_Pro_Custom_Fields_Markup' ) ) {
}
}
self::$meta_options = call_user_func_array( 'array_merge', self::$meta_options );
self::$meta_options = array_reduce(self::$meta_options, function ($carry, $item) {
if (is_array($item)) {
return array_merge($carry, $item);
}
return $carry;
}, []);
}
}

View File

@@ -164,14 +164,19 @@ if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema_Template' ) ) {
}
}
if ( is_array( $value ) ) {
$selected = array();
foreach ( $value as $val ) {
if ( is_array( $val ) ) {
if ( is_array( $val ) && array_key_exists( 'value', $val ) ) {
$selected[] = $val['value'];
} else {
$selected[] = $val;
}
}
$value = implode( ',', $selected );
if ( ! empty( $selected ) ) {
$value = implode( ',', $selected );
} else {
$value = ''; // or any default value if needed
}
}
break;
}

View File

@@ -631,15 +631,38 @@ if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema' ) ) {
'default' => 'create-field',
'description' => esc_html__( 'The organization that publishes the source content of the course. For example, UC Berkeley.', 'wp-schema-pro' ),
),
'offer-category' => array(
'label' => esc_html__( 'Offer Category', 'wp-schema-pro' ),
'type' => 'text',
'default' => 'none',
'description' => esc_html__( 'The pricing category of the course.(e.g. Free, Partially Free, Subscription, Paid).', 'wp-schema-pro' ),
'offers' => array(
'label' => esc_html__( 'Offers', 'wp-schema-pro' ),
'type' => 'repeater',
'description' => esc_html__( 'The pricing and availability of the course.', 'wp-schema-pro' ),
'required' => true,
'fields' => array(
'offer-category' => array(
'label' => esc_html__( 'Offer Category', 'wp-schema-pro' ),
'type' => 'dropdown',
'default' => 'custom-text',
'dropdown-type' => 'offer-category',
),
'priceCurrency' => array(
'label' => esc_html__( 'Price Currency', 'wp-schema-pro' ),
'type' => 'dropdown',
'default' => 'custom-text',
'dropdown-type' => 'currency',
),
'price' => array(
'label' => esc_html__( 'Price', 'wp-schema-pro' ),
'type' => 'number',
'attrs' => array(
'min' => '0',
'step' => 'any',
),
),
),
),
'course-instance' => array(
'label' => esc_html__( 'Course Instance', 'wp-schema-pro' ),
'type' => 'repeater',
'required' => true,
'description' => esc_html__( 'An offering of the course at a specific time and place or through specific media or mode of study or to a specific section of students.', 'wp-schema-pro' ),
'fields' => array(
'name' => array(
@@ -658,6 +681,7 @@ if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema' ) ) {
'label' => esc_html__( 'Course Mode', 'wp-schema-pro' ),
'type' => 'text',
'default' => 'none',
'required' => true,
'description' => esc_html__( 'The medium or means of delivery of the course instance or the mode of study, either as a text label (e.g. "online", "onsite" or "blended"; "synchronous" or "asynchronous"; "full-time" or "part-time") or as a URL reference to a term from a controlled vocabulary (e.g. https://ceds.ed.gov/element/001311#Asynchronous )', 'wp-schema-pro' ),
),
'image' => array(
@@ -670,7 +694,7 @@ if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema' ) ) {
'type' => 'dropdown',
'default' => 'custom-text',
'dropdown-type' => 'event-status',
'required' => false,
'required' => true,
'description' => esc_html__( 'The status of the Course Instance.', 'wp-schema-pro' ),
),
@@ -695,23 +719,26 @@ if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema' ) ) {
'default' => 'none',
),
'repeat-count' => array(
'label' => esc_html__( 'Repeat Count', 'wp-schema-pro' ),
'type' => 'number',
'default' => 'none',
'attrs' => array(
'label' => esc_html__( 'Repeat Count', 'wp-schema-pro' ),
'type' => 'number',
'default' => 'none',
'required' => true,
'attrs' => array(
'min' => '0',
'step' => 'any',
),
),
'repeat-frequency' => array(
'label' => esc_html__( 'Repeat Frequency', 'wp-schema-pro' ),
'type' => 'text',
'default' => 'none',
'label' => esc_html__( 'Repeat Frequency', 'wp-schema-pro' ),
'type' => 'text',
'required' => true,
'default' => 'none',
),
'course-workload' => array(
'label' => esc_html__( 'Course Workload', 'wp-schema-pro' ),
'type' => 'text',
'default' => 'none',
'label' => esc_html__( 'Course Workload', 'wp-schema-pro' ),
'type' => 'text',
'required' => true,
'default' => 'none',
),
'previous-date' => array(
'label' => esc_html__( 'Course Previous Start Date', 'wp-schema-pro' ),
@@ -810,6 +837,7 @@ if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema' ) ) {
),
),
),
'bsf-aiosrs-event' => array(
'key' => 'event',
'icon' => 'dashicons dashicons-tickets-alt',
@@ -1368,6 +1396,7 @@ if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema' ) ) {
'bsf-aiosrs-software-application' => esc_html__( 'Software Application', 'wp-schema-pro' ),
'bsf-aiosrs-movie' => esc_html__( 'Movie', 'wp-schema-pro' ),
'bsf-aiosrs-organization' => esc_html__( 'Organization', 'wp-schema-pro' ),
'bsf-aiosrs-offers' => esc_html__( 'Offers', 'wp-schema-pro' ),
),
),
'review-body' => array(
@@ -1821,13 +1850,13 @@ if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema' ) ) {
),
'recipe-video-upload-date' => array(
'label' => esc_html__( 'Upload Date', 'wp-schema-pro' ),
'type' => 'date',
'type' => 'datetime',
'default' => 'post_date',
'required' => true,
),
'recipe-video-expires-date' => array(
'label' => esc_html__( 'Expires On', 'wp-schema-pro' ),
'type' => 'date',
'type' => 'datetime',
'default' => 'create-field',
),
'recipe-video-interaction-count' => array(
@@ -1993,7 +2022,6 @@ if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema' ) ) {
'key' => 'video-object',
'icon' => 'dashicons dashicons-video-alt3',
'label' => __( 'Video Object', 'wp-schema-pro' ),
'guideline-link' => empty( $doc_link ) ? 'https://wpschema.com/docs/how-to-add-a-schema-markup-for-a-video-object/' : 'https://developers.google.com/search/docs/data-types/videos',
'path' => BSF_AIOSRS_PRO_DIR . 'classes/schema/',
'subkeys' => array(
@@ -2063,14 +2091,16 @@ if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema' ) ) {
'is_recommnded' => true,
'fields' => array(
'clip-name' => array(
'label' => esc_html__( 'Clip Name', 'wp-schema-pro' ),
'type' => 'text',
'default' => 'none',
'label' => esc_html__( 'Clip Name', 'wp-schema-pro' ),
'type' => 'text',
'default' => 'none',
'required' => true,
),
'clip-start-offset' => array(
'label' => esc_html__( 'Clip Start Offset', 'wp-schema-pro' ),
'type' => 'number',
'default' => 'none',
'required' => true,
'description' => esc_html__( 'The start time of the clip expressed as the number of seconds from the beginning of the work.', 'wp-schema-pro' ),
),
'clip-end-offset' => array(
@@ -2083,6 +2113,7 @@ if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema' ) ) {
'label' => esc_html__( 'Clip URL', 'wp-schema-pro' ),
'type' => 'text',
'default' => 'none',
'required' => true,
'description' => esc_html__( 'A URL that points to the start time of the clip.', 'wp-schema-pro' ),
),
),
@@ -2099,8 +2130,37 @@ if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema' ) ) {
'default' => 'none',
'description' => esc_html__( 'A URL that points to the start time of the clip.', 'wp-schema-pro' ),
),
'thumbnail-url' => array(
'label' => esc_html__( 'Thumbnail URL', 'wp-schema-pro' ),
'type' => 'text',
'default' => 'none',
),
'regions-allowed' => array(
'label' => esc_html__( 'Regions Allowed', 'wp-schema-pro' ),
'type' => 'text',
'default' => 'none',
),
'is-live-broadcast' => array(
'label' => esc_html__( 'Is Live Broadcast', 'wp-schema-pro' ),
'type' => 'text',
'default' => false,
'required' => true,
),
'start-date' => array(
'label' => esc_html__( 'Live Broadcast Start Date', 'wp-schema-pro' ),
'type' => 'datetime-local',
'default' => 'none',
'required' => true,
),
'end-date' => array(
'label' => esc_html__( 'Live Broadcast End Date', 'wp-schema-pro' ),
'type' => 'datetime-local',
'default' => 'none',
'required' => true,
),
),
),
'bsf-aiosrs-faq' => array(
'key' => 'faq',
'icon' => 'dashicons dashicons-editor-help',
@@ -2354,6 +2414,10 @@ if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema' ) ) {
'type' => 'text',
'default' => 'blogname',
),
'category' => array(
'label' => esc_html__( 'Category', 'wp-schema-pro' ),
'type' => 'text',
),
),
),
'bsf-aiosrs-event' => array(
@@ -3946,6 +4010,17 @@ if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema' ) ) {
)
);
break;
case 'offer-category':
$return = apply_filters(
'wp_schema_pro_offer_category_options',
array(
'Free' => __( 'Free', 'wp-schema-pro' ),
'PartiallyFree' => __( 'Partially Free', 'wp-schema-pro' ),
'Subscription' => __( 'Subscription', 'wp-schema-pro' ),
'Paid' => __( 'Paid', 'wp-schema-pro' ),
)
);
break;
case 'event-status':
$return = apply_filters(
'wp_schema_pro_event_status_options',

View File

@@ -264,25 +264,25 @@ if ( ! class_exists( 'BSF_Target_Rule_Fields' ) ) {
$search_string = isset( $_POST['q'] ) ? sanitize_text_field( $_POST['q'] ) : '';
$data = array();
$result = array();
$args = array(
'public' => true,
'_builtin' => false,
);
$output = 'objects'; // names or objects, note names is the default.
$operator = 'and';
$post_types = get_post_types( $args, $output, $operator );
$post_types['post'] = 'Posts';
$post_types['page'] = 'Pages';
foreach ( $post_types as $post_type => $singular ) {
$data = array();
add_filter( 'posts_search', array( $this, 'search_only_titles' ), 10, 2 );
$query = new WP_Query(
array(
's' => $search_string,
@@ -290,9 +290,9 @@ if ( ! class_exists( 'BSF_Target_Rule_Fields' ) ) {
'posts_per_page' => - 1,
)
);
remove_filter( 'posts_search', array( $this, 'search_only_titles' ), 10, 2 );
if ( $query->have_posts() ) {
while ( $query->have_posts() ) {
$query->the_post();
@@ -305,57 +305,57 @@ if ( ! class_exists( 'BSF_Target_Rule_Fields' ) ) {
);
}
}
if ( is_array( $data ) && ! empty( $data ) ) {
$singular = ( 'post' === $post_type || 'page' === $post_type ) ? $singular : $singular->labels->singular_name;
$result[] = array(
'text' => $singular,
'children' => $data,
);
}
}
$data = array();
wp_reset_postdata();
$args = array(
'public' => true,
);
$output = 'objects'; // names or objects, note names is the default.
$operator = 'and';
$taxonomies = get_taxonomies( $args, $output, $operator );
foreach ( $taxonomies as $taxonomy ) {
$terms = get_terms(
$taxonomy->name,
array(
'taxonomy' => $taxonomy->name,
'orderby' => 'count',
'hide_empty' => 0,
'name__like' => $search_string,
)
);
$data = array();
$label = ucwords( $taxonomy->label );
if ( ! empty( $terms ) ) {
foreach ( $terms as $term ) {
$term_taxonomy_name = ucfirst( str_replace( '_', ' ', $taxonomy->name ) );
$data[] = array(
'id' => 'tax-' . $term->term_id . '-single-' . $taxonomy->name,
'text' => 'All singulars from ' . $term->name,
);
}
}
if ( is_array( $data ) && ! empty( $data ) ) {
$result[] = array(
'text' => $label,
@@ -363,11 +363,11 @@ if ( ! class_exists( 'BSF_Target_Rule_Fields' ) ) {
);
}
}
// return the result in json.
wp_send_json( $result );
}
/**
* Return search results only by post title.
* This is only run from bsf_get_posts_by_query()

View File

@@ -34,8 +34,16 @@ if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema_Course' ) ) {
$schema['description'] = ! empty( $data['description'] ) ? wp_strip_all_tags( (string) $data['description'] ) : null;
$schema['offers']['@type'] = 'Offer';
$schema['offers']['category'] = ! empty( $data['offer-category'] ) ? wp_strip_all_tags( (string) $data['offer-category'] ) : null;
if (isset($data['offers']) && !empty($data['offers'])) {
foreach ($data['offers'] as $offer_key => $offer_value) {
if (!empty($offer_value['category']) || !empty($offer_value['priceCurrency']) || !empty($offer_value['price'])) {
$schema['offers'][$offer_key]['@type'] = 'Offer';
$schema['offers'][$offer_key]['category'] = !empty($offer_value['offer-category']) ? wp_strip_all_tags((string)$offer_value['offer-category']) : null;
$schema['offers'][$offer_key]['priceCurrency'] = !empty($offer_value['priceCurrency']) ? wp_strip_all_tags((string)$offer_value['priceCurrency']) : null;
$schema['offers'][$offer_key]['price'] = !empty($offer_value['price']) ? wp_strip_all_tags((string)$offer_value['price']) : null;
}
}
}
if ( isset( $data['course-instance'] ) && ! empty( $data['course-instance'] ) ) {

View File

@@ -94,12 +94,16 @@ if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema_Person' ) ) {
$schema ['ContactPoint']['email'] = ! empty( $contact_type['email'] ) ? wp_strip_all_tags( (string) $contact_type['email'] ) : null;
if ( isset( $contact_type['areaServed'] ) && ! empty( $contact_type['areaServed'] ) ) {
$language = explode( ',', $contact_type['areaServed'] );
foreach ( $language as $key => $value ) {
$schema ['ContactPoint']['areaServed'][ $key ] = wp_strip_all_tags( (string) $value );
if ( is_array( $language )) {
foreach ( $language as $key => $value ) {
$schema ['ContactPoint']['areaServed'][ $key ] = wp_strip_all_tags( (string) $value );
}
}
}
foreach ( $contact_point_type as $key => $value ) {
$schema ['ContactPoint']['contactOption'][ $key ] = wp_strip_all_tags( (string) $value );
if (is_array($contact_point_type)) {
foreach ( $contact_point_type as $key => $value ) {
$schema ['ContactPoint']['contactOption'][ $key ] = wp_strip_all_tags( (string) $value );
}
}
$schema ['ContactPoint']['availableLanguage'] = ! empty( $contact_type['availableLanguage'] ) ? wp_strip_all_tags( (string) $contact_type['availableLanguage'] ) : null;
}

View File

@@ -13,8 +13,9 @@ if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema_Recipe' ) ) {
*
* @since 1.0.0
*/
class BSF_AIOSRS_Pro_Schema_Recipe {
class BSF_AIOSRS_Pro_Schema_Recipe {
/**
* Render Schema.
*
@@ -22,7 +23,21 @@ if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema_Recipe' ) ) {
* @param array $post Current Post Array.
* @return array
*/
public static function render( $data, $post ) {
// Get timezone string from WordPress settings.
$timezone_string = get_option( 'timezone_string' );
// Check if the timezone string is not empty and is valid before setting it.
if ( ! empty( $timezone_string ) && in_array( $timezone_string, timezone_identifiers_list() ) ) {
// WordPress calculates offsets from UTC.
// phpcs:ignore WordPress.DateTime.RestrictedFunctions.timezone_change_date_default_timezone_set
date_default_timezone_set( $timezone_string );
} else {
// If the timezone string is empty or invalid, set a fallback timezone.
date_default_timezone_set( 'UTC' );
}
$schema = array();
$schema['@context'] = 'https://schema.org';
@@ -33,6 +48,7 @@ if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema_Recipe' ) ) {
if ( isset( $data['image'] ) && ! empty( $data['image'] ) ) {
$schema['image'] = BSF_AIOSRS_Pro_Schema_Template::get_image_schema( $data['image'] );
}
if ( isset( $data['reviewer-type'] ) && ! empty( $data['reviewer-type'] ) ) {
$schema['author']['@type'] = wp_strip_all_tags( (string) $data['reviewer-type'] );
} else {
@@ -107,18 +123,26 @@ if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema_Recipe' ) ) {
if ( isset( $value['recipe-video-embed-url'] ) && ! empty( $value['recipe-video-embed-url'] ) ) {
$schema['video'][ $key ]['embedUrl'] = esc_url( $value['recipe-video-embed-url'] );
}
$schema['video'][ $key ]['duration'] = ! empty( $value['recipe-video-duration'] ) ? wp_strip_all_tags( (string) $value['recipe-video-duration'] ) : null;
$schema['video'][ $key ]['uploadDate'] = ! empty( $value['recipe-video-upload-date'] ) ? wp_strip_all_tags( (string) $value['recipe-video-upload-date'] ) : null;
$schema['video'][ $key ]['interactionCount'] = ! empty( $value['recipe-video-interaction-count'] ) ? wp_strip_all_tags( (string) $value['recipe-video-interaction-count'] ) : null;
$schema['video'][ $key ]['duration'] = ! empty( $value['recipe-video-duration'] ) ? wp_strip_all_tags( (string) $value['recipe-video-duration'] ) : null;
// Convert uploadDate to DateTime object and set the timezone.
$upload_date = new DateTime( $value['recipe-video-upload-date'] );
$upload_date->setTimezone( new DateTimeZone( $timezone_string ?: 'UTC' ) );
$schema['video'][ $key ]['uploadDate'] = $upload_date->format( 'c' );
// Use DateTime to handle timezone for 'expires'
if ( isset( $value['recipe-video-expires-date'] ) && ! empty( $value['recipe-video-expires-date'] ) && is_string( $value['recipe-video-expires-date'] ) ) {
$schema['video'][ $key ]['expires'] = wp_strip_all_tags( $value['recipe-video-expires-date'] );
$expires_date = new DateTime( $value['recipe-video-expires-date'] );
$expires_date->setTimezone( new DateTimeZone( $timezone_string ?: 'UTC' ) );
$schema['video'][ $key ]['expires'] = $expires_date->format( 'c' );
}
$schema['video'][ $key ]['interactionCount'] = ! empty( $value['recipe-video-interaction-count'] ) ? wp_strip_all_tags( (string) $value['recipe-video-interaction-count'] ) : null;
}
}
}
return apply_filters( 'wp_schema_pro_schema_recipe', $schema, $data, $post );
}
}
}

View File

@@ -66,13 +66,18 @@ if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema_Video_Object' ) ) {
$schema['interactionStatistic']['userInteractionCount'] = wp_strip_all_tags( (string) $data['interaction-count'] );
}
if ( isset( $data['thumbnail-url'] ) && ! empty( $data['thumbnail-url'] ) ) {
$schema['thumbnailUrl'] = $data['thumbnail-url'];
}
if ( isset( $data['clip'] ) && ! empty( $data['clip'] ) ) {
foreach ( $data['clip'] as $key => $value ) {
$schema['hasPart'][ $key ]['@type'] = 'Clip';
$schema['hasPart'][ $key ]['name'] = wp_strip_all_tags( (string) $value['clip-name'] );
$schema['hasPart'][ $key ]['startOffset'] = wp_strip_all_tags( (string) $value['clip-start-offset'] );
$schema['hasPart'][ $key ]['endOffset'] = wp_strip_all_tags( (string) $value['clip-end-offset'] );
$schema['hasPart'][ $key ]['url'] = esc_url( $value['clip-url'] );
$schema['hasPart'][$key]['@type'] = 'Clip';
$schema['hasPart'][$key]['name'] = wp_strip_all_tags( (string) $value['clip-name'] );
$schema['hasPart'][$key]['startOffset'] = wp_strip_all_tags( (string) $value['clip-start-offset'] );
$schema['hasPart'][$key]['endOffset'] = wp_strip_all_tags( (string) $value['clip-end-offset'] );
$schema['hasPart'][$key]['url'] = esc_url( $value['clip-url'] );
}
}
@@ -82,8 +87,20 @@ if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema_Video_Object' ) ) {
$schema['potentialAction']['startOffset-input'] = 'required name=seek_to_second_number';
}
if ( isset( $data['regions-allowed'] ) && ! empty( $data['regions-allowed'] ) ) {
$schema['regionsAllowed'] = wp_strip_all_tags( (string) $data['regions-allowed'] );
}
if ( isset( $data['is-live-broadcast'] ) && $data['is-live-broadcast'] ) {
$schema['publication']['@type'] = 'BroadcastEvent';
$schema['publication']['isLiveBroadcast'] = true;
$schema['publication']['startDate'] = ! empty( $data['start-date'] ) ? wp_strip_all_tags( (string) $data['start-date'] ) : null;
$schema['publication']['endDate'] = ! empty( $data['end-date'] ) ? wp_strip_all_tags( (string) $data['end-date'] ) : null;
}
return apply_filters( 'wp_schema_pro_schema_video_object', $schema, $data, $post );
}
}
}

View File

@@ -90,14 +90,14 @@ if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema_Global_Organization' ) ) {
}
foreach ( $social_profiles as $type => $social_link ) {
if ( 'other' === $type ) {
if ( 'other' === $type && is_array( $social_link ) ) {
foreach ( $social_link as $dynamic_social_link ) {
if ( ! empty( $dynamic_social_link ) ) {
$schema['sameAs'][] = $dynamic_social_link;
}
}
}
if ( ! empty( $social_link ) && ( ! is_array( $social_link ) ) ) {
if ( ! empty( $social_link ) && ! is_array( $social_link ) ) {
$schema['sameAs'][] = $social_link;
}
@@ -108,3 +108,4 @@ if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema_Global_Organization' ) ) {
}
}

View File

@@ -50,16 +50,19 @@ if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema_Global_Person' ) ) {
$schema ['ContactPoint']['url'] = $contact_type['contact-page-id'];
}
}
foreach ( $social_profiles as $type => $social_link ) {
if ( 'other' === $type ) {
foreach ( $social_link as $dynamic_social_link ) {
if ( ! empty( $dynamic_social_link ) ) {
$schema['sameAs'][] = $dynamic_social_link;
if ( is_array( $social_profiles ) ) {
foreach ( $social_profiles as $type => $social_link ) {
if ( 'other' === $type && is_array( $social_link ) ) {
foreach ( $social_link as $dynamic_social_link ) {
if ( ! empty( $dynamic_social_link ) ) {
$schema['sameAs'][] = $dynamic_social_link;
}
}
} else {
if ( ! empty( $social_link ) && ( ! is_array( $social_link ) ) ) {
$schema['sameAs'][] = $social_link;
}
}
} else {
if ( ! empty( $social_link ) && ( ! is_array( $social_link ) ) ) {
$schema['sameAs'][] = $social_link;
}
}
}