PluginProbe
WP Data Access – App Builder for Tables, Forms, Charts, Maps & Dashboards / 5.2
WP Data Access – App Builder for Tables, Forms, Charts, Maps & Dashboards v5.2
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 5.5.43 All 159 releases
wp-data-access / wp-data-access-diehard.php

wp-data-access-diehard.php in WP Data Access – App Builder for Tables, Forms, Charts, Maps & Dashboards 5.2, at wp-data-access-diehard.php

147 lines 4.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php // phpcs:ignore Standard.Category.SniffName.ErrorCode
2 /**
3 * This file contains some code which is necessary to use class WP_List_Table in the public area. Part of the code is
4 * fake (added to documentation) and is only loaded if the WordPress code needed to handle WP_List_Table is not
5 * available (which is the case in the public area). List tables are available in the public area with limitations.
6 * The screen options tab is not available and settings cannot be saved.
7 *
8 * USE THIS AT YOUR OWN RISK!
9 *
10 * I strongly advise to use list tables and data entry forms in the WordPress dashboard. If you use them in the public
11 * area make sure users must log in before they can use this feature. I strongly discourage to give anonymous users
12 * access to this feature, but you can...
13 *
14 * @package plugin
15 */
16
17 /**
18 * Fake class to make WPDA_List_Table available in the public area
19 */
20 class WPDADIEHARD_Screen {
21 /**
22 * Placeholder to prevent runtime errors
23 *
24 * @var mixed
25 */
26 public $id;
27
28 /**
29 * Placeholder to prevent runtime errors
30 *
31 * @param string $key Key.
32 * @param string $tag Tag.
33 * @return void
34 */
35 public function render_screen_reader_content( $key = '', $tag = 'h2' ) {
36 return; // Features not available in the public area.
37 }
38 }
39
40 /**
41 * Fake function
42 *
43 * @param Object $screen Screen.
44 * @return WPDADIEHARD_Screen
45 */
46 function wpdadiehard_convert_to_screen( $screen ) {
47 $screen = new WPDADIEHARD_Screen();
48 $screen->id = 'wpdadiehard';
49
50 return $screen;
51 }
52
53 /**
54 * Fake function
55 *
56 * @return WPDADIEHARD_Screen
57 */
58 function wpdadiehard_get_current_screen() {
59 $screen = new WPDADIEHARD_Screen();
60 $screen->id = 'wpdadiehard';
61
62 return $screen;
63 }
64
65 if ( ! function_exists( 'get_column_headers' ) ) {
66 /**
67 * Fake function
68 *
69 * @return array
70 */
71 function get_column_headers() {
72 return array(); // Class WPDA_List_Table will fill this array.
73 }
74 }
75
76 /**
77 * Duplicated from: wp-admin/includes/template.php (24-07-2020)
78 *
79 * @param mixed $text Text.
80 * @param mixed $type Type.
81 * @param mixed $name Name.
82 * @param mixed $wrap Wrap.
83 * @param mixed $other_attributes Attr.
84 * @return void
85 */
86 function wpdadiehard_submit_button( $text = null, $type = 'primary', $name = 'submit', $wrap = true, $other_attributes = null ) {
87 echo wpdadiehard_get_submit_button( $text, $type, $name, $wrap, $other_attributes ); // phpcs:ignore WordPress.Security.EscapeOutput
88 }
89
90 /**
91 * Duplicated from: wp-admin/includes/template.php (24-07-2020)
92 *
93 * @param mixed $text Text.
94 * @param mixed $type Type.
95 * @param mixed $name Name.
96 * @param mixed $wrap Wrap.
97 * @param mixed $other_attributes Attr.
98 * @return string
99 */
100 function wpdadiehard_get_submit_button( $text = '', $type = 'primary large', $name = 'submit', $wrap = true, $other_attributes = '' ) {
101 if ( ! is_array( $type ) ) {
102 $type = explode( ' ', $type );
103 }
104
105 $button_shorthand = array( 'primary', 'small', 'large' );
106 $classes = array( 'button' );
107 foreach ( $type as $t ) {
108 if ( 'secondary' === $t || 'button-secondary' === $t ) {
109 continue;
110 }
111 $classes[] = in_array( $t, $button_shorthand, true ) ? 'button-' . $t : $t;
112 }
113 // Remove empty items, remove duplicate items, and finally build a string.
114 $class = implode( ' ', array_unique( array_filter( $classes ) ) );
115
116 $text = $text ? $text : __( 'Save Changes' );
117
118 // Default the id attribute to $name unless an id was specifically provided in $other_attributes.
119 $id = $name;
120 if ( is_array( $other_attributes ) && isset( $other_attributes['id'] ) ) {
121 $id = $other_attributes['id'];
122 unset( $other_attributes['id'] );
123 }
124
125 $attributes = '';
126 if ( is_array( $other_attributes ) ) {
127 foreach ( $other_attributes as $attribute => $value ) {
128 $attributes .= $attribute . '="' . esc_attr( $value ) . '" '; // Trailing space is important.
129 }
130 } elseif ( ! empty( $other_attributes ) ) { // Attributes provided as a string.
131 $attributes = $other_attributes;
132 }
133
134 // Don't output empty name and id attributes.
135 $name_attr = $name ? ' name="' . esc_attr( $name ) . '"' : '';
136 $id_attr = $id ? ' id="' . esc_attr( $id ) . '"' : '';
137
138 $button = '<input type="submit"' . $name_attr . $id_attr . ' class="' . esc_attr( $class );
139 $button .= '" value="' . esc_attr( $text ) . '" ' . $attributes . ' />';
140
141 if ( $wrap ) {
142 $button = '<p class="submit">' . $button . '</p>';
143 }
144
145 return $button;
146 }
147