PluginProbe
WP Data Access – App Builder for Tables, Forms, Charts, Maps & Dashboards / 5.5.34
WP Data Access – App Builder for Tables, Forms, Charts, Maps & Dashboards v5.5.34
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.34, at WPDataAccess/Settings/WPDA_Settings.php

146 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 use WPDataAccess\Utilities\WPDA_Import;
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 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 * Reference to wpda import object
53 *
54 * @var WPDA_Import
55 */
56 protected $wpda_import;
57
58 /**
59 * WPDA_Settings constructor
60 *
61 * Member $this->tabs is filled in the constructor to support i18n.
62 *
63 * If a request was send for recreation of the repository, this is done in the constructor. This action must
64 * be performed before checking the user menu model, which is part of the constructor as well, necessary to
65 * inform the user if any errors were reported.
66 *
67 * @param $current_tab Current tab label
68 *
69 * @since 1.0.0
70 */
71 public function __construct( $current_tab ) {
72 // Get menu slag of current page.
73 if ( isset( $_REQUEST['page'] ) ) {
74 $this->page = sanitize_text_field( wp_unslash( $_REQUEST['page'] ) );
75 // input var okay.
76 } else {
77 // In order to show a list table we need a page.
78 wp_die( __( 'ERROR: Wrong arguments [missing page argument]', 'wp-data-access' ) );
79 }
80 $this->current_tab = $current_tab;
81 // Tabs array is filled in constructor to add i18n.
82 $this->tabs = array(
83 'plugin' => 'Plugin',
84 'backend' => 'Back-end',
85 'frontend' => 'Front-end',
86 'datatables' => 'Data Tables',
87 'databackup' => 'Data Backup',
88 'uninstall' => 'Uninstall',
89 'repository' => 'Repository',
90 'roles' => 'Roles',
91 'system' => 'System Info',
92 );
93 }
94
95 /**
96 * Show setting page
97 *
98 * Consists of tabs {@see WPDA_Settings::add_tabs()} and the content of the selected tab
99 * {@see \WPDataAccess\API\WPDA_Settings::add_content()}.
100 *
101 * @since 1.0.0
102 *
103 * @see WPDA_Settings::add_tabs()
104 * @see \WPDataAccess\API\WPDA_Settings::add_content()
105 */
106 public function show() {
107 ?>
108 <div class="wrap">
109 <h1>
110 <?php
111 echo __( 'WP Data Access Settings', 'wp-data-access' );
112 ?>
113 </h1>
114 <?php
115 $this->add_tabs();
116 $this->add_content();
117 ?>
118 </div>
119 <script>
120 jQuery(function() {
121 jQuery( '.wpda_tooltip' ).tooltip();
122 });
123 </script>
124 <?php
125 }
126
127 /**
128 * Add tabs to page
129 *
130 * @since 1.0.0
131 */
132 protected function add_tabs() {
133 ?>
134 <h2 class="nav-tab-wrapper">
135 <?php
136 foreach ( $this->tabs as $tab => $name ) {
137 $class = ( $tab === $this->current_tab ? ' nav-tab-active' : '' );
138 echo '<a class="nav-tab' . esc_attr( $class ) . '" href="?page=' . esc_attr( $this->page ) . '&tab=' . esc_attr( $tab ) . '">' . esc_attr( $name ) . '</a>';
139 }
140 ?>
141 </h2>
142 <?php
143 }
144
145 }
146