Skip to content

Instantly share code, notes, and snippets.

@thadallender
Created January 6, 2015 03:09
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save thadallender/e6d61401688327f97056 to your computer and use it in GitHub Desktop.
A plugin to add custom social media links to Theme.Works themes https://theme.works
<?php
/**
* Plugin Name: Theme.Works Custom Social Media
* Plugin URI: https://theme.works
* Description: A plugin for adding additional social media links to all Theme.Works themes
* Version: 1.0.0
* Author: Thad Allender
* Author URI: https://theme.works
* Author Email: info@theme.works
* Text Domain: themeworks
* Domain Path: languages
* License: GPL2
*/
/**
* Define your array of custom social media slugs here
* You can use any icons listed here:
* http://genericons.com/
* Only add the unique name of the icon
*/
function themeworks_custom_social_media_array(){
$extra_fields = array(
'tumblr',
'github',
'mail'
);
return $extra_fields;
}
/**
* Add new social media to settings
*/
function themeworks_custom_social_media_settings() {
if ( function_exists( 'themeworks_register_theme_options' ) ) {
// Add more social media settings to theme options
foreach ( themeworks_custom_social_media_array() as $extra_field ) {
$additional_options[$extra_field] = array(
"tab" => 'social_tab',
"name" => $extra_field,
"title" => ucfirst( $extra_field ),
"description" => __( "URL", "themeworks" ),
"section" => 'social_section_1',
"since" => "1.0",
"id" => "social_section_1",
"type" => "text",
"sanitize" => "html",
"default" => ""
);
}
themeworks_register_theme_options( $additional_options );
}
}
add_action( 'after_setup_theme', 'themeworks_custom_social_media_settings' );
/**
* Filter the social media html markup
*/
function themeworks_custom_social_media( $fields ){
// combine the two arrays
$fields = array_merge( themeworks_custom_social_media_array(), $fields );
// return the fields
return $fields;
}
add_filter( 'themeworks_filter_social', 'themeworks_custom_social_media' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment