Skip to content

Commit

Permalink
Merge branch 'develop' into patch-2
Browse files Browse the repository at this point in the history
  • Loading branch information
stklcode committed Nov 23, 2022
2 parents d689922 + 7a6b3b4 commit 86da453
Show file tree
Hide file tree
Showing 17 changed files with 645 additions and 258 deletions.
21 changes: 21 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"extends": "plugin:@wordpress/eslint-plugin/es5",
"env": {
"browser": true,
"jquery": true
},
"globals": {
"Raphael": "readonly",
"getAnchors": "readonly"
},
"rules": {
"camelcase": 0,
"eqeqeq": 0,
"no-mixed-operators": 0,
"no-redeclare": 0,
"no-shadow": 0,
"no-unused-expressions": 0,
"no-unused-vars": 0,
"vars-on-top": 0
}
}
6 changes: 3 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ jobs:
quality:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.0'
tools: composer
- name: Setup Node
uses: actions/setup-node@v2
uses: actions/setup-node@v3
with:
node-version: '14'
node-version: '16'
- name: Code style checks for PHP and CSS
run: |
composer install
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/wordpress-plugin-asset-update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
name: Push to stable
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/wordpress-plugin-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
name: New tag
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
Expand Down
1 change: 0 additions & 1 deletion .stylelintrc.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"extends": "@wordpress/stylelint-config",
"rules": {
"declaration-property-unit-whitelist": null,
"selector-id-pattern": null
}
}
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ All notable changes to this project will be documented in this file. This projec

## unreleased

Requires PHP 5.6 and WordPress 4.7 or above

* Enhance: adjust styling for setup instructions (#215, props timse201)
* Enhance: update hooks for Multisite initialization in WordPress 5.1 and above (#246, props ouun)
* Enhance: rework flush hooks and add some third-party triggers for Autoptimize and WooCommerce (#225, props timse201)


## 2.3.2
Expand Down
20 changes: 16 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"require-dev": {
"dealerdirect/phpcodesniffer-composer-installer": "^v0.7",
"matthiasmullie/minify": "^1.3",
"squizlabs/php_codesniffer": "^3.6",
"squizlabs/php_codesniffer": "^3.7",
"phpcompatibility/phpcompatibility-wp": "^2.1",
"wp-coding-standards/wpcs": "^2.3"
},
Expand All @@ -40,7 +40,9 @@
"@build"
],
"build": [
"minifycss css/dashboard.css > css/dashboard.min.css"
"minifycss css/dashboard.css > css/dashboard.min.css",
"minifycss css/admin-bar-flush.css > css/admin-bar-flush.min.css",
"minifyjs js/admin-bar-flush.js > js/admin-bar-flush.min.js"
],
"cs": [
"@lint-php"
Expand All @@ -50,13 +52,23 @@
],
"lint-all": [
"@lint-php",
"@lint-css"
"@lint-css",
"@lint-js"
],
"lint-css": [
"npx stylelint css/dashboard.css"
"npx stylelint css/dashboard.css css/admin-bar-flush.css"
],
"lint-js": [
"npx eslint js/admin-bar-flush.js"
],
"lint-php": [
"phpcs --standard=phpcs.xml -s"
]
},
"config": {
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true,
"composer/installers": true
}
}
}
67 changes: 67 additions & 0 deletions css/admin-bar-flush.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#wp-admin-bar-cachify .animate-pulse {
animation: cachify-dash-icon-pulse 2s infinite;
animation-timing-function: linear;
}

#wp-admin-bar-cachify .animate-fade {
animation: cachify-dash-icon-fade-in 0.1s;
animation-timing-function: linear;
}

@keyframes cachify-dash-icon-pulse {

0%,
100% {
opacity: 1;
}

50% {
opacity: 0.2;
}
}

@keyframes cachify-dash-icon-fade-in {

from {
opacity: 0;
}

to {
opacity: 1;
}
}

#wp-admin-bar-cachify button.ab-item {
background: none;
border: none;
padding: 0 8px 0 7px;
}

#wp-admin-bar-cachify button.ab-item:hover {
cursor: pointer;
}

#wp-admin-bar-cachify button.ab-item:focus {
outline: none;
}

#wpadminbar #wp-admin-bar-cachify button.ab-item:focus span.ab-label {
color: inherit;
}

#wp-admin-bar-cachify {
display: list-item !important;
}

#wp-admin-bar-cachify .ab-icon {
margin: 0 !important;
}

#wp-admin-bar-cachify .ab-icon::before {
top: 2px;
margin: 0;
}

#wp-admin-bar-cachify .ab-label {
margin: 0 5px;
}
9 changes: 3 additions & 6 deletions inc/cachify.settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,10 @@
<label for="cachify_cache_expires"><?php esc_html_e( 'Cache expiration', 'cachify' ); ?></label>
</th>
<td>
<input type="number" min="0" step="1" name="cachify[cache_expires]" id="cachify_cache_expires" value="<?php echo esc_attr( $options['cache_expires'] ); ?>" class="small-text" />
<?php esc_html_e( 'Hours', 'cachify' ); ?>
<?php if ( self::METHOD_HDD === $options['use_apc'] ) : ?>
<input type="number" min="0" step="1" name="cachify[cache_expires]" id="cachify_cache_expires" value="" disabled="disabled" class="small-text" />
<?php esc_html_e( 'Hours', 'cachify' ); ?>
<p class="description"><?php esc_html_e( 'HDD cache will only expire as you update posts or flush it yourself.', 'cachify' ); ?></p>
<?php else : ?>
<input type="number" min="0" step="1" name="cachify[cache_expires]" id="cachify_cache_expires" value="<?php echo esc_attr( $options['cache_expires'] ); ?>" class="small-text" />
<?php esc_html_e( 'Hours', 'cachify' ); ?>
<p class="description"><?php esc_html_e( 'HDD cache will only expire correctly when triggered by a system cron.', 'cachify' ); ?></p>
<?php endif; ?>

<p class="description">
Expand Down
27 changes: 25 additions & 2 deletions inc/class-cachify-hdd.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,22 @@ public static function is_available() {
return ! empty( $option );
}

/**
* Returns if gzip file creation is enabled
*
* @since 2.4.0
*
* @return bool
*/
public static function is_gzip_enabled() {
/**
* Filter that allows to enable/disable gzip file creation
*
* @param bool $create_gzip_files Whether to create gzip files. Default is `true`
*/
return apply_filters( 'cachify_create_gzip_files', true );
}

/**
* Caching method as string
*
Expand Down Expand Up @@ -168,10 +184,17 @@ private static function _create_files( $data ) {
trigger_error( esc_html( __METHOD__ . ": Unable to create directory {$file_path}.", E_USER_WARNING ) );
return;
}

/* Write to file */
self::_create_file( self::_file_html( $file_path ), $data );
self::_create_file( self::_file_gzip( $file_path ), gzencode( $data, 9 ) );

/**
* Filter that allows to enable/disable gzip file creation
*
* @param bool $create_gzip_files Whether to create gzip files. Default is `true`
*/
if ( self::is_gzip_enabled() ) {
self::_create_file( self::_file_gzip( $file_path ), gzencode( $data, 9 ) );
}
}

/**
Expand Down
Loading

0 comments on commit 86da453

Please sign in to comment.