PluginProbe
Easy Invoice – Invoice Generator, PDF Quotes & Payments / 2.4.2
Easy Invoice – Invoice Generator, PDF Quotes & Payments v2.4.2
2.4.3 2.4.4 2.4.2 2.4.0 2.4.1 2.3.8 2.3.7 2.3.6 2.3.5 2.3.4 2.3.3 2.3.2 2.3.1 2.2.0 2.1.21 2.1.20 2.1.19 2.1.18 2.1.0 2.1.1 2.1.10 2.1.11 2.1.12 2.1.13 2.1.14 All 60 releases
← All changes | includes/Services/PdfRenderer.php +7 -24 2.4.4 → 2.4.2 View file →
@@ -372,12 +372,10 @@
372 372 . '<body class="easy-invoice-pdf easy-invoice-pdf--design' . ( $has_canvas ? ' easy-invoice-pdf--canvas' : '' ) . '"><div class="' . esc_attr( $type ) . '-content">'
373 373 . $body . $extra . $after . '</div></body></html>';
374 374
375 375 // Resolved over the whole document so the compat sheet can refer to the
376 - // design's own palette (its :root block lives in the body). The compat
377 - // sheet's own :root wins: it sits in the head, so document order would
378 - // otherwise hand every variable back to the design.
379 - $html = self::resolveCssVariables( $html, self::rootVariables( $compat ) );
376 + // design's own palette (its :root block lives in the body).
377 + $html = self::resolveCssVariables( $html );
380 378
381 379 /**
382 380 * Filter the complete HTML of a design-based PDF before dompdf sees it.
383 381 *
@@ -395,18 +393,14 @@
395 393 *
396 394 * @param string $html Markup with inline <style> blocks.
397 395 * @return string
398 396 */
399 - /**
400 - * The custom properties declared in every `:root` block of a stylesheet or
401 - * document, last declaration winning.
402 - *
403 - * @param string $css CSS or HTML.
404 - * @return array<string, string>
405 - */
406 - private static function rootVariables( string $css ): array {
397 + public static function resolveCssVariables( string $html ): string {
398 + if ( false === strpos( $html, 'var(--' ) ) {
399 + return $html;
400 + }
407 401 $vars = [];
408 - if ( preg_match_all( '/:root\s*\{([^}]*)\}/', $css, $blocks ) ) {
402 + if ( preg_match_all( '/:root\s*\{([^}]*)\}/', $html, $blocks ) ) {
409 403 foreach ( $blocks[1] as $block ) {
410 404 foreach ( explode( ';', $block ) as $declaration ) {
411 405 if ( preg_match( '/--([a-zA-Z0-9\-_]+)\s*:\s*(.+)$/', trim( $declaration ), $m ) ) {
412 406 $vars[ $m[1] ] = trim( $m[2] );
@@ -412,19 +406,8 @@
412 406 $vars[ $m[1] ] = trim( $m[2] );
413 407 }
414 408 }
415 409 }
416 - }
417 - return $vars;
418 - }
419 -
420 - public static function resolveCssVariables( string $html, array $overrides = [] ): string {
421 - if ( false === strpos( $html, 'var(--' ) ) {
422 - return $html;
423 - }
424 - $vars = self::rootVariables( $html );
425 - foreach ( $overrides as $name => $value ) {
426 - $vars[ $name ] = $value;
427 410 }
428 411 // Values may reference other variables; three passes cover any sane chain.
429 412 for ( $i = 0; $i < 3 && false !== strpos( $html, 'var(--' ); $i++ ) {
430 413 $html = (string) preg_replace_callback(