@@ -421,6 +421,7 @@ public function translateCategory(
421421 if ( $ fieldType == 'craft\ckeditor\Field ' ) {
422422 $ fieldValue = $ entry ->getFieldValue ( $ fieldHandle );
423423 $ entry_value = $ fieldValue !== null ? $ fieldValue ->getRawContent () : $ fieldValue ;
424+ $ entry_value = $ this ->fixAssets ($ entry_value );
424425 } else {
425426 $ entry_value = $ entry ->getFieldValue ( $ fieldHandle );
426427 }
@@ -604,6 +605,7 @@ public function translateAsset(
604605 if ( $ fieldType == 'craft\ckeditor\Field ' ) {
605606 $ fieldValue = $ entry ->getFieldValue ( $ fieldHandle );
606607 $ entry_value = $ fieldValue !== null ? $ fieldValue ->getRawContent () : $ fieldValue ;
608+ $ entry_value = $ this ->fixAssets ($ entry_value );
607609 } else {
608610 $ entry_value = $ entry ->getFieldValue ( $ fieldHandle );
609611 }
@@ -776,6 +778,7 @@ public function translateProduct(
776778 if ( $ fieldType == 'craft\ckeditor\Field ' ) {
777779 $ fieldValue = $ entry ->getFieldValue ( $ fieldHandle );
778780 $ entry_value = $ fieldValue !== null ? $ fieldValue ->getRawContent () : $ fieldValue ;
781+ $ entry_value = $ this ->fixAssets ($ entry_value );
779782 } else {
780783 $ entry_value = $ entry ->getFieldValue ( $ fieldHandle );
781784 }
@@ -976,6 +979,7 @@ public function translateEntry(
976979 if ( $ fieldType == 'craft\ckeditor\Field ' ) {
977980 $ fieldValue = $ entry ->getFieldValue ( $ fieldHandle );
978981 $ entry_value = $ fieldValue !== null ? $ fieldValue ->getRawContent () : $ fieldValue ;
982+ $ entry_value = $ this ->fixAssets ($ entry_value );
979983 } else {
980984 $ entry_value = $ entry ->getFieldValue ( $ fieldHandle );
981985 }
@@ -1150,7 +1154,7 @@ public function processMatrixFields( string $lang, Element $entry_from, int $tra
11501154 if ( in_array ( $ fieldType , static ::$ textFields ) && $ processField && ! $ or_entry ) {
11511155 if ( $ fieldType == 'craft\ckeditor\Field ' ) {
11521156 $ fieldValue = $ entry_from ->getFieldValue ( $ field ->handle );
1153- $ originalFieldValue = $ field ->serializeValue ( $ fieldValue !== null ? $ fieldValue ->getRawContent () : $ fieldValue , $ entry_from );
1157+ $ originalFieldValue = $ field ->serializeValue ( $ fieldValue !== null ? $ this -> fixAssets ( $ fieldValue ->getRawContent () ) : $ fieldValue , $ entry_from );
11541158 } else {
11551159 $ originalFieldValue = $ field ->serializeValue ( $ entry_from ->getFieldValue ( $ field ->handle ), $ entry_from );
11561160 }
@@ -1866,6 +1870,16 @@ private function getHtmlTags( $text ): array {
18661870 return array_unique ( $ matches [1 ] );
18671871 }
18681872
1873+ private function fixAssets ($ text ): string {
1874+ return preg_replace_callback (
1875+ '/\{asset:\d+:url\|\|(.*?)\}/ ' ,
1876+ function ($ matches ) {
1877+ return $ matches [1 ];
1878+ },
1879+ $ text
1880+ );
1881+ }
1882+
18691883 private function saveElement ( $ element ): bool {
18701884 /** @var SettingsModel $settings */
18711885 $ settings = BuddyPlugin::getInstance ()->getSettings ();
@@ -1905,7 +1919,11 @@ public static function isCommerceInstalled(): bool {
19051919 }
19061920
19071921 public function saveExcludeBulkSites ( $ element ): void {
1908- $ params = Craft::$ app ->request ->post ();
1922+ $ request = Craft::$ app ->getRequest ();
1923+ if (!($ request instanceof \craft \web \Request)) {
1924+ return ;
1925+ }
1926+ $ params = $ request ->post ();
19091927 if (isset ($ params ['elementId ' ]) && $ params ['elementId ' ] == $ element ->id ) {
19101928 Craft::info ( 'saveExcludeBulkSites ' , 'content-buddy ' );
19111929 Craft::info ( $ params , 'content-buddy ' );
0 commit comments