Skip to content

Commit 87c944f

Browse files
committed
plugins.jquery.com: Add lists for sidebar and show on index
* New Plugins * Recently Updated Plugins
1 parent 8955410 commit 87c944f

File tree

3 files changed

+88
-7
lines changed

3 files changed

+88
-7
lines changed

themes/plugins.jquery.com/functions.php

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,77 @@ function jq_plugin_versions() {
4949
}, array_reverse( json_decode( $versions ) ) );
5050
}
5151

52+
//
53+
// Display a list of the newest plugins (for the sidebar)
54+
//
55+
56+
function jq_new_plugins($total = 10) {
57+
global $post;
58+
$new_plugins_args = array(
59+
'post_type' => 'jquery_plugin',
60+
'posts_per_page' => $total,
61+
'order' => 'DESC',
62+
'orderby' => 'date',
63+
'post_parent' => 0,
64+
);
65+
66+
$new_plugins = new WP_Query( $new_plugins_args );
67+
if ( $new_plugins->have_posts() ):
68+
echo '<ul>';
69+
while ( $new_plugins->have_posts() ) :
70+
$new_plugins->the_post();
71+
?>
72+
<li>
73+
<a href="/<?php echo $post->post_name; ?>/"><?php echo $post->post_title; ?></a>
74+
</li>
75+
<?php
76+
endwhile;
77+
echo '</ul>';
78+
endif;
79+
wp_reset_postdata();
80+
}
81+
82+
//
83+
// Display a list of the most recently updated plugins (for the sidebar)
84+
//
85+
function jq_updated_plugins( $total = 10 ) {
86+
global $post;
87+
$updated_plugins_args = array(
88+
'post_type' => 'jquery_plugin',
89+
'order' => 'DESC',
90+
'orderby' => 'date',
91+
);
92+
93+
$added = array();
94+
$updated_plugins = new WP_Query( $updated_plugins_args );
95+
if ( $updated_plugins->have_posts() ):
96+
echo '<ul>';
97+
while ( $updated_plugins->have_posts() ) :
98+
$updated_plugins->the_post();
99+
$parent_id = $post->post_parent;
100+
101+
// Only add children of the main plugin post
102+
// And only add if no other child of same parent has been added
103+
if ( $parent_id && !in_array($parent_id, $added)):
104+
$added[] = $parent_id;
105+
$parent = get_post( $parent_id );
106+
107+
?>
108+
<li>
109+
<a href="/<?php echo $parent->post_name . '/' . $post->post_name ?>/"><?php echo $post->post_title; ?></a>
110+
(version <?php echo $post->post_name; ?>)
111+
</li>
112+
<?php
113+
if ( count($added) == $total ) {
114+
break;
115+
}
116+
endif;
117+
endwhile;
118+
echo '</ul>';
119+
endif;
120+
wp_reset_postdata();
121+
}
122+
52123
//
53124
// The functions below (with the jq_release_ prefix) relate to a specific
54125
// version number release of a plugin

themes/plugins.jquery.com/index.php

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
<?php get_header(); ?>
2-
2+
33
<!-- body -->
44
<div id="body" class="clearfix">
5-
6-
<!-- inner -->
7-
<div class="inner">
8-
5+
6+
<div class="col col3-2">
7+
<div class="inner">
98
<?php
109

1110
// TODO
@@ -22,9 +21,15 @@
2221
}
2322
}
2423
?>
25-
24+
25+
</div>
2626
</div>
27-
<!-- /inner -->
27+
<?php if($sidebar): ?>
28+
29+
<?php get_sidebar( ); ?>
30+
31+
<?php endif; ?>
32+
2833
</div>
2934
<!-- /body -->
3035

themes/plugins.jquery.com/style.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,8 @@ Template: jquery
1414
.jquery_plugin .block li { list-style-type: none; margin: 0; padding: 0; }
1515
.jquery_plugin .block ul { font-size: 110%; margin-bottom: 1em; }
1616
.jquery_plugin .block li { margin: 0.6em 0; }
17+
18+
.sidebar {
19+
background-color: #eee;
20+
padding: 2%;
21+
}

0 commit comments

Comments
 (0)