• Skip to sidebar navigation
  • Skip to content

Bitbucket

  • More
    ProjectsRepositories
    • Help
      • Online help
      • Learn Git
      • Welcome to Bitbucket
      • Keyboard shortcuts
    • Log In
    Blackrock
    1. Blackrock

    main

    Public
    Actions
    • Clone

    Learn more about cloning repositories

    You have read-only access

    Navigation
    • Source
    • Commits
    • Branches
    • All Branches Graph
    • Graphs
    • Forks
    1. Blackrock
    2. main

    Source

    main/wp-content/plugins/wpml-string-translation/classes/batch-translation/StringTranslations.php
    Артем ШиряевАртем Ширяев committed 554847ddcb906 Apr 2021
    Raw file
    Source viewDiff to previous
     
    1
    <?php
    2
    ​
    3
    namespace WPML\ST\Batch\Translation;
    4
    ​
    5
    use phpDocumentor\Reflection\Types\Callable_;
    6
    use WPML\Collect\Support\Traits\Macroable;
    7
    use WPML\FP\Fns;
    8
    use WPML\FP\Logic;
    9
    use WPML\FP\Obj;
    10
    use WPML\FP\Str;
    11
    use WPML\FP\Wrapper;
    12
    use WPML\ST\API\Fns as ST_API;
    13
    use function WPML\Container\make;
    14
    use function WPML\FP\curryN;
    15
    use function WPML\FP\invoke;
    16
    use function WPML\FP\pipe;
    17
    use function WPML\FP\spreadArgs;
    18
    ​
    19
    /**
    20
     * Class StringTranslations
    21
     *
    22
     * @package WPML\ST\Batch\Translation
    23
     * @method static callable|void save( ...$element_type_prefix, ...$job, ...$decoder ) :: string → object → ( string → string → string ) → void
    24
     * @method static callable|void addExisting( ...$prevTranslations, ...$package, ...$lang ) :: [WPML_TM_Translated_Field] → object → string → [WPML_TM_Translated_Field]
    25
     * @method static callable|bool isTranslated( ...$field ) :: object → bool
    26
     * @method static callable|bool isBatchId( ...$str ) :: string → bool
    27
     * @method static callable|bool isBatchField( ...$field ) :: object → bool
    28
     * @method static callable|string decodeStringId( ...$str ) :: string → string
    29
     * @method static callable|void markTranslationsAsInProgress( ...$getJobStatus, ...$hasTranslation, ...$addTranslation, ...$post, ...$element) :: callable -> callable -> callable -> WPML_TM_Translation_Batch_Element -> \stdClass -> void
    30
     * @method static callable|void cancelTranslations(...$job) :: \WPML_TM_Job_Entity -> void
    31
     * @method static callable|void updateStatus(...$element_type_prefix, ...$job) :: string -> \stdClass -> void
    32
     */
    33
    class StringTranslations {
    34
    ​
    35
        use Macroable;
    36
    ​
    37
        public static function init() {
    38
    ​
    39
            self::macro( 'isBatchId', Str::startsWith( Module::STRING_ID_PREFIX ) );
    40
    ​
    41
            self::macro( 'isTranslated', Obj::prop( 'field_translate' ) );
    42
    ​
    43
            self::macro(
    44
                'isBatchField',
    45
                curryN(
    46
                    1,
    47
                    function( $field ) {
    48
                        return self::isBatchId( Obj::prop( 'field_type', $field ) );
    49
                    }
    50
                )
    51
            );
    52
    ​
    53
            self::macro( 'decodeStringId', Str::replace( Module::STRING_ID_PREFIX, '' ) );
    54
    ​
    55
            self::macro(
    56
                'save',
    57
                curryN(
    58
                    3,
    59
                    function ( $element_type_prefix, $job, callable $decoder ) {
    60
                        if ( $element_type_prefix === 'st-batch' ) {
    61
    ​
    62
                            // $decodeField :: field → string
    63
                            $decodeField = pipe(
    • Git repository management for enterprise teams powered by Atlassian Bitbucket
    • Atlassian Bitbucket v5.10.1
    • Documentation
    • Contact Support
    • Request a feature
    • About
    • Contact Atlassian
    Atlassian

    Everything looks good. Well let you know here if theres anything you should know about.