Plugin Directory

Changeset 3015517


Ignore:
Timestamp:
12/29/2023 01:43:29 PM (2 years ago)
Author:
Supertext
Message:

Sync with GitHub

Location:
polylang-supertext/trunk
Files:
6 edited

Legend:

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

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

    r3003613 r3015517  
    110110== Changelog ==
    111111
     112= 4.23 =
     113* Add additional filters and actions to allow other plugins to hook into when the translation is written back (sttr_post_meta_translation for applying filter on translated post meta value, sttr_writeback_target_content for applying filter on target content, sttr_finish_target_post_writeback for running action after the target post write back)
     114
    112115= 4.22 =
    113116* Allow service type IDs greater than 5 in the settings
  • polylang-supertext/trunk/src/Supertext/Backend/CallbackHandler.php

    r2711564 r3015517  
    105105
    106106    foreach ($writeBack->getSourcePostIds() as $sourcePostId) {
    107       if('translation' == $orderType) {
     107      if ('translation' == $orderType) {
    108108        $targetPostId = $this->library->getMultilang()->getPostInLanguage($sourcePostId, $writeBack->getTargetLanguageCode());
    109109      } else {
     
    134134
    135135      $this->contentProvider->saveContentMetaData($targetPost, $writeBackMeta->getContentMetaData());
    136       $this->contentProvider->saveContentData($targetPost, $contentData[$sourcePostId]);
     136
     137      $targetContent = apply_filters(Constant::FILTER_WRITEBACK_TARGET_CONTENT, $contentData[$sourcePostId], $sourcePostId, $targetPostId, $this->library->getMultilang());
     138
     139      $this->contentProvider->saveContentData($targetPost, $targetContent);
    137140
    138141      if (isset($workflowSettings['publishOnCallback'])  && $workflowSettings['publishOnCallback']) {
     
    142145      // Now finally save that post and flush cache
    143146      wp_update_post($targetPost);
     147
     148      // Let other plugins finish any additional writeback work needed on the target post
     149      do_action(Constant::ACTION_FINISH_TARGET_POST_WRITEBACK, $targetContent, $targetPostId, $sourcePostId, $this->library->getMultilang());
    144150
    145151      // All good, set translation flag false
  • polylang-supertext/trunk/src/Supertext/Helper/Constant.php

    r2911219 r3015517  
    130130   */
    131131  const FILTER_TRANSLATABLE_BLOCK_ATTRIBUTES = 'sttr_translatable_block_attributes';
     132  /**
     133   * @var string tag filter for custom fields / post meta translation.
     134   */
     135  const FILTER_POST_META_TRANSLATION = 'sttr_post_meta_translation';
     136  /**
     137   * @var string tag filter for target texts.
     138   */
     139  const FILTER_WRITEBACK_TARGET_CONTENT = 'sttr_writeback_target_content';
     140  /**
     141   * @var string tag action when finishing writing back translation into target post.
     142   */
     143  const ACTION_FINISH_TARGET_POST_WRITEBACK = 'sttr_finish_target_post_writeback';
    132144}
  • polylang-supertext/trunk/src/Supertext/TextAccessors/AbstractPluginCustomFieldsTextAccessor.php

    r2611600 r3015517  
    143143      }
    144144
    145       update_post_meta($post->ID, $id, $value);
     145      $multiLang = $this->library->getMultilang();
     146      $targetLanguage = $multiLang->getPostLanguage($post->ID);
     147      $filteredValue = apply_filters(Constant::FILTER_POST_META_TRANSLATION, $value, $id, $targetLanguage, $multiLang);
     148
     149      update_post_meta($post->ID, $id, $filteredValue);
    146150    }
    147151  }
  • polylang-supertext/trunk/src/Supertext/TextAccessors/CustomFieldsTextAccessor.php

    r2520480 r3015517  
    103103      $decodedContent = html_entity_decode($text, ENT_COMPAT | ENT_HTML401, 'UTF-8');
    104104      $decodedContent = $this->textProcessor->replaceShortcodeNodes($decodedContent);
    105       update_post_meta($post->ID, $id, $decodedContent);
     105
     106      $multiLang = $this->library->getMultilang();
     107      $targetLanguage = $multiLang->getPostLanguage($post->ID);
     108      $filteredValue = apply_filters(Constant::FILTER_POST_META_TRANSLATION, $value, $id, $targetLanguage, $multiLang);
     109
     110      update_post_meta($post->ID, $id, $filteredValue);
    106111    }
    107112  }
Note: See TracChangeset for help on using the changeset viewer.