Skip to content

Commit

Permalink
Added support for import of more plugin configurations
Browse files Browse the repository at this point in the history
  • Loading branch information
TorbenLundsgaard committed Aug 21, 2023
1 parent 676a690 commit 1a1d2b7
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion build/admin/wizard.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('lodash', 'react', 'wp-api-fetch', 'wp-components', 'wp-element', 'wp-i18n'), 'version' => '66718e0acb5a9e6c03f7');
<?php return array('dependencies' => array('lodash', 'react', 'wp-api-fetch', 'wp-components', 'wp-element', 'wp-i18n'), 'version' => '3936f8b956d5be2badb3');
2 changes: 1 addition & 1 deletion build/admin/wizard.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ Yes! Pagespeed is one of our main focus points, and we strive to make the plugin
= 1.X =

Enhancements:
* Added support for import of more plugin configurations

Bugfixes:

Expand Down
8 changes: 4 additions & 4 deletions src/Installation/PluginDataImport.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function get_all(): array {
foreach ( $plugins as $plugin ) {
$settings = $this->get( $plugin );
if ( ! empty( $settings ) ) {
$pluginData[ $plugin ] = $settings;
$pluginData['import_data'][ $plugin ] = $settings;
$pluginData['import_available'] = true;
}
}
Expand Down Expand Up @@ -73,6 +73,7 @@ private function get_gtm4wp(): array {
}

return [
'name' => 'GTM4WP',
'general' => [
'gtm_id' => $options['gtm-code'] ?? '',
'datalayer_name' => $options['gtm-datalayer-variable-name'] ?? '',
Expand Down Expand Up @@ -117,6 +118,7 @@ private function get_gtm_for_woocommerce(): array {
}

return [
'name' => 'GTM for WooCommerce',
'general' => [
'gtm_id' => $this->extract_container_id( get_option( 'gtm_ecommerce_woo_gtm_snippet_head', '' ) ),
],
Expand All @@ -137,11 +139,9 @@ private function get_gtm_for_woocommerce(): array {
private function extract_container_id( string $container_script ): string {
$container_id = '';

if (preg_match("/'GTM-\w+'/i", $$container_script, $matches)) {
// Remove the single quotes around the ID
if (preg_match("/'GTM-\w+'/im", $container_script, $matches)) {
$container_id = trim($matches[0], "'");
}

return $container_id;
}

Expand Down

0 comments on commit 1a1d2b7

Please # to comment.