Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
OOP Settings Page
/**
* Admin page markup
* @since 0.1.0
*/
public function admin_page_display() {
self::admin_page_setup();
?>
<div class="wrap cmb_options_page <?php echo self::$key; ?>">
<h2><?php echo esc_html( get_admin_page_title() ) . ' Settings'; ?></h2>
<form method="post" action="options.php">
<?php settings_fields( self::$key ); ?>
<?php do_settings_sections( self::$key ); ?>
<?php submit_button(); ?>
</form>
</div>
<?php
}
/**
* Defines the plugin option page sections and fields
* @since 0.1.0
* @return array
*/
public static function admin_page_setup() {
add_settings_section(
'fb_pxl_display_on',
'Display Facebook Conversion Pixel fields on:',
'',
self::$key
);
add_settings_field(
'fb_pxl_display_on_posts',
'Posts',
array( $this, 'fb_pxl_display_on_posts_output' ),
self::$key,
'fb_pxl_display_on'
);
}
public static function fb_pxl_display_on_posts_output() {
$value = isset( self::$fb_pxl_options[ 'posts' ] ) ?
$options[ 'test_value' ] : '';
$html = '<input type="checkbox" id="fb_pxl_disable_posts" name="self::$fb_pxl_options[posts]" value="on"' . checked($value, "on", false) . '/>';
echo $html;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.