| @@ -5,14 +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 | -use WPDataAccess\Data_Apps\WPDA_Apps; | |
| 13 | -use WPDataAccess\Data_Apps\WPDA_Explorer_Container; | |
| 14 | -use WPDataAccess\Data_Apps\WPDA_Apps_List; | |
| 13 | +use WPDataAccess\Data_Apps\WPDA_App_Builder; | |
| 14 | +use WPDataAccess\Data_Apps\WPDA_Data_Explorer; | |
| 15 | +use WPDataAccess\Data_Apps\WPDA_Table_Container; | |
| 15 | 16 | use WPDataAccess\Global_Search\WPDA_Global_Search; |
| 16 | 17 | use WPDataAccess\List_Table\WPDA_List_View; |
| 17 | 18 | use WPDataAccess\Plugin_Table_Models\WPDA_App_Model; |
| 18 | 19 | use WPDataAccess\Plugin_Table_Models\WPDA_Design_Table_Model; |
| @@ -18,14 +19,14 @@ | ||
| 18 | 19 | use WPDataAccess\Plugin_Table_Models\WPDA_Design_Table_Model; |
| 19 | 20 | use WPDataAccess\Plugin_Table_Models\WPDA_Publisher_Model; |
| 20 | 21 | use WPDataAccess\Plugin_Table_Models\WPDA_User_Menus_Model; |
| 21 | 22 | use WPDataAccess\Premium\WPDAPRO_Data_Publisher\WPDAPRO_Data_Publisher_Manage_Styles; |
| 22 | -use WPDataAccess\Query_Builder\WPDA_Query_Builder; | |
| 23 | 23 | use WPDataAccess\Settings\WPDA_Settings; |
| 24 | +use WPDataAccess\Utilities\WPDA_Add_App_To_Menu; | |
| 24 | 25 | use WPDataAccess\Utilities\WPDA_Repository; |
| 25 | 26 | use WPDataAccess\WPDA; |
| 27 | +use WPDataAccess\WPDA_Navi\WPDA_Navi; | |
| 26 | 28 | use WPDataProjects\WPDP; |
| 27 | -use WPDataAccess\WPDA_Navi\WPDA_Navi; | |
| 28 | 29 | /** |
| 29 | 30 | * Class WP_Data_Access_Admin |
| 30 | 31 | * |
| 31 | 32 | * Defines admin specific functionality for plugin WP Data Access. |
| @@ -32,8 +33,9 @@ | ||
| 32 | 33 | * |
| 33 | 34 | * @author Peter Schulz |
| 34 | 35 | * @since 1.0.0 |
| 35 | 36 | */ |
| 37 | +// phpcs:disable WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing -- verified on page | |
| 36 | 38 | class WP_Data_Access_Admin { |
| 37 | 39 | /** |
| 38 | 40 | * Menu slug for main page |
| 39 | 41 | */ |
| @@ -88,8 +90,10 @@ | ||
| 88 | 90 | * Plugin main page slug |
| 89 | 91 | */ |
| 90 | 92 | const MAIN_PAGE_SLUG = self::PAGE_NAVI; |
| 91 | 93 | |
| 94 | + const PAGE_TABLE = 'wpda_table'; | |
| 95 | + | |
| 92 | 96 | /** |
| 93 | 97 | * Menu slug for my tables page |
| 94 | 98 | */ |
| 95 | 99 | const PAGE_MY_TABLES = 'wpda_my_tables'; |
| @@ -100,8 +104,10 @@ | ||
| 100 | 104 | * @var string|false |
| 101 | 105 | */ |
| 102 | 106 | protected $wpda_data_explorer_menu; |
| 103 | 107 | |
| 108 | + protected $wpda_table; | |
| 109 | + | |
| 104 | 110 | /** |
| 105 | 111 | * Page hook suffix to Data Designer page or false |
| 106 | 112 | * |
| 107 | 113 | * @var string|false |
| @@ -198,11 +204,9 @@ | ||
| 198 | 204 | * @since 1.0.0 |
| 199 | 205 | */ |
| 200 | 206 | public function __construct() { |
| 201 | 207 | if ( isset( $_REQUEST['page'] ) ) { |
| 202 | - // phpcs:ignore WordPress.Security.NonceVerification | |
| 203 | 208 | $this->page = sanitize_text_field( wp_unslash( $_REQUEST['page'] ) ); |
| 204 | - // phpcs:ignore WordPress.Security.NonceVerification | |
| 205 | 209 | } |
| 206 | 210 | } |
| 207 | 211 | |
| 208 | 212 | private function load_app_css() { |
| @@ -301,9 +305,9 @@ | ||
| 301 | 305 | plugins_url( '../assets/css/responsive.dataTables.min.css', __FILE__ ), |
| 302 | 306 | array(), |
| 303 | 307 | WPDA::get_option( WPDA::OPTION_WPDA_VERSION ) |
| 304 | 308 | ); |
| 305 | - 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 ) { | |
| 306 | 310 | // Load UI smoothness theme. |
| 307 | 311 | wp_enqueue_style( |
| 308 | 312 | 'wpda_ui_smoothness', |
| 309 | 313 | plugins_url( '../assets/css/jquery-ui.smoothness.min.css', __FILE__ ), |
| @@ -323,10 +327,10 @@ | ||
| 323 | 327 | if ( false !== $hide_button_icons && 'on' !== $hide_button_icons ) { |
| 324 | 328 | // SAVING SPACE - According to the plugin guidelines it is allowed to include external fonts: |
| 325 | 329 | // https://developer.wordpress.org/plugins/wordpress-org/detailed-plugin-guidelines/#8-plugins-may-not-send-executable-code-via-third-party-systems . |
| 326 | 330 | // Load fontawesome icons. |
| 331 | + // phpcs:disable WordPress.WP.EnqueuedResourceParameters.MissingVersion | |
| 327 | 332 | wp_enqueue_style( |
| 328 | - // phpcs:ignore WordPress.WP.EnqueuedResourceParameters | |
| 329 | 333 | 'wpda_fontawesome_icons', |
| 330 | 334 | WPDA::CDN_FONTAWESOME . 'all.min.css', |
| 331 | 335 | array(), |
| 332 | 336 | null, |
| @@ -331,8 +335,9 @@ | ||
| 331 | 335 | array(), |
| 332 | 336 | null, |
| 333 | 337 | false |
| 334 | 338 | ); |
| 339 | + // phpcs:enable WordPress.WP.EnqueuedResourceParameters.MissingVersion | |
| 335 | 340 | } |
| 336 | 341 | if ( self::PAGE_PUBLISHER === $this->page ) { |
| 337 | 342 | wp_register_style( |
| 338 | 343 | 'wpda_datatables_default', |
| @@ -348,23 +353,8 @@ | ||
| 348 | 353 | WPDA::get_option( WPDA::OPTION_WPDA_VERSION ), |
| 349 | 354 | false |
| 350 | 355 | ); |
| 351 | 356 | } |
| 352 | - if ( self::PAGE_QUERY_BUILDER === $this->page ) { | |
| 353 | - // Add Query Builder resources. | |
| 354 | - wp_enqueue_style( | |
| 355 | - 'wpda_query_builder', | |
| 356 | - plugins_url( '../assets/css/wpda_query_builder.css', __FILE__ ), | |
| 357 | - array(), | |
| 358 | - WPDA::get_option( WPDA::OPTION_WPDA_VERSION ) | |
| 359 | - ); | |
| 360 | - wp_enqueue_style( | |
| 361 | - 'wpda_jquery_json_viewer', | |
| 362 | - plugins_url( '../assets/css/jquery.json-viewer.css', __FILE__ ), | |
| 363 | - array(), | |
| 364 | - WPDA::get_option( WPDA::OPTION_WPDA_VERSION ) | |
| 365 | - ); | |
| 366 | - } | |
| 367 | 357 | if ( !WPDA::current_user_is_admin() ) { |
| 368 | 358 | wp_enqueue_style( |
| 369 | 359 | 'wpda_non_admin', |
| 370 | 360 | plugins_url( '../assets/css/wpda_non_admin.css', __FILE__ ), |
| @@ -525,46 +515,8 @@ | ||
| 525 | 515 | } |
| 526 | 516 | if ( self::PAGE_CHARTS === $this->page ) { |
| 527 | 517 | $this->load_google_charts(); |
| 528 | 518 | } |
| 529 | - if ( self::PAGE_QUERY_BUILDER === $this->page ) { | |
| 530 | - // Add Query Builder resources. | |
| 531 | - wp_enqueue_script( | |
| 532 | - 'wpda_query_builder', | |
| 533 | - plugins_url( '../assets/js/wpda_query_builder.js', __FILE__ ), | |
| 534 | - array(), | |
| 535 | - WPDA::get_option( WPDA::OPTION_WPDA_VERSION ), | |
| 536 | - false | |
| 537 | - ); | |
| 538 | - wp_enqueue_script( | |
| 539 | - 'wpda_jquery_xml2json', | |
| 540 | - plugins_url( '../assets/js/jquery.xml2json.js', __FILE__ ), | |
| 541 | - array(), | |
| 542 | - WPDA::get_option( WPDA::OPTION_WPDA_VERSION ), | |
| 543 | - false | |
| 544 | - ); | |
| 545 | - wp_enqueue_script( | |
| 546 | - 'wpda_jquery_json_viewer', | |
| 547 | - plugins_url( '../assets/js/jquery.json-viewer.js', __FILE__ ), | |
| 548 | - array(), | |
| 549 | - WPDA::get_option( WPDA::OPTION_WPDA_VERSION ), | |
| 550 | - false | |
| 551 | - ); | |
| 552 | - // Add codeEditor to query builder. | |
| 553 | - $cm_settings['codeEditor'] = wp_enqueue_code_editor( array( | |
| 554 | - 'type' => 'text/x-sql', | |
| 555 | - 'codemirror' => array( | |
| 556 | - 'mode' => 'sql', | |
| 557 | - 'lineNumbers' => true, | |
| 558 | - 'autoRefresh' => true, | |
| 559 | - 'lineWrapping' => true, | |
| 560 | - 'styleActiveLine' => true, | |
| 561 | - ), | |
| 562 | - ) ); | |
| 563 | - wp_enqueue_script( 'wp-theme-plugin-editor' ); | |
| 564 | - wp_localize_script( 'wp-theme-plugin-editor', 'cm_settings', $cm_settings ); | |
| 565 | - wp_enqueue_style( 'wp-codemirror' ); | |
| 566 | - } | |
| 567 | 519 | if ( self::PAGE_DASHBOARD === $this->page ) { |
| 568 | 520 | $this->load_google_charts(); |
| 569 | 521 | // Load DBMS panels. |
| 570 | 522 | wp_enqueue_script( |
| @@ -587,8 +539,9 @@ | ||
| 587 | 539 | * @return void |
| 588 | 540 | */ |
| 589 | 541 | private function load_google_charts() { |
| 590 | 542 | // Load Google Charts. |
| 543 | + // phpcs:disable WordPress.WP.EnqueuedResourceParameters | |
| 591 | 544 | wp_enqueue_script( |
| 592 | 545 | 'wpda_google_charts', |
| 593 | 546 | WPDA::GOOGLE_CHARTS, |
| 594 | 547 | array(), |
| @@ -594,8 +547,9 @@ | ||
| 594 | 547 | array(), |
| 595 | 548 | null, |
| 596 | 549 | false |
| 597 | 550 | ); |
| 551 | + // phpcs:enable WordPress.WP.EnqueuedResourceParameters | |
| 598 | 552 | wp_enqueue_script( |
| 599 | 553 | 'wpda_google_charts_fnc', |
| 600 | 554 | plugins_url( '../assets/js/wpda_google_charts.js', __FILE__ ), |
| 601 | 555 | array(), |
| @@ -640,18 +594,8 @@ | ||
| 640 | 594 | $this->add_data_projects(); |
| 641 | 595 | // Hide admin menu. |
| 642 | 596 | return; |
| 643 | 597 | } |
| 644 | - if ( self::PAGE_MAIN === $this->page && isset( $_REQUEST['de'] ) ) { | |
| 645 | - if ( 'new' === $_REQUEST['de'] ) { | |
| 646 | - update_user_meta( WPDA::get_current_user_id(), 'wpda_data_explorer', 'new' ); | |
| 647 | - } | |
| 648 | - if ( 'old' === $_REQUEST['de'] ) { | |
| 649 | - delete_user_meta( WPDA::get_current_user_id(), 'wpda_data_explorer' ); | |
| 650 | - } | |
| 651 | - } | |
| 652 | - // Specific list tables (and forms) can be made available for specific capabilities: | |
| 653 | - // managed in method add_menu_my_tables. | |
| 654 | 598 | // Main menu and items are only available to admin users (set capability to 'manage_options'). |
| 655 | 599 | add_menu_page( |
| 656 | 600 | 'WP Data Access', |
| 657 | 601 | 'WP Data Access', |
| @@ -679,12 +623,8 @@ | ||
| 679 | 623 | self::PAGE_APPS, |
| 680 | 624 | array($this, 'data_apps') |
| 681 | 625 | ); |
| 682 | 626 | // Add data explorer to WPDA menu. |
| 683 | - $current_data_explorer_version = get_user_meta( WPDA::get_current_user_id(), 'wpda_data_explorer', true ); | |
| 684 | - if ( isset( $_POST['explorer'] ) && 'OLD' === $_POST['explorer'] ) { | |
| 685 | - $current_data_explorer_version = true; | |
| 686 | - } | |
| 687 | 627 | $this->wpda_data_explorer_menu = add_submenu_page( |
| 688 | 628 | self::MAIN_PAGE_SLUG, |
| 689 | 629 | 'WP Data Access', |
| 690 | 630 | 'Data Explorer', |
| @@ -689,18 +629,19 @@ | ||
| 689 | 629 | 'WP Data Access', |
| 690 | 630 | 'Data Explorer', |
| 691 | 631 | 'manage_options', |
| 692 | 632 | self::PAGE_MAIN, |
| 693 | - array($this, ( 'new' !== $current_data_explorer_version ? 'data_explorer_page' : 'data_explorer_page_new' )) | |
| 633 | + array($this, 'data_explorer_page') | |
| 694 | 634 | ); |
| 695 | - if ( self::PAGE_MAIN === $this->page ) { | |
| 696 | - if ( 'new' !== $current_data_explorer_version ) { | |
| 697 | - $args = array( | |
| 698 | - 'page_hook_suffix' => $this->wpda_data_explorer_menu, | |
| 699 | - ); | |
| 700 | - $this->wpda_data_explorer_view = new WPDA_List_View($args); | |
| 701 | - } | |
| 702 | - } | |
| 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 | + ); | |
| 703 | 644 | // Add submenu for Query Builder. |
| 704 | 645 | $this->wpda_data_publisher_menu = add_submenu_page( |
| 705 | 646 | self::MAIN_PAGE_SLUG, |
| 706 | 647 | 'WP Data Access', |
| @@ -790,9 +731,9 @@ | ||
| 790 | 731 | * @return void |
| 791 | 732 | */ |
| 792 | 733 | protected function add_apps() { |
| 793 | 734 | // Add apps to dashbaord menu |
| 794 | - $apps = new WPDA_Apps(); | |
| 735 | + $apps = new WPDA_Add_App_To_Menu(); | |
| 795 | 736 | $apps->add_apps_to_menu(); |
| 796 | 737 | } |
| 797 | 738 | |
| 798 | 739 | /** |
| @@ -818,9 +759,9 @@ | ||
| 818 | 759 | // Cannot determine the user roles (not able to show menus). |
| 819 | 760 | return; |
| 820 | 761 | } |
| 821 | 762 | // Check dashboard role access. |
| 822 | - $dashboard_roles = get_option( \WPDataAccess\Settings\WPDA_Settings_Dashboard::DASHBOARD_ROLES ); | |
| 763 | + $dashboard_roles = get_option( \WPDataAccess\Settings\WPDA_Settings_Legacy_Dashboard::DASHBOARD_ROLES ); | |
| 823 | 764 | $user_has_role = false; |
| 824 | 765 | foreach ( $user_roles as $user_role ) { |
| 825 | 766 | if ( false !== strpos( $dashboard_roles, $user_role ) ) { |
| 826 | 767 | $user_has_role = true; |
| @@ -827,9 +768,9 @@ | ||
| 827 | 768 | break; |
| 828 | 769 | } |
| 829 | 770 | } |
| 830 | 771 | // Check dashboard user access. |
| 831 | - $dashboard_users = get_option( \WPDataAccess\Settings\WPDA_Settings_Dashboard::DASHBOARD_USERS ); | |
| 772 | + $dashboard_users = get_option( \WPDataAccess\Settings\WPDA_Settings_Legacy_Dashboard::DASHBOARD_USERS ); | |
| 832 | 773 | $user_has_access = false !== strpos( $dashboard_users, WPDA::get_current_user_login() ); |
| 833 | 774 | if ( !$user_has_role && !$user_has_access ) { |
| 834 | 775 | return; |
| 835 | 776 | } |
| @@ -902,50 +843,43 @@ | ||
| 902 | 843 | public function data_dashboard_page() { |
| 903 | 844 | WPDA_Dashboard::add_dashboard( true ); |
| 904 | 845 | } |
| 905 | 846 | |
| 906 | - /** | |
| 907 | - * Show data explorer main page | |
| 908 | - * | |
| 909 | - * Initialization of $this->wpda_data_explorer_view is done earlier in | |
| 910 | - * {@see WP_Data_Access_Admin::add_menu_items()} to support screen options. This method just shows the page | |
| 911 | - * containing the list table. | |
| 912 | - * | |
| 913 | - * @since 1.0.0 | |
| 914 | - * | |
| 915 | - * @see WP_Data_Access_Admin::add_menu_items() | |
| 916 | - */ | |
| 917 | 847 | public function data_explorer_page() { |
| 918 | 848 | WPDA_Dashboard::add_dashboard(); |
| 919 | 849 | if ( isset( $_REQUEST['page_action'] ) && 'wpda_backup' === $_REQUEST['page_action'] ) { |
| 920 | - // phpcs:ignore WordPress.Security.NonceVerification | |
| 921 | 850 | $this->backup_page(); |
| 922 | 851 | } elseif ( isset( $_REQUEST['page_action'] ) && 'wpda_import_csv' === $_REQUEST['page_action'] ) { |
| 923 | - // phpcs:ignore WordPress.Security.NonceVerification | |
| 924 | 852 | $this->import_csv(); |
| 925 | 853 | } elseif ( isset( $_REQUEST['page_action'] ) && 'wpda_global_search' === $_REQUEST['page_action'] ) { |
| 926 | - // phpcs:ignore WordPress.Security.NonceVerification | |
| 927 | 854 | $this->advanced_search(); |
| 928 | 855 | } else { |
| 929 | - $this->wpda_data_explorer_view->show(); | |
| 856 | + $explorer = new WPDA_Data_Explorer(); | |
| 857 | + $explorer->show(); | |
| 930 | 858 | } |
| 931 | 859 | } |
| 932 | 860 | |
| 933 | - public function data_explorer_page_new() { | |
| 861 | + public function data_explorer_table_page() { | |
| 934 | 862 | WPDA_Dashboard::add_dashboard(); |
| 935 | - if ( isset( $_REQUEST['page_action'] ) && 'wpda_backup' === $_REQUEST['page_action'] ) { | |
| 936 | - // phpcs:ignore WordPress.Security.NonceVerification | |
| 937 | - $this->backup_page(); | |
| 938 | - } elseif ( isset( $_REQUEST['page_action'] ) && 'wpda_import_csv' === $_REQUEST['page_action'] ) { | |
| 939 | - // phpcs:ignore WordPress.Security.NonceVerification | |
| 940 | - $this->import_csv(); | |
| 941 | - } elseif ( isset( $_REQUEST['page_action'] ) && 'wpda_global_search' === $_REQUEST['page_action'] ) { | |
| 942 | - // phpcs:ignore WordPress.Security.NonceVerification | |
| 943 | - $this->advanced_search(); | |
| 944 | - } else { | |
| 945 | - $explorer = new WPDA_Explorer_Container(); | |
| 946 | - $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' ) ); | |
| 947 | 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(); | |
| 948 | 882 | } |
| 949 | 883 | |
| 950 | 884 | public function data_navi() { |
| 951 | 885 | if ( isset( $_POST['wpda-legacy-tool-status'] ) ) { |
| @@ -980,10 +914,10 @@ | ||
| 980 | 914 | } |
| 981 | 915 | |
| 982 | 916 | public function data_apps() { |
| 983 | 917 | WPDA_Dashboard::add_dashboard(); |
| 984 | - $wpda_apps_list = new WPDA_Apps_List(); | |
| 985 | - $wpda_apps_list->show(); | |
| 918 | + $wpda_app_builder = new WPDA_App_Builder(); | |
| 919 | + $wpda_app_builder->show(); | |
| 986 | 920 | } |
| 987 | 921 | |
| 988 | 922 | public function advanced_search() { |
| 989 | 923 | $advanced_search = new WPDA_Global_Search(); |
| @@ -996,9 +930,9 @@ | ||
| 996 | 930 | * @return void |
| 997 | 931 | */ |
| 998 | 932 | public function query_builder() { |
| 999 | 933 | WPDA_Dashboard::add_dashboard(); |
| 1000 | - $query_builder = new WPDA_Query_Builder(); | |
| 934 | + $query_builder = new \WPDataAccess\Data_Apps\WPDA_Query_Builder(); | |
| 1001 | 935 | $query_builder->show(); |
| 1002 | 936 | } |
| 1003 | 937 | |
| 1004 | 938 | /** |
| @@ -1042,9 +976,9 @@ | ||
| 1042 | 976 | ?> |
| 1043 | 977 | <div class="wrap"> |
| 1044 | 978 | <h1 class="wp-heading-inline"> |
| 1045 | 979 | <span>Data Designer</span> |
| 1046 | - <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"> | |
| 1047 | 981 | <span class="dashicons dashicons-editor-help" style="text-decoration:none;vertical-align:top;font-size:30px;"> |
| 1048 | 982 | </span> |
| 1049 | 983 | </a> |
| 1050 | 984 | </h1> |
| @@ -1049,10 +983,9 @@ | ||
| 1049 | 983 | </a> |
| 1050 | 984 | </h1> |
| 1051 | 985 | <p> |
| 1052 | 986 | <?php |
| 1053 | - echo __( 'ERROR: Repository table not found!', 'wp-data-access' ); | |
| 1054 | - // phpcs:ignore WordPress.Security.EscapeOutput | |
| 987 | + esc_html_e( 'ERROR: Repository table not found!', 'wp-data-access' ); | |
| 1055 | 988 | ?> |
| 1056 | 989 | </p> |
| 1057 | 990 | </div> |
| 1058 | 991 | <?php |
| @@ -1098,9 +1031,9 @@ | ||
| 1098 | 1031 | ?> |
| 1099 | 1032 | <div class="wrap"> |
| 1100 | 1033 | <h1 class="wp-heading-inline"> |
| 1101 | 1034 | <span>Data Tables</span> |
| 1102 | - <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"> | |
| 1103 | 1036 | <span class="dashicons dashicons-editor-help" style="text-decoration:none;vertical-align:top;font-size:30px;"> |
| 1104 | 1037 | </span> |
| 1105 | 1038 | </a> |
| 1106 | 1039 | </h1> |
| @@ -1105,10 +1038,9 @@ | ||
| 1105 | 1038 | </a> |
| 1106 | 1039 | </h1> |
| 1107 | 1040 | <p> |
| 1108 | 1041 | <?php |
| 1109 | - echo __( 'ERROR: Repository table not found!', 'wp-data-access' ); | |
| 1110 | - // phpcs:ignore WordPress.Security.EscapeOutput | |
| 1042 | + esc_html_e( 'ERROR: Repository table not found!', 'wp-data-access' ); | |
| 1111 | 1043 | ?> |
| 1112 | 1044 | </p> |
| 1113 | 1045 | </div> |
| 1114 | 1046 | <?php |
| @@ -1126,13 +1058,10 @@ | ||
| 1126 | 1058 | */ |
| 1127 | 1059 | public function backup_page() { |
| 1128 | 1060 | $wpda_backup = new WPDA_Data_Export(); |
| 1129 | 1061 | $wp_nonce = ( isset( $_REQUEST['wp_nonce'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['wp_nonce'] ) ) : '?' ); |
| 1130 | - // phpcs:ignore WordPress.Security.NonceVerification | |
| 1131 | 1062 | if ( isset( $_REQUEST['action'] ) && wp_verify_nonce( $wp_nonce, 'wpda-backup-' . WPDA::get_current_user_login() ) ) { |
| 1132 | - // phpcs:ignore WordPress.Security.NonceVerification | |
| 1133 | 1063 | $action = sanitize_text_field( wp_unslash( $_REQUEST['action'] ) ); |
| 1134 | - // phpcs:ignore WordPress.Security.NonceVerification | |
| 1135 | 1064 | if ( 'new' === $action ) { |
| 1136 | 1065 | $wpda_backup->create_export( 'add' ); |
| 1137 | 1066 | } elseif ( 'add' === $action ) { |
| 1138 | 1067 | $wpda_backup->wpda_add_cron_job(); |
| @@ -1148,96 +1077,8 @@ | ||
| 1148 | 1077 | } |
| 1149 | 1078 | } |
| 1150 | 1079 | |
| 1151 | 1080 | /** |
| 1152 | - * Add user defined sub menu | |
| 1153 | - * | |
| 1154 | - * WPDA allows users to create sub menu for table lists and simple forms. Sub menus can be added to the WPDA | |
| 1155 | - * menu or any other (external) menu. A sub menu is added to an external menu via the menu slug. Sub menus are | |
| 1156 | - * taken from {@see WPDA_User_Menus_Model}. | |
| 1157 | - * | |
| 1158 | - * This method is called from the admin_menu action with a lower priority to make sure other menus are available. | |
| 1159 | - * User defined menu items are added to available menus in this method. These can be WPDA menus or external menus | |
| 1160 | - * as mentioned in the according list table and edit form. WPDA menus are added to menu WP Data Tables. External | |
| 1161 | - * menus are added to the menu having the menu slug defined by the user. | |
| 1162 | - * | |
| 1163 | - * This method does not actually show the list tables! It just creates the menu items. When the user clicks on such | |
| 1164 | - * a dynamically defined menu item, method {@see WP_Data_Access_Admin::my_tables_page()} is called, which takes | |
| 1165 | - * care of showing the list table. | |
| 1166 | - * | |
| 1167 | - * @since 1.0.0 | |
| 1168 | - * | |
| 1169 | - * @see WP_Data_Access_Admin::my_tables_page() | |
| 1170 | - * @see WPDA_User_Menus_Model | |
| 1171 | - */ | |
| 1172 | - public function add_menu_my_tables() { | |
| 1173 | - $menus_shown_to_current_user = array(); | |
| 1174 | - // Add list tables to external menus. | |
| 1175 | - foreach ( WPDA_User_Menus_Model::list_external_menus() as $menu ) { | |
| 1176 | - $user_roles = WPDA::get_current_user_roles(); | |
| 1177 | - $user_has_role = false; | |
| 1178 | - if ( '' === $menu->menu_role || null === $menu->menu_role ) { | |
| 1179 | - $user_has_role = in_array( 'administrator', $user_roles, true ); | |
| 1180 | - } else { | |
| 1181 | - $user_role_array = explode( ',', (string) $menu->menu_role ); | |
| 1182 | - //phpcs:ignore - 8.1 proof | |
| 1183 | - foreach ( $user_role_array as $user_role_array_item ) { | |
| 1184 | - $user_has_role = in_array( $user_role_array_item, $user_roles, true ); | |
| 1185 | - //phpcs:ignore - 8.1 proof | |
| 1186 | - if ( $user_has_role ) { | |
| 1187 | - break; | |
| 1188 | - } | |
| 1189 | - } | |
| 1190 | - } | |
| 1191 | - if ( $user_has_role ) { | |
| 1192 | - if ( !isset( $menus_shown_to_current_user[$menu->menu_slug . '/' . $menu->menu_name . '/' . $menu->menu_table_name . '/' . $menu->menu_schema_name] ) ) { | |
| 1193 | - $menu_slug = self::PAGE_EXPLORER . '_' . $menu->menu_table_name; | |
| 1194 | - $menu_index = $menu->menu_table_name; | |
| 1195 | - $this->create_non_admin_menu( $menu_slug ); | |
| 1196 | - $this->wpda_my_table_list_menu[$menu_index] = add_submenu_page( | |
| 1197 | - $this->first_page, | |
| 1198 | - 'WP Data Access : ' . strtoupper( $menu->menu_table_name ), | |
| 1199 | - $menu->menu_name, | |
| 1200 | - WPDA::get_current_user_capability(), | |
| 1201 | - $menu_slug, | |
| 1202 | - array($this, 'my_tables_page') | |
| 1203 | - ); | |
| 1204 | - $this->wpda_my_table_list_view[$menu_index] = new WPDA_List_View(array( | |
| 1205 | - 'page_hook_suffix' => $this->wpda_my_table_list_menu[$menu_index], | |
| 1206 | - 'wpdaschema_name' => $menu->menu_schema_name, | |
| 1207 | - 'table_name' => $menu->menu_table_name, | |
| 1208 | - )); | |
| 1209 | - $menus_shown_to_current_user[$menu->menu_slug . '/' . $menu->menu_name . '/' . $menu_index . '/' . $menu->menu_schema_name] = true; | |
| 1210 | - } | |
| 1211 | - } | |
| 1212 | - } | |
| 1213 | - } | |
| 1214 | - | |
| 1215 | - /** | |
| 1216 | - * Show user defined menus | |
| 1217 | - * | |
| 1218 | - * A user defined menu that are added to the plugin menu in {@see WP_Data_Access_Admin::add_menu_my_tables()} is | |
| 1219 | - * shown here. This method is called when the user clicks on the menu item generated in | |
| 1220 | - * {@see WP_Data_Access_Admin::add_menu_my_tables()}. | |
| 1221 | - * | |
| 1222 | - * @since 1.0.0 | |
| 1223 | - * | |
| 1224 | - * @see WP_Data_Access_Admin::add_menu_my_tables() | |
| 1225 | - */ | |
| 1226 | - public function my_tables_page() { | |
| 1227 | - // Grab table name from menu slug. | |
| 1228 | - if ( null !== $this->page ) { | |
| 1229 | - if ( strpos( $this->page, self::PAGE_EXPLORER ) !== false ) { | |
| 1230 | - $table = substr( $this->page, strlen( self::PAGE_EXPLORER . '_' ) ); | |
| 1231 | - } else { | |
| 1232 | - $table = substr( $this->page, strlen( self::PAGE_MY_TABLES . '_' ) ); | |
| 1233 | - } | |
| 1234 | - // Show list table. | |
| 1235 | - $this->wpda_my_table_list_view[$table]->show(); | |
| 1236 | - } | |
| 1237 | - } | |
| 1238 | - | |
| 1239 | - /** | |
| 1240 | 1081 | * Add main menu for non admin user |
| 1241 | 1082 | * |
| 1242 | 1083 | * @param string $first_page First plugin page. |
| 1243 | 1084 | * @return void |
| @@ -1259,4 +1100,6 @@ | ||
| 1259 | 1100 | } |
| 1260 | 1101 | } |
| 1261 | 1102 | |
| 1262 | 1103 | } |
| 1104 | + | |
| 1105 | +// phpcs:enable WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing | |