1
<?php
2
/*
3
Display WordPress Developer Credits with Shortcode (or PHP)
4
http://www.beliefmedia.com/wordpress-import-plugins
5
*/
6
7
8
9
10
'version' => 0,
11
'locale' => 0,
12
13
/* Groups to show */
14
'leaders' => 1,
15
'devs' => 1,
16
'contributors' => 1,
17
'rockstars' => 1,
18
'props' => 1,
19
'libraries' => 1,
20
21
/* Gravatar sizes for lists */
22
'gravatar' => '15',
23
'align' => '-13',
24
25
/* Cache */
26
'cache_temp' => 600,
27
'cache' => 3600 * 24 * 28
28
), $atts);
29
30
31
32
33
if ($cached_data !== false) {
34
$return = $cached_data;
35
36
} else {
37
38
/* Request URL */
39
$url = 'https://api.wordpress.org/core/credits/1.1/?';
40
$url .= ($atts['version'] != 0) ? 'version=' . $atts['version'] : 'version=';
41
$url .= ($atts['locale'] != 0) ? '&locale=' . $atts['locale'] : '&locale=';
42
43
44
if ($data !== false) {
45
46
47
48
if ($data !== false) {
49
50
if ($atts['leaders'] != 0) {
51
$leaders = $data['groups']['project-leaders']['data'];
52
foreach ($leaders AS $leader) $wp_leaders .= '
53
<li><img src="https://secure.gravatar.com/avatar/' . $leader['1'] . '?s=' . $atts['gravatar'] . '&d=mm&r=g" style="padding: 10px; vertical-align:' . $atts['align'] . 'px"><span style="font-weight: bold;">' . $leader['0'] . '</span><span style="font-size: 0.9em";>' . $leader['3'] . ' [ <a href="https://profiles.wordpress.org/' . $leader['2'] . '" rel="nofollow">' . $leader['2'] . '</a> ]</span></li>
54
55
';
56
$wp_leaders_return = '
57
<h3>WordPress Leaders</h3>
58
59
';
60
$wp_leaders_return .= '
61
<ul>' . $wp_leaders . '</ul>
62
63
';
64
}
65
66
if ($atts['devs'] != 0) {
67
$devs = $data['groups']['core-developers']['data'];
68
foreach ($devs AS $dev) $wp_devs .= '
69
<li><img src="https://secure.gravatar.com/avatar/' . $dev['1'] . '?s=' . $atts['gravatar'] . '&d=mm&r=g" style="padding: 10px; vertical-align:' . $atts['align'] . 'px"><span style="font-weight: bold;">' . $dev['0'] . '</span><span style="font-size: 0.9em";>' . $dev['3'] . ' [ <a href="https://profiles.wordpress.org/' . $dev['2'] . '" target="_blank" rel="nofollow noopener noreferrer">' . $dev['2'] . '</a> ]</span></li>
70
71
';
72
$wp_dev_return = '
73
<h3>Core Developers</h3>
74
75
';
76
$wp_dev_return .= '
77
<ul>' . $wp_devs . '</ul>
78
79
';
80
}
81
82
if ($atts['contributors'] != 0) {
83
$contributors = $data['groups']['contributing-developers']['data'];
84
foreach ($contributors AS $contributor) $wp_contributor .= '
85
<li><img src="https://secure.gravatar.com/avatar/' . $contributor['1'] . '?s=' . $atts['gravatar'] . '&d=mm&r=g" style="padding: 10px; vertical-align:' . $atts['align'] . 'px"><span style="font-weight: bold;">' . $contributor['0'] . '</span> <span style="font-size: 0.9em";>' . $contributor['3'] . ' [ <a href="https://profiles.wordpress.org/' . $contributor['2'] . '" target="_blank" rel="nofollow noopener noreferrer">' . $contributor['2'] . '</a> ]</span></li>
86
87
';
88
$wp_contributor_return = '
89
<h3>Contributors</h3>
90
91
';
92
$wp_contributor_return .= '
93
<ul>' . $wp_contributor . '</ul>
94
95
';
96
}
97
98
if ($atts['rockstars'] != 0) {
99
$rockstars = $data['groups']['recent-rockstars']['data'];
100
foreach ($rockstars AS $rockstar) $wp_rockstar .= '
101
<li><img src="https://secure.gravatar.com/avatar/' . $rockstar['1'] . '?s=' . $atts['gravatar'] . '&d=mm&r=g" style="padding: 10px; vertical-align:' . $atts['align'] . 'px"><span style="font-weight: bold;">' . $rockstar['0'] . '</span> <span style="font-size: 0.9em";>' . $rockstar['3'] . ' [ <a href="https://profiles.wordpress.org/' . $rockstar['2'] . '" target="_blank" rel="nofollow noopener noreferrer">' . $rockstar['2'] . '</a> ]</span></li>
102
103
';
104
$wp_rockstar_return = '
105
<h3>Rockstars</h3>
106
107
';
108
$wp_rockstar_return .= '
109
<ul>' . $wp_rockstar . '</ul>
110
111
';
112
}
113
114
if ($atts['props'] != 0) {
115
$props = $data['groups']['props']['data'];
116
foreach ($props AS $prop => $fullname) $wp_prop .= $fullname . ' (<a href="https://profiles.wordpress.org/' . $prop . '" target="_blank" rel="nofollow noopener noreferrer">' . $prop . '</a>) • ';
117
$wp_props_return = '
118
<h3>Core Contributors</h3>
119
120
';
121
$wp_props_return .= '<span style="text-decoration: none;">' . $wp_prop . '</span>';
122
}
123
124
if ($atts['libraries'] != 0) {
125
$libraries = $data['groups']['libraries']['data'];
126
foreach ($libraries AS $library) $wp_library .= '
127
<li><a href="' . $library['1'] . '" target="_blank" rel="nofollow noopener noreferrer">' . $library['0'] . '</a></li>
128
129
';
130
$wp_library_return = '
131
<h3>Libraries</h3>
132
133
';
134
$wp_library_return .= '<span style="text-decoration: none;">' . $wp_library . '</span>';
135
}
136
137
/* Build Page */
138
if ($atts['leaders'] != 0) $return = $wp_leaders_return;
139
if ($atts['devs'] != 0) $return .= $wp_dev_return;
140
if ($atts['contributors'] != 0) $return .= $wp_contributor_return;
141
if ($atts['rockstars'] != 0) $return .= $wp_rockstar_return;
142
if ($atts['props'] != 0) $return .= $wp_props_return;
143
if ($atts['libraries'] != 0) $return .= $wp_library_return;
144
145
/* Set transient */
146
set_transient($transient, $return, $atts['cache']);
147
148
} else {
149
150
$return = '
151
<ul>
152
<li>Credit list temporarily unavailable.</li>
153
</ul>
154
155
';
156
157
/* Set temp transient */
158
set_transient($transient, $return, $atts['cache_temp']);
159
160
}
161
162
} else {
163
164
/* file_get_contents() error */
165
$return = '
166
<ul>
167
<li>Credit list temporarily unavailable.</li>
168
</ul>
169
170
';
171
172
/* Set temp transient */
173
set_transient($transient, $return, $atts['cache_temp']);
174
175
}
176
177
}
178
179
return '' . $return . '';
180
}
181