|
1
|
|
|
<?php |
|
|
|
|
|
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* GravityView_Default_Template_Table class. |
|
5
|
|
|
* Defines Table(default) template |
|
6
|
|
|
*/ |
|
7
|
|
|
class GravityView_Default_Template_Table extends GravityView_Template { |
|
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 (default)', 'gravityview' ), |
|
28
|
|
|
'description' => __( 'Display items in a table view.', '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', 'gravityview' ), |
|
43
|
|
|
'value' => false, |
|
44
|
|
|
'context' => 'directory' |
|
|
|
|
|
|
45
|
|
|
), |
|
46
|
|
|
); |
|
47
|
|
|
|
|
48
|
|
|
$areas = array( |
|
49
|
|
|
array( |
|
50
|
|
|
'1-1' => array( |
|
51
|
|
|
array( |
|
52
|
|
|
'areaid' => 'table-columns', |
|
53
|
|
|
'title' => __( 'Visible Table Columns', 'gravityview' ), |
|
54
|
|
|
'subtitle' => __( 'Each field will be displayed as a column in the table.', 'gravityview' ), |
|
55
|
|
|
) |
|
|
|
|
|
|
56
|
|
|
) |
|
57
|
|
|
) |
|
|
|
|
|
|
58
|
|
|
); |
|
59
|
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
61
|
|
|
parent::__construct( $id, $settings, $field_options, $areas ); |
|
62
|
|
|
|
|
63
|
|
|
} |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
new GravityView_Default_Template_Table; |
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.