GravityView  2.17
The best, easiest way to display Gravity Forms entries on your website.
class-gravityview-default-template-table.php
Go to the documentation of this file.
1 <?php
2 
3 /**
4  * GravityView_Default_Template_Table class.
5  * Defines Table(default) template
6  */
8 
9  function __construct( $id = 'default_table', $settings = array(), $field_options = array(), $areas = array() ) {
10 
11  /**
12  * @filter `gravityview/template/table/use-legacy-style` Should GravityView use the legacy Table layout stylesheet (from before Version 2.1)?
13  * @since 2.1.1
14  * @param bool $use_legacy_table_style If true, loads `table-view-legacy.css`. If false, loads `table-view.css`. Default: `false`
15  */
16  $use_legacy_table_style = apply_filters( 'gravityview/template/table/use-legacy-style', false );
17 
18  $css_filename = 'table-view.css';
19 
20  if ( $use_legacy_table_style ) {
21  $css_filename = 'table-view-legacy.css';
22  }
23 
24  $table_settings = array(
25  'slug' => 'table',
26  'type' => 'custom',
27  'label' => __( 'Table', 'gk-gravityview' ),
28  'description' => __( 'Display items in a table view.', 'gk-gravityview' ),
29  'logo' => plugins_url( 'includes/presets/default-table/logo-default-table.png', GRAVITYVIEW_FILE ),
30  'css_source' => gravityview_css_url( $css_filename, GRAVITYVIEW_DIR . 'templates/css/' ),
31  );
32 
33  $settings = wp_parse_args( $settings, $table_settings );
34 
35  /**
36  * @see GravityView_Admin_Views::get_default_field_options() for Generic Field Options
37  * @var array
38  */
39  $field_options = array(
40  'show_as_link' => array(
41  'type' => 'checkbox',
42  'label' => __( 'Link to single entry', 'gk-gravityview' ),
43  'value' => false,
44  'context' => 'directory',
45  'priority' => 1190,
46  'group' => 'display',
47  ),
48  );
49 
50  $areas = array(
51  array(
52  '1-1' => array(
53  array(
54  'areaid' => 'table-columns',
55  'title' => __( 'Visible Table Columns', 'gk-gravityview' ),
56  'subtitle' => __( 'Each field will be displayed as a column in the table.', 'gk-gravityview' ),
57  )
58  )
59  )
60  );
61 
62  $this->add_hooks();
63 
64  parent::__construct( $id, $settings, $field_options, $areas );
65 
66  }
67 
68  /**
69  * Adds hooks specific to this template
70  *
71  * @since 2.8.1
72  */
73  private function add_hooks() {
74  add_filter( 'gravityview/admin/add_button_label', array( $this, 'maybe_modify_button_label' ), 10, 2 );
75  }
76 
77  /**
78  * Changes the button label to reflect that fields = rows
79  *
80  * @internal
81  *
82  * @param string $label Text for button: "Add Widget" or "Add Field"
83  * @param array $atts {
84  * @type string $type 'widget' or 'field'
85  * @type string $template_id The current slug of the selected View template
86  * @type string $zone Where is this button being shown? Either 'single', 'directory', 'edit', 'header', 'footer'
87  * }
88  *
89  * @return string|void
90  */
91  public function maybe_modify_button_label( $label = '', $atts = array() ) {
92 
93  if( $this->template_id !== \GV\Utils::get( $atts, 'template_id' ) ) {
94  return $label;
95  }
96 
97  if( 'field' !== \GV\Utils::get( $atts, 'type' ) ) {
98  return $label;
99  }
100 
101  if( 'edit' === \GV\Utils::get( $atts, 'zone' ) ) {
102  return $label;
103  }
104 
105  return __( 'Add Table Column', 'gk-gravityview' );
106  }
107 }
108 
const GRAVITYVIEW_DIR
"GRAVITYVIEW_DIR" "./" The absolute path to the plugin directory, with trailing slash ...
Definition: gravityview.php:49
GravityView_Default_Template_Table class.
maybe_modify_button_label( $label='', $atts=array())
Changes the button label to reflect that fields = rows.
add_hooks()
Adds hooks specific to this template.
Class used to register a new template to be shown in GravityView presets.
gravityview_css_url( $css_file='', $dir_path='')
Functions that don&#39;t require GravityView or Gravity Forms API access but are used in the plugin to ex...
const GRAVITYVIEW_FILE
Full path to the GravityView file "GRAVITYVIEW_FILE" "./gravityview.php".
Definition: gravityview.php:40
__construct( $id, $settings=array(), $field_options=array(), $areas=array())