PluginProbe
TablePress – Tables in WordPress made easy / 2.2.4
TablePress – Tables in WordPress made easy v2.2.4
3.3.4 3.3.3 3.3.2 3.3.1 trunk 1.12 1.14 1.9.2 2.0.4 2.1.7 2.1.8 2.2 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.3 2.3.1 2.3.2 2.4 2.4.1 2.4.2 2.4.3 2.4.4 All 44 releases
tablepress / views / view-add.php

view-add.php in TablePress – Tables in WordPress made easy 2.2.4, at views/view-add.php

104 lines 3.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Add Table View
4 *
5 * @package TablePress
6 * @subpackage Views
7 * @author Tobias Bäthge
8 * @since 1.0.0
9 */
10
11 // Prohibit direct script loading.
12 defined( 'ABSPATH' ) || die( 'No direct script access allowed!' );
13
14 /**
15 * Add Table View class
16 *
17 * @package TablePress
18 * @subpackage Views
19 * @author Tobias Bäthge
20 * @since 1.0.0
21 */
22 class TablePress_Add_View extends TablePress_View {
23
24 /**
25 * Set up the view with data and do things that are specific for this view.
26 *
27 * @since 1.0.0
28 *
29 * @param string $action Action for this view.
30 * @param array<string, mixed> $data Data for this view.
31 */
32 #[\Override]
33 public function setup( /* string */ $action, array $data ) /* : void */ {
34 // Don't use type hints in the method declaration to prevent PHP errors, as the method is inherited.
35
36 parent::setup( $action, $data );
37
38 $this->process_action_messages( array(
39 'error_add' => __( 'Error: The table could not be added.', 'tablepress' ),
40 ) );
41
42 $this->add_text_box( 'head', array( $this, 'textbox_head' ), 'normal' );
43 $this->add_meta_box( 'add-table', __( 'Add New Table', 'tablepress' ), array( $this, 'postbox_add_table' ), 'normal' );
44 $this->data['submit_button_caption'] = __( 'Add Table', 'tablepress' );
45 $this->add_text_box( 'submit', array( $this, 'textbox_submit_button' ), 'submit' );
46 }
47
48 /**
49 * Print the screen head text.
50 *
51 * @since 1.0.0
52 *
53 * @param array<string, mixed> $data Data for this screen.
54 * @param array<string, mixed> $box Information about the text box.
55 */
56 public function textbox_head( array $data, array $box ): void {
57 ?>
58 <p>
59 <?php _e( 'To add a new table, enter its name, a description (optional), and the number of rows and columns into the form below.', 'tablepress' ); ?>
60 </p>
61 <p>
62 <?php _e( 'You can always change the name, description, and size of your table later.', 'tablepress' ); ?>
63 </p>
64 <?php
65 }
66
67 /**
68 * Print the content of the "Add New Table" post meta box.
69 *
70 * @since 1.0.0
71 *
72 * @param array<string, mixed> $data Data for this screen.
73 * @param array<string, mixed> $box Information about the meta box.
74 */
75 public function postbox_add_table( array $data, array $box ): void {
76 ?>
77 <div class="form-wrap">
78 <div class="form-field">
79 <label for="table-name"><?php _e( 'Table Name', 'tablepress' ); ?>:</label>
80 <input type="text" name="table[name]" id="table-name" value="" />
81 <p><?php _e( 'The name or title of your table.', 'tablepress' ); ?></p>
82 </div>
83 <div class="form-field">
84 <label for="table-description"><?php _e( 'Description', 'tablepress' ); ?> <?php _e( '(optional)', 'tablepress' ); ?>:</label>
85 <textarea name="table[description]" id="table-description" rows="4"></textarea>
86 <p><?php _e( 'A description of the contents of your table.', 'tablepress' ); ?></p>
87 </div>
88 <div class="form-field form-field-small">
89 <label for="table-rows"><?php _e( 'Number of Rows', 'tablepress' ); ?>:</label>
90 <input type="number" name="table[rows]" id="table-rows" class="small-text" title="<?php esc_attr_e( 'This field must contain a positive number.', 'tablepress' ); ?>" value="5" min="1" max="99999" required />
91 <p><?php _e( 'The number of rows in your table.', 'tablepress' ); ?></p>
92 </div>
93 <div class="form-field form-field-small">
94 <label for="table-columns"><?php _e( 'Number of Columns', 'tablepress' ); ?>:</label>
95 <input type="number" name="table[columns]" id="table-columns" class="small-text" title="<?php esc_attr_e( 'This field must contain a positive number.', 'tablepress' ); ?>" value="5" min="1" max="99999" required />
96 <p><?php _e( 'The number of columns in your table.', 'tablepress' ); ?></p>
97 </div>
98 <div class="clear"></div>
99 </div>
100 <?php
101 }
102
103 } // class TablePress_Add_View
104