PluginProbe
WP Data Access – App Builder for Tables, Forms, Charts, Maps & Dashboards / 5.5.73
WP Data Access – App Builder for Tables, Forms, Charts, Maps & Dashboards v5.5.73
5.5.85 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 All 161 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.73, at WPDataAccess/Settings/WPDA_Settings.php

141 lines 3.9 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 namespace WPDataAccess\Settings;
9
10 /**
11 * Class WPDA_Settings
12 *
13 * All tabs have the following similar structure:
14 * + If form was posted save options (show success or error message)
15 * + Read options
16 * + Show form with options for selected tab
17 *
18 * Tabs Back-end Settings, Front-end Settings, Data Backup Settings and Uninstall Settings have reset buttons. When
19 * the reset button on a specific tab is clicked, the default values for the settings on that tab are taken from
20 * WPDA and stored in $pwdb->options.
21 *
22 * When the users clicks on tab Manage Repository, the repository is validated and the status of the repository
23 * is shown. If the repository has errors, a button is offered to recreate the repository.
24 *
25 * @author Peter Schulz
26 * @since 1.0.0
27 */
28 abstract class WPDA_Settings {
29 /**
30 * Menu slug of the current page
31 *
32 * @var string
33 */
34 protected $page;
35
36 /**
37 * Available tabs on the page
38 *
39 * @var array
40 */
41 protected $tabs;
42
43 /**
44 * Current tab name
45 *
46 * @var string
47 */
48 protected $current_tab;
49
50 /**
51 * WPDA_Settings constructor
52 *
53 * Member $this->tabs is filled in the constructor to support i18n.
54 *
55 * If a request was sent for recreation of the repository, this is done in the constructor. This action must
56 * be performed before checking the user menu model, which is part of the constructor as well, necessary to
57 * inform the user if any errors were reported.
58 *
59 * @param $current_tab Current tab label
60 *
61 * @since 1.0.0
62 */
63 public function __construct( $current_tab ) {
64 // Get menu slug of current page.
65 if ( isset( $_REQUEST['page'] ) ) {
66 $this->page = sanitize_text_field( wp_unslash( $_REQUEST['page'] ) );
67 // input var okay.
68 } else {
69 // In order to show a list table we need a page.
70 wp_die( __( '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 echo __( '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