Skip to content

Commit 1fc60e0

Browse files
authored
Sort repos and only show ones which have contributions (#22)
1 parent 88c5b0c commit 1fc60e0

File tree

3 files changed

+21
-14
lines changed

3 files changed

+21
-14
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@
66
vendor/
77
logs/
88
build/
9+
.env

ossc.php

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Install: Drop this directory in the "wp-content/plugins/" directory and activate it. You need to specify "[ossc]" in the code section of a page or a post.
77
* Contributors: pjaudiomv, radius314
88
* Authors: pjaudiomv, radius314
9-
* Version: 1.1.2
9+
* Version: 1.1.3
1010
* Requires PHP: 8.1
1111
* Requires at least: 6.2
1212
* License: GPL v2 or later
@@ -15,7 +15,7 @@
1515

1616
namespace OsscPlugin;
1717

18-
if ( basename( $_SERVER['PHP_SELF'] ) == basename( __FILE__ ) ) {
18+
if ( ! defined( 'WPINC' ) ) {
1919
die( 'Sorry, but you cannot access this page directly.' );
2020
}
2121

@@ -155,8 +155,8 @@ public static function register_settings(): void {
155155
public static function create_menu(): void {
156156
// Create the plugin's settings page in the WordPress admin menu
157157
add_options_page(
158-
esc_html__( 'OSSC Settings', 'ossc' ), // Page Title
159-
esc_html__( 'OSSC', 'ossc' ), // Menu Title
158+
esc_html__( 'OSSC Settings', 'ossc-wp' ), // Page Title
159+
esc_html__( 'OSSC', 'ossc-wp' ), // Menu Title
160160
'manage_options', // Capability
161161
self::PLUG_SLUG, // Menu Slug
162162
[ static::class, 'draw_settings' ] // Callback function to display the page content
@@ -176,12 +176,12 @@ private static function determine_option( string|array $attrs, string $option ):
176176
if ( isset( $_POST['ossc_nonce'] ) && wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['ossc_nonce'] ) ), 'ossc_action' ) ) {
177177
if ( isset( $_POST[ $option ] ) ) {
178178
// Form data option
179-
return sanitize_text_field( strtolower( $_POST[ $option ] ) );
179+
return sanitize_text_field( strtolower( wp_unslash( $_POST[ $option ] ) ) );
180180
}
181181
}
182182
if ( isset( $_GET[ $option ] ) ) {
183183
// Query String Option
184-
return wp_kses( strtolower( $_GET[ $option ] ), [ 'br' => [] ] );
184+
return wp_kses( strtolower( wp_unslash( $_GET[ $option ] ) ), [ 'br' => [] ] );
185185
} elseif ( ! empty( $attrs[ $option ] ) ) {
186186
// Shortcode Option
187187
return sanitize_text_field( strtolower( $attrs[ $option ] ) );
@@ -250,16 +250,18 @@ public function render_ossc( string|array $attrs = [] ): string {
250250
} else {
251251
$github_repos = [];
252252
}
253-
253+
asort( $github_repos );
254254
foreach ( $github_repos as $repo ) {
255255
$repo_name = explode( '/', $repo )[1] ?? '';
256-
$content .= '<p><strong><a href="https://github.com/' . esc_url( $repo ) . '" target="_blank" data-type="URL" rel="noreferrer noopener">' . $repo_name . '</a></strong></p>';
257256
$results = $wpdb->get_results( $wpdb->prepare( 'SELECT * FROM %i WHERE repo = %s ORDER BY closed_at DESC', $table_name, $repo ), ARRAY_A ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
258-
$content .= '<ul class="ossc_ul">';
259-
foreach ( $results as $item ) {
260-
$content .= '<li class="ossc_li">' . '<a target="_blank" rel="noopener noreferrer" href="' . $item['url'] . '">' . $item['url'] . '</a></li>';
257+
if ( count( $results ) > 0 ) {
258+
$content .= '<p><strong><a href="' . esc_url( 'https://github.com/' . $repo ) . '" target="_blank" data-type="URL" rel="noreferrer noopener">' . $repo_name . '</a></strong></p>';
259+
$content .= '<ul class="ossc_ul">';
260+
foreach ( $results as $item ) {
261+
$content .= '<li class="ossc_li">' . '<a target="_blank" rel="noopener noreferrer" href="' . $item['url'] . '">' . $item['url'] . '</a></li>';
262+
}
263+
$content .= '</ul>';
261264
}
262-
$content .= '</ul>';
263265
}
264266

265267
$content .= '</div>';

readme.txt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
Contributors: pjaudiomv, radius314
44
Tags: ossc, open source software contributions, github, pull requests
55
Requires at least: 6.2
6-
Tested up to: 6.6.1
7-
Stable tag: 1.1.2
6+
Tested up to: 6.7.1
7+
Stable tag: 1.1.3
88
License: GPLv2 or later
99
License URI: http://www.gnu.org/licenses/gpl-2.0.html
1010

@@ -57,6 +57,10 @@ This section describes how to install the plugin and get it working.
5757

5858
== Changelog ==
5959

60+
= 1.1.3 =
61+
62+
* Added auto sort by repo name.
63+
6064
= 1.1.2 =
6165

6266
* First WordPress plugin repository release.

0 commit comments

Comments
 (0)