first commit

This commit is contained in:
2023-09-12 21:41:04 +02:00
commit 3361a7f053
13284 changed files with 2116755 additions and 0 deletions

View File

@@ -0,0 +1,31 @@
<?php
namespace WPML\ST\Main\Ajax;
use WPML\Ajax\IHandler;
use WPML\Collect\Support\Collection;
use WPML\FP\Either;
class FetchCompletedStrings implements IHandler {
public function run( Collection $data ) {
global $wpdb;
$strings = $data->get( 'strings', [] );
if( count( $strings ) ) {
$strings_in = wpml_prepare_in( $strings, '%d' );
$result = $wpdb->get_results(
$wpdb->prepare(
"SELECT string_id, language AS lang, value AS translation FROM {$wpdb->prefix}icl_string_translations WHERE string_id IN({$strings_in}) AND status=%d",
ICL_TM_COMPLETE
)
);
return Either::of( $result );
} else {
return Either::of( [] );
}
}
}

View File

@@ -0,0 +1,25 @@
<?php
namespace WPML\ST\Main\Ajax;
use WPML\Ajax\IHandler;
use WPML\Collect\Support\Collection;
use WPML\FP\Either;
use WPML\FP\Obj;
use WPML\ST\API\Fns as STAPI;
class SaveTranslation implements IHandler {
public function run( Collection $data ) {
$id = Obj::prop( 'id', $data );
$translation = Obj::prop( 'translation', $data );
$lang = Obj::prop( 'lang', $data );
if ( $id && $translation && $lang ) {
return Either::of( STAPI::saveTranslation( $id, $lang, $translation, ICL_TM_COMPLETE ) );
} else {
return Either::left( 'invalid data' );
}
}
}