PHP code example of mindkomm / theme-lib-structured-data

1. Go to this page and download the library: Download mindkomm/theme-lib-structured-data library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

mindkomm / theme-lib-structured-data example snippets


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();
} );

// Use SearchAction, ignore check for search.php file.
echo $website->generate_jsonld( true );



$options = [
    'name'                      => 'MIND Kommunikation GmbH',
    'street'                    => 'Wülflingerstrasse 36',
    'post_office_box_number'    => '',
    'zip'                       => '8400',
    'city'                      => 'Winterthur',
    'email'                     => '[email protected]',
    '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();

$logo = new Theme\Structured_Data\Logo( 'https://www.mind.ch/our-logo.png' );

echo $logo->generate_jsonld();

$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();