| @@ -92,9 +92,12 @@ | ||
| 92 | 92 | $csstidy->set_cfg( 'timestamp', false ); |
| 93 | 93 | $csstidy->set_cfg( 'template', 'highest' ); |
| 94 | 94 | |
| 95 | 95 | $csstidy->parse( $css ); |
| 96 | - return $csstidy->print->plain(); | |
| 96 | + $css = $csstidy->print->plain(); | |
| 97 | + | |
| 98 | + // Remove all CSS comments from the minified CSS code, as CSSTidy does not remove those inside a CSS selector. | |
| 99 | + return preg_replace( '!/\*[^*]*\*+([^/][^*]*\*+)*/\n?!', '', $css ); | |
| 97 | 100 | } |
| 98 | 101 | |
| 99 | 102 | /** |
| 100 | 103 | * Get the location (file path or URL) of the "Custom CSS" file, depending on whether it's a Multisite install or not. |
| @@ -243,9 +246,9 @@ | ||
| 243 | 246 | /* |
| 244 | 247 | * Do we have credentials already? (Otherwise the form will have been rendered, which is not supported here.) |
| 245 | 248 | * Or, if we have credentials, are they valid? |
| 246 | 249 | */ |
| 247 | - if ( false === $credentials || ! WP_Filesystem( $credentials ) ) { // @phpstan-ignore-line | |
| 250 | + if ( false === $credentials || ! WP_Filesystem( $credentials ) ) { // @phpstan-ignore argument.type | |
| 248 | 251 | ob_end_clean(); |
| 249 | 252 | return false; |
| 250 | 253 | } |
| 251 | 254 | |
| @@ -275,18 +278,18 @@ | ||
| 275 | 278 | $credentials = request_filesystem_credentials( '', '', false, '', null, false ); |
| 276 | 279 | // Do we have credentials already? Otherwise the form will have been rendered already. |
| 277 | 280 | if ( false === $credentials ) { |
| 278 | 281 | $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 | |
| 282 | + $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 | 283 | return $form_data; |
| 281 | 284 | } |
| 282 | 285 | |
| 283 | 286 | // We have received credentials, but don't know if they are valid yet. |
| 284 | - if ( ! WP_Filesystem( $credentials ) ) { // @phpstan-ignore-line | |
| 287 | + if ( ! WP_Filesystem( $credentials ) ) { // @phpstan-ignore argument.type | |
| 285 | 288 | // Credentials failed, so ask again (with $error flag true). |
| 286 | 289 | request_filesystem_credentials( '', '', true, '', null, false ); |
| 287 | 290 | $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 | |
| 291 | + $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 | 292 | return $form_data; |
| 290 | 293 | } |
| 291 | 294 | |
| 292 | 295 | // We have valid access to the filesystem now -> try to save the files, or delete them if the "Custom CSS" is empty. |
| @@ -325,14 +328,8 @@ | ||
| 325 | 328 | |
| 326 | 329 | $default_css_minified = $this->load_default_css_from_file( false ); |
| 327 | 330 | if ( false === $default_css_minified ) { |
| 328 | 331 | $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 | 332 | } |
| 336 | 333 | $file_content = array( |
| 337 | 334 | 'normal' => $custom_css_normal, |
| 338 | 335 | 'minified' => $custom_css_minified, |
| @@ -374,9 +371,9 @@ | ||
| 374 | 371 | /* |
| 375 | 372 | * Do we have credentials already? (Otherwise the form will have been rendered, which is not supported here.) |
| 376 | 373 | * Or, if we have credentials, are they valid? |
| 377 | 374 | */ |
| 378 | - if ( false === $credentials || ! WP_Filesystem( $credentials ) ) { // @phpstan-ignore-line | |
| 375 | + if ( false === $credentials || ! WP_Filesystem( $credentials ) ) { // @phpstan-ignore argument.type | |
| 379 | 376 | ob_end_clean(); |
| 380 | 377 | return false; |
| 381 | 378 | } |
| 382 | 379 | |
| @@ -446,9 +443,9 @@ | ||
| 446 | 443 | w3tc_minify_flush(); |
| 447 | 444 | } |
| 448 | 445 | // WP Fastest Cache. |
| 449 | 446 | if ( isset( $GLOBALS['wp_fastest_cache'] ) && is_callable( array( $GLOBALS['wp_fastest_cache'], 'deleteCache' ) ) ) { |
| 450 | - $GLOBALS['wp_fastest_cache']->deleteCache( true ); // @phpstan-ignore-line | |
| 447 | + $GLOBALS['wp_fastest_cache']->deleteCache( true ); // @phpstan-ignore method.nonObject | |
| 451 | 448 | } |
| 452 | 449 | } |
| 453 | 450 | |
| 454 | 451 | } // class TablePress_CSS |