32 | | The patch does the follow steps for theme_mods and options: |
33 | | 1. serialize with **maybe_serialize()** |
34 | | 2. checks for post symbol matches on strings for theme_mod/option values. |
35 | | 3. replaces these strings with post ID ints |
36 | | 4. unserialize with **maybe_unserialize()** so values can be properly used. |
| 32 | If you're not using a **fresh_site** install, you will need to manually force that state, you can add this to the same **functions.php** file: |
| 33 | |
| 34 | {{{ |
| 35 | update_option( 'fresh_site', 1 ); |
| 36 | }}} |
| 37 | |
| 38 | Now go into the customizer, and you will get PHP warning for not being able to preg_match on the values passed as they are arrays, like these: |
| 39 | |
| 40 | |
| 41 | {{{ |
| 42 | [22-Mar-2019 03:25:50 UTC] PHP Warning: preg_match() expects parameter 2 to be string, array given in /srv/www/wordpress-default/public_html/wp-includes/class-wp-customize-manager.php on line 1526 |
| 43 | [22-Mar-2019 03:25:50 UTC] PHP Warning: preg_match() expects parameter 2 to be string, array given in /srv/www/wordpress-default/public_html/wp-includes/class-wp-customize-manager.php on line 1544 |
| 44 | }}} |
| 45 | |
| 46 | Now apply patch, and follow the same steps. You should no longer receive PHP warnings. |
| 47 | |
| 48 | From the browser console, you can verify the correct value is set in the array for the theme_mod using the customizer js api: |
| 49 | |
| 50 | {{{ |
| 51 | wp.customize( 'testing' )(); |
| 52 | }}} |
| 53 | |
| 54 | The code for options vs theme_mods is pretty much identical, so it could probably be consolidated if necessary. |
| 55 | |
| 56 | ---- |
| 57 | |
| 58 | The patch does the following steps for theme_mods and options: |
| 59 | |
| 60 | 1. serialize value with **maybe_serialize()** |
| 61 | 2. check for post symbol matches on strings. |
| 62 | 3. replace these strings with post ID ints. |
| 63 | 4. unserialize value with **maybe_unserialize()** so values can be properly used. |