We have had a couple of reports in the support forum of the following Ads deprecation error:
Deprecated: Creation of dynamic property Google\Site_Kit\Modules\Ads\Web_Tag::$home_domain is deprecated in /home/w4397664/public_html/wp-content/plugins/google-site-kit/includes/Modules/Ads/Web_Tag.php on line 37
Like with many of these errors, it doesn't appear to have an impact in the Site Kit plugin but it's likely something that needs addressing with how we deal with the Ads module.
Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
The deprecation notice mentioned in the issue description should no longer be raised.
Implementation Brief
[ ] In includes/Modules/Ads/Web_Tag.php:
[ ] Use the Core\Tags\Tag_With_Linker_Trait trait.
[ ] Remove the set_home_domain method as it is already identically available in the above trait.
The above should fix the reported issue. However, I see another potential issue with this class. The class accepts a home domain, but doesn't exactly embed this tag config as a linker command in the tag. As it is a simple improvement, the following can be done to solve this:
[ ] In includes/Modules/Ads/Web_Tag.php:
[ ] Add a protected get_tag_config method:
[ ] Call the add_linker_to_tag_config method, passing an empty array to it as a parameter and return its value.
[ ] Update the setup_gtag method:
[ ] Call the get_tag_config method and store its value in a variable named $gtag_opt.
[ ] Add the linker to the GTag similar to how it is done in Modules\Analytics_4\Web_Tag::setup_gtag.
Bug Description
We have had a couple of reports in the support forum of the following Ads deprecation error:
Deprecated: Creation of dynamic property Google\Site_Kit\Modules\Ads\Web_Tag::$home_domain is deprecated in /home/w4397664/public_html/wp-content/plugins/google-site-kit/includes/Modules/Ads/Web_Tag.php on line 37
Like with many of these errors, it doesn't appear to have an impact in the Site Kit plugin but it's likely something that needs addressing with how we deal with the Ads module.
Example support topic: https://wordpress.org/support/topic/deprecated-creation-of-dynamic-property-google/
Steps to reproduce
N/A
Screenshots
Additional Context
Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
Implementation Brief
includes/Modules/Ads/Web_Tag.php
:Core\Tags\Tag_With_Linker_Trait
trait.set_home_domain
method as it is already identically available in the above trait.The above should fix the reported issue. However, I see another potential issue with this class. The class accepts a home domain, but doesn't exactly embed this tag config as a linker command in the tag. As it is a simple improvement, the following can be done to solve this:
includes/Modules/Ads/Web_Tag.php
:get_tag_config
method:add_linker_to_tag_config
method, passing an empty array to it as a parameter and return its value.setup_gtag
method:get_tag_config
method and store its value in a variable named$gtag_opt
.Modules\Analytics_4\Web_Tag::setup_gtag
.Test Coverage
QA Brief
Changelog entry