Or, embed this snippet using GenerateWP WordPress Plugin.

Download

Clone

SMCS Profile

class SMCS_Settings_Page {

	public function __construct() {

		add_action( 'admin_menu', array( $this, 'add_admin_menu' ) );
		add_action( 'admin_init', array( $this, 'init_settings'  ) );

	}

	public function add_admin_menu() {

		add_menu_page(
			esc_html__( 'SMCS Options', 'smcs' ),
			esc_html__( 'SMCS Options', 'smcs' ),
			'manage_options',
			'smcs_options',
			array( $this, 'page_layout' ),
			'dashicons-forms',
			99
		);

	}

	public function init_settings() {

		register_setting(
			'smcs_settings_group',
			'smcs_options'
		);

		add_settings_section(
			'smcs_options_section',
			'',
			false,
			'smcs_options'
		);

		add_settings_field(
			'smcs_notices',
			__( 'Profile Notices', 'smcs' ),
			array( $this, 'render_smcs_notices_field' ),
			'smcs_options',
			'smcs_options_section'
		);

	}

	public function page_layout() {

		// Check required user capability
		if ( !current_user_can( 'manage_options' ) )  {
			wp_die( esc_html__( 'You do not have sufficient permissions to access this page.', 'smcs' ) );
		}

		// Admin Page Layout
		echo '<div class="wrap">' . "n";
		echo '	<h1>' . get_admin_page_title() . '</h1>' . "n";
		echo '	<form action="options.php" method="post">' . "n";

		settings_fields( 'smcs_settings_group' );
		do_settings_sections( 'smcs_options' );
		submit_button();

		echo '	</form>' . "n";
		echo '</div>' . "n";

	}

	function render_smcs_notices_field() {

		// Retrieve data from the database.
		$options = get_option( 'smcs_options' );

		// Set default value.
		$value = isset( $options['smcs_notices'] ) ? $options['smcs_notices'] : '';

		// Field output.
		echo '<select name="smcs_options[smcs_notices]" class="smcs_notices_field">';
		echo '	<option value="post_id1" ' . selected( $value, 'post_id1', false ) . '> ' . __( 'Post Name 1', 'smcs' ) . '</option>';
		echo '	<option value="post_id2" ' . selected( $value, 'post_id2', false ) . '> ' . __( 'Post Name 2', 'smcs' ) . '</option>';
		echo '	<option value="post_id3" ' . selected( $value, 'post_id3', false ) . '> ' . __( 'Post Name 3', 'smcs' ) . '</option>';
		echo '</select>';
		echo '<p class="description">' . __( 'Select the views to show as alerts on the user profile page.', 'smcs' ) . '</p>';

	}

}

new SMCS_Settings_Page;