简体   繁体   中英

What is the best way to use sanitze wpml with php and wordpress

what is the best way to use sanitze wpml with php and wordpress

<span>
  <?php
    if(ICL_LANGUAGE_CODE == 'en'): ?>
      I agree with <a href="<?php echo esc_url( $policy['url'] ); ?>" target="<?php echo esc_attr( $policy['target'] ); ?>"><?php echo esc_html( $policy['title'] ); ?></a> and <a href="<?php echo esc_url( $terms['url'] ); ?>" target="<?php echo esc_attr( $terms['target'] ); ?>"><?php echo esc_html( $terms['title'] ); ?></a>
    else : ?>
      Sunt de acord cu <a href="<?php echo esc_url( $policy['url'] ); ?>" target="<?php echo esc_attr( $policy['target'] ); ?>"><?php echo esc_html( $policy['title'] ); ?></a> si <a href="<?php echo esc_url( $terms['url'] ); ?>" target="<?php echo esc_attr( $terms['target'] ); ?>"><?php echo esc_html( $terms['title'] ); ?></a> <?php
    endif;
  ?>
</span>

Thank you!

I've generated with wp-cli pot file: wp i18n make-pot. textdomain.pot Then I've edited with Poedit to desired language And changed I think in better code:

<?php 
      printf( 
        esc_html( __( 'I agree with %1$s and %2$s', 'textdomain' ) ),
        '<a href="' . esc_url( $policy['url'] ) . '" target="' . esc_attr( $policy['target'] ) . '">'. esc_html( $policy['title'] ) . '</a>',
        '<a href="' . esc_url( $terms['url'] ) . '" target="' . esc_attr( $terms['target'] ) . '">'. esc_html( $terms['title'] ) . '</a>'
      );
?>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM