| @@ -7,8 +7,10 @@ | ||
| 7 | 7 | * @author Tobias Bäthge |
| 8 | 8 | * @since 1.1.0 |
| 9 | 9 | */ |
| 10 | 10 | |
| 11 | +declare(strict_types=1); | |
| 12 | + | |
| 11 | 13 | // Prohibit direct script loading. |
| 12 | 14 | defined( 'ABSPATH' ) || die( 'No direct script access allowed!' ); |
| 13 | 15 | |
| 14 | 16 | /** |
| @@ -92,9 +94,12 @@ | ||
| 92 | 94 | $csstidy->set_cfg( 'timestamp', false ); |
| 93 | 95 | $csstidy->set_cfg( 'template', 'highest' ); |
| 94 | 96 | |
| 95 | 97 | $csstidy->parse( $css ); |
| 96 | - return $csstidy->print->plain(); | |
| 98 | + $css = $csstidy->print->plain(); | |
| 99 | + | |
| 100 | + // Remove all CSS comments from the minified CSS code, as CSSTidy does not remove those inside a CSS selector. | |
| 101 | + return preg_replace( '!/\*[^*]*\*+([^/][^*]*\*+)*/\n?!', '', $css ); | |
| 97 | 102 | } |
| 98 | 103 | |
| 99 | 104 | /** |
| 100 | 105 | * Get the location (file path or URL) of the "Custom CSS" file, depending on whether it's a Multisite install or not. |
| @@ -243,9 +248,9 @@ | ||
| 243 | 248 | /* |
| 244 | 249 | * Do we have credentials already? (Otherwise the form will have been rendered, which is not supported here.) |
| 245 | 250 | * Or, if we have credentials, are they valid? |
| 246 | 251 | */ |
| 247 | - if ( false === $credentials || ! WP_Filesystem( $credentials ) ) { // @phpstan-ignore-line | |
| 252 | + if ( false === $credentials || ! WP_Filesystem( $credentials ) ) { // @phpstan-ignore argument.type | |
| 248 | 253 | ob_end_clean(); |
| 249 | 254 | return false; |
| 250 | 255 | } |
| 251 | 256 | |
| @@ -275,18 +280,18 @@ | ||
| 275 | 280 | $credentials = request_filesystem_credentials( '', '', false, '', null, false ); |
| 276 | 281 | // Do we have credentials already? Otherwise the form will have been rendered already. |
| 277 | 282 | if ( false === $credentials ) { |
| 278 | 283 | $form_data = ob_get_clean(); |
| 279 | - $form_data = str_replace( 'name="upgrade" id="upgrade" class="button"', 'name="upgrade" id="upgrade" class="button button-primary button-large"', $form_data ); // @phpstan-ignore-line | |
| 284 | + $form_data = str_replace( 'name="upgrade" id="upgrade" class="button"', 'name="upgrade" id="upgrade" class="components-button is-primary"', $form_data ); // @phpstan-ignore argument.type | |
| 280 | 285 | return $form_data; |
| 281 | 286 | } |
| 282 | 287 | |
| 283 | 288 | // We have received credentials, but don't know if they are valid yet. |
| 284 | - if ( ! WP_Filesystem( $credentials ) ) { // @phpstan-ignore-line | |
| 289 | + if ( ! WP_Filesystem( $credentials ) ) { // @phpstan-ignore argument.type | |
| 285 | 290 | // Credentials failed, so ask again (with $error flag true). |
| 286 | 291 | request_filesystem_credentials( '', '', true, '', null, false ); |
| 287 | 292 | $form_data = ob_get_clean(); |
| 288 | - $form_data = str_replace( 'name="upgrade" id="upgrade" class="button"', 'name="upgrade" id="upgrade" class="button button-primary button-large"', $form_data ); // @phpstan-ignore-line | |
| 293 | + $form_data = str_replace( 'name="upgrade" id="upgrade" class="button"', 'name="upgrade" id="upgrade" class="components-button is-primary"', $form_data ); // @phpstan-ignore argument.type | |
| 289 | 294 | return $form_data; |
| 290 | 295 | } |
| 291 | 296 | |
| 292 | 297 | // We have valid access to the filesystem now -> try to save the files, or delete them if the "Custom CSS" is empty. |
| @@ -325,14 +330,8 @@ | ||
| 325 | 330 | |
| 326 | 331 | $default_css_minified = $this->load_default_css_from_file( false ); |
| 327 | 332 | if ( false === $default_css_minified ) { |
| 328 | 333 | $default_css_minified = ''; |
| 329 | - } else { | |
| 330 | - // Change relative URLs to web font files to absolute URLs, as combining the CSS files and saving to another directory breaks the relative URLs. | |
| 331 | - $absolute_path = plugins_url( 'css/build/tablepress.', TABLEPRESS__FILE__ ); | |
| 332 | - // Make the absolute URL protocol-relative to prevent mixed content warnings. | |
| 333 | - $absolute_path = str_replace( array( 'http:', 'https:' ), '', $absolute_path ); | |
| 334 | - $default_css_minified = str_replace( 'url(tablepress.', 'url(' . $absolute_path, $default_css_minified ); | |
| 335 | 334 | } |
| 336 | 335 | $file_content = array( |
| 337 | 336 | 'normal' => $custom_css_normal, |
| 338 | 337 | 'minified' => $custom_css_minified, |
| @@ -374,9 +373,9 @@ | ||
| 374 | 373 | /* |
| 375 | 374 | * Do we have credentials already? (Otherwise the form will have been rendered, which is not supported here.) |
| 376 | 375 | * Or, if we have credentials, are they valid? |
| 377 | 376 | */ |
| 378 | - if ( false === $credentials || ! WP_Filesystem( $credentials ) ) { // @phpstan-ignore-line | |
| 377 | + if ( false === $credentials || ! WP_Filesystem( $credentials ) ) { // @phpstan-ignore argument.type | |
| 379 | 378 | ob_end_clean(); |
| 380 | 379 | return false; |
| 381 | 380 | } |
| 382 | 381 | |
| @@ -446,9 +445,9 @@ | ||
| 446 | 445 | w3tc_minify_flush(); |
| 447 | 446 | } |
| 448 | 447 | // WP Fastest Cache. |
| 449 | 448 | if ( isset( $GLOBALS['wp_fastest_cache'] ) && is_callable( array( $GLOBALS['wp_fastest_cache'], 'deleteCache' ) ) ) { |
| 450 | - $GLOBALS['wp_fastest_cache']->deleteCache( true ); // @phpstan-ignore-line | |
| 449 | + $GLOBALS['wp_fastest_cache']->deleteCache( true ); // @phpstan-ignore method.nonObject | |
| 451 | 450 | } |
| 452 | 451 | } |
| 453 | 452 | |
| 454 | 453 | } // class TablePress_CSS |