PluginProbe
TablePress – Tables in WordPress made easy / 3.4
TablePress – Tables in WordPress made easy v3.4
3.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 All 45 releases
tablepress / views / view-editor_button_thickbox.php

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

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