-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathindex.php
128 lines (106 loc) · 3.8 KB
/
index.php
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
<?php
get_header();
if(current_user_can('edit_theme_options')) {
$uri = 'https://themes.trac.wordpress.org/query?priority=new+theme&priority=previously+reviewed&owner=&status=new&status=reviewing&keywords=!~buddypress&max=1000&col=id&col=summary&col=status&col=time&col=changetime&col=reporter&report=2&order=time';
$contents = wp_remote_fopen($uri);
$dom = new DOMDocument();
$dom->preserveWhiteSpace = false;
$dom->loadHTML($contents);
function ticket_reviewer_themelist( $dom ){
$domxpath = new DOMXPath($dom);
$themelist = array();
$count = 1;
$tr = $domxpath->query('//table[@class="listing tickets"]/tbody/tr');
foreach ($tr as $key) {
foreach ($key->childNodes as $k) {
if($k->nodeName === 'td') {
foreach($k->attributes as $v){
// Ticket ID
if($v->nodeValue === 'id') {
$themelist[$count]['id'] = trim(str_replace('#', '', $k->nodeValue));
}
// Theme Name
if($v->nodeValue === 'summary') {
$themerawn = str_replace('THEME: ', '', $k->nodeValue);
$themename = trim(substr($themerawn, 0, strpos($themerawn, " –")));
$themeslug = strtolower( $themename );
$themeslug = preg_replace( '/[^a-z0-9_\-]/', '-', $themeslug );
$themeslug = preg_replace( '/(--)/', '-', $themeslug );
$themevers = trim(substr( $themerawn, strpos( $themerawn, '–') + 3 ) );
$themelist[$count]['name'] = $themename;
$themelist[$count]['slug'] = $themeslug;
$themelist[$count]['version'] = $themevers;
}
// Theme Author
if($v->nodeValue === 'reporter') {
$themelist[$count]['reporter'] = trim($k->nodeValue);
}
// Modified
if($v->nodeValue === 'changetime') {
$themelist[$count]['changetime'] = trim($k->nodeValue);
}
// Created
if($v->nodeValue === 'time') {
$themelist[$count]['time'] = trim($k->nodeValue);
}
}
}
}
$count++;
}
return (array) $themelist;
}
$themelist = ticket_reviewer_themelist( $dom );
?>
<section class="container">
<div class="row">
<div class="col-xs-12 themepositions" style="text-align:center; margin-bottom: 150px; font-size: 24px;">
</div>
</div>
</section>
<section class="container">
<div class="row">
<?php
$default_thumb = get_template_directory_uri() . '/images/placeholder.png';
// Create list in grid
foreach ($themelist as $key => $value) {
$theme_thumb = 'https://themes.svn.wordpress.org/' . $value['slug'] . '/' . $value['version'] . '/screenshot.png';
$ticket_link = 'https://themes.trac.wordpress.org/ticket/' . $value['id'];
$output = '<div class="col-xs-3 themewrap">';
$output .= '<div class="inner-col">';
$output .= '<a target="_blank" href="' . esc_url($ticket_link) . '">';
$output .= '<figure class="thumbnail">';
$output .= '<img class="screenshot" src="' . esc_url($default_thumb) . '" data-src="' . esc_url($theme_thumb) . '" alt="thumb" />';
$output .= '<span class="position">' . absint($key) . '</span>';
$output .= '<span class="author">' . esc_html($value['reporter']) . '</span>';
$output .= '</figure>';
$output .= '<footer class="details clearfix">';
$output .= esc_html($value['name']);
$output .= '</footer>';
$output .= '</a>';
$output .= '</div>';
$output .= '</div>';
echo $output;
}
?>
</div>
</section>
<script>
//<![CDATA[
var trtPlaceholderIMG = '<?php echo esc_url( $default_thumb ); ?>';
//]]>
</script>
<?php
} else {
?>
<section class="container">
<div class="row">
<div class="col-xs-12 themepositions" style="text-align:center; margin-bottom: 150px; font-size: 24px;">
<h4 class="login-heading"><?php _e( 'You need to login to see the results', 'textdomain' ); ?></h4>
<?php wp_login_form(); ?>
</div>
</div>
</section>
<?php
}
get_footer();