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 / WPDataAccess / Settings / WPDA_Settings.php

WPDA_Settings.php in WP Data Access – App Builder for Tables, Forms, Charts, Maps & Dashboards 5.5.84, at WPDataAccess/Settings/WPDA_Settings.php

142 lines 4.1 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\Settings
7 */
8 // phpcs:disable WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing -- verified on page
9 namespace WPDataAccess\Settings;
10
11 /**
12 * Class WPDA_Settings
13 *
14 * All tabs have the following similar structure:
15 * + If form was posted save options (show success or error message)
16 * + Read options
17 * + Show form with options for selected tab
18 *
19 * Tabs Back-end Settings, Front-end Settings, Data Backup Settings and Uninstall Settings have reset buttons. When
20 * the reset button on a specific tab is clicked, the default values for the settings on that tab are taken from
21 * WPDA and stored in $pwdb->options.
22 *
23 * When the users clicks on tab Manage Repository, the repository is validated and the status of the repository
24 * is shown. If the repository has errors, a button is offered to recreate the repository.
25 *
26 * @author Peter Schulz
27 * @since 1.0.0
28 */
29 abstract class WPDA_Settings {
30 /**
31 * Menu slug of the current page
32 *
33 * @var string
34 */
35 protected $page;
36
37 /**
38 * Available tabs on the page
39 *
40 * @var array
41 */
42 protected $tabs;
43
44 /**
45 * Current tab name
46 *
47 * @var string
48 */
49 protected $current_tab;
50
51 /**
52 * WPDA_Settings constructor
53 *
54 * Member $this->tabs is filled in the constructor to support i18n.
55 *
56 * If a request was sent for recreation of the repository, this is done in the constructor. This action must
57 * be performed before checking the user menu model, which is part of the constructor as well, necessary to
58 * inform the user if any errors were reported.
59 *
60 * @param $current_tab Current tab label
61 *
62 * @since 1.0.0
63 */
64 public function __construct( $current_tab ) {
65 // Get menu slug of current page.
66 if ( isset( $_REQUEST['page'] ) ) {
67 $this->page = sanitize_text_field( wp_unslash( $_REQUEST['page'] ) );
68 } else {
69 // In order to show a list table we need a page.
70 wp_die( esc_attr__( 'ERROR: Wrong arguments [missing page argument]', 'wp-data-access' ) );
71 }
72 $this->current_tab = $current_tab;
73 // Tabs array is filled in constructor to add i18n.
74 $this->tabs = array(
75 'plugin' => 'Plugin',
76 'apps' => 'Apps',
77 'backend' => 'Back-end',
78 'frontend' => 'Front-end',
79 'uninstall' => 'Uninstall',
80 'repository' => 'Repository',
81 'mail' => 'Mail',
82 'drives' => 'Drives',
83 'legacy' => 'Legacy Tools',
84 'system' => 'System Info',
85 );
86 }
87
88 protected abstract function add_content();
89
90 /**
91 * Show setting page
92 *
93 * Consists of tabs {@see WPDA_Settings::add_tabs()} and the content of the selected tab
94 * {@see \WPDataAccess\API\WPDA_Settings::add_content()}.
95 *
96 * @since 1.0.0
97 *
98 * @see WPDA_Settings::add_tabs()
99 * @see \WPDataAccess\API\WPDA_Settings::add_content()
100 */
101 public function show() {
102 ?>
103 <div class="wrap">
104 <h1>
105 <?php
106 esc_html_e( 'WP Data Access Settings', 'wp-data-access' );
107 ?>
108 </h1>
109 <?php
110 $this->add_tabs();
111 $this->add_content();
112 ?>
113 </div>
114 <script>
115 jQuery(function() {
116 jQuery( '.wpda_tooltip' ).tooltip();
117 });
118 </script>
119 <?php
120 }
121
122 /**
123 * Add tabs to page
124 *
125 * @since 1.0.0
126 */
127 protected function add_tabs() {
128 ?>
129 <h2 class="nav-tab-wrapper">
130 <?php
131 foreach ( $this->tabs as $tab => $name ) {
132 $class = ( $tab === $this->current_tab ? ' nav-tab-active' : '' );
133 echo '<a class="nav-tab' . esc_attr( $class ) . '" href="?page=' . esc_attr( $this->page ) . '&tab=' . esc_attr( $tab ) . '">' . esc_attr( $name ) . '</a>';
134 }
135 ?>
136 </h2>
137 <?php
138 }
139
140 }
141
142 // phpcs:disable WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing