cameronterry / dark-matter

A highly opinionated domain mapping plugin for WordPress Networks
Other
12 stars 2 forks source link

Media domain support for switch_to_blog() #97

Closed cameronterry closed 2 years ago

cameronterry commented 2 years ago

A rethink of the DM_Media to get it working with switch_to_blog(). Media domains functionality is now more aware of the context switches and now has the capability to retrieve settings on a per site basis and recall them when needed.

Also DarkMatter_Domains no longer has a hard requirement for the DM_NETWORK_MEDIA constant to be the only way to hard-code the media domains. Using DarkMatter_Domains::instance()->network_media property now affords the opportunity for more sophisticated logic to be applied - for example: someone could theoretically group sites together and serve them on a specific set of CDN domains for media assets. This is now easier to achieve that running the risk of accidentally defining the DM_NETWORK_MEDIA constant more than once.

This PR resolves the following unit test errors / warnings:

1) MappingDomainsTest::test_attachment_src
Failed asserting that false is not false.

/home/runner/work/dark-matter/dark-matter/tests/phpunit/domain-mapping/MappingDomainsTest.php:121

2) MappingDomainsTest::test_feature_image
Failed asserting that false is not false.

/home/runner/work/dark-matter/dark-matter/tests/phpunit/domain-mapping/MappingDomainsTest.php:148

Fixes: https://github.com/cameronterry/dark-matter/issues/91