Permalink
Browse files

Implementing a text area element and sanitization functionality

  • Loading branch information...
1 parent fb7de6a commit bd9e2165a1da62d6e650d3dcffecb5be53aece95 @tommcfarlin committed Apr 10, 2012
Showing with 22 additions and 1 deletion.
  1. +18 −1 functions.php
  2. +4 −0 index.php
View
19 functions.php
@@ -173,7 +173,7 @@ function sandbox_initialize_theme_options() {
add_action( 'admin_init', 'sandbox_initialize_theme_options' );
/**
- * Initializes the theme's social optoions by registering the Sections,
+ * Initializes the theme's social options by registering the Sections,
* Fields, and Settings.
*
* This function is registered with the 'admin_init' hook.
@@ -252,6 +252,14 @@ function sandbox_theme_initialize_input_examples() {
'input_examples_section'
);
+ add_settings_field(
+ 'Textarea Element',
+ 'Textarea Element',
+ 'sandbox_textarea_element_callback',
+ 'sandbox_theme_input_examples',
+ 'input_examples_section'
+ );
+
register_setting(
'sandbox_theme_input_examples',
'sandbox_theme_input_examples',
@@ -396,6 +404,15 @@ function sandbox_input_element_callback() {
} // end sandbox_input_element_callback
+function sandbox_textarea_element_callback() {
+
+ $options = get_option( 'sandbox_theme_input_examples' );
+
+ // Render the output
+ echo '<textarea id="textarea_example" name="sandbox_theme_input_examples[textarea_example]" rows="5" cols="50">' . $options['textarea_example'] . '</textarea>';
+
+} // end sandbox_textarea_element_callback
+
/* ------------------------------------------------------------------------ *
* Setting Callbacks
* ------------------------------------------------------------------------ */
View
4 index.php
@@ -32,6 +32,10 @@
<?php if( $input_examples[ 'input_example' ] ) { ?>
<?php echo sanitize_text_field( $input_examples['input_example'] ); ?>
<?php } // end if ?>
+
+ <?php if( $input_examples[ 'textarea_example' ] ) { ?>
+ <?php echo sanitize_text_field( $input_examples['textarea_example'] ); ?>
+ <?php } // end if ?>
</body>
</html>

0 comments on commit bd9e216

Please sign in to comment.