|
<?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: [email protected] |
|
* 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' ); |