| @@ -5,13 +5,15 @@ | ||
| 5 | 5 | * |
| 6 | 6 | * @package plugin\admin |
| 7 | 7 | */ |
| 8 | 8 | use WPDataAccess\API\WPDA_API; |
| 9 | +use WPDataAccess\API\WPDA_API_Core; | |
| 9 | 10 | use WPDataAccess\Backup\WPDA_Data_Export; |
| 10 | 11 | use WPDataAccess\CSV_Files\WPDA_CSV_Import; |
| 11 | 12 | use WPDataAccess\Dashboard\WPDA_Dashboard; |
| 12 | 13 | use WPDataAccess\Data_Apps\WPDA_App_Builder; |
| 13 | 14 | use WPDataAccess\Data_Apps\WPDA_Data_Explorer; |
| 15 | +use WPDataAccess\Data_Apps\WPDA_Table_Container; | |
| 14 | 16 | use WPDataAccess\Global_Search\WPDA_Global_Search; |
| 15 | 17 | use WPDataAccess\List_Table\WPDA_List_View; |
| 16 | 18 | use WPDataAccess\Plugin_Table_Models\WPDA_App_Model; |
| 17 | 19 | use WPDataAccess\Plugin_Table_Models\WPDA_Design_Table_Model; |
| @@ -31,8 +33,9 @@ | ||
| 31 | 33 | * |
| 32 | 34 | * @author Peter Schulz |
| 33 | 35 | * @since 1.0.0 |
| 34 | 36 | */ |
| 37 | +// phpcs:disable WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing -- verified on page | |
| 35 | 38 | class WP_Data_Access_Admin { |
| 36 | 39 | /** |
| 37 | 40 | * Menu slug for main page |
| 38 | 41 | */ |
| @@ -87,8 +90,10 @@ | ||
| 87 | 90 | * Plugin main page slug |
| 88 | 91 | */ |
| 89 | 92 | const MAIN_PAGE_SLUG = self::PAGE_NAVI; |
| 90 | 93 | |
| 94 | + const PAGE_TABLE = 'wpda_table'; | |
| 95 | + | |
| 91 | 96 | /** |
| 92 | 97 | * Menu slug for my tables page |
| 93 | 98 | */ |
| 94 | 99 | const PAGE_MY_TABLES = 'wpda_my_tables'; |
| @@ -99,8 +104,10 @@ | ||
| 99 | 104 | * @var string|false |
| 100 | 105 | */ |
| 101 | 106 | protected $wpda_data_explorer_menu; |
| 102 | 107 | |
| 108 | + protected $wpda_table; | |
| 109 | + | |
| 103 | 110 | /** |
| 104 | 111 | * Page hook suffix to Data Designer page or false |
| 105 | 112 | * |
| 106 | 113 | * @var string|false |
| @@ -197,11 +204,9 @@ | ||
| 197 | 204 | * @since 1.0.0 |
| 198 | 205 | */ |
| 199 | 206 | public function __construct() { |
| 200 | 207 | if ( isset( $_REQUEST['page'] ) ) { |
| 201 | - // phpcs:ignore WordPress.Security.NonceVerification | |
| 202 | 208 | $this->page = sanitize_text_field( wp_unslash( $_REQUEST['page'] ) ); |
| 203 | - // phpcs:ignore WordPress.Security.NonceVerification | |
| 204 | 209 | } |
| 205 | 210 | } |
| 206 | 211 | |
| 207 | 212 | private function load_app_css() { |
| @@ -300,9 +305,9 @@ | ||
| 300 | 305 | plugins_url( '../assets/css/responsive.dataTables.min.css', __FILE__ ), |
| 301 | 306 | array(), |
| 302 | 307 | WPDA::get_option( WPDA::OPTION_WPDA_VERSION ) |
| 303 | 308 | ); |
| 304 | - if ( self::PAGE_MAIN === $this->page || self::PAGE_APPS === $this->page || self::PAGE_DASHBOARD === $this->page || self::PAGE_QUERY_BUILDER === $this->page || self::PAGE_PUBLISHER === $this->page || self::PAGE_CHARTS === $this->page ) { | |
| 309 | + if ( self::PAGE_MAIN === $this->page || self::PAGE_APPS === $this->page || self::PAGE_DASHBOARD === $this->page || self::PAGE_PUBLISHER === $this->page || self::PAGE_CHARTS === $this->page ) { | |
| 305 | 310 | // Load UI smoothness theme. |
| 306 | 311 | wp_enqueue_style( |
| 307 | 312 | 'wpda_ui_smoothness', |
| 308 | 313 | plugins_url( '../assets/css/jquery-ui.smoothness.min.css', __FILE__ ), |
| @@ -322,10 +327,10 @@ | ||
| 322 | 327 | if ( false !== $hide_button_icons && 'on' !== $hide_button_icons ) { |
| 323 | 328 | // SAVING SPACE - According to the plugin guidelines it is allowed to include external fonts: |
| 324 | 329 | // https://developer.wordpress.org/plugins/wordpress-org/detailed-plugin-guidelines/#8-plugins-may-not-send-executable-code-via-third-party-systems . |
| 325 | 330 | // Load fontawesome icons. |
| 331 | + // phpcs:disable WordPress.WP.EnqueuedResourceParameters.MissingVersion | |
| 326 | 332 | wp_enqueue_style( |
| 327 | - // phpcs:ignore WordPress.WP.EnqueuedResourceParameters | |
| 328 | 333 | 'wpda_fontawesome_icons', |
| 329 | 334 | WPDA::CDN_FONTAWESOME . 'all.min.css', |
| 330 | 335 | array(), |
| 331 | 336 | null, |
| @@ -330,8 +335,9 @@ | ||
| 330 | 335 | array(), |
| 331 | 336 | null, |
| 332 | 337 | false |
| 333 | 338 | ); |
| 339 | + // phpcs:enable WordPress.WP.EnqueuedResourceParameters.MissingVersion | |
| 334 | 340 | } |
| 335 | 341 | if ( self::PAGE_PUBLISHER === $this->page ) { |
| 336 | 342 | wp_register_style( |
| 337 | 343 | 'wpda_datatables_default', |
| @@ -347,23 +353,8 @@ | ||
| 347 | 353 | WPDA::get_option( WPDA::OPTION_WPDA_VERSION ), |
| 348 | 354 | false |
| 349 | 355 | ); |
| 350 | 356 | } |
| 351 | - if ( self::PAGE_QUERY_BUILDER === $this->page ) { | |
| 352 | - // Add Query Builder resources. | |
| 353 | - wp_enqueue_style( | |
| 354 | - 'wpda_query_builder', | |
| 355 | - plugins_url( '../assets/css/wpda_query_builder.css', __FILE__ ), | |
| 356 | - array(), | |
| 357 | - WPDA::get_option( WPDA::OPTION_WPDA_VERSION ) | |
| 358 | - ); | |
| 359 | - wp_enqueue_style( | |
| 360 | - 'wpda_jquery_json_viewer', | |
| 361 | - plugins_url( '../assets/css/jquery.json-viewer.css', __FILE__ ), | |
| 362 | - array(), | |
| 363 | - WPDA::get_option( WPDA::OPTION_WPDA_VERSION ) | |
| 364 | - ); | |
| 365 | - } | |
| 366 | 357 | if ( !WPDA::current_user_is_admin() ) { |
| 367 | 358 | wp_enqueue_style( |
| 368 | 359 | 'wpda_non_admin', |
| 369 | 360 | plugins_url( '../assets/css/wpda_non_admin.css', __FILE__ ), |
| @@ -524,46 +515,8 @@ | ||
| 524 | 515 | } |
| 525 | 516 | if ( self::PAGE_CHARTS === $this->page ) { |
| 526 | 517 | $this->load_google_charts(); |
| 527 | 518 | } |
| 528 | - if ( self::PAGE_QUERY_BUILDER === $this->page ) { | |
| 529 | - // Add Query Builder resources. | |
| 530 | - wp_enqueue_script( | |
| 531 | - 'wpda_query_builder', | |
| 532 | - plugins_url( '../assets/js/wpda_query_builder.js', __FILE__ ), | |
| 533 | - array(), | |
| 534 | - WPDA::get_option( WPDA::OPTION_WPDA_VERSION ), | |
| 535 | - false | |
| 536 | - ); | |
| 537 | - wp_enqueue_script( | |
| 538 | - 'wpda_jquery_xml2json', | |
| 539 | - plugins_url( '../assets/js/jquery.xml2json.js', __FILE__ ), | |
| 540 | - array(), | |
| 541 | - WPDA::get_option( WPDA::OPTION_WPDA_VERSION ), | |
| 542 | - false | |
| 543 | - ); | |
| 544 | - wp_enqueue_script( | |
| 545 | - 'wpda_jquery_json_viewer', | |
| 546 | - plugins_url( '../assets/js/jquery.json-viewer.js', __FILE__ ), | |
| 547 | - array(), | |
| 548 | - WPDA::get_option( WPDA::OPTION_WPDA_VERSION ), | |
| 549 | - false | |
| 550 | - ); | |
| 551 | - // Add codeEditor to query builder. | |
| 552 | - $cm_settings['codeEditor'] = wp_enqueue_code_editor( array( | |
| 553 | - 'type' => 'text/x-sql', | |
| 554 | - 'codemirror' => array( | |
| 555 | - 'mode' => 'sql', | |
| 556 | - 'lineNumbers' => true, | |
| 557 | - 'autoRefresh' => true, | |
| 558 | - 'lineWrapping' => true, | |
| 559 | - 'styleActiveLine' => true, | |
| 560 | - ), | |
| 561 | - ) ); | |
| 562 | - wp_enqueue_script( 'wp-theme-plugin-editor' ); | |
| 563 | - wp_localize_script( 'wp-theme-plugin-editor', 'cm_settings', $cm_settings ); | |
| 564 | - wp_enqueue_style( 'wp-codemirror' ); | |
| 565 | - } | |
| 566 | 519 | if ( self::PAGE_DASHBOARD === $this->page ) { |
| 567 | 520 | $this->load_google_charts(); |
| 568 | 521 | // Load DBMS panels. |
| 569 | 522 | wp_enqueue_script( |
| @@ -586,8 +539,9 @@ | ||
| 586 | 539 | * @return void |
| 587 | 540 | */ |
| 588 | 541 | private function load_google_charts() { |
| 589 | 542 | // Load Google Charts. |
| 543 | + // phpcs:disable WordPress.WP.EnqueuedResourceParameters | |
| 590 | 544 | wp_enqueue_script( |
| 591 | 545 | 'wpda_google_charts', |
| 592 | 546 | WPDA::GOOGLE_CHARTS, |
| 593 | 547 | array(), |
| @@ -593,8 +547,9 @@ | ||
| 593 | 547 | array(), |
| 594 | 548 | null, |
| 595 | 549 | false |
| 596 | 550 | ); |
| 551 | + // phpcs:enable WordPress.WP.EnqueuedResourceParameters | |
| 597 | 552 | wp_enqueue_script( |
| 598 | 553 | 'wpda_google_charts_fnc', |
| 599 | 554 | plugins_url( '../assets/js/wpda_google_charts.js', __FILE__ ), |
| 600 | 555 | array(), |
| @@ -639,24 +594,8 @@ | ||
| 639 | 594 | $this->add_data_projects(); |
| 640 | 595 | // Hide admin menu. |
| 641 | 596 | return; |
| 642 | 597 | } |
| 643 | - if ( self::PAGE_MAIN === $this->page && isset( $_REQUEST['de'] ) ) { | |
| 644 | - if ( 'new' === $_REQUEST['de'] ) { | |
| 645 | - update_user_meta( WPDA::get_current_user_id(), 'wpda_data_explorer', 'new' ); | |
| 646 | - } elseif ( 'old' === $_REQUEST['de'] ) { | |
| 647 | - delete_user_meta( WPDA::get_current_user_id(), 'wpda_data_explorer' ); | |
| 648 | - } | |
| 649 | - } | |
| 650 | - if ( self::PAGE_QUERY_BUILDER === $this->page && isset( $_REQUEST['qb'] ) ) { | |
| 651 | - if ( 'new' === $_REQUEST['qb'] ) { | |
| 652 | - update_user_meta( WPDA::get_current_user_id(), 'wpda_query_builder_version', 'new' ); | |
| 653 | - } elseif ( 'old' === $_REQUEST['qb'] ) { | |
| 654 | - update_user_meta( WPDA::get_current_user_id(), 'wpda_query_builder_version', 'old' ); | |
| 655 | - } | |
| 656 | - } | |
| 657 | - // Specific list tables (and forms) can be made available for specific capabilities: | |
| 658 | - // managed in method add_menu_my_tables. | |
| 659 | 598 | // Main menu and items are only available to admin users (set capability to 'manage_options'). |
| 660 | 599 | add_menu_page( |
| 661 | 600 | 'WP Data Access', |
| 662 | 601 | 'WP Data Access', |
| @@ -684,12 +623,8 @@ | ||
| 684 | 623 | self::PAGE_APPS, |
| 685 | 624 | array($this, 'data_apps') |
| 686 | 625 | ); |
| 687 | 626 | // Add data explorer to WPDA menu. |
| 688 | - $current_data_explorer_version = get_user_meta( WPDA::get_current_user_id(), 'wpda_data_explorer', true ); | |
| 689 | - if ( isset( $_POST['explorer'] ) && 'OLD' === $_POST['explorer'] ) { | |
| 690 | - $current_data_explorer_version = true; | |
| 691 | - } | |
| 692 | 627 | $this->wpda_data_explorer_menu = add_submenu_page( |
| 693 | 628 | self::MAIN_PAGE_SLUG, |
| 694 | 629 | 'WP Data Access', |
| 695 | 630 | 'Data Explorer', |
| @@ -694,20 +629,20 @@ | ||
| 694 | 629 | 'WP Data Access', |
| 695 | 630 | 'Data Explorer', |
| 696 | 631 | 'manage_options', |
| 697 | 632 | self::PAGE_MAIN, |
| 698 | - array($this, ( 'new' !== $current_data_explorer_version ? 'data_explorer_page' : 'data_explorer_page_new' )) | |
| 633 | + array($this, 'data_explorer_page') | |
| 699 | 634 | ); |
| 700 | - if ( self::PAGE_MAIN === $this->page ) { | |
| 701 | - if ( 'new' !== $current_data_explorer_version ) { | |
| 702 | - $args = array( | |
| 703 | - 'page_hook_suffix' => $this->wpda_data_explorer_menu, | |
| 704 | - ); | |
| 705 | - $this->wpda_data_explorer_view = new WPDA_List_View($args); | |
| 706 | - } | |
| 707 | - } | |
| 635 | + // Add data explorer to WPDA menu. | |
| 636 | + $this->wpda_table = add_submenu_page( | |
| 637 | + self::PAGE_TABLE, | |
| 638 | + 'WP Data Access', | |
| 639 | + 'Data Explorer', | |
| 640 | + 'manage_options', | |
| 641 | + self::PAGE_TABLE, | |
| 642 | + array($this, 'data_explorer_table_page') | |
| 643 | + ); | |
| 708 | 644 | // Add submenu for Query Builder. |
| 709 | - $current_query_builder_version = get_user_meta( WPDA::get_current_user_id(), 'wpda_query_builder_version', true ); | |
| 710 | 645 | $this->wpda_data_publisher_menu = add_submenu_page( |
| 711 | 646 | self::MAIN_PAGE_SLUG, |
| 712 | 647 | 'WP Data Access', |
| 713 | 648 | 'SQL Query Builder', |
| @@ -712,9 +647,9 @@ | ||
| 712 | 647 | 'WP Data Access', |
| 713 | 648 | 'SQL Query Builder', |
| 714 | 649 | 'manage_options', |
| 715 | 650 | self::PAGE_QUERY_BUILDER, |
| 716 | - array($this, ( $current_query_builder_version === 'old' ? 'query_builder_old' : 'query_builder' )) | |
| 651 | + array($this, 'query_builder') | |
| 717 | 652 | ); |
| 718 | 653 | // Add submenu for Data Tables. |
| 719 | 654 | $this->wpda_data_publisher_menu = add_submenu_page( |
| 720 | 655 | self::MAIN_PAGE_SLUG, |
| @@ -908,50 +843,43 @@ | ||
| 908 | 843 | public function data_dashboard_page() { |
| 909 | 844 | WPDA_Dashboard::add_dashboard( true ); |
| 910 | 845 | } |
| 911 | 846 | |
| 912 | - /** | |
| 913 | - * Show data explorer main page | |
| 914 | - * | |
| 915 | - * Initialization of $this->wpda_data_explorer_view is done earlier in | |
| 916 | - * {@see WP_Data_Access_Admin::add_menu_items()} to support screen options. This method just shows the page | |
| 917 | - * containing the list table. | |
| 918 | - * | |
| 919 | - * @since 1.0.0 | |
| 920 | - * | |
| 921 | - * @see WP_Data_Access_Admin::add_menu_items() | |
| 922 | - */ | |
| 923 | 847 | public function data_explorer_page() { |
| 924 | 848 | WPDA_Dashboard::add_dashboard(); |
| 925 | 849 | if ( isset( $_REQUEST['page_action'] ) && 'wpda_backup' === $_REQUEST['page_action'] ) { |
| 926 | - // phpcs:ignore WordPress.Security.NonceVerification | |
| 927 | 850 | $this->backup_page(); |
| 928 | 851 | } elseif ( isset( $_REQUEST['page_action'] ) && 'wpda_import_csv' === $_REQUEST['page_action'] ) { |
| 929 | - // phpcs:ignore WordPress.Security.NonceVerification | |
| 930 | 852 | $this->import_csv(); |
| 931 | 853 | } elseif ( isset( $_REQUEST['page_action'] ) && 'wpda_global_search' === $_REQUEST['page_action'] ) { |
| 932 | - // phpcs:ignore WordPress.Security.NonceVerification | |
| 933 | 854 | $this->advanced_search(); |
| 934 | 855 | } else { |
| 935 | - $this->wpda_data_explorer_view->show(); | |
| 856 | + $explorer = new WPDA_Data_Explorer(); | |
| 857 | + $explorer->show(); | |
| 936 | 858 | } |
| 937 | 859 | } |
| 938 | 860 | |
| 939 | - public function data_explorer_page_new() { | |
| 861 | + public function data_explorer_table_page() { | |
| 940 | 862 | WPDA_Dashboard::add_dashboard(); |
| 941 | - if ( isset( $_REQUEST['page_action'] ) && 'wpda_backup' === $_REQUEST['page_action'] ) { | |
| 942 | - // phpcs:ignore WordPress.Security.NonceVerification | |
| 943 | - $this->backup_page(); | |
| 944 | - } elseif ( isset( $_REQUEST['page_action'] ) && 'wpda_import_csv' === $_REQUEST['page_action'] ) { | |
| 945 | - // phpcs:ignore WordPress.Security.NonceVerification | |
| 946 | - $this->import_csv(); | |
| 947 | - } elseif ( isset( $_REQUEST['page_action'] ) && 'wpda_global_search' === $_REQUEST['page_action'] ) { | |
| 948 | - // phpcs:ignore WordPress.Security.NonceVerification | |
| 949 | - $this->advanced_search(); | |
| 950 | - } else { | |
| 951 | - $explorer = new WPDA_Data_Explorer(); | |
| 952 | - $explorer->show(); | |
| 863 | + if ( !isset( | |
| 864 | + $_POST['dbs'], | |
| 865 | + $_POST['tbl'], | |
| 866 | + $_POST['s'], | |
| 867 | + $_POST['c'] | |
| 868 | + ) ) { | |
| 869 | + wp_die( esc_attr__( 'ERROR: Invalid usage', 'wp-data-access' ) ); | |
| 953 | 870 | } |
| 871 | + $dbs = WPDA_API_Core::sanitize_db_identifier( sanitize_text_field( wp_unslash( $_POST['dbs'] ) ) ); | |
| 872 | + $tbl = WPDA_API_Core::sanitize_db_identifier( sanitize_text_field( wp_unslash( $_POST['tbl'] ) ) ); | |
| 873 | + $s = WPDA_API_Core::sanitize_db_identifier( sanitize_text_field( wp_unslash( $_POST['s'] ) ) ); | |
| 874 | + $c = WPDA_API_Core::sanitize_db_identifier( sanitize_text_field( wp_unslash( $_POST['c'] ) ) ); | |
| 875 | + $explorer = new WPDA_Table_Container(array( | |
| 876 | + 'dbs' => $dbs, | |
| 877 | + 'tbl' => $tbl, | |
| 878 | + 's' => $s, | |
| 879 | + 'c' => $c, | |
| 880 | + )); | |
| 881 | + $explorer->show(); | |
| 954 | 882 | } |
| 955 | 883 | |
| 956 | 884 | public function data_navi() { |
| 957 | 885 | if ( isset( $_POST['wpda-legacy-tool-status'] ) ) { |
| @@ -1006,14 +934,8 @@ | ||
| 1006 | 934 | $query_builder = new \WPDataAccess\Data_Apps\WPDA_Query_Builder(); |
| 1007 | 935 | $query_builder->show(); |
| 1008 | 936 | } |
| 1009 | 937 | |
| 1010 | - public function query_builder_old() { | |
| 1011 | - WPDA_Dashboard::add_dashboard(); | |
| 1012 | - $query_builder = new \WPDataAccess\Query_Builder\WPDA_Query_Builder(); | |
| 1013 | - $query_builder->show(); | |
| 1014 | - } | |
| 1015 | - | |
| 1016 | 938 | /** |
| 1017 | 939 | * Add CSV page |
| 1018 | 940 | * |
| 1019 | 941 | * @return void |
| @@ -1054,9 +976,9 @@ | ||
| 1054 | 976 | ?> |
| 1055 | 977 | <div class="wrap"> |
| 1056 | 978 | <h1 class="wp-heading-inline"> |
| 1057 | 979 | <span>Data Designer</span> |
| 1058 | - <a href="https://wpdataaccess.com/docs/data-designer/data-designer-getting-started/" target="_blank" class="wpda_tooltip" title="Plugin Help - opens in a new tab or window"> | |
| 980 | + <a href="https://docs.legacy.wpdataaccess.com/docs/data-designer-getting-started/" target="_blank" class="wpda_tooltip" title="Plugin Help - opens in a new tab or window"> | |
| 1059 | 981 | <span class="dashicons dashicons-editor-help" style="text-decoration:none;vertical-align:top;font-size:30px;"> |
| 1060 | 982 | </span> |
| 1061 | 983 | </a> |
| 1062 | 984 | </h1> |
| @@ -1061,10 +983,9 @@ | ||
| 1061 | 983 | </a> |
| 1062 | 984 | </h1> |
| 1063 | 985 | <p> |
| 1064 | 986 | <?php |
| 1065 | - echo __( 'ERROR: Repository table not found!', 'wp-data-access' ); | |
| 1066 | - // phpcs:ignore WordPress.Security.EscapeOutput | |
| 987 | + esc_html_e( 'ERROR: Repository table not found!', 'wp-data-access' ); | |
| 1067 | 988 | ?> |
| 1068 | 989 | </p> |
| 1069 | 990 | </div> |
| 1070 | 991 | <?php |
| @@ -1110,9 +1031,9 @@ | ||
| 1110 | 1031 | ?> |
| 1111 | 1032 | <div class="wrap"> |
| 1112 | 1033 | <h1 class="wp-heading-inline"> |
| 1113 | 1034 | <span>Data Tables</span> |
| 1114 | - <a href="https://wpdataaccess.com/docs/data-tables/data-tables-getting-started/" target="_blank" class="wpda_tooltip" title="Plugin Help - opens in a new tab or window"> | |
| 1035 | + <a href="https://docs.legacy.wpdataaccess.com/docs/data-tables-getting-started/" target="_blank" class="wpda_tooltip" title="Plugin Help - opens in a new tab or window"> | |
| 1115 | 1036 | <span class="dashicons dashicons-editor-help" style="text-decoration:none;vertical-align:top;font-size:30px;"> |
| 1116 | 1037 | </span> |
| 1117 | 1038 | </a> |
| 1118 | 1039 | </h1> |
| @@ -1117,10 +1038,9 @@ | ||
| 1117 | 1038 | </a> |
| 1118 | 1039 | </h1> |
| 1119 | 1040 | <p> |
| 1120 | 1041 | <?php |
| 1121 | - echo __( 'ERROR: Repository table not found!', 'wp-data-access' ); | |
| 1122 | - // phpcs:ignore WordPress.Security.EscapeOutput | |
| 1042 | + esc_html_e( 'ERROR: Repository table not found!', 'wp-data-access' ); | |
| 1123 | 1043 | ?> |
| 1124 | 1044 | </p> |
| 1125 | 1045 | </div> |
| 1126 | 1046 | <?php |
| @@ -1138,13 +1058,10 @@ | ||
| 1138 | 1058 | */ |
| 1139 | 1059 | public function backup_page() { |
| 1140 | 1060 | $wpda_backup = new WPDA_Data_Export(); |
| 1141 | 1061 | $wp_nonce = ( isset( $_REQUEST['wp_nonce'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['wp_nonce'] ) ) : '?' ); |
| 1142 | - // phpcs:ignore WordPress.Security.NonceVerification | |
| 1143 | 1062 | if ( isset( $_REQUEST['action'] ) && wp_verify_nonce( $wp_nonce, 'wpda-backup-' . WPDA::get_current_user_login() ) ) { |
| 1144 | - // phpcs:ignore WordPress.Security.NonceVerification | |
| 1145 | 1063 | $action = sanitize_text_field( wp_unslash( $_REQUEST['action'] ) ); |
| 1146 | - // phpcs:ignore WordPress.Security.NonceVerification | |
| 1147 | 1064 | if ( 'new' === $action ) { |
| 1148 | 1065 | $wpda_backup->create_export( 'add' ); |
| 1149 | 1066 | } elseif ( 'add' === $action ) { |
| 1150 | 1067 | $wpda_backup->wpda_add_cron_job(); |
| @@ -1160,96 +1077,8 @@ | ||
| 1160 | 1077 | } |
| 1161 | 1078 | } |
| 1162 | 1079 | |
| 1163 | 1080 | /** |
| 1164 | - * Add user defined sub menu | |
| 1165 | - * | |
| 1166 | - * WPDA allows users to create sub menu for table lists and simple forms. Sub menus can be added to the WPDA | |
| 1167 | - * menu or any other (external) menu. A sub menu is added to an external menu via the menu slug. Sub menus are | |
| 1168 | - * taken from {@see WPDA_User_Menus_Model}. | |
| 1169 | - * | |
| 1170 | - * This method is called from the admin_menu action with a lower priority to make sure other menus are available. | |
| 1171 | - * User defined menu items are added to available menus in this method. These can be WPDA menus or external menus | |
| 1172 | - * as mentioned in the according list table and edit form. WPDA menus are added to menu WP Data Tables. External | |
| 1173 | - * menus are added to the menu having the menu slug defined by the user. | |
| 1174 | - * | |
| 1175 | - * This method does not actually show the list tables! It just creates the menu items. When the user clicks on such | |
| 1176 | - * a dynamically defined menu item, method {@see WP_Data_Access_Admin::my_tables_page()} is called, which takes | |
| 1177 | - * care of showing the list table. | |
| 1178 | - * | |
| 1179 | - * @since 1.0.0 | |
| 1180 | - * | |
| 1181 | - * @see WP_Data_Access_Admin::my_tables_page() | |
| 1182 | - * @see WPDA_User_Menus_Model | |
| 1183 | - */ | |
| 1184 | - public function add_menu_my_tables() { | |
| 1185 | - $menus_shown_to_current_user = array(); | |
| 1186 | - // Add list tables to external menus. | |
| 1187 | - foreach ( WPDA_User_Menus_Model::list_external_menus() as $menu ) { | |
| 1188 | - $user_roles = WPDA::get_current_user_roles(); | |
| 1189 | - $user_has_role = false; | |
| 1190 | - if ( '' === $menu->menu_role || null === $menu->menu_role ) { | |
| 1191 | - $user_has_role = in_array( 'administrator', $user_roles, true ); | |
| 1192 | - } else { | |
| 1193 | - $user_role_array = explode( ',', (string) $menu->menu_role ); | |
| 1194 | - //phpcs:ignore - 8.1 proof | |
| 1195 | - foreach ( $user_role_array as $user_role_array_item ) { | |
| 1196 | - $user_has_role = in_array( $user_role_array_item, $user_roles, true ); | |
| 1197 | - //phpcs:ignore - 8.1 proof | |
| 1198 | - if ( $user_has_role ) { | |
| 1199 | - break; | |
| 1200 | - } | |
| 1201 | - } | |
| 1202 | - } | |
| 1203 | - if ( $user_has_role ) { | |
| 1204 | - if ( !isset( $menus_shown_to_current_user[$menu->menu_slug . '/' . $menu->menu_name . '/' . $menu->menu_table_name . '/' . $menu->menu_schema_name] ) ) { | |
| 1205 | - $menu_slug = self::PAGE_EXPLORER . '_' . $menu->menu_table_name; | |
| 1206 | - $menu_index = $menu->menu_table_name; | |
| 1207 | - $this->create_non_admin_menu( $menu_slug ); | |
| 1208 | - $this->wpda_my_table_list_menu[$menu_index] = add_submenu_page( | |
| 1209 | - $this->first_page, | |
| 1210 | - 'WP Data Access : ' . strtoupper( $menu->menu_table_name ), | |
| 1211 | - $menu->menu_name, | |
| 1212 | - WPDA::get_current_user_capability(), | |
| 1213 | - $menu_slug, | |
| 1214 | - array($this, 'my_tables_page') | |
| 1215 | - ); | |
| 1216 | - $this->wpda_my_table_list_view[$menu_index] = new WPDA_List_View(array( | |
| 1217 | - 'page_hook_suffix' => $this->wpda_my_table_list_menu[$menu_index], | |
| 1218 | - 'wpdaschema_name' => $menu->menu_schema_name, | |
| 1219 | - 'table_name' => $menu->menu_table_name, | |
| 1220 | - )); | |
| 1221 | - $menus_shown_to_current_user[$menu->menu_slug . '/' . $menu->menu_name . '/' . $menu_index . '/' . $menu->menu_schema_name] = true; | |
| 1222 | - } | |
| 1223 | - } | |
| 1224 | - } | |
| 1225 | - } | |
| 1226 | - | |
| 1227 | - /** | |
| 1228 | - * Show user defined menus | |
| 1229 | - * | |
| 1230 | - * A user defined menu that are added to the plugin menu in {@see WP_Data_Access_Admin::add_menu_my_tables()} is | |
| 1231 | - * shown here. This method is called when the user clicks on the menu item generated in | |
| 1232 | - * {@see WP_Data_Access_Admin::add_menu_my_tables()}. | |
| 1233 | - * | |
| 1234 | - * @since 1.0.0 | |
| 1235 | - * | |
| 1236 | - * @see WP_Data_Access_Admin::add_menu_my_tables() | |
| 1237 | - */ | |
| 1238 | - public function my_tables_page() { | |
| 1239 | - // Grab table name from menu slug. | |
| 1240 | - if ( null !== $this->page ) { | |
| 1241 | - if ( strpos( $this->page, self::PAGE_EXPLORER ) !== false ) { | |
| 1242 | - $table = substr( $this->page, strlen( self::PAGE_EXPLORER . '_' ) ); | |
| 1243 | - } else { | |
| 1244 | - $table = substr( $this->page, strlen( self::PAGE_MY_TABLES . '_' ) ); | |
| 1245 | - } | |
| 1246 | - // Show list table. | |
| 1247 | - $this->wpda_my_table_list_view[$table]->show(); | |
| 1248 | - } | |
| 1249 | - } | |
| 1250 | - | |
| 1251 | - /** | |
| 1252 | 1081 | * Add main menu for non admin user |
| 1253 | 1082 | * |
| 1254 | 1083 | * @param string $first_page First plugin page. |
| 1255 | 1084 | * @return void |
| @@ -1271,4 +1100,6 @@ | ||
| 1271 | 1100 | } |
| 1272 | 1101 | } |
| 1273 | 1102 | |
| 1274 | 1103 | } |
| 1104 | + | |
| 1105 | +// phpcs:enable WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing | |