Skip to content

Integrate with WPML #89

Description

@danieliser

This work will be the same for PM likely.

We have ids from the base( admin language?* ). We would need them transposed to the ids of said content in the current language.

We would also likely need an option to enable rules across translations, or not.

Possible process

# new method for get_selected_ids( $ids, $kind, $type )
function get_selected_ids( $ids, $type , $kind = 'post_type'  ) {
    return apply_filters( 'content_control/get_selected_ids', $ids, $kind, $type );
}

if (  $query | $post is a translation ) { // pseudo code
    add_filter( 'content_control/get_selected_ids', 'Compatibility\WPML::get_selected_ids' );
}

Compatibility\WPML::get_selected_ids( $ids,  $type, $kind) {
    $base_lang = ...;
    $current_lang = ...;

    if ( $base_lang === $current_lang ) {
        return $ids;
    }

    foreach( $ids as $key => $id ) {
        if ( 'postType' === $kind  ) {
            // Get remapped ids for post.
            $ids[ $key ] = get_translated_post_id( $id, $current_lang, $type );
        } else if ( 'taxonomy' === $kind  ) {
            // Get remapped ids for post.
            $ids[ $key ] = get_translated_tax_id( $id, $current_lang, $type );
        } 
    }

    return $ids;
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions