Last active
August 8, 2024 17:55
-
-
Save Jehu/1cafcbd770a8a6ef2bb0ee92d8f717b8 to your computer and use it in GitHub Desktop.
wp-cli Bricks Code Signing - save in mu-plugins folder
This file contains hidden or 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
<?php | |
namespace Bricks; | |
class MWE_BRICKS_SIGN_CODE | |
{ | |
public function __construct() { | |
if (defined('WP_CLI') && WP_CLI) { | |
// https://make.wordpress.org/cli/handbook/references/internal-api/wp-cli-add-command/ | |
\WP_CLI::add_command('bricks', '\Bricks\MWE_BRICKS_SIGN_CODE'); | |
} | |
} | |
public function sign_code() | |
{ | |
// Add option table entry with version & timestamp of last code signature generation | |
update_option(BRICKS_CODE_SIGNATURES_LAST_GENERATED, BRICKS_VERSION); | |
update_option(BRICKS_CODE_SIGNATURES_LAST_GENERATED_TIMESTAMP, time()); | |
$success = Admin::crawl_and_update_code_signatures(); | |
if ($success) { | |
// Regenerate CSS files if 'file' is set | |
if (Database::get_setting('cssLoading') === 'file') { | |
Assets_Files::regenerate_css_files(); | |
} | |
\WP_CLI::log('DONE! Code signatures regenerated successfully.'); | |
} | |
else { | |
\WP_CLI::log('Something went wrong.'); | |
} | |
} | |
} | |
new MWE_BRICKS_SIGN_CODE(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you @mickaelperrin