Skip to content

Fix issue with accessing array offset on boolean value in get_custom_logo_url function#69

Open
umairayub79 wants to merge 1 commit intoimranhsayed:masterfrom
umairayub79:master
Open

Fix issue with accessing array offset on boolean value in get_custom_logo_url function#69
umairayub79 wants to merge 1 commit intoimranhsayed:masterfrom
umairayub79:master

Conversation

@umairayub79
Copy link

@umairayub79 umairayub79 commented Mar 6, 2024

Issue:

I encountered an issue with the get_custom_logo_url function where a warning was triggered due to attempting to access an array offset on a boolean value. This warning occurred on line 139 of the class-header-footer-api.php file in the headless-cms-master plugin. The warning arose because the function did not handle scenarios where the theme either did not support a custom logo or when no logo was set.

<b>Warning</b>: Trying to access array offset on value of type bool in <b>/home/baloch/Local Sites/headless/app/public/wp-content/plugins/headless-cms-master/inc/classes/api/class-header-footer-api.php</b> on line <b>139</b><br />

Additionally, there's an existing issue (#33) titled "Cannot find custom logo" that seems related to the same warning message.

Solution:

To address this issue comprehensively, I made the following improvements:

  • Utilized the has_custom_logo() function to check if the current theme supports a custom logo.
  • Added a check to verify if a custom logo ID exists before attempting to retrieve the custom logo URL.
  • Provided a fallback URL or value if the theme doesn't support a custom logo or if no logo is set.

These changes ensure that the get_custom_logo_url function gracefully handles variations in theme configurations, preventing the warning from being triggered and providing a more robust solution overall.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Comments