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

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