@@ -49,6 +49,77 @@ function jq_plugin_versions() {
49
49
}, array_reverse ( json_decode ( $ versions ) ) );
50
50
}
51
51
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
+
52
123
//
53
124
// The functions below (with the jq_release_ prefix) relate to a specific
54
125
// version number release of a plugin
0 commit comments