translationproxy-popup.class.php
1.78 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?php
class TranslationProxy_Popup {
public static function display() {
include_once WPML_TM_PATH . '/inc/translation-proxy/translationproxy-popup.php';
exit;
}
public static function get_link( $link, $args = array(), $just_url = false ) {
$defaults = array(
'title' => null,
'class' => '',
'id' => '',
'ar' => 0, // auto_resize
'unload_cb' => false, // onunload callback
);
$args = array_merge($defaults, $args);
/**
* @var title string
*/
$title = $args['title'];
/**
* @var $class string
*/
$class = $args['class'];
/**
* @var $id int
*/
$id = $args['id'];
/**
* @var $ar int
*/
$ar = $args['ar'];
/**
* @var $unload_cb bool
*/
$unload_cb = $args['unload_cb'];
if ( !empty( $ar ) ) {
$auto_resize = '&auto_resize=1';
} else {
$auto_resize = '';
}
$unload_cb = isset( $unload_cb ) ? '&unload_cb=' . $unload_cb : '';
$url_glue = false !== strpos( $link, '?' ) ? '&' : '?';
$link .= $url_glue . 'compact=1';
$nonce_snippet = '&_icl_nonce=' . wp_create_nonce( 'reminder_popup_nonce' );
$action_and_nonce = 'admin.php?page=' . ICL_PLUGIN_FOLDER
. "/menu/languages.php&icl_action=reminder_popup{$nonce_snippet}{$auto_resize}{$unload_cb}"
. "&target=" . urlencode( $link );
if ( ! empty( $id ) ) {
$id = ' id="' . $id . '"';
}
if ( ! $just_url ) {
return '<a class="icl_thickbox ' . $class . '" title="' . $title . '" href="' . $action_and_nonce . '"' . $id . '>';
} else {
if ( ! $just_url ) {
return '<a class="icl_thickbox ' . $class . '" href="' . $action_and_nonce . '"' . $id . '>';
} else {
return $action_and_nonce;
}
}
}
}