Created
February 11, 2018 18:36
-
-
Save kenziebottoms/e17f35784a3ced28ff6c6a4d6d554993 to your computer and use it in GitHub Desktop.
Social links options page for WordPress
This file contains 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
// social media links settings page | |
function social_links_page() { ?> | |
<div class="wrap"> | |
<h1>Social Links</h1> | |
<form method="post" action="options.php"> | |
<?php settings_fields("section"); | |
do_settings_sections("social-links"); | |
submit_button(); ?> | |
</form> | |
</div> | |
<?php } | |
function display_twitter_link() { ?> | |
<input type="text" name="twitter_url" id="twitter_url" value="<?php echo get_option('twitter_url'); ?>" /> | |
<?php } | |
function display_facebook_link() { ?> | |
<input type="text" name="facebook_url" id="facebook_url" value="<?php echo get_option('facebook_url'); ?>" /> | |
<?php } | |
function display_linkedin_link() { ?> | |
<input type="text" name="linkedin_url" id="linkedin_url" value="<?php echo get_option('linkedin_url'); ?>" /> | |
<?php } | |
function display_instagram_link() { ?> | |
<input type="text" name="instagram_url" id="instagram_url" value="<?php echo get_option('instagram_url'); ?>" /> | |
<?php } | |
function display_gplus_link() { ?> | |
<input type="text" name="gplus_url" id="gplus_url" value="<?php echo get_option('gplus_url'); ?>" /> | |
<?php } | |
function display_email_link() { ?> | |
<input placeholder="[email protected]" type="text" name="email" id="email" value="<?php echo get_option('email'); ?>" /> | |
<?php } | |
function display_social_link_fields() { | |
add_settings_section("social-links", "", null, "social-links"); | |
add_settings_field("twitter_url", "Twitter Profile Url", "display_twitter_link", "social-links", "social-links"); | |
add_settings_field("facebook_url", "Facebook Profile Url", "display_facebook_link", "social-links", "social-links"); | |
add_settings_field("linkedin_url", "LinkedIn Profile Url", "display_linkedin_link", "social-links", "social-links"); | |
add_settings_field("instagram_url", "Instagram Profile Url", "display_instagram_link", "social-links", "social-links"); | |
add_settings_field("gplus_url", "Google+ Profile Url", "display_gplus_link", "social-links", "social-links"); | |
add_settings_field("email", "Email Address", "display_email_link", "social-links", "social-links"); | |
register_setting("section", "twitter_url"); | |
register_setting("section", "facebook_url"); | |
register_setting("section", "linkedin_url"); | |
register_setting("section", "instagram_url"); | |
register_setting("section", "gplus_url"); | |
register_setting("section", "email"); | |
} | |
add_action("admin_init", "display_social_link_fields"); | |
function add_social_links_page() { | |
add_menu_page("Social Links", "Social Links", "manage_options", "social-links", "social_links_page", null, 99); | |
} | |
add_action("admin_menu", "add_social_links_page"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment