PluginProbe
TablePress – Tables in WordPress made easy / 3.0
TablePress – Tables in WordPress made easy v3.0
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-editor_button_thickbox.php

view-editor_button_thickbox.php in TablePress – Tables in WordPress made easy 3.0, at views/view-editor_button_thickbox.php

157 lines 4.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Editor Button Thickbox List 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 * Editor Button Thickbox List View class
16 *
17 * @package TablePress
18 * @subpackage Views
19 * @author Tobias Bäthge
20 * @since 1.0.0
21 */
22 class TablePress_Editor_Button_Thickbox_View extends TablePress_View {
23
24 /**
25 * Object for the Editor Button Thickbox List Table.
26 *
27 * @since 1.0.0
28 */
29 protected \TablePress_Editor_Button_Thickbox_List_Table $wp_list_table;
30
31 /**
32 * Initializes the View class.
33 *
34 * @since 1.0.0
35 */
36 public function __construct() {
37 // Intentionally left empty, to void code from parent::__construct().
38 }
39
40 /**
41 * Sets up the view with data and do things that are specific for this view.
42 *
43 * @since 1.0.0
44 *
45 * @param string $action Action for this view.
46 * @param array<string, mixed> $data Data for this view.
47 */
48 #[\Override]
49 public function setup( /* string */ $action, array $data ) /* : void */ {
50 // Don't use type hints in the method declaration to prevent PHP errors, as the method is inherited.
51
52 $this->action = $action;
53 $this->data = $data;
54
55 $this->wp_list_table = TablePress::load_class( 'TablePress_Editor_Button_Thickbox_List_Table', 'class-editor-button-thickbox-list-table.php', 'views' );
56
57 $this->wp_list_table->set_items( $this->data['table_ids'] );
58 $this->wp_list_table->prepare_items();
59 }
60
61 /**
62 * Renders the current view.
63 *
64 * @since 1.0.0
65 */
66 #[\Override]
67 public function render(): void {
68 _wp_admin_html_begin();
69
70 wp_print_styles( 'colors' );
71 wp_print_scripts( 'jquery-core' );
72 ?>
73 <title><?php printf( __( '%1$s &lsaquo; %2$s', 'tablepress' ), __( 'List of Tables', 'tablepress' ), 'TablePress' ); ?></title>
74 <style>
75 /* Account for .wp-toolbar. */
76 html {
77 padding-top: 0 !important;
78 }
79 #tablepress-page {
80 margin: 0 15px;
81 padding: 0 0 15px 0;
82 }
83 #tablepress-page .subtitle {
84 float: left;
85 padding: 10px 0 0;
86 }
87 #tablepress-page p.search-box {
88 position: relative;
89 }
90 /* Width and font weight for the columns. */
91 .tablepress-editor-button-list thead .column-table_id {
92 width: 50px;
93 }
94 .tablepress-editor-button-list tbody .column-table_id,
95 .tablepress-editor-button-list tbody .column-table_name {
96 font-weight: bold;
97 }
98 .tablepress-editor-button-list thead .column-table_action {
99 min-width: 150px;
100 }
101 /* Responsiveness on the All Tables screen. */
102 @media screen and (max-width: 782px) {
103 .tablepress-editor-button-list .column-table_id {
104 display: none !important;
105 padding: 3px 8px 3px 35%;
106 }
107 }
108 <?php if ( is_rtl() ) : ?>
109 /* RTL CSS */
110 .rtl #tablepress-page .subtitle {
111 float: right;
112 }
113 <?php endif; ?>
114 </style>
115 </head>
116 <body class="wp-admin wp-core-ui js iframe<?php echo is_rtl() ? ' rtl' : ''; ?>">
117 <div id="tablepress-page" class="wrap">
118 <h1><?php printf( __( '%1$s &lsaquo; %2$s', 'tablepress' ), __( 'List of Tables', 'tablepress' ), 'TablePress' ); ?></h1>
119 <div id="poststuff">
120 <p><?php _e( 'This is a list of your tables.', 'tablepress' ); ?> <?php _e( 'You may insert a table into a post or page here.', 'tablepress' ); ?></p>
121 <p><?php printf( __( 'Click the “%1$s” button for the desired table to automatically insert its Shortcode into the editor.', 'tablepress' ), __( 'Insert Shortcode', 'tablepress' ) ); ?></p>
122 <?php
123 if ( ! empty( $_GET['s'] ) ) {
124 printf( '<span class="subtitle">' . __( 'Search results for &#8220;%s&#8221;', 'tablepress' ) . '</span>', esc_html( wp_unslash( $_GET['s'] ) ) );
125 }
126 ?>
127 <form method="get">
128 <input type="hidden" name="action" value="tablepress_<?php echo $this->action; ?>">
129 <?php
130 wp_nonce_field( TablePress::nonce( $this->action ), '_wpnonce', false );
131 $this->wp_list_table->search_box( __( 'Search Tables', 'tablepress' ), 'tables_search' );
132 ?>
133 </form>
134 <?php $this->wp_list_table->display(); ?>
135 </div>
136 </div>
137 <script>
138 jQuery( function( $ ) {
139 // Toggle list table rows on small screens.
140 $( '.tablepress-editor-button-list' )
141 .on( 'click', 'tr', function() {
142 this.classList.toggle( 'is-expanded' );
143 })
144 .on( 'click', '.insert-shortcode', function() {
145 const win = window.dialogArguments || opener || parent || top;
146 win.send_to_editor( this.title );
147 } );
148 } );
149 </script>
150 </body>
151 </html>
152 <?php
153 }
154
155 } // class TablePress_Editor_Button_View
156
157