class-wp-installer-api.php
3.73 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
<?php
class WP_Installer_API{
public static function get_product_installer_link($repository_id, $package_id = false){
$menu_url = WP_Installer()->menu_url();
$url = $menu_url . '#' . $repository_id;
if($package_id){
$url .= '/' . $package_id;
}
return $url;
}
public static function get_product_price($repository_id, $package_id, $product_id, $incl_discount = false){
$price = WP_Installer()->get_product_price($repository_id, $package_id, $product_id, $incl_discount);
return $price;
}
/**
* Retrieve the preferred translation service.
*
* @since 1.6.5
*
* @param string $repository_id The repository id (e.g. wpml)
* @return string|false The translation service id or false if none is set
*/
public static function get_preferred_ts($repository_id = 'wpml'){
if(isset(WP_Installer()->settings['repositories'][$repository_id]['ts_info']['preferred'])){
return WP_Installer()->settings['repositories'][$repository_id]['ts_info']['preferred'];
}
return false;
}
/**
* Set the preferred translation service.
*
* @since 1.6.5
*
* @param string $value The translation service id
* @param string $repository_id The repository id (e.g. wpml)
*/
public static function set_preferred_ts( $value, $repository_id = 'wpml' ){
if( isset( WP_Installer()->settings['repositories'][$repository_id]['ts_info']['preferred'] ) ){
WP_Installer()->settings['repositories'][$repository_id]['ts_info']['preferred'] = $value;
WP_Installer()->save_settings();
}
}
/**
* Retrieve the referring translation service (if any)
*
* @since 1.6.5
*
* @param string $repository_id The repository id (e.g. wpml)
* @return string The translation service id or false
*/
public static function get_ts_referal( $repository_id = 'wpml' ) {
if(isset(WP_Installer()->settings['repositories'][$repository_id]['ts_info']['referal'])){
return WP_Installer()->settings['repositories'][$repository_id]['ts_info']['referal'];
}
return false;
}
/**
* Retrieve the translation services client id for a specific repository (if any)
*
* @since 1.7.9
*
* @param string $repository_id The repository id (e.g. wpml)
* @return string|false The client id or false
*/
public static function get_ts_client_id( $repository_id = 'wpml' ){
if(isset(WP_Installer()->settings['repositories'][$repository_id]['ts_info']['client_id'])){
return WP_Installer()->settings['repositories'][$repository_id]['ts_info']['client_id'];
}
return false;
}
/**
* Retrieve the site key corresponding to a repository.
* This is a wrapper of WP_Installer::get_site_key()
* @see WP_Installer::get_site_key()
*
* @since 1.7.9
*
* @param string $repository_id The repository id (e.g. wpml)
* @return string The site key (or false)
*/
public static function get_site_key( $repository_id = 'wpml' ){
return WP_Installer()->get_site_key( $repository_id );
}
/**
* Retrieve the ID of the last user who registered a repository.
*
* @since 1.7.16
*
* @param string $repository_id The repository id (e.g. wpml)
* @return int The user id (or zero)
*/
public static function get_registering_user_id( $repository_id = 'wpml' ){
$user_id = 0;
if( isset( WP_Installer()->settings['repositories'][$repository_id]['subscription']['registered_by'] ) ){
$user_id = WP_Installer()->settings['repositories'][$repository_id]['subscription']['registered_by'];
}
return $user_id;
}
}