rebase from live enviornment

This commit is contained in:
Rachit Bhargava
2024-01-09 22:14:20 -05:00
parent ff0b49a046
commit 3a22fcaa4a
15968 changed files with 2344674 additions and 45234 deletions

View File

@@ -142,7 +142,7 @@ if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema' ) ) {
public function bsf_delete_cached_json_ld() {
global $wpdb;
$wpdb->delete( $wpdb->postmeta, array( 'meta_key' => BSF_AIOSRS_PRO_CACHE_KEY ) );
$wpdb->delete( $wpdb->postmeta, array( 'meta_key' => BSF_AIOSRS_PRO_CACHE_KEY ) ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
}
/**
@@ -156,7 +156,7 @@ if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema' ) ) {
check_ajax_referer( 'schema_nonce', 'nonce' );
$item_type = sanitize_text_field( $_POST['itemType'] );
$item_type = isset( $_POST['itemType'] ) ? sanitize_text_field( $_POST['itemType'] ) : '';
$post_id = filter_input( INPUT_POST, 'post_id', FILTER_VALIDATE_INT );
$item_type_fields = self::$schema_item_types[ $item_type ]['subkeys'];
@@ -340,7 +340,7 @@ if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema' ) ) {
global $wpdb;
// WPCS: unprepared SQL OK.
$aiosrs_meta_array = $wpdb->get_results( "SELECT DISTINCT meta_key FROM {$wpdb->postmeta} WHERE meta_key LIKE '%{$search_string}%'", ARRAY_A ); // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared
$aiosrs_meta_array = $wpdb->get_results( "SELECT DISTINCT meta_key FROM {$wpdb->postmeta} WHERE meta_key LIKE '%{$search_string}%'", ARRAY_A ); // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
$schema_post_meta_fields = array_merge( self::$schema_meta_keys, array( 'bsf-aiosrs-schema-type', 'bsf-aiosrs-schema-location', 'bsf-aiosrs-schema-exclusion' ) );
if ( isset( $aiosrs_meta_array ) && ! empty( $aiosrs_meta_array ) ) {
@@ -363,6 +363,32 @@ if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema' ) ) {
wp_send_json( $result );
}
/**
* Get an array of timezones
*
* @return array
*/
public static function timezone_options() {
$html = wp_timezone_choice( 'UTC+0' );
$dom = new DOMDocument();
$dom->loadHTML( $html );
$result = array();
foreach ( $dom->getElementsByTagName( 'optgroup' ) as $optgroup ) {
$label = $optgroup->getAttribute( 'label' );
foreach ( $optgroup->getElementsByTagName( 'option' ) as $option ) {
$value = $option->getAttribute( 'value' );
$name = $option->nodeValue; // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
$result[ $value ] = $name;
}
}
return $result;
}
/**
* Initialize Schema Meta fields.
*
@@ -605,6 +631,12 @@ 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' ),
),
'course-instance' => array(
'label' => esc_html__( 'Course Instance', 'wp-schema-pro' ),
'type' => 'repeater',
@@ -662,6 +694,25 @@ if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema' ) ) {
'type' => 'date',
'default' => 'none',
),
'repeat-count' => array(
'label' => esc_html__( 'Repeat Count', 'wp-schema-pro' ),
'type' => 'number',
'default' => 'none',
'attrs' => array(
'min' => '0',
'step' => 'any',
),
),
'repeat-frequency' => array(
'label' => esc_html__( 'Repeat Frequency', 'wp-schema-pro' ),
'type' => 'text',
'default' => 'none',
),
'course-workload' => array(
'label' => esc_html__( 'Course Workload', 'wp-schema-pro' ),
'type' => 'text',
'default' => 'none',
),
'previous-date' => array(
'label' => esc_html__( 'Course Previous Start Date', 'wp-schema-pro' ),
'type' => 'datetime-local',
@@ -840,6 +891,14 @@ if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema' ) ) {
'type' => 'datetime-local',
'default' => 'none',
),
'timezone' => array(
'label' => esc_html__( 'Timezone', 'wp-schema-pro' ),
'type' => 'dropdown',
'default' => 'custom-text',
'dropdown-type' => 'timezone',
'class' => 'wpsp-online-event-timezone',
'required' => false,
),
'previous-date' => array(
'label' => esc_html__( 'Previous Start Date', 'wp-schema-pro' ),
'type' => 'datetime-local',
@@ -1743,9 +1802,9 @@ if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema' ) ) {
'required' => true,
),
'recipe-video-content-url' => array(
'label' => esc_html__( 'Content URL', 'wp-schema-pro' ),
'type' => 'text',
'default' => 'create-field',
'label' => esc_html__( 'Content URL', 'wp-schema-pro' ),
'type' => 'text',
'default' => 'create-field',
'required' => true,
),
'recipe-video-embed-url' => array(
@@ -1936,66 +1995,108 @@ if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema' ) ) {
'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(
'name' => array(
'name' => array(
'label' => esc_html__( 'Video Title', 'wp-schema-pro' ),
'type' => 'text',
'default' => 'post_title',
'required' => true,
),
'description' => array(
'description' => array(
'label' => esc_html__( 'Video Description', 'wp-schema-pro' ),
'type' => 'textarea',
'default' => 'post_content',
'required' => true,
),
'image' => array(
'image' => array(
'label' => esc_html__( 'Video Thumbnail', 'wp-schema-pro' ),
'type' => 'image',
'default' => 'featured_img',
'required' => true,
),
'upload-date' => array(
'upload-date' => array(
'label' => esc_html__( 'Video Upload Date', 'wp-schema-pro' ),
'type' => 'date',
'default' => 'post_date',
'required' => true,
),
'orgnization-name' => array(
'orgnization-name' => array(
'label' => esc_html__( 'Publisher Name', 'wp-schema-pro' ),
'type' => 'text',
'default' => 'blogname',
),
'site-logo' => array(
'site-logo' => array(
'label' => esc_html__( 'Publisher Logo', 'wp-schema-pro' ),
'type' => 'image',
'default' => 'site_logo',
),
'content-url' => array(
'content-url' => array(
'label' => esc_html__( 'Content URL', 'wp-schema-pro' ),
'type' => 'text',
'default' => 'none',
),
'embed-url' => array(
'embed-url' => array(
'label' => esc_html__( 'Embed URL', 'wp-schema-pro' ),
'type' => 'text',
'default' => 'none',
),
'duration' => array(
'duration' => array(
'label' => esc_html__( 'Video Duration', 'wp-schema-pro' ),
'type' => 'time-duration',
'default' => 'none',
),
'expires-date' => array(
'expires-date' => array(
'label' => esc_html__( 'Video Expires On', 'wp-schema-pro' ),
'type' => 'date',
'default' => 'none',
),
'interaction-count' => array(
'interaction-count' => array(
'label' => esc_html__( 'Video Interaction Count', 'wp-schema-pro' ),
'type' => 'number',
'default' => 'none',
'description' => esc_html__( 'The number of times the video has been watched.', 'wp-schema-pro' ),
),
'clip' => array(
'label' => esc_html__( 'Clips', 'wp-schema-pro' ),
'type' => 'repeater',
'is_recommnded' => true,
'fields' => array(
'clip-name' => array(
'label' => esc_html__( 'Clip Name', 'wp-schema-pro' ),
'type' => 'text',
'default' => 'none',
),
'clip-start-offset' => array(
'label' => esc_html__( 'Clip Start Offset', 'wp-schema-pro' ),
'type' => 'number',
'default' => 'none',
'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(
'label' => esc_html__( 'Clip End Offset', 'wp-schema-pro' ),
'type' => 'number',
'default' => 'none',
'description' => esc_html__( 'The end time of the clip expressed as the number of seconds from the beginning of the work.', 'wp-schema-pro' ),
),
'clip-url' => array(
'label' => esc_html__( 'Clip URL', 'wp-schema-pro' ),
'type' => 'text',
'default' => 'none',
'description' => esc_html__( 'A URL that points to the start time of the clip.', 'wp-schema-pro' ),
),
),
),
'seekto-action-start-offset' => array(
'label' => esc_html__( 'Seek To Action Start Offset', 'wp-schema-pro' ),
'type' => 'number',
'default' => 'none',
'description' => esc_html__( 'The number of seconds to skip to.', 'wp-schema-pro' ),
),
'seekto-action-target' => array(
'label' => esc_html__( 'Seek To Action target URL', 'wp-schema-pro' ),
'type' => 'text',
'default' => 'none',
'description' => esc_html__( 'A URL that points to the start time of the clip.', 'wp-schema-pro' ),
),
),
),
'bsf-aiosrs-faq' => array(
@@ -2162,12 +2263,12 @@ if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema' ) ) {
'type' => 'text',
'default' => 'create-field',
),
'credit-text' => array(
'credit-text' => array(
'label' => esc_html__( 'Credit Text', 'wp-schema-pro' ),
'type' => 'text',
'default' => 'create-field',
),
'creator-type' => array(
'creator-type' => array(
'label' => esc_html__( 'Creator Type', 'wp-schema-pro' ),
'type' => 'text',
'default' => 'Person',
@@ -2176,12 +2277,12 @@ if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema' ) ) {
'Organization' => esc_html__( 'Organization', 'wp-schema-pro' ),
),
),
'creator' => array(
'creator' => array(
'label' => esc_html__( 'Creator', 'wp-schema-pro' ),
'type' => 'text',
'default' => 'author_name',
),
'copy-right-notice' => array(
'copy-right-notice' => array(
'label' => esc_html__( 'Copy Right Notice', 'wp-schema-pro' ),
'type' => 'text',
'default' => 'create-field',
@@ -3107,10 +3208,12 @@ if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema' ) ) {
$schema_meta_repeater_keys = array_keys( $schema_meta_repeater );
}
foreach ( $meta_values as $index => $repeater_values ) {
if ( is_array( $repeater_values ) ) {
foreach ( $repeater_values as $repeater_key => $repeater_value ) {
$meta_repeater_value = $repeater_value;
if ( is_array( $meta_values ) ) {
foreach ( $meta_values as $index => $repeater_values ) {
if ( is_array( $repeater_values ) ) {
foreach ( $repeater_values as $repeater_key => $repeater_value ) {
$meta_repeater_value = $repeater_value;
}
}
}
}
@@ -3714,7 +3817,7 @@ if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema' ) ) {
$key = $value[0];
$text = isset( $value[1] ) ? $value[1] : $value[0];
?>
<option value="<?php echo esc_attr( $key ); ?>" <?php in_array( $key, $selected_options, true ) ? selected( 1 ) : ''; ?>><?php echo esc_attr( $text ); ?></option>
<option value="<?php echo esc_attr( $key ); ?>" <?php in_array( $key, $selected_options, true ) ? selected( 1 ) : ''; ?>><?php echo esc_html( $text ); ?></option>
<?php
}
}
@@ -3733,7 +3836,7 @@ if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema' ) ) {
if ( ! empty( $option_list ) ) {
foreach ( $option_list as $key => $value ) {
?>
<option value="<?php echo esc_attr( $key ); ?>" <?php selected( $default_value, $key ); ?>><?php echo esc_attr( $value ); ?></option>
<option value="<?php echo esc_attr( $key ); ?>" <?php selected( $default_value, $key ); ?>><?php echo esc_html( $value ); ?></option>
<?php
}
}
@@ -3864,6 +3967,12 @@ if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema' ) ) {
)
);
break;
case 'timezone':
$return = apply_filters(
'wp_schema_pro_event_timezone_options',
self::timezone_options()
);
break;
case 'action-platform':
$return = apply_filters(
'wp_schema_pro_action_platform_options',
@@ -4451,7 +4560,7 @@ if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema' ) ) {
$is_autosave = wp_is_post_autosave( $post_id );
$is_revision = wp_is_post_revision( $post_id );
$is_valid_nonce = ( isset( $_POST['aiosrs-schema'] ) && wp_verify_nonce( $_POST['aiosrs-schema'], basename( __FILE__ ) ) ) ? true : false;
$is_valid_nonce = ( isset( $_POST['aiosrs-schema'] ) && wp_verify_nonce( sanitize_text_field( $_POST['aiosrs-schema'] ), basename( __FILE__ ) ) ) ? true : false;
// Exits script depending on save status.
if ( $is_autosave || $is_revision || ! $is_valid_nonce ) {
@@ -4469,10 +4578,10 @@ if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema' ) ) {
continue;
}
$_POST[ $key ] = array_filter( $_POST[ $key ], __CLASS__ . '::is_not_empty' );
$_POST[ $key ] = array_filter( $_POST[ $key ], __CLASS__ . '::is_not_empty' ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
$meta_value = array();
foreach ( $_POST[ $key ] as $meta_key => $value ) {
foreach ( $_POST[ $key ] as $meta_key => $value ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
$subkey_type = isset( self::$schema_meta_fields[ $key ]['subkeys'][ $meta_key ]['type'] ) ? self::$schema_meta_fields[ $key ]['subkeys'][ $meta_key ]['type'] : 'text';
if ( ( 'repeater' === $subkey_type || 'repeater-target' === $subkey_type ) && is_array( $value ) ) {
$i = 0;
@@ -4509,7 +4618,7 @@ if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema' ) ) {
break;
default:
$meta_value = filter_input( INPUT_POST, $key, FILTER_DEFAULT );
$meta_value = filter_input( INPUT_POST, $key, FILTER_DEFAULT ); // phpcs:ignore WordPressVIPMinimum.Security.PHPFilterFunctions.RestrictedFilter
break;
}
}
@@ -4542,7 +4651,7 @@ if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema' ) ) {
* @return void
*/
public function redirect_custom_post_type() {
if ( isset( $_REQUEST['wp_schema_pro_admin_page_nonce'] ) && ! wp_verify_nonce( $_REQUEST['wp_schema_pro_admin_page_nonce'], 'wp_schema_pro_admin_page' ) ) {
if ( isset( $_REQUEST['wp_schema_pro_admin_page_nonce'] ) && ! wp_verify_nonce( sanitize_text_field( $_REQUEST['wp_schema_pro_admin_page_nonce'] ), 'wp_schema_pro_admin_page' ) ) {
return;
}
global $pagenow;
@@ -4559,7 +4668,7 @@ if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema' ) ) {
/**
* Back to Schemas link
*/
public function back_to_schema() {
public function back_to_schema() { // phpcs:ignore WordPressVIPMinimum.Hooks.AlwaysReturnInFilter.VoidReturn, WordPressVIPMinimum.Hooks.AlwaysReturnInFilter.MissingReturnStatement
global $post_type;
if ( 'aiosrs-schema' !== $post_type ) {
return;
@@ -4634,7 +4743,7 @@ if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema' ) ) {
* @param array $messages Array of default messages.
*/
public function custom_post_type_post_update_messages( $messages ) {
if ( isset( $_REQUEST['wp_schema_pro_admin_page_nonce'] ) && ! wp_verify_nonce( $_REQUEST['wp_schema_pro_admin_page_nonce'], 'wp_schema_pro_admin_page' ) ) {
if ( isset( $_REQUEST['wp_schema_pro_admin_page_nonce'] ) && ! wp_verify_nonce( sanitize_text_field( $_REQUEST['wp_schema_pro_admin_page_nonce'] ), 'wp_schema_pro_admin_page' ) ) {
return false;
}
$custom_post_type = get_post_type( get_the_ID() );