Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds new field option for full width, New filter for table markup and… #2147

16 changes: 10 additions & 6 deletions future/includes/class-gv-template-entry-table.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,15 +94,19 @@ public function the_entry() {
*/
$hide_empty = apply_filters( 'gravityview/render/hide-empty-zone', $this->view->settings->get( 'hide_empty_single', false ), $context );

$markup = '<tr id="{{ field_id }}" class="{{ class }}"><th scope="row">{{ label }}</th><td>{{ value }}</td></tr>';

/**
* Modify the markup for a table row.
* Modifies the table row markup for an entry.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@omarkasem, please take note of how we document filters. Also check the other changes in this and 5f9589e commits.

*
* @filter `gravityview/template/table/entry/markup`
*
* @since 2.29.0
*
* @since TBD
*
* @param string $markup The markup.
* @param \GV\Field $field The field.
* @param string $markup The markup.
* @param \GV\Field $field The field.
*/
$markup = apply_filters( 'gravityview/template/table/entry/markup', '<tr id="{{ field_id }}" class="{{ class }}"><th scope="row">{{ label }}</th><td>{{ value }}</td></tr>', $field );
$markup = apply_filters( 'gravityview/template/table/entry/markup', $markup, $field );

echo \gravityview_field_output(
array(
Expand Down
12 changes: 8 additions & 4 deletions includes/fields/class-gravityview-field-custom.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,18 @@ public function __construct() {
}

/**
* Make the Custom Content field full width in the table template if full width is enabled.
* Makes the Custom Content field full width in the table template when enabled in the field settings.
*
* @param string $markup
* @since 2.29.0
*
* @param string $markup
* @param \GV\Field $field
*
* @return string
*/
public function filter_table_entry_markup( $markup, $field ) {
$field_settings = $field->as_configuration();

if ( isset( $field_settings['full_width'] ) && 1 === (int) $field_settings['full_width'] ) {
$markup = '<tr id="{{ field_id }}" class="{{ class }}"><td colspan="2">{{ value }}</td></tr>';
}
Expand Down Expand Up @@ -111,8 +115,8 @@ public function field_options( $field_options, $template_id, $field_id, $context
if ( 'single' === $context && strpos( $template_id, 'table' ) !== false ) {
$new_fields['full_width'] = array(
'type' => 'checkbox',
'label' => __( 'Full Width', 'gk-gravityview' ),
'desc' => __( 'Display the field in full width (Label will be hidden).', 'gk-gravityview' ),
'label' => __( 'Full width', 'gk-gravityview' ),
'desc' => __( 'Show the field at full width without the label.', 'gk-gravityview' ),
'value' => '',
'group' => 'field',
);
Expand Down