Automattic\WooCommerce\Admin\Features
LaunchYourStore::maybe_track_template_change
Track when coming soon template is changed.
Метод класса: LaunchYourStore{}
Хуков нет.
Возвращает
null. Ничего (null).
Использование
$LaunchYourStore = new LaunchYourStore(); $LaunchYourStore->maybe_track_template_change( $post_id, $post, $update );
- $post_id(int) (обязательный)
- The post ID.
- $post(WP_Post) (обязательный)
- The post object.
- $update(true|false) (обязательный)
- Whether the post is being updated.
Код LaunchYourStore::maybe_track_template_change() LaunchYourStore::maybe track template change WC 10.4.3
public function maybe_track_template_change( $post_id, $post, $update ) {
if ( ! $post instanceof \WP_Post || ! isset( $post->post_name, $post->post_title ) ) {
return;
}
// Check multiple fields to avoid false matches with non-WooCommerce templates.
if ( 'coming-soon' === $post->post_name && 'Page: Coming soon' === $post->post_title ) {
$matches = array();
$content = $post->post_content;
preg_match( '/"comingSoonPatternId":"([^"]+)"/', $content, $matches );
if ( isset( $matches[1] ) ) {
wc_admin_record_tracks_event(
'coming_soon_template_saved',
array(
'pattern_id' => $matches[1],
'is_update' => $update,
)
);
}
}
}