Skip to content

Commit

Permalink
Merge branch 'master' into fields-ui-modifications
Browse files Browse the repository at this point in the history
  • Loading branch information
mboynes committed Dec 31, 2015
2 parents 99b02c9 + 73e422e commit 0c7dcc5
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
21 changes: 14 additions & 7 deletions php/class-fieldmanager-options.php
Expand Up @@ -65,13 +65,20 @@ public function __construct( $label = '', $options = array() ) {
fm_add_style( 'fm_options_css', 'css/fieldmanager-options.css' );

// Sanitization
$this->sanitize = function( $value ) {
if ( isset( $value ) && is_array( $value ) && !empty( $value ) ) {
return array_map( 'sanitize_text_field', $value );
} else {
return sanitize_text_field( $value );
}
};
$this->sanitize = array( $this, 'sanitize' );
}

/**
* Sanitize function that can handle arrays as well as string values.
* @param array|string $value
* @return array|string Sanitized $value
*/
public function sanitize( $value ) {
if ( isset( $value ) && is_array( $value ) && ! empty( $value ) ) {
return array_map( 'sanitize_text_field', $value );
} else {
return sanitize_text_field( $value );
}
}

/**
Expand Down
2 changes: 1 addition & 1 deletion php/context/class-fieldmanager-context-submenu.php
Expand Up @@ -94,7 +94,7 @@ public function render_submenu_page() {
<div class="updated success"><p><?php esc_html_e( 'Options updated', 'fieldmanager' ); ?></p></div>
<?php endif ?>

<h2><?php echo esc_html( $this->page_title ) ?></h2>
<h1><?php echo esc_html( $this->page_title ) ?></h1>

<form method="POST" id="<?php echo esc_attr( $this->uniqid ) ?>">
<div class="fm-submenu-form-wrapper">
Expand Down
2 changes: 1 addition & 1 deletion tests/php/test-fieldmanager-context-submenu.php
Expand Up @@ -29,7 +29,7 @@ public function test_submenu_context() {
$context = $this->get_context( $name );
$html = $this->get_html( $context, $name );

$this->assertContains( '<h2>Tools Meta Fields</h2>', $html );
$this->assertContains( '<h1>Tools Meta Fields</h1>', $html );
$this->assertRegExp( '/<input type="hidden"[^>]+name="fieldmanager-' . $name . '-nonce"/', $html );
$this->assertRegExp( '/<input[^>]+type="text"[^>]+name="' . $name . '\[name\]"[^>]+value=""/', $html );
$this->assertRegExp( '/<input[^>]+type="text"[^>]+name="' . $name . '\[email\]"[^>]+value=""/', $html );
Expand Down

0 comments on commit 0c7dcc5

Please sign in to comment.