← All changes
|
vendor/automattic/jetpack-composer-plugin/src/class-plugin.php
+15
-0
3.3.6
→
3.3.8
View file →
| @@ -105,8 +105,9 @@ | ||
| 105 | 105 | $data = array( |
| 106 | 106 | 'domain' => $todomain, |
| 107 | 107 | 'type' => $totype, |
| 108 | 108 | 'packages' => array(), |
| 109 | + 'paths' => array(), | |
| 109 | 110 | ); |
| 110 | 111 | foreach ( $composer->getRepositoryManager()->getLocalRepository()->getCanonicalPackages() as $package ) { |
| 111 | 112 | if ( $package->getType() !== 'jetpack-library' ) { |
| 112 | 113 | continue; |
| @@ -127,8 +128,21 @@ | ||
| 127 | 128 | |
| 128 | 129 | $extra = $package->getExtra(); |
| 129 | 130 | if ( empty( $extra['textdomain'] ) ) { |
| 130 | 131 | $io->info( " {$package->getName()} ($ver): no textdomain set" ); |
| 132 | + } elseif ( $extra['textdomain'] === $todomain ) { | |
| 133 | + // Nothing to alias: the package's strings are already in the | |
| 134 | + // plugin's domain, and emitting a self-alias would make | |
| 135 | + // Assets::filter_gettext() recurse infinitely on any | |
| 136 | + // untranslated string in it. The path is still needed — it is | |
| 137 | + // the prefix WordPress hashes to name the package's JavaScript | |
| 138 | + // translation files — so it goes in `paths`, which registers | |
| 139 | + // only that. | |
| 140 | + $data['paths'][ $extra['textdomain'] ] = array( | |
| 141 | + 'path' => 'jetpack_vendor/' . $package->getPrettyName(), | |
| 142 | + 'ver' => $ver, | |
| 143 | + ); | |
| 144 | + $io->info( " {$package->getName()} ($ver): textdomain {$extra['textdomain']} matches the plugin domain, recording its path without an alias" ); | |
| 131 | 145 | } else { |
| 132 | 146 | $data['packages'][ $extra['textdomain'] ] = array( |
| 133 | 147 | 'path' => 'jetpack_vendor/' . $package->getPrettyName(), |
| 134 | 148 | 'ver' => $ver, |
| @@ -137,8 +151,9 @@ | ||
| 137 | 151 | } |
| 138 | 152 | } |
| 139 | 153 | |
| 140 | 154 | ksort( $data['packages'] ); |
| 155 | + ksort( $data['paths'] ); | |
| 141 | 156 | |
| 142 | 157 | $code = "<?php\n"; |
| 143 | 158 | $code .= "// i18n-map.php @generated by automattic/jetpack-composer-plugin\n"; |
| 144 | 159 | // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_var_export |