We keep all mkp_base options in the WordPress options table. In a multisite network, each site has its own options table.
This code tests that options can be read, written and re-read properly with a variety of option value data types:
- Boolean True
- Boolean False
- Integer
- String
- Simple Array
- Associative Array
- Nested Associative Array
In this shortcode, we clear the diagnostics table and any pending notifications, do the test and then display any diagnostic output.
Output:
Notifications clearedPerforming Options Test for 29Testing update of mkp_29_option_test_1 PASSED
Testing update of mkp_29_option_test_2 PASSED
Testing update of mkp_29_option_test_3 PASSED
Testing update of mkp_29_option_test_4 PASSED
Testing update of mkp_29_option_test_5 PASSED
Testing update of mkp_29_option_test_6 PASSED
Diagnostic Logfile Contents
03/01/21 10:49:15->MKP Plugins: Logfile [/nas/content/live/mkpusaws/wp-content/MKP Plugins_29.log] cleared
03/01/21 10:49:15->MKP Plugins: Doing code=[options_test] name=[options_test] value=[true]
03/01/21 10:49:15->MKP Plugins: mkp_29_option_test_1 PASSED
03/01/21 10:49:15->MKP Plugins: Table Name: [mkpusa_29_notifications]
03/01/21 10:49:15->MKP BASE: Saving Notification type 4[mkp_29_option_test_1 PASSED] to table [mkpusa_29_notifications]
03/01/21 10:49:15->MKP Plugins: Testing update of mkp_29_option_test_1 PASSED
03/01/21 10:49:15->MKP Plugins: mkp_29_option_test_2 PASSED
03/01/21 10:49:15->MKP Plugins: Table Name: [mkpusa_29_notifications]
03/01/21 10:49:15->MKP BASE: Saving Notification type 4[mkp_29_option_test_2 PASSED] to table [mkpusa_29_notifications]
03/01/21 10:49:16->MKP Plugins: Testing update of mkp_29_option_test_2 PASSED
03/01/21 10:49:16->MKP Plugins: mkp_29_option_test_3 PASSED
03/01/21 10:49:16->MKP Plugins: Table Name: [mkpusa_29_notifications]
03/01/21 10:49:16->MKP BASE: Saving Notification type 4[mkp_29_option_test_3 PASSED] to table [mkpusa_29_notifications]
03/01/21 10:49:16->MKP Plugins: Testing update of mkp_29_option_test_3 PASSED
03/01/21 10:49:16->MKP Plugins: mkp_29_option_test_4 PASSED
03/01/21 10:49:16->MKP Plugins: Table Name: [mkpusa_29_notifications]
03/01/21 10:49:16->MKP BASE: Saving Notification type 4[mkp_29_option_test_4 PASSED] to table [mkpusa_29_notifications]
03/01/21 10:49:16->MKP Plugins: Testing update of mkp_29_option_test_4 PASSED
03/01/21 10:49:16->MKP Plugins: mkp_29_option_test_5 PASSED
03/01/21 10:49:16->MKP Plugins: Table Name: [mkpusa_29_notifications]
03/01/21 10:49:16->MKP BASE: Saving Notification type 4[mkp_29_option_test_5 PASSED] to table [mkpusa_29_notifications]
03/01/21 10:49:16->MKP Plugins: Testing update of mkp_29_option_test_5 PASSED
03/01/21 10:49:16->MKP Plugins: mkp_29_option_test_6 PASSED
03/01/21 10:49:16->MKP Plugins: Table Name: [mkpusa_29_notifications]
03/01/21 10:49:16->MKP BASE: Saving Notification type 4[mkp_29_option_test_6 PASSED] to table [mkpusa_29_notifications]
03/01/21 10:49:16->MKP Plugins: Testing update of mkp_29_option_test_6 PASSED
03/01/21 10:49:16->MKP Plugins: Doing code=[show_diagnostics] name=[show_diagnostics] value=[true]