Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Commit

Permalink
Add upgrader_process_complete to update the pattern content
Browse files Browse the repository at this point in the history
  • Loading branch information
albarin committed Oct 11, 2023
1 parent a030d05 commit 2a7b09b
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/BlockPatterns.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Automattic\WooCommerce\Blocks\Patterns\PatternUpdater;
use Automattic\WooCommerce\Blocks\Verticals\Client;
use Automattic\WooCommerce\Blocks\Verticals\VerticalsSelector;
use WP_Upgrader;

/**
* Registers patterns under the `./patterns/` directory and updates their content.
Expand Down Expand Up @@ -53,6 +54,29 @@ public function __construct( Package $package ) {
add_action( 'init', array( $this, 'register_block_patterns' ) );
add_action( 'update_option_woo_ai_describe_store_description', array( $this, 'schedule_patterns_content_update' ), 10, 2 );
add_action( 'woocommerce_update_patterns_content', array( $this, 'update_patterns_content' ) );

add_action( 'upgrader_process_complete', array( $this, 'refresh_patterns_content_after_plugin_update' ), 10, 2 );
}

/**
* Schedules an action to update the patterns content after plugin update.
*
* @param WP_Upgrader $upgrader_object The upgrader object.
* @param array $extra Array of bulk item update data.
*
* @return void
*/
public function refresh_patterns_content_after_plugin_update( $upgrader_object, $extra ) {
$current_plugin_path_name = plugin_basename( __FILE__ );
error_log( print_r( $current_plugin_path_name, true ) );

Check warning on line 71 in src/BlockPatterns.php

View workflow job for this annotation

GitHub Actions / PHP coding standards

error_log() found. Debug code should not normally be used in production.

Check warning on line 71 in src/BlockPatterns.php

View workflow job for this annotation

GitHub Actions / PHP coding standards

print_r() found. Debug code should not normally be used in production.

// if ( 'update' === $extra['action'] && 'plugin' === $extra['type'] ) {

Check warning on line 73 in src/BlockPatterns.php

View workflow job for this annotation

GitHub Actions / PHP coding standards

This comment is 49% valid code; is this commented out code?
// foreach ( $extra['plugins'] as $plugin ) {
// if ( $plugin === $current_plugin_path_name ) {
// $this->schedule_patterns_content_update( '', get_option( PatternUpdater::WC_BLOCKS_PATTERNS_CONTENT ) );
// }
// }
// }

Check failure on line 79 in src/BlockPatterns.php

View workflow job for this annotation

GitHub Actions / PHP coding standards

Inline comments must end in full-stops, exclamation marks, or question marks
}

/**
Expand Down

0 comments on commit 2a7b09b

Please sign in to comment.