| @@ -8,11 +8,10 @@ | ||
| 8 | 8 | use WPDataAccess\Connection\WPDADB; |
| 9 | 9 | use WPDataAccess\Cookies\WPDA_Cookies; |
| 10 | 10 | use WPDataAccess\Data_Dictionary\WPDA_Dictionary_Lists; |
| 11 | 11 | use WPDataAccess\Data_Tables\WPDA_Data_Tables; |
| 12 | -use WPDataAccess\Utilities\WPDA_Table_Actions; | |
| 12 | +use WPDataAccess\Plugin_Table_Models\WPDA_Table_Settings_Model; | |
| 13 | 13 | use WPDataAccess\Utilities\WPDA_Export; |
| 14 | -use WPDataAccess\Utilities\WPDA_Favourites; | |
| 15 | 14 | use WPDataAccess\WPDA; |
| 16 | 15 | use WPDataProjects\Utilities\WPDP_Export_Project; |
| 17 | 16 | use WPDataAccess\Backup\WPDA_Data_Export; |
| 18 | 17 | use WPDataAccess\Plugin_Table_Models\WPDA_CSV_Uploads_Model; |
| @@ -19,9 +18,8 @@ | ||
| 19 | 18 | use WPDataRoles\WPDA_Roles; |
| 20 | 19 | use WPDataAccess\Utilities\WPDA_Autocomplete; |
| 21 | 20 | use WPDataAccess\Premium\WPDAPRO_Geo_Location\WPDAPRO_Geo_Location_WS; |
| 22 | 21 | use WPDataAccess\Premium\WPDAPRO_Geo_Location\WPDAPRO_Geo_Location; |
| 23 | -use WPDataAccess\Query_Builder\WPDA_Query_Builder; | |
| 24 | 22 | use WPDataAccess\Dashboard\WPDA_Dashboard; |
| 25 | 23 | use WPDataAccess\Dashboard\WPDA_Widget_Code; |
| 26 | 24 | use WPDataAccess\Dashboard\WPDA_Widget_Publication; |
| 27 | 25 | use WPDataAccess\Dashboard\WPDA_Widget_Dbms; |
| @@ -43,8 +41,9 @@ | ||
| 43 | 41 | * @see WP_Data_Access_Public |
| 44 | 42 | * @see WP_Data_Access_I18n |
| 45 | 43 | * @see WP_Data_Access_Loader |
| 46 | 44 | */ |
| 45 | +// phpcs:disable WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing -- verified on page | |
| 47 | 46 | class WP_Data_Access { |
| 48 | 47 | /** |
| 49 | 48 | * Reference to plugin loader |
| 50 | 49 | * |
| @@ -80,11 +79,9 @@ | ||
| 80 | 79 | * @see WP_Data_Access::define_public_hooks() |
| 81 | 80 | */ |
| 82 | 81 | public function __construct() { |
| 83 | 82 | if ( isset( $_REQUEST['page'] ) ) { |
| 84 | - // phpcs:ignore WordPress.Security.NonceVerification | |
| 85 | 83 | $this->page = sanitize_text_field( wp_unslash( $_REQUEST['page'] ) ); |
| 86 | - // phpcs:ignore WordPress.Security.NonceVerification | |
| 87 | 84 | } |
| 88 | 85 | $this->load_dependencies(); |
| 89 | 86 | $this->set_locale(); |
| 90 | 87 | $this->define_admin_hooks(); |
| @@ -152,14 +149,8 @@ | ||
| 152 | 149 | $this->loader->add_action( 'admin_init', $wpda_cookies, 'handle_plugin_cookies' ); |
| 153 | 150 | } |
| 154 | 151 | // Admin menu. |
| 155 | 152 | $this->loader->add_action( 'admin_menu', $plugin_admin, 'add_menu_items' ); |
| 156 | - $this->loader->add_action( | |
| 157 | - 'admin_menu', | |
| 158 | - $plugin_admin, | |
| 159 | - 'add_menu_my_tables', | |
| 160 | - 11 | |
| 161 | - ); | |
| 162 | 153 | $this->loader->add_filter( 'submenu_file', $plugin_admin, 'wpda_submenu_filter' ); |
| 163 | 154 | // Admin scripts. |
| 164 | 155 | $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' ); |
| 165 | 156 | $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts' ); |
| @@ -166,17 +157,53 @@ | ||
| 166 | 157 | $this->loader->add_action( 'in_admin_header', $plugin_admin, 'user_admin_notices' ); |
| 167 | 158 | $this->loader->add_action( 'admin_head', $plugin_admin, 'remove_icons' ); |
| 168 | 159 | // Add settings page. |
| 169 | 160 | $this->loader->add_action( 'admin_menu', $this, 'wpdataaccess_register_settings_page' ); |
| 170 | - // Query Builder. | |
| 171 | - $query_builder = new WPDA_Query_Builder(); | |
| 172 | - $this->loader->add_action( 'admin_action_wpda_query_builder_execute_sql', $query_builder, 'execute' ); | |
| 173 | - $this->loader->add_action( 'admin_action_wpda_query_builder_save_sql', $query_builder, 'save' ); | |
| 174 | - $this->loader->add_action( 'admin_action_wpda_query_builder_open_sql', $query_builder, 'open' ); | |
| 175 | - $this->loader->add_action( 'admin_action_wpda_query_builder_delete_sql', $query_builder, 'delete' ); | |
| 176 | - $this->loader->add_action( 'admin_action_wpda_query_builder_get_db_hints', $query_builder, 'get_db_hints' ); | |
| 177 | - $this->loader->add_action( 'admin_action_wpda_query_builder_set_db_hints', $query_builder, 'set_db_hints' ); | |
| 178 | - $this->loader->add_action( 'admin_action_wpda_query_builder_get_vqb', $query_builder, 'get_visual_query' ); | |
| 161 | + // Run unattended scheduled export | |
| 162 | + $this->loader->add_action( \WPDataAccess\Utilities\WPDA_Export_Scheduler::SCHEDULER_HOOK_NAME, \WPDataAccess\Utilities\WPDA_Export_Scheduler::class, 'run_scheduled_export' ); | |
| 163 | + // Mail service. | |
| 164 | + $wpda_mail_server = \WPDataAccess\Utilities\WPDA_Mail::get_option(); | |
| 165 | + if ( isset( | |
| 166 | + $wpda_mail_server['host'], | |
| 167 | + $wpda_mail_server['port'], | |
| 168 | + $wpda_mail_server['authenticate'], | |
| 169 | + $wpda_mail_server['encryption'], | |
| 170 | + $wpda_mail_server['skip_verify'], | |
| 171 | + $wpda_mail_server['username'], | |
| 172 | + $wpda_mail_server['password'] | |
| 173 | + ) ) { | |
| 174 | + add_action( | |
| 175 | + 'phpmailer_init', | |
| 176 | + function ( $phpmailer ) use($wpda_mail_server) { | |
| 177 | + // Only run if mail WPDA requests. | |
| 178 | + if ( !did_action( 'wpda_sending_mail' ) ) { | |
| 179 | + return; | |
| 180 | + // Allow other plugins/themes to overwrite. | |
| 181 | + } | |
| 182 | + $phpmailer->isSMTP(); | |
| 183 | + $phpmailer->isHTML( false ); | |
| 184 | + $phpmailer->SMTPDebug = $wpda_mail_server['debug'] ?? 0; | |
| 185 | + $phpmailer->Host = $wpda_mail_server['host']; | |
| 186 | + $phpmailer->Port = $wpda_mail_server['port']; | |
| 187 | + $phpmailer->SMTPAuth = 'on' === $wpda_mail_server['authenticate']; | |
| 188 | + $phpmailer->SMTPSecure = $wpda_mail_server['encryption']; | |
| 189 | + if ( 'on' === $wpda_mail_server['skip_verify'] ) { | |
| 190 | + $phpmailer->SMTPOptions = array( | |
| 191 | + 'ssl' => array( | |
| 192 | + 'verify_peer' => false, | |
| 193 | + 'verify_peer_name' => false, | |
| 194 | + 'allow_self_signed' => true, | |
| 195 | + ), | |
| 196 | + ); | |
| 197 | + } | |
| 198 | + $phpmailer->Username = $wpda_mail_server['username']; | |
| 199 | + $phpmailer->Password = $wpda_mail_server['password']; | |
| 200 | + $phpmailer->From = $wpda_mail_server['username']; | |
| 201 | + }, | |
| 202 | + 10, | |
| 203 | + 1 | |
| 204 | + ); | |
| 205 | + } | |
| 179 | 206 | // Export action. |
| 180 | 207 | $this->loader->add_action( 'admin_action_wpda_export', WPDA_Export::class, 'export' ); |
| 181 | 208 | // Dashboard and widgets. |
| 182 | 209 | $this->loader->add_action( 'wp_ajax_wpda_save_dashboard', WPDA_Dashboard::class, 'save' ); |
| @@ -189,15 +216,8 @@ | ||
| 189 | 216 | $this->loader->add_action( 'wp_ajax_wpda_remove_new_dashboard_message', WPDA_Dashboard::class, 'remove_new_dashboard_message' ); |
| 190 | 217 | $this->loader->add_action( 'wp_ajax_wpda_widget_pub_add', WPDA_Widget_Publication::class, 'ajax_widget' ); |
| 191 | 218 | $this->loader->add_action( 'wp_ajax_wpda_widget_chart_add', WPDA_Widget_Google_Chart::class, 'ajax_widget' ); |
| 192 | 219 | $this->loader->add_action( 'wp_ajax_wpda_widget_chart_refresh', WPDA_Widget_Google_Chart::class, 'ajax_refresh' ); |
| 193 | - // Add/remove favourites. | |
| 194 | - $plugin_favourites = new WPDA_Favourites(); | |
| 195 | - $this->loader->add_action( 'admin_action_wpda_add_favourite', $plugin_favourites, 'add' ); | |
| 196 | - $this->loader->add_action( 'admin_action_wpda_rem_favourite', $plugin_favourites, 'rem' ); | |
| 197 | - // Show tables actions. | |
| 198 | - $plugin_table_actions = new WPDA_Table_Actions(); | |
| 199 | - $this->loader->add_action( 'admin_action_wpda_show_table_actions', $plugin_table_actions, 'show' ); | |
| 200 | 220 | $plugin_dictionary_list = new WPDA_Dictionary_Lists(); |
| 201 | 221 | // Get tables for a specific database. |
| 202 | 222 | $this->loader->add_action( 'admin_action_wpda_get_tables', $plugin_dictionary_list, 'get_tables_ajax' ); |
| 203 | 223 | // Get columns for a specific table. |
| @@ -204,9 +224,9 @@ | ||
| 204 | 224 | $this->loader->add_action( 'admin_action_wpda_get_columns', $plugin_dictionary_list, 'get_columns' ); |
| 205 | 225 | // Get row count for a specific table. |
| 206 | 226 | $this->loader->add_action( 'admin_action_wpda_get_table_row_count', $plugin_dictionary_list, 'get_table_row_count_ajax' ); |
| 207 | 227 | // Get table widget info. |
| 208 | - $this->loader->add_action( 'admin_action_wpda_get_table_widget_info', $plugin_dictionary_list, 'get_table_widget_info' ); | |
| 228 | + $this->loader->add_action( 'admin_action_wpda_get_table_widget_info', $plugin_dictionary_list, 'get_table_widget_info_ajax' ); | |
| 209 | 229 | // Global database search and replace. |
| 210 | 230 | $this->loader->add_action( 'wp_ajax_wpda_global_search', \WPDataAccess\Global_Search\WPDA_Global_Search::class, 'search' ); |
| 211 | 231 | $this->loader->add_action( 'wp_ajax_wpda_global_replace', \WPDataAccess\Global_Search\WPDA_Global_Search::class, 'replace' ); |
| 212 | 232 | // Export project. |
| @@ -241,41 +261,35 @@ | ||
| 241 | 261 | 'wp_ajax_wpda_dbinit_admin', |
| 242 | 262 | function () { |
| 243 | 263 | if ( !isset( $_POST['wpnonce'], $_POST['wpdaschema_name'] ) ) { |
| 244 | 264 | WPDA::sent_header( 'application/json' ); |
| 245 | - echo WPDA::sent_msg( 'ERROR', 'Invalid arguments' ); | |
| 246 | - // phpcs:ignore WordPress.Security.EscapeOutput | |
| 265 | + WPDA::sent_msg( 'ERROR', 'Invalid arguments' ); | |
| 247 | 266 | wp_die(); |
| 248 | 267 | } |
| 268 | + // phpcs:disable WordPress.Security.ValidatedSanitizedInput.InputNotValidated | |
| 249 | 269 | $wpnonce = sanitize_text_field( wp_unslash( $_REQUEST['wpnonce'] ) ); |
| 250 | - // input var okay. | |
| 251 | - if ( !current_user_can( 'manage_options' ) || !wp_verify_nonce( $wpnonce, 'wpda_dbinit_admin_' . WPDA::get_current_user_login() ) ) { | |
| 270 | + if ( !WPDA::current_user_is_admin() || !wp_verify_nonce( $wpnonce, 'wpda_dbinit_admin_' . WPDA::get_current_user_login() ) ) { | |
| 252 | 271 | WPDA::sent_header( 'application/json' ); |
| 253 | - echo WPDA::sent_msg( 'ERROR', 'Not authorized' ); | |
| 254 | - // phpcs:ignore WordPress.Security.EscapeOutput | |
| 272 | + WPDA::sent_msg( 'ERROR', 'Not authorized' ); | |
| 255 | 273 | wp_die(); |
| 256 | 274 | } |
| 257 | 275 | $wpdaschema_name = sanitize_text_field( wp_unslash( $_REQUEST['wpdaschema_name'] ) ); |
| 258 | - // input var okay. | |
| 276 | + // phpcs:enable WordPress.Security.ValidatedSanitizedInput.InputNotValidated | |
| 259 | 277 | $wpdadb = WPDADB::get_db_connection( $wpdaschema_name ); |
| 260 | 278 | if ( null === $wpdadb ) { |
| 261 | 279 | WPDA::sent_header( 'application/json' ); |
| 262 | - echo WPDA::sent_msg( 'ERROR', 'Cannot connect to database' ); | |
| 263 | - // phpcs:ignore WordPress.Security.EscapeOutput | |
| 280 | + WPDA::sent_msg( 'ERROR', 'Cannot connect to database' ); | |
| 264 | 281 | wp_die(); |
| 265 | 282 | } |
| 266 | 283 | $suppress_errors = $wpdadb->suppress_errors( true ); |
| 267 | 284 | $wpdadb->query( 'create function wpda_get_wp_user_id() returns integer deterministic no sql return @wpda_wp_user_id' ); |
| 268 | 285 | $error = $wpdadb->last_error; |
| 269 | - $fnc = $wpdadb->dbh->query( "show function status like 'wpda_get_wp_user_id'" ); | |
| 270 | 286 | $wpdadb->suppress_errors( $suppress_errors ); |
| 271 | - if ( 1 === count( (array) $fnc ) ) { | |
| 272 | - //phpcs:ignore - 8.1 proof | |
| 273 | - echo WPDA::sent_msg( 'OK', '' ); | |
| 274 | - // phpcs:ignore WordPress.Security.EscapeOutput | |
| 287 | + if ( '' === $error ) { | |
| 288 | + // phpcs:ignore -- 8.1 proof | |
| 289 | + WPDA::sent_msg( 'OK', '' ); | |
| 275 | 290 | } else { |
| 276 | - echo WPDA::sent_msg( 'ERROR', "Function not created [{$error}]" ); | |
| 277 | - // phpcs:ignore WordPress.Security.EscapeOutput | |
| 291 | + WPDA::sent_msg( 'ERROR', "Function not created [{$error}]" ); | |
| 278 | 292 | } |
| 279 | 293 | wp_die(); |
| 280 | 294 | }, |
| 281 | 295 | 10, |
| @@ -324,8 +338,102 @@ | ||
| 324 | 338 | }, |
| 325 | 339 | 10, |
| 326 | 340 | 1 |
| 327 | 341 | ); |
| 342 | + add_action( | |
| 343 | + 'wpda_set_hard_row_count', | |
| 344 | + function ( $dbs, $tbl ) { | |
| 345 | + // Only admins and super admins. | |
| 346 | + if ( WPDA::current_user_is_admin() ) { | |
| 347 | + // Get actual row count. | |
| 348 | + $count = \WPDataAccess\API\WPDA_Actions::get_row_count( $dbs, $tbl ); | |
| 349 | + // Get table settings. | |
| 350 | + $settings_db = WPDA_Table_Settings_Model::query( $tbl, $dbs ); | |
| 351 | + if ( isset( $settings_db[0]['wpda_table_settings'] ) ) { | |
| 352 | + // Convert string to JSON. | |
| 353 | + $settings = json_decode( $settings_db[0]['wpda_table_settings'], true ); | |
| 354 | + if ( isset( $settings['table_settings']['row_count_estimate_value_hard'] ) ) { | |
| 355 | + // Store actual row count as hard estimate. | |
| 356 | + $settings['table_settings']['row_count_estimate_value_hard'] = $count; | |
| 357 | + // Save new hard row count. | |
| 358 | + WPDA_Table_Settings_Model::update( $tbl, json_encode( $settings ), $dbs ); | |
| 359 | + } | |
| 360 | + } | |
| 361 | + } | |
| 362 | + }, | |
| 363 | + 10, | |
| 364 | + 2 | |
| 365 | + ); | |
| 366 | + // Add WP Data Access dashboard to freemius pages | |
| 367 | + add_action( 'admin_enqueue_scripts', function () { | |
| 368 | + if ( 'wpda_navi-account' === $this->page || 'wpda_navi-pricing' === $this->page || 'wpda_navi-affiliation' === $this->page ) { | |
| 369 | + wp_enqueue_script( 'jquery-ui-sortable' ); | |
| 370 | + wp_enqueue_script( 'jquery-ui-tooltip' ); | |
| 371 | + wp_enqueue_style( | |
| 372 | + 'wpdataaccess_dashboard', | |
| 373 | + plugins_url( '../assets/css/wpda_dashboard.css', __FILE__ ), | |
| 374 | + array(), | |
| 375 | + WPDA::get_option( WPDA::OPTION_WPDA_VERSION ) | |
| 376 | + ); | |
| 377 | + wp_enqueue_script( | |
| 378 | + 'wpdataaccess_dashboard', | |
| 379 | + plugins_url( '../assets/js/wpda_dashboard.js', __FILE__ ), | |
| 380 | + array(), | |
| 381 | + WPDA::get_option( WPDA::OPTION_WPDA_VERSION ), | |
| 382 | + false | |
| 383 | + ); | |
| 384 | + wp_localize_script( 'wpdataaccess_dashboard', 'wpda_dashboard_vars', array( | |
| 385 | + 'wpda_ajaxurl' => admin_url( 'admin-ajax.php' ), | |
| 386 | + ) ); | |
| 387 | + // SAVING SPACE - According to the plugin guidelines it is allowed to include external fonts: | |
| 388 | + // https://developer.wordpress.org/plugins/wordpress-org/detailed-plugin-guidelines/#8-plugins-may-not-send-executable-code-via-third-party-systems . | |
| 389 | + // Load fontawesome icons. | |
| 390 | + // phpcs:disable WordPress.WP.EnqueuedResourceParameters.MissingVersion | |
| 391 | + wp_enqueue_style( | |
| 392 | + 'wpda_fontawesome_icons', | |
| 393 | + WPDA::CDN_FONTAWESOME . 'all.min.css', | |
| 394 | + array(), | |
| 395 | + null, | |
| 396 | + false | |
| 397 | + ); | |
| 398 | + // phpcs:enable WordPress.WP.EnqueuedResourceParameters.MissingVersion | |
| 399 | + // Add dashboards to freemius pages | |
| 400 | + wp_enqueue_style( | |
| 401 | + 'wpda_add_dashboard_freemius', | |
| 402 | + plugins_url( '../assets/css/wpda_freemius.css', __FILE__ ), | |
| 403 | + array(), | |
| 404 | + WPDA::get_option( WPDA::OPTION_WPDA_VERSION ) | |
| 405 | + ); | |
| 406 | + wp_enqueue_script( | |
| 407 | + 'wpda_add_dashboard_freemius', | |
| 408 | + plugins_url( '../assets/js/wpda_freemius.js', __FILE__ ), | |
| 409 | + array(), | |
| 410 | + WPDA::get_option( WPDA::OPTION_WPDA_VERSION ), | |
| 411 | + false | |
| 412 | + ); | |
| 413 | + ob_start(); | |
| 414 | + WPDA_Dashboard::add_dashboard(); | |
| 415 | + $freemius_dashboard = ob_get_clean(); | |
| 416 | + $freemius_title = ''; | |
| 417 | + if ( 'wpda_navi-affiliation' === $this->page ) { | |
| 418 | + $freemius_title = '<h1 class="wp-heading-inline" style="padding-top: 10px">WP Data Access Affiliate Program</h1>'; | |
| 419 | + } else { | |
| 420 | + if ( 'wpda_navi-pricing' === $this->page ) { | |
| 421 | + $freemius_title = '<h1 class="wp-heading-inline" style="padding-top: 10px">WP Data Access Plans and Pricing</h1><h2>Choose your plan and upgrade in minutes!</h2>'; | |
| 422 | + } else { | |
| 423 | + if ( 'wpda_navi-account' === $this->page ) { | |
| 424 | + $freemius_title = '<h1 class="wp-heading-inline" style="padding-top: 10px">WP Data Access Account</h1>'; | |
| 425 | + } | |
| 426 | + } | |
| 427 | + } | |
| 428 | + wp_localize_script( 'wpda_add_dashboard_freemius', 'dashboard', array( | |
| 429 | + 'content' => $freemius_dashboard . $freemius_title, | |
| 430 | + ) ); | |
| 431 | + // Remove notices | |
| 432 | + remove_all_actions( 'admin_notices' ); | |
| 433 | + remove_all_actions( 'all_admin_notices' ); | |
| 434 | + } | |
| 435 | + }, 9 ); | |
| 328 | 436 | } |
| 329 | 437 | |
| 330 | 438 | /** |
| 331 | 439 | * Needed for JDT to support IE |
| @@ -336,10 +444,11 @@ | ||
| 336 | 444 | * @return mixed|string |
| 337 | 445 | */ |
| 338 | 446 | public function add_id_to_script( $tag, $handle, $src ) { |
| 339 | 447 | if ( 'wpda_datatables' === $handle ) { |
| 448 | + // phpcs:disable WordPress.WP.EnqueuedResources.NonEnqueuedScript | |
| 340 | 449 | $tag = '<script id="wpda_datatables" src="' . $src . '"></script>'; |
| 341 | - // phpcs:ignore WordPress.WP.EnqueuedResources.NonEnqueuedScript | |
| 450 | + // phpcs:enable WordPress.WP.EnqueuedResources.NonEnqueuedScript | |
| 342 | 451 | } |
| 343 | 452 | return $tag; |
| 344 | 453 | } |
| 345 | 454 | |
| @@ -401,11 +510,49 @@ | ||
| 401 | 510 | * |
| 402 | 511 | * @since 1.0.0 |
| 403 | 512 | */ |
| 404 | 513 | public function run() { |
| 514 | + $this->loader->add_action( 'init', $this, 'register_blocks' ); | |
| 515 | + $this->loader->add_action( 'enqueue_block_assets', $this, 'enqueue_block_assets' ); | |
| 405 | 516 | $this->loader->run(); |
| 406 | 517 | } |
| 407 | 518 | |
| 519 | + public function register_blocks() { | |
| 520 | + register_block_type( plugin_dir_path( dirname( __FILE__ ) ) . 'assets/gtb', array( | |
| 521 | + 'render_callback' => array($this, 'render_wp_data_access_app_block'), | |
| 522 | + ) ); | |
| 523 | + } | |
| 524 | + | |
| 525 | + public function enqueue_block_assets() { | |
| 526 | + wp_enqueue_style( 'dashicons' ); | |
| 527 | + } | |
| 528 | + | |
| 529 | + public function render_wp_data_access_app_block( $attributes ) { | |
| 530 | + $appid = ( isset( $attributes['appid'] ) ? sanitize_text_field( $attributes['appid'] ) : '' ); | |
| 531 | + $feedback = filter_var( $attributes['feedback'] ?? false, FILTER_VALIDATE_BOOLEAN ); | |
| 532 | + $builders = filter_var( $attributes['builders'] ?? false, FILTER_VALIDATE_BOOLEAN ); | |
| 533 | + $hidetitlebar = filter_var( $attributes['hidetitlebar'] ?? false, FILTER_VALIDATE_BOOLEAN ); | |
| 534 | + $fullscreen = filter_var( $attributes['fullscreen'] ?? false, FILTER_VALIDATE_BOOLEAN ); | |
| 535 | + if ( empty( $appid ) ) { | |
| 536 | + return null; | |
| 537 | + } | |
| 538 | + if ( !shortcode_exists( 'wpda_app' ) ) { | |
| 539 | + return 'Shortcode wpda_app is not registered.'; | |
| 540 | + } | |
| 541 | + $shortcode = sprintf( | |
| 542 | + '[wpda_app app_id="%s" builders="%s" feedback="%s" hidetitlebar="%s" fullscreen="%s"]', | |
| 543 | + esc_attr( $appid ), | |
| 544 | + ( $builders ? 'false' : 'true' ), | |
| 545 | + ( $feedback ? 'true' : 'false' ), | |
| 546 | + ( $hidetitlebar ? 'true' : 'false' ), | |
| 547 | + ( $fullscreen ? 'true' : 'false' ) | |
| 548 | + ); | |
| 549 | + $wrapper_attributes = get_block_wrapper_attributes( array( | |
| 550 | + 'class' => 'wpda-wp-data-access-app', | |
| 551 | + ) ); | |
| 552 | + return sprintf( '<div %s>%s</div>', $wrapper_attributes, do_shortcode( $shortcode ) ); | |
| 553 | + } | |
| 554 | + | |
| 408 | 555 | /** |
| 409 | 556 | * Add plugin settings page |
| 410 | 557 | */ |
| 411 | 558 | public function wpdataaccess_register_settings_page() { |
| @@ -423,60 +570,46 @@ | ||
| 423 | 570 | */ |
| 424 | 571 | public function wpdataaccess_settings_page() { |
| 425 | 572 | WPDA_Dashboard::add_dashboard(); |
| 426 | 573 | $current_tab = ( isset( $_REQUEST['tab'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['tab'] ) ) : 'plugin' ); |
| 427 | - // phpcs:ignore WordPress.Security.NonceVerification | |
| 428 | 574 | switch ( $current_tab ) { |
| 575 | + case 'apps': | |
| 576 | + $wpda_settings_class_name = 'WPDA_Settings_Apps'; | |
| 577 | + break; | |
| 429 | 578 | case 'backend': |
| 430 | 579 | $wpda_settings_class_name = 'WPDA_Settings_BackEnd'; |
| 431 | - $help_url = 'https://wpdataaccess.com/docs/plugin-settings/back-end/'; | |
| 432 | 580 | break; |
| 433 | 581 | case 'frontend': |
| 434 | 582 | $wpda_settings_class_name = 'WPDA_Settings_FrontEnd'; |
| 435 | - $help_url = 'https://wpdataaccess.com/docs/plugin-settings/front-end/'; | |
| 436 | 583 | break; |
| 437 | 584 | case 'pds': |
| 438 | 585 | $wpda_settings_class_name = 'WPDA_Settings_PDS'; |
| 439 | - $help_url = 'https://wpdataaccess.com/docs/plugin-settings/premium-data-services/'; | |
| 440 | 586 | break; |
| 441 | - case 'dashboard': | |
| 442 | - $wpda_settings_class_name = 'WPDA_Settings_Dashboard'; | |
| 443 | - $help_url = 'https://wpdataaccess.com/docs/plugin-settings/dashboard/'; | |
| 444 | - break; | |
| 445 | - case 'datatables': | |
| 446 | - $wpda_settings_class_name = 'WPDA_Settings_DataTables'; | |
| 447 | - $help_url = 'https://wpdataaccess.com/docs/plugin-settings/data-tables/'; | |
| 448 | - break; | |
| 449 | - case 'dataforms': | |
| 450 | - $wpda_settings_class_name = 'WPDA_Settings_DataForms'; | |
| 451 | - $help_url = 'https://wpdataaccess.com/docs/plugin-settings/data-forms/'; | |
| 452 | - break; | |
| 453 | - case 'databackup': | |
| 454 | - $wpda_settings_class_name = 'WPDA_Settings_DataBackup'; | |
| 455 | - $help_url = 'https://wpdataaccess.com/docs/plugin-settings/data-backup/'; | |
| 456 | - break; | |
| 457 | 587 | case 'uninstall': |
| 458 | 588 | $wpda_settings_class_name = 'WPDA_Settings_Uninstall'; |
| 459 | - $help_url = 'https://wpdataaccess.com/docs/plugin-settings/uninstall/'; | |
| 460 | 589 | break; |
| 461 | 590 | case 'repository': |
| 462 | 591 | $wpda_settings_class_name = 'WPDA_Settings_ManageRepository'; |
| 463 | - $help_url = 'https://wpdataaccess.com/docs/plugin-settings/manage-repository/'; | |
| 464 | 592 | break; |
| 465 | - case 'roles': | |
| 466 | - $wpda_settings_class_name = 'WPDA_Settings_ManageRoles'; | |
| 467 | - $help_url = 'https://wpdataaccess.com/docs/plugin-settings/manage-roles/'; | |
| 468 | - break; | |
| 469 | 593 | case 'system': |
| 470 | 594 | $wpda_settings_class_name = 'WPDA_Settings_SystemInfo'; |
| 471 | - $help_url = 'https://wpdataaccess.com/docs/plugin-settings/system-info/'; | |
| 472 | 595 | break; |
| 596 | + case 'mail': | |
| 597 | + $wpda_settings_class_name = 'WPDA_Settings_Mail'; | |
| 598 | + break; | |
| 599 | + case 'drives': | |
| 600 | + $wpda_settings_class_name = 'WPDA_Settings_Drives'; | |
| 601 | + break; | |
| 602 | + case 'legacy': | |
| 603 | + $wpda_settings_class_name = 'WPDA_Settings_Legacy'; | |
| 604 | + break; | |
| 473 | 605 | default: |
| 474 | 606 | $wpda_settings_class_name = 'WPDA_Settings_Plugin'; |
| 475 | - $help_url = 'https://wpdataaccess.com/docs/plugin-settings/plugin/'; | |
| 476 | 607 | } |
| 477 | 608 | $wpda_settings_class_name = '\\WPDataAccess\\Settings\\' . $wpda_settings_class_name; |
| 478 | - $wpda_settings = new $wpda_settings_class_name($current_tab, $help_url); | |
| 609 | + $wpda_settings = new $wpda_settings_class_name($current_tab); | |
| 479 | 610 | $wpda_settings->show(); |
| 480 | 611 | } |
| 481 | 612 | |
| 482 | 613 | } |
| 614 | + | |
| 615 | +// phpcs:enable WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing | |