PluginProbe
WP Data Access – App Builder for Tables, Forms, Charts, Maps & Dashboards / 5.5.41
WP Data Access – App Builder for Tables, Forms, Charts, Maps & Dashboards v5.5.41
5.5.84 5.5.83 5.5.82 5.5.81 5.5.80 5.5.79 5.5.77 5.5.76 5.5.75 5.5.73 5.5.72 5.5.22 5.5.23 5.5.29 5.5.3 5.5.31 5.5.32 5.5.34 5.5.35 5.5.36 5.5.37 5.5.4 5.5.40 5.5.41 5.5.42 All 160 releases
wp-data-access / WPDataAccess / Data_Publisher / WPDA_Publisher_Form.php

WPDA_Publisher_Form.php in WP Data Access – App Builder for Tables, Forms, Charts, Maps & Dashboards 5.5.41, at WPDataAccess/Data_Publisher/WPDA_Publisher_Form.php

1,331 lines 49.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Suppress "error - 0 - No summary was found for this file" on phpdoc generation
5 *
6 * @package WPDataAccess\Data_Publisher
7 */
8 namespace WPDataAccess\Data_Publisher;
9
10 use WPDataAccess\Data_Dictionary\WPDA_Dictionary_Lists;
11 use WPDataAccess\Data_Dictionary\WPDA_List_Columns_Cache;
12 use WPDataAccess\Data_Tables\WPDA_Data_Tables;
13 use WPDataAccess\Plugin_Table_Models\WPDA_Table_Settings_Model;
14 use WPDataAccess\Plugin_Table_Models\WPDA_Publisher_Model;
15 use WPDataAccess\Premium\WPDAPRO_CPT\WPDAPRO_CPT_Services;
16 use WPDataAccess\Premium\WPDAPRO_Data_Publisher\WPDAPRO_Data_Publisher_Manage_Styles;
17 use WPDataAccess\Simple_Form\WPDA_Simple_Form;
18 use WPDataAccess\Simple_Form\WPDA_Simple_Form_Item_Boolean;
19 use WPDataAccess\Simple_Form\WPDA_Simple_Form_Item_Enum;
20 use WPDataAccess\Simple_Form\WPDA_Simple_Form_Item_Enum_Radio;
21 use WPDataAccess\WPDA;
22 use function GuzzleHttp\Psr7\_caseless_remove;
23 /**
24 * Class WPDA_Publisher_Form extends WPDA_Simple_Form
25 *
26 * Data entry form which allows users to create, update and test data tables. A data table consists of a database
27 * table, a number of columns and some options. A shortcode can be generated for a data table. The shortcode can
28 * be copied to the clipboard and from there pasted in a WordPress post or page. The shortcode is used to add a
29 * dynamic HTML table to a post or page that supports searching, pagination and sorting. Tables are created with
30 * jQuery DataTables.
31 *
32 * @author Peter Schulz
33 * @since 2.0.15
34 */
35 class WPDA_Publisher_Form extends WPDA_Simple_Form {
36 protected $hyperlinks = array();
37
38 protected $color = array();
39
40 protected $databases = array();
41
42 protected $cpts = array();
43
44 protected $cpts_non_selectable = array();
45
46 protected $cpts_selected = array();
47
48 protected $cfds = array();
49
50 protected $cfds_selectable = array();
51
52 protected $cfds_hidden = array();
53
54 protected $pub_data_source = 'Table';
55
56 /**
57 * WPDA_Publisher_Form constructor.
58 *
59 * @param string $schema_name Database schema name
60 * @param string $table_name Database table name
61 * @param object $wpda_list_columns Handle to instance of WPDA_List_Columns
62 * @param array $args
63 */
64 public function __construct(
65 $schema_name,
66 $table_name,
67 &$wpda_list_columns,
68 $args = array()
69 ) {
70 // Add column labels.
71 $args['column_headers'] = array(
72 'pub_id' => __( 'ID', 'wp-data-access' ),
73 'pub_name' => __( 'Name', 'wp-data-access' ),
74 'pub_schema_name' => __( 'Database', 'wp-data-access' ),
75 'pub_data_source' => __( 'Data Source', 'wp-data-access' ),
76 'pub_table_name' => __( 'Table/View Name', 'wp-data-access' ),
77 'pub_column_names' => __( 'Column Names (* = all)', 'wp-data-access' ),
78 'pub_format' => __( 'Column Labels', 'wp-data-access' ),
79 'pub_query' => __( '* Query', 'wp-data-access' ),
80 'pub_sort_icons' => __( 'Sort Icons', 'wp-data-access' ),
81 'pub_styles' => __( 'Styling', 'wp-data-access' ),
82 'pub_style_premium' => __( 'Enable Premium Styling', 'wp-data-access' ),
83 'pub_style_user' => __( 'Use Custom Style', 'wp-data-access' ),
84 'pub_style_color' => __( 'Color', 'wp-data-access' ),
85 'pub_style_space' => __( 'Spacing', 'wp-data-access' ),
86 'pub_style_corner' => __( 'Border Radius', 'wp-data-access' ),
87 'pub_style_modal_width' => __( 'Modal Width', 'wp-data-access' ),
88 'pub_responsive' => __( 'Output', 'wp-data-access' ),
89 'pub_responsive_popup_title' => __( 'Popup Title', 'wp-data-access' ),
90 'pub_responsive_cols' => __( 'Number Of Columns', 'wp-data-access' ),
91 'pub_responsive_type' => __( 'Type', 'wp-data-access' ),
92 'pub_responsive_modal_hyperlinks' => __( 'Hyperlinks On Modal', 'wp-data-access' ),
93 'pub_responsive_icon' => __( 'Show Icon', 'wp-data-access' ),
94 'pub_flat_scrollx' => __( 'Horizontal Scrollbar', 'wp-data-access' ),
95 'pub_default_where' => __( 'WHERE Clause', 'wp-data-access' ),
96 'pub_default_orderby' => __( 'Default Order By', 'wp-data-access' ),
97 'pub_table_options_searching' => __( 'Allow Searching?', 'wp-data-access' ),
98 'pub_table_options_ordering' => __( 'Allow Ordering?', 'wp-data-access' ),
99 'pub_table_options_paging' => __( 'Allow Paging?', 'wp-data-access' ),
100 'pub_table_options_serverside' => __( 'Server Side Processing?', 'wp-data-access' ),
101 'pub_table_options_nl2br' => __( 'NL > BR', 'wp-data-access' ),
102 'pub_table_options_advanced' => __( 'Advanced Options', 'wp-data-access' ),
103 'pub_extentions' => __( 'Extensions', 'wp-data-access' ),
104 'pub_cpt' => __( 'Post type', 'wp-data-access' ),
105 'pub_cpt_fields' => __( 'Custom fields', 'wp-data-access' ),
106 'pub_cpt_query' => __( 'CPT query', 'wp-data-access' ),
107 'pub_cpt_format' => __( 'Field labels', 'wp-data-access' ),
108 );
109 $this->check_table_type = false;
110 $this->title = 'Data Tables';
111 $args['help_url'] = 'https://wpdataaccess.com/docs/data-tables/data-tables-getting-started/';
112 parent::__construct(
113 $schema_name,
114 $table_name,
115 $wpda_list_columns,
116 $args
117 );
118 // Get available databases.
119 $schema_names = WPDA_Dictionary_Lists::get_db_schemas();
120 foreach ( $schema_names as $schema_name ) {
121 array_push( $this->databases, $schema_name['schema_name'] );
122 //phpcs:ignore - 8.1 proof
123 }
124 // Add scripts and styles.
125 WPDA_Data_Tables::enqueue_styles_and_script();
126 }
127
128 /**
129 * Overwrites method add_buttons
130 */
131 public function add_buttons() {
132 $index = $this->get_item_index( 'pub_id' );
133 $pub_id_item = $this->form_items[$index];
134 $pub_id = $pub_id_item->get_item_value();
135 $disabled = ( 'new' === $this->action ? 'disabled' : '' );
136 ?>
137 <a href="javascript:void(0)"
138 onclick="test_publication()"
139 class="button wpda_tooltip <?php
140 echo esc_attr( $disabled );
141 ?>"
142 title="Test"
143 >
144 <i class="fas fa-bug wpda_icon_on_button"></i>
145 <?php
146 echo __( 'Test', 'wp-data-access' );
147 ?>
148 </a>
149 <?php
150 $this->show_shortcode( $pub_id );
151 }
152
153 /**
154 * Overwrites method prepare_items
155 *
156 * @param bool $set_back_form_values
157 */
158 public function prepare_items( $set_back_form_values = false ) {
159 parent::prepare_items( $set_back_form_values );
160 $i = 0;
161 foreach ( $this->form_items as $form_item ) {
162 // Prepare listbox for column pub_schema_name
163 if ( $form_item->get_item_name() === 'pub_schema_name' ) {
164 if ( '' === $form_item->get_item_value() || null === $form_item->get_item_value() ) {
165 $form_item->set_item_value( WPDA::get_user_default_scheme() );
166 }
167 $form_item->set_enum( $this->databases );
168 $this->form_items[$i] = new WPDA_Simple_Form_Item_Enum($form_item);
169 }
170 if ( $form_item->get_item_name() === 'pub_sort_icons' ) {
171 $form_item->set_enum( array('Show', 'Hide') );
172 $form_item->set_enum_options( array('default', 'none') );
173 }
174 if ( $form_item->get_item_name() === 'pub_data_source' ) {
175 if ( null !== $form_item->get_item_value() ) {
176 $this->pub_data_source = $form_item->get_item_value();
177 }
178 }
179 // Prepare listbox for column pub_table_name
180 if ( $form_item->get_item_name() === 'pub_table_name' ) {
181 $this->form_items[$i] = new WPDA_Simple_Form_Item_Enum($form_item);
182 }
183 // Set default value for popup title.
184 if ( $form_item->get_item_name() === 'pub_responsive_popup_title' ) {
185 $form_item->set_item_default_value( __( 'Row details', 'wp-data-access' ) );
186 }
187 // Prepare listbox for column pub_responsive.
188 if ( $form_item->get_item_name() === 'pub_responsive' ) {
189 $form_item->set_enum( array('Responsive', 'Flat') );
190 $form_item->set_enum_options( array('Yes', 'No') );
191 }
192 // Prepare selection for column pub_column_names.
193 if ( $form_item->get_item_name() === 'pub_column_names' ) {
194 $title = __( 'Select columns shown in data table', 'wp-data-access' );
195 $form_item->set_item_hide_icon( true );
196 $form_item->set_item_js( 'jQuery("#pub_column_names").parent().parent().find("td.icon").append("<a id=\'select_columns\' class=\'button wpda_tooltip\' href=\'javascript:void(0)\' title=\'' . $title . '\' onclick=\'select_columns()\'>' . '<i class=\'fas fa-list wpda_icon_on_button\'></i> ' . __( 'Select', 'wp-data-access' ) . '</a>");' );
197 }
198 // Prepare column label settings.
199 if ( $form_item->get_item_name() === 'pub_format' ) {
200 $title = __( 'Define columns for data table (not necessary if already defined in Data Explorer table settings)', 'wp-data-access' );
201 $form_item->set_item_hide_icon( true );
202 $form_item->set_item_class( 'hide_item' );
203 $form_item->set_item_js( 'jQuery("#pub_format").parent().parent().find("td.data").append("<a id=\'format_columns\' class=\'button wpda_tooltip\' href=\'javascript:void(0)\' title=\'' . $title . '\' onclick=\'format_columns()\'>' . '<i class=\'fas fa-tag wpda_icon_on_button\'></i> ' . __( 'Click to define column labels', 'wp-data-access' ) . '</a>");' );
204 }
205 if ( 'pub_responsive_popup_title' === $form_item->get_item_name() || 'pub_responsive_cols' === $form_item->get_item_name() || 'pub_responsive_type' === $form_item->get_item_name() || 'pub_responsive_modal_hyperlinks' === $form_item->get_item_name() || 'pub_responsive_icon' === $form_item->get_item_name() || 'pub_flat_scrollx' === $form_item->get_item_name() ) {
206 $form_item->set_hide_item_init( true );
207 }
208 if ( 'pub_table_options_advanced' === $form_item->get_item_name() ) {
209 if ( '' === $form_item->get_item_value() || null === $form_item->get_item_value() ) {
210 $form_item->set_item_value( '{}' );
211 }
212 }
213 if ( 'pub_table_options_searching' === $form_item->get_item_name() || 'pub_table_options_ordering' === $form_item->get_item_name() || 'pub_table_options_paging' === $form_item->get_item_name() || 'pub_table_options_serverside' === $form_item->get_item_name() ) {
214 if ( 'pub_table_options_searching' !== $form_item->get_item_name() ) {
215 $form_item->set_hide_item_init( true );
216 }
217 $form_item->checkbox_value_on = 'on';
218 if ( 'new' === $this->action ) {
219 $form_item->set_item_value( 'on' );
220 }
221 $this->form_items[$i] = new WPDA_Simple_Form_Item_Boolean($form_item);
222 }
223 if ( 'pub_table_options_nl2br' === $form_item->get_item_name() ) {
224 $form_item->set_hide_item_init( true );
225 $form_item->checkbox_value_on = 'on';
226 $this->form_items[$i] = new WPDA_Simple_Form_Item_Boolean($form_item);
227 }
228 if ( $form_item->get_item_name() === 'pub_styles' ) {
229 $options = $form_item->get_item_enum();
230 $option_values = $options;
231 $option_values[0] = 'default = stripe + hover + order-column + row-border';
232 $form_item->set_enum( $option_values );
233 $form_item->set_enum_options( $options );
234 }
235 if ( 'pub_default_orderby' === $form_item->get_item_name() ) {
236 $form_item->set_item_hide_icon( true );
237 }
238 $i++;
239 }
240 }
241
242 protected function init_custom_fields() {
243 }
244
245 protected function add_fieldsets() {
246 $fields = array();
247 foreach ( $this->form_items as $item ) {
248 $fields[$item->get_item_name()] = true;
249 }
250 $data = array(
251 'pub_id',
252 'pub_name',
253 'pub_schema_name',
254 'pub_table_name',
255 'pub_column_names',
256 'pub_format'
257 );
258 $styling = array('pub_sort_icons', 'pub_styles');
259 $this->fieldsets = array(
260 'Publication Data' => array(
261 'id' => 'pub_main',
262 'fields' => $data,
263 ),
264 'Publication Type' => array(
265 'id' => 'pub_type',
266 'fields' => array(
267 'pub_responsive',
268 'pub_responsive_popup_title',
269 'pub_responsive_cols',
270 'pub_responsive_type',
271 'pub_responsive_modal_hyperlinks',
272 'pub_responsive_icon',
273 'pub_flat_scrollx'
274 ),
275 'expandable' => true,
276 ),
277 'Publication Styling' => array(
278 'id' => 'pub_styling',
279 'fields' => $styling,
280 'expandable' => true,
281 ),
282 );
283 $this->fieldsets['Advanced Settings'] = array(
284 'id' => 'pub_advanced',
285 'fields' => array(
286 'pub_default_where',
287 'pub_default_orderby',
288 'pub_table_options_searching',
289 'pub_table_options_ordering',
290 'pub_table_options_paging',
291 'pub_table_options_serverside',
292 'pub_table_options_nl2br',
293 'pub_table_options_advanced'
294 ),
295 'expandable' => true,
296 );
297 }
298
299 /**
300 * Overwrites method show
301 *
302 * @param bool $allow_save
303 * @param string $add_param
304 */
305 public function show( $allow_save = true, $add_param = '' ) {
306 parent::show( $allow_save, $add_param );
307 $index = $this->get_item_index( 'pub_id' );
308 $pub_id_item = $this->form_items[$index];
309 $pub_id = $pub_id_item->get_item_value();
310 $index = $this->get_item_index( 'pub_schema_name' );
311 $schema_name_item = $this->form_items[$index];
312 $schema_name = $schema_name_item->get_item_value();
313 global $wpdb;
314 $wpdb_name = $wpdb->dbname;
315 $index = $this->get_item_index( 'pub_table_name' );
316 $table_name_item = $this->form_items[$index];
317 $table_name = $table_name_item->get_item_value();
318 $table_columns = WPDA_List_Columns_Cache::get_list_columns( $schema_name, $table_name );
319 $columns = array();
320 foreach ( $table_columns->get_table_columns() as $table_column ) {
321 array_push( $columns, $table_column['column_name'] );
322 //phpcs:ignore - 8.1 proof
323 }
324 $column_labels = $table_columns->get_table_column_headers();
325 $json_editing = WPDA::get_option( WPDA::OPTION_DP_JSON_EDITING );
326 $wpda_table_settings_db = WPDA_Table_Settings_Model::query( $table_name, $schema_name );
327 if ( isset( $wpda_table_settings_db[0]['wpda_table_settings'] ) ) {
328 $wpda_table_settings = json_decode( $wpda_table_settings_db[0]['wpda_table_settings'] );
329 if ( isset( $wpda_table_settings->hyperlinks ) ) {
330 foreach ( $wpda_table_settings->hyperlinks as $hyperlink ) {
331 $hyperlink_label = ( isset( $hyperlink->hyperlink_label ) ? $hyperlink->hyperlink_label : '' );
332 $hyperlink_html = ( isset( $hyperlink->hyperlink_html ) ? $hyperlink->hyperlink_html : '' );
333 if ( $hyperlink_label !== '' && $hyperlink_html !== '' ) {
334 array_push( $this->hyperlinks, $hyperlink_label );
335 //phpcs:ignore - 8.1 proof
336 }
337 }
338 }
339 }
340 ?>
341 <style>
342 #pub_cpt_fields,
343 #pub_cpt_format,
344 #pub_default_orderby {
345 display: none;
346 }
347 table.wpda_simple_table td.icon a.button.wpda_tooltip {
348 width: 120px;
349 text-align: center;
350 }
351 span.pub_premium {
352 line-height: 40px;
353 }
354 span.pub_buttons {
355 float: right;
356 margin-top: 5px;
357 margin-bottom: 5px;
358 }
359 div.multiselect_sortable_content {
360 margin: 0 0 0 6px;
361 }
362 div.selection div.selection_title,
363 div.selectable div.selectable_title {
364 font-weight: bold;
365 }
366 div.selection ul.selection_content,
367 div.selectable ul.selectable_content {
368 background-color: white;
369 border: 1px solid #8c8f94;
370 border-radius: 4px;
371 height: 120px;
372 }
373 div.selection ul.selection_content li,
374 div.selectable ul.selectable_content li {
375 cursor: pointer;
376 padding: 0 10px;
377 margin: 0;
378 border: 0;
379 user-select: none;
380 }
381 div.selection ul.selection_content li:hover,
382 div.selectable ul.selectable_content li:hover {
383 font-weight: bold;
384 background-color: lightgrey;
385 }
386 select.multiselect_sortable_hide {
387 display: none;
388 }
389 .pub-post-types {
390 padding-top: 20px !important;
391 }
392 #manual_styling div {
393 display: grid;
394 grid-template-columns: 1fr 1fr 1fr 1fr;
395 gap: 10px;
396 width: 100%;
397 }
398 #manual_styling div span {
399 display: grid;
400 grid-template-rows: auto 1fr;
401 }
402 #manual_styling div span span {
403 display: grid;
404 grid-template-columns: 1fr auto;
405 }
406 </style>
407 <script type='text/javascript'>
408 let wpda_qb_columns = [];
409 let wpda_sp_columns = [];
410
411 let cpts_all = <?php
412 echo wp_json_encode( $this->cpts );
413 ?>;
414 let cpts_non_selectable = <?php
415 echo wp_json_encode( $this->cpts_non_selectable );
416 ?>;
417
418 let cfds_selected = <?php
419 echo wp_json_encode( $this->cfds );
420 ?>;
421 let cfds_selection = <?php
422 echo wp_json_encode( $this->cfds_selectable );
423 ?>;
424 let cfds_hidden = <?php
425 echo wp_json_encode( $this->cfds_hidden );
426 ?>;
427 let cfds_default_selectable = [];
428 let cfds_default_hidden = [];
429
430 function set_responsive_columns() {
431 if (jQuery('#pub_responsive').val() == 'Yes') {
432 // Show responsive settings
433 jQuery('#pub_responsive_popup_title').parent().parent().show();
434 jQuery('#pub_responsive_cols').parent().parent().show();
435 jQuery('#pub_responsive_type').parent().parent().show();
436 jQuery('#pub_responsive_modal_hyperlinks').parent().parent().show();
437 jQuery('#pub_responsive_icon').parent().parent().show();
438 jQuery('#pub_flat_scrollx').parent().parent().hide();
439 } else {
440 // Hide responsive settings
441 jQuery('#pub_responsive_popup_title').parent().parent().hide();
442 jQuery('#pub_responsive_cols').parent().parent().hide();
443 jQuery('#pub_responsive_type').parent().parent().hide();
444 jQuery('#pub_responsive_modal_hyperlinks').parent().parent().hide();
445 jQuery('#pub_responsive_icon').parent().parent().hide();
446 jQuery('#pub_flat_scrollx').parent().parent().show();
447 }
448 }
449
450 function get_selected_columns() {
451 let selectedColumns = table_columns;
452 let dataSource = "<?php
453 echo esc_attr( $this->pub_data_source );
454 ?>";
455 if (dataSource==="CPT") {
456 selectedColumns = cpt_fields;
457 } else if (dataSource==="Table") {
458 if (jQuery("#pub_column_names").val() !== "*") {
459 selectedColumns = jQuery("#pub_column_names").val().split(",");
460 }
461 }
462 return selectedColumns;
463 }
464
465 <?php
466 ?>
467
468 function pre_submit_form() {
469 // Simple form will automatically find and execute this function before the submit_form().
470 // Check column names
471 if (jQuery("#pub_column_names").val().trim()==="") {
472 jQuery("#pub_column_names").val("*");
473 }
474 // Process order by.
475 let defaultOrderBy = "";
476 jQuery(".wpda_dp_orderby").each(function() {
477 let index = jQuery(this).data("index");
478 let column = jQuery("#orderby" + index).val();
479 let order = jQuery("#order" + index).val();
480 if (column!=="") {
481 if (defaultOrderBy!=="") {
482 defaultOrderBy += "|";
483 }
484 defaultOrderBy += column;
485 if (order!=="") {
486 defaultOrderBy += "," + order;
487 }
488 }
489 });
490 jQuery("#pub_default_orderby").val(defaultOrderBy);
491
492 <?php
493 ?>
494
495 return true;
496 }
497
498 function getListValues(list) {
499 let values = [];
500 list.each(
501 function() {
502 values.push(jQuery(this).text());
503 }
504 );
505 return values;
506 }
507
508 function update_table_list(table_name = '') {
509 var url = location.pathname + '?action=wpda_get_tables';
510 var data = {
511 wpdaschema_name: jQuery("[name='pub_schema_name']").val(),
512 wpda_wpnonce: '<?php
513 echo esc_attr( wp_create_nonce( 'wpda-getdata-access-' . WPDA::get_current_user_login() ) );
514 ?>'
515 };
516 jQuery.post(
517 url,
518 data,
519 function (data) {
520 jQuery('[name="pub_table_name"]').empty();
521 var tables = JSON.parse(data);
522 for (var i = 0; i < tables.length; i++) {
523 jQuery('<option/>', {
524 value: tables[i].table_name,
525 html: tables[i].table_name
526 }).appendTo("[name='pub_table_name']");
527 }
528 if (table_name!=='') {
529 jQuery("[name='pub_table_name']").val(table_name);
530 } else {
531 jQuery('#pub_column_names').val('*');
532 jQuery('#pub_format').val('');
533 table_columns = [];
534 }
535 }
536 );
537 }
538
539 function updateWordPressDatabaseName() {
540 jQuery("#pub_schema_name option[value='<?php
541 echo esc_attr( $wpdb_name );
542 ?>']").text("WordPress database (<?php
543 echo esc_attr( $wpdb_name );
544 ?>)");
545 }
546
547 jQuery(function () {
548 updateWordPressDatabaseName();
549
550 pub_table_options_searching = jQuery('#pub_table_options_searching').parent().parent();
551 pub_table_options_ordering = jQuery('#pub_table_options_ordering').parent().parent().children();
552 pub_table_options_ordering_tr = jQuery(pub_table_options_ordering).parent().parent();
553 pub_table_options_paging = jQuery('#pub_table_options_paging').parent().parent().children();
554 pub_table_options_paging_tr = jQuery(pub_table_options_paging).parent().parent();
555 pub_table_options_serverside = jQuery('#pub_table_options_serverside').parent().parent().children();
556 pub_table_options_serverside_tr = jQuery(pub_table_options_serverside).parent().parent();
557 pub_table_options_nl2br = jQuery('#pub_table_options_nl2br').parent().parent().children();
558 pub_table_options_nl2br_tr = jQuery(pub_table_options_nl2br).parent().parent();
559
560 jQuery('<span style="width:10px;display:inline-block;"></span>').appendTo(pub_table_options_searching);
561 pub_table_options_ordering.appendTo(pub_table_options_searching);
562 jQuery('<span style="width:10px;display:inline-block;"></span>').appendTo(pub_table_options_searching);
563 pub_table_options_paging.appendTo(pub_table_options_searching);
564 jQuery('<span style="width:10px;display:inline-block;"></span>').appendTo(pub_table_options_searching);
565 pub_table_options_serverside.appendTo(pub_table_options_searching);
566 jQuery('<span style="width:10px;display:inline-block;"></span>').appendTo(pub_table_options_searching);
567 pub_table_options_nl2br.appendTo(pub_table_options_searching);
568
569 pub_table_options_ordering_tr.remove();
570 pub_table_options_paging_tr.remove();
571 pub_table_options_serverside_tr.remove();
572 pub_table_options_nl2br_tr.remove();
573
574 set_responsive_columns();
575
576 <?php
577 if ( WPDA::OPTION_DP_JSON_EDITING[1] === $json_editing ) {
578 ?>
579 var cm = wp.codeEditor.initialize(jQuery('#pub_table_options_advanced'), cm_settings);
580 <?php
581 }
582 ?>
583
584 jQuery("[name='pub_schema_name']").on('change', function () {
585 update_table_list();
586 });
587 update_table_list('<?php
588 echo esc_attr( $table_name );
589 ?>');
590
591 jQuery("[name='pub_table_name']").on('change', function () {
592 jQuery('#pub_column_names').val('*');
593 jQuery('#pub_format').val('');
594 table_columns = [];
595 });
596
597 <?php
598 ?>
599
600 jQuery('#pub_default_where').closest("tr").find('td.icon').empty().append('<i title="Enter a valid sql where clause, for example:\nfirst_name like \'Peter%\'" class="fas fa-circle-question pointer wpda_tooltip"></i>');
601 jQuery('#pub_table_options_searching').closest("tr").find('td.icon').empty().append('<i title="When paging is disabled, all rows are fetch on page load (this implicitly disables server side processing)\n\nEnable NL > BR to automatically convert New Lines to <BR> tags" class="fas fa-circle-question pointer wpda_tooltip"></i>');
602 jQuery('#pub_table_options_advanced').closest("tr").find('td.icon').empty().append('<i title=\'Must be valid JSON:\n{"option":"value","option2","value2"}\' class="fas fa-circle-question pointer wpda_tooltip"></i>');
603 jQuery('#pub_table_options_advanced').closest("tr").find('td.icon').append('<br/><a href="https://datatables.net/reference/option/" target="_blank" title="Click to check jQuery DataTables website for available\noptions (opens in a new tab or window)" class="dashicons dashicons-external wpda_tooltip" style="margin-top:5px;"></a>');
604 jQuery('#pub_styles').closest("tr").find('td.icon').empty().append('<i title="Hold control key to selected multiple" class="fas fa-circle-question pointer wpda_tooltip"></i>');
605
606 jQuery( '.wpda_tooltip' ).tooltip();
607 jQuery( '.wpda_tooltip_ic' ).tooltip({
608 tooltipClass: "wpda_tooltip_css_ic",
609 });
610
611 <?php
612 if ( 'view' === $this->action ) {
613 ?>
614 jQuery('#format_columns').prop("readonly", true).prop("disabled", true).addClass("disabled");
615 jQuery('#select_columns').prop("readonly", true).prop("disabled", true).addClass("disabled");
616 <?php
617 }
618 ?>
619
620 jQuery('#pub_responsive').on('change', function () {
621 set_responsive_columns();
622 });
623
624 // Add default order by UI.
625 jQuery("#pub_default_orderby").before(createOrderByLine(0));
626 // Restore default sorting.
627 let defaultSorting = jQuery("#pub_default_orderby").val();
628 let arraySorting = defaultSorting.split("|");
629 for (let i=0; i<arraySorting.length; i++) {
630 if (arraySorting[i]!=="") {
631 if (jQuery("#orderby" + i).length===0) {
632 // Add order by line.
633 jQuery("#pub_default_orderby").before(createOrderByLine(i));
634 }
635 let orderBy = arraySorting[i].split(",");
636 if (orderBy[0]!=="") {
637 jQuery("#orderby" + i).val(orderBy[0]);
638 jQuery("#order" + i).val(orderBy[1]);
639 }
640 }
641 }
642
643 <?php
644 ?>
645 });
646
647 let no_cols_selected = '* (= show all columns)';
648
649 let table_columns = [];
650 let cpt_fields = [];
651 <?php
652 foreach ( $columns as $column ) {
653 ?>
654 table_columns.push('<?php
655 echo esc_attr( $column );
656 ?>');
657 <?php
658 }
659 ?>
660
661 var hyperlinks = [];
662 <?php
663 if ( null !== $this->hyperlinks && is_array( $this->hyperlinks ) ) {
664 foreach ( $this->hyperlinks as $hyperlink ) {
665 echo "hyperlinks.push('{$hyperlink}');";
666 // phpcs:ignore WordPress.Security.EscapeOutput
667 }
668 }
669 ?>
670
671 function select_available(e) {
672 var option = jQuery("#columns_available option:selected");
673 var add_to = jQuery("#columns_selected");
674
675 option.remove();
676 new_option = add_to.append(option);
677
678 if (jQuery("#columns_selected option[value='*']").length > 0) {
679 // Remove ALL from selected list.
680 jQuery("#columns_selected option[value='*']").remove();
681 }
682
683 jQuery('select#columns_selected option').prop("selected", false);
684 }
685
686 function select_selected() {
687 var option = jQuery("#columns_selected option:selected");
688 if (option[0].value === '*') {
689 // Cannot remove ALL.
690 return;
691 }
692
693 var add_to = jQuery("#columns_available");
694
695 option.remove();
696 add_to.append(option);
697
698 if (jQuery('select#columns_selected option').length === 0) {
699 jQuery("#columns_selected").append(jQuery('<option></option>').attr('value', '*').text(no_cols_selected));
700 }
701
702 jQuery('select#columns_available option').prop("selected", false);
703 }
704
705 function select_columns() {
706 if (!(Array.isArray(table_columns) && table_columns.length)) {
707 alert("<?php
708 echo __( 'To select columns you need to save your data table first', 'wp-data-access' );
709 ?>");
710 return;
711 }
712
713 var columns_available = jQuery(
714 '<select id="columns_available" name="columns_available[]" multiple size="8" style="width:200px" onchange="select_available()">' +
715 '</select>'
716 );
717 jQuery.each(table_columns, function (i, val) {
718 columns_available.append(jQuery('<option></option>').attr('value', val).text(val));
719 });
720 for (let i=0; i<hyperlinks.length;i++) {
721 columns_available.append(jQuery('<option></option>').attr('value', 'wpda_hyperlink_' + i).text('Hyperlink: ' + hyperlinks[i]));
722 }
723
724 var currently_select_option = '';
725 var currently_select_values = jQuery('#pub_column_names').val();
726 if (currently_select_values == '*') {
727 currently_select_values = [];
728 } else {
729 currently_select_values = currently_select_values.split(',');
730 }
731 if (currently_select_values.length === 0) {
732 currently_select_option = '<option value="*">' + no_cols_selected + '</option>';
733 } else {
734 for (let i=0; i < currently_select_values.length; i++) {
735 if (currently_select_values[i].substr(0,15)==='wpda_hyperlink_') {
736 hyperlink_no = currently_select_values[i].substr(15);
737 if (hyperlink_no<hyperlinks.length) {
738 option_text = 'Hyperlink: ' + hyperlinks[hyperlink_no];
739 currently_select_option += '<option value="' + currently_select_values[i] + '">' + option_text + '</option>';
740 }
741 } else {
742 option_text = currently_select_values[i];
743 currently_select_option += '<option value="' + currently_select_values[i] + '">' + option_text + '</option>';
744 }
745 }
746 }
747
748 var columns_selected = jQuery(
749 '<select id="columns_selected" name="columns_selected[]" multiple size="8" style="width:200px" onchange="select_selected()">' +
750 currently_select_option +
751 '</select>'
752 );
753
754 var dialog_table = jQuery('<table style="width:410px"></table>');
755 var dialog_table_row = dialog_table.append(jQuery('<tr></tr>'));
756 dialog_table_row.append(jQuery('<td width="50%"></td>').append(columns_available));
757 dialog_table_row.append(jQuery('<td width="50%"></td>').append(columns_selected));
758
759 var dialog_text = jQuery('<div style="width:410px"></div>');
760 var dialog = jQuery('<div></div>');
761
762 dialog.append(dialog_text);
763 dialog.append(dialog_table);
764
765 jQuery(dialog).dialog(
766 {
767 dialogClass: 'wp-dialog no-close',
768 title: 'Add column(s) to data table',
769 modal: true,
770 autoOpen: true,
771 closeOnEscape: false,
772 resizable: false,
773 width: 'auto',
774 buttons: {
775 "OK": function () {
776 var selected_columns = '';
777 jQuery("#columns_selected option").each(
778 function () {
779 selected_columns += jQuery(this).val() + ',';
780 }
781 );
782 if (selected_columns !== '') {
783 selected_columns = selected_columns.slice(0, -1);
784 }
785 jQuery('#pub_column_names').val(selected_columns);
786 jQuery(this).dialog('destroy').remove();
787 },
788 "Cancel": function () {
789 jQuery(this).dialog('destroy').remove();
790 }
791 }
792 }
793 );
794
795 wpda_add_icons_to_dialog_buttons();
796
797 // Remove selected columns from available columns
798 for (let i = 0; i < currently_select_values.length; i++) {
799 jQuery("#columns_available option[value='" + currently_select_values[i] + "']").remove();
800 }
801 }
802
803 function format_cpt_columns() {
804 if (!(Array.isArray(cpt_fields) && cpt_fields.length)) {
805 alert("<?php
806 echo __( 'To format columns you need to save your data table first', 'wp-data-access' );
807 ?>");
808 return;
809 }
810
811 let pub_cpt_format = null;
812 try {
813 pub_cpt_format = JSON.parse(jQuery('#pub_cpt_format').val());
814 } catch (e) {
815 pub_cpt_format = null;
816 }
817
818 let dialog_table = jQuery('<table></table>');
819 dialog_table.append(
820 jQuery('<tr></tr>').append(
821 jQuery('<th style="text-align:left;"><?php
822 echo __( 'Field Name', 'wp-data-access' );
823 ?></th>'),
824 jQuery('<th style="text-align:left;"><?php
825 echo __( 'Field Label', 'wp-data-access' );
826 ?></th>'),
827 )
828 );
829
830 for (let i=0; i<cpt_fields.length; i++) {
831 let label = cpt_fields[i];
832 try {
833 label = pub_cpt_format.cpt_format.cpt_labels[cpt_fields[i]];
834 } catch (e) {
835 label = cpt_fields[i];
836 }
837 dialog_table.append(
838 jQuery('<tr></tr>').append(
839 jQuery('<td style="text-align:left;">' + cpt_fields[i] + '</td>'),
840 jQuery('<td style="text-align:left;"><input type="text" class="cpt_label" name="' + cpt_fields[i] + '" value="' + label + '"></td>'),
841 )
842 );
843 }
844
845 let dialog_text = jQuery('<div></div>');
846 let dialog = jQuery('<div id="define_cpt_labels"></div>');
847
848 dialog.append(dialog_text);
849 dialog.append(dialog_table);
850
851 jQuery(dialog).dialog({
852 dialogClass: 'wp-dialog no-close',
853 title: 'Define field labels',
854 modal: true,
855 autoOpen: true,
856 closeOnEscape: false,
857 resizable: false,
858 width: 'auto',
859 buttons: {
860 "OK": function () {
861 // Create JSON from defined field labels
862 var cpt_labels = {};
863 jQuery("#define_cpt_labels input.cpt_label").each(
864 function () {
865 cpt_labels[jQuery(this).attr('name')] = jQuery(this).val();
866 }
867 );
868
869 // Write JSON to column pub_format
870 cpt_format = {
871 "cpt_format": {
872 "cpt_labels": cpt_labels
873 }
874 };
875 jQuery('#pub_cpt_format').val(JSON.stringify(cpt_format));
876 jQuery(this).dialog('destroy').remove();
877 },
878 "Cancel": function () {
879 jQuery(this).dialog('destroy').remove();
880 }
881 }
882 });
883
884 wpda_add_icons_to_dialog_buttons();
885 }
886
887 function format_columns() {
888 if (!(Array.isArray(table_columns) && table_columns.length)) {
889 alert("<?php
890 echo __( 'To format columns you need to save your data table first', 'wp-data-access' );
891 ?>");
892 return;
893 }
894
895 var pub_format_json_string = jQuery('#pub_format').val();
896
897 var columns_labels = [];
898
899 if (pub_format_json_string !== '') {
900 // Use previously defined formatting
901 var pub_format = JSON.parse(pub_format_json_string);
902 if (typeof pub_format['pub_format']['column_labels'] !== 'undefined') {
903 columns_labels = pub_format['pub_format']['column_labels'];
904 }
905 } else {
906 // Get column labels from table settings
907 columns_labels = <?php
908 echo json_encode( $column_labels );
909 ?>;
910 }
911
912 var dialog_table = jQuery('<table></table>');
913 dialog_table.append(
914 jQuery('<tr></tr>').append(
915 jQuery('<th style="text-align:left;"><?php
916 echo __( 'Column Name', 'wp-data-access' );
917 ?></th>'),
918 jQuery('<th style="text-align:left;"><?php
919 echo __( 'Column Label', 'wp-data-access' );
920 ?></th>'),
921 )
922 );
923
924 <?php
925 foreach ( $table_columns->get_table_columns() as $table_column ) {
926 ?>
927 columns_label = '<?php
928 echo esc_attr( $table_column['column_name'] );
929 ?>';
930 if (typeof columns_labels !== 'undefined') {
931 if (columns_label in columns_labels) {
932 columns_label = columns_labels[columns_label];
933 }
934 }
935 dialog_table.append(
936 jQuery('<tr></tr>').append(
937 jQuery('<td style="text-align:left;"><?php
938 echo esc_attr( $table_column['column_name'] );
939 ?></td>'),
940 jQuery('<td style="text-align:left;"><input type="text" class="column_label" name="<?php
941 echo esc_attr( $table_column['column_name'] );
942 ?>" value="' + columns_label + '"></td>'),
943 )
944 );
945 <?php
946 }
947 ?>
948
949 var dialog_text = jQuery('<div></div>');
950 var dialog = jQuery('<div id="define_column_labels"></div>');
951
952 dialog.append(dialog_text);
953 dialog.append(dialog_table);
954
955 jQuery(dialog).dialog({
956 dialogClass: 'wp-dialog no-close',
957 title: 'Define column labels',
958 modal: true,
959 autoOpen: true,
960 closeOnEscape: false,
961 resizable: false,
962 width: 'auto',
963 buttons: {
964 "OK": function () {
965 // Create JSON from defined column labels
966 var column_labels = {};
967 jQuery('.column_label').each(
968 function () {
969 column_labels[jQuery(this).attr('name')] = jQuery(this).val();
970 }
971 );
972
973 // Write JSON to column pub_format
974 pub_format = {
975 "pub_format": {
976 "column_labels": column_labels
977 }
978 };
979 jQuery('#pub_format').val(JSON.stringify(pub_format));
980 jQuery(this).dialog('destroy').remove();
981 },
982 "Cancel": function () {
983 jQuery(this).dialog('destroy').remove();
984 }
985 }
986 });
987
988 wpda_add_icons_to_dialog_buttons();
989 }
990
991 function getQuery() {
992 url = location.pathname + '?action=wpda_query_builder_open_sql';
993 jQuery.ajax({
994 method: 'POST',
995 url: url,
996 data: {
997 wpda_wpnonce: "<?php
998 echo esc_attr( wp_create_nonce( 'wpda-query-builder-' . WPDA::get_current_user_id() ) );
999 ?>",
1000 wpda_exclude: ""
1001 }
1002 }).done(
1003 function (msg) {
1004 if (!Array.isArray(msg.data)) {
1005 // Show queries
1006 list = jQuery("<ul/>");
1007 for (var queryName in msg.data) {
1008 dbs = msg.data[queryName].schema_name;
1009 qry = msg.data[queryName].query;
1010
1011 query = jQuery(`
1012 <div class="wpda-query-select">
1013 <div class="wpda-query-select-title ui-widget-header">
1014 ${queryName}
1015 <span class="fas fa-copy wpda-query-select-title-copy wpda_tooltip_left" title="Copy SQL"></span>
1016 </div>
1017 <div class="wpda-query-select-content">
1018 <textarea>${qry}</textarea>
1019 </div>
1020 </div>
1021 `);
1022 listitem = jQuery("<li/>").attr("data-dbs", dbs);
1023 listitem.append(query);
1024
1025 list.append(listitem);
1026 }
1027 dialog = jQuery("<div class='wpda-query'/>").attr("title", "Select from Query Builder");
1028 dialog.append(list);
1029 dialog.dialog({
1030 modal: true,
1031 resizable: false,
1032 width: "700px"
1033 });
1034 jQuery(".wpda_tooltip_left").tooltip({
1035 tooltipClass: "wpda_tooltip_dashboard",
1036 position: { my: "right top", at: "right bottom" }
1037 });
1038
1039 jQuery(".wpda-query-select-title-copy").on("click", function() {
1040 selectedDbs = jQuery(this).closest("li").data("dbs");
1041 selectedQuery = jQuery(this).closest("li").find("textarea").val();
1042
1043 jQuery("#pub_schema_name").val(selectedDbs);
1044 jQuery("#pub_query").val(selectedQuery);
1045
1046 jQuery(this).closest('.ui-dialog-content').dialog('close');
1047 });
1048 } else {
1049 // No queries found
1050 }
1051 }
1052 ).fail(
1053 function (msg) {
1054 console.log("WP Data Access error (getSQLFromQueryBuilder):", msg);
1055 }
1056 );
1057 }
1058
1059 function test_publication() {
1060 jQuery.ajax({
1061 type: "POST",
1062 url: "<?php
1063 echo admin_url( 'admin-ajax.php?action=wpda_test_publication' );
1064 // phpcs:ignore WordPress.Security.EscapeOutput
1065 ?>",
1066 data: {
1067 wpnonce: "<?php
1068 echo esc_attr( wp_create_nonce( "wpda-publication-{$pub_id}" ) );
1069 ?>",
1070 pub_id: "<?php
1071 echo esc_attr( $pub_id );
1072 ?>"
1073 }
1074 }).done(
1075 function(html) {
1076 jQuery("body").append(html);
1077 jQuery('#data_publisher_test_container_<?php
1078 echo esc_html( $pub_id );
1079 ?>').show();
1080 }
1081 );
1082 }
1083
1084 function addOrderByColumn() {
1085 let index = 0;
1086 jQuery(".wpda_dp_orderby").each(function() {
1087 if (parseInt(jQuery(this).data("index"))>index) {
1088 index = parseInt(jQuery(this).data("index"));
1089 }
1090 });
1091 index++;
1092 jQuery("#pub_default_orderby").before(createOrderByLine(index));
1093 }
1094
1095 function removeOrderByColumn(elem) {
1096 elem.parent().remove();
1097 }
1098
1099 function createOrderByLine(index) {
1100 let selectedColumns = get_selected_columns();
1101
1102 let options = '<option value=""></option>';
1103 for (let i=0; i<selectedColumns.length; i++) {
1104 options += `<option value="${i}">${selectedColumns[i]}</option>`;
1105 }
1106 let columns = `<select id="orderby${index}">${options}</select>`;
1107
1108 let order = `<select id="order${index}"><option></option><option value="asc">Ascending</option><option value="desc">Descending</option></select>`;
1109
1110 let icon = "";
1111 if (index===0) {
1112 icon = `<i class="fas fa-plus-circle wpda_tooltip" title="Add column" onclick="addOrderByColumn()"></i>`;
1113 } else {
1114 icon = `<i class="fas fa-minus-circle wpda_tooltip" title="Remove column" onclick="removeOrderByColumn(jQuery(this))"></i>`;
1115 }
1116
1117 return `<div data-index="${index}" class="wpda_dp_orderby">${columns}${order}${icon}</div>`;
1118 }
1119 </script>
1120 <?php
1121 }
1122
1123 protected function show_shortcode( $pub_id ) {
1124 // Show data table shortcode directly from Data Tables main page
1125 $shortcode_enabled = 'on' === WPDA::get_option( WPDA::OPTION_PLUGIN_WPDATAACCESS_POST ) && 'on' === WPDA::get_option( WPDA::OPTION_PLUGIN_WPDATAACCESS_PAGE );
1126 ?>
1127 <div id="wpda_publication_<?php
1128 echo esc_attr( $pub_id );
1129 ?>"
1130 title="<?php
1131 echo __( 'Shortcode', 'wp-data-access' );
1132 ?>"
1133 style="display:none"
1134 >
1135 <p class="wpda_shortcode_content">
1136 Copy the shortcode below into your post or page to make this data table available on your website.
1137 </p>
1138 <p class="wpda_shortcode_text">
1139 <strong>
1140 [wpdataaccess pub_id="<?php
1141 echo esc_attr( $pub_id );
1142 ?>"]
1143 </strong>
1144 </p>
1145 <p class="wpda_shortcode_buttons">
1146 <button class="button wpda_shortcode_clipboard wpda_shortcode_button"
1147 type="button"
1148 data-clipboard-text='[wpdataaccess pub_id="<?php
1149 echo esc_attr( $pub_id );
1150 ?>"]'
1151 onclick="jQuery.notify('<?php
1152 echo __( 'Shortcode successfully copied to clipboard!' );
1153 ?>','info')"
1154 >
1155 <?php
1156 echo __( 'Copy', 'wp-data-access' );
1157 ?>
1158 </button>
1159 <button class="button button-primary wpda_shortcode_button"
1160 type="button"
1161 onclick="jQuery('.ui-dialog-content').dialog('close')"
1162 >
1163 <?php
1164 echo __( 'Close', 'wp-data-access' );
1165 ?>
1166 </button>
1167 </p>
1168 <?php
1169 if ( !$shortcode_enabled ) {
1170 ?>
1171 <p>
1172 Shortcode wpdataaccess is not enabled for all output types.
1173 <a href="<?php
1174 echo admin_url( 'options-general.php' );
1175 // phpcs:ignore WordPress.Security.EscapeOutput
1176 ?>?page=wpdataaccess" class="wpda_shortcode_link">&raquo; Manage settings</a>
1177 </p>
1178 <?php
1179 }
1180 ?>
1181 </div>
1182 <a href="javascript:void(0)"
1183 class="button view wpda_tooltip"
1184 title="<?php
1185 echo __( 'Get shortcode', 'wp-data-access' );
1186 ?>"
1187 onclick="jQuery('#wpda_publication_<?php
1188 echo esc_attr( $pub_id );
1189 ?>').dialog()"
1190 >
1191 <span style="white-space:nowrap">
1192 <i class="fas fa-code wpda_icon_on_button"></i>
1193 <?php
1194 echo __( 'Shortcode', 'wp-data-access' );
1195 ?>
1196 </span>
1197 </a>
1198 <?php
1199 WPDA::shortcode_popup();
1200 }
1201
1202 public static function test_publication() {
1203 $pub_id = ( isset( $_REQUEST['pub_id'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['pub_id'] ) ) : null );
1204 $wp_nonce = ( isset( $_REQUEST['wpnonce'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['wpnonce'] ) ) : '' );
1205 // input var okay.
1206 $datatables_enabled = WPDA::get_option( WPDA::OPTION_BE_LOAD_DATATABLES ) === 'on';
1207 $datatables_responsive_enabled = WPDA::get_option( WPDA::OPTION_BE_LOAD_DATATABLES_RESPONSE ) === 'on';
1208 if ( !wp_verify_nonce( $wp_nonce, "wpda-publication-{$pub_id}" ) ) {
1209 $publication = '<strong>' . __( 'ERROR: Not authorized', 'wp-data-access' ) . '</strong>';
1210 } elseif ( null === $pub_id ) {
1211 $publication = '<strong>' . __( 'ERROR: Cannot test data table [wrong arguments]', 'wp-data-access' ) . '</strong>';
1212 } elseif ( !$datatables_enabled || !$datatables_responsive_enabled ) {
1213 $publication = '<strong>' . __( 'ERROR: Cannot test data table', 'wp-data-access' ) . '</strong><br/><br/>' . __( 'SOLUTION: Load jQuery DataTables: WP Data Access > Manage Plugin > Back-End Settings', 'wp-data-access' );
1214 } else {
1215 $wpda_data_tables = new WPDA_Data_Tables();
1216 $publication = $wpda_data_tables->show(
1217 $pub_id,
1218 '',
1219 '',
1220 '',
1221 '',
1222 '',
1223 '',
1224 '',
1225 '',
1226 ''
1227 );
1228 // , '', '', '', true );
1229 }
1230 ob_start();
1231 ?>
1232 <div id="data_publisher_test_container_<?php
1233 echo esc_html( $pub_id );
1234 ?>">
1235 <style>
1236 #data_publisher_test_header_<?php
1237 echo esc_html( $pub_id );
1238 ?> {
1239 height: 30px;
1240 background-color: #ccc;
1241 padding: 10px;
1242 margin-bottom: 10px;
1243 }
1244
1245 #data_publisher_test_header_<?php
1246 echo esc_html( $pub_id );
1247 ?> span strong {
1248 padding-top: 10px;
1249 font-size: 14px;
1250 vertical-align: middle;
1251 }
1252
1253 #data_publisher_test_container_<?php
1254 echo esc_html( $pub_id );
1255 ?> {
1256 display: none;
1257 padding: 10px;
1258 position: absolute;
1259 top: 30px;
1260 left: 10px;
1261 color: black;
1262 overflow-y: auto;
1263 background-color: white;
1264 border: 1px solid #ccc;
1265 width: calc(100% - 100px);
1266 z-index: 9999;
1267 }
1268
1269 #data_publisher_test_container_<?php
1270 echo esc_html( $pub_id );
1271 ?> thead input[type='search'],
1272 #data_publisher_test_container_<?php
1273 echo esc_html( $pub_id );
1274 ?> thead select,
1275 #data_publisher_test_container_<?php
1276 echo esc_html( $pub_id );
1277 ?> tfoot input[type='search'],
1278 #data_publisher_test_container_<?php
1279 echo esc_html( $pub_id );
1280 ?> tfoot select {
1281 padding-top: 5px;
1282 padding-bottom: 5px;
1283 }
1284
1285 #data_publisher_test_container_<?php
1286 echo esc_html( $pub_id );
1287 ?> .dataTables_filter {
1288 height: 42px;
1289 }
1290
1291 .dataTables_wrapper .dataTables_filter {
1292 height: 35px;
1293 }
1294 </style>
1295 <div id="data_publisher_test_header_<?php
1296 echo esc_attr( $pub_id );
1297 ?>">
1298 <span><strong><?php
1299 echo __( 'Test', 'wp-data-access' );
1300 ?> (pub_id=<?php
1301 echo esc_attr( $pub_id );
1302 ?>
1303 - <?php
1304 echo __( 'data table looks different on your website', 'wp-data-access' );
1305 ?>)
1306 </strong></span>
1307 <span class="button" style="float:right;"
1308 onclick="jQuery('#data_publisher_test_container_<?php
1309 echo esc_attr( $pub_id );
1310 ?>').hide(); jQuery('#data_publisher_test_container_<?php
1311 echo esc_attr( $pub_id );
1312 ?>').remove();">x</span><br/>
1313 </div>
1314 <?php
1315 echo $publication;
1316 // phpcs:ignore WordPress.Security.EscapeOutput
1317 ?>
1318 </div>
1319 <script type='text/javascript'>
1320 jQuery("#data_publisher_test_container_<?php
1321 echo esc_attr( $pub_id );
1322 ?>").appendTo("#wpbody-content");
1323 </script>
1324 <?php
1325 echo ob_get_clean();
1326 // phpcs:ignore WordPress.Security.EscapeOutput
1327 wp_die();
1328 }
1329
1330 }
1331