I am trying to switch my Wordpress site to a new theme. I could reproduce the initial issue on my live site as well but did all the following testing in my local staging environment.
Issue: As long as I stick with the current theme, the Customizer works just fine. However, as soon as I switch to another theme, the customizer stops working. It only shows a blank page in the live preview and no options in the left-side menu bar.
Here is what I have tried/found so far:
- WordPress is on version 6.1.1
- Issue occurs in Chrome, Brave and Firefox browsers (haven't tried any other)
- Issue occurs on PHP 7.4, 8.0 and 8.1 alike
- Cleared all caches
- Deactivated all plugins
- Resaved permalink settings
- The issue also occurs with WordPress standard themes (I tried 2019 and 2021)
- The WordPress Health Check Plugin did not show any issues or errors
- Script Debug did not solve the problem
- Replaced wp-admin and wp-includes files with files from a fresh WP install without effect
- Theme support of current theme (Newspaper by tagdiv) has confirmed that they do not use any elements of the Customizer which could cause this problem
JavaScript console error
Uncaught SyntaxError: Unexpected token '<' ; customize.php:6017
I get the following errors in the PHP error log:
[19-Nov-2022 14:00:13 UTC] PHP Warning: parse_url() expects parameter 1 to be string, array given in […]\wp-includes\media.php on line 5104
[19-Nov-2022 14:00:13 UTC] PHP Stack trace:
[19-Nov-2022 14:00:13 UTC] PHP 1. {main}() […]\wp-admin\customize.php:0
[19-Nov-2022 14:00:13 UTC] PHP 2. do_action() […]\wp-admin\customize.php:292
[19-Nov-2022 14:00:13 UTC] PHP 3. WP_Hook->do_action() […]\wp-includes\plugin.php:517
[19-Nov-2022 14:00:13 UTC] PHP 4. WP_Hook->apply_filters() […]\wp-includes\class-wp-hook.php:332
[19-Nov-2022 14:00:13 UTC] PHP 5. WP_Customize_Manager->customize_pane_settings() […]\wp-includes\class-wp-hook.php:308
[19-Nov-2022 14:00:13 UTC] PHP 6. WP_Customize_Cropped_Image_Control->json() […]\wp-includes\class-wp-customize-manager.php:4985
[19-Nov-2022 14:00:13 UTC] PHP 7. WP_Customize_Cropped_Image_Control->to_json() […]\wp-includes\class-wp-customize-control.php:337
[19-Nov-2022 14:00:13 UTC] PHP 8. WP_Customize_Cropped_Image_Control->to_json() […]\wp-includes\customize\class-wp-customize-cropped-image-control.php:78
[19-Nov-2022 14:00:13 UTC] PHP 9. attachment_url_to_postid() […]\wp-includes\customize\class-wp-customize-upload-control.php:59
[19-Nov-2022 14:00:13 UTC] PHP 10. parse_url() […]\wp-includes\media.php:5104
[19-Nov-2022 14:00:13 UTC] PHP Warning: strpos() expects parameter 1 to be string, array given in […]\wp-includes\media.php on line 5111
[19-Nov-2022 14:00:13 UTC] PHP Stack trace:
[19-Nov-2022 14:00:13 UTC] PHP 1. {main}() […]\wp-admin\customize.php:0
[19-Nov-2022 14:00:13 UTC] PHP 2. do_action() […]\wp-admin\customize.php:292
[19-Nov-2022 14:00:13 UTC] PHP 3. WP_Hook->do_action() […]\wp-includes\plugin.php:517
[19-Nov-2022 14:00:13 UTC] PHP 4. WP_Hook->apply_filters() […]\wp-includes\class-wp-hook.php:332
[19-Nov-2022 14:00:13 UTC] PHP 5. WP_Customize_Manager->customize_pane_settings() […]\wp-includes\class-wp-hook.php:308
[19-Nov-2022 14:00:13 UTC] PHP 6. WP_Customize_Cropped_Image_Control->json() […]\wp-includes\class-wp-customize-manager.php:4985
[19-Nov-2022 14:00:13 UTC] PHP 7. WP_Customize_Cropped_Image_Control->to_json() […]\wp-includes\class-wp-customize-control.php:337
[19-Nov-2022 14:00:13 UTC] PHP 8. WP_Customize_Cropped_Image_Control->to_json() […]\wp-includes\customize\class-wp-customize-cropped-image-control.php:78
[19-Nov-2022 14:00:13 UTC] PHP 9. attachment_url_to_postid() […]\wp-includes\customize\class-wp-customize-upload-control.php:59
[19-Nov-2022 14:00:13 UTC] PHP 10. strpos() […]\wp-includes\media.php:5111
[19-Nov-2022 14:00:13 UTC] PHP Notice: Function wpdb::prepare was called <strong>incorrectly</strong>. Unsupported value type (array). Please see <a href="https://wordpress.org/support/article/debugging-in-wordpress/">Debugging in WordPress</a> for more information. (This message was added in version 4.8.2.) in […]\wp-includes\functions.php on line 5835
[19-Nov-2022 14:00:13 UTC] PHP Stack trace:
[19-Nov-2022 14:00:13 UTC] PHP 1. {main}() […]\wp-admin\customize.php:0
[19-Nov-2022 14:00:13 UTC] PHP 2. do_action() […]\wp-admin\customize.php:292
[19-Nov-2022 14:00:13 UTC] PHP 3. WP_Hook->do_action() […]\wp-includes\plugin.php:517
[19-Nov-2022 14:00:13 UTC] PHP 4. WP_Hook->apply_filters() […]\wp-includes\class-wp-hook.php:332
[19-Nov-2022 14:00:13 UTC] PHP 5. WP_Customize_Manager->customize_pane_settings() […]\wp-includes\class-wp-hook.php:308
[19-Nov-2022 14:00:13 UTC] PHP 6. WP_Customize_Cropped_Image_Control->json() […]\wp-includes\class-wp-customize-manager.php:4985
[19-Nov-2022 14:00:13 UTC] PHP 7. WP_Customize_Cropped_Image_Control->to_json() […]\wp-includes\class-wp-customize-control.php:337
[19-Nov-2022 14:00:13 UTC] PHP 8. WP_Customize_Cropped_Image_Control->to_json() […]\wp-includes\customize\class-wp-customize-cropped-image-control.php:78
[19-Nov-2022 14:00:13 UTC] PHP 9. attachment_url_to_postid() […]\wp-includes\customize\class-wp-customize-upload-control.php:59
[19-Nov-2022 14:00:13 UTC] PHP 10. wpdb->prepare() […]\wp-includes\media.php:5116
[19-Nov-2022 14:00:13 UTC] PHP 11. _doing_it_wrong() […]\wp-includes\class-wpdb.php:1453
[19-Nov-2022 14:00:13 UTC] PHP 12. trigger_error() […]\wp-includes\functions.php:5835
[19-Nov-2022 14:00:13 UTC] PHP Notice: Function wpdb::prepare was called <strong>incorrectly</strong>. The query only expected one placeholder, but an array of multiple placeholders was sent. Please see <a href="https://wordpress.org/support/article/debugging-in-wordpress/">Debugging in WordPress</a> for more information. (This message was added in version 4.9.0.) in […]\wp-includes\functions.php on line 5835
[19-Nov-2022 14:00:13 UTC] PHP Stack trace:
[19-Nov-2022 14:00:13 UTC] PHP 1. {main}() […]\wp-admin\customize.php:0
[19-Nov-2022 14:00:13 UTC] PHP 2. do_action() […]\wp-admin\customize.php:292
[19-Nov-2022 14:00:13 UTC] PHP 3. WP_Hook->do_action() […]\wp-includes\plugin.php:517
[19-Nov-2022 14:00:13 UTC] PHP 4. WP_Hook->apply_filters() […]\wp-includes\class-wp-hook.php:332
[19-Nov-2022 14:00:13 UTC] PHP 5. WP_Customize_Manager->customize_pane_settings() […]\wp-includes\class-wp-hook.php:308
[19-Nov-2022 14:00:13 UTC] PHP 6. WP_Customize_Cropped_Image_Control->json() […]\wp-includes\class-wp-customize-manager.php:4985
[19-Nov-2022 14:00:13 UTC] PHP 7. WP_Customize_Cropped_Image_Control->to_json() […]\wp-includes\class-wp-customize-control.php:337
[19-Nov-2022 14:00:13 UTC] PHP 8. WP_Customize_Cropped_Image_Control->to_json() […]\wp-includes\customize\class-wp-customize-cropped-image-control.php:78
[19-Nov-2022 14:00:13 UTC] PHP 9. attachment_url_to_postid() […]\wp-includes\customize\class-wp-customize-upload-control.php:59
[19-Nov-2022 14:00:13 UTC] PHP 10. wpdb->prepare() […]\wp-includes\media.php:5116
[19-Nov-2022 14:00:13 UTC] PHP 11. _doing_it_wrong() […]\wp-includes\class-wpdb.php:1496
[19-Nov-2022 14:00:13 UTC] PHP 12. trigger_error() […]\wp-includes\functions.php:5835
Unfortunately, I cannot make sense of it myself. Hence, any ideas on where to look further would be greatly appreciated. Thank you so much!