Created
April 12, 2019 20:04
-
-
Save PaulMorel/6881313e325ae01090ecdcc989894fa0 to your computer and use it in GitHub Desktop.
Adding The SEO Framework Social Media fields to your Timber context for Wordpress
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Add the SEO Framework's social media fields to the Timber context | |
* | |
* @param array $context Timber's context | |
* | |
* @return array | |
*/ | |
function timber_add_seo_framework_social( $context ) { | |
$settings = maybe_unserialize( get_option('autodescription-site-settings') ); | |
$context['social'] = [ | |
'facebook' => [ | |
'slug' =>'facebook', | |
'url' => $settings['knowledge_facebook'], | |
'name' => 'Facebook' | |
], | |
'twitter' => [ | |
'slug' =>'twitter', | |
'url' => $settings['knowledge_twitter'], | |
'name' => 'Twitter' | |
], | |
'gplus' => [ | |
'slug' =>'gplus', | |
'url' => $settings['knowledge_gplus'], | |
'name' => 'Google+' | |
], | |
'instagram' => [ | |
'slug' =>'instagram', | |
'url' => $settings['knowledge_instagram'], | |
'name' => 'Instagram' | |
], | |
'youtube' => [ | |
'slug' =>'youtube', | |
'url' => $settings['knowledge_youtube'], | |
'name' => 'YouTube' | |
], | |
'linkedin' => [ | |
'slug' =>'linkedin', | |
'url' => $settings['knowledge_linkedin'], | |
'name' => 'LinkedIn' | |
], | |
'pinterest' => [ | |
'slug' =>'pinterest', | |
'url' => $settings['knowledge_pinterest'], | |
'name' => 'Pinterest' | |
], | |
'soundcloud' => [ | |
'slug' =>'soundcloud', | |
'url' => $settings['knowledge_soundcloud'], | |
'name' => 'Soundcloud' | |
], | |
'tumblr' => [ | |
'slug' =>'tumblr', | |
'url' => $settings['knowledge_tumblr'], | |
'name' => 'Tumblr' | |
], | |
]; | |
return $context; | |
} | |
add_filter( 'timber/context', 'timber_add_seo_framework_social' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment