Skip to content

Instantly share code, notes, and snippets.

@Jehu
Last active June 11, 2024 17:05
Show Gist options
  • Save Jehu/1cafcbd770a8a6ef2bb0ee92d8f717b8 to your computer and use it in GitHub Desktop.
Save Jehu/1cafcbd770a8a6ef2bb0ee92d8f717b8 to your computer and use it in GitHub Desktop.
wp-cli Bricks Code Signing
<?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