class-job-links.php
1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php
namespace WPML\PB\Gutenberg\ReusableBlocks;
class JobLinks {
/** @var JobFactory $job_factory */
private $job_factory;
public function __construct( JobFactory $job_factory ) {
$this->job_factory = $job_factory;
}
/**
* @param array $job_ids
*
* @return \WPML\Collect\Support\Collection
*/
public function get( array $job_ids ) {
return \wpml_collect( $job_ids )->map( function( $job_id ) {
return $this->getJobEditLink( $job_id );
} )->filter();
}
/**
* @param int $job_id
*
* @return string|null
*/
private function getJobEditLink( $job_id ) {
$job = $this->job_factory->get_translation_job( $job_id );
if ( ! $job || 'post_wp_block' !== $job->original_post_type ) {
return null;
}
$job_edit_url = admin_url( 'admin.php?page='
. WPML_TM_FOLDER
. '/menu/translations-queue.php&job_id='
. $job_id );
$job_edit_url = apply_filters( 'icl_job_edit_url', $job_edit_url, $job_id );
return '<a href="' . $job_edit_url . '" class="wpml-external-link" target="_blank">' . $job->title . '</a>';
}
}