Skip to content

Commit

Permalink
Merge pull request alleyinteractive#343 from alleyinteractive/quicked…
Browse files Browse the repository at this point in the history
…it-title

Implement titles in quicktext
  • Loading branch information
mboynes committed Jan 4, 2016
2 parents d3b94e6 + 8dd191b commit eab5610
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
3 changes: 3 additions & 0 deletions php/context/class-fieldmanager-context-quickedit.php
Expand Up @@ -123,6 +123,9 @@ public function add_quickedit_box( $column_name, $post_type, $values = array() )
?>
<fieldset class="inline-edit-col-left fm-quickedit" id="fm-quickedit-<?php echo esc_attr( $column_name ); ?>" data-fm-post-type="<?php echo esc_attr( $post_type ); ?>">
<div class="inline-edit-col">
<?php if ( ! empty( $this->title ) ) : ?>
<h4><?php echo esc_html( $this->title ) ?></h4>
<?php endif ?>
<?php $this->render_field( array( 'data' => $values ) ); ?>
</div>
</fieldset>
Expand Down
20 changes: 19 additions & 1 deletion tests/php/test-fieldmanager-context-quickedit.php
Expand Up @@ -59,7 +59,7 @@ private function _get_context( $fm ) {
// The QuickEdit context absolutely requires we be in the edit.php
// context, so we have to kind of fake it.
$context->post_types = array( 'post' );
$context->title = 'test_meta_box';
$context->title = 'test meta box';
$context->column_title = 'Custom Column';
$context->column_display_callback = array( $this, '_quickedit_column' );
$context->fm = $fm;
Expand Down Expand Up @@ -133,6 +133,24 @@ public function test_context_render() {
$this->assertContains( 'name="base_group[test_extended][0][extext][0]"', $str );
}

public function test_title() {
$context = $this->_get_context( $this->_get_elements() );
$context->title = rand_str();

ob_start();
$context->add_quickedit_box( 'base_group', 'post' );
$str = ob_get_clean();

$this->assertRegExp( "/<h4[^>]*>{$context->title}<\/h4>/", $str );

$context->title = false;
ob_start();
$context->add_quickedit_box( 'base_group', 'post' );
$str = ob_get_clean();

$this->assertNotRegExp( '/<\/h4>/', $str );
}

public function test_context_save() {
$base = $this->_get_elements();
$test_data = $this->_get_valid_test_data();
Expand Down

0 comments on commit eab5610

Please sign in to comment.