| @@ -19,9 +19,9 @@ | ||
| 19 | 19 | * Class WPDA |
| 20 | 20 | * |
| 21 | 21 | * Plugin default values and settings are managed through this class. Every plugin option has a default value |
| 22 | 22 | * which is maintained in an array together with the option name. Options are only saved in $wpdb->options when |
| 23 | - * they are changed. Otherwise the default values are used. After reading option values from $wpdb->options the | |
| 23 | + * they are changed. Otherwise, the default values are used. After reading option values from $wpdb->options the | |
| 24 | 24 | * values are cached as many of them are used in multiple |
| 25 | 25 | * values are cached as many of them are used in multiple |
| 26 | 26 | * places during the processing of a request. |
| 27 | 27 | * |
| @@ -27,10 +27,12 @@ | ||
| 27 | 27 | * |
| 28 | 28 | * @author Peter Schulz |
| 29 | 29 | * @since 1.0.0 |
| 30 | 30 | */ |
| 31 | - class WPDA { | |
| 32 | 31 | |
| 32 | + // phpcs:disable PluginCheck.CodeAnalysis.Offloading.OffloadedContent | |
| 33 | + class WPDA { | |
| 34 | + | |
| 33 | 35 | // SAVING SPACE - According to the plugin guidelines it is allowed to include external fonts: |
| 34 | 36 | // https://developer.wordpress.org/plugins/wordpress-org/detailed-plugin-guidelines/#8-plugins-may-not-send-executable-code-via-third-party-systems |
| 35 | 37 | const CDN_FONTAWESOME = 'https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.2.0/css/'; |
| 36 | 38 | const GOOGLE_CHARTS = 'https://www.gstatic.com/charts/loader.js'; |
| @@ -50,10 +52,10 @@ | ||
| 50 | 52 | // Application options. |
| 51 | 53 | /** |
| 52 | 54 | * Option wpda_version and it's default value |
| 53 | 55 | */ |
| 54 | - const OPTION_WPDA_VERSION = array( 'wpda_version', '5.5.77' ); | |
| 55 | - const OPTION_WPDA_CLIENT_VERSION = array( 'wpda_client_version', '1.0.75' ); | |
| 56 | + const OPTION_WPDA_VERSION = array( 'wpda_version', '5.5.84' ); | |
| 57 | + const OPTION_WPDA_CLIENT_VERSION = array( 'wpda_client_version', '1.0.82' ); | |
| 56 | 58 | const OPTION_WPDA_UPGRADED = array( 'wpda_upgraded', false ); |
| 57 | 59 | /** |
| 58 | 60 | * Option wpda_setup_error and it's default value |
| 59 | 61 | */ |
| @@ -344,8 +346,9 @@ | ||
| 344 | 346 | WP_Data_Access_Admin::PAGE_PUBLISHER, |
| 345 | 347 | WP_Data_Access_Admin::PAGE_DESIGNER, |
| 346 | 348 | WP_Data_Access_Admin::PAGE_MY_TABLES, |
| 347 | 349 | WP_Data_Access_Admin::PAGE_CHARTS, |
| 350 | + WP_Data_Access_Admin::PAGE_TABLE, | |
| 348 | 351 | WPDP::PAGE_MAIN, |
| 349 | 352 | WPDP::PAGE_TEMPLATES, |
| 350 | 353 | ); |
| 351 | 354 | |
| @@ -471,8 +474,10 @@ | ||
| 471 | 474 | wp_die( esc_attr( 'ERROR: ' . $e->getMessage() ) ); |
| 472 | 475 | } |
| 473 | 476 | } |
| 474 | 477 | |
| 478 | + return false; | |
| 479 | + | |
| 475 | 480 | } |
| 476 | 481 | |
| 477 | 482 | /** |
| 478 | 483 | * Checks if a table is a WordPress table |
| @@ -818,8 +823,9 @@ | ||
| 818 | 823 | } else if ( $matches[2] == 'K' ) { |
| 819 | 824 | return $matches[1] * 1024; |
| 820 | 825 | } |
| 821 | 826 | } |
| 827 | + return ''; | |
| 822 | 828 | } |
| 823 | 829 | |
| 824 | 830 | public static function get_current_user_id() { |
| 825 | 831 | global $current_user; |
| @@ -925,9 +931,9 @@ | ||
| 925 | 931 | * $columns['column_default'] => information_schema.tables.column_default |
| 926 | 932 | * |
| 927 | 933 | * @param string $schema_name Schema name (optional) |
| 928 | 934 | * @param string $table_name Table name (optional) |
| 929 | - * @param string $columns Array containing table columns | |
| 935 | + * @param array $columns Array containing table columns | |
| 930 | 936 | * @param string $search Search string entered by user |
| 931 | 937 | * @param boolean $is_case_sensitive Case-sensitive search (default = false) |
| 932 | 938 | * @param boolean $is_dt_request Always skip filter for DataTable requests (default = false) |
| 933 | 939 | * |
| @@ -1145,23 +1151,28 @@ | ||
| 1145 | 1151 | jQuery(function() { |
| 1146 | 1152 | var clipboard = new ClipboardJS('.wpda_shortcode_clipboard'); |
| 1147 | 1153 | }); |
| 1148 | 1154 | </script> |
| 1149 | - <style type="text/css"> | |
| 1155 | + <style> | |
| 1156 | + /* noinspection CssUnusedSymbol */ | |
| 1150 | 1157 | .wpda_shortcode_content { |
| 1151 | 1158 | padding: 0 20px; |
| 1152 | 1159 | } |
| 1160 | + /* noinspection CssUnusedSymbol */ | |
| 1153 | 1161 | .wpda_shortcode_text { |
| 1154 | 1162 | text-align: center; |
| 1155 | 1163 | font-size: 105%; |
| 1156 | 1164 | white-space: nowrap; |
| 1157 | 1165 | } |
| 1166 | + /* noinspection CssUnusedSymbol */ | |
| 1158 | 1167 | .wpda_shortcode_buttons { |
| 1159 | 1168 | text-align: center; |
| 1160 | 1169 | } |
| 1170 | + /* noinspection CssUnusedSymbol */ | |
| 1161 | 1171 | .button.wpda_shortcode_button { |
| 1162 | 1172 | width: 100px !important; |
| 1163 | 1173 | } |
| 1174 | + /* noinspection CssUnusedSymbol */ | |
| 1164 | 1175 | .wpda_shortcode_link { |
| 1165 | 1176 | text-decoration: none; |
| 1166 | 1177 | font-weight: bold; |
| 1167 | 1178 | } |
| @@ -1236,13 +1247,13 @@ | ||
| 1236 | 1247 | |
| 1237 | 1248 | /** |
| 1238 | 1249 | * Get estimated number of rows in a table |
| 1239 | 1250 | * |
| 1240 | - * @param $schema_name Schema name | |
| 1241 | - * @param $table_name Table name | |
| 1242 | - * @param $wpda_table_settings Table settings (query WPDA_Table_Settings_Model) | |
| 1251 | + * @param $schema_name string Schema name | |
| 1252 | + * @param $table_name string Table name | |
| 1253 | + * @param $wpda_table_settings string Table settings (query WPDA_Table_Settings_Model) | |
| 1243 | 1254 | * |
| 1244 | - * @return int row count estimate or -1 if no estimate available | |
| 1255 | + * @return array row count estimate or -1 if no estimate available | |
| 1245 | 1256 | */ |
| 1246 | 1257 | public static function get_row_count_estimate( $schema_name, $table_name, $wpda_table_settings ) { |
| 1247 | 1258 | $row_count = null; |
| 1248 | 1259 | $is_estimate = null; |
| @@ -1669,10 +1680,10 @@ | ||
| 1669 | 1680 | |
| 1670 | 1681 | /** |
| 1671 | 1682 | * Get the column data types from a custom query |
| 1672 | 1683 | * |
| 1673 | - * @param $database Database (schema) name | |
| 1674 | - * @param $query Custom query | |
| 1684 | + * @param $database string Database (schema) name | |
| 1685 | + * @param $query string Custom query | |
| 1675 | 1686 | * @return array|null Column data type array or null if the query does not return any columns |
| 1676 | 1687 | */ |
| 1677 | 1688 | public static function get_columns_from_query( $database, $query ) { |
| 1678 | 1689 | $wpdadb = WPDADB::get_db_connection( $database ); |
| @@ -1702,9 +1713,18 @@ | ||
| 1702 | 1713 | return $rows; |
| 1703 | 1714 | } |
| 1704 | 1715 | |
| 1705 | 1716 | public static function current_user_is_admin() { |
| 1706 | - return current_user_can( 'manage_options' ) || is_super_admin(); | |
| 1717 | + if (current_user_can( 'manage_options' ) || is_super_admin()) { | |
| 1718 | + return true; | |
| 1719 | + } | |
| 1720 | + | |
| 1721 | + $user = wp_get_current_user(); | |
| 1722 | + if ( in_array( 'administrator', $user->roles ) ) { | |
| 1723 | + return true; | |
| 1724 | + } | |
| 1725 | + | |
| 1726 | + return false; | |
| 1707 | 1727 | } |
| 1708 | 1728 | |
| 1709 | 1729 | } |
| 1710 | 1730 | |