← All changes
|
includes/api/class-charitable-api-route-campaign-css.php
+33
-2
1.8.12
→
1.8.13
View file →
| @@ -170,11 +170,34 @@ | ||
| 170 | 170 | |
| 171 | 171 | // Save current working directory. |
| 172 | 172 | $original_cwd = getcwd(); |
| 173 | 173 | |
| 174 | - // Change to the template directory so relative paths in template files work. | |
| 174 | + /* | |
| 175 | + * Change to the template directory. The templates now resolve their shared | |
| 176 | + * helper from their own directory instead of the working directory, so this is | |
| 177 | + * belt and braces for any third-party template that still uses a relative | |
| 178 | + * path. It must not become load-bearing again: if chdir() is disabled or | |
| 179 | + * restricted by open_basedir, a template relying on it fatals and this route | |
| 180 | + * returns a PHP error instead of CSS, which the browser rejects - leaving the | |
| 181 | + * campaign with only the base stylesheet's default colours. | |
| 182 | + */ | |
| 175 | 183 | chdir( dirname( $template_file ) ); |
| 176 | 184 | |
| 185 | + /* | |
| 186 | + * Campaign Hero base CSS, emitted for every template. | |
| 187 | + * | |
| 188 | + * The hero block can be added to a campaign built on any template, but the | |
| 189 | + * bespoke hero CSS lives in partials/beacon-hero.php scoped to the Beacon | |
| 190 | + * wrappers. Without this, a hero on any other template gets an unstyled | |
| 191 | + * `__banner` — which is absolutely positioned and so collapses to zero height, | |
| 192 | + * making the background image invisible. | |
| 193 | + * | |
| 194 | + * Emitted *before* the template so a template's own rules always take | |
| 195 | + * precedence, and every selector in the partial is deliberately one class less | |
| 196 | + * specific than its Beacon counterpart. | |
| 197 | + */ | |
| 198 | + include charitable()->get_path( 'includes' ) . 'css-templates/frontend/partials/campaign-hero-base.php'; | |
| 199 | + | |
| 177 | 200 | // Include the template file - it will output CSS. |
| 178 | 201 | include $template_file; |
| 179 | 202 | |
| 180 | 203 | // Restore original working directory. |
| @@ -238,9 +261,17 @@ | ||
| 238 | 261 | |
| 239 | 262 | // Save current working directory. |
| 240 | 263 | $original_cwd = getcwd(); |
| 241 | 264 | |
| 242 | - // Change to the template directory so relative paths in template files work. | |
| 265 | + /* | |
| 266 | + * Change to the template directory. The templates now resolve their shared | |
| 267 | + * helper from their own directory instead of the working directory, so this is | |
| 268 | + * belt and braces for any third-party template that still uses a relative | |
| 269 | + * path. It must not become load-bearing again: if chdir() is disabled or | |
| 270 | + * restricted by open_basedir, a template relying on it fatals and this route | |
| 271 | + * returns a PHP error instead of CSS, which the browser rejects - leaving the | |
| 272 | + * campaign with only the base stylesheet's default colours. | |
| 273 | + */ | |
| 243 | 274 | chdir( dirname( $template_file ) ); |
| 244 | 275 | |
| 245 | 276 | // Include the template file - it will output CSS. |
| 246 | 277 | include $template_file; |