Or, embed this snippet using GenerateWP WordPress Plugin.

Download

Clone

Admin Setting Page For Social Media Accounts

Class that create a admin page with a form where admin can enter social media account

<?php namespace FollowSocial;

class AdminSettingPage
{

	public function init_action()
	{
		add_action( 'admin_menu', array( $this, 'admin_setting_page' ) );
	}

	public function admin_setting_page()
	{
		add_options_page(
			'Social Accounts',
			'Social Accounts',
			'manage_options',
			'options_page_slug',
			array(
				$this,
				'settings_page'
			)
		);
	}

	public function settings_page()
	{
		if (isset($_POST["update_settings"]))
		{
			$twitter = sanitize_text_field($_POST["twitter"]);
			update_option("twitter", $twitter);

			$facebook = sanitize_text_field($_POST["facebook"]);
			update_option("facebook", $facebook);

			$linkedin = sanitize_text_field($_POST["linkedin"]);
			update_option("linkedin", $linkedin);

			$youtube = sanitize_text_field($_POST["youtube"]);
			update_option("youtube", $youtube);

			?><div id="message" class="updated">Social Media Accounts Saved</div><?php
		}
		else
		{
			$twitter = get_option("twitter");
			$facebook = get_option("facebook");
			$linkedin = get_option("linkedin");
			$youtube = get_option("youtube");
		}

		?>
		<div class="wrap">
			<form method="POST" action="">
				<h2>Social Media Accounts</h2>

				<label for="twitter">Twitter :</label>
				<input type="text" name="twitter" value="<?php echo ($twitter != '')? $twitter : ''; ?>" size="100" />
				<br>
				<label for="facebook">Facebook :</label>
				<input type="text" name="facebook" value="<?php echo ($facebook != '')? $facebook : ''; ?>" size="100" />
				<br>
				<label for="linkedin">LinkedIn :</label>
				<input type="text" name="linkedin" value="<?php echo ($linkedin != '')? $linkedin : ''; ?>" size="100" />
				<br>
				<label for="youtube">YouTube :</label>
				<input type="text" name="youtube" value="<?php echo ($youtube != '')? $youtube : ''; ?>" size="100" />
				<br>
				<br>

				<input type="hidden" name="update_settings" value="Y" />
				<input type="submit" value="Save" class="button-primary"/>
			</form>
		</div>
		<?php

	}

}