Plugin Directory

Changeset 2711564


Ignore:
Timestamp:
04/19/2022 12:50:49 PM (4 years ago)
Author:
Supertext
Message:

Sync with GitHub

Location:
polylang-supertext/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • polylang-supertext/trunk/plugin.php

    r2675218 r2711564  
    77Domain Path: /resources/languages
    88Author: Supertext AG
    9 Version: 4.09
     9Version: 4.11
    1010Author URI: http://www.supertext.ch
    1111License: GPLv2 or later
    1212*/
    1313
    14 define('SUPERTEXT_PLUGIN_VERSION', '4.09');
     14define('SUPERTEXT_PLUGIN_VERSION', '4.11');
    1515define('SUPERTEXT_PLUGIN_REVISION', 46);
    1616define('SUPERTEXT_BASE_PATH', __DIR__);
  • polylang-supertext/trunk/readme.txt

    r2675218 r2711564  
    110110== Changelog ==
    111111
     112= 4.11 =
     113* Skip checking for translated post IDs for proofreading orders
     114
     115= 4.10 =
     116* Use Wordpress standard functions to serialize Gutenberg blocks.
     117
    112118= 4.09 =
    113119* Add basic support for ACF Gutenberg blocks that contain text in the data object.
  • polylang-supertext/trunk/src/Supertext/Api/WriteBack.php

    r2520480 r2711564  
    5858  {
    5959    $sourcePostIds = $this->getSourcePostIds();
     60    $orderType = $this->getOrderType();
    6061
    6162    $referenceData = hex2bin(Constant::REFERENCE_BITMASK);
    6263    foreach ($sourcePostIds as $sourcePostId) {
    63       $targetPostId = $this->library->getMultilang()->getPostInLanguage($sourcePostId, $this->getTargetLanguageCode());
     64      if('translation' == $orderType) {
     65        $targetPostId = $this->library->getMultilang()->getPostInLanguage($sourcePostId, $this->getTargetLanguageCode());
     66      } else {
     67        $targetPostId = $sourcePostId;
     68      }
    6469      $writeBackMeta = $this->getWriteBackMeta($targetPostId);
    6570      $referenceHash = $writeBackMeta->getReferenceHash();
  • polylang-supertext/trunk/src/Supertext/Backend/CallbackHandler.php

    r2520480 r2711564  
    102102    $errors = array();
    103103    $contentData = $writeBack->getContentData();
     104    $orderType = $writeBack->getOrderType();
    104105
    105106    foreach ($writeBack->getSourcePostIds() as $sourcePostId) {
    106       $targetPostId = $this->library->getMultilang()->getPostInLanguage($sourcePostId, $writeBack->getTargetLanguageCode());
     107      if('translation' == $orderType) {
     108        $targetPostId = $this->library->getMultilang()->getPostInLanguage($sourcePostId, $writeBack->getTargetLanguageCode());
     109      } else {
     110        $targetPostId = $sourcePostId;
     111      }
    107112
    108113      if ($targetPostId == null) {
  • polylang-supertext/trunk/src/Supertext/TextAccessors/PostTextAccessor.php

    r2520480 r2711564  
    122122
    123123      if (isset($texts['post_content_block_attributes'])) {
    124         $decodedContent = $this->setTranslatableBlockAttributes($texts['post_content_block_attributes'], parse_blocks($decodedContent), $decodedContent);
    125       }
    126 
     124        $newBlocks = $this->setTranslatableBlockAttributes($texts['post_content_block_attributes'], parse_blocks($decodedContent));
     125        $decodedContent = serialize_blocks($newBlocks);
     126      }
    127127      $post->post_content = $this->textProcessor->replaceShortcodeNodes($decodedContent);
    128128    }
     
    180180      }
    181181
    182       $blockAttributesTexts[$key] = $value;
     182      $blockAttributesTexts[$key] = $this->textProcessor->replaceShortcodes($value);
    183183    }
    184184
     
    186186  }
    187187
    188   private function setTranslatableBlockAttributes($blockAttributes, $blocks, $content)
    189   {
    190     $newContent = $content;
     188  private function setTranslatableBlockAttributes($blockAttributes, $blocks)
     189  {
     190    $newBlocks = array();
    191191
    192192    foreach ($blocks as $index => $block) {
    193193      if (!isset($blockAttributes[$index])) {
    194         continue;
    195       }
    196 
    197       $blockName = str_replace('/', '\/', str_replace('core/', '', $block['blockName']));
     194        array_push($newBlocks, $block);
     195        continue;
     196      }
    198197
    199198      if (isset($blockAttributes[$index]['inner-blocks'])) {
    200         $newContent = $this->setTranslatableBlockAttributes($blockAttributes[$index]['inner-blocks'], $block['innerBlocks'], $newContent);
     199        $block['innerBlocks'] = $this->setTranslatableBlockAttributes($blockAttributes[$index]['inner-blocks'], $block['innerBlocks']);
    201200      }
    202201
    203202      foreach ($blockAttributes[$index]['attrs'] as $key => $value) {
    204         $oldValue = $block['attrs'][$key];
    205         $regex = "/(<!--\s*wp:$blockName\s*{.*\"$key\"\s*:\s*)\"$oldValue\"/";
    206         $newContent = preg_replace($regex, "$1\"$value\"", $newContent);
    207       }
    208     }
    209 
    210     return $newContent;
     203        $block['attrs'][$key] = $this->textProcessor->replaceShortcodeNodes($value);
     204      }
     205
     206      array_push($newBlocks, $block);
     207    }
     208
     209    return $newBlocks;
    211210  }
    212211}
Note: See TracChangeset for help on using the changeset viewer.