-
Notifications
You must be signed in to change notification settings - Fork 216
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
86 changed files
with
3,153 additions
and
925 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?php | ||
|
||
namespace WP_Rocket\Engine\Optimization\RUCSS\Context; | ||
|
||
use WP_Rocket\Admin\Options_Data; | ||
use WP_Rocket\Engine\Common\Context\AbstractContext; | ||
use WP_Rocket\Engine\Optimization\RUCSS\Controller\Filesystem; | ||
|
||
class RUCSSContext extends AbstractContext { | ||
|
||
|
||
|
||
/** | ||
* Filesystem instance | ||
* | ||
* @var Filesystem | ||
*/ | ||
protected $filesystem; | ||
|
||
/** | ||
* Instantiate the class. | ||
* | ||
* @param Options_Data $options Options. | ||
* @param Filesystem $filesystem Filesystem instance. | ||
*/ | ||
public function __construct( Options_Data $options, Filesystem $filesystem ) { | ||
parent::__construct( $options ); | ||
$this->filesystem = $filesystem; | ||
} | ||
|
||
|
||
/** | ||
* Check if the operation is allowed. | ||
* | ||
* @param array $data Data to provide to the context. | ||
* @return bool | ||
*/ | ||
public function is_allowed( array $data = [] ): bool { | ||
$is_allowed = $this->run_common_checks( | ||
[ | ||
'do_not_optimize' => false, | ||
'bypass' => false, | ||
'option' => 'remove_unused_css', | ||
'password_protected' => false, | ||
'post_excluded' => 'remove_unused_css', | ||
'logged_in' => false, | ||
] | ||
); | ||
|
||
if ( ! $is_allowed ) { | ||
return false; | ||
} | ||
|
||
return $this->filesystem->is_writable_folder(); | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
inc/Engine/Optimization/RUCSS/Context/RUCSSOptimizeContext.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
|
||
namespace WP_Rocket\Engine\Optimization\RUCSS\Context; | ||
|
||
use WP_Rocket\Engine\Common\Context\AbstractContext; | ||
|
||
class RUCSSOptimizeContext extends AbstractContext { | ||
|
||
/** | ||
* Check if the operation is allowed. | ||
* | ||
* @param array $data Data to provide to the context. | ||
* @return bool | ||
*/ | ||
public function is_allowed( array $data = [] ): bool { | ||
$is_allowed = $this->run_common_checks( | ||
[ | ||
'bypass' => false, | ||
'option' => 'remove_unused_css', | ||
'post_excluded' => 'remove_unused_css', | ||
] | ||
); | ||
|
||
if ( 'local' === wp_get_environment_type() ) { | ||
return false; | ||
} | ||
|
||
if ( ! current_user_can( 'rocket_remove_unused_css' ) ) { | ||
return false; | ||
} | ||
|
||
if ( is_admin() ) { | ||
return false; | ||
} | ||
|
||
if ( ! $is_allowed ) { | ||
return false; | ||
} | ||
|
||
if ( ! rocket_can_display_options() ) { | ||
return false; | ||
} | ||
|
||
return true; | ||
} | ||
} |
Oops, something went wrong.