Skip to content

Commit 52fab12

Browse files
committed
Implement titles in quicktext
closes #340
1 parent 6ea9ce1 commit 52fab12

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

php/context/class-fieldmanager-context-quickedit.php

+3
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,9 @@ public function add_quickedit_box( $column_name, $post_type, $values = array() )
123123
?>
124124
<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 ); ?>">
125125
<div class="inline-edit-col">
126+
<?php if ( ! empty( $this->title ) ) : ?>
127+
<h4><?php echo esc_html( $this->title ) ?></h4>
128+
<?php endif ?>
126129
<?php $this->render_field( array( 'data' => $values ) ); ?>
127130
</div>
128131
</fieldset>

tests/php/test-fieldmanager-context-quickedit.php

+19-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ private function _get_context( $fm ) {
5959
// The QuickEdit context absolutely requires we be in the edit.php
6060
// context, so we have to kind of fake it.
6161
$context->post_types = array( 'post' );
62-
$context->title = 'test_meta_box';
62+
$context->title = 'test meta box';
6363
$context->column_title = 'Custom Column';
6464
$context->column_display_callback = array( $this, '_quickedit_column' );
6565
$context->fm = $fm;
@@ -133,6 +133,24 @@ public function test_context_render() {
133133
$this->assertContains( 'name="base_group[test_extended][0][extext][0]"', $str );
134134
}
135135

136+
public function test_title() {
137+
$context = $this->_get_context( $this->_get_elements() );
138+
$context->title = rand_str();
139+
140+
ob_start();
141+
$context->add_quickedit_box( 'base_group', 'post' );
142+
$str = ob_get_clean();
143+
144+
$this->assertRegExp( "/<h4[^>]*>{$context->title}<\/h4>/", $str );
145+
146+
$context->title = false;
147+
ob_start();
148+
$context->add_quickedit_box( 'base_group', 'post' );
149+
$str = ob_get_clean();
150+
151+
$this->assertNotRegExp( '/<\/h4>/', $str );
152+
}
153+
136154
public function test_context_save() {
137155
$base = $this->_get_elements();
138156
$test_data = $this->_get_valid_test_data();

0 commit comments

Comments
 (0)