dev-master
9999999-devStructured Data helper classes for WordPress themes
MIT
The Requires
- php >=7.1.0
- spatie/schema-org ^1.3.0
1.0.0
1.0.0.0Structured Data helper classes for WordPress themes
MIT
The Requires
- php >=7.1.0
- spatie/schema-org ^1.3.0
Wallogit.com
2017 © Pedro PelĆ”ez
Structured Data helper classes for WordPress themes
Structured Data helper classes for WordPress themes., (*1)
Supports the following data types:, (*2)
You can install the package via Composer:, (*3)
composer require mindkomm/theme-lib-structured-data
Put the generated output into the <head> of your HTML., (*4)
add_action( 'wp_head', function() {
// Local Business
$local_business = new Theme\Structured_Data\Local_Business( $options );
echo $local_business->generate_jsonld();
// Website
$website = new Theme\Structured_Data\Website();
echo $website->generate_jsonld();
// Logo
$logo = new Theme\Structured_Data\Logo( $logo_url );
echo $logo->generate_jsonld();
// Social profiles
$social_profiles = new Theme\Structured_Data\Social_Profile( $social_profiles );
echo $social_profiles->generate_jsonld();
} );
The class checks if it can find a search.php file in your theme directory and will include a potential search action property accordingly. If you want to have more control over this, you can pass a boolean to the generate_jsonld() function:, (*5)
// Use SearchAction, ignore check for search.php file. echo $website->generate_jsonld( true );
A Local Business entry can take a lot of data. The following types of data are supported:, (*6)
You need to pass this data when you instantiate the class in the form of an array. Hereās an overview over all the options you can pass in:, (*7)
<?php
$options = [
'name' => 'MIND Kommunikation GmbH',
'street' => 'Wülflingerstrasse 36',
'post_office_box_number' => '',
'zip' => '8400',
'city' => 'Winterthur',
'email' => 'hello@mind.ch',
'phone' => '052 203 45 00',
'country_code' => 'CH',
'logo' => 'https://www.mind.ch/our-logo.png',
'social_profiles' => [
'facebook' => '',
'twitter' => 'https://twitter.com/mindkomm',
'instagram' => '',
'youtube' => '',
'linkedin' => '',
'myspace' => '',
'pinterest' => '',
'soundcloud' => '',
'tumblr' => '',
],
'location_map_url' => 'https://www.google.ch/maps/place/MIND+Kommunikation+GmbH/@47.5054599,8.715229,17z/data=!3m1!4b1!4m5!3m4!1s0x479a999cb35b1801:0xefef1560f7750a4f!8m2!3d47.5054599!4d8.7174177',
'geo' => [
'address' => 'MIND Kommunikation GmbH, Wülflingerstrasse, Winterthur, Schweiz',
'lat' => '47.50545990000001',
'lng' => '8.717417699999942',
],
'opening_hours' => [
[
'weekday' => 'Monday',
'opens' => '08:00:00',
'closes' => '17:30:00',
],
[
'weekday' => 'Tuesday',
'opens' => '08:00:00',
'closes' => '17:30:00',
],
[
'weekday' => 'Wednesday',
'opens' => '08:00:00',
'closes' => '17:30:00',
],
// ā¦
],
'opening_hours_closed' => [
[
'date_from' => '2018-12-24',
'date_to' => '2019-01-02',
],
],
];
$local_business = new Theme\Structured_Data\Local_Business( $options );
echo $local_business->generate_jsonld();
Adds logo markup according to the Structured Data Guide for Logo., (*8)
$logo = new Theme\Structured_Data\Logo( 'https://www.mind.ch/our-logo.png' ); echo $logo->generate_jsonld();
Links to social profiles such as Facebook, Twitter, Instagram according to the Structured Data Guide for Social Profile., (*9)
$social_profiles = new Theme\Structured_Data\Social_Profile( [
'facebook' => '',
'twitter' => 'https://twitter.com/mindkomm',
'instagram' => '',
'youtube' => '',
'linkedin' => '',
'myspace' => '',
'pinterest' => '',
'soundcloud' => '',
'tumblr' => '',
] );
echo $social_profiles->generate_jsonld();
Uses the fantastic schema-org library by Spatie., (*10)
This is a library that we use at MIND to develop WordPress themes. Youāre free to use it, but currently, we donāt provide any support., (*11)
Structured Data helper classes for WordPress themes
MIT
Structured Data helper classes for WordPress themes
MIT