Skip to content

mkpbd/option-page

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 

Repository files navigation

/**

  • Generated by the WordPress Option Page generator

*/

class OptionDemo { private $option_demo_options;

public function __construct() {
	add_action( 'admin_menu', array( $this, 'option_demo_add_plugin_page' ) );
	add_action( 'admin_init', array( $this, 'option_demo_page_init' ) );
}

public function option_demo_add_plugin_page() {
	add_options_page(
		'option demo', // page_title
		'option demo', // menu_title
		'manage_options', // capability
		'option-demo', // menu_slug
		array( $this, 'option_demo_create_admin_page' ) // function
	);
}

public function option_demo_create_admin_page() {
	$this->option_demo_options = get_option( 'option_demo_option_name' ); ?>

	<div class="wrap">
		<h2>option demo</h2>
		<p></p>
		<?php settings_errors(); ?>

		<form method="post" action="options.php">
			<?php
				settings_fields( 'option_demo_option_group' );
				do_settings_sections( 'option-demo-admin' );
				submit_button();
			?>
		</form>
	</div>
<?php }

public function option_demo_page_init() {
	register_setting(
		'option_demo_option_group', // option_group
		'option_demo_option_name', // option_name
		array( $this, 'option_demo_sanitize' ) // sanitize_callback
	);

	add_settings_section(
		'option_demo_setting_section', // id
		'Settings', // title
		array( $this, 'option_demo_section_info' ), // callback
		'option-demo-admin' // page
	);

	add_settings_field(
		'latitute_0', // id
		'latitute', // title
		array( $this, 'latitute_0_callback' ), // callback
		'option-demo-admin', // page
		'option_demo_setting_section' // section
	);

	add_settings_field(
		'logtitue_1', // id
		'logtitue', // title
		array( $this, 'logtitue_1_callback' ), // callback
		'option-demo-admin', // page
		'option_demo_setting_section' // section
	);

	add_settings_field(
		'zoomlabel_2', // id
		'zoomlabel', // title
		array( $this, 'zoomlabel_2_callback' ), // callback
		'option-demo-admin', // page
		'option_demo_setting_section' // section
	);

	add_settings_field(
		'apikey_3', // id
		'apikey', // title
		array( $this, 'apikey_3_callback' ), // callback
		'option-demo-admin', // page
		'option_demo_setting_section' // section
	);

	add_settings_field(
		'externalcss_4', // id
		'externalcss', // title
		array( $this, 'externalcss_4_callback' ), // callback
		'option-demo-admin', // page
		'option_demo_setting_section' // section
	);
}

public function option_demo_sanitize($input) {
	$sanitary_values = array();
	if ( isset( $input['latitute_0'] ) ) {
		$sanitary_values['latitute_0'] = sanitize_text_field( $input['latitute_0'] );
	}

	if ( isset( $input['logtitue_1'] ) ) {
		$sanitary_values['logtitue_1'] = sanitize_text_field( $input['logtitue_1'] );
	}

	if ( isset( $input['zoomlabel_2'] ) ) {
		$sanitary_values['zoomlabel_2'] = sanitize_text_field( $input['zoomlabel_2'] );
	}

	if ( isset( $input['apikey_3'] ) ) {
		$sanitary_values['apikey_3'] = sanitize_text_field( $input['apikey_3'] );
	}

	if ( isset( $input['externalcss_4'] ) ) {
		$sanitary_values['externalcss_4'] = sanitize_text_field( $input['externalcss_4'] );
	}

	return $sanitary_values;
}

public function option_demo_section_info() {
	
}

public function latitute_0_callback() {
	printf(
		'<input class="regular-text" type="text" name="option_demo_option_name[latitute_0]" id="latitute_0" value="%s">',
		isset( $this->option_demo_options['latitute_0'] ) ? esc_attr( $this->option_demo_options['latitute_0']) : ''
	);
}

public function logtitue_1_callback() {
	printf(
		'<input class="regular-text" type="text" name="option_demo_option_name[logtitue_1]" id="logtitue_1" value="%s">',
		isset( $this->option_demo_options['logtitue_1'] ) ? esc_attr( $this->option_demo_options['logtitue_1']) : ''
	);
}

public function zoomlabel_2_callback() {
	printf(
		'<input class="regular-text" type="text" name="option_demo_option_name[zoomlabel_2]" id="zoomlabel_2" value="%s">',
		isset( $this->option_demo_options['zoomlabel_2'] ) ? esc_attr( $this->option_demo_options['zoomlabel_2']) : ''
	);
}

public function apikey_3_callback() {
	printf(
		'<input class="regular-text" type="text" name="option_demo_option_name[apikey_3]" id="apikey_3" value="%s">',
		isset( $this->option_demo_options['apikey_3'] ) ? esc_attr( $this->option_demo_options['apikey_3']) : ''
	);
}

public function externalcss_4_callback() {
	printf(
		'<input class="regular-text" type="text" name="option_demo_option_name[externalcss_4]" id="externalcss_4" value="%s">',
		isset( $this->option_demo_options['externalcss_4'] ) ? esc_attr( $this->option_demo_options['externalcss_4']) : ''
	);
}

} if ( is_admin() ) $option_demo = new OptionDemo();

/*

  • Retrieve this value with:
  • $option_demo_options = get_option( 'option_demo_option_name' ); // Array of All Options
  • $latitute_0 = $option_demo_options['latitute_0']; // latitute
  • $logtitue_1 = $option_demo_options['logtitue_1']; // logtitue
  • $zoomlabel_2 = $option_demo_options['zoomlabel_2']; // zoomlabel
  • $apikey_3 = $option_demo_options['apikey_3']; // apikey
  • $externalcss_4 = $option_demo_options['externalcss_4']; // externalcss */

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published