Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 12 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
| Playground_Site_Integrity_Check | |
0.00% |
0 / 10 |
|
0.00% |
0 / 2 |
12 | |
0.00% |
0 / 1 |
| check | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
| check_active_theme | |
0.00% |
0 / 8 |
|
0.00% |
0 / 1 |
6 | |||
| 1 | <?php |
| 2 | /** |
| 3 | * Site Integrity Checker file. |
| 4 | * |
| 5 | * @package wpcomsh |
| 6 | */ |
| 7 | |
| 8 | namespace Imports; |
| 9 | |
| 10 | require_once __DIR__ . '/../utils/class-filerestorer.php'; |
| 11 | require_once __DIR__ . '/../class-backup-import-action.php'; |
| 12 | |
| 13 | use Imports\Utils\FileRestorer; |
| 14 | |
| 15 | /** |
| 16 | * Class Playground_Site_Integrity_Check |
| 17 | * |
| 18 | * The Playground_Site_Integrity_Check class provides a mechanism for checking the integrity of the site. |
| 19 | */ |
| 20 | class Playground_Site_Integrity_Check extends \Imports\Backup_Import_Action { |
| 21 | /** |
| 22 | * Performs a check to verify the integrity of the site. |
| 23 | * |
| 24 | * This method calls the check_active_theme method to ensure that the currently active theme is installed. |
| 25 | * |
| 26 | * @return bool Always returns true. |
| 27 | */ |
| 28 | public function check() { |
| 29 | $this->check_active_theme(); |
| 30 | return true; |
| 31 | } |
| 32 | |
| 33 | /** |
| 34 | * Checks if the currently active theme is installed and installs it if it's not. |
| 35 | * |
| 36 | * @return bool Always returns true. |
| 37 | */ |
| 38 | private function check_active_theme() { |
| 39 | $current_theme_slug = get_stylesheet(); |
| 40 | $this->log( 'Current active theme found:' . $current_theme_slug ); |
| 41 | $theme = wp_get_theme( $current_theme_slug ); |
| 42 | if ( ! $theme->exists() ) { |
| 43 | // The theme is not installed |
| 44 | $this->log( 'Current theme' . $current_theme_slug . ' is not installed. Installing it now.' ); |
| 45 | $result = FileRestorer::install_theme( $current_theme_slug ); |
| 46 | $this->log( 'Install theme result: ' . $result ); |
| 47 | } |
| 48 | |
| 49 | return true; |
| 50 | } |
| 51 | } |