field_data = ''; $elements[ $index ]->field_data_translated = ''; } return $elements; } /** * Remove the 'View' link from translation jobs because Contact * Forms don't have a link to 'View' them. * * @param string $link The complete link. * @param string $text The text to link. * @param object $job The corresponding translation job. * @param string $prefix The prefix of the element type. * @param string $type The element type. * * @return string */ public function document_view_item_link( $link, $text, $job, $prefix, $type ) { if ( Constants::POST_TYPE === $type ) { $link = ''; } return $link; } /** * Adjust the 'Edit' link from translation jobs because Contact * Forms have a different URL for editing. * * @param string $link The complete link. * @param string $text The text to link. * @param object $current_document The document to translate. * @param string $prefix The prefix of the element type. * @param string $type The element type. * * @return string */ public function document_edit_item_link( $link, $text, $current_document, $prefix, $type ) { if ( Constants::POST_TYPE === $type ) { $url = sprintf( 'admin.php?page=wpcf7&post=%d&action=edit', $current_document->ID ); $link = sprintf( '%s', admin_url( $url ), $text ); } return $link; } /** * CF7 sets post_ID to -1 for new forms. * WPML thinks we are saving a different post and doesn't save language information. * Removing it fixes the misunderstanding. */ public function fix_setting_language_information() { if ( empty( $_POST['_wpnonce'] ) || empty( $_POST['post_ID'] ) ) { return; } if ( ! wp_verify_nonce( $_POST['_wpnonce'], 'wpcf7-save-contact-form_' . $_POST['post_ID'] ) ) { return; } if ( -1 === (int) $_POST['post_ID'] ) { unset( $_POST['post_ID'] ); } } }