6
6
* 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.
7
7
* Contributors: pjaudiomv, radius314
8
8
* Authors: pjaudiomv, radius314
9
- * Version: 1.1.2
9
+ * Version: 1.1.3
10
10
* Requires PHP: 8.1
11
11
* Requires at least: 6.2
12
12
* License: GPL v2 or later
15
15
16
16
namespace OsscPlugin ;
17
17
18
- if ( basename ( $ _SERVER [ ' PHP_SELF ' ] ) == basename ( __FILE__ ) ) {
18
+ if ( ! defined ( ' WPINC ' ) ) {
19
19
die ( 'Sorry, but you cannot access this page directly. ' );
20
20
}
21
21
@@ -155,8 +155,8 @@ public static function register_settings(): void {
155
155
public static function create_menu (): void {
156
156
// Create the plugin's settings page in the WordPress admin menu
157
157
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
160
160
'manage_options ' , // Capability
161
161
self ::PLUG_SLUG , // Menu Slug
162
162
[ 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 ):
176
176
if ( isset ( $ _POST ['ossc_nonce ' ] ) && wp_verify_nonce ( sanitize_text_field ( wp_unslash ( $ _POST ['ossc_nonce ' ] ) ), 'ossc_action ' ) ) {
177
177
if ( isset ( $ _POST [ $ option ] ) ) {
178
178
// Form data option
179
- return sanitize_text_field ( strtolower ( $ _POST [ $ option ] ) );
179
+ return sanitize_text_field ( strtolower ( wp_unslash ( $ _POST [ $ option ] ) ) );
180
180
}
181
181
}
182
182
if ( isset ( $ _GET [ $ option ] ) ) {
183
183
// Query String Option
184
- return wp_kses ( strtolower ( $ _GET [ $ option ] ), [ 'br ' => [] ] );
184
+ return wp_kses ( strtolower ( wp_unslash ( $ _GET [ $ option ] ) ), [ 'br ' => [] ] );
185
185
} elseif ( ! empty ( $ attrs [ $ option ] ) ) {
186
186
// Shortcode Option
187
187
return sanitize_text_field ( strtolower ( $ attrs [ $ option ] ) );
@@ -250,16 +250,18 @@ public function render_ossc( string|array $attrs = [] ): string {
250
250
} else {
251
251
$ github_repos = [];
252
252
}
253
-
253
+ asort ( $ github_repos );
254
254
foreach ( $ github_repos as $ repo ) {
255
255
$ 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> ' ;
257
256
$ 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> ' ;
261
264
}
262
- $ content .= '</ul> ' ;
263
265
}
264
266
265
267
$ content .= '</div> ' ;
0 commit comments