Class WPDA

Plugin default values and settings are managed through this class. Every plugin option has a default value which is maintained in an array together with the option name. Options are only saved in $wpdb->options when they are changed. Otherwise the default values are used. After reading option values from $wpdb->options the values are cached as many of them are used in multiple places during the processing of a request.

author Peter Schulz
since 1.0.0
package WPDataAccess

 Methods

Delete all plugin options from table wp_options

clear_all_options() 
Static
since 1.0.0

Check if repository column represents a schema name

column_is_schema_name(string $table_name, string $column_name) : boolean
Static

Parameters

$table_name

string

Table name

$column_name

string

Column name

Returns

boolean

Where clause construction (use filter if applied)

construct_where_clause(string $schema_name, string $table_name, string $columns, string $search) : string
Static

Param $columns = associative array containing the following column info taken from the data dictionary: $columns['column_name'] => information_schema.tables.column_name $columns['data_type'] => information_schema.tables.data_type $columns['extra'] => information_schema.tables.extra $columns['column_type' => information_schema.tables.column_type $columns['is_nullable' => information_schema.tables.is_nullable $columns['column_default'] => information_schema.tables.column_default

Parameters

$schema_name

string

Schema name (optional)

$table_name

string

Table name (optional)

$columns

string

Array containing table columns

$search

string

Search string entered by user

Returns

stringWhere clause between ()

Convert memory value to integer.

convert_memory_to_decimal($memory_value) : integer
Static
since 2.0.8

Parameters

$memory_value

string Memory value (eg 128M)

Returns

integerConverted value in decimal

Get user capability

get_current_user_capability() : mixed
Static
since 2.0.8

Returns

mixedCurrent users first capability or FALSE if not logged in.

get_current_user_id()

get_current_user_id() 
Static

Get user role

get_current_user_roles() : mixed
Static
since 2.0.8

Returns

mixedCurrent user roles or FALSE if not logged in.

Get plugin option values

get_option(array $option) : mixed
Static

Get value for pluginoption saved in wp_options. If option is not found in $wpdb->options the default value for that option is returned. Option values once taken from $wpdb->options are cached to prevent execution of the same query multiple times during teh processing of a request.

since 1.0.0

Parameters

$option

array

OPTION_ARRAY (use class constants).

Returns

mixedValue for OPTION_ARRAY ($option): (1) cached value (2) wp_options value (3) default value.

Return the default value for a plugin option

get_option_default(array $option) : mixed
Static
since 1.0.0

Parameters

$option

array

OPTION_ARRAY (use class constants).

Returns

mixedDefault value for OPTION_ARRAY ($option).

Translated table label

get_table_type_text(string $table_type) : string
Static

Returns a translated table label. The label depends on the type of table. Provided through a function to support internationalization.

since 1.0.0

Parameters

$table_type

string

Table type (use WPDA constants).

Returns

stringTranslated table type.

Simplify data type for simple forms

get_type(string $arg) : string
Static

Data types used in plugin a re simplified for simple form usage.

since 1.0.0
see \WPDataAccess\Simple_Form\WPDA_Simple_Form

Parameters

$arg

string

Data type as known to the MySQL database.

Returns

stringSimplified data type (mainly used to recognize when to use quotes).

List containing all WordPress tables

get_wp_tables() : array
Static
since 1.1.0

Returns

array

Returns a list of all plugin tables

get_wpda_tables() : array
Static
since 1.0.0

Returns

arrayList of plugin tables

is_plugin_page()

is_plugin_page($page) 
Static

Parameters

$page

Checks if a table is a WordPress table

is_wp_table(string $table_name) : boolean
Static
since 1.1.0

Parameters

$table_name

string

Table name.

Returns

booleanTRUE = WordPress table

Checks if table is plugin table

is_wpda_table(string $real_table_name) : boolean
Static

NOTE Variable $phpdoc_supported_solution is a temporary variable that does not add any functionality to this function. It only serves the purpose to get class WPDA in the documentation!!! If the isset statement in the return is performed directly on self::WPDA_TABLES, class WPDA will not appear in the phpdoc generated documentation. To avoid class WPDA to be undocumented, we use $phpdoc_supported_solution.

since 1.0.0

Parameters

$real_table_name

string

Table name to be checked.

Returns

booleanTRUE = $table_name is a WPDA table, FALSE = $table_name is not a WPDA table.

Load all WordPress tables

load_wp_tables() 
Static
since 1.1.0

Log a message in the database

log($log_id, $log_type, $log_msg) 
Static

Use this method to log messages to the database.

NOTE Don't use $wpdb->insert! You'll miss a lot of information...

since 2.0.7

Parameters

$log_id

string Id to identify/find logged data.

$log_type

string Possible values: 'FATAL', 'ERROR', 'WARN', 'INFO', 'DEBUG', 'TRACE'

$log_msg

string Any text (max length 4096kb).

register_plugin_page()

register_plugin_page($page) 
Static

Parameters

$page

Check if database schema exists (local and remote databases)

schema_exists(string $schema_name) : boolean
Static

Parameters

$schema_name

string

Database schema

Returns

booleanExists?

Save plugin option

set_option(array $option, mixed $value = null
Static

Saves a plugin option in $wpdb->options.

since 1.0.0

Parameters

$option

array

OPTION_ARRAYS (use class constants).

$value

mixed

Value to be saved for $option. If null set to default.

Replaces environment variables in where clause with appropriate values

substitute_environment_vars($where_clause) : string
Static

Parameters

$where_clause

Returns

string

 Properties

 

Options cache array

$option_cache : array

Default

array()
Static
 

$plugin_pages

$plugin_pages 

Default

array(\WP_Data_Access_Admin::PAGE_MAIN, \WP_Data_Access_Admin::PAGE_SETTINGS, \WP_Data_Access_Admin::PAGE_EXPLORER, \WP_Data_Access_Admin::PAGE_PUBLISHER, \WP_Data_Access_Admin::PAGE_DESIGNER, \WP_Data_Access_Admin::PAGE_MY_TABLES, \WPDataProjects\WPDP::PAGE_MAIN)
Static
 

List containing all WordPress tables

$wp_tables : array

Default

array()
Static
 

List containing all plugin tables

$wpda_tables : array

Default

array()
Static

 Constants

 

BACKEND_OPTIONNAME_DATABASE_ACCESS

BACKEND_OPTIONNAME_DATABASE_ACCESS = 'WPDA_BE_TABLE_ACCESS_' 
 

BACKEND_OPTIONNAME_DATABASE_SELECTED

BACKEND_OPTIONNAME_DATABASE_SELECTED = 'WPDA_BE_TABLE_SELECTED_' 
 

DB_DATETIME_FORMAT

DB_DATETIME_FORMAT = 'Y-m-d H:i:s' 
 

DB_DATE_FORMAT

DB_DATE_FORMAT = 'Y-m-d' 
 

DB_TIME_FORMAT

DB_TIME_FORMAT = 'H:i:s' 
 

FRONTEND_OPTIONNAME_DATABASE_ACCESS

FRONTEND_OPTIONNAME_DATABASE_ACCESS = 'WPDA_FE_TABLE_ACCESS_' 
 

FRONTEND_OPTIONNAME_DATABASE_SELECTED

FRONTEND_OPTIONNAME_DATABASE_SELECTED = 'WPDA_FE_TABLE_SELECTED_' 
 

Option wpda_be_allow_delete and it's default value

OPTION_BE_ALLOW_DELETE = array('wpda_be_allow_delete', 'on') 
 

Option wpda_be_wpda_allow_imports and it's default value

OPTION_BE_ALLOW_IMPORTS = array('wpda_be_wpda_allow_imports', 'on') 
 

Option wpda_be_allow_insert and it's default value

OPTION_BE_ALLOW_INSERT = array('wpda_be_allow_insert', 'on') 
 

Option wpda_be_allow_update and it's default value

OPTION_BE_ALLOW_UPDATE = array('wpda_be_allow_update', 'on') 
 

Option wpda_be_confirm_export and it's default value

OPTION_BE_CONFIRM_EXPORT = array('wpda_be_confirm_export', 'on') 
 

Option wpda_be_confirm_view and it's default value

OPTION_BE_CONFIRM_VIEW = array('wpda_be_confirm_view', 'on') 
 

Option wpda_be_debug and it's default value

OPTION_BE_DEBUG = array('wpda_be_debug', 'off') 
 

Option wpda_be_design_mode and it's default value

OPTION_BE_DESIGN_MODE = array('wpda_be_design_mode', 'advanced') 
 

Option wpda_be_wpda_export_rows and it's default value

OPTION_BE_EXPORT_ROWS = array('wpda_be_wpda_export_rows', 'on') 
 

Option wpda_be_wpda_export_variable_prefix and it's default value

OPTION_BE_EXPORT_VARIABLE_PREFIX = array('wpda_be_wpda_export_variable_prefix', 'on') 
 

Option wpda_be_innodb_count and it's default value

OPTION_BE_INNODB_COUNT = array('wpda_be_innodb_count', 100000) 
 

Option wpda_be_load_datatables and it's default value

OPTION_BE_LOAD_DATATABLES = array('wpda_be_load_datatables', 'on') 
 

Option wpda_be_load_datatables_response and it's default value

OPTION_BE_LOAD_DATATABLES_RESPONSE = array('wpda_be_load_datatables_response', 'on') 
 

Option wpda_be_pagination and it's default value

OPTION_BE_PAGINATION = array('wpda_be_pagination', '10') 
   

Option wpda_be_table_access and it's default value

OPTION_BE_TABLE_ACCESS = array('wpda_be_table_access', 'show') 
 

Option wpda_be_table_access_selected and it's default value

OPTION_BE_TABLE_ACCESS_SELECTED = array('wpda_be_table_access_selected', '') 
 

Option wpda_be_text_wrap and it's default value

OPTION_BE_TEXT_WRAP = array('wpda_be_text_wrap', 400) 
 

Option wpda_be_text_wrap_switch and it's default value

OPTION_BE_TEXT_WRAP_SWITCH = array('wpda_be_text_wrap_switch', 'off') 
   

Option wpda_db_dropbox_path and it's default value

OPTION_DB_DROPBOX_PATH = array('wpda_db_dropbox_path', '/wp-data-access/') 
 

Option wpda_db_local_path and it's default value

OPTION_DB_LOCAL_PATH = array('wpda_db_local_path', '') 
 

OPTION_DP_JSON_EDITING

OPTION_DP_JSON_EDITING = array('wpda_dp_json_editing', 'validate') 
 

OPTION_DP_LANGUAGE

OPTION_DP_LANGUAGE = array('wpda_dp_language', 'English') 
 

Option wpda_dp_publication_roles and it's default value

OPTION_DP_PUBLICATION_ROLES = array('wpda_dp_publication_roles', '') 
 

Option wpda_fe_load_datatables and it's default value

OPTION_FE_LOAD_DATATABLES = array('wpda_fe_load_datatables', 'on') 
 

Option wpda_fe_load_datatables_response and it's default value

OPTION_FE_LOAD_DATATABLES_RESPONSE = array('wpda_fe_load_datatables_response', 'on') 
 

Option wpda_fe_pagination and it's default value

OPTION_FE_PAGINATION = array('wpda_fe_pagination', '10') 
 

Option wpda_fe_table_access and it's default value

OPTION_FE_TABLE_ACCESS = array('wpda_fe_table_access', 'select') 
 

Option wpda_fe_table_access_selected and it's default value

OPTION_FE_TABLE_ACCESS_SELECTED = array('wpda_fe_table_access_selected', '') 
 

Option wpda_mr_keep_backup_tables and it's default value

OPTION_MR_KEEP_BACKUP_TABLES = array('wpda_mr_keep_backup_tables', 'on') 
 

OPTION_PLUGIN_DATE_FORMAT

OPTION_PLUGIN_DATE_FORMAT = array('wpda_plugin_date_format', 'Y-m-d') 
 

OPTION_PLUGIN_DATE_PLACEHOLDER

OPTION_PLUGIN_DATE_PLACEHOLDER = array('wpda_plugin_date_placeholder', 'yyyy-mm-dd') 
 

OPTION_PLUGIN_HIDE_ADMIN_MENU

OPTION_PLUGIN_HIDE_ADMIN_MENU = array('wpda_plugin_hide_admin_menu', 'off') 
 

OPTION_PLUGIN_PANEL_COOKIES

OPTION_PLUGIN_PANEL_COOKIES = array('wpda_plugin_panel_cookies', 'clear') 
 

OPTION_PLUGIN_SECRET_IV

OPTION_PLUGIN_SECRET_IV = array('wpda_plugin_secret_iv', self::OPTION_PLUGIN_SECRET_IV_DEFAULT) 
 

OPTION_PLUGIN_SECRET_IV_DEFAULT

OPTION_PLUGIN_SECRET_IV_DEFAULT = 'enter-your-secret-iv-here' 
 

OPTION_PLUGIN_SECRET_KEY

OPTION_PLUGIN_SECRET_KEY = array('wpda_plugin_secret_key', self::OPTION_PLUGIN_SECRET_KEY_DEFAULT) 
 

OPTION_PLUGIN_SECRET_KEY_DEFAULT

OPTION_PLUGIN_SECRET_KEY_DEFAULT = 'enter-your-secret-key-here' 
 

OPTION_PLUGIN_SET_FORMAT

OPTION_PLUGIN_SET_FORMAT = array('wpda_plugin_set_format', 'csv') 
 

OPTION_PLUGIN_TIME_FORMAT

OPTION_PLUGIN_TIME_FORMAT = array('wpda_plugin_time_format', 'H:i') 
 

OPTION_PLUGIN_TIME_PLACEHOLDER

OPTION_PLUGIN_TIME_PLACEHOLDER = array('wpda_plugin_time_placeholder', 'hh:mi') 
 

OPTION_PLUGIN_WPDADIEHARD_PAGE

OPTION_PLUGIN_WPDADIEHARD_PAGE = array('wpda_plugin_wpdadiehard_page', 'on') 
 

OPTION_PLUGIN_WPDADIEHARD_POST

OPTION_PLUGIN_WPDADIEHARD_POST = array('wpda_plugin_wpdadiehard_post', 'on') 
 

OPTION_PLUGIN_WPDATAACCESS_PAGE

OPTION_PLUGIN_WPDATAACCESS_PAGE = array('wpda_plugin_wpdataaccess_page', 'on') 
 

OPTION_PLUGIN_WPDATAACCESS_POST

OPTION_PLUGIN_WPDATAACCESS_POST = array('wpda_plugin_wpdataaccess_post', 'on') 
 

Option wpda_datatables_responsive_version and it's default value

OPTION_WPDA_DATATABLES_RESPONSIVE_VERSION = array('wpda_datatables_responsive_version', '2.2.3') 
 

Option wpda_datatables_version and it's default value

OPTION_WPDA_DATATABLES_VERSION = array('wpda_datatables_version', '1.10.20') 
 

OPTION_WPDA_ENABLE_ROLE_MANAGEMENT

OPTION_WPDA_ENABLE_ROLE_MANAGEMENT = array('wpda_rm_enable_role_management', 'off') 
 

Option wpda_setup_error and it's default value

OPTION_WPDA_SETUP_ERROR = array('wpda_setup_error', '') 
 

Option wpda_show_whats_new and it's default value

OPTION_WPDA_SHOW_WHATS_NEW = array('wpda_show_whats_new', 'off') 
 

Option wpda_uninstall_options and it's default value

OPTION_WPDA_UNINSTALL_OPTIONS = array('wpda_uninstall_options', 'on') 
 

Option wpda_uninstall_tables and it's default value

OPTION_WPDA_UNINSTALL_TABLES = array('wpda_uninstall_tables', 'on') 
 

OPTION_WPDA_USE_ROLES_IN_SHORTCODE

OPTION_WPDA_USE_ROLES_IN_SHORTCODE = array('wpda_rm_use_roles_in_shortcode', 'off') 
 

Option wpda_version and it's default value

OPTION_WPDA_VERSION = array('wpda_version', '3.1.2') 
 

Label for WordPress tables

TABLE_TYPE_WP = 'wordpress table' 
 

Label for WPDA plugin tables

TABLE_TYPE_WPDA = 'plugin table' 
 

List of plugin tables

WPDA_TABLES = array('wpda_logging' => true, 'wpda_menus' => true, 'wpda_table_settings' => true, 'wpda_table_design' => true, 'wpda_publisher' => true, 'wpda_media' => true, 'wpda_project' => true, 'wpda_project_page' => true, 'wpda_project_table' => true)