PluginProbe
TablePress – Tables in WordPress made easy / 2.2
TablePress – Tables in WordPress made easy v2.2
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 2.2, at views/view-editor_button_thickbox.php

156 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 * @var TablePress_Editor_Button_Thickbox_List_Table
29 */
30 protected $wp_list_table;
31
32 /**
33 * Initializes the View class.
34 *
35 * @since 1.0.0
36 */
37 public function __construct() {
38 // Intentionally left empty, to void code from parent::__construct().
39 }
40
41 /**
42 * Sets up the view with data and do things that are specific for this view.
43 *
44 * @since 1.0.0
45 *
46 * @param string $action Action for this view.
47 * @param array<string, mixed> $data Data for this view.
48 */
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 public function render(): void {
67 _wp_admin_html_begin();
68
69 wp_print_styles( 'colors' );
70 wp_print_scripts( 'jquery-core' );
71 ?>
72 <title><?php printf( __( '%1$s &lsaquo; %2$s', 'tablepress' ), __( 'List of Tables', 'tablepress' ), 'TablePress' ); ?></title>
73 <style>
74 /* Account for .wp-toolbar. */
75 html {
76 padding-top: 0 !important;
77 }
78 #tablepress-page {
79 margin: 0 15px;
80 padding: 0 0 15px 0;
81 }
82 #tablepress-page .subtitle {
83 float: left;
84 padding: 10px 0 0;
85 }
86 #tablepress-page p.search-box {
87 position: relative;
88 }
89 /* Width and font weight for the columns. */
90 .tablepress-editor-button-list thead .column-table_id {
91 width: 50px;
92 }
93 .tablepress-editor-button-list tbody .column-table_id,
94 .tablepress-editor-button-list tbody .column-table_name {
95 font-weight: bold;
96 }
97 .tablepress-editor-button-list thead .column-table_action {
98 min-width: 150px;
99 }
100 /* Responsiveness on the All Tables screen. */
101 @media screen and (max-width: 782px) {
102 .tablepress-editor-button-list .column-table_id {
103 display: none !important;
104 padding: 3px 8px 3px 35%;
105 }
106 }
107 <?php if ( is_rtl() ) : ?>
108 /* RTL CSS */
109 .rtl #tablepress-page .subtitle {
110 float: right;
111 }
112 <?php endif; ?>
113 </style>
114 </head>
115 <body class="wp-admin wp-core-ui js iframe<?php echo is_rtl() ? ' rtl' : ''; ?>">
116 <div id="tablepress-page" class="wrap">
117 <h1><?php printf( __( '%1$s &lsaquo; %2$s', 'tablepress' ), __( 'List of Tables', 'tablepress' ), 'TablePress' ); ?></h1>
118 <div id="poststuff">
119 <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>
120 <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>
121 <?php
122 if ( ! empty( $_GET['s'] ) ) {
123 printf( '<span class="subtitle">' . __( 'Search results for &#8220;%s&#8221;', 'tablepress' ) . '</span>', esc_html( wp_unslash( $_GET['s'] ) ) );
124 }
125 ?>
126 <form method="get" action="">
127 <input type="hidden" name="action" value="tablepress_<?php echo $this->action; ?>" />
128 <?php
129 wp_nonce_field( TablePress::nonce( $this->action ), '_wpnonce', false );
130 $this->wp_list_table->search_box( __( 'Search Tables', 'tablepress' ), 'tables_search' );
131 ?>
132 </form>
133 <?php $this->wp_list_table->display(); ?>
134 </div>
135 </div>
136 <script>
137 jQuery( function( $ ) {
138 // Toggle list table rows on small screens.
139 $( '.tablepress-editor-button-list' )
140 .on( 'click', 'tr', function() {
141 this.classList.toggle( 'is-expanded' );
142 })
143 .on( 'click', '.insert-shortcode', function() {
144 const win = window.dialogArguments || opener || parent || top;
145 win.send_to_editor( this.title );
146 } );
147 } );
148 </script>
149 </body>
150 </html>
151 <?php
152 }
153
154 } // class TablePress_Editor_Button_View
155
156