PluginProbe
WP Data Access – App Builder for Tables, Forms, Charts, Maps & Dashboards / 5.5.84
WP Data Access – App Builder for Tables, Forms, Charts, Maps & Dashboards v5.5.84
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 / wp-data-access-diehard.php

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

156 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 * 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
21 if ( ! defined( 'WPINC' ) ) {
22 die;
23 }
24
25 if ( ! defined( 'ABSPATH' ) ) {
26 exit;
27 }
28
29 class WPDADIEHARD_Screen {
30 /**
31 * Placeholder to prevent runtime errors
32 *
33 * @var mixed
34 */
35 public $id;
36
37 /**
38 * Placeholder to prevent runtime errors
39 *
40 * @param string $key Key.
41 * @param string $tag Tag.
42 * @return void
43 */
44 public function render_screen_reader_content( $key = '', $tag = 'h2' ) {
45 return; // Features not available in the public area.
46 }
47 }
48
49 /**
50 * Fake function
51 *
52 * @param Object $screen Screen.
53 * @return WPDADIEHARD_Screen
54 */
55 function wpdadiehard_convert_to_screen( $screen ) {
56 $screen = new WPDADIEHARD_Screen();
57 $screen->id = 'wpdadiehard';
58
59 return $screen;
60 }
61
62 /**
63 * Fake function
64 *
65 * @return WPDADIEHARD_Screen
66 */
67 function wpdadiehard_get_current_screen() {
68 $screen = new WPDADIEHARD_Screen();
69 $screen->id = 'wpdadiehard';
70
71 return $screen;
72 }
73
74 if ( ! function_exists( 'get_column_headers' ) ) {
75 /**
76 * Fake function
77 *
78 * @return array
79 */
80 function get_column_headers() { // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound
81 return array(); // Class WPDA_List_Table will fill this array.
82 }
83 }
84
85 /**
86 * Duplicated from: wp-admin/includes/template.php (24-07-2020)
87 *
88 * @param mixed $text Text.
89 * @param mixed $type Type.
90 * @param mixed $name Name.
91 * @param mixed $wrap Wrap.
92 * @param mixed $other_attributes Attr.
93 * @return void
94 */
95 function wpdadiehard_submit_button( $text = null, $type = 'primary', $name = 'submit', $wrap = true, $other_attributes = null ) {
96 echo wpdadiehard_get_submit_button( $text, $type, $name, $wrap, $other_attributes ); // phpcs:ignore WordPress.Security.EscapeOutput
97 }
98
99 /**
100 * Duplicated from: wp-admin/includes/template.php (24-07-2020)
101 *
102 * @param mixed $text Text.
103 * @param mixed $type Type.
104 * @param mixed $name Name.
105 * @param mixed $wrap Wrap.
106 * @param mixed $other_attributes Attr.
107 * @return string
108 */
109 function wpdadiehard_get_submit_button( $text = '', $type = 'primary large', $name = 'submit', $wrap = true, $other_attributes = '' ) {
110 if ( ! is_array( $type ) ) {
111 $type = explode( ' ', (string) $type ); // phpcs:ignore -- 8.1 proof
112 }
113
114 $button_shorthand = array( 'primary', 'small', 'large' );
115 $classes = array( 'button' );
116 foreach ( $type as $t ) {
117 if ( 'secondary' === $t || 'button-secondary' === $t ) {
118 continue;
119 }
120 $classes[] = in_array( $t, $button_shorthand, true ) ? 'button-' . $t : $t; // phpcs:ignore -- 8.1 proof
121 }
122 // Remove empty items, remove duplicate items, and finally build a string.
123 $class = implode( ' ', array_unique( array_filter( $classes ) ) ); // phpcs:ignore -- 8.1 proof
124
125 $text = $text ? $text : __( 'Save Changes', 'wp-data-access' );
126
127 // Default the id attribute to $name unless an id was specifically provided in $other_attributes.
128 $id = $name;
129 if ( is_array( $other_attributes ) && isset( $other_attributes['id'] ) ) {
130 $id = $other_attributes['id'];
131 unset( $other_attributes['id'] );
132 }
133
134 $attributes = '';
135 if ( is_array( $other_attributes ) ) {
136 foreach ( $other_attributes as $attribute => $value ) {
137 $attributes .= $attribute . '="' . esc_attr( $value ) . '" '; // Trailing space is important.
138 }
139 } elseif ( ! empty( $other_attributes ) ) { // Attributes provided as a string.
140 $attributes = $other_attributes;
141 }
142
143 // Don't output empty name and id attributes.
144 $name_attr = $name ? ' name="' . esc_attr( $name ) . '"' : '';
145 $id_attr = $id ? ' id="' . esc_attr( $id ) . '"' : '';
146
147 $button = '<input type="submit"' . $name_attr . $id_attr . ' class="' . esc_attr( $class );
148 $button .= '" value="' . esc_attr( $text ) . '" ' . $attributes . ' />';
149
150 if ( $wrap ) {
151 $button = '<p class="submit">' . $button . '</p>';
152 }
153
154 return $button;
155 }
156