I am having a satan of a time getting my plugin settings to save lots of. I’ve gone by way of the code so many instances I’ve to assume I’ve merely missed one thing. I am following the Setting API, however any adjustments I make on the plugin settings web page do not save. What did I miss?
operate __construct() {
self::$occasion = $this;
// Add "Settings" hyperlink to plugin web page
add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ) , array( $this, 'settings_link' ) );
// Creates the CEMB Seminar submenu
add_action( 'admin_menu', array( $this, 'add_menu' ) );
// Register and outline the settings
add_action( 'admin_init', array( $this, 'settings_init' ) );
} // Finish of __construct()
/***** Menus *****/
// Add "Settings" hyperlink to plugin web page
operate settings_link( $hyperlinks ) {
$settings_link = sprintf( '<a href="%s">%s</a>', admin_url( 'options-general.php?web page=cemb-seminar' ), __( 'Settings' ) );
array_unshift( $hyperlinks, $settings_link );
return $hyperlinks;
}
// Creates the CEMB Seminar submenu
operate add_menu() {
add_submenu_page(
'edit.php?post_type=cemb_seminar',
__( 'Course Necessities' ),
__( 'Course Necessities' ),
'manage_options',
'cemb-seminar',
array( $this, 'settings_page' )
);
}
/***** Course Requirement Settings *****/
/* Creates new database fields */
operate settings_init() {
$choices = array(
'cemb_seminar_seminars_college' => '0',
'cemb_seminar_showcases_college' => '0',
'cemb_seminar_writers_college' > '0',
'cemb_seminar_aet_college' => '0',
'cemb_seminar_mbu_college' => '0',
'cemb_seminar_eis_college' => '0',
'cemb_seminar_sng_college' => '0',
);
update_option( 'cemb_seminar_options', $choices );
register_setting(
'cemb_seminar_options',
'cemb_seminar_options'
);
add_settings_section(
'cemb_seminar_reqs_college',
'Course Necessities',
array( $this, 'reqs_college_fn' ),
'cemb-seminar'
);
add_settings_field(
'cemb_seminar_seminars_college_field',
'Seminars',
array( $this, 'seminars_college_fn' ),
'cemb-seminar',
'cemb_seminar_reqs_college'
);
add_settings_field(
'cemb_seminar_showcases_college_field',
'Showcases',
array( $this, 'showcases_college_fn' ),
'cemb-seminar',
'cemb_seminar_reqs_college'
);
add_settings_field(
'cemb_seminar_writers_college_field',
'Author's Nights',
array( $this, 'writers_college_fn' ),
'cemb-seminar',
'cemb_seminar_reqs_college'
);
add_settings_field(
'cemb_seminar_aet_college_field',
'AET Seminars',
array( $this, 'aet_college_fn' ),
'cemb-seminar',
'cemb_seminar_reqs_college'
);
add_settings_field(
'cemb_seminar_mbu_college_field',
'MBU Seminars',
array( $this, 'mbu_college_fn' ),
'cemb-seminar',
'cemb_seminar_reqs_college'
);
add_settings_field(
'cemb_seminar_eis_college_field',
'EIS Seminars',
array( $this, 'eis_college_fn' ),
'cemb-seminar',
'cemb_seminar_reqs_college'
);
add_settings_field(
'cemb_seminar_sng_college_field',
'SNG Seminars',
array( $this, 'sng_college_fn' ),
'cemb-seminar',
'cemb_seminar_reqs_college'
);
} // Finish of settings_init()
// Add word concerning the course necessities settings
operate reqs_college_fn() {
echo '<p>The course requirement choices beneath will apply to all college students for all majors.</p>';
}
// Checks for the chosen worth within the drop menus
operate course_req_selected( $chosen, $possibility ) {
// Get choices first
$choices = get_option( 'cemb_seminar_options' );
// Test if the choice matches the enter
if ( $choices['$option'] == $chosen ) {
echo ' chosen="chosen"';
}
} // Finish of course_req_selected()
// Add college-wide Seminars necessities Discipline
operate seminars_college_fn() {
// Get choices from database
$choices = get_option( 'cemb_seminar_options' );
$possibility = $choices['cemb_seminar_seminars_college'];
// Construct the choose type ?>
<choose id="cemb_seminar_seminars_college" class="cemb_seminar_settings_field" title="cemb_seminar_options[cemb_seminar_seminars_college]">
<possibility worth="0" <?php if ( $possibility == '0' ) { echo 'chosen="chosen"'; } ?>>0</possibility>
<possibility worth="1" <?php if ( $possibility == '1' ) { echo 'chosen="chosen"'; } ?>>1</possibility>
<possibility worth="2" <?php if ( $possibility == '2' ) { echo 'chosen="chosen"'; } ?>>2</possibility>
<possibility worth="3" <?php if ( $possibility == '3' ) { echo 'chosen="chosen"'; } ?>>3</possibility>
<possibility worth="4" <?php if ( $possibility == '4' ) { echo 'chosen="chosen"'; } ?>>4</possibility>
<possibility worth="5" <?php if ( $possibility == '5' ) { echo 'chosen="chosen"'; } ?>>5</possibility>
</choose> <?php
} // Finish of seminars_college_fn()
// Add college-wide Showcases necessities Discipline
operate showcases_college_fn() {
// Get choices from database
$choices = get_option( 'cemb_seminar_options' );
$possibility = $choices['cemb_seminar_showcases_college'];
// Construct the choose type ?>
<choose id="cemb_seminar_showcases_college" class="cemb_seminar_settings_field" title="cemb_seminar_options[cemb_seminar_showcases_college]">
<possibility worth="0" <?php if ( $possibility == '0' ) { echo 'chosen="chosen"'; } ?>>0</possibility>
<possibility worth="1" <?php if ( $possibility == '1' ) { echo 'chosen="chosen"'; } ?>>1</possibility>
<possibility worth="2" <?php if ( $possibility == '2' ) { echo 'chosen="chosen"'; } ?>>2</possibility>
<possibility worth="3" <?php if ( $possibility == '3' ) { echo 'chosen="chosen"'; } ?>>3</possibility>
<possibility worth="4" <?php if ( $possibility == '4' ) { echo 'chosen="chosen"'; } ?>>4</possibility>
<possibility worth="5" <?php if ( $possibility == '5' ) { echo 'chosen="chosen"'; } ?>>5</possibility>
</choose> <?php
} // Finish of showcases_college_fn()
// Add college-wide Author's Evening necessities area
operate writers_college_fn() {
// Get choices from database
$choices = get_option( 'cemb_seminar_options' );
$possibility = $choices['cemb_seminar_writers_college'];
// Construct the choose type */?>
<choose id="cemb_seminar_writers_college" class="cemb_seminar_settings_field" title="cemb_seminar_options[cemb_seminar_writers_college]">
<possibility worth="0" <?php if ( $possibility == '0' ) { echo 'chosen="chosen"'; } ?>>0</possibility>
<possibility worth="1" <?php if ( $possibility == '1' ) { echo 'chosen="chosen"'; } ?>>1</possibility>
<possibility worth="2" <?php if ( $possibility == '2' ) { echo 'chosen="chosen"'; } ?>>2</possibility>
<possibility worth="3" <?php if ( $possibility == '3' ) { echo 'chosen="chosen"'; } ?>>3</possibility>
<possibility worth="4" <?php if ( $possibility == '4' ) { echo 'chosen="chosen"'; } ?>>4</possibility>
<possibility worth="5" <?php if ( $possibility == '5' ) { echo 'chosen="chosen"'; } ?>>5</possibility>
</choose> <?php
} // Finish of writers_college_fn()
// Add college-wide AET Seminars necessities area
operate aet_college_fn() {
// Get choices from database
$choices = get_option( 'cemb_seminar_options' );
$possibility = $choices['cemb_seminar_aet_college'];
// Construct the choose type ?>
<choose id="cemb_seminar_aet_college" class="cemb_seminar_settings_field" title="cemb_seminar_options[cemb_seminar_aet_college]">
<possibility worth="0" <?php if ( $possibility == '0' ) { echo 'chosen="chosen"'; } ?>>0</possibility>
<possibility worth="1" <?php if ( $possibility == '1' ) { echo 'chosen="chosen"'; } ?>>1</possibility>
<possibility worth="2" <?php if ( $possibility == '2' ) { echo 'chosen="chosen"'; } ?>>2</possibility>
<possibility worth="3" <?php if ( $possibility == '3' ) { echo 'chosen="chosen"'; } ?>>3</possibility>
<possibility worth="4" <?php if ( $possibility == '4' ) { echo 'chosen="chosen"'; } ?>>4</possibility>
<possibility worth="5" <?php if ( $possibility == '5' ) { echo 'chosen="chosen"'; } ?>>5</possibility>
</choose> <?php
} // Finish of aet_college_fn()
// Add college-wide MBU Seminars necessities area
operate mbu_college_fn() {
// Get choices from database
$choices = get_option( 'cemb_seminar_options' );
$possibility = $choices['cemb_seminar_mbu_college'];
// Construct the choose type ?>
<choose id="cemb_seminar_mbu_college" class="cemb_seminar_settings_field" title="cemb_seminar_options[cemb_seminar_mbu_college]">
<possibility worth="0" <?php if ( $possibility == '0' ) { echo 'chosen="chosen"'; } ?>>0</possibility>
<possibility worth="1" <?php if ( $possibility == '1' ) { echo 'chosen="chosen"'; } ?>>1</possibility>
<possibility worth="2" <?php if ( $possibility == '2' ) { echo 'chosen="chosen"'; } ?>>2</possibility>
<possibility worth="3" <?php if ( $possibility == '3' ) { echo 'chosen="chosen"'; } ?>>3</possibility>
<possibility worth="4" <?php if ( $possibility == '4' ) { echo 'chosen="chosen"'; } ?>>4</possibility>
<possibility worth="5" <?php if ( $possibility == '5' ) { echo 'chosen="chosen"'; } ?>>5</possibility>
</choose> <?php
} // Finish of mbu_college_fn()
// Add college-wide EIS Seminars necessities area
operate eis_college_fn() {
// Get choices from database
$choices = get_option( 'cemb_seminar_options' );
$possibility = $choices['cemb_seminar_eis_college'];
// Construct the choose type ?>
<choose id="cemb_seminar_eis_college" class="cemb_seminar_settings_field" title="cemb_seminar_options[cemb_seminar_eis_college]">
<possibility worth="0" <?php if ( $possibility == '0' ) { echo 'chosen="chosen"'; } ?>>0</possibility>
<possibility worth="1" <?php if ( $possibility == '1' ) { echo 'chosen="chosen"'; } ?>>1</possibility>
<possibility worth="2" <?php if ( $possibility == '2' ) { echo 'chosen="chosen"'; } ?>>2</possibility>
<possibility worth="3" <?php if ( $possibility == '3' ) { echo 'chosen="chosen"'; } ?>>3</possibility>
<possibility worth="4" <?php if ( $possibility == '4' ) { echo 'chosen="chosen"'; } ?>>4</possibility>
<possibility worth="5" <?php if ( $possibility == '5' ) { echo 'chosen="chosen"'; } ?>>5</possibility>
</choose> <?php
} // Finish of eis_college_fn()
// Add college-wide SNG Seminars necessities area
operate sng_college_fn() {
// Get choices from database
$choices = get_option( 'cemb_seminar_options' );
$possibility = $choices['cemb_seminar_sng_college'];
// Construct the choose type ?>
<choose id="cemb_seminar_sng_college" class="cemb_seminar_settings_field" title="cemb_seminar_options[cemb_seminar_sng_college]">
<possibility worth="0" <?php if ( $possibility == '0' ) { echo 'chosen="chosen"'; } ?>>0</possibility>
<possibility worth="1" <?php if ( $possibility == '1' ) { echo 'chosen="chosen"'; } ?>>1</possibility>
<possibility worth="2" <?php if ( $possibility == '2' ) { echo 'chosen="chosen"'; } ?>>2</possibility>
<possibility worth="3" <?php if ( $possibility == '3' ) { echo 'chosen="chosen"'; } ?>>3</possibility>
<possibility worth="4" <?php if ( $possibility == '4' ) { echo 'chosen="chosen"'; } ?>>4</possibility>
<possibility worth="5" <?php if ( $possibility == '5' ) { echo 'chosen="chosen"'; } ?>>5</possibility>
</choose> <?php
} // Finish of sng_college_fn()
// Creates the course necessities web page
operate settings_page() {
?>
<div class="wrap">
<div class="icon32" fashion="background-image:url(<?php echo WP_PLUGIN_URL . '/cemb-seminar/photos/cemb-logo32x32.png'; ?>); background-repeat:no-repeat;"><br /></div>
<h2>Course Necessities</h2>
<type methodology="put up" motion="choices.php">
<?php settings_fields( 'cemb_seminar_options' ); ?>
<?php do_settings_sections( 'cemb-seminar' ); ?>
<br />
<enter class="button-primary" sort="submit" title="Submit" worth=" <?php _e( 'Save Settings' ); ?> " />
</type>
</div> <?php
} // Finish of settings_page()