get_active_languages(); $version = isset( $_GET['version'] ) ? filter_var( $_GET['version'], FILTER_SANITIZE_STRING ) : false; $translations = array(); if ( isset( $active_languages[ $language ] ) ) { try { $WPML_ST_MO_Downloader->load_xml(); $WPML_ST_MO_Downloader->get_translation_files(); $version_projects = explode( ';', $version ); $types = array(); foreach ( $version_projects as $project ) { $exp = explode( '|', $project ); $types[] = $exp[0]; } $translations = $WPML_ST_MO_Downloader->get_translations( $language, array( 'types' => $types ) ); } catch ( Exception $error ) { $user_errors[] = $error->getMessage(); } } if ( isset( $_POST['action'] ) && $_POST['action'] == 'icl_admo_add_translations' && wp_verify_nonce( $_POST['_wpnonce'], 'icl_adm_save_translations' ) ) { $translations_add = array(); if ( ! empty( $_POST['add_new'] ) && array_key_exists( 'new', $translations ) ) { $new_translations = $translations['new']; foreach ( $new_translations as $tr ) { $translations_add[] = array( 'string' => filter_var( $tr['string'], FILTER_SANITIZE_STRING ), 'translation' => filter_var( $tr['new'], FILTER_SANITIZE_STRING ), 'name' => filter_var( $tr['name'], FILTER_SANITIZE_STRING ), 'gettext_context' => filter_var( $tr['gettext_context'], FILTER_SANITIZE_STRING ), ); } if ( ! empty( $translations_add ) ) { $user_messages[] = sprintf( _n( '%d new translation was added.', '%d new translations were added.', count( $translations_add ), 'wpml-string-translation' ), count( $translations_add ) ); } } if ( ! empty( $_POST['selected'] ) ) { $translations_updated = 0; foreach ( $_POST['selected'] as $idx => $v ) { if ( ! empty( $v ) ) { $translations_add[] = array( 'string' => filter_var( base64_decode( $_POST['string'][ $idx ] ), FILTER_SANITIZE_STRING ), 'translation' => filter_var( base64_decode( $_POST['translation'][ $idx ] ), FILTER_SANITIZE_STRING ), 'name' => filter_var( base64_decode( $_POST['name'] [ $idx ] ), FILTER_SANITIZE_STRING ), 'gettext_context' => filter_var( base64_decode( $_POST['gettext_context'][ $idx ] ), FILTER_SANITIZE_STRING ), ); $translations_updated ++; } } if ( $translations_updated ) { $user_messages[] = sprintf( _n( '%d translation was updated.', '%d translations were updated.', $translations_updated, 'wpml-string-translation' ), $translations_updated ); } } if($translations_add){ $WPML_ST_MO_Downloader->save_translations($translations_add, $_POST['language'], $_POST['version']); }else{ $user_errors[] = __('No action performed. Please select the strings that you need to update or add.', 'wpml-string-translation'); } } ?>