Skip to content

Instantly share code, notes, and snippets.

View GauravKhupse's full-sized avatar
🏠
Working from home

Gaurav Khupse GauravKhupse

🏠
Working from home
  • Tata consultancy services
  • Pune
View GitHub Profile
@GauravKhupse
GauravKhupse / gist:f0cb3a0916af34760171ece6377d05c9
Created October 26, 2022 07:11
service_schmea_multiple_area_served_type_country
add_action( 'after_setup_theme', 'add_my_custom_meta_field' );
function add_my_custom_meta_field() {
add_filter( 'wp_schema_pro_schema_meta_fields', 'my_extra_schema_field' );
add_filter( 'wp_schema_pro_schema_service', 'my_extra_schema_field_mapping', 10, 3 );
}
/**
* Add fields for mapping.
*
* @param array $fields Mapping fields array.
@GauravKhupse
GauravKhupse / gist:8a300ab51cb0262194023c2ab517343f
Created September 22, 2022 08:55
add extra Local business sub type
add_action( 'after_setup_theme', 'add_my_custom_meta_field' );
function add_my_custom_meta_field() {
add_filter( 'wp_schema_pro_schema_meta_fields', 'my_extra_schema_field' );
function my_extra_schema_field( $fields ) {
$fields['bsf-aiosrs-local-business']['subkeys']['schema-type']['choices']['ExerciseGym '] = esc_html__( 'ExerciseGym ', 'wp-schema-pro'
); //you can add as per schema.org name insted ExerciseGym"
return $fields;
if ( defined( 'BSF_AIOSRS_PRO_VER' ) && class_exists( 'BSF_AIOSRS_Pro_Markup' ) ) {
$instance = BSF_AIOSRS_Pro_Markup::get_instance();
remove_filter( 'the_content', array( $instance, 'rating_markup' ) );
}
@GauravKhupse
GauravKhupse / gist:5c3392f74ef97f56c40ee1fbbc2bb451
Created July 18, 2022 11:57
Custom layout 404 hook not working with embedded link
function ensure_autoembed_on_embed_blocks( $block ) {
global $wp_embed;
if ( $block['blockName'] === 'core/embed' && strpos( $block['innerContent'][ 0 ], '</iframe>' ) === false ) {
$block['innerContent'][ 0 ] = $wp_embed->autoembed( $block['innerContent'][ 0 ] );
}
return $block;
}
add_action('astra_404_content_template','ensure_autoembed_on_embed_blocks_404',10,1);
@GauravKhupse
GauravKhupse / gist:2946cd32ea530124f98d72263bbda8bc
Created July 5, 2022 12:28
RoofingContractor in the Local business schema type
add_action( 'after_setup_theme', 'add_my_custom_meta_field' );
function add_my_custom_meta_field() {
add_filter( 'wp_schema_pro_schema_meta_fields', 'my_extra_schema_field' );
function my_extra_schema_field( $fields ) {
$fields['bsf-aiosrs-local-business']['subkeys']['schema-type']['choices']['RoofingContractor '] = esc_html__( 'Roofing Contractor ', 'wp-schema-pro'
);
return $fields;
@GauravKhupse
GauravKhupse / gist:f34dcb7601f8f10e66d43f0ddad714b6
Created July 5, 2022 09:57
TouristAttraction_subtype_in_Localbusiness_schema
add_action( 'after_setup_theme', 'add_my_custom_meta_field' );
function add_my_custom_meta_field() {
add_filter( 'wp_schema_pro_schema_meta_fields', 'my_extra_schema_field' );
function my_extra_schema_field( $fields ) {
$fields['bsf-aiosrs-local-business']['subkeys']['schema-type']['choices']['TouristAttraction '] = esc_html__( 'Tourist Attraction ', 'wp-schema-pro'
);
return $fields;
@GauravKhupse
GauravKhupse / gist:ed6a5c2ec0f3da61a3041fe57fc39a11
Created April 21, 2022 03:52
Add Extra ID field for product schema.
add_action( 'after_setup_theme', 'add_my_custom_meta_field' );
function add_my_custom_meta_field() {
add_filter( 'wp_schema_pro_schema_meta_fields', 'my_extra_schema_field' );
add_filter( 'wp_schema_pro_schema_product', 'my_extra_schema_field_mapping', 10, 3 );
}
/**
* Add fields for mapping.
*
* @param array $fields Mapping fields array.
@GauravKhupse
GauravKhupse / gist:864af7416335dd2bb2774359582fed20
Last active June 30, 2022 11:41
Added author and publisher same as field URL as home page URL
add_filter( 'wp_schema_pro_schema_review', 'my_extra_schema_field_mapping', 10, 3 );
/**
* Mapping extra field for schema markup.
*
* @param array $schema Schema array.
* @param array $data Mapping fields array.
* @return array
*/
function my_extra_schema_field_mapping( $schema, $data, $post ) {
@GauravKhupse
GauravKhupse / gist:6f90e6a9499662382b905f2fe558ea18
Last active June 30, 2022 11:41
Added compatibility YITH WooCommerce Brands Add-on Premium for brand field.
add_filter( 'wp_schema_pro_schema_product', 'my_brand_field_mapping', 10, 3 );
/**
* Mapping extra field for schema markup.
*
* @param array $schema Schema array.
* @param array $data Mapping fields array.
* @return array
*/
function my_brand_field_mapping( $schema, $data, $post ) {