Enqueuing the CSS script only if query string contains a print parameter and making the CSS always apply

This commit is contained in:
Eric van der Vlist 2025-03-26 12:23:53 +01:00
parent 8d41dcf22c
commit c01b4a7ad6
2 changed files with 6 additions and 3 deletions

View File

@ -1,4 +1,3 @@
@media print {
video,
.attached-videos,
@ -25,4 +24,3 @@ footer,
}

View File

@ -11,7 +11,12 @@ if ( ! defined( 'WPINC' ) ) {
add_action('wp_enqueue_scripts', 'wpdfh_enqueue_scripts');
function wpdfh_enqueue_scripts() {
if (array_key_exists('print', $_GET)) {
wp_enqueue_style( 'wpdfh', plugin_dir_url( __FILE__ ) . 'assets/wp-pdf-helper.css' );
}
}
#error_log("PHP: parse_url($url, PHP_URL_QUERY): ".print_r(parse_url($url, PHP_URL_QUERY), true), 0);
#error_log('PHP: $_GET: '.print_r($_GET, true), 0);